Skip to content

Commit

Permalink
feat: Page visibility settings
Browse files Browse the repository at this point in the history
  • Loading branch information
Ayideyia committed Jul 14, 2024
1 parent 0cb84da commit 3acfca6
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 8 deletions.
11 changes: 10 additions & 1 deletion frontend/src/components/NavigationBar.vue
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
<script setup lang="ts">
import { computed } from 'vue'
import { useI18n } from 'vue-i18n'
import rawRoutes from '@/router/routes'
import { useAppSettingsStore } from '@/stores'
const { t } = useI18n()
const appSettings = useAppSettingsStore()
const routes = rawRoutes.filter((r) => !r.meta?.hidden)
const routes = computed(() =>
rawRoutes.filter(
(r) =>
r.meta?.hidden === false ||
(!r.meta?.hidden && appSettings.app.pages.includes(r.name! as string))
)
)
</script>

<template>
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/lang/locale/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,9 @@ export default {
zh: '简体中文',
en: 'English'
},
pages: {
name: 'Page visibility'
},
windowState: {
normal: 'Normal window',
maximised: 'Maximised',
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/lang/locale/zh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,9 @@ export default {
zh: '简体中文',
en: 'English'
},
pages: {
name: '页面可见性'
},
windowState: {
normal: '以普通窗口启动',
maximised: '最大化',
Expand Down
9 changes: 5 additions & 4 deletions frontend/src/router/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -50,7 +50,7 @@ const routes: RouteRecordRaw[] = [
},
{
path: '/plugins',
name: 'PluginsView',
name: 'Plugins',
component: PluginsView,
meta: {
name: 'router.plugins',
Expand All @@ -59,7 +59,7 @@ const routes: RouteRecordRaw[] = [
},
{
path: '/scheduledtasks',
name: 'ScheduledTasksView',
name: 'ScheduledTasks',
component: ScheduledTasksView,
meta: {
name: 'router.scheduledtasks',
Expand All @@ -72,7 +72,8 @@ const routes: RouteRecordRaw[] = [
component: SettingsView,
meta: {
name: 'router.settings',
icon: 'settings2'
icon: 'settings2',
hidden: false
}
},
{
Expand Down
7 changes: 6 additions & 1 deletion frontend/src/stores/appSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ type AppSettings = {
githubApiToken: string
multipleInstance: boolean
rollingRelease: boolean
pages: string[]
}

export const useAppSettingsStore = defineStore('app-settings', () => {
Expand Down Expand Up @@ -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) => {
Expand All @@ -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)
Expand Down
15 changes: 13 additions & 2 deletions frontend/src/views/SettingsView/components/GeneralSetting.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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 = () => {
Expand Down Expand Up @@ -186,6 +193,10 @@ if (envStore.env.os === 'windows') {
<Input v-model="appSettings.app['font-family']" editable style="margin-left: 8px" />
</div>
</div>
<div class="settings-item">
<div class="title">{{ t('settings.pages.name') }}</div>
<CheckBox v-model="appSettings.app.pages" :options="pages" />
</div>
<div class="settings-item">
<div class="title">{{ t('settings.appFolder.name') }}</div>
<Button @click="handleOpenFolder" type="primary" icon="folder">
Expand Down

0 comments on commit 3acfca6

Please sign in to comment.