新增 建站日期显示及配置

This commit is contained in:
底层用户 2023-02-02 11:06:16 +08:00
parent c4c040402b
commit 854cebff03
6 changed files with 63 additions and 5 deletions

4
.env
View File

@ -20,6 +20,10 @@ VITE_DESC_TEXT_OTHER = "哎呀,这都被你发现了( 再点击一次可关
## 请各位大佬行行好,别再让我超量了 ## 请各位大佬行行好,别再让我超量了
VITE_WEATHER_KEY = "57eaea5833ff1616cfd1ff2c4cf9b58a" VITE_WEATHER_KEY = "57eaea5833ff1616cfd1ff2c4cf9b58a"
# 建站日期
## 请按照 YYYY-MM-DD 格式填写
VITE_SITE_START = "2020-10-24"
# 歌曲 API 地址 # 歌曲 API 地址
## 备用https://api.wuenci.com/meting/api/ ## 备用https://api.wuenci.com/meting/api/
VITE_SONG_API = "https://api-meting.imsyy.top" VITE_SONG_API = "https://api-meting.imsyy.top"

View File

@ -1 +1 @@
if(!self.define){let e,s={};const t=(t,i)=>(t=new URL(t+".js",i).href,s[t]||new Promise((s=>{if("document"in self){const e=document.createElement("script");e.src=t,e.onload=s,document.head.appendChild(e)}else e=t,importScripts(t),s()})).then((()=>{let e=s[t];if(!e)throw new Error(`Module ${t} didnt register its module`);return e})));self.define=(i,n)=>{const o=e||("document"in self?document.currentScript.src:"")||location.href;if(s[o])return;let r={};const c=e=>t(e,o),l={module:{uri:o},exports:r,require:c};s[o]=Promise.all(i.map((e=>l[e]||c(e)))).then((e=>(n(...e),r)))}}define(["./workbox-082d0e8a"],(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(/(.*?)\.(js|css|woff2|woff|ttf)/,new e.CacheFirst({cacheName:"js-css-cache",plugins:[]}),"GET"),e.registerRoute(/(.*?)\.(png|jpe?g|svg|gif|bmp|psd|tiff|tga|eps)/,new e.CacheFirst({cacheName:"image-cache",plugins:[]}),"GET")})); if(!self.define){let e,s={};const t=(t,i)=>(t=new URL(t+".js",i).href,s[t]||new Promise((s=>{if("document"in self){const e=document.createElement("script");e.src=t,e.onload=s,document.head.appendChild(e)}else e=t,importScripts(t),s()})).then((()=>{let e=s[t];if(!e)throw new Error(`Module ${t} didnt register its module`);return e})));self.define=(i,n)=>{const o=e||("document"in self?document.currentScript.src:"")||location.href;if(s[o])return;let r={};const c=e=>t(e,o),l={module:{uri:o},exports:r,require:c};s[o]=Promise.all(i.map((e=>l[e]||c(e)))).then((e=>(n(...e),r)))}}define(["./workbox-082d0e8a"],(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:[/^index.html$/]})),e.registerRoute(/(.*?)\.(js|css|woff2|woff|ttf)/,new e.CacheFirst({cacheName:"js-css-cache",plugins:[]}),"GET"),e.registerRoute(/(.*?)\.(png|jpe?g|svg|gif|bmp|psd|tiff|tga|eps)/,new e.CacheFirst({cacheName:"image-cache",plugins:[]}),"GET")}));

View File

@ -12,7 +12,15 @@
</div> </div>
</el-collapse-item> </el-collapse-item>
<el-collapse-item title="其他设置" name="2"> <el-collapse-item title="其他设置" name="2">
<div>设置内容待增加</div> <div class="item">
<span class="text">建站日期显示</span>
<el-switch
v-model="siteStartShow"
inline-prompt
:active-icon="CheckSmall"
:inactive-icon="CloseSmall"
/>
</div>
</el-collapse-item> </el-collapse-item>
<el-collapse-item title="其他设置" name="3"> <el-collapse-item title="其他设置" name="3">
<div>设置内容待增加</div> <div>设置内容待增加</div>
@ -27,7 +35,11 @@
<script setup> <script setup>
import { ref, onMounted, watch } from "vue"; import { ref, onMounted, watch } from "vue";
import { mainStore } from "@/store"; import { mainStore } from "@/store";
import { CheckSmall, CloseSmall } from "@icon-park/vue-next";
import { storeToRefs } from "pinia";
const store = mainStore(); const store = mainStore();
const { siteStartShow } = storeToRefs(store);
// //
let activeName = ref("1"); let activeName = ref("1");
@ -67,7 +79,16 @@ watch(
.el-collapse-item__content { .el-collapse-item__content {
padding: 20px; padding: 20px;
.item {
display: flex;
align-items: center;
justify-content: space-between;
font-size: 14px;
.el-switch__core {
border-color: transparent;
background-color: #ffffff30;
}
}
.bg-set { .bg-set {
.el-radio-group { .el-radio-group {
justify-content: space-between; justify-content: space-between;

View File

@ -40,21 +40,37 @@
:stroke-width="20" :stroke-width="20"
:percentage="timeData.year.pass" :percentage="timeData.year.pass"
/> />
<div v-if="startDateText && store.siteStartShow">
<span class="text" v-html="startDateText" />
<!-- <el-progress
:show-text="false"
:indeterminate="true"
:stroke-width="6"
:percentage="80"
:duration="2"
/> -->
</div>
</div> </div>
</template> </template>
<script setup> <script setup>
import { onMounted, onBeforeUnmount, ref } from "vue"; import { onMounted, onBeforeUnmount, ref } from "vue";
import { HourglassFull } from "@icon-park/vue-next"; import { HourglassFull } from "@icon-park/vue-next";
import { getTimeCapsule } from "@/utils/getTime.js"; import { getTimeCapsule, siteDateStatistics } from "@/utils/getTime.js";
import { mainStore } from "@/store";
const store = mainStore();
// //
let timeData = ref(getTimeCapsule()); let timeData = ref(getTimeCapsule());
let startDate = ref(import.meta.env.VITE_SITE_START);
let startDateText = ref(null);
let timeInterval = null; let timeInterval = null;
onMounted(() => { onMounted(() => {
timeInterval = setInterval(() => { timeInterval = setInterval(() => {
timeData.value = getTimeCapsule(); timeData.value = getTimeCapsule();
if (startDate.value)
startDateText.value = siteDateStatistics(new Date(startDate.value));
}, 1000); }, 1000);
}); });

View File

@ -7,6 +7,7 @@ export const mainStore = defineStore("main", {
return { return {
innerWidth: null, // 当前窗口宽度 innerWidth: null, // 当前窗口宽度
coverType: "0", // 壁纸种类 coverType: "0", // 壁纸种类
siteStartShow: true, // 建站日期显示
musicIsOk: false, // 音乐是否加载完成 musicIsOk: false, // 音乐是否加载完成
musicVolume: 0, // 音乐音量; musicVolume: 0, // 音乐音量;
musicOpenState: false, // 音乐面板开启状态 musicOpenState: false, // 音乐面板开启状态
@ -69,6 +70,6 @@ export const mainStore = defineStore("main", {
persist: { persist: {
key: 'data', key: 'data',
storage: window.localStorage, storage: window.localStorage,
paths: ['coverType', 'musicVolume'], paths: ['coverType', 'musicVolume', 'siteStartShow'],
}, },
}) })

View File

@ -116,3 +116,19 @@ export const checkDays = () => {
} }
} }
} }
// 建站日期统计
export const siteDateStatistics = (startDate) => {
const currentDate = new Date();
const differenceInTime = currentDate.getTime() - startDate.getTime();
const differenceInDays = differenceInTime / (1000 * 3600 * 24);
const differenceInMonths = differenceInDays / 30;
const differenceInYears = differenceInMonths / 12;
if (differenceInYears >= 1) {
return `本站已经苟活了 ${Math.floor(differenceInYears)}${Math.floor(differenceInMonths % 12)}${Math.round(differenceInDays % 30)}`;
} else if (differenceInMonths >= 1) {
return `本站已经苟活了 ${Math.floor(differenceInMonths)}${Math.round(differenceInDays % 30)}`;
} else {
return `本站已经苟活了 ${Math.round(differenceInDays)}`;
}
}