fix:转存报错没有提示

This commit is contained in:
jiangrui
2025-02-25 13:24:01 +08:00
parent 25ecdb1078
commit 5b701e499a
2 changed files with 14 additions and 9 deletions

View File

@@ -272,14 +272,14 @@ export const useResourceStore = defineStore("resource", {
}, },
// 获取资源列表并选择 // 获取资源列表并选择
async getResourceListAndSelect(resource: ResourceItem): Promise<void> { async getResourceListAndSelect(resource: ResourceItem): Promise<boolean> {
const { cloudType } = resource; const { cloudType } = resource;
const drive = CLOUD_DRIVES.find((x) => x.type === cloudType); const drive = CLOUD_DRIVES.find((x) => x.type === cloudType);
if (!drive) { if (!drive) {
return; return false;
} }
const link = resource.cloudLinks.find((link) => drive.regex.test(link)); const link = resource.cloudLinks.find((link) => drive.regex.test(link));
if (!link) return; if (!link) return false;
const match = link.match(drive.regex); const match = link.match(drive.regex);
if (!match) throw new Error("链接解析失败"); 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 { shareCode: string; receiveCode: string })
: await drive.api.getShareInfo(parsedCode as { pwdId: string }); : await drive.api.getShareInfo(parsedCode as { pwdId: string });
} }
this.setLoadTree(false);
if (shareInfo) { if (shareInfo) {
if (Array.isArray(shareInfo)) { if (Array.isArray(shareInfo)) {
shareInfo = { shareInfo = {
@@ -308,10 +309,13 @@ export const useResourceStore = defineStore("resource", {
...parsedCode, ...parsedCode,
}; };
} }
}
this.shareInfo = shareInfo; this.shareInfo = shareInfo;
this.setSelectedResource(this.shareInfo.list); this.setSelectedResource(this.shareInfo.list);
this.setLoadTree(false); return true;
} else {
ElMessage.error("获取资源信息失败,请先检查cookie!");
return false;
}
}, },
// 统一错误处理 // 统一错误处理

View File

@@ -117,11 +117,13 @@ const saveDialogMap = {
}, },
}; };
const handleSave = (resource: ResourceItem) => { const handleSave = async (resource: ResourceItem) => {
currentResource.value = resource; currentResource.value = resource;
saveDialogVisible.value = true; saveDialogVisible.value = true;
saveDialogStep.value = 1; saveDialogStep.value = 1;
resourceStore.getResourceListAndSelect(currentResource.value); if (!(await resourceStore.getResourceListAndSelect(currentResource.value))) {
saveDialogVisible.value = false;
}
}; };
const handleFolderSelect = async (folderId: string) => { const handleFolderSelect = async (folderId: string) => {
@@ -156,7 +158,6 @@ const handleLoadMore = (channelId: string) => {
}; };
const searchMovieforTag = (tag: string) => { const searchMovieforTag = (tag: string) => {
console.log("iiii");
router.push({ path: "/", query: { keyword: tag } }); router.push({ path: "/", query: { keyword: tag } });
}; };
</script> </script>