diff --git a/src/store/index.js b/src/store/index.js index f9fa6ca..b74aed2 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -1,28 +1,15 @@ import { createStore } from 'vuex' - + +var moduleFile=import.meta.globEager("./modules/**/*.js") + const store = createStore({ - state: { - userInfo: { - name:'myName' - } - }, - mutations: { - getUserInfo (state, name) { - state.userInfo.name = name - } - }, - actions: { - asyncGetUserInfo ({ commit }) { - setTimeout(() => { - commit("getUserInfo", +new Date() + 'action') - },2000) - } - }, getters: { - userInfoGetter (state) { - return state.userInfo.name - } - } + + }, + modules:Object.keys(moduleFile).reduce((a,b)=>{ + a[b.match(/\/modules\/(.+)\.js/)[1]]=moduleFile[b].default + return a; + },{}) }) export default store \ No newline at end of file diff --git a/src/store/modules/data.js b/src/store/modules/data.js new file mode 100644 index 0000000..be014ba --- /dev/null +++ b/src/store/modules/data.js @@ -0,0 +1,16 @@ + +export default { + namespaced:true, + state:{ + + }, + getters:{ + + }, + mutations:{ + + }, + actions:{ + + } +} \ No newline at end of file diff --git a/src/view/home.vue b/src/view/home.vue index 4d3c764..6ae41d4 100644 --- a/src/view/home.vue +++ b/src/view/home.vue @@ -17,7 +17,7 @@ import HelloWorld from "@/components/HelloWorld.vue" function img(){//动态引入图片 - var img=import.meta.globEager('@/assets/img/logo.png') + var img=import.meta.globEager('@/assets/img/**/*.png') return img['../assets/img/logo.png'].default } \ No newline at end of file diff --git a/vite.config.js b/vite.config.js index 9b48741..d2a25fd 100644 --- a/vite.config.js +++ b/vite.config.js @@ -21,7 +21,6 @@ export default defineConfig({ rollupOptions:{ input:{ // 多项目打包 index: path.resolve(__dirname, 'index.html') - // index: path.resolve(__dirname, 'src/index.js') }, // external:['vue'], // 控制插件不编译 output: {