feat: 添加 vite-plugin-vue-layouts 插件并更新 vite 版本至 6.0.5

This commit is contained in:
严浩
2024-12-25 00:06:46 +08:00
parent 400de0f222
commit bfbeb326bc
14 changed files with 122 additions and 64 deletions

View File

@ -6,4 +6,4 @@ export function install({ app }: { app: import('vue').App<Element> }) {
app.use(PiniaColada, {});
}
export * from './counter';
export * from '../stores/counter';

View File

@ -1,22 +0,0 @@
import { ref, computed } from 'vue';
import { defineStore } from 'pinia';
export const useCounterStore = defineStore(
'counter',
() => {
const count = ref(0);
const doubleCount = computed(() => count.value * 2);
function increment() {
count.value++;
}
return { count, doubleCount, increment };
},
{
persist: true,
},
);
if (import.meta.hot) {
import.meta.hot.accept(acceptHMRUpdate(useCounterStore, import.meta.hot));
}

View File

@ -1,10 +1,11 @@
import { DataLoaderPlugin } from 'unplugin-vue-router/data-loaders';
import { createRouter, createWebHistory } from 'vue-router';
import { setupLayouts } from 'virtual:generated-layouts';
import { createRouter, createWebHistory } from 'vue-router/auto';
import { handleHotUpdate, routes } from 'vue-router/auto-routes';
const router = createRouter({
history: createWebHistory(import.meta.env.BASE_URL),
routes,
routes: setupLayouts(routes),
strict: true,
scrollBehavior: () => ({ left: 0, top: 0 }),
});