Skip to content

Commit 1b9575b

Browse files
committed
✨ feat: 加个新模式
1 parent 4f74566 commit 1b9575b

16 files changed

Lines changed: 98 additions & 114 deletions

File tree

components.d.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ declare module 'vue' {
8282
NGi: typeof import('naive-ui')['NGi']
8383
NGlobalStyle: typeof import('naive-ui')['NGlobalStyle']
8484
NGrid: typeof import('naive-ui')['NGrid']
85+
NGridItem: typeof import('naive-ui')['NGridItem']
8586
NH1: typeof import('naive-ui')['NH1']
8687
NH2: typeof import('naive-ui')['NH2']
8788
NH3: typeof import('naive-ui')['NH3']
@@ -124,6 +125,7 @@ declare module 'vue' {
124125
NTag: typeof import('naive-ui')['NTag']
125126
NText: typeof import('naive-ui')['NText']
126127
NThing: typeof import('naive-ui')['NThing']
128+
NUpload: typeof import('naive-ui')['NUpload']
127129
NVirtualList: typeof import('naive-ui')['NVirtualList']
128130
OtherSetting: typeof import('./src/components/Setting/OtherSetting.vue')['default']
129131
PersonalFM: typeof import('./src/components/Player/PersonalFM.vue')['default']
@@ -157,6 +159,7 @@ declare module 'vue' {
157159
SongUnlockManager: typeof import('./src/components/Modal/Setting/SongUnlockManager.vue')['default']
158160
SvgIcon: typeof import('./src/components/Global/SvgIcon.vue')['default']
159161
TextContainer: typeof import('./src/components/Global/TextContainer.vue')['default']
162+
ThemeConfig: typeof import('./src/components/Modal/Setting/ThemeConfig.vue')['default']
160163
ThirdSetting: typeof import('./src/components/Setting/ThirdSetting.vue')['default']
161164
UpdateApp: typeof import('./src/components/Modal/UpdateApp.vue')['default']
162165
UpdatePlaylist: typeof import('./src/components/Modal/UpdatePlaylist.vue')['default']

src/components/Card/SongCard.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,7 @@ const localCover = async (show: boolean) => {
420420
justify-content: center;
421421
width: 40px;
422422
.n-icon {
423+
color: var(--primary-hex);
423424
transition: transform 0.3s;
424425
cursor: pointer;
425426
&:hover {

src/components/Global/Provider.vue

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,9 @@ import {
3737
useMessage,
3838
useNotification,
3939
GlobalThemeOverrides,
40-
NButton,
4140
} from "naive-ui";
4241
import { useSettingStore, useStatusStore } from "@/stores";
4342
import { setColorSchemes } from "@/utils/color";
44-
import { openLink } from "@/utils/helper";
4543
// import { rgbToHex } from "@imsyy/color-utils";
4644
import themeColor from "@/assets/data/themeColor.json";
4745
@@ -279,43 +277,5 @@ watchDebounced(
279277
280278
onMounted(() => {
281279
changeGlobalTheme();
282-
283-
// 增加启动次数
284-
settingStore.appLaunchCount++;
285-
286-
// 检查是否需要弹出 Star 提示(第 100 次启动且未隐藏)
287-
if (settingStore.appLaunchCount === 100 && !settingStore.hideStarPopup) {
288-
const dialog = window.$dialog.create({
289-
title: "🎉 感谢",
290-
content: "SPlayer已经被打开了100次,喜欢此项目请考虑在 Github 仓库给作者一个 Star 哦",
291-
type: "success",
292-
closable: false,
293-
maskClosable: false,
294-
action: () => h("div", { style: "display: flex; justify-content: flex-end; gap: 12px;" }, [
295-
h(NButton, {
296-
size: "small",
297-
onClick: () => {
298-
settingStore.hideStarPopup = true;
299-
window.$message.success("已永久关闭此类弹窗");
300-
dialog.destroy();
301-
}
302-
}, { default: () => "永久关闭此类弹窗" }),
303-
h(NButton, {
304-
size: "small",
305-
onClick: () => {
306-
dialog.destroy();
307-
}
308-
}, { default: () => "我知道了" }),
309-
h(NButton, {
310-
type: "primary",
311-
size: "small",
312-
onClick: () => {
313-
openLink("https://github.com/imsyy/SPlayer");
314-
dialog.destroy();
315-
}
316-
}, { default: () => "去 Github 支持" })
317-
])
318-
});
319-
}
320280
});
321281
</script>

src/components/Layout/Menu.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ import { renderIcon } from "@/utils/helper";
3434
import { openCreatePlaylist } from "@/utils/modal";
3535
import { debounce } from "lodash-es";
3636
import { isLogin } from "@/utils/auth";
37-
import { isDevBuild, isElectron } from "@/utils/env";
37+
import { isElectron } from "@/utils/env";
3838
import { usePlayerController } from "@/core/player/PlayerController";
3939
4040
const router = useRouter();
@@ -105,7 +105,7 @@ const menuOptions = computed<MenuOption[] | MenuGroupOption[]>(() => {
105105
h(NText, null, () => "我喜欢的音乐"),
106106
!settingStore.hideHeartbeatMode
107107
? h(NButton, {
108-
type: "tertiary",
108+
type: "primary",
109109
round: true,
110110
strong: true,
111111
secondary: true,
@@ -145,7 +145,7 @@ const menuOptions = computed<MenuOption[] | MenuGroupOption[]>(() => {
145145
},
146146
() => "下载管理",
147147
),
148-
show: isDevBuild && isElectron && !settingStore.hideDownload,
148+
show: statusStore.isDeveloperMode && isElectron && !settingStore.hideDownload,
149149
icon: renderIcon("Download"),
150150
},
151151
{

src/components/Menu/SongListMenu.vue

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ import { songUrl } from "@/api/song";
3333
import { dailyRecommendDislike } from "@/api/rec";
3434
import { formatSongsList } from "@/utils/format";
3535
import { usePlayerController } from "@/core/player/PlayerController";
36-
import { isDevBuild } from "@/utils/env";
3736
3837
const emit = defineEmits<{ removeSong: [index: number[]] }>();
3938
@@ -251,14 +250,14 @@ const openDropdown = (
251250
{
252251
key: "download",
253252
label: "下载歌曲",
254-
show: isDevBuild && !isLocal && type === "song" && !isDownloading,
253+
show: statusStore.isDeveloperMode && !isLocal && type === "song" && !isDownloading,
255254
props: { onClick: () => openDownloadSong(song) },
256255
icon: renderIcon("Download"),
257256
},
258257
{
259258
key: "retry-download",
260259
label: "重试下载",
261-
show: isDevBuild && isDownloading,
260+
show: statusStore.isDeveloperMode && isDownloading,
262261
props: { onClick: () => downloadManager.retryDownload(song.id) },
263262
icon: renderIcon("Refresh"),
264263
},

src/components/Modal/BatchList.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
<n-flex class="menu">
4242
<!-- 批量下载 -->
4343
<n-button
44-
v-if="isDevBuild"
44+
v-if="statusStore.isDeveloperMode"
4545
:disabled="!checkCount || isLocal"
4646
type="primary"
4747
strong
@@ -111,11 +111,11 @@ import { isArray, isObject } from "lodash-es";
111111
import { openPlaylistAdd } from "@/utils/modal";
112112
import { deleteSongs } from "@/utils/auth";
113113
import { NInput, NInputNumber, NButton, NText, NFlex } from "naive-ui";
114-
import { useLocalStore } from "@/stores";
114+
import { useLocalStore, useStatusStore } from "@/stores";
115115
import { openDownloadSongs } from "@/utils/modal";
116-
import { isDevBuild } from "@/utils/env";
117116
118117
const localStore = useLocalStore();
118+
const statusStore = useStatusStore();
119119
120120
interface DataType {
121121
key?: number;

src/components/Player/MainPlayer.vue

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,6 @@ import {
201201
} from "@/utils/modal";
202202
import { useSongManager } from "@/core/player/SongManager";
203203
import { usePlayerController } from "@/core/player/PlayerController";
204-
import { isDevBuild } from "@/utils/env";
205204
206205
const router = useRouter();
207206
const dataStore = useDataStore();
@@ -290,7 +289,7 @@ const songMoreOptions = computed<DropdownOption[]>(() => {
290289
{
291290
key: "download",
292291
label: "下载歌曲",
293-
show: isDevBuild && !isLocal && isSong,
292+
show: statusStore.isDeveloperMode && !isLocal && isSong,
294293
props: { onClick: () => openDownloadSong(musicStore.playSong) },
295294
icon: renderIcon("Download"),
296295
},

src/components/Setting/AboutSetting.vue

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
<n-flex align="center" class="about">
77
<SvgIcon name="SPlayer" size="26" />
88
<n-text class="logo-name">SPlayer</n-text>
9-
<n-tag v-if="isDevBuild" size="small" type="warning" round> DEV </n-tag>
10-
<n-tag :bordered="false" size="small" type="primary" round>
9+
<n-tag v-if="statusStore.isDeveloperMode" size="small" type="warning" round> DEV </n-tag>
10+
<n-tag :bordered="false" size="small" type="primary" round @click="openDeveloperMode">
1111
{{ packageJson.version }}
1212
</n-tag>
1313
</n-flex>
@@ -102,11 +102,14 @@ import type { UpdateLogType } from "@/types/main";
102102
import { getUpdateLog, openLink } from "@/utils/helper";
103103
import { debounce } from "lodash-es";
104104
import { useStatusStore } from "@/stores";
105+
import { isElectron } from "@/utils/env";
105106
import packageJson from "@/../package.json";
106-
import { isDevBuild, isElectron } from "@/utils/env";
107107
108108
const statusStore = useStatusStore();
109109
110+
// 开发者模式点击次数
111+
const developerModeClickCount = ref(0);
112+
110113
// 特别鸣谢
111114
const contributors = [
112115
{
@@ -195,6 +198,23 @@ const jumpLink = (e: MouseEvent) => {
195198
// 获取更新日志
196199
const getUpdateData = async () => (updateData.value = await getUpdateLog());
197200
201+
// 打开开发者模式
202+
const openDeveloperMode = useThrottleFn(() => {
203+
developerModeClickCount.value++;
204+
if (developerModeClickCount.value >= 5 && developerModeClickCount.value < 8) {
205+
if (statusStore.developerMode) {
206+
window.$message.info("已处于开发者模式!");
207+
developerModeClickCount.value = 0;
208+
return;
209+
}
210+
window.$message.info(`再点击${8 - developerModeClickCount.value}次以开启开发者模式`);
211+
} else if (developerModeClickCount.value >= 8) {
212+
developerModeClickCount.value = 0;
213+
statusStore.developerMode = true;
214+
window.$message.warning("开发者模式已开启,请谨慎使用!");
215+
}
216+
}, 100);
217+
198218
onMounted(getUpdateData);
199219
</script>
200220

src/components/Setting/GeneralSetting.vue

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929
</n-card>
3030
<n-card class="set-item">
3131
<div class="label">
32-
<n-text class="name">全局主题色</n-text>
33-
<n-text class="tip" :depth="3">更改全局主题色</n-text>
32+
<n-text class="name">主题配置</n-text>
33+
<n-text class="tip" :depth="3">更改主题色或自定义图片</n-text>
3434
</div>
3535
<n-select
3636
v-model:value="settingStore.themeColorType"
@@ -49,9 +49,9 @@
4949
</div>
5050
<n-color-picker
5151
v-model:value="settingStore.themeCustomColor"
52-
class="set"
5352
:show-alpha="false"
5453
:modes="['hex']"
54+
class="set"
5555
/>
5656
</n-card>
5757
</n-collapse-transition>
@@ -70,7 +70,7 @@
7070
<n-card class="set-item">
7171
<div class="label">
7272
<n-text class="name">全局动态取色</n-text>
73-
<n-text class="tip" :depth="3">主题色是否跟随封面,目前感觉不好看</n-text>
73+
<n-text class="tip" :depth="3">主题色是否跟随封面,开启后自定义主题色将失效</n-text>
7474
</div>
7575
<n-switch
7676
v-model:value="settingStore.themeFollowCover"

src/components/Setting/LocalSetting.vue

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@
9595
<n-card class="set-item">
9696
<div class="label">
9797
<n-text class="name">缓存大小上限</n-text>
98-
<n-text class="tip" :depth="3">达到上限后将清理最旧的缓存,数值可以是小数,最低 2GB</n-text>
98+
<n-text class="tip" :depth="3">达到上限后将清理最旧的缓存,可以是小数,最低 2GB</n-text>
9999
</div>
100100
<n-input-group class="set">
101101
<n-input-number
@@ -105,31 +105,35 @@
105105
:max="9999"
106106
:style="{
107107
width: cacheLimited ? '55%' : '0%',
108-
transition: isMounted ? 'width 0.3s ease' : 'none',
109-
}"
110-
@update:value="(value) => {
111-
cacheLimit = value ?? 2;
112-
changeCacheLimit(cacheLimit);
108+
transition: 'width 0.3s',
113109
}"
110+
@update:value="
111+
(value) => {
112+
cacheLimit = value ?? 2;
113+
changeCacheLimit(cacheLimit);
114+
}
115+
"
114116
/>
115117
<n-select
116118
v-model:value="cacheLimited"
117119
:options="[
118120
{ label: '不限制', value: 0 },
119-
{ label: cacheLimited === 0 ? '输入数值 (单位 GB)' : 'GB', value: 1 },
121+
{ label: cacheLimited === 0 ? '自定义大小 (GB)' : 'GB', value: 1 },
120122
]"
121123
:style="{
122124
width: cacheLimited ? '45%' : '100%',
123-
transition: isMounted ? 'width 0.3s ease' : 'none',
125+
transition: 'width 0.3s',
124126
}"
125-
@update:value="(value) => {
126-
if (value === 0) {
127-
changeCacheLimit(0);
128-
} else {
129-
if (cacheLimit === 0) cacheLimit = 2;
130-
changeCacheLimit(cacheLimit);
127+
@update:value="
128+
(value) => {
129+
if (value === 0) {
130+
changeCacheLimit(0);
131+
} else {
132+
if (cacheLimit === 0) cacheLimit = 2;
133+
changeCacheLimit(cacheLimit);
134+
}
131135
}
132-
}"
136+
"
133137
/>
134138
</n-input-group>
135139
</n-card>
@@ -158,7 +162,7 @@
158162
<n-button type="error" strong secondary @click="confirmClearCache"> 清空缓存 </n-button>
159163
</n-card>
160164
</div>
161-
<div v-if="isDevBuild" class="set-list">
165+
<div v-if="statusStore.isDeveloperMode" class="set-list">
162166
<n-h3 prefix="bar"> 下载配置 </n-h3>
163167
<n-card class="set-item">
164168
<div class="label">
@@ -309,18 +313,16 @@
309313
</template>
310314

311315
<script setup lang="ts">
312-
import { useSettingStore } from "@/stores";
316+
import { useSettingStore, useStatusStore } from "@/stores";
313317
import { changeLocalLyricPath, changeLocalMusicPath, formatFileSize } from "@/utils/helper";
314318
import { songLevelData, getSongLevelsData } from "@/utils/meta";
315319
import { useCacheManager, type CacheResourceType } from "@/core/resource/CacheManager";
316320
import { pick } from "lodash-es";
317-
import { isDevBuild } from "@/utils/env";
318321
322+
const statusStore = useStatusStore();
319323
const settingStore = useSettingStore();
320324
const cacheManager = useCacheManager();
321325
322-
const isMounted = ref<boolean>(false);
323-
324326
const cachePath = ref<string>("");
325327
const cacheSizeDisplay = ref<string>("--");
326328
const cacheLimit = ref<number>(10); // 本地状态
@@ -470,7 +472,6 @@ onMounted(async () => {
470472
console.error("读取缓存路径失败:", error);
471473
}
472474
await loadCacheSize();
473-
isMounted.value = true;
474475
});
475476
</script>
476477

0 commit comments

Comments
 (0)