添加配置项

This commit is contained in:
imsyy 2023-02-16 10:57:30 +08:00
parent 8f46b8dd46
commit ddda08c037
7 changed files with 50 additions and 21 deletions

6
.env
View File

@ -1,8 +1,14 @@
# 站点名称 # 站点名称
VITE_SITE_NAME = "無名の主页" VITE_SITE_NAME = "無名の主页"
VITE_SITE_ANTHOR = "無名"
VITE_SITE_KEYWORDS = "無名,个人主页"
VITE_SITE_DES = "一个默默无闻的主页"
VITE_SITE_URL = "imsyy.top" VITE_SITE_URL = "imsyy.top"
VITE_SITE_LOGO = "/images/icon/logo.png" VITE_SITE_LOGO = "/images/icon/logo.png"
# 百度统计(若不需要可不填)
VITE_SITE_BAIDUTONGJI = "14e9f35ff8bc67fd4bcb5f07a6e6655a"
# 简介文本 # 简介文本
VITE_DESC_HELLO = "Hello World !" VITE_DESC_HELLO = "Hello World !"
VITE_DESC_TEXT = "一个建立于 21 世纪的小站,存活于互联网的边缘" VITE_DESC_TEXT = "一个建立于 21 世纪的小站,存活于互联网的边缘"

View File

@ -40,6 +40,9 @@
* 在 `终端` 中输入: * 在 `终端` 中输入:
```bash ```bash
# 安装 yarn
npm install -g yarn
# 安装依赖 # 安装依赖
yarn install yarn install

View File

@ -6,9 +6,9 @@
<meta http-equiv="Access-Control-Allow-Origin" content="*"> <meta http-equiv="Access-Control-Allow-Origin" content="*">
<!-- <meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests"> --> <!-- <meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests"> -->
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description" content="一个默默无闻的主页" /> <meta name="description" content="<%- description %>" />
<meta name="keywords" content="無名,个人主页" /> <meta name="keywords" content="<%- keywords %>" />
<meta name="author" content="無名" /> <meta name="author" content="<%- author %>" />
<meta name="theme-color" content="#424242" /> <meta name="theme-color" content="#424242" />
<title><%- title %></title> <title><%- title %></title>
<!-- HarmonyOS Sans --> <!-- HarmonyOS Sans -->
@ -24,16 +24,18 @@
window.location.href = window.location.href =
"https://support.dmeng.net/upgrade-your-browser.html?referrer=" + encodeURIComponent(window.location.href) "https://support.dmeng.net/upgrade-your-browser.html?referrer=" + encodeURIComponent(window.location.href)
</script> </script>
<% if (tongji) { %>
<!-- 百度统计 --> <!-- 百度统计 -->
<script> <script>
var _hmt = _hmt || []; var _hmt = _hmt || [];
(function () { (function () {
var hm = document.createElement("script"); var hm = document.createElement("script");
hm.src = "https://hm.baidu.com/hm.js?14e9f35ff8bc67fd4bcb5f07a6e6655a"; hm.src = "https://hm.baidu.com/hm.js?<%- tongji %>";
var s = document.getElementsByTagName("script")[0]; var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(hm, s); s.parentNode.insertBefore(hm, s);
})(); })();
</script> </script>
<% } %>
</head> </head>
<body class="loading"> <body class="loading">

View File

@ -18,9 +18,14 @@
"icon": "/images/icon/email.png", "icon": "/images/icon/email.png",
"tip": "来封 Email ~", "tip": "来封 Email ~",
"url": "mailto:one@imsyy.top" "url": "mailto:one@imsyy.top"
}, {
"name": "Twitter",
"icon": "/images/icon/twitter.png",
"tip": "你懂的 ~",
"url": "https://twitter.com/iimmsyy"
}, { }, {
"name": "Telegram", "name": "Telegram",
"icon": "/images/icon/telegram.png", "icon": "/images/icon/telegram.png",
"tip": "你懂的 ~", "tip": "你懂的 ~",
"url": "https://twitter.com/iimmsyy" "url": "https://t.me/bottom_user"
}] }]

View File

@ -114,13 +114,6 @@ onMounted(() => {
playListCount.value = res.length; playListCount.value = res.length;
// //
store.musicIsOk = true; store.musicIsOk = true;
console.log(
"音乐加载完成",
res,
playIndex.value,
playListCount.value,
props.volume
);
// //
res.forEach((v) => { res.forEach((v) => {
playList.value.push({ playList.value.push({
@ -131,6 +124,13 @@ onMounted(() => {
lrc: v.lrc, lrc: v.lrc,
}); });
}); });
console.log(
"音乐加载完成",
playList.value,
playIndex.value,
playListCount.value,
props.volume
);
}) })
.catch(() => { .catch(() => {
store.musicIsOk = false; store.musicIsOk = false;
@ -214,7 +214,7 @@ const changeSong = (type) => {
defineExpose({ playToggle, changeVolume, changeSong }); defineExpose({ playToggle, changeVolume, changeSong });
</script> </script>
<style lang='scss' scoped> <style lang="scss" scoped>
.aplayer { .aplayer {
width: 80%; width: 80%;
background: transparent; background: transparent;

View File

@ -15,3 +15,10 @@ pinia.use(piniaPluginPersistedstate);
app.use(pinia); app.use(pinia);
app.mount('#app') app.mount('#app')
// PWA
navigator.serviceWorker.addEventListener('controllerchange', () => {
// 弹出更新提醒
console.log("站点已更新,刷新后生效");
ElMessage("站点已更新,刷新后生效");
})

View File

@ -36,6 +36,10 @@ export default ({
inject: { inject: {
data: { data: {
title: loadEnv(mode, process.cwd()).VITE_SITE_NAME, 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$/] navigateFallbackAllowlist: [/^index.html$/]
}, },
workbox: { workbox: {
skipWaiting: true,
clientsClaim: true,
runtimeCaching: [{ runtimeCaching: [{
urlPattern: /(.*?)\.(js|css|woff2|woff|ttf)/, // js / css 静态资源缓存 urlPattern: /(.*?)\.(js|css|woff2|woff|ttf)/, // js / css 静态资源缓存
handler: 'CacheFirst', handler: 'CacheFirst',
@ -63,9 +69,9 @@ export default ({
], ],
}, },
manifest: { manifest: {
"name": "無名の主页", "name": loadEnv(mode, process.cwd()).VITE_SITE_NAME,
"short_name": "無名の主页", "short_name": loadEnv(mode, process.cwd()).VITE_SITE_NAME,
"description": "一个默默无闻的主页", "description": loadEnv(mode, process.cwd()).VITE_SITE_DES,
"display": "standalone", "display": "standalone",
"start_url": "/", "start_url": "/",
"theme_color": "#424242", "theme_color": "#424242",