flat: 性能优化,招聘会时间筛选性能优化、精选企业性能优化,封装缓存request、indexDb方法,主要用于不常更新的接口,以达到毫秒级性能
This commit is contained in:
@@ -26,7 +26,7 @@
|
||||
<view
|
||||
class="item button-click"
|
||||
:class="{
|
||||
optional:hasZphInData(item),
|
||||
optional: item.isThisMonth && hasZphInData(item),
|
||||
noOptional: !item.isThisMonth,
|
||||
active: current.date === item.date && item.isThisMonth,
|
||||
}"
|
||||
@@ -60,10 +60,9 @@ const pages = reactive({
|
||||
month: 0,
|
||||
});
|
||||
|
||||
const hasZphDateArray = ref([])
|
||||
const hasZphDateArray = ref([]);
|
||||
|
||||
onLoad((options) => {
|
||||
updateDateArray()
|
||||
if (options.date) {
|
||||
current.value = {
|
||||
date: options?.date || null,
|
||||
@@ -81,20 +80,30 @@ onLoad((options) => {
|
||||
addMonth();
|
||||
});
|
||||
}
|
||||
if (options.entrance === 'careerfair') {
|
||||
updateDateArray();
|
||||
}
|
||||
});
|
||||
|
||||
function hasZphInData(item) {
|
||||
return hasZphDateArray.value.some(date=>date == item.date)
|
||||
if (!item || typeof item.date !== 'string') {
|
||||
return false;
|
||||
}
|
||||
|
||||
const dateArray = Array.isArray(hasZphDateArray.value) ? hasZphDateArray.value : [];
|
||||
|
||||
return dateArray.some((date) => {
|
||||
return typeof date === 'string' && date === item.date;
|
||||
});
|
||||
}
|
||||
|
||||
async function updateDateArray() {
|
||||
if(localStorage.getItem('hasZphDateArray')) hasZphDateArray.value = localStorage.getItem('hasZphDateArray')
|
||||
|
||||
let res = await $api.createRequest('/app/internal/getDateList', {}, 'get')
|
||||
if(res.data){
|
||||
hasZphDateArray.value = res.data
|
||||
localStorage.setItem('hasZphDateArray',res.data)
|
||||
}
|
||||
const LoadCache = (resData) => {
|
||||
if (resData.code === 200) {
|
||||
hasZphDateArray.value = resData.data;
|
||||
}
|
||||
};
|
||||
$api.createRequestWithCache('/app/internal/getDateList', {}, 'GET', false, {}, LoadCache).then(LoadCache);
|
||||
}
|
||||
|
||||
function backParams() {
|
||||
|
||||
Reference in New Issue
Block a user