From ee37d680b273935c59c98fac2e58345949536314 Mon Sep 17 00:00:00 2001 From: fangxiang Date: Mon, 20 Feb 2023 18:57:23 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0GetHttpInterfaceVersion?= =?UTF-8?q?=E6=9D=A5=E6=A0=A1=E9=AA=8C=E5=85=BC=E5=AE=B9=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- quasar.conf.js | 3 +- src/App.vue | 50 ++++++++++++++-------------------- src/common/ClientConnection.ts | 16 +++++------ src/entities/WSProtocol.ts | 32 +++++++++++++++------- src/i18n/zh-CN/index.ts | 12 ++++---- 5 files changed, 58 insertions(+), 55 deletions(-) diff --git a/quasar.conf.js b/quasar.conf.js index 54c6d0a..9050962 100644 --- a/quasar.conf.js +++ b/quasar.conf.js @@ -43,7 +43,6 @@ module.exports = configure(function (ctx) { vueRouterMode: "hash", // available values: 'hash', 'history' // transpile: false, - // Add dependencies for transpiling with Babel (Array of string/regex) // (from node_modules, which are by default not transpiled). // Applies only if "transpile" is set to true. @@ -52,7 +51,7 @@ module.exports = configure(function (ctx) { // rtl: true, // https://v2.quasar.dev/options/rtl-support // preloadChunks: true, // showProgress: false, - // gzip: true, + gzip: true, // analyze: true, // Options below are automatically set depending on the env, set them if you want to override diff --git a/src/App.vue b/src/App.vue index db4b284..7ff6ab6 100644 --- a/src/App.vue +++ b/src/App.vue @@ -15,8 +15,8 @@ import GlobalData from "./common/GlobalData"; import { EProductNames } from "./entities/ProductNames"; import { api } from "./boot/axios"; import { WuJieInitializer } from "./common/WuJieInitializer"; -import { isNumber } from "zrender/lib/core/util"; import ClientConnection from "./common/ClientConnection"; +import { Common } from "./common/Common"; export default defineComponent({ name: "App", @@ -288,43 +288,35 @@ 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 {} - } + async (connection: ClientConnection) => { 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 !" + "Version Mismatch ! Please Upgrade The Software Again ! Otherwise, The File 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; + if (connection) { + let count = 0; + while ( + connection && + !connection.is_login && + count < (1000 * 10) / 100 /* 10 S */ + ) { + await Common.waitFor(100); + } + if (count < (1000 * 10) / 100) { + try { + const response = await connection.getHttpInterfaceVersion(); + if (!response || response.version != 2) { + show_version_tip(); } + } catch (e) { + show_version_tip(); } - show_version_tip(); - }) - .catch(() => { - show_version_tip(); - }); + } + } } ); diff --git a/src/common/ClientConnection.ts b/src/common/ClientConnection.ts index dadb8aa..68e9163 100644 --- a/src/common/ClientConnection.ts +++ b/src/common/ClientConnection.ts @@ -1343,6 +1343,12 @@ export default class ClientConnection { ); } + public async getHttpInterfaceVersion() { + return await this.doRpc( + new Protocol.RpcGetHttpInterfaceVersionRequestEntity() + ); + } + public async setJointActionEquipment( entity: JointActionEquipmentTableEntity ) { @@ -1551,19 +1557,13 @@ export default class ClientConnection { ); } - public async SetProjectorResolution( - width: number, - height: number - ) { + public async SetProjectorResolution(width: number, height: number) { return await this.doRpc( new Protocol.SetProjectorResolutionRequestEntity(width, height) ); } - public async SetProjectorLayout( - row: number, - column: number - ) { + public async SetProjectorLayout(row: number, column: number) { return await this.doRpc( new Protocol.SetProjectorResolutionRequestEntity(row, column) ); diff --git a/src/entities/WSProtocol.ts b/src/entities/WSProtocol.ts index 51852a8..52ca007 100644 --- a/src/entities/WSProtocol.ts +++ b/src/entities/WSProtocol.ts @@ -570,6 +570,9 @@ export namespace Protocol { public static get kRpcCheckModeIndex() { return Commands.PROTOCOL_PREFIX + "RpcCheckModeIndex"; } + public static get kRpcGetHttpInterfaceVersion() { + return Commands.PROTOCOL_PREFIX + "RpcGetHttpInterfaceVersion"; + } static _all_commands = new Set([ Commands.kUnKnowCommand, Commands.kSearchDevice, @@ -716,6 +719,7 @@ export namespace Protocol { Commands.kRpcFileManagerDelete, Commands.kRpcFileManagerCreateDirectory, Commands.kRpcCheckModeIndex, + Commands.kRpcGetHttpInterfaceVersion, ]); public static get AllCommands() { return this._all_commands; @@ -3682,11 +3686,7 @@ export namespace Protocol { } export class SetProjectorResolutionRequestEntity extends PacketEntity { - constructor( - width: number, - height: number, - rpc_id = 0 - ) { + constructor(width: number, height: number, rpc_id = 0) { super(); super.command = Commands.kSetProjectorResolution; super.flag = PacketEntity.FLAG_REQUEST; @@ -3701,11 +3701,7 @@ export namespace Protocol { } export class SetProjectorLayoutRequestEntity extends PacketEntity { - constructor( - row: number, - column: number, - rpc_id = 0 - ) { + constructor(row: number, column: number, rpc_id = 0) { super(); super.command = Commands.kSetProjectorResolution; super.flag = PacketEntity.FLAG_REQUEST; @@ -3827,4 +3823,20 @@ export namespace Protocol { } success = false; } + + export class RpcGetHttpInterfaceVersionRequestEntity extends PacketEntity { + constructor(rpc_id = 0) { + super(); + super.command = Commands.kRpcGetHttpInterfaceVersion; + super.flag = PacketEntity.FLAG_REQUEST; + } + timestamp = 0; + } + export class RpcGetHttpInterfaceVersionResponseEntity extends PacketEntity { + constructor() { + super(); + super.flag = PacketEntity.FLAG_RESPONSE; + } + version = 0; + } } diff --git a/src/i18n/zh-CN/index.ts b/src/i18n/zh-CN/index.ts index 95454f4..bea4f97 100644 --- a/src/i18n/zh-CN/index.ts +++ b/src/i18n/zh-CN/index.ts @@ -736,8 +736,8 @@ export default { "确定删除你将失去现在调整的数据", "Please enter the points you need to add": "请输入你所需要添加的点数", "Whether to add control points": "是否添加控制点", - "Reset all program control points":"重置全部方案控制点", - "Reset the current program control point":"重置当前方案控制点", + "Reset all program control points": "重置全部方案控制点", + "Reset the current program control point": "重置当前方案控制点", "device verify key": "设备校验码", "use wss": "使用Wss", "server address": "服务器地址", @@ -756,9 +756,9 @@ export default { "export magic": "导出", "raster graph": "栅格图", "the folder name cannot start with a '.'": "文件夹名称不能以“.” 开头", - "change resolution":"更改分辨率", - "Loading please wait":"加载中 请稍等" + "change resolution": "更改分辨率", + "Loading please wait": "加载中 请稍等", "Version Mismatch !": "版本不匹配!", - "Version Mismatch ! Please Upgrade The Software Again ! Otherwise, The File Upload Function Cannot Be Used !": - "版本不匹配!请重新升级软件!否则文件上传功能无法正常使用!", + "Version Mismatch ! Please Upgrade The Software Again ! Otherwise, The File Function Cannot Be Used !": + "版本不匹配!请重新升级软件!否则文件功能无法正常使用!", };