cmvr-wms/ruoyi-ui/src/main.js

92 lines
3.2 KiB
JavaScript
Raw Normal View History

2026-07-16 11:21:59 +08:00
import Vue from 'vue'
import Cookies from 'js-cookie'
import Element from 'element-ui'
import './assets/styles/element-variables.scss'
import '@/assets/styles/index.scss' // global css
import '@/assets/styles/app.scss'
import '@/assets/styles/viewport.scss'
2026-07-16 11:21:59 +08:00
import App from './App'
import store from './store'
import router from './router'
import { installAppNavigation } from '@/utils/app-navigation'
2026-07-16 11:21:59 +08:00
import directive from './directive' // directive
import plugins from './plugins' // plugins
import { download } from '@/utils/request'
import './assets/icons' // icon
import './permission' // permission control
import { getDicts } from "@/api/system/dict/data"
import { getConfigKey } from "@/api/system/config"
import { parseTime, resetForm, addDateRange, selectDictLabel, selectDictLabels, handleTree } from "@/utils/common"
// 分页组件
import Pagination from "@/components/Pagination"
// 自定义表格工具组件
import RightToolbar from "@/components/RightToolbar"
import BusinessPageHeader from "@/components/BusinessPageHeader"
2026-07-16 11:21:59 +08:00
// 字典标签组件
import DictTag from '@/components/DictTag'
// 字典数据组件
import DictData from '@/components/DictData'
// 全局方法挂载
Vue.prototype.getDicts = getDicts
Vue.prototype.getConfigKey = getConfigKey
Vue.prototype.parseTime = parseTime
Vue.prototype.resetForm = resetForm
Vue.prototype.addDateRange = addDateRange
Vue.prototype.selectDictLabel = selectDictLabel
Vue.prototype.selectDictLabels = selectDictLabels
Vue.prototype.download = download
Vue.prototype.handleTree = handleTree
// 全局组件挂载
Vue.component('DictTag', DictTag)
Vue.component('Pagination', Pagination)
Vue.component('RightToolbar', RightToolbar)
Vue.component('BusinessPageHeader', BusinessPageHeader)
// 非首屏重型组件按需加载,避免富文本和拖拽依赖阻塞系统启动。
Vue.component('Editor', () => import(/* webpackChunkName: "component-editor" */ '@/components/Editor'))
Vue.component('FileUpload', () => import(/* webpackChunkName: "component-upload" */ '@/components/FileUpload'))
Vue.component('ImageUpload', () => import(/* webpackChunkName: "component-upload" */ '@/components/ImageUpload'))
Vue.component('ImagePreview', () => import(/* webpackChunkName: "component-image-preview" */ '@/components/ImagePreview'))
2026-07-16 11:21:59 +08:00
Vue.use(directive)
Vue.use(plugins)
DictData.install()
/**
* If you don't want to use mock-server
* you want to use MockJs for mock api
* you can execute: mockXHR()
*
* Currently MockJs will be used in the production environment,
* please remove it before going online! ! !
*/
Vue.use(Element, {
size: Cookies.get('size') || 'medium' // set element-ui default size
})
Vue.config.productionTip = false
installAppNavigation(router)
2026-07-16 11:21:59 +08:00
// 应用成功启动后清理资源恢复标记,后续版本切换仍可自动恢复。
try {
window.sessionStorage.removeItem('cmvr_asset_recovery_time')
const currentUrl = new URL(window.location.href)
if (currentUrl.searchParams.has('_asset_retry')) {
currentUrl.searchParams.delete('_asset_retry')
window.history.replaceState(window.history.state, '', currentUrl.pathname + currentUrl.search + currentUrl.hash)
}
} catch (ignore) {}
2026-07-16 11:21:59 +08:00
new Vue({
el: '#app',
router,
store,
render: h => h(App)
})