From 3acfca6ea3148f3c75c6a0a314f63a73810f7a61 Mon Sep 17 00:00:00 2001 From: Ayideyia <150233177+Ayideyia@users.noreply.github.com> Date: Sun, 14 Jul 2024 23:23:08 +0800 Subject: [PATCH] feat: Page visibility settings --- frontend/src/components/NavigationBar.vue | 11 ++++++++++- frontend/src/lang/locale/en.ts | 3 +++ frontend/src/lang/locale/zh.ts | 3 +++ frontend/src/router/routes.ts | 9 +++++---- frontend/src/stores/appSettings.ts | 7 ++++++- .../SettingsView/components/GeneralSetting.vue | 15 +++++++++++++-- 6 files changed, 40 insertions(+), 8 deletions(-) diff --git a/frontend/src/components/NavigationBar.vue b/frontend/src/components/NavigationBar.vue index bfe937f6..8c815030 100644 --- a/frontend/src/components/NavigationBar.vue +++ b/frontend/src/components/NavigationBar.vue @@ -1,11 +1,20 @@ diff --git a/frontend/src/lang/locale/en.ts b/frontend/src/lang/locale/en.ts index 6bb2fd6d..4d69eb24 100644 --- a/frontend/src/lang/locale/en.ts +++ b/frontend/src/lang/locale/en.ts @@ -529,6 +529,9 @@ export default { zh: '简体中文', en: 'English' }, + pages: { + name: 'Page visibility' + }, windowState: { normal: 'Normal window', maximised: 'Maximised', diff --git a/frontend/src/lang/locale/zh.ts b/frontend/src/lang/locale/zh.ts index 008416cd..ea532972 100644 --- a/frontend/src/lang/locale/zh.ts +++ b/frontend/src/lang/locale/zh.ts @@ -530,6 +530,9 @@ export default { zh: '简体中文', en: 'English' }, + pages: { + name: '页面可见性' + }, windowState: { normal: '以普通窗口启动', maximised: '最大化', diff --git a/frontend/src/router/routes.ts b/frontend/src/router/routes.ts index 86b75144..7e191f4d 100644 --- a/frontend/src/router/routes.ts +++ b/frontend/src/router/routes.ts @@ -14,7 +14,7 @@ import PlaygroundView from '@/views/PlaygroundView/index.vue' const routes: RouteRecordRaw[] = [ { path: '/', - name: 'Home', + name: 'Overview', component: HomeView, meta: { name: 'router.overview', @@ -50,7 +50,7 @@ const routes: RouteRecordRaw[] = [ }, { path: '/plugins', - name: 'PluginsView', + name: 'Plugins', component: PluginsView, meta: { name: 'router.plugins', @@ -59,7 +59,7 @@ const routes: RouteRecordRaw[] = [ }, { path: '/scheduledtasks', - name: 'ScheduledTasksView', + name: 'ScheduledTasks', component: ScheduledTasksView, meta: { name: 'router.scheduledtasks', @@ -72,7 +72,8 @@ const routes: RouteRecordRaw[] = [ component: SettingsView, meta: { name: 'router.settings', - icon: 'settings2' + icon: 'settings2', + hidden: false } }, { diff --git a/frontend/src/stores/appSettings.ts b/frontend/src/stores/appSettings.ts index 514aa298..4838f24a 100644 --- a/frontend/src/stores/appSettings.ts +++ b/frontend/src/stores/appSettings.ts @@ -52,6 +52,7 @@ type AppSettings = { githubApiToken: string multipleInstance: boolean rollingRelease: boolean + pages: string[] } export const useAppSettingsStore = defineStore('app-settings', () => { @@ -130,7 +131,8 @@ export const useAppSettingsStore = defineStore('app-settings', () => { pluginSettings: {}, githubApiToken: '', multipleInstance: false, - rollingRelease: false + rollingRelease: false, + pages: ['Overview', 'Profiles', 'Subscriptions', 'Plugins'] }) const saveAppSettings = debounce((config: string) => { @@ -142,6 +144,9 @@ export const useAppSettingsStore = defineStore('app-settings', () => { const data = await ignoredError(Readfile, 'data/user.yaml') data && (app.value = Object.assign(app.value, parse(data))) + // compatibility code + app.value.pages = app.value.pages ?? ['Overview', 'Profiles', 'Subscriptions', 'Plugins'] + firstOpen = !!data updateAppSettings(app.value) diff --git a/frontend/src/views/SettingsView/components/GeneralSetting.vue b/frontend/src/views/SettingsView/components/GeneralSetting.vue index 77dd4685..6b14621e 100644 --- a/frontend/src/views/SettingsView/components/GeneralSetting.vue +++ b/frontend/src/views/SettingsView/components/GeneralSetting.vue @@ -3,6 +3,7 @@ import { ref } from 'vue' import { useI18n } from 'vue-i18n' import { useMessage } from '@/hooks' +import routes from '@/router/routes' import { useAppSettingsStore, useEnvStore } from '@/stores' import { APP_TITLE, APP_VERSION, getTaskSchXmlString } from '@/utils' import { BrowserOpenURL, GetEnv, Writefile, Removefile, AbsolutePath } from '@/bridge' @@ -76,11 +77,17 @@ const langs = [ } ] +const pages = routes.flatMap((route) => { + if (route.meta?.hidden !== undefined) return [] + return { + label: route.meta!.name, + value: route.name as string + } +}) + const windowStates = [ { label: 'settings.windowState.normal', value: WindowStartState.Normal }, - // { label: 'settings.windowState.maximised', value: WindowStartState.Maximised }, { label: 'settings.windowState.minimised', value: WindowStartState.Minimised } - // { label: 'settings.windowState.fullscreen', value: WindowStartState.Fullscreen } ] const resetFontFamily = () => { @@ -186,6 +193,10 @@ if (envStore.env.os === 'windows') { + + {{ t('settings.pages.name') }} + + {{ t('settings.appFolder.name') }}