Skip to content

Commit b1669b9

Browse files
🎈 perf: 优化ko字体
1 parent cfc6637 commit b1669b9

2 files changed

Lines changed: 49 additions & 80 deletions

File tree

src/components/Setting/GeneralSetting.vue

Lines changed: 29 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -242,81 +242,29 @@
242242
</n-flex>
243243
</n-card>
244244
<n-collapse-transition :show="settingStore.LyricFont !== 'follow'">
245-
<n-card class="set-item">
245+
<n-card
246+
v-for="item in languageFontSettings"
247+
:key="item.key"
248+
class="set-item"
249+
>
246250
<div class="label">
247-
<n-text class="name">英语歌词字体</n-text>
248-
<n-text class="tip" :depth="3"> 是否在歌词为英语时单独设置字体 </n-text>
251+
<n-text class="name">{{ item.name }}歌词字体</n-text>
252+
<n-text class="tip" :depth="3"> {{ item.tip }} </n-text>
249253
</div>
250254
<n-flex>
251255
<Transition name="fade" mode="out-in">
252256
<n-button
253-
v-if="settingStore.englishLyricFont !== 'follow'"
257+
v-if="settingStore[item.key] !== 'follow'"
254258
type="primary"
255259
strong
256260
secondary
257-
@click="settingStore.englishLyricFont = 'follow'"
261+
@click="settingStore[item.key] = 'follow'"
258262
>
259263
恢复默认
260264
</n-button>
261265
</Transition>
262266
<n-select
263-
v-model:value="settingStore.englishLyricFont"
264-
:options="[
265-
{ label: '跟随全局', value: 'follow' },
266-
...allFontsData.filter((v) => v.value !== 'default'),
267-
]"
268-
class="set"
269-
filterable
270-
/>
271-
</n-flex>
272-
</n-card>
273-
<n-card class="set-item">
274-
<div class="label">
275-
<n-text class="name">日语歌词字体</n-text>
276-
<n-text class="tip" :depth="3"> 是否在歌词为日语时单独设置字体 </n-text>
277-
</div>
278-
<n-flex>
279-
<Transition name="fade" mode="out-in">
280-
<n-button
281-
v-if="settingStore.japaneseLyricFont !== 'follow'"
282-
type="primary"
283-
strong
284-
secondary
285-
@click="settingStore.japaneseLyricFont = 'follow'"
286-
>
287-
恢复默认
288-
</n-button>
289-
</Transition>
290-
<n-select
291-
v-model:value="settingStore.japaneseLyricFont"
292-
:options="[
293-
{ label: '跟随全局', value: 'follow' },
294-
...allFontsData.filter((v) => v.value !== 'default'),
295-
]"
296-
class="set"
297-
filterable
298-
/>
299-
</n-flex>
300-
</n-card>
301-
<n-card class="set-item">
302-
<div class="label">
303-
<n-text class="name">韩语歌词字体</n-text>
304-
<n-text class="tip" :depth="3"> 是否在歌词为韩语时单独设置字体 </n-text>
305-
</div>
306-
<n-flex>
307-
<Transition name="fade" mode="out-in">
308-
<n-button
309-
v-if="settingStore.koreanLyricFont !== 'follow'"
310-
type="primary"
311-
strong
312-
secondary
313-
@click="settingStore.koreanLyricFont = 'follow'"
314-
>
315-
恢复默认
316-
</n-button>
317-
</Transition>
318-
<n-select
319-
v-model:value="settingStore.koreanLyricFont"
267+
v-model:value="settingStore[item.key]"
320268
:options="[
321269
{ label: '跟随全局', value: 'follow' },
322270
...allFontsData.filter((v) => v.value !== 'default'),
@@ -431,6 +379,25 @@ const closeTaskbarProgress = (val: boolean) => {
431379
if (!val) window.electron.ipcRenderer.send("set-bar", "none");
432380
};
433381
382+
// 语言字体配置
383+
const languageFontSettings = [
384+
{
385+
name: "英语",
386+
key: "englishLyricFont" as const,
387+
tip: "是否在歌词为英语时单独设置字体",
388+
},
389+
{
390+
name: "日语",
391+
key: "japaneseLyricFont" as const,
392+
tip: "是否在歌词为日语时单独设置字体",
393+
},
394+
{
395+
name: "韩语",
396+
key: "koreanLyricFont" as const,
397+
tip: "是否在歌词为韩语时单独设置字体",
398+
},
399+
];
400+
434401
// 获取全部系统字体
435402
const getAllSystemFonts = async () => {
436403
const allFonts = await window.electron.ipcRenderer.invoke("get-all-fonts");

src/utils/format.ts

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -47,19 +47,19 @@ export const formatSongsList = (data: any[]): SongType[] => {
4747
typeof item.album === "string"
4848
? item.album
4949
: {
50-
id: (item.album || item.al)?.id,
51-
name: (item.album || item.al)?.name,
52-
cover: (item.album || item.al)?.picUrl,
53-
},
50+
id: (item.album || item.al)?.id,
51+
name: (item.album || item.al)?.name,
52+
cover: (item.album || item.al)?.picUrl,
53+
},
5454
alia: isArray(item.alia || item.alias || item.transNames || item.tns)
5555
? item.alia?.[0] || item.alias?.[0] || item.transNames?.[0] || item.tns?.[0]
5656
: item.alia,
5757
dj: item.dj
5858
? {
59-
id: item.mainTrackId || item.id,
60-
name: item.dj?.brand,
61-
creator: item.dj?.nickname,
62-
}
59+
id: item.mainTrackId || item.id,
60+
name: item.dj?.brand,
61+
creator: item.dj?.nickname,
62+
}
6363
: undefined,
6464
...getCoverUrl(item),
6565
duration: Number(item.duration || item.dt || 0),
@@ -175,13 +175,13 @@ export const formatCommentList = (data: any[]): CommentType[] => {
175175
beReplied:
176176
item.beReplied?.length > 0
177177
? {
178-
content: item.beReplied[0]?.content,
179-
user: {
180-
id: item.beReplied[0]?.user.userId,
181-
name: item.beReplied[0]?.user.nickname,
182-
avatarUrl: item.beReplied[0]?.user.avatarUrl,
183-
},
184-
}
178+
content: item.beReplied[0]?.content,
179+
user: {
180+
id: item.beReplied[0]?.user.userId,
181+
name: item.beReplied[0]?.user.nickname,
182+
avatarUrl: item.beReplied[0]?.user.avatarUrl,
183+
},
184+
}
185185
: undefined,
186186
time: item.time,
187187
likedCount: item.likedCount,
@@ -197,9 +197,9 @@ export const formatCommentList = (data: any[]): CommentType[] => {
197197
},
198198
ip: item?.ip
199199
? {
200-
ip: item.ip,
201-
location: item.location,
202-
}
200+
ip: item.ip,
201+
location: item.location,
202+
}
203203
: undefined,
204204
}));
205205
};
@@ -280,6 +280,8 @@ const getCoverSizeUrl = (url: string, size: number | null = null) => {
280280
export const getLyricLanguage = (lyric: string): string => {
281281
// 判断日语 根据平假名和片假名
282282
if (/[\u3040-\u309f\u30a0-\u30ff]/.test(lyric)) return "ja";
283+
// 判断韩语 根据韩文音节
284+
if (/[\uac00-\ud7af]/.test(lyric)) return "ko";
283285
// 判断简体中文 根据中日韩统一表意文字基本区
284286
if (/[\u4e00-\u9fa5]/.test(lyric)) return "zh-CN";
285287
// 默认英语

0 commit comments

Comments
 (0)