From 36c23deef81178b196b4a3fb2bb77e5b1f714cc5 Mon Sep 17 00:00:00 2001 From: tiny-craft <137850705+tiny-craft@users.noreply.github.com> Date: Sun, 20 Aug 2023 15:45:20 +0800 Subject: [PATCH] refactor: export theme overrides for discrete api --- frontend/src/App.vue | 29 ++++------------------------ frontend/src/utils/confirm_dialog.js | 7 ++++++- frontend/src/utils/message.js | 7 ++++++- frontend/src/utils/theme.js | 24 +++++++++++++++++++++++ 4 files changed, 40 insertions(+), 27 deletions(-) create mode 100644 frontend/src/utils/theme.js diff --git a/frontend/src/App.vue b/frontend/src/App.vue index 8d03b1f..6d81b69 100644 --- a/frontend/src/App.vue +++ b/frontend/src/App.vue @@ -18,35 +18,11 @@ import { useI18n } from 'vue-i18n' import { darkTheme, lightTheme, useOsTheme } from 'naive-ui' import KeyFilterDialog from './components/dialogs/KeyFilterDialog.vue' import { WindowSetDarkTheme, WindowSetLightTheme } from 'wailsjs/runtime/runtime.js' +import { themeOverrides } from '@/utils/theme.js' hljs.registerLanguage('json', json) hljs.registerLanguage('plaintext', plaintext) -/** - * - * @type import('naive-ui').GlobalThemeOverrides - */ -const themeOverrides = { - common: { - primaryColor: '#D33A31', - primaryColorHover: '#FF6B6B', - primaryColorPressed: '#D5271C', - primaryColorSuppl: '#FF6B6B', - borderRadius: '4px', - borderRadiusSmall: '3px', - lineHeight: 1.5, - scrollbarWidth: '8px', - }, - Tag: { - // borderRadius: '3px' - }, - Tabs: { - tabGapSmallCard: '1px', - tabGapMediumCard: '1px', - tabGapLargeCard: '1px', - }, -} - const prefStore = usePreferencesStore() const connectionStore = useConnectionStore() const i18n = useI18n() @@ -58,6 +34,9 @@ onBeforeMount(async () => { i18n.locale.value = prefStore.currentLanguage await prefStore.loadFontList() await connectionStore.initConnections() + if (prefStore.autoCheckUpdate) { + prefStore.checkForUpdate() + } } finally { initializing.value = false } diff --git a/frontend/src/utils/confirm_dialog.js b/frontend/src/utils/confirm_dialog.js index 4adc468..7ae1f19 100644 --- a/frontend/src/utils/confirm_dialog.js +++ b/frontend/src/utils/confirm_dialog.js @@ -1,7 +1,12 @@ import { createDiscreteApi } from 'naive-ui' import { i18nGlobal } from '@/utils/i18n.js' +import { themeOverrides } from '@/utils/theme.js' -const { dialog } = createDiscreteApi(['dialog']) +const { dialog } = createDiscreteApi(['dialog'], { + configProviderProps: { + themeOverrides, + }, +}) export function useConfirmDialog() { return { diff --git a/frontend/src/utils/message.js b/frontend/src/utils/message.js index 25e3709..078294e 100644 --- a/frontend/src/utils/message.js +++ b/frontend/src/utils/message.js @@ -1,6 +1,11 @@ import { createDiscreteApi } from 'naive-ui' +import { themeOverrides } from '@/utils/theme.js' -const { message } = createDiscreteApi(['message']) +const { message } = createDiscreteApi(['message'], { + configProviderProps: { + themeOverrides, + }, +}) export function useMessage() { return { diff --git a/frontend/src/utils/theme.js b/frontend/src/utils/theme.js new file mode 100644 index 0000000..1d56dd8 --- /dev/null +++ b/frontend/src/utils/theme.js @@ -0,0 +1,24 @@ +/** + * + * @type import('naive-ui').GlobalThemeOverrides + */ +export const themeOverrides = { + common: { + primaryColor: '#D33A31', + primaryColorHover: '#FF6B6B', + primaryColorPressed: '#D5271C', + primaryColorSuppl: '#FF6B6B', + borderRadius: '4px', + borderRadiusSmall: '3px', + lineHeight: 1.5, + scrollbarWidth: '8px', + }, + Tag: { + // borderRadius: '3px' + }, + Tabs: { + tabGapSmallCard: '1px', + tabGapMediumCard: '1px', + tabGapLargeCard: '1px', + }, +}