增加http接口兼容判断

This commit is contained in:
fangxiang 2023-02-16 10:42:58 +08:00
parent a4c3a24dda
commit 00c4056b5d
2 changed files with 47 additions and 0 deletions

View File

@ -15,6 +15,8 @@ import GlobalData from "./common/GlobalData";
import { EProductNames } from "./entities/ProductNames"; import { EProductNames } from "./entities/ProductNames";
import { api } from "./boot/axios"; import { api } from "./boot/axios";
import { WuJieInitializer } from "./common/WuJieInitializer"; import { WuJieInitializer } from "./common/WuJieInitializer";
import { isNumber } from "zrender/lib/core/util";
import ClientConnection from "./common/ClientConnection";
export default defineComponent({ export default defineComponent({
name: "App", name: "App",
@ -284,6 +286,48 @@ export default defineComponent({
}); });
} }
EventBus.getInstance().on(
EventNamesDefine.CurrentConnectConnected,
(connection: ClientConnection) => {
let final_url = "/get_interface_version";
if (connection) {
try {
const current_http_url = new URL(window.location.toString());
const current_ws_url = new URL(connection.url);
current_http_url.hostname = current_ws_url.hostname;
current_http_url.pathname = "/get_interface_version";
current_http_url.port = "80";
final_url = current_http_url.toString();
} catch {}
}
const show_version_tip = () =>
$q.dialog({
persistent: true,
title: $t.t("Version Mismatch !"),
message: $t.t(
"Version Mismatch ! Please Upgrade The Software Again ! Otherwise, The File Upload Function Cannot Be Used !"
),
});
interface _GetInterfaceVersionResponse {
version: number;
}
api
.get(final_url)
.then((data) => {
if (data) {
const verson = data.data as _GetInterfaceVersionResponse;
if (verson && verson.version == 2) {
return;
}
}
show_version_tip();
})
.catch(() => {
show_version_tip();
});
}
);
return {}; return {};
}, },
}); });

View File

@ -758,4 +758,7 @@ export default {
"the folder name cannot start with a '.'": "文件夹名称不能以“.” 开头", "the folder name cannot start with a '.'": "文件夹名称不能以“.” 开头",
"change resolution":"更改分辨率", "change resolution":"更改分辨率",
"Loading please wait":"加载中 请稍等" "Loading please wait":"加载中 请稍等"
"Version Mismatch !": "版本不匹配!",
"Version Mismatch ! Please Upgrade The Software Again ! Otherwise, The File Upload Function Cannot Be Used !":
"版本不匹配!请重新升级软件!否则文件上传功能无法正常使用!",
}; };