From fa2f8c76cf82b384b035bae1d411f672c968746d Mon Sep 17 00:00:00 2001 From: fangxiang Date: Tue, 18 Jan 2022 16:09:15 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=A4=9A=E5=AA=92=E4=BD=93?= =?UTF-8?q?=E6=8E=A7=E5=88=B6=E7=BB=84=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/common/ClientConnection.ts | 42 ++++-- src/components/SignalSourceDialog.vue | 37 ++++- src/components/Window.vue | 1 + src/entities/MultimediaWindowEntity.ts | 2 +- src/entities/WSProtocol.ts | 64 ++++++++ src/layouts/MainLayout.vue | 13 +- src/pages/Index.vue | 6 +- src/pages/MediaControlPage.vue | 199 +++++++++++++++++++++++++ src/pages/WallPage.vue | 12 ++ src/store/index.ts | 5 + 10 files changed, 362 insertions(+), 19 deletions(-) create mode 100644 src/pages/MediaControlPage.vue diff --git a/src/common/ClientConnection.ts b/src/common/ClientConnection.ts index 90e0aaa..e5cdee9 100644 --- a/src/common/ClientConnection.ts +++ b/src/common/ClientConnection.ts @@ -626,24 +626,46 @@ export default class ClientConnection { } } public async setWindowVolume(window_id: number, volume: number) { - try { - return await this.doRpc( + this.ws?.send( + JSON.stringify( new Protocol.SetWindowVolumeRequestEntity(window_id, volume, 0) - ); - } catch (e) { - console.error(e); - } + ) + ); } public async unmuteWindow(window_id: number) { - return await this.doRpc( - new Protocol.UnMuteWindowRequestEntity(window_id, 0) + this.ws?.send( + JSON.stringify(new Protocol.UnMuteWindowRequestEntity(window_id, 0)) ); } public async muteWindow(window_id: number) { - return await this.doRpc( - new Protocol.MuteWindowRequestEntity(window_id, 0) + this.ws?.send( + JSON.stringify(new Protocol.MuteWindowRequestEntity(window_id, 0)) + ); + } + + public async playWindow(window_id: number) { + this.ws?.send( + JSON.stringify(new Protocol.PlayWindowRequestEntity(window_id, 0)) + ); + } + + public async windowPlayNext(window_id: number) { + this.ws?.send( + JSON.stringify(new Protocol.WindowPlayNextRequestEntity(window_id, 0)) + ); + } + + public async windowPlayPrev(window_id: number) { + this.ws?.send( + JSON.stringify(new Protocol.WindowPlayPrevRequestEntity(window_id, 0)) + ); + } + + public async pauseWindow(window_id: number) { + this.ws?.send( + JSON.stringify(new Protocol.PauseWindowRequestEntity(window_id, 0)) ); } diff --git a/src/components/SignalSourceDialog.vue b/src/components/SignalSourceDialog.vue index 168d7bc..0219a8e 100644 --- a/src/components/SignalSourceDialog.vue +++ b/src/components/SignalSourceDialog.vue @@ -140,7 +140,12 @@ :loading="loading" :disable="loading" filled - @dblclick="showPlaylistDialog()" + @dblclick=" + media_url_label.startsWith($t('file path')) && + item_data.window_type == 'EwindowType::Image' + ? doSelectFile() + : showPlaylistDialog() + " v-model="item_data.media_url" :readonly="media_url_label.startsWith($t('file path'))" :label="media_url_label" @@ -258,6 +263,7 @@ + @@ -284,12 +290,13 @@ import GlobalData from "src/common/GlobalData"; import { useQuasar } from "quasar"; import { useI18n } from "vue-i18n"; import { SignalSourceEntity } from "src/entities/SignalSourceEntity"; - +import FileManageDialog from "src/components/FileManageDialog.vue"; import PlaylistDialog from "src/components/PlaylistDialog.vue"; +import FileEntity from "src/entities/FileEntity"; export default defineComponent({ name: "ComponentSignalSourceDialog", - components: { PlaylistDialog }, + components: { FileManageDialog, PlaylistDialog }, setup() { let $store = useStore(); @@ -304,6 +311,7 @@ export default defineComponent({ const selected: any = ref(null); let loading = ref(false); let playlist_dialog: any = ref(null); + let file_manage_dialog: any = ref(null); let suppored_window_types = new Set([ "EwindowType::Multimedia", @@ -417,6 +425,7 @@ export default defineComponent({ loading, tree_nodes, playlist_dialog, + file_manage_dialog, showDialog(options: any) { if (options) { type.value = options.type ?? 1; @@ -469,6 +478,28 @@ export default defineComponent({ item_data.media_url = decodeURI(result); } }, + async doSelectFile() { + if (!media_url_label.value.startsWith($t.t("file path"))) { + return; + } + const obj = await file_manage_dialog.value.showDialogAsync("select"); + if (obj) { + interface __I { + path: string; + file: FileEntity; + } + let { path, file }: __I = obj; + if (path && file) { + item_data.media_url = path + "/" + file.name; + + if (item_data.name.trim() == "") { + nextTick(() => { + item_data.name = file.name; + }); + } + } + } + }, }; }, }); diff --git a/src/components/Window.vue b/src/components/Window.vue index dc4d2a4..5d1b02a 100644 --- a/src/components/Window.vue +++ b/src/components/Window.vue @@ -369,6 +369,7 @@ export default defineComponent({ } focused.value = newValue.focus; selected.value = old; + $store.commit("setSelectedWindow", props.window.uuid); } } ); diff --git a/src/entities/MultimediaWindowEntity.ts b/src/entities/MultimediaWindowEntity.ts index c4acdeb..c290308 100644 --- a/src/entities/MultimediaWindowEntity.ts +++ b/src/entities/MultimediaWindowEntity.ts @@ -11,7 +11,7 @@ export class MultimediaWindowEntity extends BaseEntity { volume: number = 80; muted: boolean = false; - paused: boolean = false; + playing: boolean = false; play_speed: number = 1; } diff --git a/src/entities/WSProtocol.ts b/src/entities/WSProtocol.ts index 13eebfd..cf5a1c4 100644 --- a/src/entities/WSProtocol.ts +++ b/src/entities/WSProtocol.ts @@ -240,6 +240,22 @@ export namespace Protocol { return Commands.PROTOCOL_PREFIX + "FanTemperature"; } + public static get kPlayWindow() { + return Commands.PROTOCOL_PREFIX + "PlayWindow"; + } + + public static get kPauseWindow() { + return Commands.PROTOCOL_PREFIX + "PauseWindow"; + } + + public static get kWindowPlayNext() { + return Commands.PROTOCOL_PREFIX + "PlayNext"; + } + + public static get kWindowPlayPrev() { + return Commands.PROTOCOL_PREFIX + "PlayPrev"; + } + static _all_commands = new Set([ Commands.kUnKnowCommand, Commands.kSearchDevice, @@ -295,6 +311,10 @@ export namespace Protocol { Commands.kUnMuteWidow, Commands.kRpcGetBuildInfo, Commands.kFanTemperature, + Commands.kWindowPlayPrev, + Commands.kWindowPlayNext, + Commands.kPauseWindow, + Commands.kPlayWindow, ]); public static get AllCommands() { @@ -1383,6 +1403,50 @@ export namespace Protocol { } } + export class PlayWindowRequestEntity extends Protocol.PacketEntity { + window_id: number; + + constructor(window_id: number, rcp_id?: number) { + super(); + this.rpc_id = rcp_id ?? 0; + this.command = Protocol.Commands.kPlayWindow; + this.window_id = window_id; + } + } + + export class WindowPlayNextRequestEntity extends Protocol.PacketEntity { + window_id: number; + + constructor(window_id: number, rcp_id?: number) { + super(); + this.rpc_id = rcp_id ?? 0; + this.command = Protocol.Commands.kWindowPlayNext; + this.window_id = window_id; + } + } + + export class WindowPlayPrevRequestEntity extends Protocol.PacketEntity { + window_id: number; + + constructor(window_id: number, rcp_id?: number) { + super(); + this.rpc_id = rcp_id ?? 0; + this.command = Protocol.Commands.kWindowPlayPrev; + this.window_id = window_id; + } + } + + export class PauseWindowRequestEntity extends Protocol.PacketEntity { + window_id: number; + + constructor(window_id: number, rcp_id?: number) { + super(); + this.rpc_id = rcp_id ?? 0; + this.command = Protocol.Commands.kPauseWindow; + this.window_id = window_id; + } + } + export class UnMuteWindowRequestEntity extends Protocol.PacketEntity { window_id: number; diff --git a/src/layouts/MainLayout.vue b/src/layouts/MainLayout.vue index 9d9773e..4f8156e 100644 --- a/src/layouts/MainLayout.vue +++ b/src/layouts/MainLayout.vue @@ -2,7 +2,11 @@
- + @@ -21,6 +25,7 @@ } } " + @click="(evt) => evt.stopPropagation()" >
@@ -42,8 +47,12 @@ } } " + @click="(evt) => evt.stopPropagation()" > - + diff --git a/src/pages/Index.vue b/src/pages/Index.vue index 17d23ad..e37bcab 100644 --- a/src/pages/Index.vue +++ b/src/pages/Index.vue @@ -1,25 +1,25 @@ diff --git a/src/pages/WallPage.vue b/src/pages/WallPage.vue index 8c84170..4405d39 100644 --- a/src/pages/WallPage.vue +++ b/src/pages/WallPage.vue @@ -278,6 +278,18 @@ export default defineComponent({ notify.data ) as WindowOtherStateChangeNotifyEntity; if (temp && temp.window_id) { + if (temp.focus) { + for (const window of $store.state.windows) { + if (window) { + $store.commit("setWindowProperty", { + window, + property_name: "focus", + value: false, + }); + } + } + } + const window = $store.state.windows.find( (item) => item.window_id == temp.window_id ); diff --git a/src/store/index.ts b/src/store/index.ts index 41131d1..36f7dad 100644 --- a/src/store/index.ts +++ b/src/store/index.ts @@ -41,6 +41,7 @@ export interface StateInterface { device_ip_address: string; power_on_plan: string; fan_temp: number; + selected_window: string; } // provide typings for `this.$store` @@ -268,6 +269,7 @@ export default store(function (/* { ssrContext } */) { device_ip_address: "localhost", power_on_plan: "", fan_temp: 0, + selected_window: "", }, mutations: { @@ -641,6 +643,9 @@ export default store(function (/* { ssrContext } */) { state.fan_temp = f; } }, + setSelectedWindow(state: StateInterface, playload?: any) { + state.selected_window = playload; + }, }, // enable strict mode (adds overhead!)