flat: 性能优化,招聘会时间筛选性能优化、精选企业性能优化,封装缓存request、indexDb方法,主要用于不常更新的接口,以达到毫秒级性能

This commit is contained in:
Apcallover
2025-11-29 16:31:34 +08:00
parent 636818361c
commit 63d0cdb5ad
10 changed files with 190 additions and 104 deletions

View File

@@ -50,10 +50,11 @@ function delCollectionCard(item) {
}
function getPremiumList() {
$api.createRequest('/app/company/card').then((resData) => {
const LoadCache = (resData) => {
const { rows, total } = resData;
list.value = rows;
});
};
$api.createRequestWithCache('/app/company/card', {}, 'GET', false, {}, LoadCache).then(LoadCache);
}
function seeDetail(item) {

View File

@@ -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() {