forked from imsyy/SPlayer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
74 lines (67 loc) · 2.24 KB
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import { createApp } from "vue";
import { createPinia } from "pinia";
import { checkPlatform, loadCSS } from "@/utils/helper";
import App from "@/App.vue";
import router from "@/router";
import piniaPluginPersistedstate from "pinia-plugin-persistedstate";
import packageJson from "@/../package.json";
// 全局样式
import "@/style/main.scss";
import "@/style/animate.scss";
// 是否为 Electron
const isElectron = checkPlatform.electron();
// 分设备添加字体
if (isElectron) {
loadCSS(`${import.meta.env.BASE_URL}font/font.css`);
} else {
loadCSS("https://s1.hdslb.com/bfs/static/jinkela/long/font/regular.css");
}
// 分设备类名
document.body.classList.add(isElectron ? "electron" : "webapp");
// 程序重置
window.$cleanAll = (tip = true) => {
if (tip) {
const isConfirmed = window.confirm(`确认要重置${isElectron ? "应用程序" : "该站点"}吗?`);
if (!isConfirmed) return false;
}
// 清除 localStorage
localStorage.clear();
// 清除 IndexedDB 数据库
indexedDB.deleteDatabase("filesDB");
// 清除所有 Cookie
document.cookie.split(";").forEach((cookie) => {
var eqPos = cookie.indexOf("=");
var name = eqPos > -1 ? cookie.substring(0, eqPos) : cookie;
document.cookie = name + "=;expires=Thu, 01 Jan 1970 00:00:00 GMT";
});
// 清除缓存
if (caches) {
caches.keys().then((names) => {
for (let name of names) caches.delete(name);
});
}
return "已重置应用,请" + (isElectron ? "重启应用" : "刷新页面");
};
// 版权声明
const logoText = import.meta.env.RENDERER_VITE_SITE_TITLE;
const copyrightNotice = `\n\n版本: ${packageJson.version}\n作者: ${packageJson.author}\n作者主页: ${packageJson.home}\nGitHub: ${packageJson.github}`;
console.info(
`%c${logoText} %c ${copyrightNotice}`,
"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;",
);
// 挂载
const app = createApp(App);
// pinia
const pinia = createPinia();
pinia.use(piniaPluginPersistedstate);
app.use(pinia);
// router
app.use(router);
// app
app.mount("#app");