Skip to content

Commit 7142991

Browse files
authored
Merge pull request #28 from imsyy/dev
feat: 支持音译歌词
2 parents bc7031b + a60e557 commit 7142991

File tree

13 files changed

+246
-234
lines changed

13 files changed

+246
-234
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,8 @@ npm build
131131

132132
- [NeteaseCloudMusicApi](https://github.com/Binaryify/NeteaseCloudMusicApi)
133133
- [YesPlayMusic](https://github.com/qier222/YesPlayMusic)
134+
- [UnblockNeteaseMusic](https://github.com/UnblockNeteaseMusic/server)
135+
- [BlurLyric](https://github.com/Project-And-Factory/BlurLyric)
134136
- [Vue-mmPlayer](https://github.com/maomao1996/Vue-mmPlayer)
135137

136138
## 📜 开源许可

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "splayer",
3-
"version": "1.1.4",
3+
"version": "1.1.5",
44
"author": "imsyy",
55
"home": "https://imsyy.top",
66
"github": "https://github.com/imsyy/SPlayer",

src/components/Nav/index.vue

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<div class="logo" @click="router.push('/')">
55
<img src="/images/logo/favicon.svg" alt="logo" />
66
</div>
7-
<div class="controls">
7+
<div :class="site.searchInputActive ? 'controls hidden' : 'controls'">
88
<n-icon size="22" :component="Left" @click="router.go(-1)" />
99
<n-icon size="22" :component="Right" @click="router.go(1)" />
1010
</div>
@@ -68,13 +68,14 @@ import {
6868
SunOne,
6969
Moon,
7070
} from "@icon-park/vue-next";
71-
import { userStore, settingStore } from "@/store";
71+
import { userStore, settingStore, siteStore } from "@/store";
7272
import { useRouter } from "vue-router";
7373
import AboutSite from "@/components/DataModal/AboutSite.vue";
7474
import SearchInp from "@/components/SearchInp/index.vue";
7575
7676
const router = useRouter();
7777
const user = userStore();
78+
const site = siteStore();
7879
const setting = settingStore();
7980
const aboutSiteRef = ref(null);
8081
const timeOut = ref(null);
@@ -361,6 +362,7 @@ watch(
361362
362363
onMounted(() => {
363364
changeUserOptions(user.userLogin);
365+
console.log(router);
364366
});
365367
366368
onBeforeUnmount(() => {
@@ -402,7 +404,10 @@ nav {
402404
flex-direction: row;
403405
align-items: center;
404406
@media (max-width: 520px) {
405-
display: none;
407+
&.hidden{
408+
display: none;
409+
}
410+
406411
}
407412
.n-icon {
408413
margin: 0 4px;

src/components/Player/BigPlayer.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,9 @@
120120
>
121121
<n-icon
122122
v-if="music.getPlaySongTransl"
123-
:class="setting.getShowTransl ? 'open' : ''"
123+
:class="setting.showTransl ? 'open' : ''"
124124
:component="GTranslateFilled"
125-
@click="setting.setShowTransl(!setting.getShowTransl)"
125+
@click="setting.setShowTransl(!setting.showTransl)"
126126
/>
127127
<n-icon
128128
class="open"

src/components/Player/CountDown.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
:style="{ animationPlayState: music.getPlayState ? 'running' : 'paused' }"
66
v-if="
77
remainingPoint <= 2 &&
8-
totalDuration > 3 &&
8+
totalDuration > 1 &&
99
music.getPlaySongLyric.lrc[0]
1010
"
1111
>

src/components/Player/RollingLyrics.vue

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,26 @@
5050
</span>
5151
<span
5252
v-show="
53-
music.getPlaySongLyric.hasTran &&
54-
setting.getShowTransl &&
53+
music.getPlaySongLyric.hasLrcTran &&
54+
setting.showTransl &&
5555
item.tran
5656
"
5757
:style="{ fontSize: setting.lyricsFontSize - 1 + 'vh' }"
5858
class="lyric-fy"
5959
>
6060
{{ item.tran }}</span
6161
>
62+
<span
63+
v-show="
64+
music.getPlaySongLyric.hasLrcRoma &&
65+
setting.showRoma &&
66+
item.roma
67+
"
68+
:style="{ fontSize: setting.lyricsFontSize - 1.5 + 'vh' }"
69+
class="lyric-roma"
70+
>
71+
{{ item.roma }}</span
72+
>
6273
</div>
6374
</div>
6475
</template>
@@ -88,11 +99,11 @@
8899
v-for="(v, i) in item.content"
89100
:key="i"
90101
:style="{
91-
'--dur': v.duration - 0.15 + 's',
102+
'--dur': `${Math.max(v.duration - 0.15, 0.1)}s`,
92103
}"
93104
:class="
94-
music.getPlaySongLyricIndex == index &&
95-
music.getPlaySongTime.currentTime + 0.15 >= v.time
105+
music.getPlaySongLyricIndex === index &&
106+
music.getPlaySongTime.currentTime + 0.15 > v.time
96107
? 'text fill'
97108
: 'text'
98109
"
@@ -102,15 +113,26 @@
102113
</div>
103114
<span
104115
v-show="
105-
music.getPlaySongLyric.hasTran &&
106-
setting.getShowTransl &&
116+
music.getPlaySongLyric.hasYrcTran &&
117+
setting.showTransl &&
107118
item.tran
108119
"
109120
:style="{ fontSize: setting.lyricsFontSize - 1 + 'vh' }"
110121
class="lyric-fy"
111122
>
112-
{{ item.tran }}</span
123+
{{ item.tran }}
124+
</span>
125+
<span
126+
v-show="
127+
music.getPlaySongLyric.hasYrcRoma &&
128+
setting.showRoma &&
129+
item.roma
130+
"
131+
:style="{ fontSize: setting.lyricsFontSize - 1.5 + 'vh' }"
132+
class="lyric-roma"
113133
>
134+
{{ item.roma }}
135+
</span>
114136
</div>
115137
</div>
116138
</template>
@@ -268,7 +290,8 @@ const lrcTextClick = (time) => {
268290
}
269291
}
270292
}
271-
.lyric-fy {
293+
.lyric-fy,
294+
.lyric-roma {
272295
margin-top: 4px;
273296
transition: all 0.3s;
274297
opacity: 0.6;

src/components/SearchInp/index.vue

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
<template>
22
<div class="searchInp">
33
<n-input
4-
:class="inputActive ? 'input focus' : 'input'"
4+
:class="site.searchInputActive ? 'input focus' : 'input'"
55
:input-props="{ autoComplete: false }"
6+
ref="searchInpRef"
67
round
78
clearable
89
placeholder="搜索音乐/视频"
@@ -14,7 +15,7 @@
1415
<template #prefix>
1516
<n-icon
1617
size="16"
17-
:class="inputActive ? 'active' : ''"
18+
:class="site.searchInputActive ? 'active' : ''"
1819
:component="Search"
1920
/>
2021
</template>
@@ -23,7 +24,7 @@
2324
<n-card
2425
class="list"
2526
v-show="
26-
inputActive &&
27+
site.searchInputActive &&
2728
!inputValue &&
2829
(music.getSearchHistory[0] || searchData.hot[0])
2930
"
@@ -93,7 +94,7 @@
9394
<CollapseTransition easing="ease-in-out">
9495
<n-card
9596
class="list"
96-
v-show="inputActive && inputValue && searchData.suggest"
97+
v-show="site.searchInputActive && inputValue && searchData.suggest"
9798
content-style="padding: 0"
9899
>
99100
<n-scrollbar>
@@ -195,20 +196,21 @@ import {
195196
import CollapseTransition from "@ivanv/vue-collapse-transition/src/CollapseTransition.vue";
196197
import debounce from "@/utils/debounce";
197198
import { useRouter } from "vue-router";
198-
import { musicStore, settingStore } from "@/store";
199+
import { musicStore, settingStore, siteStore } from "@/store";
200+
199201
const router = useRouter();
200202
const music = musicStore();
201203
const setting = settingStore();
204+
const site = siteStore();
202205
203206
// 输入框内容
204207
const inputValue = ref(null);
205-
206-
// 输入框激活状态
207-
const inputActive = ref(false);
208+
const searchInpRef = ref(null);
208209
209210
// 输入框激活事件
210211
const inputFocus = () => {
211-
inputActive.value = true;
212+
searchInpRef.value?.focus();
213+
site.searchInputActive = true;
212214
music.showPlayList = false;
213215
getSearchHotData();
214216
};
@@ -274,7 +276,8 @@ const toSearch = (val, type) => {
274276
const inputkeydown = (e) => {
275277
if (e.key === "Enter" && inputValue.value != null) {
276278
console.log("执行搜索" + inputValue.value.trim());
277-
inputActive.value = false;
279+
searchInpRef.value?.blur();
280+
site.searchInputActive = false;
278281
// 写入搜索历史
279282
music.setSearchHistory(inputValue.value.trim());
280283
router.push({
@@ -306,13 +309,15 @@ onMounted(() => {
306309
getSearchHotData();
307310
// 搜索框失焦
308311
document.addEventListener("click", () => {
309-
inputActive.value = false;
312+
searchInpRef.value?.blur();
313+
site.searchInputActive = false;
310314
});
311315
});
312316
313317
onUnmounted(() => {
314318
document.removeEventListener("click", () => {
315-
inputActive.value = false;
319+
searchInpRef.value?.blur();
320+
site.searchInputActive = false;
316321
});
317322
});
318323
@@ -333,7 +338,10 @@ watch(
333338
watch(
334339
() => music.showPlayList,
335340
(val) => {
336-
if (val) inputActive.value = false;
341+
if (val) {
342+
searchInpRef.value?.blur();
343+
site.searchInputActive = false;
344+
}
337345
}
338346
);
339347
</script>

src/store/musicData.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -232,22 +232,22 @@ const useMusicDataStore = defineStore("musicData", {
232232
setLikeSong(id, like).then((res) => {
233233
if (res.code == 200) {
234234
list.push(id);
235-
$message.info("成功喜欢歌曲");
235+
$message.info("已添加到我喜欢的音乐");
236236
} else {
237-
$message.error("喜欢歌曲时发生错误");
237+
$message.error("喜欢音乐时发生错误");
238238
}
239239
});
240240
} else {
241-
$message.info("我喜欢的列表中已存在该歌曲");
241+
$message.info("我喜欢的音乐中已存在该歌曲");
242242
}
243243
} else {
244244
if (exists) {
245245
setLikeSong(id, like).then((res) => {
246246
if (res.code == 200) {
247247
list.splice(list.indexOf(id), 1);
248-
$message.info("成功取消喜欢歌曲");
248+
$message.info("已从我喜欢的音乐中移除");
249249
} else {
250-
$message.error("取消喜欢歌曲时发生错误");
250+
$message.error("取消喜欢音乐时发生错误");
251251
}
252252
});
253253
} else {

src/store/settingData.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ const useSettingDataStore = defineStore("settingData", {
2626
showYrc: true,
2727
// 是否显示歌词翻译
2828
showTransl: true,
29+
// 是否显示歌词音译
30+
showRoma: true,
2931
// 歌曲音质
3032
songLevel: "exhigh",
3133
// 歌词位置
@@ -53,10 +55,6 @@ const useSettingDataStore = defineStore("settingData", {
5355
getSiteTheme(state) {
5456
return state.theme;
5557
},
56-
// 获取是否开启翻译
57-
getShowTransl(state) {
58-
return state.showTransl;
59-
},
6058
},
6159
actions: {
6260
// 切换明暗模式

src/store/siteData.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ const useSiteDataStore = defineStore("siteData", {
77
siteTitle: "SPlayer",
88
// 封面主题色
99
songPicColor: "rgb(128,128,128)",
10+
// 搜索框激活状态
11+
searchInputActive: false,
1012
};
1113
},
1214
getters: {},

0 commit comments

Comments
 (0)