diff --git a/README.md b/README.md index 04e911f0..5c6318d9 100644 --- a/README.md +++ b/README.md @@ -67,44 +67,60 @@ export default router - [路由的 hash 模式和 history 模式的区别](https://www.cnblogs.com/GGbondLearn/p/12239651.html) -## vuex +## pinia ```shell -npm install vuex@next +npm install pinia ``` -src 下创建 store/interface.ts +src 下创建 store/index.ts ```typescript -import {InjectionKey} from 'vue' -import {createStore, Store} from 'vuex' +import { createPinia } from "pinia"; +const store = createPinia(); +export { store }; +``` +## main.ts -export interface State { - count: number +```typescript +import {createApp} from 'vue' +import App from './App.vue' +import router from "./router"; +import '@/styles/index.scss' +import { store } from "./store"; +import ElementPlus from 'element-plus' +import 'element-plus/theme-chalk/index.css' +import locale from 'element-plus/lib/locale/lang/zh-cn' +import 'virtual:svg-icons-register'; + + +// @see https://blog.csdn.net/qq_37213281/article/details/121422027 +import * as ElIconModules from '@element-plus/icons' +import '@/permission' + + +import Pagination from '@/components/Pagination/index.vue' +import {getDictItemsByCode} from '@/api/system/dict' + + +const app = createApp(App) + +// 统一注册el-icon图标 +// @link https://blog.csdn.net/Alloom/article/details/119415984 +for (let iconName in ElIconModules) { + app.component(iconName, (ElIconModules as any)[iconName]) } -export const key: InjectionKey> = Symbol() +// 全局方法 +app.config.globalProperties.$getDictItemsByCode = getDictItemsByCode +app.component('Pagination', Pagination) // 全局组件 + .use(store) + .use(router) + .use(ElementPlus, {locale}) + .mount('#app') - -export const store = createStore({ - state() { - return { - count: 0 - } - }, - mutations: { - increment(state: { count: number }) { - state.count++ - } - } -}) ``` -**参考文档:** - -- [Vue3 的 InjectionKey 解决提供者和消费者同步注入值的类型](https://www.jianshu.com/p/7064c5f8f143) - - ## element-plus diff --git a/package.json b/package.json index 98decf67..d73047f4 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,7 @@ "nprogress": "^0.2.0", "path-browserify": "^1.0.1", "path-to-regexp": "^6.2.0", - "pinia": "^2.0.6", + "pinia": "^2.0.9", "screenfull": "^6.0.0", "vue": "^3.2.16", "vue-router": "^4.0.12", diff --git a/src/layout/components/AppMain.vue b/src/layout/components/AppMain.vue index 754be628..e48bc59b 100644 --- a/src/layout/components/AppMain.vue +++ b/src/layout/components/AppMain.vue @@ -13,15 +13,13 @@