|
@@ -60,22 +60,27 @@ const postFile = (url: string, data: Record<string, any>) => {
|
|
|
);
|
|
|
};
|
|
|
|
|
|
-const login = () => {
|
|
|
+const login = (isBack = true) => {
|
|
|
if (import.meta.env.VITE_LOGIN_VIEW) {
|
|
|
- setTimeout(() => {
|
|
|
- location.replace(
|
|
|
- tempStrFill(import.meta.env.VITE_LOGIN_VIEW, {
|
|
|
+ const link = isBack
|
|
|
+ ? tempStrFill(import.meta.env.VITE_LOGIN_VIEW, {
|
|
|
redirect: escape(location.href),
|
|
|
})
|
|
|
- );
|
|
|
- }, 1000);
|
|
|
+ : import.meta.env.VITE_LOGIN_VIEW;
|
|
|
+ const url = new URL(link)
|
|
|
+ if (!isBack) {
|
|
|
+ url.searchParams.delete('redirect')
|
|
|
+ }
|
|
|
+ location.replace(url.toString());
|
|
|
}
|
|
|
};
|
|
|
|
|
|
const after = async (fet: Promise<Response>) => {
|
|
|
const res = await fet.then((res) => res.json());
|
|
|
if (res.code === 4008) {
|
|
|
- login();
|
|
|
+ setTimeout(() => {
|
|
|
+ login();
|
|
|
+ }, 1000);
|
|
|
throw res.message;
|
|
|
} else if (res.code !== 0) {
|
|
|
throw res.message;
|
|
@@ -84,7 +89,11 @@ const after = async (fet: Promise<Response>) => {
|
|
|
}
|
|
|
};
|
|
|
|
|
|
-const token = params.token;
|
|
|
+const token = (params.token || localStorage.getItem("token")) as string;
|
|
|
+if (!params.caseId || !token) {
|
|
|
+ login(!!params.caseId);
|
|
|
+}
|
|
|
+
|
|
|
const getSceneList = genLoading(async (keyword: string): Promise<Scene[]> => {
|
|
|
const list = await post(`fusion/case/sceneListPost`, {
|
|
|
caseId: params.caseId,
|