main.js 2.58 KB
/*
 * @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')