mirror of
https://github.com/XiaoDaiGua-Ray/ray-template.git
synced 2026-11-27 23:13:38 +08:00
feat(settings): redesign the preferences drawer
This commit is contained in:
parent
8786da60fb
commit
41ad0b5292
@ -29,10 +29,8 @@
|
||||
position: relative;
|
||||
box-sizing: border-box;
|
||||
display: grid;
|
||||
grid-template-rows: minmax(0, 1fr) auto;
|
||||
place-items: center;
|
||||
align-self: start;
|
||||
gap: 3px;
|
||||
min-inline-size: 0;
|
||||
min-block-size: 0;
|
||||
inline-size: 100%;
|
||||
@ -75,7 +73,7 @@
|
||||
display: grid;
|
||||
grid-template: minmax(0, 1fr) minmax(0, 3fr) / minmax(0, 1fr) minmax(0, 3fr);
|
||||
gap: 3px;
|
||||
block-size: min(100%, 42px);
|
||||
block-size: min(68%, 60px);
|
||||
max-inline-size: 100%;
|
||||
aspect-ratio: 1;
|
||||
padding: 4px;
|
||||
|
||||
@ -15,7 +15,7 @@ import {
|
||||
|
||||
export default defineComponent({
|
||||
name: 'LayoutSettings',
|
||||
props: { showDescription: { type: Boolean, default: true } },
|
||||
props: { showDescription: { type: Boolean, default: false } },
|
||||
setup(props) {
|
||||
const { t } = useI18n('layout')
|
||||
const { getLayoutConfig } = useSettingGetters()
|
||||
@ -36,6 +36,8 @@ export default defineComponent({
|
||||
type="button"
|
||||
class="r-layout-preset"
|
||||
key={mode}
|
||||
aria-label={text(mode)}
|
||||
title={text(mode)}
|
||||
aria-pressed={getLayoutConfig.value.mode === mode}
|
||||
onClick={() => update({ mode })}
|
||||
>
|
||||
@ -47,7 +49,6 @@ export default defineComponent({
|
||||
<span class="r-layout-preview__aside" />
|
||||
<span class="r-layout-preview__body" />
|
||||
</span>
|
||||
<span>{text(mode)}</span>
|
||||
{getLayoutConfig.value.mode === mode ? (
|
||||
<span class="r-layout-preset__selected" aria-hidden="true">
|
||||
✓
|
||||
@ -55,9 +56,11 @@ export default defineComponent({
|
||||
) : null}
|
||||
</button>
|
||||
))}
|
||||
<p class="r-layout-settings__hint">
|
||||
{text(`modeHint.${getLayoutConfig.value.mode}`)}
|
||||
</p>
|
||||
{props.showDescription ? (
|
||||
<p class="r-layout-settings__hint">
|
||||
{text(`modeHint.${getLayoutConfig.value.mode}`)}
|
||||
</p>
|
||||
) : null}
|
||||
</div>
|
||||
<NForm labelPlacement="top" showFeedback={false}>
|
||||
<NFormItem label={text('contentWidth')}>
|
||||
|
||||
@ -0,0 +1,14 @@
|
||||
export default defineComponent({
|
||||
name: 'SettingsSection',
|
||||
props: { title: { type: String, required: true } },
|
||||
setup(props, { slots }) {
|
||||
const id = useId()
|
||||
|
||||
return () => (
|
||||
<section class="r-settings-section" aria-labelledby={id}>
|
||||
<h3 id={id}>{props.title}</h3>
|
||||
{slots.default?.()}
|
||||
</section>
|
||||
)
|
||||
},
|
||||
})
|
||||
@ -1,4 +1,5 @@
|
||||
import { RIcon, RSegment } from '@/components'
|
||||
import { useI18n } from '@/hooks'
|
||||
import { useSettingActions, useSettingGetters } from '@/store'
|
||||
import type { SettingState } from '@/store/modules/setting/types'
|
||||
import { useColorMode } from '@vueuse/core'
|
||||
@ -7,25 +8,26 @@ export default defineComponent({
|
||||
name: 'ThemeSegment',
|
||||
setup() {
|
||||
const { system } = useColorMode()
|
||||
const { t } = useI18n('preferences')
|
||||
const { getAppThemeStr, getAppTheme } = useSettingGetters()
|
||||
const { updateSettingState } = useSettingActions()
|
||||
const options = [
|
||||
const options = computed(() => [
|
||||
{
|
||||
label: '深色',
|
||||
label: t('theme.dark'),
|
||||
key: 'dark',
|
||||
icon: () => <RIcon name="system/dark" size="16" />,
|
||||
},
|
||||
{
|
||||
label: '浅色',
|
||||
label: t('theme.light'),
|
||||
key: 'light',
|
||||
icon: () => <RIcon name="system/light" size="16" />,
|
||||
},
|
||||
{
|
||||
label: '自动',
|
||||
label: t('theme.auto'),
|
||||
key: 'auto',
|
||||
icon: () => <RIcon name="system/system_os" size="16" />,
|
||||
},
|
||||
]
|
||||
])
|
||||
const modelAppTheme = computed({
|
||||
get: () => {
|
||||
if (getAppThemeStr.value === 'auto') {
|
||||
|
||||
@ -1,11 +0,0 @@
|
||||
import type { SettingState } from '@/store/modules/setting/types'
|
||||
import type { DebouncedFunc } from 'lodash-es'
|
||||
import type { InjectionKey, Reactive } from 'vue'
|
||||
|
||||
interface SettingDrawerInjectKey extends SettingState {
|
||||
throttleSetupAppMenu: DebouncedFunc<() => Promise<void>>
|
||||
}
|
||||
|
||||
export const SETTING_DRAWER_INJECT_KEY: Reactive<
|
||||
InjectionKey<Partial<SettingDrawerInjectKey>>
|
||||
> = Symbol('segmentDrawer')
|
||||
@ -1,3 +1,151 @@
|
||||
.n-form.setting-drawer__overrides-form .n-form-item .n-form-item-blank {
|
||||
justify-content: flex-end;
|
||||
.r-settings-drawer {
|
||||
.r-settings-drawer__header,
|
||||
.r-settings-drawer__footer {
|
||||
padding: 16px clamp(16px, 4vw, 24px);
|
||||
background: var(--r-surface);
|
||||
}
|
||||
|
||||
.r-settings-drawer__body {
|
||||
container-type: inline-size;
|
||||
padding: 12px clamp(12px, 3vw, 20px) 20px;
|
||||
background: var(--r-canvas);
|
||||
}
|
||||
}
|
||||
|
||||
.r-settings-heading {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
|
||||
&__icon {
|
||||
display: grid;
|
||||
place-items: center;
|
||||
flex: none;
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
border: 1px solid var(--r-line);
|
||||
border-radius: 10px;
|
||||
background: var(--r-surface-muted);
|
||||
color: var(--r-primary-text);
|
||||
}
|
||||
|
||||
h2 {
|
||||
margin: 0;
|
||||
font-size: 18px;
|
||||
line-height: 1.35;
|
||||
color: var(--r-text);
|
||||
}
|
||||
|
||||
p {
|
||||
margin-block: 3px 0;
|
||||
color: var(--r-text-secondary);
|
||||
font-size: 12px;
|
||||
font-weight: 400;
|
||||
}
|
||||
}
|
||||
|
||||
.r-settings-tabs {
|
||||
&__label {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
> .n-tabs-nav {
|
||||
padding-inline: 8px;
|
||||
border: 1px solid var(--r-line);
|
||||
border-radius: 10px;
|
||||
background: var(--r-surface);
|
||||
}
|
||||
|
||||
> .n-tab-pane {
|
||||
padding-block-start: 14px;
|
||||
}
|
||||
}
|
||||
|
||||
.r-settings-stack,
|
||||
.r-settings-section {
|
||||
display: grid;
|
||||
gap: 14px;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.r-settings-section {
|
||||
padding: 16px;
|
||||
border: 1px solid var(--r-line);
|
||||
border-radius: 12px;
|
||||
background: var(--r-surface);
|
||||
|
||||
h3 {
|
||||
margin: 0;
|
||||
color: var(--r-text);
|
||||
font-size: 14px;
|
||||
font-weight: 650;
|
||||
}
|
||||
|
||||
> .n-button {
|
||||
justify-self: start;
|
||||
}
|
||||
}
|
||||
|
||||
.r-settings-fields {
|
||||
display: grid;
|
||||
gap: 12px 14px;
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
|
||||
&__wide {
|
||||
grid-column: 1 / -1;
|
||||
}
|
||||
|
||||
.n-input-number,
|
||||
.n-color-picker {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
.r-settings-switches {
|
||||
display: grid;
|
||||
border: 1px solid var(--r-line);
|
||||
border-radius: 8px;
|
||||
background: var(--r-surface-muted);
|
||||
}
|
||||
|
||||
.r-settings-switch {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
padding: 10px 12px;
|
||||
color: var(--r-text);
|
||||
font-size: 13px;
|
||||
|
||||
& + & {
|
||||
border-block-start: 1px solid var(--r-line);
|
||||
}
|
||||
|
||||
.n-switch {
|
||||
flex: none;
|
||||
}
|
||||
}
|
||||
|
||||
@container (min-width: 420px) {
|
||||
.r-settings-fields {
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
}
|
||||
}
|
||||
|
||||
@container (max-width: 419px) {
|
||||
.r-settings-tabs__label {
|
||||
flex-direction: column;
|
||||
gap: 3px;
|
||||
font-size: 11px;
|
||||
line-height: 1.2;
|
||||
}
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.r-settings-drawer {
|
||||
transition-duration: 0.01ms !important;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,136 +1,122 @@
|
||||
import { useI18n } from '@/hooks'
|
||||
import LayoutSettings from '@/layout/components/LayoutSettings'
|
||||
import './index.scss'
|
||||
import { RIcon, useModal } from '@/components'
|
||||
import { useMenuActions, useSettingActions, useSettingGetters } from '@/store'
|
||||
import { useI18n } from '@/hooks'
|
||||
import LayoutSettings from '@/layout/components/LayoutSettings'
|
||||
import { useMenuActions, useSettingActions } from '@/store'
|
||||
import { getDefaultSettingConfig } from '@/store/modules/setting/constant'
|
||||
import type { SettingState } from '@/store/modules/setting/types'
|
||||
import { cloneDeep, forIn, throttle } from 'lodash-es'
|
||||
import { cloneDeep, forIn } from 'lodash-es'
|
||||
import {
|
||||
drawerProps,
|
||||
NButton,
|
||||
NDrawer,
|
||||
NDrawerContent,
|
||||
NFlex,
|
||||
NTabPane,
|
||||
NTabs,
|
||||
} from 'naive-ui'
|
||||
import { SETTING_DRAWER_INJECT_KEY } from './constant'
|
||||
import SegmentViewsAppearance from './segment-views/Appearance'
|
||||
import SegmentViewsCommon from './segment-views/Common'
|
||||
import SegmentViewsCustomMenu from './segment-views/CustomMenu'
|
||||
import SegmentViewsWatermark from './segment-views/Watermark'
|
||||
import SettingsSection from './components/SettingsSection'
|
||||
import Appearance from './segment-views/Appearance'
|
||||
import Common from './segment-views/Common'
|
||||
import CustomMenu from './segment-views/CustomMenu'
|
||||
import Watermark from './segment-views/Watermark'
|
||||
|
||||
const categories = [
|
||||
{ key: 'layout', icon: 'navigation/dashboard', view: LayoutSettings },
|
||||
{ key: 'appearance', icon: 'system/light', view: Appearance },
|
||||
{ key: 'menu', icon: 'navigation/menu', view: CustomMenu },
|
||||
{ key: 'watermark', icon: 'action/print', view: Watermark },
|
||||
{ key: 'general', icon: 'action/setting', view: Common },
|
||||
] as const
|
||||
|
||||
export default defineComponent({
|
||||
name: 'SettingDrawer',
|
||||
props: drawerProps,
|
||||
setup() {
|
||||
const { t } = useI18n()
|
||||
const { create: createModal } = useModal()
|
||||
const { changePrimaryColor, updateSettingState } = useSettingActions()
|
||||
const {
|
||||
getAppTheme,
|
||||
getPrimaryColorOverride,
|
||||
getMenuTagSwitch,
|
||||
getBreadcrumbSwitch,
|
||||
getCopyrightSwitch,
|
||||
getContentTransition,
|
||||
getWatermarkSwitch,
|
||||
getKeepAliveConfig,
|
||||
getMenuConfig,
|
||||
getDrawerPlacement,
|
||||
getColorWeakness,
|
||||
getWatermarkConfig,
|
||||
getDynamicDocumentTitle,
|
||||
} = useSettingGetters()
|
||||
setup(props) {
|
||||
const { t } = useI18n('preferences')
|
||||
const { create } = useModal()
|
||||
const { updateSettingState } = useSettingActions()
|
||||
const { setupAppMenu } = useMenuActions()
|
||||
const throttleSetupAppMenu = throttle(setupAppMenu, 300)
|
||||
const modelReactive = reactive({
|
||||
menuTagSwitch: getMenuTagSwitch.value,
|
||||
breadcrumbSwitch: getBreadcrumbSwitch.value,
|
||||
copyrightSwitch: getCopyrightSwitch.value,
|
||||
contentTransition: getContentTransition.value,
|
||||
watermarkSwitch: getWatermarkSwitch.value,
|
||||
keepAliveConfig: getKeepAliveConfig.value,
|
||||
menuConfig: getMenuConfig.value,
|
||||
drawerPlacement: getDrawerPlacement.value,
|
||||
colorWeakness: getColorWeakness.value,
|
||||
primaryColorOverride: getPrimaryColorOverride.value,
|
||||
watermarkConfig: getWatermarkConfig.value,
|
||||
dynamicDocumentTitle: getDynamicDocumentTitle.value,
|
||||
throttleSetupAppMenu,
|
||||
})
|
||||
|
||||
const defaultSettingBtnClick = () => {
|
||||
createModal({
|
||||
const reset = () =>
|
||||
create({
|
||||
preset: 'dialog',
|
||||
title: '恢复默认配置',
|
||||
title: t('reset'),
|
||||
type: 'warning',
|
||||
content: '点击【确认初始化】按钮会恢复默认系统配置,是否继续?',
|
||||
positiveText: '确认初始化',
|
||||
negativeText: '取消',
|
||||
content: t('resetDescription'),
|
||||
positiveText: t('reset'),
|
||||
negativeText: t('cancel'),
|
||||
dialogWidth: 'min(420px, calc(100vw - 32px))',
|
||||
onPositiveClick: () => {
|
||||
forIn(cloneDeep(getDefaultSettingConfig()), (value, key) => {
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore
|
||||
modelReactive[key] = value
|
||||
|
||||
updateSettingState(key as keyof SettingState, value)
|
||||
})
|
||||
|
||||
throttleSetupAppMenu()
|
||||
void setupAppMenu()
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
provide(SETTING_DRAWER_INJECT_KEY, modelReactive)
|
||||
|
||||
return {
|
||||
t,
|
||||
changePrimaryColor,
|
||||
getAppTheme,
|
||||
getPrimaryColorOverride,
|
||||
updateSettingState,
|
||||
modelReactive,
|
||||
defaultSettingBtnClick,
|
||||
}
|
||||
},
|
||||
render() {
|
||||
const { defaultSettingBtnClick, $props } = this
|
||||
const { trapFocus, autoFocus, nativeScrollbar, ...restProps } = $props
|
||||
|
||||
return (
|
||||
<NDrawer {...restProps} trapFocus={false} autoFocus={false} width={320}>
|
||||
<NDrawerContent title="个性化配置" closable>
|
||||
return () => (
|
||||
<NDrawer
|
||||
{...props}
|
||||
width={props.width ?? 'min(580px, 100vw)'}
|
||||
class="r-settings-drawer"
|
||||
>
|
||||
<NDrawerContent
|
||||
title={t('title')}
|
||||
closable
|
||||
headerClass="r-settings-drawer__header"
|
||||
bodyContentClass="r-settings-drawer__body"
|
||||
footerClass="r-settings-drawer__footer"
|
||||
nativeScrollbar={props.nativeScrollbar}
|
||||
>
|
||||
{{
|
||||
header: () => (
|
||||
<div class="r-settings-heading">
|
||||
<span class="r-settings-heading__icon">
|
||||
<RIcon
|
||||
name="action/adjustment"
|
||||
size={20}
|
||||
aria-hidden="true"
|
||||
/>
|
||||
</span>
|
||||
<div>
|
||||
<h2>{t('title')}</h2>
|
||||
<p>{t('subtitle')}</p>
|
||||
</div>
|
||||
</div>
|
||||
),
|
||||
default: () => (
|
||||
<NTabs type="bar" animated defaultValue="appearance">
|
||||
<NTabPane name="layout" tab={this.t<string>('layout.tab')}>
|
||||
<LayoutSettings />
|
||||
</NTabPane>
|
||||
<NTabPane name="appearance" tab="外观">
|
||||
<SegmentViewsAppearance />
|
||||
</NTabPane>
|
||||
<NTabPane name="navigation/menu" tab="菜单">
|
||||
<SegmentViewsCustomMenu />
|
||||
</NTabPane>
|
||||
<NTabPane name="watermark" tab="水印">
|
||||
<SegmentViewsWatermark />
|
||||
</NTabPane>
|
||||
<NTabPane name="common" tab="通用">
|
||||
<SegmentViewsCommon />
|
||||
</NTabPane>
|
||||
<NTabs
|
||||
type="line"
|
||||
defaultValue="appearance"
|
||||
class="r-settings-tabs"
|
||||
justifyContent="space-between"
|
||||
>
|
||||
{categories.map(({ key, icon, view: View }) => (
|
||||
<NTabPane
|
||||
key={key}
|
||||
name={key}
|
||||
tab={() => (
|
||||
<span class="r-settings-tabs__label">
|
||||
<RIcon name={icon} size={16} aria-hidden="true" />
|
||||
{t(`section.${key}`)}
|
||||
</span>
|
||||
)}
|
||||
>
|
||||
{key === 'layout' ? (
|
||||
<SettingsSection title={t('section.layout')}>
|
||||
<LayoutSettings />
|
||||
</SettingsSection>
|
||||
) : (
|
||||
<View />
|
||||
)}
|
||||
</NTabPane>
|
||||
))}
|
||||
</NTabs>
|
||||
),
|
||||
footer: () => (
|
||||
<NFlex justify="flex-start">
|
||||
<NButton type="warning" onClick={defaultSettingBtnClick}>
|
||||
{{
|
||||
icon: () => <RIcon name="action/reload" />,
|
||||
default: () => '初始化配置',
|
||||
}}
|
||||
</NButton>
|
||||
</NFlex>
|
||||
<NButton type="warning" secondary onClick={reset}>
|
||||
{t('reset')}
|
||||
</NButton>
|
||||
),
|
||||
}}
|
||||
</NDrawerContent>
|
||||
|
||||
@ -1,116 +1,96 @@
|
||||
import { APP_THEME, CONTENT_TRANSITION_OPTIONS } from '@/app-config'
|
||||
import { useSettingActions } from '@/store'
|
||||
import {
|
||||
NColorPicker,
|
||||
NDivider,
|
||||
NFlex,
|
||||
NForm,
|
||||
NFormItem,
|
||||
NSelect,
|
||||
NSwitch,
|
||||
} from 'naive-ui'
|
||||
import { useI18n } from '@/hooks'
|
||||
import { useSettingActions, useSettingGetters } from '@/store'
|
||||
import { NColorPicker, NForm, NFormItem, NSelect, NSwitch } from 'naive-ui'
|
||||
import SettingsSection from '../components/SettingsSection'
|
||||
import ThemeSegment from '../components/ThemeSegment'
|
||||
import { SETTING_DRAWER_INJECT_KEY } from '../constant'
|
||||
|
||||
export default defineComponent({
|
||||
name: 'SegmentViewsAppearance',
|
||||
setup() {
|
||||
const model = inject(SETTING_DRAWER_INJECT_KEY, {})
|
||||
const { t } = useI18n('preferences')
|
||||
const { changePrimaryColor, updateSettingState, toggleColorWeakness } =
|
||||
useSettingActions()
|
||||
|
||||
return {
|
||||
toggleColorWeakness,
|
||||
model,
|
||||
changePrimaryColor,
|
||||
updateSettingState,
|
||||
}
|
||||
},
|
||||
render() {
|
||||
const {
|
||||
toggleColorWeakness,
|
||||
model,
|
||||
changePrimaryColor,
|
||||
updateSettingState,
|
||||
} = this
|
||||
getPrimaryColorOverride,
|
||||
getDrawerPlacement,
|
||||
getContentTransition,
|
||||
getMenuTagSwitch,
|
||||
getBreadcrumbSwitch,
|
||||
getCopyrightSwitch,
|
||||
getColorWeakness,
|
||||
} = useSettingGetters()
|
||||
const switches = [
|
||||
['breadcrumbSwitch', getBreadcrumbSwitch],
|
||||
['menuTagSwitch', getMenuTagSwitch],
|
||||
['copyrightSwitch', getCopyrightSwitch],
|
||||
['colorWeakness', getColorWeakness],
|
||||
] as const
|
||||
|
||||
return (
|
||||
<NFlex vertical style="width: 100%;" size={[0, 0]}>
|
||||
<NDivider>系统主题</NDivider>
|
||||
<ThemeSegment />
|
||||
<NDivider>内置主题</NDivider>
|
||||
<NColorPicker
|
||||
showPreview
|
||||
swatches={APP_THEME.appThemeColors}
|
||||
v-model:value={model.primaryColorOverride!.common!.primaryColor}
|
||||
onUpdateValue={changePrimaryColor.bind(this)}
|
||||
/>
|
||||
<NDivider>切换动画</NDivider>
|
||||
<NSelect
|
||||
v-model:value={model.contentTransition}
|
||||
options={CONTENT_TRANSITION_OPTIONS}
|
||||
onUpdateValue={(value) => {
|
||||
updateSettingState('contentTransition', value)
|
||||
}}
|
||||
/>
|
||||
<NDivider>配置入口出现位置</NDivider>
|
||||
<NSelect
|
||||
v-model:value={model.drawerPlacement}
|
||||
options={[
|
||||
{
|
||||
label: '右边',
|
||||
value: 'right',
|
||||
},
|
||||
{
|
||||
label: '左边',
|
||||
value: 'left',
|
||||
},
|
||||
]}
|
||||
onUpdateValue={(value) => {
|
||||
updateSettingState('drawerPlacement', value)
|
||||
}}
|
||||
/>
|
||||
<NDivider>其他设置</NDivider>
|
||||
<NForm
|
||||
labelPlacement="left"
|
||||
class="setting-drawer__overrides-form"
|
||||
showFeedback={false}
|
||||
>
|
||||
<NFormItem label="面包屑">
|
||||
<NSwitch
|
||||
v-model:value={model.breadcrumbSwitch}
|
||||
onUpdateValue={(bool) =>
|
||||
updateSettingState('breadcrumbSwitch', bool)
|
||||
}
|
||||
/>
|
||||
</NFormItem>
|
||||
<NFormItem label="标签页">
|
||||
<NSwitch
|
||||
v-model:value={model.menuTagSwitch}
|
||||
onUpdateValue={(bool) =>
|
||||
updateSettingState('menuTagSwitch', bool)
|
||||
}
|
||||
/>
|
||||
</NFormItem>
|
||||
<NFormItem label="页底信息">
|
||||
<NSwitch
|
||||
v-model:value={model.copyrightSwitch}
|
||||
onUpdateValue={(bool) =>
|
||||
updateSettingState('copyrightSwitch', bool)
|
||||
}
|
||||
/>
|
||||
</NFormItem>
|
||||
<NFormItem label="色弱模式">
|
||||
<NSwitch
|
||||
v-model:value={model.colorWeakness}
|
||||
onUpdateValue={(bool) => {
|
||||
updateSettingState('colorWeakness', bool)
|
||||
toggleColorWeakness(bool)
|
||||
}}
|
||||
/>
|
||||
</NFormItem>
|
||||
</NForm>
|
||||
</NFlex>
|
||||
return () => (
|
||||
<div class="r-settings-stack">
|
||||
<SettingsSection title={t('appearance.theme')}>
|
||||
<ThemeSegment />
|
||||
<NForm
|
||||
labelPlacement="top"
|
||||
showFeedback={false}
|
||||
class="r-settings-fields"
|
||||
>
|
||||
<NFormItem label={t('appearance.primaryColor')}>
|
||||
<NColorPicker
|
||||
showPreview
|
||||
swatches={APP_THEME.appThemeColors}
|
||||
value={getPrimaryColorOverride.value.common?.primaryColor}
|
||||
onUpdateValue={(value) => {
|
||||
if (value) changePrimaryColor(value)
|
||||
}}
|
||||
/>
|
||||
</NFormItem>
|
||||
<NFormItem label={t('appearance.transition')}>
|
||||
<NSelect
|
||||
value={getContentTransition.value}
|
||||
options={CONTENT_TRANSITION_OPTIONS.map(({ value }) => ({
|
||||
value,
|
||||
label: t(`transition.${value}`),
|
||||
}))}
|
||||
onUpdateValue={(value) =>
|
||||
updateSettingState('contentTransition', value)
|
||||
}
|
||||
/>
|
||||
</NFormItem>
|
||||
<NFormItem label={t('appearance.placement')}>
|
||||
<NSelect
|
||||
value={getDrawerPlacement.value}
|
||||
options={['right', 'left'].map((value) => ({
|
||||
value,
|
||||
label: t(`placement.${value}`),
|
||||
}))}
|
||||
onUpdateValue={(value: 'right' | 'left') =>
|
||||
updateSettingState('drawerPlacement', value)
|
||||
}
|
||||
/>
|
||||
</NFormItem>
|
||||
</NForm>
|
||||
</SettingsSection>
|
||||
<SettingsSection title={t('appearance.display')}>
|
||||
<div class="r-settings-switches">
|
||||
{switches.map(([key, value]) => (
|
||||
<label class="r-settings-switch" key={key}>
|
||||
<span>{t(`appearance.${key}`)}</span>
|
||||
<NSwitch
|
||||
value={value.value}
|
||||
aria-label={t(`appearance.${key}`)}
|
||||
onUpdateValue={(enabled) =>
|
||||
key === 'colorWeakness'
|
||||
? toggleColorWeakness(enabled)
|
||||
: updateSettingState(key, enabled)
|
||||
}
|
||||
/>
|
||||
</label>
|
||||
))}
|
||||
</div>
|
||||
</SettingsSection>
|
||||
</div>
|
||||
)
|
||||
},
|
||||
})
|
||||
|
||||
@ -1,97 +1,79 @@
|
||||
import { RIcon } from '@/components'
|
||||
import { useSettingActions } from '@/store'
|
||||
import {
|
||||
NDivider,
|
||||
NDynamicTags,
|
||||
NFlex,
|
||||
NForm,
|
||||
NFormItem,
|
||||
NInputNumber,
|
||||
NSwitch,
|
||||
} from 'naive-ui'
|
||||
import { SETTING_DRAWER_INJECT_KEY } from '../constant'
|
||||
import { useI18n } from '@/hooks'
|
||||
import { useSettingActions, useSettingGetters } from '@/store'
|
||||
import { NDynamicTags, NForm, NFormItem, NInputNumber, NSwitch } from 'naive-ui'
|
||||
import SettingsSection from '../components/SettingsSection'
|
||||
|
||||
export default defineComponent({
|
||||
name: 'SegmentViewsCommon',
|
||||
setup() {
|
||||
const model = inject(SETTING_DRAWER_INJECT_KEY, {})
|
||||
const { t } = useI18n('preferences')
|
||||
const { getKeepAliveConfig, getDynamicDocumentTitle } = useSettingGetters()
|
||||
const { updateSettingState } = useSettingActions()
|
||||
|
||||
return {
|
||||
model,
|
||||
updateSettingState,
|
||||
}
|
||||
},
|
||||
render() {
|
||||
const { model, updateSettingState } = this
|
||||
|
||||
return (
|
||||
<NFlex vertical style="width: 100%;" size={[0, 0]}>
|
||||
<NDivider>基础设置</NDivider>
|
||||
<NForm
|
||||
labelPlacement="left"
|
||||
class="setting-drawer__overrides-form"
|
||||
showFeedback={false}
|
||||
>
|
||||
<NFormItem label="页面缓存">
|
||||
<NSwitch
|
||||
v-model:value={model.keepAliveConfig!.setupKeepAlive}
|
||||
onUpdateValue={(bool) =>
|
||||
updateSettingState('keepAliveConfig', {
|
||||
setupKeepAlive: bool,
|
||||
})
|
||||
}
|
||||
/>
|
||||
</NFormItem>
|
||||
<NFormItem label="动态浏览器标题">
|
||||
<NSwitch
|
||||
v-model:value={model.dynamicDocumentTitle}
|
||||
onUpdateValue={(bool) =>
|
||||
updateSettingState('dynamicDocumentTitle', bool)
|
||||
}
|
||||
/>
|
||||
</NFormItem>
|
||||
</NForm>
|
||||
<NDivider>缓存设置</NDivider>
|
||||
<NForm
|
||||
labelPlacement="top"
|
||||
showFeedback={true}
|
||||
showRequireMark={false}
|
||||
model={model.keepAliveConfig}
|
||||
>
|
||||
<NFormItem
|
||||
label="最大缓存数"
|
||||
feedback={
|
||||
computed(() => {
|
||||
if (model.keepAliveConfig!.maxKeepAliveLength <= 0) {
|
||||
return '设置为【0】时,缓存将会失效'
|
||||
return () => (
|
||||
<div class="r-settings-stack">
|
||||
<SettingsSection title={t('section.general')}>
|
||||
<div class="r-settings-switches">
|
||||
<label class="r-settings-switch">
|
||||
<span>{t('general.title')}</span>
|
||||
<NSwitch
|
||||
value={getDynamicDocumentTitle.value}
|
||||
aria-label={t('general.title')}
|
||||
onUpdateValue={(value) =>
|
||||
updateSettingState('dynamicDocumentTitle', value)
|
||||
}
|
||||
|
||||
return ''
|
||||
}).value
|
||||
}
|
||||
/>
|
||||
</label>
|
||||
</div>
|
||||
</SettingsSection>
|
||||
<SettingsSection title={t('general.cache')}>
|
||||
<div class="r-settings-switches">
|
||||
<label class="r-settings-switch">
|
||||
<span>{t('general.enableCache')}</span>
|
||||
<NSwitch
|
||||
value={getKeepAliveConfig.value.setupKeepAlive}
|
||||
aria-label={t('general.enableCache')}
|
||||
onUpdateValue={(setupKeepAlive) =>
|
||||
updateSettingState('keepAliveConfig', { setupKeepAlive })
|
||||
}
|
||||
/>
|
||||
</label>
|
||||
</div>
|
||||
<NForm
|
||||
labelPlacement="top"
|
||||
showFeedback={false}
|
||||
class="r-settings-fields"
|
||||
>
|
||||
<NInputNumber
|
||||
disabled={!model.keepAliveConfig!.setupKeepAlive}
|
||||
v-model:value={model.keepAliveConfig!.maxKeepAliveLength}
|
||||
min={0}
|
||||
precision={0}
|
||||
showButton={false}
|
||||
onUpdateValue={(val) =>
|
||||
updateSettingState('keepAliveConfig', {
|
||||
maxKeepAliveLength: val!,
|
||||
})
|
||||
}
|
||||
/>
|
||||
</NFormItem>
|
||||
<NFormItem label="排除缓存">
|
||||
<NDynamicTags
|
||||
type="success"
|
||||
v-model:value={model.keepAliveConfig!.keepAliveExclude}
|
||||
/>
|
||||
</NFormItem>
|
||||
</NForm>
|
||||
</NFlex>
|
||||
<NFormItem label={t('general.cacheLimit')}>
|
||||
<NInputNumber
|
||||
value={getKeepAliveConfig.value.maxKeepAliveLength}
|
||||
disabled={!getKeepAliveConfig.value.setupKeepAlive}
|
||||
inputProps={{ 'aria-label': t('general.cacheLimit') }}
|
||||
min={0}
|
||||
precision={0}
|
||||
showButton={false}
|
||||
onUpdateValue={(value) => {
|
||||
if (value !== null)
|
||||
updateSettingState('keepAliveConfig', {
|
||||
maxKeepAliveLength: value,
|
||||
})
|
||||
}}
|
||||
/>
|
||||
</NFormItem>
|
||||
<NFormItem
|
||||
label={t('general.cacheExcluded')}
|
||||
class="r-settings-fields__wide"
|
||||
>
|
||||
<NDynamicTags
|
||||
value={getKeepAliveConfig.value.keepAliveExclude}
|
||||
onUpdateValue={(keepAliveExclude: string[]) =>
|
||||
updateSettingState('keepAliveConfig', { keepAliveExclude })
|
||||
}
|
||||
/>
|
||||
</NFormItem>
|
||||
</NForm>
|
||||
</SettingsSection>
|
||||
</div>
|
||||
)
|
||||
},
|
||||
})
|
||||
|
||||
@ -1,166 +1,74 @@
|
||||
import { RIcon } from '@/components'
|
||||
import { useSettingActions } from '@/store'
|
||||
import {
|
||||
NButton,
|
||||
NDivider,
|
||||
NFlex,
|
||||
NForm,
|
||||
NFormItem,
|
||||
NInputNumber,
|
||||
NSwitch,
|
||||
NText,
|
||||
NTooltip,
|
||||
} from 'naive-ui'
|
||||
import { SETTING_DRAWER_INJECT_KEY } from '../constant'
|
||||
import { useI18n } from '@/hooks'
|
||||
import { useMenuActions, useSettingActions, useSettingGetters } from '@/store'
|
||||
import { NButton, NForm, NFormItem, NInputNumber, NSwitch } from 'naive-ui'
|
||||
import SettingsSection from '../components/SettingsSection'
|
||||
|
||||
const sizes = [
|
||||
'menuWidth',
|
||||
'collapsedWidth',
|
||||
'collapsedIndent',
|
||||
'iconSize',
|
||||
'collapsedIconSize',
|
||||
] as const
|
||||
const switches = [
|
||||
'inverted',
|
||||
'menuSiderBarLogo',
|
||||
'accordion',
|
||||
'nativeScrollbar',
|
||||
] as const
|
||||
|
||||
export default defineComponent({
|
||||
name: 'SegmentViewsCustomMenu',
|
||||
setup() {
|
||||
const model = inject(SETTING_DRAWER_INJECT_KEY, {})
|
||||
const { t } = useI18n('preferences')
|
||||
const { getMenuConfig } = useSettingGetters()
|
||||
const { updateSettingState } = useSettingActions()
|
||||
const { setupAppMenu } = useMenuActions()
|
||||
|
||||
return {
|
||||
model,
|
||||
updateSettingState,
|
||||
}
|
||||
},
|
||||
render() {
|
||||
const { model, updateSettingState } = this
|
||||
|
||||
return (
|
||||
<NFlex vertical style="width: 100%;" size={[0, 0]}>
|
||||
<NDivider titlePlacement="center">
|
||||
<NFlex wrap={false} align="center" size={[4, 0]}>
|
||||
<NTooltip placement="top" showArrow={false}>
|
||||
{{
|
||||
trigger: () => <RIcon name="status/question" size="16" />,
|
||||
default: () =>
|
||||
'菜单更新是一个复杂、耗时的操作,请手动点击【更新菜单】按钮更新设置',
|
||||
}}
|
||||
</NTooltip>
|
||||
<NText>菜单样式</NText>
|
||||
</NFlex>
|
||||
</NDivider>
|
||||
<NForm
|
||||
showFeedback={true}
|
||||
showRequireMark={false}
|
||||
class="setting-drawer__overrides-form"
|
||||
>
|
||||
<NFormItem label="每级菜单缩进">
|
||||
<NInputNumber
|
||||
v-model:value={model.menuConfig!.collapsedIndent}
|
||||
min={0}
|
||||
precision={0}
|
||||
onUpdateValue={(value) =>
|
||||
updateSettingState('menuConfig', {
|
||||
collapsedIndent: value!,
|
||||
})
|
||||
}
|
||||
/>
|
||||
</NFormItem>
|
||||
<NFormItem label="菜单图标尺寸">
|
||||
<NInputNumber
|
||||
v-model:value={model.menuConfig!.iconSize}
|
||||
min={0}
|
||||
precision={0}
|
||||
onUpdateValue={(value) =>
|
||||
updateSettingState('menuConfig', {
|
||||
iconSize: value!,
|
||||
})
|
||||
}
|
||||
/>
|
||||
</NFormItem>
|
||||
<NFormItem label="折叠菜单图标尺寸">
|
||||
<NInputNumber
|
||||
v-model:value={model.menuConfig!.collapsedIconSize}
|
||||
min={0}
|
||||
precision={0}
|
||||
onUpdateValue={(value) =>
|
||||
updateSettingState('menuConfig', {
|
||||
collapsedIconSize: value!,
|
||||
})
|
||||
}
|
||||
/>
|
||||
</NFormItem>
|
||||
<NFormItem label="菜单宽度">
|
||||
<NInputNumber
|
||||
v-model:value={model.menuConfig!.menuWidth}
|
||||
min={0}
|
||||
precision={0}
|
||||
onUpdateValue={(value) =>
|
||||
updateSettingState('menuConfig', {
|
||||
menuWidth: value!,
|
||||
})
|
||||
}
|
||||
/>
|
||||
</NFormItem>
|
||||
<NFormItem label="折叠菜单宽度">
|
||||
<NInputNumber
|
||||
v-model:value={model.menuConfig!.collapsedWidth}
|
||||
min={0}
|
||||
precision={0}
|
||||
onUpdateValue={(value) =>
|
||||
updateSettingState('menuConfig', {
|
||||
collapsedWidth: value!,
|
||||
})
|
||||
}
|
||||
/>
|
||||
</NFormItem>
|
||||
<NFormItem showFeedback={false} showLabel={false}>
|
||||
<NButton onClick={model.throttleSetupAppMenu} block type="primary">
|
||||
更新菜单
|
||||
</NButton>
|
||||
</NFormItem>
|
||||
</NForm>
|
||||
<NDivider>其他设置</NDivider>
|
||||
<NForm
|
||||
showFeedback={false}
|
||||
showRequireMark={false}
|
||||
class="setting-drawer__overrides-form"
|
||||
labelPlacement="left"
|
||||
>
|
||||
<NFormItem label="反转色菜单">
|
||||
<NSwitch
|
||||
v-model:value={model.menuConfig!.inverted}
|
||||
onUpdateValue={(bool) =>
|
||||
updateSettingState('menuConfig', {
|
||||
inverted: bool,
|
||||
})
|
||||
}
|
||||
/>
|
||||
</NFormItem>
|
||||
<NFormItem label="菜单标题">
|
||||
<NSwitch
|
||||
v-model:value={model.menuConfig!.menuSiderBarLogo}
|
||||
onUpdateValue={(bool) =>
|
||||
updateSettingState('menuConfig', {
|
||||
menuSiderBarLogo: bool,
|
||||
})
|
||||
}
|
||||
/>
|
||||
</NFormItem>
|
||||
<NFormItem label="手风琴菜单">
|
||||
<NSwitch
|
||||
v-model:value={model.menuConfig!.accordion}
|
||||
onUpdateValue={(bool) =>
|
||||
updateSettingState('menuConfig', {
|
||||
accordion: bool,
|
||||
})
|
||||
}
|
||||
/>
|
||||
</NFormItem>
|
||||
<NFormItem label="原生滚动条">
|
||||
<NSwitch
|
||||
v-model:value={model.menuConfig!.nativeScrollbar}
|
||||
onUpdateValue={(bool) =>
|
||||
updateSettingState('menuConfig', {
|
||||
nativeScrollbar: bool,
|
||||
})
|
||||
}
|
||||
/>
|
||||
</NFormItem>
|
||||
</NForm>
|
||||
</NFlex>
|
||||
return () => (
|
||||
<div class="r-settings-stack">
|
||||
<SettingsSection title={t('menu.size')}>
|
||||
<NForm
|
||||
labelPlacement="top"
|
||||
showFeedback={false}
|
||||
class="r-settings-fields"
|
||||
>
|
||||
{sizes.map((key) => (
|
||||
<NFormItem label={t(`menu.${key}`)} key={key}>
|
||||
<NInputNumber
|
||||
value={getMenuConfig.value[key]}
|
||||
min={0}
|
||||
precision={0}
|
||||
inputProps={{ 'aria-label': t(`menu.${key}`) }}
|
||||
onUpdateValue={(value) => {
|
||||
if (value !== null)
|
||||
updateSettingState('menuConfig', { [key]: value })
|
||||
}}
|
||||
/>
|
||||
</NFormItem>
|
||||
))}
|
||||
</NForm>
|
||||
<NButton secondary type="primary" onClick={setupAppMenu}>
|
||||
{t('menu.refresh')}
|
||||
</NButton>
|
||||
</SettingsSection>
|
||||
<SettingsSection title={t('menu.behavior')}>
|
||||
<div class="r-settings-switches">
|
||||
{switches.map((key) => (
|
||||
<label key={key} class="r-settings-switch">
|
||||
<span>{t(`menu.${key}`)}</span>
|
||||
<NSwitch
|
||||
value={getMenuConfig.value[key]}
|
||||
aria-label={t(`menu.${key}`)}
|
||||
onUpdateValue={(enabled) =>
|
||||
updateSettingState('menuConfig', { [key]: enabled })
|
||||
}
|
||||
/>
|
||||
</label>
|
||||
))}
|
||||
</div>
|
||||
</SettingsSection>
|
||||
</div>
|
||||
)
|
||||
},
|
||||
})
|
||||
|
||||
@ -1,183 +1,88 @@
|
||||
import { useSettingActions } from '@/store'
|
||||
import {
|
||||
NDivider,
|
||||
NFlex,
|
||||
NForm,
|
||||
NFormItem,
|
||||
NInput,
|
||||
NInputNumber,
|
||||
NSwitch,
|
||||
} from 'naive-ui'
|
||||
import { SETTING_DRAWER_INJECT_KEY } from '../constant'
|
||||
import { useI18n } from '@/hooks'
|
||||
import { useSettingActions, useSettingGetters } from '@/store'
|
||||
import { NForm, NFormItem, NInput, NInputNumber, NSwitch } from 'naive-ui'
|
||||
import SettingsSection from '../components/SettingsSection'
|
||||
|
||||
const dimensions = [
|
||||
'fontSize',
|
||||
'lineHeight',
|
||||
'width',
|
||||
'height',
|
||||
'xOffset',
|
||||
'yOffset',
|
||||
'xGap',
|
||||
'yGap',
|
||||
'rotate',
|
||||
] as const
|
||||
|
||||
export default defineComponent({
|
||||
name: 'SegmentViewsWatermark',
|
||||
setup() {
|
||||
const model = inject(SETTING_DRAWER_INJECT_KEY, {})
|
||||
const { t } = useI18n('preferences')
|
||||
const { getWatermarkSwitch, getWatermarkConfig } = useSettingGetters()
|
||||
const { updateSettingState } = useSettingActions()
|
||||
|
||||
return {
|
||||
model,
|
||||
updateSettingState,
|
||||
}
|
||||
},
|
||||
render() {
|
||||
const { model, updateSettingState } = this
|
||||
|
||||
return (
|
||||
<NFlex vertical style="width: 100%;" size={[0, 0]}>
|
||||
<NDivider>基础设置</NDivider>
|
||||
<NForm
|
||||
showFeedback={false}
|
||||
showRequireMark={false}
|
||||
class="setting-drawer__overrides-form"
|
||||
labelPlacement="left"
|
||||
>
|
||||
<NFormItem label="全屏水印">
|
||||
<NSwitch
|
||||
v-model:value={model.watermarkSwitch}
|
||||
onUpdateValue={(bool) =>
|
||||
updateSettingState('watermarkSwitch', bool)
|
||||
}
|
||||
/>
|
||||
</NFormItem>
|
||||
<NFormItem label="跨边界显示">
|
||||
<NSwitch
|
||||
v-model:value={model.watermarkConfig!.cross}
|
||||
onUpdateValue={(val) =>
|
||||
updateSettingState('watermarkConfig', {
|
||||
cross: val,
|
||||
})
|
||||
}
|
||||
/>
|
||||
</NFormItem>
|
||||
</NForm>
|
||||
<NDivider>个性化水印</NDivider>
|
||||
<NForm
|
||||
showFeedback={true}
|
||||
showRequireMark={false}
|
||||
class="setting-drawer__overrides-form"
|
||||
>
|
||||
<NFormItem label="水印内容">
|
||||
<NInput
|
||||
v-model:value={model.watermarkConfig!.content}
|
||||
onUpdateValue={(val) =>
|
||||
updateSettingState('watermarkConfig', {
|
||||
content: val,
|
||||
})
|
||||
}
|
||||
/>
|
||||
</NFormItem>
|
||||
<NFormItem label="字体尺寸">
|
||||
<NInputNumber
|
||||
precision={0}
|
||||
showButton={false}
|
||||
v-model:value={model.watermarkConfig!.fontSize}
|
||||
onUpdateValue={(val) =>
|
||||
updateSettingState('watermarkConfig', {
|
||||
fontSize: val!,
|
||||
})
|
||||
}
|
||||
/>
|
||||
</NFormItem>
|
||||
<NFormItem label="字体行高">
|
||||
<NInputNumber
|
||||
precision={0}
|
||||
showButton={false}
|
||||
v-model:value={model.watermarkConfig!.lineHeight}
|
||||
onUpdateValue={(val) =>
|
||||
updateSettingState('watermarkConfig', {
|
||||
lineHeight: val!,
|
||||
})
|
||||
}
|
||||
/>
|
||||
</NFormItem>
|
||||
<NFormItem label="字体宽度">
|
||||
<NInputNumber
|
||||
precision={0}
|
||||
showButton={false}
|
||||
v-model:value={model.watermarkConfig!.width}
|
||||
onUpdateValue={(val) =>
|
||||
updateSettingState('watermarkConfig', {
|
||||
width: val!,
|
||||
})
|
||||
}
|
||||
/>
|
||||
</NFormItem>
|
||||
<NFormItem label="字体高度">
|
||||
<NInputNumber
|
||||
precision={0}
|
||||
showButton={false}
|
||||
v-model:value={model.watermarkConfig!.height}
|
||||
onUpdateValue={(val) =>
|
||||
updateSettingState('watermarkConfig', {
|
||||
height: val!,
|
||||
})
|
||||
}
|
||||
/>
|
||||
</NFormItem>
|
||||
<NFormItem label="x轴偏移">
|
||||
<NInputNumber
|
||||
precision={0}
|
||||
showButton={false}
|
||||
v-model:value={model.watermarkConfig!.xOffset}
|
||||
onUpdateValue={(val) =>
|
||||
updateSettingState('watermarkConfig', {
|
||||
xOffset: val!,
|
||||
})
|
||||
}
|
||||
/>
|
||||
</NFormItem>
|
||||
<NFormItem label="x轴间隙">
|
||||
<NInputNumber
|
||||
precision={0}
|
||||
showButton={false}
|
||||
v-model:value={model.watermarkConfig!.xGap}
|
||||
onUpdateValue={(val) =>
|
||||
updateSettingState('watermarkConfig', {
|
||||
xGap: val!,
|
||||
})
|
||||
}
|
||||
/>
|
||||
</NFormItem>
|
||||
<NFormItem label="y轴偏移">
|
||||
<NInputNumber
|
||||
precision={0}
|
||||
showButton={false}
|
||||
v-model:value={model.watermarkConfig!.yOffset}
|
||||
onUpdateValue={(val) =>
|
||||
updateSettingState('watermarkConfig', {
|
||||
yOffset: val!,
|
||||
})
|
||||
}
|
||||
/>
|
||||
</NFormItem>
|
||||
<NFormItem label="y轴间隙">
|
||||
<NInputNumber
|
||||
precision={0}
|
||||
showButton={false}
|
||||
v-model:value={model.watermarkConfig!.yGap}
|
||||
onUpdateValue={(val) =>
|
||||
updateSettingState('watermarkConfig', {
|
||||
yGap: val!,
|
||||
})
|
||||
}
|
||||
/>
|
||||
</NFormItem>
|
||||
<NFormItem label="旋转角度">
|
||||
<NInputNumber
|
||||
precision={0}
|
||||
showButton={false}
|
||||
v-model:value={model.watermarkConfig!.rotate}
|
||||
onUpdateValue={(val) =>
|
||||
updateSettingState('watermarkConfig', {
|
||||
rotate: val!,
|
||||
})
|
||||
}
|
||||
/>
|
||||
</NFormItem>
|
||||
</NForm>
|
||||
</NFlex>
|
||||
return () => (
|
||||
<div class="r-settings-stack">
|
||||
<SettingsSection title={t('section.watermark')}>
|
||||
<div class="r-settings-switches">
|
||||
<label class="r-settings-switch">
|
||||
<span>{t('watermark.enabled')}</span>
|
||||
<NSwitch
|
||||
value={getWatermarkSwitch.value}
|
||||
aria-label={t('watermark.enabled')}
|
||||
onUpdateValue={(enabled) =>
|
||||
updateSettingState('watermarkSwitch', enabled)
|
||||
}
|
||||
/>
|
||||
</label>
|
||||
<label class="r-settings-switch">
|
||||
<span>{t('watermark.cross')}</span>
|
||||
<NSwitch
|
||||
value={getWatermarkConfig.value.cross}
|
||||
aria-label={t('watermark.cross')}
|
||||
onUpdateValue={(cross) =>
|
||||
updateSettingState('watermarkConfig', { cross })
|
||||
}
|
||||
/>
|
||||
</label>
|
||||
</div>
|
||||
</SettingsSection>
|
||||
<SettingsSection title={t('watermark.style')}>
|
||||
<NForm
|
||||
labelPlacement="top"
|
||||
showFeedback={false}
|
||||
class="r-settings-fields"
|
||||
>
|
||||
<NFormItem
|
||||
label={t('watermark.content')}
|
||||
class="r-settings-fields__wide"
|
||||
>
|
||||
<NInput
|
||||
value={getWatermarkConfig.value.content}
|
||||
inputProps={{ 'aria-label': t('watermark.content') }}
|
||||
onUpdateValue={(content) =>
|
||||
updateSettingState('watermarkConfig', { content })
|
||||
}
|
||||
/>
|
||||
</NFormItem>
|
||||
{dimensions.map((key) => (
|
||||
<NFormItem label={t(`watermark.${key}`)} key={key}>
|
||||
<NInputNumber
|
||||
value={getWatermarkConfig.value[key]}
|
||||
precision={0}
|
||||
showButton={false}
|
||||
inputProps={{ 'aria-label': t(`watermark.${key}`) }}
|
||||
onUpdateValue={(value) => {
|
||||
if (value !== null)
|
||||
updateSettingState('watermarkConfig', { [key]: value })
|
||||
}}
|
||||
/>
|
||||
</NFormItem>
|
||||
))}
|
||||
</NForm>
|
||||
</SettingsSection>
|
||||
</div>
|
||||
)
|
||||
},
|
||||
})
|
||||
|
||||
78
src/locales/lang/en-US/preferences.json
Normal file
78
src/locales/lang/en-US/preferences.json
Normal file
@ -0,0 +1,78 @@
|
||||
{
|
||||
"title": "Preferences",
|
||||
"subtitle": "Changes apply immediately and are saved in this browser",
|
||||
"reset": "Restore defaults",
|
||||
"resetDescription": "Restore the default layout, menu and general options.",
|
||||
"cancel": "Cancel",
|
||||
"section": {
|
||||
"layout": "Layout",
|
||||
"appearance": "Appearance",
|
||||
"menu": "Menu",
|
||||
"watermark": "Watermark",
|
||||
"general": "General"
|
||||
},
|
||||
"theme": {
|
||||
"light": "Light",
|
||||
"dark": "Dark",
|
||||
"auto": "System"
|
||||
},
|
||||
"appearance": {
|
||||
"theme": "Theme and motion",
|
||||
"primaryColor": "Accent color",
|
||||
"transition": "Page transition",
|
||||
"placement": "Drawer position",
|
||||
"display": "Interface display",
|
||||
"breadcrumbSwitch": "Breadcrumbs",
|
||||
"menuTagSwitch": "Page tabs",
|
||||
"copyrightSwitch": "Footer",
|
||||
"colorWeakness": "Color vision mode"
|
||||
},
|
||||
"transition": {
|
||||
"none": "None",
|
||||
"scale": "Scale in",
|
||||
"fade-scale": "Scale and fade",
|
||||
"fade-slide": "Slide in",
|
||||
"opacity": "Fade",
|
||||
"fade-bottom": "Fade downward"
|
||||
},
|
||||
"placement": {
|
||||
"right": "Right",
|
||||
"left": "Left"
|
||||
},
|
||||
"menu": {
|
||||
"size": "Size and spacing",
|
||||
"menuWidth": "Menu width",
|
||||
"collapsedWidth": "Collapsed width",
|
||||
"collapsedIndent": "Item indent",
|
||||
"iconSize": "Icon size",
|
||||
"collapsedIconSize": "Collapsed icon size",
|
||||
"refresh": "Refresh menu",
|
||||
"behavior": "Menu behavior",
|
||||
"inverted": "Inverted menu",
|
||||
"menuSiderBarLogo": "Brand mark",
|
||||
"accordion": "Accordion groups",
|
||||
"nativeScrollbar": "Native scrollbar"
|
||||
},
|
||||
"watermark": {
|
||||
"enabled": "Full-page watermark",
|
||||
"cross": "Staggered tiles",
|
||||
"style": "Content and style",
|
||||
"content": "Watermark text",
|
||||
"fontSize": "Font size",
|
||||
"lineHeight": "Line height",
|
||||
"width": "Tile width",
|
||||
"height": "Tile height",
|
||||
"xOffset": "Horizontal offset",
|
||||
"yOffset": "Vertical offset",
|
||||
"xGap": "Horizontal gap",
|
||||
"yGap": "Vertical gap",
|
||||
"rotate": "Rotation"
|
||||
},
|
||||
"general": {
|
||||
"title": "Dynamic browser title",
|
||||
"cache": "Page cache",
|
||||
"enableCache": "Enable caching",
|
||||
"cacheLimit": "Cache limit",
|
||||
"cacheExcluded": "Excluded component names"
|
||||
}
|
||||
}
|
||||
78
src/locales/lang/zh-CN/preferences.json
Normal file
78
src/locales/lang/zh-CN/preferences.json
Normal file
@ -0,0 +1,78 @@
|
||||
{
|
||||
"title": "偏好设置",
|
||||
"subtitle": "更改即时生效并保存在此浏览器",
|
||||
"reset": "恢复默认设置",
|
||||
"resetDescription": "将布局、菜单和通用选项恢复为默认值。",
|
||||
"cancel": "取消",
|
||||
"section": {
|
||||
"layout": "布局",
|
||||
"appearance": "外观",
|
||||
"menu": "菜单",
|
||||
"watermark": "水印",
|
||||
"general": "通用"
|
||||
},
|
||||
"theme": {
|
||||
"light": "浅色",
|
||||
"dark": "深色",
|
||||
"auto": "跟随系统"
|
||||
},
|
||||
"appearance": {
|
||||
"theme": "主题与动效",
|
||||
"primaryColor": "主题色",
|
||||
"transition": "页面切换动画",
|
||||
"placement": "设置抽屉位置",
|
||||
"display": "界面显示",
|
||||
"breadcrumbSwitch": "面包屑导航",
|
||||
"menuTagSwitch": "页面标签",
|
||||
"copyrightSwitch": "页脚信息",
|
||||
"colorWeakness": "色弱模式"
|
||||
},
|
||||
"transition": {
|
||||
"none": "无",
|
||||
"scale": "缩放出现",
|
||||
"fade-scale": "缩放淡出",
|
||||
"fade-slide": "滑入出现",
|
||||
"opacity": "淡入淡出",
|
||||
"fade-bottom": "底部消退"
|
||||
},
|
||||
"placement": {
|
||||
"right": "右侧",
|
||||
"left": "左侧"
|
||||
},
|
||||
"menu": {
|
||||
"size": "尺寸与间距",
|
||||
"menuWidth": "菜单宽度",
|
||||
"collapsedWidth": "折叠宽度",
|
||||
"collapsedIndent": "层级缩进",
|
||||
"iconSize": "图标尺寸",
|
||||
"collapsedIconSize": "折叠图标尺寸",
|
||||
"refresh": "刷新菜单",
|
||||
"behavior": "菜单行为",
|
||||
"inverted": "反色菜单",
|
||||
"menuSiderBarLogo": "品牌标识",
|
||||
"accordion": "手风琴展开",
|
||||
"nativeScrollbar": "原生滚动条"
|
||||
},
|
||||
"watermark": {
|
||||
"enabled": "全屏水印",
|
||||
"cross": "交错显示",
|
||||
"style": "内容与样式",
|
||||
"content": "水印文本",
|
||||
"fontSize": "字号",
|
||||
"lineHeight": "行高",
|
||||
"width": "单元宽度",
|
||||
"height": "单元高度",
|
||||
"xOffset": "水平偏移",
|
||||
"yOffset": "垂直偏移",
|
||||
"xGap": "水平间距",
|
||||
"yGap": "垂直间距",
|
||||
"rotate": "旋转角度"
|
||||
},
|
||||
"general": {
|
||||
"title": "动态浏览器标题",
|
||||
"cache": "页面缓存",
|
||||
"enableCache": "启用缓存",
|
||||
"cacheLimit": "最大缓存数",
|
||||
"cacheExcluded": "排除的组件名称"
|
||||
}
|
||||
}
|
||||
@ -125,42 +125,50 @@ export const piniaSettingStore = defineStore(
|
||||
}
|
||||
|
||||
const toggleColorWeakness = (bool: boolean) => {
|
||||
const html = document.documentElement
|
||||
|
||||
updateSettingState('colorWeakness', bool)
|
||||
setStyle(html, {
|
||||
filter: bool ? 'invert(100%)' : '',
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @description
|
||||
* 初始化合并自定义主题色。
|
||||
* 该方法会在初始化时执行一次,之后会在切换主题色时执行。
|
||||
*/
|
||||
watchEffect(() => {
|
||||
if (settingState.appTheme === 'auto')
|
||||
settingState._appTheme = preferredDark.value
|
||||
watch(
|
||||
() => (settingState.appTheme === 'auto' ? preferredDark.value : void 0),
|
||||
(systemDark) => {
|
||||
if (systemDark !== void 0) settingState._appTheme = systemDark
|
||||
},
|
||||
{ immediate: true },
|
||||
)
|
||||
|
||||
settingState._appTheme
|
||||
? (settingState.primaryColorOverride = merge(
|
||||
{},
|
||||
settingState.primaryColorOverride,
|
||||
APP_THEME.appNaiveUIThemeOverrides.dark,
|
||||
))
|
||||
: (settingState.primaryColorOverride = merge(
|
||||
{},
|
||||
settingState.primaryColorOverride,
|
||||
APP_THEME.appNaiveUIThemeOverrides.light,
|
||||
))
|
||||
watch(
|
||||
() => settingState._appTheme,
|
||||
(dark) => {
|
||||
settingState.primaryColorOverride = merge(
|
||||
{},
|
||||
settingState.primaryColorOverride,
|
||||
dark
|
||||
? APP_THEME.appNaiveUIThemeOverrides.dark
|
||||
: APP_THEME.appNaiveUIThemeOverrides.light,
|
||||
)
|
||||
},
|
||||
{ immediate: true },
|
||||
)
|
||||
|
||||
toggleColorWeakness(settingState.colorWeakness)
|
||||
watch(
|
||||
() => settingState.colorWeakness,
|
||||
(enabled) =>
|
||||
setStyle(document.documentElement, {
|
||||
filter: enabled ? 'invert(100%)' : '',
|
||||
}),
|
||||
{ immediate: true },
|
||||
)
|
||||
|
||||
if (!settingState.dynamicDocumentTitle) {
|
||||
document.title = settingState.sideBarLogo?.title || 'Ray Template'
|
||||
}
|
||||
})
|
||||
watch(
|
||||
() =>
|
||||
settingState.dynamicDocumentTitle
|
||||
? void 0
|
||||
: settingState.sideBarLogo?.title || 'Ray Template',
|
||||
(title) => {
|
||||
if (title) document.title = title
|
||||
},
|
||||
{ immediate: true },
|
||||
)
|
||||
|
||||
return {
|
||||
...toRefs(settingState),
|
||||
|
||||
@ -15,7 +15,6 @@ export default defineComponent({
|
||||
return () => (
|
||||
<DemoPage
|
||||
title={t<string>('title')}
|
||||
description={t<string>('description')}
|
||||
eyebrow={showcaseT<string>('layoutEyebrow')}
|
||||
meta={showcaseT<string>('livePreferences')}
|
||||
>
|
||||
@ -30,7 +29,6 @@ export default defineComponent({
|
||||
</pre>
|
||||
</NCard>
|
||||
<NCard title={t<string>('extension')}>
|
||||
<p class="r-layout-extension-description">{t('slots')}</p>
|
||||
<pre class="r-demo-code">
|
||||
<code>{`const { updateSettingState } = useSettingActions()\n\nupdateSettingState('layoutConfig', {\n mode: 'mixed',\n contentWidth: 'fixed',\n})\n\n<RLayout>\n {{\n header: () => <CustomHeader />,\n footer: () => <CustomFooter />,\n }}\n</RLayout>`}</code>
|
||||
</pre>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user