From 526f51a3420bbd8a56e2ab375f59ea05d6e7c225 Mon Sep 17 00:00:00 2001 From: Hooray <304327508@qq.com> Date: Tue, 10 May 2022 14:42:59 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96pinia=E4=BD=BF=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plop-templates/store/index.hbs | 9 +-- src/App.vue | 2 +- src/api/index.js | 11 ++- src/components/Copyright/index.vue | 2 +- src/layout/components/AppSetting/index.vue | 4 +- src/layout/components/Header/index.vue | 4 +- src/layout/components/Logo/index.vue | 2 +- src/layout/components/MainSidebar/index.vue | 4 +- src/layout/components/Search/index.vue | 6 +- src/layout/components/SubSidebar/index.vue | 4 +- src/layout/components/Tools/index.vue | 4 +- src/layout/components/Topbar/index.vue | 2 +- src/layout/index.vue | 6 +- src/main.js | 8 +- src/router/index.js | 74 +++++++++---------- src/store/index.js | 5 +- src/store/modules/keepAlive.js | 9 +-- src/store/modules/menu.js | 14 ++-- src/store/modules/route.js | 12 +-- src/store/modules/settings.js | 8 +- src/store/modules/user.js | 12 +-- src/util/index.js | 12 +-- .../keep_alive_example/nested/nested.vue | 2 +- .../nested/nested/nested.vue | 2 +- src/views/keep_alive_example/page.vue | 2 +- src/views/login.vue | 4 +- src/views/mock_example/index.vue | 2 +- src/views/permission_example/index.vue | 4 +- src/views/personal/edit.password.vue | 2 +- vite/plugins/auto-import.js | 3 +- 30 files changed, 105 insertions(+), 130 deletions(-) diff --git a/plop-templates/store/index.hbs b/plop-templates/store/index.hbs index e4e81230..838ac111 100644 --- a/plop-templates/store/index.hbs +++ b/plop-templates/store/index.hbs @@ -1,7 +1,4 @@ -import { defineStore } from 'pinia' -import { piniaStore } from '@/store' - -export const use{{ properCase name }}Store = defineStore( +const use{{ properCase name }}Store = defineStore( // 唯一ID '{{ camelCase name }}', { @@ -11,6 +8,4 @@ export const use{{ properCase name }}Store = defineStore( } ) -export function use{{ properCase name }}OutsideStore() { - return use{{ properCase name }}Store(piniaStore) -} +export default use{{ properCase name }}Store diff --git a/src/App.vue b/src/App.vue index fd3d0813..a83383ca 100644 --- a/src/App.vue +++ b/src/App.vue @@ -1,7 +1,7 @@ diff --git a/src/layout/components/AppSetting/index.vue b/src/layout/components/AppSetting/index.vue index 710c2a23..46a8c679 100644 --- a/src/layout/components/AppSetting/index.vue +++ b/src/layout/components/AppSetting/index.vue @@ -2,9 +2,9 @@ const { proxy } = getCurrentInstance() const route = useRoute() -import { useSettingsStore } from '@/store/modules/settings' +import useSettingsStore from '@/store/modules/settings' const settingsStore = useSettingsStore() -import { useMenuStore } from '@/store/modules/menu' +import useMenuStore from '@/store/modules/menu' const menuStore = useMenuStore() const isShow = ref(false) diff --git a/src/layout/components/Header/index.vue b/src/layout/components/Header/index.vue index 880d3472..14108b0f 100644 --- a/src/layout/components/Header/index.vue +++ b/src/layout/components/Header/index.vue @@ -2,9 +2,9 @@ import Logo from '../Logo/index.vue' import Tools from '../Tools/index.vue' -import { useSettingsStore } from '@/store/modules/settings' +import useSettingsStore from '@/store/modules/settings' const settingsStore = useSettingsStore() -import { useMenuStore } from '@/store/modules/menu' +import useMenuStore from '@/store/modules/menu' const menuStore = useMenuStore() const switchMenu = inject('switchMenu') diff --git a/src/layout/components/Logo/index.vue b/src/layout/components/Logo/index.vue index 046ae2de..67e380c8 100644 --- a/src/layout/components/Logo/index.vue +++ b/src/layout/components/Logo/index.vue @@ -1,7 +1,7 @@ diff --git a/src/views/keep_alive_example/nested/nested/nested.vue b/src/views/keep_alive_example/nested/nested/nested.vue index c7ef95ef..d5266909 100644 --- a/src/views/keep_alive_example/nested/nested/nested.vue +++ b/src/views/keep_alive_example/nested/nested/nested.vue @@ -7,7 +7,7 @@ diff --git a/src/views/keep_alive_example/page.vue b/src/views/keep_alive_example/page.vue index 45461f95..1656a3fc 100644 --- a/src/views/keep_alive_example/page.vue +++ b/src/views/keep_alive_example/page.vue @@ -11,7 +11,7 @@ import { onBeforeRouteLeave } from 'vue-router' const router = useRouter() -import { useKeepAliveStore } from '@/store/modules/keepAlive' +import useKeepAliveStore from '@/store/modules/keepAlive' const keepAliveStore = useKeepAliveStore() const openKeepAlive = ref(false) diff --git a/src/views/login.vue b/src/views/login.vue index 4a8c78e8..c355e485 100644 --- a/src/views/login.vue +++ b/src/views/login.vue @@ -12,9 +12,9 @@ const { proxy } = getCurrentInstance() const route = useRoute(), router = useRouter() -import { useSettingsStore } from '@/store/modules/settings' +import useSettingsStore from '@/store/modules/settings' const settingsStore = useSettingsStore() -import { useUserStore } from '@/store/modules/user' +import useUserStore from '@/store/modules/user' const userStore = useUserStore() const title = import.meta.env.VITE_APP_TITLE diff --git a/src/views/mock_example/index.vue b/src/views/mock_example/index.vue index 7490d119..ff029942 100644 --- a/src/views/mock_example/index.vue +++ b/src/views/mock_example/index.vue @@ -7,7 +7,7 @@