main.js
2.58 KB
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
/*
* @Date: 2025-03-20 20:36:36
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2025-12-28 11:48:35
* @FilePath: /mlaj/src/main.js
* @Description: 文件描述
*/
import { createApp } from 'vue'
import './style.css'
import App from './App.vue'
import router from './router'
import axios from '@/utils/axios'
import { restoreHashAfterOAuth } from '@/utils/oauthHashRestore'
import 'vant/lib/index.css'
import '@vant/touch-emulator'
/* import the fontawesome core */
import { library } from '@fortawesome/fontawesome-svg-core'
/* import font awesome icon component */
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome'
import { Icon as IconifyIcon } from '@iconify/vue'
/* import specific icons */
import {
faCirclePause,
faCirclePlay,
faPlay,
faPause,
faBackwardStep,
faForwardStep,
faVolumeUp,
faRedo,
faRepeat,
faList,
faChevronDown,
faVolumeOff,
faXmark,
faFileAlt,
faTimes,
faEye,
faFilePdf,
faExternalLinkAlt,
faSpinner,
faExclamationCircle,
faDownload,
faVenus,
faMars,
faMagnifyingGlassPlus,
faMagnifyingGlassMinus,
} from '@fortawesome/free-solid-svg-icons'
/* add icons to the library */
library.add(
faCirclePause,
faCirclePlay,
faPlay,
faPause,
faBackwardStep,
faForwardStep,
faVolumeUp,
faRedo,
faRepeat,
faList,
faChevronDown,
faVolumeOff,
faXmark,
faFileAlt,
faTimes,
faEye,
faFilePdf,
faExternalLinkAlt,
faSpinner,
faExclamationCircle,
faDownload,
faVenus,
faMars,
faMagnifyingGlassPlus,
faMagnifyingGlassMinus
)
if (!Array.prototype.at) {
Array.prototype.at = function (n) {
n = Math.trunc(n) || 0
if (n < 0) n += this.length
if (n < 0 || n >= this.length) return undefined
return this[n]
}
}
const app = createApp(App)
app.component('Icon', IconifyIcon)
app.component('FontAwesomeIcon', FontAwesomeIcon)
// 屏蔽警告信息
app.config.warnHandler = () => null
app.config.globalProperties.$http = axios // 关键语句
// 在安装路由前进行一次 hash 复原,确保初始路由正确
restoreHashAfterOAuth()
app.use(router)
// 开发环境添加欢迎页调试工具
if (import.meta.env.DEV) {
window.resetWelcomeFlag = () => {
const { resetWelcomeFlag } = require('./router/guards.js')
resetWelcomeFlag()
console.log('✅ 欢迎页标志已重置,请刷新页面查看欢迎页')
}
window.showWelcome = () => {
window.location.href = '/welcome'
}
console.log('🔧 开发工具:')
console.log(' - window.resetWelcomeFlag() 重置欢迎页标志')
console.log(' - window.showWelcome() 跳转到欢迎页')
}
app.mount('#app')