|
@@ -70,6 +70,7 @@ export const useMainStore = defineStore("MainStoreId", {
|
|
await this.logOut();
|
|
await this.logOut();
|
|
}
|
|
}
|
|
} catch (err) {
|
|
} catch (err) {
|
|
|
|
+ this.addNotification({ content: i18n.global.t("loggedError"), color: "error" });
|
|
this.setLogInError(true);
|
|
this.setLogInError(true);
|
|
await this.logOut();
|
|
await this.logOut();
|
|
}
|
|
}
|
|
@@ -188,6 +189,7 @@ export const useMainStore = defineStore("MainStoreId", {
|
|
router.push("/login")
|
|
router.push("/login")
|
|
}, 2000)
|
|
}, 2000)
|
|
} catch (error) {
|
|
} catch (error) {
|
|
|
|
+ this.addNotification({ content: i18n.global.t("registerError"), color: "error" });
|
|
await this.checkApiError(error);
|
|
await this.checkApiError(error);
|
|
}
|
|
}
|
|
},
|
|
},
|
|
@@ -272,7 +274,8 @@ export const useMainStore = defineStore("MainStoreId", {
|
|
file_name: file[i].name,
|
|
file_name: file[i].name,
|
|
stored_file_name: element,
|
|
stored_file_name: element,
|
|
content: "sr",
|
|
content: "sr",
|
|
- state: "subscribe"
|
|
|
|
|
|
+ state: "subscribe",
|
|
|
|
+ link: ""
|
|
};
|
|
};
|
|
this.addImage(tmpImage);
|
|
this.addImage(tmpImage);
|
|
}
|
|
}
|
|
@@ -289,38 +292,42 @@ export const useMainStore = defineStore("MainStoreId", {
|
|
await mainStore.checkApiError(error);
|
|
await mainStore.checkApiError(error);
|
|
}
|
|
}
|
|
},
|
|
},
|
|
- async getImage(data: ImageDownload) {
|
|
|
|
- const mainStore = useMainStore();
|
|
|
|
- try {
|
|
|
|
- const response = (
|
|
|
|
- await Promise.all([
|
|
|
|
- api.getImage(mainStore.token, data),
|
|
|
|
- await new Promise<void>((resolve, _) => setTimeout(() => resolve(), 0)),
|
|
|
|
- ])
|
|
|
|
- );
|
|
|
|
- } catch (error) {
|
|
|
|
- await mainStore.checkApiError(error);
|
|
|
|
- }
|
|
|
|
- },
|
|
|
|
|
|
+ // async getImage(data: ImageDownload) {
|
|
|
|
+ // const mainStore = useMainStore();
|
|
|
|
+ // try {
|
|
|
|
+ // const response = (
|
|
|
|
+ // await Promise.all([
|
|
|
|
+ // api.getImage(mainStore.token, data),
|
|
|
|
+ // await new Promise<void>((resolve, _) => setTimeout(() => resolve(), 0)),
|
|
|
|
+ // ])
|
|
|
|
+ // );
|
|
|
|
+ // } catch (error) {
|
|
|
|
+ // await mainStore.checkApiError(error);
|
|
|
|
+ // }
|
|
|
|
+ // },
|
|
addImage(payload: Image) {
|
|
addImage(payload: Image) {
|
|
this.images.push(payload);
|
|
this.images.push(payload);
|
|
},
|
|
},
|
|
- finishImage(payload: string) {
|
|
|
|
|
|
+ async finishImage(payload: ImageDownload) {
|
|
const WS = new WebSocket(`${wsUrl}/api/v1/images/sr`);
|
|
const WS = new WebSocket(`${wsUrl}/api/v1/images/sr`);
|
|
let image = this.images.filter(e => {
|
|
let image = this.images.filter(e => {
|
|
- return payload.includes(e.stored_file_name)
|
|
|
|
|
|
+ return payload.stored_file_name.includes(e.stored_file_name)
|
|
});
|
|
});
|
|
-
|
|
|
|
- if (image) {
|
|
|
|
- image.map(e => {
|
|
|
|
- e.state = "completed";
|
|
|
|
- })
|
|
|
|
|
|
+ const mainStore = useMainStore();
|
|
|
|
+ try {
|
|
|
|
+ const response = await api.downloadImage(mainStore.token, payload);
|
|
|
|
+ if (image) {
|
|
|
|
+ image.map(e => {
|
|
|
|
+ e.state = "completed";
|
|
|
|
+ e.link = response.data;
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ } catch (error) {
|
|
|
|
+ await mainStore.checkApiError(error);
|
|
}
|
|
}
|
|
|
|
|
|
// 全部完成後回傳 WebSocket
|
|
// 全部完成後回傳 WebSocket
|
|
let processing = this.images.find(e => e.state !== "completed");
|
|
let processing = this.images.find(e => e.state !== "completed");
|
|
- console.log('processing', processing);
|
|
|
|
-
|
|
|
|
if (!processing) {
|
|
if (!processing) {
|
|
setTimeout(() => {
|
|
setTimeout(() => {
|
|
// WS.close();
|
|
// WS.close();
|