diff --git a/frontend/src/stores/resource.ts b/frontend/src/stores/resource.ts index 735516a..258ae38 100644 --- a/frontend/src/stores/resource.ts +++ b/frontend/src/stores/resource.ts @@ -272,14 +272,14 @@ export const useResourceStore = defineStore("resource", { }, // 获取资源列表并选择 - async getResourceListAndSelect(resource: ResourceItem): Promise { + async getResourceListAndSelect(resource: ResourceItem): Promise { const { cloudType } = resource; const drive = CLOUD_DRIVES.find((x) => x.type === cloudType); if (!drive) { - return; + return false; } const link = resource.cloudLinks.find((link) => drive.regex.test(link)); - if (!link) return; + if (!link) return false; const match = link.match(drive.regex); if (!match) throw new Error("链接解析失败"); @@ -296,6 +296,7 @@ export const useResourceStore = defineStore("resource", { ? await drive.api.getShareInfo(parsedCode as { shareCode: string; receiveCode: string }) : await drive.api.getShareInfo(parsedCode as { pwdId: string }); } + this.setLoadTree(false); if (shareInfo) { if (Array.isArray(shareInfo)) { shareInfo = { @@ -308,10 +309,13 @@ export const useResourceStore = defineStore("resource", { ...parsedCode, }; } + this.shareInfo = shareInfo; + this.setSelectedResource(this.shareInfo.list); + return true; + } else { + ElMessage.error("获取资源信息失败,请先检查cookie!"); + return false; } - this.shareInfo = shareInfo; - this.setSelectedResource(this.shareInfo.list); - this.setLoadTree(false); }, // 统一错误处理 diff --git a/frontend/src/views/ResourceList.vue b/frontend/src/views/ResourceList.vue index 059692d..5e7c3f9 100644 --- a/frontend/src/views/ResourceList.vue +++ b/frontend/src/views/ResourceList.vue @@ -117,11 +117,13 @@ const saveDialogMap = { }, }; -const handleSave = (resource: ResourceItem) => { +const handleSave = async (resource: ResourceItem) => { currentResource.value = resource; saveDialogVisible.value = true; saveDialogStep.value = 1; - resourceStore.getResourceListAndSelect(currentResource.value); + if (!(await resourceStore.getResourceListAndSelect(currentResource.value))) { + saveDialogVisible.value = false; + } }; const handleFolderSelect = async (folderId: string) => { @@ -156,7 +158,6 @@ const handleLoadMore = (channelId: string) => { }; const searchMovieforTag = (tag: string) => { - console.log("iiii"); router.push({ path: "/", query: { keyword: tag } }); };