/* * @Author: levi7754 levi7754@163.com * @Date: 2025-07-25 13:38:20 * @LastEditors: levi7754 levi7754@163.com * @LastEditTime: 2025-11-14 10:52:54 * @FilePath: \udp-front\packages\udp-core\src\main.ts * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE */ import { createApp, type Directive } from 'vue'; import App from './App.vue'; // import router from './router'; import { setViews } from './router'; import { setupStore } from './store'; import { setConfig, setSystemEnv } from './config'; import { useI18n, transformI18n } from '../src/plugins/i18n'; import { setTableConfig } from '../src/plugins/vxe-table'; import { injectResponsiveStorage } from './utils/storage'; import hasAuthority from './utils/authority'; import { getServiceApi, getBaseURL, setRouter, setBaseUrl } from './api'; import 'nprogress/nprogress.css'; // 一定要在main.ts中导入tailwind.css,防止vite每次hmr都会请求src/style/index.scss整体css文件导致热更新慢的问题 import './style/tailwind.css'; // // 引入重置样式 import './style/reset.scss'; // 导入公共样式 import './style/index.scss'; // import 'viewerjs/dist/viewer.css'; // import VueViewer from 'v-viewer'; // import SuTable from './components/SuTable/SuTable.vue'; import { // utLov2, // UtDivider, // UtModalForm2 // FormUpload2, // UtForm2, UtGrid2 // UtContent2 // UtStampBadge2 // UtModalGrid2 // UtUpload2 // UtIconSelect, // UtCalendar // uAttachment } from './components/udp'; const app = createApp(App); // 全局注册`@iconify/vue`图标库 import { IconifyIconOffline, FontIcon } from './components/ReIcon'; // 全局注册`vue-tippy` import 'tippy.js/dist/tippy.css'; import 'tippy.js/animations/perspective.css'; import VueTippy from 'vue-tippy'; app.use(VueTippy, { defaultProps: { animation: 'perspective' } }); // 自定义指令 import * as directives from './directives'; const setGlobal = app => { app.config.globalProperties.$hasAuthority = hasAuthority; app.config.globalProperties.$serviceApi = getServiceApi(); app.config.globalProperties.$url = getBaseURL(); window.$i18n = transformI18n; }; const setGlobalDirective = app => { Object.keys(directives).forEach(key => { app.directive(key, (directives as { [key: string]: Directive })[key]); }); }; const init = ({ router, config, lang, views, env, tableConfig }) => { setViews(views, router); app.use(router); setRouter(router); setConfig(app, config); setSystemEnv(env); setTableConfig(tableConfig); return new Promise(resolve => { useI18n(app, lang); app.component('IconifyIconOffline', IconifyIconOffline); app.component('FontIcon', FontIcon); // app.component('uAttachment', uAttachment).component('UGrid', UGrid); // .component('UtDivider', UtDivider) // app.component('UtModalForm2', UtModalForm2); app.component('UtGrid2', UtGrid2); // app.component('UtForm2', UtForm2); // app.component('UtModalGrid2', UtModalGrid2); // .component('UtIconSelect', UtIconSelect) // app.component('FormUpload2', FormUpload2); // .component('UtCalendar', UtCalendar) // app.component('UtContent2', UtContent2); // app.component('UtStampBadge2', UtStampBadge2); // .component('UtModalGrid', UtModalGrid); // app.use(VueViewer, { defaultOptions: { zIndex: 9999 } }); setGlobal(app); setBaseUrl(getBaseURL()); setGlobalDirective(app); // 全局组件 setupStore(app); injectResponsiveStorage(app, config); const result = { app, router }; resolve(result); }); }; export default init;