Skip to content

Commit 5ac9f72

Browse files
committed
简单实装歌词掩码功能
修正空拍组件布局
1 parent bfacb62 commit 5ac9f72

File tree

6 files changed

+50
-26
lines changed

6 files changed

+50
-26
lines changed

locales/en-US/translation.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
"lyrics": "Lyrics",
6161
"showTranslation": "Show Translation",
6262
"showRoman": "Show Romanization",
63+
"maskObsceneWords": "Mask Obscene Words",
6364
"word": "Word",
6465
"fadeWidth": "Fade Width"
6566
},
@@ -513,4 +514,4 @@
513514
"updateRefresh": "Site updated, refresh to use the latest version!",
514515
"refresh": "Refresh"
515516
}
516-
}
517+
}

locales/zh-CN/translation.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
"lyrics": "歌词",
6161
"showTranslation": "显示翻译",
6262
"showRoman": "显示音译",
63+
"maskObsceneWords": "屏蔽不雅用语",
6364
"word": "单词",
6465
"fadeWidth": "过渡宽度"
6566
},
@@ -513,4 +514,4 @@
513514
"updateRefresh": "网站已更新,刷新网页以使用最新版本!",
514515
"refresh": "刷新"
515516
}
516-
}
517+
}

src/components/AMLLWrapper/index.tsx

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,19 @@
22
// #warning Using local Apple Music Like Lyrics, skip importing css style
33
// #else
44
import "@applemusic-like-lyrics/core/style.css";
5+
56
// #endif
67

8+
import { audioEngine } from "$/modules/audio/audio-engine";
9+
import { audioPlayingAtom, currentTimeAtom } from "$/modules/audio/states";
10+
import {
11+
hideObsceneWordsAtom,
12+
lyricWordFadeWidthAtom,
13+
showRomanLinesAtom,
14+
showTranslationLinesAtom,
15+
} from "$/modules/settings/states/preview";
16+
import { isDarkThemeAtom, lyricLinesAtom } from "$/states/main.ts";
17+
import { MaskObsceneWordsMode } from "@applemusic-like-lyrics/core";
718
import {
819
LyricPlayer,
920
type LyricPlayerRef,
@@ -13,14 +24,6 @@ import structuredClone from "@ungap/structured-clone";
1324
import classNames from "classnames";
1425
import { useAtomValue } from "jotai";
1526
import { memo, useEffect, useMemo, useRef } from "react";
16-
import { audioEngine } from "$/modules/audio/audio-engine";
17-
import { audioPlayingAtom, currentTimeAtom } from "$/modules/audio/states";
18-
import {
19-
lyricWordFadeWidthAtom,
20-
showRomanLinesAtom,
21-
showTranslationLinesAtom,
22-
} from "$/modules/settings/states/preview";
23-
import { isDarkThemeAtom, lyricLinesAtom } from "$/states/main.ts";
2427
import styles from "./index.module.css";
2528

2629
export const AMLLWrapper = memo(() => {
@@ -30,6 +33,7 @@ export const AMLLWrapper = memo(() => {
3033
const darkMode = useAtomValue(isDarkThemeAtom);
3134
const showTranslationLines = useAtomValue(showTranslationLinesAtom);
3235
const showRomanLines = useAtomValue(showRomanLinesAtom);
36+
const hideObsceneWords = useAtomValue(hideObsceneWordsAtom);
3337
const wordFadeWidth = useAtomValue(lyricWordFadeWidthAtom);
3438
const playerRef = useRef<LyricPlayerRef>(null);
3539

@@ -63,6 +67,11 @@ export const AMLLWrapper = memo(() => {
6367
lyricLines={lyricLines}
6468
currentTime={currentTime}
6569
playing={isPlaying}
70+
maskObsceneWordsMode={
71+
hideObsceneWords
72+
? MaskObsceneWordsMode.FullMask
73+
: MaskObsceneWordsMode.Disabled
74+
}
6675
wordFadeWidth={wordFadeWidth}
6776
ref={playerRef}
6877
/>

src/components/RibbonBar/preview-mode.tsx

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,16 @@
99
* https://github.com/Steve-xmh/amll-ttml-tool/blob/main/LICENSE
1010
*/
1111

12-
import { Checkbox, Grid, Text, TextField } from "@radix-ui/themes";
13-
import { useAtom } from "jotai";
14-
import { forwardRef } from "react";
15-
import { useTranslation } from "react-i18next";
1612
import {
13+
hideObsceneWordsAtom,
1714
lyricWordFadeWidthAtom,
1815
showRomanLinesAtom,
1916
showTranslationLinesAtom,
2017
} from "$/modules/settings/states/preview";
18+
import { Checkbox, Grid, Text, TextField } from "@radix-ui/themes";
19+
import { useAtom } from "jotai";
20+
import { forwardRef } from "react";
21+
import { useTranslation } from "react-i18next";
2122
import { RibbonFrame, RibbonSection } from "./common";
2223

2324
export const PreviewModeRibbonBar = forwardRef<HTMLDivElement>(
@@ -26,6 +27,8 @@ export const PreviewModeRibbonBar = forwardRef<HTMLDivElement>(
2627
showTranslationLinesAtom,
2728
);
2829
const [showRomanLine, setShowRomanLine] = useAtom(showRomanLinesAtom);
30+
const [hideObsceneWords, setHideObsceneWords] =
31+
useAtom(hideObsceneWordsAtom);
2932
const [lyricWordFadeWidth, setLyricWordFadeWidth] = useAtom(
3033
lyricWordFadeWidthAtom,
3134
);
@@ -49,6 +52,13 @@ export const PreviewModeRibbonBar = forwardRef<HTMLDivElement>(
4952
checked={showRomanLine}
5053
onCheckedChange={(v) => setShowRomanLine(!!v)}
5154
/>
55+
<Text wrap="nowrap" size="1">
56+
{t("ribbonBar.previewMode.maskObsceneWords", "屏蔽不雅用语")}
57+
</Text>
58+
<Checkbox
59+
checked={hideObsceneWords}
60+
onCheckedChange={(v) => setHideObsceneWords(!!v)}
61+
/>
5262
</Grid>
5363
</RibbonSection>
5464
<RibbonSection label={t("ribbonBar.previewMode.word", "单词")}>

src/components/RibbonBar/sync-mode.tsx

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,6 @@
99
* https://github.com/Steve-xmh/amll-ttml-tool/blob/main/LICENSE
1010
*/
1111

12-
import {
13-
Checkbox,
14-
Flex,
15-
Grid,
16-
Slider,
17-
Text,
18-
TextField,
19-
} from "@radix-ui/themes";
20-
import { useAtom, useAtomValue } from "jotai";
21-
import { type FC, forwardRef } from "react";
22-
import { useTranslation } from "react-i18next";
2312
import { useCurrentLocation } from "$/modules/lyric-editor/utils/lyric-states.ts";
2413
import {
2514
displayRomanizationInSyncAtom,
@@ -39,6 +28,17 @@ import {
3928
keySyncNextAtom,
4029
keySyncStartAtom,
4130
} from "$/states/keybindings.ts";
31+
import {
32+
Checkbox,
33+
Flex,
34+
Grid,
35+
Slider,
36+
Text,
37+
TextField,
38+
} from "@radix-ui/themes";
39+
import { useAtom, useAtomValue } from "jotai";
40+
import { type FC, forwardRef } from "react";
41+
import { useTranslation } from "react-i18next";
4242
import { KeyBinding } from "../KeyBinding/index.tsx";
4343
import { RibbonFrame, RibbonSection } from "./common";
4444

@@ -95,7 +95,9 @@ export const SyncModeRibbonBar: FC = forwardRef<HTMLDivElement>(
9595
<RibbonSection
9696
label={t("ribbonBar.syncMode.currentEmptyBeat", "当前空拍")}
9797
>
98-
<EmptyBeatField />
98+
<Grid columns="0fr 4em" gap="4" gapY="1" flexGrow="1" align="center">
99+
<EmptyBeatField />
100+
</Grid>
99101
</RibbonSection>
100102
<RibbonSection
101103
label={t("ribbonBar.syncMode.syncAdjustment", "打轴调整")}

src/modules/settings/states/preview.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ export const showTranslationLinesAtom = atomWithStorage(
55
false,
66
);
77
export const showRomanLinesAtom = atomWithStorage("showRomanLines", false);
8+
export const hideObsceneWordsAtom = atomWithStorage("hideObsceneWords", false);
89
export const lyricWordFadeWidthAtom = atomWithStorage(
910
"lyricWordFadeWidth",
1011
0.5,

0 commit comments

Comments
 (0)