refactor: 移除default-passive-events、字典方法重命名和pinia全局挂载方式优化

Former-commit-id: cde13acdb3068bca126a46b9684d0f0e82c46ac8
This commit is contained in:
haoxr
2022-12-18 13:26:43 +08:00
parent 98f1608745
commit b127b3d97b

View File

@@ -1,16 +1,13 @@
import { createApp, Directive } from 'vue'; import { createApp, Directive } from 'vue';
import App from './App.vue'; import App from './App.vue';
import router from '@/router'; import router from '@/router';
import { setupStore } from '@/store';
import { createPinia } from 'pinia';
import ElementPlus from 'element-plus'; import ElementPlus from 'element-plus';
import 'element-plus/theme-chalk/index.css'; import 'element-plus/theme-chalk/index.css';
import Pagination from '@/components/Pagination/index.vue'; import Pagination from '@/components/Pagination/index.vue';
import '@/permission'; import '@/permission';
import 'default-passive-events';
// 引入svg注册脚本 // 引入svg注册脚本
import 'virtual:svg-icons-register'; import 'virtual:svg-icons-register';
@@ -20,25 +17,21 @@ import i18n from '@/lang/index';
// 自定义样式 // 自定义样式
import '@/styles/index.scss'; import '@/styles/index.scss';
// 根据字典编码获取字典列表全局方法
import { listDictItemsByTypeCode } from '@/api/dict';
const app = createApp(App); const app = createApp(App);
// 自定义指令 // 自定义指令
import * as directive from '@/directive'; import * as directive from '@/directive';
Object.keys(directive).forEach(key => { Object.keys(directive).forEach(key => {
app.directive(key, (directive as { [key: string]: Directive })[key]); app.directive(key, (directive as { [key: string]: Directive })[key]);
}); });
// 全局方法 // 全局方法
app.config.globalProperties.$listDictItemsByTypeCode = listDictItemsByTypeCode; import { getDictionaries } from '@/api/dict';
app.config.globalProperties.$getDictionaries = getDictionaries;
// 注册全局组件 // 全局挂载
setupStore(app);
app app
.component('Pagination', Pagination) .component('Pagination', Pagination)
.use(createPinia())
.use(router) .use(router)
.use(ElementPlus) .use(ElementPlus)
.use(i18n) .use(i18n)