From ddda08c03770ce8845ef10b354338f713ffa3e81 Mon Sep 17 00:00:00 2001 From: imsyy Date: Thu, 16 Feb 2023 10:57:30 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env | 6 ++++++ README.md | 5 ++++- index.html | 10 ++++++---- public/socialLinks.json | 7 ++++++- src/components/Player/index.vue | 22 +++++++++++----------- src/main.js | 9 ++++++++- vite.config.js | 12 +++++++++--- 7 files changed, 50 insertions(+), 21 deletions(-) diff --git a/.env b/.env index 76d52b8..c747522 100644 --- a/.env +++ b/.env @@ -1,8 +1,14 @@ # 站点名称 VITE_SITE_NAME = "無名の主页" +VITE_SITE_ANTHOR = "無名" +VITE_SITE_KEYWORDS = "無名,个人主页" +VITE_SITE_DES = "一个默默无闻的主页" VITE_SITE_URL = "imsyy.top" VITE_SITE_LOGO = "/images/icon/logo.png" +# 百度统计(若不需要可不填) +VITE_SITE_BAIDUTONGJI = "14e9f35ff8bc67fd4bcb5f07a6e6655a" + # 简介文本 VITE_DESC_HELLO = "Hello World !" VITE_DESC_TEXT = "一个建立于 21 世纪的小站,存活于互联网的边缘" diff --git a/README.md b/README.md index c6de78e..264ccd3 100644 --- a/README.md +++ b/README.md @@ -33,13 +33,16 @@ * **安装** [node.js](https://nodejs.org/zh-cn/) **环境** - > node > 16.16.0 + > node > 16.16.0 > npm > 8.15.0 * 然后以 **管理员权限** 运行 `cmd` 终端,并 `cd` 到 项目根目录 * 在 `终端` 中输入: ```bash +# 安装 yarn +npm install -g yarn + # 安装依赖 yarn install diff --git a/index.html b/index.html index c3e122d..7061aa8 100644 --- a/index.html +++ b/index.html @@ -6,9 +6,9 @@ - - - + + + <%- title %> @@ -24,16 +24,18 @@ window.location.href = "https://support.dmeng.net/upgrade-your-browser.html?referrer=" + encodeURIComponent(window.location.href) + <% if (tongji) { %> + <% } %> diff --git a/public/socialLinks.json b/public/socialLinks.json index 625df14..2be8bef 100644 --- a/public/socialLinks.json +++ b/public/socialLinks.json @@ -18,9 +18,14 @@ "icon": "/images/icon/email.png", "tip": "来封 Email ~", "url": "mailto:one@imsyy.top" +}, { + "name": "Twitter", + "icon": "/images/icon/twitter.png", + "tip": "你懂的 ~", + "url": "https://twitter.com/iimmsyy" }, { "name": "Telegram", "icon": "/images/icon/telegram.png", "tip": "你懂的 ~", - "url": "https://twitter.com/iimmsyy" + "url": "https://t.me/bottom_user" }] \ No newline at end of file diff --git a/src/components/Player/index.vue b/src/components/Player/index.vue index 9f3b49f..2df519e 100644 --- a/src/components/Player/index.vue +++ b/src/components/Player/index.vue @@ -18,7 +18,7 @@ @onSelectSong="onSelectSong" /> - + - - \ No newline at end of file + diff --git a/src/main.js b/src/main.js index 6782128..a5ac7a1 100644 --- a/src/main.js +++ b/src/main.js @@ -14,4 +14,11 @@ const pinia = createPinia(); pinia.use(piniaPluginPersistedstate); app.use(pinia); -app.mount('#app') \ No newline at end of file +app.mount('#app') + +// PWA +navigator.serviceWorker.addEventListener('controllerchange', () => { + // 弹出更新提醒 + console.log("站点已更新,刷新后生效"); + ElMessage("站点已更新,刷新后生效"); +}) \ No newline at end of file diff --git a/vite.config.js b/vite.config.js index da51a30..735a1dd 100644 --- a/vite.config.js +++ b/vite.config.js @@ -36,6 +36,10 @@ export default ({ inject: { data: { title: loadEnv(mode, process.cwd()).VITE_SITE_NAME, + author: loadEnv(mode, process.cwd()).VITE_SITE_ANTHOR, + keywords: loadEnv(mode, process.cwd()).VITE_SITE_KEYWORDS, + description: loadEnv(mode, process.cwd()).VITE_SITE_DES, + tongji: loadEnv(mode, process.cwd()).VITE_SITE_BAIDUTONGJI, }, }, }), @@ -46,6 +50,8 @@ export default ({ navigateFallbackAllowlist: [/^index.html$/] }, workbox: { + skipWaiting: true, + clientsClaim: true, runtimeCaching: [{ urlPattern: /(.*?)\.(js|css|woff2|woff|ttf)/, // js / css 静态资源缓存 handler: 'CacheFirst', @@ -63,9 +69,9 @@ export default ({ ], }, manifest: { - "name": "無名の主页", - "short_name": "無名の主页", - "description": "一个默默无闻的主页", + "name": loadEnv(mode, process.cwd()).VITE_SITE_NAME, + "short_name": loadEnv(mode, process.cwd()).VITE_SITE_NAME, + "description": loadEnv(mode, process.cwd()).VITE_SITE_DES, "display": "standalone", "start_url": "/", "theme_color": "#424242", From 03eef443922a588eedbb4f1df487be376deddd52 Mon Sep 17 00:00:00 2001 From: imsyy Date: Thu, 9 Mar 2023 15:39:52 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E5=B0=9D=E8=AF=95=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E9=9F=B3=E4=B9=90=E6=92=AD=E6=94=BE=E9=94=99=E8=AF=AF=20#85=20?= =?UTF-8?q?#93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env | 3 +- package.json | 1 + src/api/index.js | 63 ++++-- src/components/Music/test.vue | 375 -------------------------------- src/components/Player/index.vue | 85 ++++---- src/components/Player/old.vue | 319 --------------------------- yarn.lock | 5 + 7 files changed, 96 insertions(+), 755 deletions(-) delete mode 100644 src/components/Music/test.vue delete mode 100644 src/components/Player/old.vue diff --git a/.env b/.env index c747522..a1241ca 100644 --- a/.env +++ b/.env @@ -31,8 +31,9 @@ VITE_WEATHER_KEY = "57eaea5833ff1616cfd1ff2c4cf9b58a" VITE_SITE_START = "2020-10-24" # 歌曲 API 地址 -## 请参照 https://github.com/imsyy/Meting-API#cloudflare-workers 进行 API 服务部署 +## 请参照 https://github.com/xizeyoupan/Meting-API#deno-deploy 进行 API 服务部署 ## 此处提供的服务可能会超量从而无法访问,请自行部署 +## 若使用QQ音乐歌单,歌曲数量最好不要超出50首 ## 备用:https://api.wuenci.com/meting/api/ VITE_SONG_API = "https://api-meting.imsyy.top/api" # 歌曲服务器 ( netease-网易云, tencent-qq音乐 ) diff --git a/package.json b/package.json index 0b4d42e..97ee2f8 100644 --- a/package.json +++ b/package.json @@ -16,6 +16,7 @@ "aplayer": "^1.10.1", "axios": "^1.1.3", "element-plus": "^2.2.18", + "fetch-jsonp": "^1.2.3", "pinia": "^2.0.23", "pinia-plugin-persistedstate": "^3.0.0", "terser": "^5.16.1", diff --git a/src/api/index.js b/src/api/index.js index 3bfb168..fa9adc0 100644 --- a/src/api/index.js +++ b/src/api/index.js @@ -1,4 +1,5 @@ // import axios from "axios"; +import fetchJsonp from "fetch-jsonp"; /** * 音乐播放器 @@ -6,9 +7,38 @@ // 获取音乐播放列表 export const getPlayerList = async (server, type, id) => { - const res = await fetch(`${import.meta.env.VITE_SONG_API}?server=${server}&type=${type}&id=${id}`); - return await res.json(); -} + const res = await fetch( + `${import.meta.env.VITE_SONG_API}?server=${server}&type=${type}&id=${id}` + ); + const data = await res.json(); + + if (data[0].url.startsWith("@")) { + const [handle, jsonpCallback, jsonpCallbackFunction, url] = data[0].url + .split("@") + .slice(1); + const jsonpData = await fetchJsonp(url).then((res) => res.json()); + const domain = ( + jsonpData.req_0.data.sip.find((i) => !i.startsWith("http://ws")) || + jsonpData.req_0.data.sip[0] + ).replace("http://", "https://"); + + return data.map((v, i) => ({ + title: v.name || v.title, + artist: v.artist || v.author, + src: domain + jsonpData.req_0.data.midurlinfo[i].purl, + pic: v.pic, + lrc: v.lrc, + })); + } else { + return data.map((v) => ({ + title: v.name || v.title, + artist: v.artist || v.author, + src: v.url, + pic: v.pic, + lrc: v.lrc, + })); + } +}; /** * 一言 @@ -16,26 +46,27 @@ export const getPlayerList = async (server, type, id) => { // 获取一言数据 export const getHitokoto = async () => { - const res = await fetch("https://v1.hitokoto.cn"); - return await res.json(); -} + const res = await fetch("https://v1.hitokoto.cn"); + return await res.json(); +}; /** * 天气 */ - // 获取高德地理位置信息 export const getAdcode = async (key) => { - const res = await fetch(`https://restapi.amap.com/v3/ip?key=${key}`); - return await res.json(); -} + const res = await fetch(`https://restapi.amap.com/v3/ip?key=${key}`); + return await res.json(); +}; // 获取高德地理天气信息 export const getWeather = async (key, city) => { - const res = await fetch(`https://restapi.amap.com/v3/weather/weatherInfo?key=${key}&city=${city}`); - return await res.json(); -} + const res = await fetch( + `https://restapi.amap.com/v3/weather/weatherInfo?key=${key}&city=${city}` + ); + return await res.json(); +}; /** * 获取配置 @@ -43,6 +74,6 @@ export const getWeather = async (key, city) => { // 获取社交链接 export const getSocialLinks = async () => { - const res = await fetch("/socialLinks.json"); - return await res.json(); -} \ No newline at end of file + const res = await fetch("/socialLinks.json"); + return await res.json(); +}; diff --git a/src/components/Music/test.vue b/src/components/Music/test.vue deleted file mode 100644 index cd61f3b..0000000 --- a/src/components/Music/test.vue +++ /dev/null @@ -1,375 +0,0 @@ - - - - - \ No newline at end of file diff --git a/src/components/Player/index.vue b/src/components/Player/index.vue index 2df519e..6ccb90c 100644 --- a/src/components/Player/index.vue +++ b/src/components/Player/index.vue @@ -20,17 +20,10 @@ - - \ No newline at end of file diff --git a/yarn.lock b/yarn.lock index 1fcc6a9..e72b382 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2024,6 +2024,11 @@ fastq@^1.6.0: dependencies: reusify "^1.0.4" +fetch-jsonp@^1.2.3: + version "1.2.3" + resolved "https://registry.yarnpkg.com/fetch-jsonp/-/fetch-jsonp-1.2.3.tgz#ae99a867095cb1ce5c39fac601d70d1084db122f" + integrity sha512-C13k1o7R9JTN1wmhKkrW5bU/00LwixXnkufQUR6Rbf4KCS0i8mycQaovt4WVbHnA2NKgi7Ryp9Whpy/CGcij6Q== + filelist@^1.0.1: version "1.0.4" resolved "https://registry.npmmirror.com/filelist/-/filelist-1.0.4.tgz" From 5c9e14a585bd6e56252b341e5f8772f3a13ebe43 Mon Sep 17 00:00:00 2001 From: imsyy Date: Thu, 9 Mar 2023 15:46:03 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E6=A0=B7=E5=BC=8F=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- src/components/Player/index.vue | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 97ee2f8..c81c416 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "github": "https://github.com/imsyy/home", "home": "https://imsyy.top", "private": true, - "version": "4.0.2", + "version": "4.0.3", "type": "module", "scripts": { "dev": "vite --host", diff --git a/src/components/Player/index.vue b/src/components/Player/index.vue index 6ccb90c..0e7c2ed 100644 --- a/src/components/Player/index.vue +++ b/src/components/Player/index.vue @@ -223,7 +223,7 @@ defineExpose({ playToggle, changeVolume, changeSong }); .aplayer-info { margin-left: 0; background-color: #ffffff40; - border-color: transparent; + border-color: transparent !important; .aplayer-music { flex-grow: initial; margin-bottom: 2px;