-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Expand file tree
/
Copy pathmain.ts
More file actions
50 lines (40 loc) · 1.21 KB
/
main.ts
File metadata and controls
50 lines (40 loc) · 1.21 KB
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
import { initializeMermaid } from '@md/core/utils'
import JsLiteRest from 'js-lite-rest'
import { createPinia } from 'pinia'
import { createApp } from 'vue'
import { data } from '@/stores/defaultData'
import App from './App.vue'
import { setupComponents } from './utils/setup-components'
import 'vue-sonner/style.css'
/* 每个页面公共css */
import '@/assets/index.css'
import '@/assets/less/theme.less'
;
(async function () {
const storex = await JsLiteRest.create({
history: [],
posts: data.posts,
}, {
savePath: `storex`,
})
storex.use(async (args: any, next: any) => {
const restLog: any = {}
if (args[2]) {
// 统一处理 vue 包装的可能是响应式的特殊对象
args[2] = JSON.parse(JSON.stringify(args[2]))
}
let result = await next(args)
result = JSON.parse(JSON.stringify(result))
restLog.args = args
restLog.result = result
console.debug(`restLog`, args.slice(0, 2).join(`/`), args[2], result.data)
return result
})
window.storex = storex
// 异步初始化 mermaid,避免初始化顺序问题
initializeMermaid().catch(console.error)
setupComponents()
const app = createApp(App)
app.use(createPinia())
app.mount(`#app`)
})()