提交 | 用户 | 时间
|
820397
|
1 |
// 引入unocss css |
H |
2 |
import '@/plugins/unocss' |
|
3 |
|
|
4 |
// 导入全局的svg图标 |
|
5 |
import '@/plugins/svgIcon' |
|
6 |
|
6baa33
|
7 |
import Iconify from '@iconify/iconify' |
H |
8 |
import epJson from '@iconify/json/json/ep.json' |
|
9 |
import faJson from '@iconify/json/json/fa.json' |
|
10 |
import faSolidJson from '@iconify/json/json/fa-solid.json' |
|
11 |
|
|
12 |
Iconify.addCollection(epJson) |
|
13 |
Iconify.addCollection(faJson) |
|
14 |
Iconify.addCollection(faSolidJson) |
|
15 |
|
|
16 |
export * from '@iconify/iconify' |
|
17 |
|
|
18 |
export default Iconify |
|
19 |
|
820397
|
20 |
// 初始化多语言 |
H |
21 |
import { setupI18n } from '@/plugins/vueI18n' |
|
22 |
|
|
23 |
// 引入状态管理 |
|
24 |
import { setupStore } from '@/store' |
|
25 |
|
|
26 |
// 全局组件 |
|
27 |
import { setupGlobCom } from '@/components' |
|
28 |
|
|
29 |
// 引入 element-plus |
|
30 |
import { setupElementPlus } from '@/plugins/elementPlus' |
|
31 |
|
|
32 |
// 引入 form-create |
|
33 |
import { setupFormCreate } from '@/plugins/formCreate' |
|
34 |
|
|
35 |
// 引入全局样式 |
|
36 |
import '@/styles/index.scss' |
|
37 |
|
|
38 |
// 引入动画 |
|
39 |
import '@/plugins/animate.css' |
|
40 |
|
|
41 |
// 路由 |
|
42 |
import router, { setupRouter } from '@/router' |
|
43 |
|
|
44 |
// 权限 |
|
45 |
import { setupAuth } from '@/directives' |
|
46 |
|
|
47 |
import { createApp } from 'vue' |
|
48 |
|
|
49 |
import App from './App.vue' |
|
50 |
|
|
51 |
import './permission' |
|
52 |
|
|
53 |
import '@/plugins/tongji' // 百度统计 |
|
54 |
import Logger from '@/utils/Logger' |
|
55 |
|
|
56 |
import VueDOMPurifyHTML from 'vue-dompurify-html' // 解决v-html 的安全隐患 |
|
57 |
|
e7305d
|
58 |
import WujieVue from 'wujie-vue3' |
H |
59 |
|
|
60 |
const { setupApp } = WujieVue |
|
61 |
|
effbd8
|
62 |
import hostMap from "@/utils/hostMap"; |
H |
63 |
|
|
64 |
import { micros } from '@/utils/micors' |
e7305d
|
65 |
|
H |
66 |
import lifecycles from '@/utils/lifecycles' // 生命周期函数 |
effbd8
|
67 |
|
H |
68 |
// import credentialsFetch from "@/utils/fetch"; |
|
69 |
|
|
70 |
const isProduction = process.env.NODE_ENV === "production"; |
e7305d
|
71 |
|
820397
|
72 |
// 创建实例 |
H |
73 |
const setupAll = async () => { |
|
74 |
const app = createApp(App) |
|
75 |
|
|
76 |
await setupI18n(app) |
|
77 |
|
|
78 |
setupStore(app) |
|
79 |
|
|
80 |
setupGlobCom(app) |
|
81 |
|
|
82 |
setupElementPlus(app) |
|
83 |
|
|
84 |
setupFormCreate(app) |
|
85 |
|
|
86 |
setupRouter(app) |
|
87 |
|
|
88 |
setupAuth(app) |
|
89 |
|
|
90 |
await router.isReady() |
|
91 |
|
|
92 |
app.use(VueDOMPurifyHTML) |
|
93 |
|
e7305d
|
94 |
app.use(WujieVue) |
H |
95 |
|
820397
|
96 |
app.mount('#app') |
H |
97 |
} |
|
98 |
|
|
99 |
setupAll() |
|
100 |
|
effbd8
|
101 |
const degrade = window.localStorage.getItem("degrade") === "true" || !window.Proxy || !window.CustomElementRegistry; |
H |
102 |
const props = { |
|
103 |
jump: (name) => { |
|
104 |
router.push({ name }); |
|
105 |
}, |
|
106 |
}; |
|
107 |
|
e7305d
|
108 |
// 模拟接口查询,实现动动态子应用加载与动态路由添加 |
H |
109 |
const setMiro = () => |
|
110 |
new Promise((resolve) => { |
|
111 |
for (const value of micros) { |
|
112 |
const obj: any = { |
|
113 |
path: `/${value.name}`, |
|
114 |
name: value.name, |
|
115 |
component: () => import(`@/views/micro/index.vue`) |
|
116 |
} |
|
117 |
router.addRoute('home', obj) |
effbd8
|
118 |
const attrs = isProduction ? { src: hostMap("//localhost/") } : {}; |
e7305d
|
119 |
setupApp({ |
effbd8
|
120 |
name: "fast", |
H |
121 |
url: hostMap("//localhost:90/"), |
|
122 |
attrs, |
e7305d
|
123 |
exec: true, |
effbd8
|
124 |
alive: true, |
H |
125 |
plugins: [{ cssExcludes: ["https://stackpath.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"] }], |
|
126 |
props, |
|
127 |
// 引入了的第三方样式不需要添加credentials |
|
128 |
// fetch: (url, options) => |
|
129 |
// url.includes(hostMap("//localhost:90/")) ? credentialsFetch(url, options) : window.fetch(url, options), |
|
130 |
degrade, |
|
131 |
...lifecycles, |
|
132 |
}); |
|
133 |
// setupApp({ |
|
134 |
// name: value.name, |
|
135 |
// url: getUrl(value.name, micros), |
|
136 |
// exec: true, |
|
137 |
// ...lifecycles |
|
138 |
// }) |
e7305d
|
139 |
} |
H |
140 |
resolve(true) |
|
141 |
}) |
|
142 |
// eslint-disable-next-line require-await |
|
143 |
router.beforeEach(async (to, _from, next) => { |
|
144 |
if (router.getRoutes().length <= 3) { |
|
145 |
// 如果路由个数为基础路由,则说明没有进行路由和子应用添加,需要动态添加,添加完成,根据路由地址进行跳转 |
|
146 |
await setMiro() |
|
147 |
next({ |
|
148 |
path: to.path, |
|
149 |
query: { ...to.query } |
|
150 |
}) |
|
151 |
} else { |
|
152 |
next() |
|
153 |
} |
|
154 |
}) |
|
155 |
|
820397
|
156 |
Logger.prettyPrimary(`欢迎使用`, import.meta.env.VITE_APP_TITLE) |