吴羡
8 小时以前 1193ed5cf72c8d1093d0c061b9eefe61a28b0cb7
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
import { createApp } from 'vue'
 
import Cookies from 'js-cookie'
 
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import 'element-plus/theme-chalk/dark/css-vars.css'
import locale from 'element-plus/es/locale/lang/zh-cn'
 
import '@/assets/styles/index.scss' // global css
 
import App from './App'
import store from './store'
import router from './router'
import directive from './directive' // directive
 
// 注册指令
import plugins from './plugins' // plugins
import { download } from '@/utils/request'
 
// svg图标
import 'virtual:svg-icons-register'
import SvgIcon from '@/components/SvgIcon'
import elementIcons from '@/components/SvgIcon/svgicon'
import LimsIcon from '@/components/LimsIcon'
import { getLimsIcon } from '@/utils/lims-icon'
 
// 业务字典插件(组件选项 dicts: [...] → this.dict)
import DictData from '@/components/DictData'
 
import './permission' // permission control
 
import { useDict } from '@/utils/dict'
import { getConfigKey } from "@/api/system/config"
import { getDicts } from "@/api/system/dict/data"
import { parseTime, resetForm, addDateRange, handleTree, selectDictLabel, selectDictLabels } from '@/utils/ruoyi'
import { dictToValue } from '@/utils/index'
import { checkPermi } from '@/utils/permission'
import { getToken } from '@/utils/auth'
import { getJavaApi } from '@/utils/java-api'
import Big from 'big.js'
 
// 分页组件
import Pagination from '@/components/Pagination'
// 自定义表格工具组件
import RightToolbar from '@/components/RightToolbar'
// 富文本组件
import Editor from "@/components/Editor"
// 文件上传组件
import FileUpload from "@/components/FileUpload"
// 图片上传组件
import ImageUpload from "@/components/ImageUpload"
// 图片预览组件
import ImagePreview from "@/components/ImagePreview"
// 字典标签组件
import DictTag from '@/components/DictTag'
// 条形码组件(旧 vue-barcode 的 Vue3 版本)
import VueBarcode from '@chenfengyuan/vue-barcode'
// 源码用 moment 挂 $moment,只有 3 处调用(都是 .format),换 dayjs:体积小得多,格式串兼容
import dayjs from 'dayjs'
// element-ui 的日期令牌 `WW`(ISO 周次,两位补零)dayjs 默认不认。
// advancedFormat 负责把 `WW` 解释成 isoWeek(),isoWeek 提供该方法;两者一起装才等价于 element-ui。
import advancedFormat from 'dayjs/plugin/advancedFormat'
import isoWeek from 'dayjs/plugin/isoWeek'
dayjs.extend(advancedFormat)
dayjs.extend(isoWeek)
 
const app = createApp(App)
 
// 全局方法挂载
app.config.globalProperties.useDict = useDict
app.config.globalProperties.download = download
app.config.globalProperties.parseTime = parseTime
app.config.globalProperties.resetForm = resetForm
app.config.globalProperties.handleTree = handleTree
app.config.globalProperties.addDateRange = addDateRange
app.config.globalProperties.getConfigKey = getConfigKey
app.config.globalProperties.getDicts = getDicts
app.config.globalProperties.selectDictLabel = selectDictLabel
app.config.globalProperties.selectDictLabels = selectDictLabels
// 业务全局量
app.config.globalProperties.$Big = Big
app.config.globalProperties.dictToValue = dictToValue
app.config.globalProperties.checkPermi = checkPermi
app.config.globalProperties.HaveJson = (val) => JSON.parse(JSON.stringify(val))
// 旧版图标名 → EP 图标组件,供 :icon="$icon('el-icon-x')" 使用
app.config.globalProperties.$icon = getLimsIcon
app.config.globalProperties.$moment = dayjs
 
// javaApi:业务拼接静态资源/附件地址用。源码在加载时一次性求值,此处改为 getter 实时求值,
// 避免域名或环境切换后拿到失效快照。求值规则在 utils/java-api.js,普通 js 模块也从那里取。
Object.defineProperty(app.config.globalProperties, 'javaApi', {
  get: getJavaApi
})
// uploadHeader:源码同样是快照,改为 getter,保证登录/刷新 token 后上传仍带对凭证。
Object.defineProperty(app.config.globalProperties, 'uploadHeader', {
  get() {
    return { Authorization: 'Bearer ' + getToken() }
  }
})
 
// 全局组件挂载
app.component('DictTag', DictTag)
app.component('Pagination', Pagination)
app.component('FileUpload', FileUpload)
app.component('ImageUpload', ImageUpload)
app.component('ImagePreview', ImagePreview)
app.component('RightToolbar', RightToolbar)
app.component('Editor', Editor)
app.component('lims-icon', LimsIcon)
app.component('barcode', VueBarcode)
 
app.use(router)
app.use(store)
app.use(plugins)
app.use(elementIcons)
app.component('svg-icon', SvgIcon)
 
directive(app)
 
// 业务字典插件安装
app.use(DictData)
 
// 使用element-plus 并且设置全局的大小
app.use(ElementPlus, {
  locale: locale,
  // 支持 large、default、small
  size: Cookies.get('size') || 'default'
})
 
app.mount('#app')