diff --git a/src/common/ClientConnection.ts b/src/common/ClientConnection.ts index 7a22123..d0e3b13 100644 --- a/src/common/ClientConnection.ts +++ b/src/common/ClientConnection.ts @@ -387,6 +387,10 @@ export default class ClientConnection { ); } + public restartDevice() { + this.ws?.send(JSON.stringify(new Protocol.RestartDeviceRequestEntity())); + } + private _destoryed = false; public destory() { this._destoryed = true; diff --git a/src/components/RecoveryDatabaseDialog.vue b/src/components/RecoveryDatabaseDialog.vue new file mode 100644 index 0000000..a49a09e --- /dev/null +++ b/src/components/RecoveryDatabaseDialog.vue @@ -0,0 +1,204 @@ + + + + + diff --git a/src/entities/HttpProtocol.ts b/src/entities/HttpProtocol.ts index a108a83..b760ca3 100644 --- a/src/entities/HttpProtocol.ts +++ b/src/entities/HttpProtocol.ts @@ -1,9 +1,13 @@ export namespace HttpProtocol { export const DefaultHttpPort = 61429; export const RequestUploadFile = "/upload_file"; + export const RequestPathUpdateDBBackupFile = "/common/update_db_backup_file"; + export const RequestPathDBBackup = "/db_backup"; export const UploadTypeBackgroundImage = "U_T_BACKGROUND_IMAGE"; export const UploadTypeMedia = "U_T_MEDIA"; + export const HttpUploadTypeDatabase = "U_T_DATABASE"; + export const UploadTypeRootFS = "U_T_ROOT_FS"; export const kHeaderXFileLength = "X-File-Length"; diff --git a/src/entities/WSProtocol.ts b/src/entities/WSProtocol.ts index 00ba3ec..00503c4 100644 --- a/src/entities/WSProtocol.ts +++ b/src/entities/WSProtocol.ts @@ -93,6 +93,10 @@ export namespace Protocol { return Commands.PROTOCOL_PREFIX + "SetApplicationConfig"; } + public static get kRestartDeviceCommand() { + return Commands.PROTOCOL_PREFIX + "RestartDeviceCommand"; + } + static _all_commands = new Set([ Commands.kUnKnowCommand, Commands.kSearchDevice, @@ -500,4 +504,15 @@ export namespace Protocol { key: string = ""; value: string = ""; } + + export class RestartDeviceRequestEntity extends Protocol.PacketEntity { + timestamp: number; + constructor() { + super(); + this.timestamp = new Date().getUTCMilliseconds(); + this.command = Protocol.Commands.kRestartDeviceCommand; + this.flag = Protocol.PacketEntity.FLAG_REQUEST; + this.rpc_id = 0; + } + } } diff --git a/src/i18n/zh-CN/index.ts b/src/i18n/zh-CN/index.ts index 7fe3494..657ba5e 100644 --- a/src/i18n/zh-CN/index.ts +++ b/src/i18n/zh-CN/index.ts @@ -71,4 +71,9 @@ export default { "use this image to background image": "确定使用这张图片作为背景图片吗", "upload background image": "上传图片", "view current background image": "查看当前底图", + "select data(DBP) file": "选择数据(DBP)文件", + "use this file to recovery data": "使用这个文件恢复数据", + "data changes will take effect after the restart": "数据更改将在重启后生效", + "reboot now": "现在重启", + "reboot device command sended": "重启指令已发送", }; diff --git a/src/pages/TopToolBar.vue b/src/pages/TopToolBar.vue index 2b8752a..6299441 100644 --- a/src/pages/TopToolBar.vue +++ b/src/pages/TopToolBar.vue @@ -31,6 +31,7 @@ icon="backup" :label="$t('data import')" class="q-mr-sm" + @click="$refs.recovery_database_dialog.showDialog()" /> @@ -61,6 +63,7 @@ +