From d4e87d6764fd29d3854c9bd573a5f9c14ed4e7ac Mon Sep 17 00:00:00 2001 From: fangxiang Date: Wed, 9 Mar 2022 15:42:05 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=B3=A8=E5=86=8C=E5=AF=B9?= =?UTF-8?q?=E8=AF=9D=E6=A1=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 1 + src/common/ClientConnection.ts | 20 +++ src/components/RegisterDialog.vue | 236 ++++++++++++++++++++++++++++++ src/entities/WSProtocol.ts | 49 +++++++ src/i18n/zh-CN/index.ts | 4 + src/pages/Index.vue | 23 ++- yarn.lock | 5 + 7 files changed, 332 insertions(+), 6 deletions(-) create mode 100644 src/components/RegisterDialog.vue diff --git a/package.json b/package.json index 77c3a41..64014a3 100644 --- a/package.json +++ b/package.json @@ -16,6 +16,7 @@ "axios": "^0.21.1", "core-js": "^3.21.0", "element-resize-detector": "^1.2.4", + "qrcode.vue": "^3.3.3", "quasar": "^2.5.5", "reconnecting-websocket": "^4.4.0", "v-viewer": "^3.0.9", diff --git a/src/common/ClientConnection.ts b/src/common/ClientConnection.ts index 4dc7f38..aae2169 100644 --- a/src/common/ClientConnection.ts +++ b/src/common/ClientConnection.ts @@ -648,6 +648,26 @@ export default class ClientConnection { } } + public async getRegisterInfo() { + try { + return await this.doRpc( + new Protocol.GetRegisterInfoRequestEntity(0) + ); + } catch (e) { + console.error(e); + } + } + + public async registerDevice(register_code: string, active_code: string) { + try { + return await this.doRpc( + new Protocol.RegisterDeviceRequestEntity(register_code, active_code, 0) + ); + } catch (e) { + console.error(e); + } + } + public async setSubtitle(subtitle: SubtitleEntity) { try { return await this.doRpc( diff --git a/src/components/RegisterDialog.vue b/src/components/RegisterDialog.vue new file mode 100644 index 0000000..e42d5a7 --- /dev/null +++ b/src/components/RegisterDialog.vue @@ -0,0 +1,236 @@ + + + + + diff --git a/src/entities/WSProtocol.ts b/src/entities/WSProtocol.ts index 3d02544..75b86b8 100644 --- a/src/entities/WSProtocol.ts +++ b/src/entities/WSProtocol.ts @@ -228,6 +228,12 @@ export namespace Protocol { public static get kRpcGetSubtitle() { return Commands.PROTOCOL_PREFIX + "RpcGetSubtitle"; } + public static get kRpcGetRegisterInfo() { + return Commands.PROTOCOL_PREFIX + "RpcGetRegisterInfo"; + } + public static get kRpcRegisterDevice() { + return Commands.PROTOCOL_PREFIX + "RpcRegisterDevice"; + } public static get kRpcSetSubtitle() { return Commands.PROTOCOL_PREFIX + "RpcSetSubtitle"; @@ -383,6 +389,8 @@ export namespace Protocol { Commands.kRpcDeletePolling, Commands.kSetApplicationConfig, Commands.kRpcGetSubtitle, + Commands.kRpcGetRegisterInfo, + Commands.kRpcRegisterDevice, Commands.kRpcSetSubtitle, Commands.kRpcGetScreenSize, Commands.kScreenSizeChanged, @@ -1428,6 +1436,47 @@ export namespace Protocol { } } + export class GetRegisterInfoRequestEntity extends Protocol.PacketEntity { + timestamp: number = new Date().getMilliseconds(); + constructor(rcp_id?: number) { + super(); + this.rpc_id = rcp_id ?? 0; + this.command = Protocol.Commands.kRpcGetRegisterInfo; + } + } + + export class GetRegisterInfoResponseEntity extends Protocol.PacketEntity { + registered: boolean = false; + register_code: string = ""; + + constructor() { + super(); + this.command = Protocol.Commands.kRpcGetRegisterInfo; + } + } + + export class RegisterDeviceRequestEntity extends Protocol.PacketEntity { + timestamp: number = new Date().getMilliseconds(); + register_code: string = ""; + active_code: string = ""; + constructor(register_code: string, active_code: string, rcp_id?: number) { + super(); + this.rpc_id = rcp_id ?? 0; + this.command = Protocol.Commands.kRpcRegisterDevice; + this.register_code = register_code; + this.active_code = active_code; + } + } + + export class RegisterDeviceResponseEntity extends Protocol.PacketEntity { + success: boolean = false; + + constructor() { + super(); + this.command = Protocol.Commands.kRpcRegisterDevice; + } + } + export class SetSubtitleRequestEntity extends Protocol.PacketEntity { subtitle: SubtitleEntity = new SubtitleEntity(); constructor(rcp_id?: number, subtitle?: SubtitleEntity) { diff --git a/src/i18n/zh-CN/index.ts b/src/i18n/zh-CN/index.ts index 91eb75e..0d71ede 100644 --- a/src/i18n/zh-CN/index.ts +++ b/src/i18n/zh-CN/index.ts @@ -372,4 +372,8 @@ export default { "强制输出: 强制指定分辨率输出", "FOCEOUTPUT(CUSTOM): uses the specified timing output": "强制输出(自定义): 使用指定时序强制输出", + "register code": "注册码", + copy: "拷贝", + "register dialog": "注册对话框", + "active code": "激活码", }; diff --git a/src/pages/Index.vue b/src/pages/Index.vue index 728a488..f02bafd 100644 --- a/src/pages/Index.vue +++ b/src/pages/Index.vue @@ -3,10 +3,11 @@ + diff --git a/yarn.lock b/yarn.lock index 740d08a..9882a0c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6497,6 +6497,11 @@ pupa@^2.1.1: dependencies: escape-goat "^2.0.0" +qrcode.vue@^3.3.3: + version "3.3.3" + resolved "https://registry.npmmirror.com/qrcode.vue/-/qrcode.vue-3.3.3.tgz#00262244311a0ee1956fb7a0e238197ff7e14cfa" + integrity sha512-OsD4tQjIbxg/K6D5ZkWjBdYI9eg9K2i8qeYILdEAX5mdAydSAxV7xKmmZSP/hA12olLqEMZ9ryqDQrwa9jEMgw== + qs@6.7.0: version "6.7.0" resolved "https://registry.npmmirror.com/qs/download/qs-6.7.0.tgz#41dc1a015e3d581f1621776be31afb2876a9b1bc"