🎈 perf: 优化云盘缓存

This commit is contained in:
imsyy
2023-12-25 18:30:38 +08:00
parent eed76966c4
commit 8eaeffeda3
4 changed files with 7 additions and 10 deletions

View File

@@ -49,7 +49,7 @@ module.exports = {
$notification: true,
$changeThemeColor: true,
$canNotConnect: true,
$refreshCloudList: true,
$refreshCloudCatch: true,
$cleanAll: true,
},
};

1
components.d.ts vendored
View File

@@ -44,7 +44,6 @@ declare module 'vue' {
NGi: typeof import('naive-ui')['NGi']
NGlobalStyle: typeof import('naive-ui')['NGlobalStyle']
NGrid: typeof import('naive-ui')['NGrid']
NGridItem: typeof import('naive-ui')['NGridItem']
NH1: typeof import('naive-ui')['NH1']
NH3: typeof import('naive-ui')['NH3']
NH4: typeof import('naive-ui')['NH4']

View File

@@ -150,7 +150,7 @@ const setCloudSongMatchBtn = async (data) => {
allCloudSongs[cloudMatchIndex.value] = JSON.parse(JSON.stringify(cloudMatchSongData.value));
await indexedDB.setfilesDB("userCloudList", allCloudSongs.slice());
// 刷新列表
if (typeof $refreshCloudList !== "undefined") $refreshCloudList();
if (typeof $refreshCloudCatch !== "undefined") $refreshCloudCatch();
} catch (error) {
console.error("更改云盘列表时出错:", error);
$message.error("更改云盘列表时出错,请刷新后重试");

View File

@@ -104,10 +104,9 @@ const searchValue = ref(null);
const searchData = ref([]);
// 获取用户云盘缓存数据
const getUserCloudDataList = async () => {
await indexedDB.getfilesDB("userCloudList").then((res) => {
userCloudData.value = res;
});
const getUserCloudDataCatch = async () => {
const result = await indexedDB.getfilesDB("userCloudList");
userCloudData.value = result;
};
// 获取用户云盘列表
@@ -117,7 +116,6 @@ const getUserCloudData = async (isOnce = false) => {
let offset = 0;
let totalCount = null;
let resultArr = [];
userCloudData.value = [];
// 获取数据
while (totalCount === null || offset < totalCount) {
const res = await getUserCloud(100, offset);
@@ -191,12 +189,12 @@ const goBuy = () => {
};
onMounted(async () => {
await getUserCloudDataList();
await getUserCloudDataCatch();
await getUserCloudData();
});
onMounted(() => {
window.$refreshCloudList = getUserCloudDataList;
window.$refreshCloudCatch = getUserCloudDataCatch;
});
</script>