Skip to content

Commit

Permalink
查找文件
Browse files Browse the repository at this point in the history
  • Loading branch information
jsxiaosi committed Jun 13, 2021
1 parent c7f42e7 commit 830b0c1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
28 changes: 17 additions & 11 deletions src/store/index.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,26 @@
import { createStore } from 'vuex'

const routesModules = import.meta.globEager('./module/**/index.ts');

const modules = (r => {
return r.keys().map(key => {
return {
name: key.match(/^\.\/([\s\S]+)\/index\.js$/)[1],
module: r(key).default
}
})
})(require.context('./module/', true, /^\.\/([\s\S])+\/index\.js$/))
console.log(routesModules)

// const modules = (r => {
// console.log(r)
// return r.keys().map(key => {
// return {
// name: key.match(/^\.\/([\s\S]+)\/index\.js$/)[1],
// module: r(key).default
// }
// })
// })(import.meta.globEager("./module/**/index.js"))

// require.context('./module/', true, /^\.\/([\s\S])+\/index\.js$/)

let modulesObj = {}

modules.forEach(item => {
modulesObj[item.name] = item.module
})
// modules.forEach(item => {
// modulesObj[item.name] = item.module
// })

export default createStore({
modules: modulesObj,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import storage from '@/config/storage'

const actionTypes = {}

Expand Down

0 comments on commit 830b0c1

Please sign in to comment.