97 lines
4.6 KiB
JavaScript
97 lines
4.6 KiB
JavaScript
import { createApp } from 'vue'
|
|
import ElementPlus from 'element-plus'
|
|
import zhCn from 'element-plus/es/locale/lang/zh-cn'
|
|
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
|
|
import 'element-plus/dist/index.css'
|
|
import App from './App.vue'
|
|
import './style.css'
|
|
|
|
const app = createApp(App)
|
|
// 全量注册图标,模板中可直接 <component :is="XxxIcon"> 使用
|
|
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
|
|
app.component(key, component)
|
|
}
|
|
app.use(ElementPlus, { locale: zhCn }).mount('#app')
|
|
|
|
/* ============================================================
|
|
皮肤(skin):只切 token,不改组件。
|
|
precision = 冷灰 + 压深天蓝的精密工作台(默认)
|
|
cream = 奶油极简治愈风(旧皮肤,保留可切换)
|
|
切换:localStorage['37du.skin'] = 'precision' | 'cream'
|
|
============================================================ */
|
|
const SKIN_KEY = '37du.skin'
|
|
const SKINS = ['cream', 'precision']
|
|
|
|
function initSkin() {
|
|
let skin = 'precision'
|
|
try { skin = localStorage.getItem(SKIN_KEY) || 'precision' } catch (_) { /* 隐私模式等 */ }
|
|
if (!SKINS.includes(skin)) skin = 'precision'
|
|
document.documentElement.dataset.skin = skin
|
|
}
|
|
|
|
// 在挂载前应用,避免首屏闪一下默认皮肤
|
|
initSkin()
|
|
|
|
/* ============================================================
|
|
奶油涂鸦装饰层:fixed 浮于页面顶层,仅视觉点缀。
|
|
可开关:localStorage['37du.doodles'] = 'off'(登录页顶部 ✿ 按钮同源)
|
|
注意:涂鸦是奶油皮肤专属装饰,precision 皮肤下由 CSS 整体隐藏。
|
|
============================================================ */
|
|
const DOODLES = {
|
|
squiggle:
|
|
'<svg width="90" height="46" viewBox="0 0 90 46" fill="none">' +
|
|
'<path d="M4 34 Q 16 6 30 28 T 58 22 T 84 26" stroke="#7CC3E8" stroke-width="3" stroke-linecap="round"/>' +
|
|
'<path d="M6 41 Q 22 20 38 38 T 66 34" stroke="#E5D9C5" stroke-width="2.4" stroke-linecap="round"/></svg>',
|
|
cloud:
|
|
'<svg width="70" height="44" viewBox="0 0 70 44" fill="none">' +
|
|
'<path d="M18 36 a10 10 0 0 1-1-19.8 A13 13 0 0 1 42 14.5 a9.5 9.5 0 0 1 10 8.6 A8 8 0 0 1 51 36Z" fill="#DCEFF9" stroke="#A8D8F2" stroke-width="2"/></svg>',
|
|
sparkles:
|
|
'<svg width="80" height="60" viewBox="0 0 80 60" fill="none">' +
|
|
'<path d="M14 8 l2.6 5.4 5.4 2.6 -5.4 2.6 -2.6 5.4 -2.6 -5.4 -5.4 -2.6 5.4 -2.6Z" fill="#F2C96B"/>' +
|
|
'<path d="M62 6 l1.8 3.7 3.7 1.8 -3.7 1.8 -1.8 3.7 -1.8 -3.7 -3.7 -1.8 3.7 -1.8Z" fill="#7CC3E8"/>' +
|
|
'<path d="M40 30 l2 4 4 2 -4 2 -2 4 -2 -4 -4 -2 4 -2Z" fill="#E58B8B"/></svg>',
|
|
heart:
|
|
'<svg width="46" height="42" viewBox="0 0 46 42" fill="none">' +
|
|
'<path d="M23 38 C 10 29 3 21 3 13 A 10 10 0 0 1 23 9 A 10 10 0 0 1 43 13 C 43 21 36 29 23 38Z" fill="#FBE3E0" stroke="#E9A7A0" stroke-width="2.4"/></svg>',
|
|
plant:
|
|
'<svg width="60" height="66" viewBox="0 0 60 66" fill="none">' +
|
|
'<path d="M30 62 V 26" stroke="#9BC88F" stroke-width="3" stroke-linecap="round"/>' +
|
|
'<path d="M30 30 C 18 30 14 18 16 10 C 24 10 28 18 30 22 C 32 15 38 9 46 10 C 46 18 40 28 30 30Z" fill="#D9EED1" stroke="#9BC88F" stroke-width="2"/>' +
|
|
'<path d="M30 44 C 22 44 18 36 19 30 C 26 30 29 36 30 40 C 34 34 40 31 45 32 C 43 40 37 44 30 44Z" fill="#C6E6BB" stroke="#9BC88F" stroke-width="2"/></svg>',
|
|
sun:
|
|
'<svg width="54" height="54" viewBox="0 0 54 54" fill="none">' +
|
|
'<circle cx="27" cy="27" r="12" fill="#FFF2C9" stroke="#F2C96B" stroke-width="2.4"/>' +
|
|
'<g stroke="#F2C96B" stroke-width="2.6" stroke-linecap="round">' +
|
|
'<path d="M27 4v7M27 43v7M4 27h7M43 27h7M10 10l5 5M39 39l5 5M44 10l-5 5M15 39l-5 5"/></g></svg>',
|
|
}
|
|
|
|
function initDoodles() {
|
|
if (document.getElementById('dsh-doodles')) return
|
|
const wrap = document.createElement('div')
|
|
wrap.id = 'dsh-doodles'
|
|
// [类型, left, top, 水平翻转]
|
|
const spots = [
|
|
['squiggle', '6%', '12%', false],
|
|
['cloud', '88%', '8%', false],
|
|
['sun', '93%', '40%', false],
|
|
['sparkles', '78%', '66%', false],
|
|
['heart', '5%', '68%', false],
|
|
['plant', '13%', '36%', true],
|
|
]
|
|
for (const [name, left, top, flip] of spots) {
|
|
const el = document.createElement('span')
|
|
el.className = 'doodle'
|
|
el.style.left = left
|
|
el.style.top = top
|
|
el.innerHTML = DOODLES[name] || DOODLES.sparkles
|
|
if (flip) el.querySelector('svg').style.transform = 'scaleX(-1)'
|
|
wrap.appendChild(el)
|
|
}
|
|
document.body.appendChild(wrap)
|
|
let on = 'on'
|
|
try { on = localStorage.getItem('37du.doodles') || 'on' } catch (_) {}
|
|
document.documentElement.classList.toggle('no-doodles', on === 'off')
|
|
}
|
|
|
|
// 应用挂载后注入(body 已存在),不阻塞首屏
|
|
initDoodles() |