Skip to content

Commit c872f37

Browse files
committed
auto load metaFile
1 parent b292d5b commit c872f37

File tree

12 files changed

+88
-48
lines changed

12 files changed

+88
-48
lines changed

README.md

+13-6
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,22 @@
44

55
English | [简体中文](./README.zh-CN.md)
66

7-
# 介绍
7+
# Introduction
88

9-
quick-vue-admi是一个开箱即用的后台集成解决方案,它基于[Vue](https://cn.vuejs.org/)[Element](http://element-cn.eleme.io)[MongoDB](https://www.mongodb.com/),开创性地t推出基于配置的开发解决方案,帮你最快速地搭建企业级后台产品.
9+
quick-vue-admin is a front-end management background integration solution,base on [Vue](https://cn.vuejs.org/)[Element](http://element-cn.eleme.io)[MongoDB](https://www.mongodb.com/)
10+
Least programming,Auto dbref,out of the box。
1011

11-
- [文档](https://linzhixian.github.io/quick-vue-admin-document)
12+
- [Document](https://linzhixian.github.io/quick-vue-admin-document)
1213

13-
- [讨论组](https://gitter.im/quick-vue-admin/discuss)
14+
- [Discuss](https://gitter.im/quick-vue-admin/discuss)
1415

15-
## 依赖
16+
## Dependencies
1617
- nodejs           (need stand alone install)
1718
- koa 2.0.0         (include)
1819
- Element UI 2.x      (include)
1920
- MongoDB 3.x      (need stand alone install)
2021

21-
## 特性
22+
## Features
2223
```
2324
- Login / Logout
2425
@@ -63,6 +64,12 @@ npm run dev
6364
# Run for production environment
6465
npm run pm2
6566
```
67+
## contact
68+
69+
- Wechat:flygobaby
70+
71+
![](https://linzhixian.github.io/quick-vue-admin-document/wechat.jpg)
72+
6673
## Changelog
6774
Detailed changes for each release are documented in the [release notes](https://github.com/linzhixian/quick-vue-admin/releases).
6875

README.zh-CN.md

+4-9
Original file line numberDiff line numberDiff line change
@@ -15,29 +15,24 @@
1515
- [讨论组](https://gitter.im/quick-vue-admin/discuss)
1616

1717
## 依赖
18-
- nodejs           (需要单独安装)
19-
- koa 2.0.0         (项目依赖模块)
20-
- Element UI 2.x      (项目依赖模块)
21-
- MongoDB 3.x      (需要单独安装)
18+
- nodejs(需要单独安装)
19+
- koa 2.0.0 项目依赖模块)
20+
- Element UI 2.x (项目依赖模块)
21+
- MongoDB 3.x(需要单独安装)
2222

2323
## 功能
2424
```
2525
- 登录 / 注销
26-
27-
2826
- CRUD(增、删、改、查)
2927
- 通过编写一个元配置文件即可自动生成完整的:增、删、改、查、翻页 功能
3028
- 自动更新、保存数据到MongoDB
3129
- 自动创建索引到MongoDB
32-
3330
- 数据关联
34-
3531
- 权限验证
3632
- 菜单权限控制
3733
- 基于用户+角色的权限管理
3834
-
3935
- 支持自定义组件
40-
4136
- 错误页面
4237
- 404
4338
```

bin/Main.js

+2
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ var initLogPath = function() {
4646

4747
initLogPath();
4848

49+
/**初始化meta/index.js*/
50+
4951
/**
5052
* Get port from environment and store in Express.
5153
*/

bin/Run.js

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/usr/bin/env node
2+
let generateMetaFiles=require("../src/shared/meta/GenerateMetaFiles")
3+
generateMetaFiles().then(function(){
4+
var current_path = process.cwd();
5+
require(current_path + '/bin/Main')
6+
})
7+

bin/run

-6
This file was deleted.

package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
"author": "your name",
66
"private": true,
77
"scripts": {
8-
"dev": "cross-env NODE_ENV=development nodemon bin/Main",
9-
"pm2": "cross-env NODE_ENV=product pm2 start bin/Main.js --name quickVueAdmin -e logs/error.log -o logs/access.log",
8+
"dev": "cross-env NODE_ENV=development nodemon bin/Run --ignore src/shared/meta/metaFiles.js",
9+
"pm2": "cross-env NODE_ENV=product pm2 start bin/Run --name quickVueAdmin -e logs/error.log -o logs/access.log",
1010
"stop": "pm2 stop tcAdAdmin",
11-
"test": "cross-env NODE_ENV=test pm2 start bin/Main.js --name quickVueAdmin -i 1 -e logs/error.log -o logs/access.log",
11+
"test": "cross-env NODE_ENV=test pm2 start bin/Run --name quickVueAdmin -i 1 -e logs/error.log -o logs/access.log",
1212
"restart": "pm2 restart quickVueAdmin",
1313
"build": "cross-env NODE_ENV=production webpack --config build/webpack.config.js --progress ",
1414
"list": "pm2 list"

src/shared/meta/GenerateMetaFiles.js

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
2+
const fs=require("fs")
3+
const dir = require('node-dir');
4+
5+
async function subdir() {
6+
return new Promise(function(resolve,reject){
7+
dir.subdirs(__dirname, function(err, subdirs) {
8+
if (err) throw err;
9+
resolve(subdirs)
10+
})
11+
})
12+
}
13+
module.exports=async function() {
14+
let subdirs=await subdir()
15+
let paths=[]
16+
for(let oneDir of subdirs) {
17+
let files=dir.files(oneDir,{sync:true})
18+
for(let f of files) {
19+
let p=f.replace(__dirname,"").replace(/\\/g, "/")
20+
paths.push(p.substring(0,p.length-3))
21+
}
22+
}
23+
console.log(paths)
24+
let content="module.exports={"
25+
for(let one of paths) {
26+
content=content+"\n'"+one+"':"+"require('."+one+"'),"
27+
}
28+
content=content+"\n}"
29+
fs.writeFileSync(__dirname+"/metaFiles.js",content)
30+
return
31+
}

src/shared/meta/company/index.js

-4
This file was deleted.

src/shared/meta/example/index.js

-5
This file was deleted.

src/shared/meta/index.js

+19-10
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,22 @@
1+
let metaFiles=require("./metaFiles")
12
let map = {};
23

3-
load("company", require("./company"));
4-
load("sys",require("./sys"));
5-
load("example", require("./example"));
4+
/*--start--*/
5+
for(let one of Object.keys(metaFiles)) {
6+
load(one,metaFiles[one])
7+
}
8+
9+
/*load("./company/Employee")
10+
load("./example/Input")
11+
load("./example/SetThemeColor")
12+
load("./example/Tree")
13+
load("./sys/Role")
14+
load("./sys/User")*/
15+
/*--end--*/
616

717

8-
function load(path, modules) {
9-
for (let key of Object.keys(modules)) {
10-
let modu=modules[key]
11-
modu.columnsMap = {};
18+
function load(path,modu) {
19+
modu.columnsMap = {};
1220
modu.subPermissions=[]
1321
if (modu.columnsDef) {
1422
for (let one of modu.columnsDef) {
@@ -25,8 +33,9 @@ function load(path, modules) {
2533
})
2634
}
2735

28-
map["/" + path + "/" + key] = modu;
29-
console.log("loaded:" + "/" + path + "/" + key);
30-
}
36+
map[path ] = modu;
37+
console.log("loaded:" + path);
38+
3139
}
40+
3241
module.exports = map;

src/shared/meta/metaFiles.js

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
module.exports={
2+
'/company/Department':require('./company/Department'),
3+
'/company/Employee':require('./company/Employee'),
4+
'/example/Input':require('./example/Input'),
5+
'/example/SetThemeColor':require('./example/SetThemeColor'),
6+
'/example/Tree':require('./example/Tree'),
7+
'/sys/Role':require('./sys/Role'),
8+
'/sys/User':require('./sys/User'),
9+
}

src/shared/meta/sys/index.js

-5
This file was deleted.

0 commit comments

Comments
 (0)