Skip to content
This repository was archived by the owner on Jul 17, 2026. It is now read-only.

Commit c915b56

Browse files
committed
feat(FontManager): 增加「多字体备选」的输入模式
1 parent eb444fe commit c915b56

2 files changed

Lines changed: 66 additions & 15 deletions

File tree

src/components/Modal/Setting/FontManager.vue

Lines changed: 63 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,32 @@
44
<n-h3 prefix="bar">通用字体</n-h3>
55
<n-card v-if="isElectron" class="set-item">
66
<div class="label">
7-
<n-text class="name">自定义 CSS 字体</n-text>
8-
<n-text class="tip" :depth="3"> 开启后可手动输入字体名称,支持 CSS 字体族 </n-text>
7+
<n-text class="name">字体设置样式</n-text>
8+
<n-text class="tip" :depth="3"> 下面的字体如何显示,如何设置 </n-text>
99
</div>
10-
<n-switch v-model:value="settingStore.useCustomFont" class="set" :round="false" />
10+
<n-select
11+
v-model:value="settingStore.fontSettingStyle"
12+
:options="[
13+
{
14+
label: '自定义 CSS 字体',
15+
value: 'custom',
16+
},
17+
{
18+
label: '多字体备选',
19+
value: 'multi',
20+
},
21+
{
22+
label: '单字体选择',
23+
value: 'single',
24+
},
25+
]"
26+
class="set"
27+
:round="false"
28+
/>
1129
</n-card>
1230
<n-card
1331
class="set-item"
14-
:class="{ 'input-mode': settingStore.useCustomFont || !isElectron }"
32+
:class="{ 'input-mode': isInputMode }"
1533
>
1634
<div class="label">
1735
<div style="display: flex; justify-content: space-between; align-items: center">
@@ -34,14 +52,24 @@
3452
</div>
3553
<n-flex align="center">
3654
<s-input
37-
v-if="settingStore.useCustomFont || !isElectron"
55+
v-if="settingStore.fontSettingStyle === 'custom' || !isElectron"
3856
v-model:value="settingStore.globalFont"
3957
:update-value-on-input="false"
4058
placeholder="输入字体名称"
4159
class="set"
4260
/>
4361
<n-select
44-
v-else
62+
v-else-if="settingStore.fontSettingStyle === 'multi'"
63+
:value="settingStore.globalFont.split(',').map(s => s.trim())"
64+
:on-update-value="(value: Array<string>) => settingStore.globalFont = value.join(', ')"
65+
:options="getOptions('globalFont')"
66+
class="set"
67+
filterable
68+
multiple
69+
tag
70+
/>
71+
<n-select
72+
v-else-if="settingStore.fontSettingStyle === 'single'"
4573
v-model:value="settingStore.globalFont"
4674
:options="getOptions('globalFont')"
4775
class="set"
@@ -54,7 +82,7 @@
5482
<n-h3 prefix="bar">桌面歌词</n-h3>
5583
<n-card
5684
class="set-item"
57-
:class="{ 'input-mode': settingStore.useCustomFont }"
85+
:class="{ 'input-mode': isInputMode }"
5886
>
5987
<div class="label">
6088
<div class="label-header">
@@ -82,15 +110,25 @@
82110
</div>
83111
<n-flex align="center">
84112
<s-input
85-
v-if="settingStore.useCustomFont"
113+
v-if="settingStore.fontSettingStyle === 'custom'"
86114
v-model:value="desktopLyricConfig.fontFamily"
87115
:update-value-on-input="false"
88116
placeholder="输入字体名称"
89117
class="set"
90118
@change="saveDesktopLyricConfig"
91119
/>
92120
<n-select
93-
v-else
121+
v-else-if="settingStore.fontSettingStyle === 'multi'"
122+
:value="desktopLyricConfig.fontFamily.split(',').map(s => s.trim())"
123+
:on-update-value="(value: Array<string>) => desktopLyricConfig.fontFamily = value.join(', ')"
124+
:options="getOptions('desktop')"
125+
class="set"
126+
filterable
127+
multiple
128+
tag
129+
/>
130+
<n-select
131+
v-else-if="settingStore.fontSettingStyle === 'single'"
94132
v-model:value="desktopLyricConfig.fontFamily"
95133
:options="getOptions('desktop')"
96134
class="set"
@@ -106,7 +144,7 @@
106144
v-for="font in lyricFontConfigs"
107145
:key="font.keySetting"
108146
class="set-item"
109-
:class="{ 'input-mode': settingStore.useCustomFont || !isElectron }"
147+
:class="{ 'input-mode': isInputMode }"
110148
>
111149
<div class="label">
112150
<div class="label-header">
@@ -129,14 +167,24 @@
129167
</div>
130168
<n-flex align="center">
131169
<s-input
132-
v-if="settingStore.useCustomFont || !isElectron"
170+
v-if="settingStore.fontSettingStyle === 'custom' || !isElectron"
133171
v-model:value="settingStore[font.keySetting]"
134172
:update-value-on-input="false"
135173
placeholder="输入字体名称"
136174
class="set"
137175
/>
138176
<n-select
139-
v-else
177+
v-else-if="settingStore.fontSettingStyle === 'multi'"
178+
:value="settingStore[font.keySetting].split(',').map(s => s.trim())"
179+
:on-update-value="(value: Array<string>) => settingStore[font.keySetting] = value.join(', ')"
180+
:options="getOptions(font.keySetting)"
181+
class="set"
182+
filterable
183+
multiple
184+
tag
185+
/>
186+
<n-select
187+
v-else-if="settingStore.fontSettingStyle === 'single'"
140188
v-model:value="settingStore[font.keySetting]"
141189
:options="getOptions(font.keySetting)"
142190
class="set"
@@ -165,6 +213,9 @@ const systemFonts = ref<SelectOption[]>([]);
165213
// 桌面歌词配置
166214
const desktopLyricConfig = reactive<LyricConfig>({ ...defaultDesktopLyricConfig });
167215
216+
// 是否为输入模式
217+
const isInputMode = computed(() => settingStore.fontSettingStyle !== "single" || !isElectron);
218+
168219
// 获取下拉选项
169220
const getOptions = (key: string) => {
170221
const isGlobal = key === "globalFont";

src/stores/setting.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ export interface SettingState {
2525
themeVariant: "primary" | "secondary" | "tertiary" | "neutral" | "neutralVariant" | "error";
2626
/** 主题跟随封面 */
2727
themeFollowCover: boolean;
28+
/** 字体设置样式 */
29+
fontSettingStyle: "single" | "multi" | "custom";
2830
/** 全局字体 */
2931
globalFont: "default" | string;
3032
/** 歌词区域字体 */
@@ -408,8 +410,6 @@ export interface SettingState {
408410
playerFollowCoverColor: boolean;
409411
/** 进度条悬浮时显示歌词 */
410412
progressLyricShow: boolean;
411-
/** 是否使用自定义字体输入 */
412-
useCustomFont: boolean;
413413
/** Discord RPC 配置 */
414414
discordRpc: {
415415
/** 是否启用 Discord RPC */
@@ -448,6 +448,7 @@ export const useSettingStore = defineStore("setting", {
448448
themeFollowCover: false,
449449
themeGlobalColor: false,
450450
themeVariant: "secondary",
451+
fontSettingStyle: "single",
451452
globalFont: "default",
452453
LyricFont: "follow",
453454
japaneseLyricFont: "follow",
@@ -666,7 +667,6 @@ export const useSettingStore = defineStore("setting", {
666667
},
667668
playerFollowCoverColor: true,
668669
progressLyricShow: true,
669-
useCustomFont: false,
670670
discordRpc: {
671671
enabled: false,
672672
showWhenPaused: true,

0 commit comments

Comments
 (0)