From 37bf4382ff4953ec5161449a4fc6a5788a6a9253 Mon Sep 17 00:00:00 2001 From: viarotel Date: Sun, 8 Dec 2024 21:18:26 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E2=99=BB=EF=B8=8F=20Refactor=20configu?= =?UTF-8?q?ration=20related=20code=20to=20improve=20stability?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- electron/main.js | 36 +++++---- src/App.vue | 19 ++--- src/components/PreferenceForm/index.vue | 10 +-- src/dicts/device/index.js | 12 +++ src/dicts/helper.js | 10 ++- src/dicts/index.js | 1 + src/locales/languages/zh-CN.json | 3 + src/pages/about/index.vue | 19 ++--- .../device/components/DevicePopover/index.vue | 32 ++++++++ .../device/components/WirelessGroup/index.vue | 34 +++++---- src/pages/device/index.vue | 73 ++++++++++++++----- src/pages/preference/index.vue | 4 - src/plugins/index.js | 2 + src/plugins/vue-screen/index.js | 7 ++ src/store/device/index.js | 1 + src/store/preference/helpers/index.js | 36 ++++----- src/store/preference/index.js | 15 +--- src/store/preference/model/audio/index.js | 1 + src/store/preference/model/device/index.js | 1 + src/store/preference/model/input/index.js | 1 + src/store/preference/model/record/index.js | 1 + src/store/preference/model/video/index.js | 1 + 22 files changed, 200 insertions(+), 119 deletions(-) create mode 100644 src/dicts/device/index.js create mode 100644 src/pages/device/components/DevicePopover/index.vue create mode 100644 src/plugins/vue-screen/index.js diff --git a/electron/main.js b/electron/main.js index d53ef2d..f48beca 100644 --- a/electron/main.js +++ b/electron/main.js @@ -61,14 +61,17 @@ let mainWindow function createWindow() { const bounds = appStore.get('common.bounds') || {} + const baseWidth = 640 + const baseHeight = Number((baseWidth / 1.57).toFixed()) + mainWindow = new BrowserWindow({ - icon: getLogoPath(), - show: false, - width: 768, - minWidth: 768, - height: 600, - minHeight: 450, + width: baseWidth, + minWidth: baseWidth, + height: baseHeight, + minHeight: baseHeight, ...bounds, + show: false, + icon: getLogoPath(), autoHideMenuBar: true, webPreferences: { preload: path.join(__dirname, 'preload.mjs'), @@ -81,21 +84,22 @@ function createWindow() { remote.enable(mainWindow.webContents) remote.initialize() - new Edger(mainWindow); + new Edger(mainWindow) mainWindow.on('ready-to-show', () => { mainWindow.show() }) - mainWindow.on('resize', () => { - if(mainWindow.isMaximized()) { - return false - } - - const bounds = mainWindow.getBounds(); - appStore.set('common.bounds', { - ...bounds, - isMaximized: false + ;['resize', 'move'].forEach((eventName) => { + mainWindow.on(eventName, () => { + if(mainWindow.isMaximized()) { + return false + } + + const bounds = mainWindow.getBounds() + appStore.set('common.bounds', { + ...bounds + }) }) }) diff --git a/src/App.vue b/src/App.vue index a7a9dee..c4009c9 100644 --- a/src/App.vue +++ b/src/App.vue @@ -1,5 +1,5 @@ @@ -12,7 +12,6 @@ import localeModel from '$/plugins/element-plus/locale.js' import { usePreferenceStore } from '$/store/preference/index.js' import { useThemeStore } from '$/store/theme/index.js' -import { useGrid } from 'vue-screen' import Layouts from './layouts/index.vue' @@ -24,16 +23,6 @@ const locale = computed(() => { return value }) -const grid = useGrid('tailwind') - -const size = computed(() => { - if (['sm', 'md'].includes(grid.breakpoint)) { - return 'small' - } - - return 'default' -}) - const themeStore = useThemeStore() const preferenceStore = usePreferenceStore() @@ -42,6 +31,12 @@ preferenceStore.init() showTips() +function getSize(grid) { + const value = ['sm', 'md'].includes(grid.breakpoint) ? 'small' : 'default' + + return value +} + async function showTips() { const { scrcpyPath } = window.electron?.configs || {} diff --git a/src/components/PreferenceForm/index.vue b/src/components/PreferenceForm/index.vue index 2798c63..ac0c88b 100644 --- a/src/components/PreferenceForm/index.vue +++ b/src/components/PreferenceForm/index.vue @@ -1,5 +1,5 @@