mirror of
https://github.com/imsyy/SPlayer.git
synced 2025-11-25 11:29:26 +08:00
fix: 去除开发环境 PWA & 修复一些问题
This commit is contained in:
@@ -1 +0,0 @@
|
||||
if('serviceWorker' in navigator) navigator.serviceWorker.register('/dev-sw.js?dev-sw', { scope: '/', type: 'classic' })
|
||||
@@ -1 +0,0 @@
|
||||
if(!self.define){let e,i={};const t=(t,n)=>(t=new URL(t+".js",n).href,i[t]||new Promise((i=>{if("document"in self){const e=document.createElement("script");e.src=t,e.onload=i,document.head.appendChild(e)}else e=t,importScripts(t),i()})).then((()=>{let e=i[t];if(!e)throw new Error(`Module ${t} didn’t register its module`);return e})));self.define=(n,s)=>{const o=e||("document"in self?document.currentScript.src:"")||location.href;if(i[o])return;let r={};const l=e=>t(e,o),c={module:{uri:o},exports:r,require:l};i[o]=Promise.all(n.map((e=>c[e]||l(e)))).then((e=>(s(...e),r)))}}define(["./workbox-d4ada07d"],(function(e){"use strict";self.skipWaiting(),e.clientsClaim(),e.precacheAndRoute([{url:"registerSW.js",revision:"3ca0b8505b4bec776b69afdba2768812"},{revision:null,url:"index.html"}],{}),e.cleanupOutdatedCaches(),e.registerRoute(new e.NavigationRoute(e.createHandlerBoundToURL("index.html"),{allowlist:[/^\/$/]})),e.registerRoute(/(.*?)\.(woff2|woff|ttf)/,new e.CacheFirst({cacheName:"file-cache",plugins:[]}),"GET"),e.registerRoute(/(.*?)\.(webp|png|jpe?g|svg|gif|bmp|psd|tiff|tga|eps)/,new e.CacheFirst({cacheName:"image-cache",plugins:[]}),"GET")}));
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "splayer",
|
||||
"version": "0.8.0",
|
||||
"version": "0.9.0",
|
||||
"private": true,
|
||||
"author": "imsyy",
|
||||
"home": "https://imsyy.top",
|
||||
@@ -13,8 +13,6 @@
|
||||
"dependencies": {
|
||||
"@icon-park/vue-next": "^1.4.2",
|
||||
"@ivanv/vue-collapse-transition": "^1.0.2",
|
||||
"@jridgewell/sourcemap-codec": "^1.4.14",
|
||||
"@rollup/plugin-terser": "^0.4.0",
|
||||
"artplayer": "^4.5.12",
|
||||
"axios": "^1.2.0",
|
||||
"pinia": "^2.0.26",
|
||||
@@ -27,6 +25,8 @@
|
||||
"vue-router": "^4.1.6"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@jridgewell/sourcemap-codec": "^1.4.14",
|
||||
"@rollup/plugin-terser": "^0.4.0",
|
||||
"@vicons/material": "^0.12.0",
|
||||
"@vitejs/plugin-vue": "^3.2.0",
|
||||
"naive-ui": "^2.34.2",
|
||||
|
||||
1321
pnpm-lock.yaml
generated
1321
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
28
src/App.vue
28
src/App.vue
@@ -30,7 +30,7 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { musicStore, userStore } from "@/store";
|
||||
import { musicStore, userStore, settingStore } from "@/store";
|
||||
import { useRouter } from "vue-router";
|
||||
import { getLoginState } from "@/api/login";
|
||||
import { userDailySignin, userYunbeiSign } from "@/api/user";
|
||||
@@ -41,6 +41,7 @@ import packageJson from "@/../package.json";
|
||||
|
||||
const music = musicStore();
|
||||
const user = userStore();
|
||||
const setting = settingStore();
|
||||
const router = useRouter();
|
||||
const mainContent = ref(null);
|
||||
|
||||
@@ -74,6 +75,11 @@ const signIn = () => {
|
||||
console.log("签到成功!");
|
||||
console.log("userDailySignin:", results[0]);
|
||||
console.log("userYunbeiSign:", results[1]);
|
||||
$notification["success"]({
|
||||
content: "签到成功",
|
||||
meta: "每日签到及云贝签到成功",
|
||||
duration: 3000,
|
||||
});
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error("签到失败:", error);
|
||||
@@ -83,10 +89,17 @@ const signIn = () => {
|
||||
console.log("今天已经签到过了!");
|
||||
}
|
||||
};
|
||||
// 系统重置
|
||||
const cleanAll = () => {
|
||||
$message ? $message.success("重置成功") : alert("重置成功");
|
||||
localStorage.clear();
|
||||
window.location.href = "/";
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
// 挂载主窗口至全局
|
||||
// 挂载至全局
|
||||
window.$mainContent = mainContent.value;
|
||||
window.$cleanAll = cleanAll;
|
||||
|
||||
// 初始化
|
||||
$notification["info"]({
|
||||
@@ -103,13 +116,18 @@ onMounted(() => {
|
||||
"color:#f55e55;font-size:26px;font-weight:bold;",
|
||||
"font-size:16px"
|
||||
);
|
||||
console.info(
|
||||
"若站点出现异常,可尝试在下方输入 %c$cleanAll()%c 然后按回车来重置",
|
||||
"background: #eaeffd;color:#f55e55;padding: 4px 6px;border-radius:8px;",
|
||||
"background:unset;color:unset;"
|
||||
);
|
||||
|
||||
// 检查账号登录状态
|
||||
getLoginState()
|
||||
.then((res) => {
|
||||
if (res.data.profile && user.userLogin) {
|
||||
// 签到
|
||||
signIn();
|
||||
if (setting.autoSignIn) signIn();
|
||||
user.userLogin = true;
|
||||
user.setUserOtherData();
|
||||
} else {
|
||||
@@ -121,7 +139,9 @@ onMounted(() => {
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
$message.error("遇到错误" + err);
|
||||
$message.error("请求遇到错误");
|
||||
console.error("请求遇到错误" + err);
|
||||
router.push("/500");
|
||||
return false;
|
||||
});
|
||||
|
||||
|
||||
@@ -59,7 +59,6 @@ import { musicStore } from "@/store";
|
||||
import { RemoveCircleOutlineFilled } from "@vicons/material";
|
||||
import AllArtists from "./AllArtists.vue";
|
||||
import CollapseTransition from "@ivanv/vue-collapse-transition/src/CollapseTransition.vue";
|
||||
import { nextTick } from "vue";
|
||||
|
||||
const music = musicStore();
|
||||
|
||||
|
||||
@@ -200,6 +200,7 @@ const getFilter = (lrcIndex, index) => {
|
||||
|
||||
// 点击歌词跳转
|
||||
const jumpTime = (time) => {
|
||||
lrcMouseStatus.value = false;
|
||||
if ($player) $player.currentTime = time;
|
||||
};
|
||||
|
||||
@@ -220,6 +221,7 @@ const screenfullChange = () => {
|
||||
: FullscreenExitRound;
|
||||
// 延迟一段时间执行列表滚动
|
||||
setTimeout(() => {
|
||||
lrcMouseStatus.value = false;
|
||||
lyricsScroll(music.getPlaySongLyricIndex);
|
||||
}, 500);
|
||||
}
|
||||
@@ -399,11 +401,12 @@ watch(
|
||||
display: none !important;
|
||||
}
|
||||
.right {
|
||||
padding: 0 5vw;
|
||||
padding: 0 2vw;
|
||||
.lrcShow {
|
||||
.lrc-all {
|
||||
height: 70vh !important;
|
||||
padding-right: 16% !important;
|
||||
// padding-right: 16% !important;
|
||||
margin-right: 0 !important;
|
||||
}
|
||||
.data,
|
||||
.menu {
|
||||
@@ -463,7 +466,7 @@ watch(
|
||||
}
|
||||
}
|
||||
.lrc-all {
|
||||
padding-right: 20%;
|
||||
margin-right: 20%;
|
||||
scrollbar-width: none;
|
||||
// max-width: 460px;
|
||||
max-width: 52vh;
|
||||
|
||||
@@ -281,9 +281,12 @@ const songCanplay = () => {
|
||||
|
||||
// 歌曲开始播放
|
||||
const songPlay = () => {
|
||||
if (!music.getPlaySongData) {
|
||||
$message.error("音乐数据获取失败");
|
||||
return false;
|
||||
}
|
||||
music.setPlayState(true);
|
||||
// 兼容 mediaSession
|
||||
console.log(music.getPlaySongData.album.picUrl);
|
||||
if ("mediaSession" in navigator) {
|
||||
navigator.mediaSession.metadata = new MediaMetadata({
|
||||
title: music.getPlaySongData.name,
|
||||
|
||||
@@ -36,7 +36,9 @@ router.beforeEach((to, from, next) => {
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
$message.error("遇到错误" + err);
|
||||
$message.error("请求遇到错误");
|
||||
console.error("请求遇到错误" + err);
|
||||
next("/500");
|
||||
return false;
|
||||
});
|
||||
} else {
|
||||
|
||||
@@ -241,10 +241,6 @@ const routes = [
|
||||
},
|
||||
component: () => import("@/views/State/404.vue"),
|
||||
},
|
||||
{
|
||||
path: "/:pathMatch(.*)",
|
||||
redirect: "/404",
|
||||
},
|
||||
// 403
|
||||
{
|
||||
path: "/403",
|
||||
@@ -263,6 +259,10 @@ const routes = [
|
||||
},
|
||||
component: () => import("@/views/State/500.vue"),
|
||||
},
|
||||
{
|
||||
path: "/:pathMatch(.*)",
|
||||
redirect: "/404",
|
||||
},
|
||||
];
|
||||
|
||||
export default routes;
|
||||
|
||||
@@ -182,8 +182,8 @@ const useMusicDataStore = defineStore("musicData", {
|
||||
setPersonalFmData() {
|
||||
getPersonalFm().then((res) => {
|
||||
if (res.data[0]) {
|
||||
let data = res.data[0];
|
||||
let fmData = {
|
||||
const data = res.data[0];
|
||||
const fmData = {
|
||||
id: data.id,
|
||||
name: data.name,
|
||||
artist: data.artists,
|
||||
@@ -200,7 +200,7 @@ const useMusicDataStore = defineStore("musicData", {
|
||||
this.persistData.playlists.push(fmData);
|
||||
this.persistData.playSongIndex = 0;
|
||||
}
|
||||
this.playState = true;
|
||||
// this.playState = true;
|
||||
} else {
|
||||
$message.error("获取私人 FM 失败");
|
||||
}
|
||||
|
||||
@@ -10,6 +10,8 @@ const useSettingDataStore = defineStore("settingData", {
|
||||
themeAuto: true,
|
||||
// 轮播图显示
|
||||
bannerShow: true,
|
||||
// 自动签到
|
||||
autoSignIn: true,
|
||||
// 列表点击方式
|
||||
listClickMode: "dblclick",
|
||||
// 播放器样式
|
||||
|
||||
@@ -24,7 +24,7 @@ axios.interceptors.request.use(
|
||||
},
|
||||
(error) => {
|
||||
$loadingBar.error();
|
||||
$message.error("请求失败,请稍后重试");
|
||||
console.error("请求失败,请稍后重试");
|
||||
return Promise.reject(error);
|
||||
}
|
||||
);
|
||||
@@ -41,23 +41,23 @@ axios.interceptors.response.use(
|
||||
const data = error.response.data;
|
||||
switch (error.response.status) {
|
||||
case 401:
|
||||
$message.error("您未登录");
|
||||
console.error("您未登录");
|
||||
break;
|
||||
case 301:
|
||||
$message.error("请求发生重定向");
|
||||
console.error("请求发生重定向");
|
||||
break;
|
||||
case 404:
|
||||
$message.error("请求资源不存在");
|
||||
console.error("请求资源不存在");
|
||||
break;
|
||||
case 500:
|
||||
$message.error("内部服务器错误");
|
||||
console.error("内部服务器错误");
|
||||
break;
|
||||
default:
|
||||
$message.error(data.message ? data.message : "请求失败,请稍后重试");
|
||||
console.error(data.message ? data.message : "请求失败,请稍后重试");
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
$message.error("请求失败,请稍后重试");
|
||||
console.error("请求失败,请稍后重试");
|
||||
}
|
||||
return Promise.reject(error);
|
||||
}
|
||||
|
||||
@@ -10,6 +10,13 @@
|
||||
<div class="name">明暗模式跟随系统</div>
|
||||
<n-switch v-model:value="themeAuto" :round="false" />
|
||||
</n-card>
|
||||
<n-card class="set-item">
|
||||
<div class="name">
|
||||
每日签到
|
||||
<span class="tip">是否自动进行每日签到</span>
|
||||
</div>
|
||||
<n-switch v-model:value="autoSignIn" :round="false" />
|
||||
</n-card>
|
||||
<n-card class="set-item">
|
||||
<div class="name">
|
||||
列表点击方式
|
||||
@@ -133,6 +140,16 @@
|
||||
@click="changeMusicFrequency"
|
||||
/>
|
||||
</n-card>
|
||||
<n-h6 prefix="bar"> 其他设置 </n-h6>
|
||||
<n-card class="set-item">
|
||||
<div class="name">
|
||||
系统重置
|
||||
<span class="tip">若程序显示异常或出现问题时可尝试此操作</span>
|
||||
</div>
|
||||
<n-button strong secondary type="error" @click="resetApp">
|
||||
重置
|
||||
</n-button>
|
||||
</n-card>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -155,6 +172,7 @@ const {
|
||||
songLevel,
|
||||
bannerShow,
|
||||
lyricsBlur,
|
||||
autoSignIn,
|
||||
} = storeToRefs(setting);
|
||||
|
||||
// 深浅模式
|
||||
@@ -268,6 +286,24 @@ const changeMusicFrequency = () => {
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
// 系统重置
|
||||
const resetApp = () => {
|
||||
const cleanAll = () => {
|
||||
$message ? $message.success("重置成功") : alert("重置成功");
|
||||
localStorage.clear();
|
||||
window.location.href = "/";
|
||||
};
|
||||
$dialog.warning({
|
||||
title: "系统重置",
|
||||
content: "确认重置为默认状态?你的登录状态以及自定义设置都将丢失!",
|
||||
positiveText: "重置",
|
||||
negativeText: "取消",
|
||||
onPositiveClick: () => {
|
||||
$cleanAll ? $cleanAll() : cleanAll();
|
||||
},
|
||||
});
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
||||
@@ -30,10 +30,9 @@ export default ({ mode }) =>
|
||||
// PWA
|
||||
VitePWA({
|
||||
registerType: "autoUpdate",
|
||||
devOptions: {
|
||||
enabled: true,
|
||||
},
|
||||
workbox: {
|
||||
clientsClaim: true,
|
||||
skipWaiting: true,
|
||||
cleanupOutdatedCaches: true,
|
||||
runtimeCaching: [
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user