From 95e48e75d34741fc0e64289c60c5a184371a2eda Mon Sep 17 00:00:00 2001 From: tiny-craft <137850705+tiny-craft@users.noreply.github.com> Date: Thu, 24 Aug 2023 00:44:19 +0800 Subject: [PATCH] perf: bind message and dialog to window --- frontend/package-lock.json | 12 ++-- frontend/src/App.vue | 28 +++------ .../src/components/content/ContentPane.vue | 4 +- .../content_value/ContentToolbar.vue | 12 ++-- .../content_value/ContentValueHash.vue | 14 ++--- .../content_value/ContentValueList.vue | 14 ++--- .../content_value/ContentValueSet.vue | 14 ++--- .../content_value/ContentValueStream.vue | 8 +-- .../content_value/ContentValueString.vue | 12 ++-- .../content_value/ContentValueZSet.vue | 16 +++-- .../components/dialogs/AddFieldsDialog.vue | 24 ++++---- .../components/dialogs/ConnectionDialog.vue | 6 +- .../components/dialogs/DeleteKeyDialog.vue | 6 +- .../src/components/dialogs/GroupDialog.vue | 12 ++-- .../src/components/dialogs/NewKeyDialog.vue | 8 +-- .../components/dialogs/PreferencesDialog.vue | 4 +- .../components/dialogs/RenameKeyDialog.vue | 8 +-- .../src/components/sidebar/BrowserTree.vue | 16 ++--- .../src/components/sidebar/ConnectionTree.vue | 16 ++--- frontend/src/main.js | 18 ++++-- frontend/src/stores/preferences.js | 24 +++++--- frontend/src/utils/confirm_dialog.js | 28 --------- frontend/src/utils/discrete.js | 60 +++++++++++++++++++ frontend/src/utils/message.js | 28 --------- 24 files changed, 182 insertions(+), 210 deletions(-) delete mode 100644 frontend/src/utils/confirm_dialog.js create mode 100644 frontend/src/utils/discrete.js delete mode 100644 frontend/src/utils/message.js diff --git a/frontend/package-lock.json b/frontend/package-lock.json index 748abe1..dfb3508 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -1090,9 +1090,9 @@ } }, "node_modules/immutable": { - "version": "4.3.2", - "resolved": "https://registry.npmmirror.com/immutable/-/immutable-4.3.2.tgz", - "integrity": "sha512-oGXzbEDem9OOpDWZu88jGiYCvIsLHMvGw+8OXlpsvTFvIQplQbjg1B1cvKg8f7Hoch6+NGjpPsH1Fr+Mc2D1aA==" + "version": "4.3.3", + "resolved": "https://registry.npmmirror.com/immutable/-/immutable-4.3.3.tgz", + "integrity": "sha512-808ZFYMsIRAjLAu5xkKo0TsbY9LBy9H5MazTKIEHerNkg0ymgilGfBPMR/3G7d/ihGmuK2Hw8S1izY2d3kd3wA==" }, "node_modules/is-binary-path": { "version": "2.1.0", @@ -2720,9 +2720,9 @@ "dev": true }, "immutable": { - "version": "4.3.2", - "resolved": "https://registry.npmmirror.com/immutable/-/immutable-4.3.2.tgz", - "integrity": "sha512-oGXzbEDem9OOpDWZu88jGiYCvIsLHMvGw+8OXlpsvTFvIQplQbjg1B1cvKg8f7Hoch6+NGjpPsH1Fr+Mc2D1aA==" + "version": "4.3.3", + "resolved": "https://registry.npmmirror.com/immutable/-/immutable-4.3.3.tgz", + "integrity": "sha512-808ZFYMsIRAjLAu5xkKo0TsbY9LBy9H5MazTKIEHerNkg0ymgilGfBPMR/3G7d/ihGmuK2Hw8S1izY2d3kd3wA==" }, "is-binary-path": { "version": "2.1.0", diff --git a/frontend/src/App.vue b/frontend/src/App.vue index ed54e4f..5564445 100644 --- a/frontend/src/App.vue +++ b/frontend/src/App.vue @@ -11,11 +11,11 @@ import AddFieldsDialog from './components/dialogs/AddFieldsDialog.vue' import AppContent from './AppContent.vue' import GroupDialog from './components/dialogs/GroupDialog.vue' import DeleteKeyDialog from './components/dialogs/DeleteKeyDialog.vue' -import { computed, onBeforeMount, ref } from 'vue' +import { onMounted, ref, watch } from 'vue' import usePreferencesStore from './stores/preferences.js' import useConnectionStore from './stores/connections.js' import { useI18n } from 'vue-i18n' -import { darkTheme, lightTheme, useOsTheme } from 'naive-ui' +import { darkTheme } from 'naive-ui' import KeyFilterDialog from './components/dialogs/KeyFilterDialog.vue' import { WindowSetDarkTheme, WindowSetLightTheme } from 'wailsjs/runtime/runtime.js' import { themeOverrides } from '@/utils/theme.js' @@ -27,12 +27,10 @@ const prefStore = usePreferencesStore() const connectionStore = useConnectionStore() const i18n = useI18n() const initializing = ref(false) -onBeforeMount(async () => { +onMounted(async () => { try { initializing.value = true - await prefStore.loadPreferences() i18n.locale.value = prefStore.currentLanguage - await prefStore.loadFontList() await connectionStore.initConnections() if (prefStore.autoCheckUpdate) { prefStore.checkForUpdate() @@ -42,27 +40,17 @@ onBeforeMount(async () => { } }) -const osTheme = useOsTheme() -const theme = computed(() => { - if (prefStore.general.theme === 'auto') { - if (osTheme.value === 'dark') { - WindowSetDarkTheme() - return darkTheme - } - } else if (prefStore.general.theme === 'dark') { - WindowSetDarkTheme() - return darkTheme - } - WindowSetLightTheme() - return lightTheme -}) +watch( + () => prefStore.isDark, + (isDark) => (isDark ? WindowSetDarkTheme() : WindowSetLightTheme()), +)