diff --git a/src/common/ClientConnection.ts b/src/common/ClientConnection.ts index ace81df..ab83d8a 100644 --- a/src/common/ClientConnection.ts +++ b/src/common/ClientConnection.ts @@ -443,20 +443,21 @@ export default class ClientConnection { } } - public async addMode(group_uuid?: string, name?: string) { + public async addMode(group_uuid?: string, name?: string, index?: number) { try { + console.log(index); return await this.doRpc( - new Protocol.AddModeRequestEntity(0, name, group_uuid) + new Protocol.AddModeRequestEntity(0, name, group_uuid, index) ); } catch (e) { console.error(e); } } - public async editMode(uuid?: string, name?: string) { + public async editMode(uuid?: string, name?: string, index?: number) { try { return await this.doRpc( - new Protocol.EditModeRequestEntity(0, name, uuid) + new Protocol.EditModeRequestEntity(0, name, uuid, index) ); } catch (e) { console.error(e); diff --git a/src/components/ModeDialog.vue b/src/components/ModeDialog.vue index af19702..e7e54e6 100644 --- a/src/components/ModeDialog.vue +++ b/src/components/ModeDialog.vue @@ -110,6 +110,32 @@ + + + + + + @@ -151,6 +177,8 @@ import { useStore } from "src/store"; import GlobalData from "src/common/GlobalData"; import { useQuasar } from "quasar"; import { useI18n } from "vue-i18n"; +import { api } from "boot/axios"; +import { HttpProtocol } from "src/entities/HttpProtocol"; export default defineComponent({ name: "ComponentModeDialog", @@ -163,6 +191,7 @@ export default defineComponent({ let show_dialog = ref(false); let type = ref(1); let name = ref(null); + let index = ref(0); let uuid = ref(""); const selected: any = ref(null); let loading = ref(false); @@ -184,7 +213,7 @@ export default defineComponent({ const requestAddMode = async () => { let response = await GlobalData.getInstance() .getCurrentClient() - ?.addMode(selected.value, name.value ?? ""); + ?.addMode(selected.value, name.value ?? "", index.value); if (response) { $q.notify({ color: response.success ? "positive" : "negative", @@ -202,7 +231,7 @@ export default defineComponent({ const requestEditMode = async () => { let response = await GlobalData.getInstance() .getCurrentClient() - ?.editMode(uuid.value, name.value ?? ""); + ?.editMode(uuid.value, name.value ?? "", index.value); if (response) { $q.notify({ color: response.success ? "positive" : "negative", @@ -221,6 +250,7 @@ export default defineComponent({ show_dialog, type, name, + index, uuid, selected, loading, @@ -233,6 +263,7 @@ export default defineComponent({ name.value = options.data?.name ?? null; selected.value = options.data?.item_data?.group_uuid ?? null; uuid.value = options.data?.item_data?.uuid ?? null; + index.value = options.data?.item_data?.number ?? 0; } else { selected.value = options.data?.uuid ?? null; uuid.value = options.data?.uuid ?? null; @@ -248,7 +279,37 @@ export default defineComponent({ treeNodesFilter(node: any, filter: any) { return node.is_group; }, - + checkIndex(val: number) { + return new Promise(async (resolve, reject) => { + if (val < 0) { + resolve($t.t("Please type 0~65535")); + } else { + try { + let url = GlobalData.getInstance().createCurrentRequestUrl(); + if (!url) { + url = new URL(window.location.hostname); + } + url.pathname = HttpProtocol.RequestCheckModeIndex; + url.searchParams.append("index", index.value.toString()); + let response = (await api.get(url.toString())).data as boolean; + if (typeof response != "boolean") { + try { + response = JSON.parse(response); + } catch { + response = false; + } + } + if (!response) { + resolve($t.t("index exised!")); + } else { + resolve(true); + } + } catch (e) { + resolve($t.t("check error")); + } + } + }); + }, async onSubmit() { loading.value = true; try { diff --git a/src/entities/HttpProtocol.ts b/src/entities/HttpProtocol.ts index c0bfd4b..82a57e4 100644 --- a/src/entities/HttpProtocol.ts +++ b/src/entities/HttpProtocol.ts @@ -7,6 +7,7 @@ export namespace HttpProtocol { export const RequestPathCreateDirectory = "/create_directory"; export const RequestPathDeleteFile = "/delete_file"; export const RequestPathRenameFile = "/rename_file"; + export const RequestCheckModeIndex = "/check_mode_index"; export const HttpUploadTypeNormal = "U_T_Normal"; export const UploadTypeBackgroundImage = "U_T_BACKGROUND_IMAGE"; diff --git a/src/entities/WSProtocol.ts b/src/entities/WSProtocol.ts index 473017f..8e3367c 100644 --- a/src/entities/WSProtocol.ts +++ b/src/entities/WSProtocol.ts @@ -692,12 +692,19 @@ export namespace Protocol { export class AddModeRequestEntity extends Protocol.PacketEntity { name: string; group_uuid: string; - constructor(rcp_id?: number, name?: string, group_uuid?: string) { + number: number; + constructor( + rcp_id?: number, + name?: string, + group_uuid?: string, + number?: number + ) { super(); this.rpc_id = rcp_id ?? 0; this.command = Protocol.Commands.kRpcAddMode; this.name = name ?? ""; this.group_uuid = group_uuid ?? ""; + this.number = number ?? 0; } } @@ -713,12 +720,19 @@ export namespace Protocol { export class EditModeRequestEntity extends Protocol.PacketEntity { name: string; uuid: string; - constructor(rcp_id?: number, name?: string, uuid?: string) { + number: number; + constructor( + rcp_id?: number, + name?: string, + uuid?: string, + number?: number + ) { super(); this.rpc_id = rcp_id ?? 0; this.command = Protocol.Commands.kRpcEditMode; this.name = name ?? ""; this.uuid = uuid ?? ""; + this.number = number ?? 0; } } diff --git a/src/pages/WallPage.vue b/src/pages/WallPage.vue index 1464792..e03b8a7 100644 --- a/src/pages/WallPage.vue +++ b/src/pages/WallPage.vue @@ -137,10 +137,6 @@ export default defineComponent({ const calcWallVWScaler = (wall_width: number, wall_height: number) => { if (wall.value && wall.value.parentElement) { - console.log($store.state.device_screen_width); - console.log($store.state.device_screen_height); - console.log(wall_width); - console.log(wall_height); wall_height_scaler.value = $store.state.device_screen_height / wall_height; wall_width_scaler.value = $store.state.device_screen_width / wall_width;