Skip to content

Commit c898d40

Browse files
author
Training
committed
兼容性
1 parent 187f8a6 commit c898d40

File tree

4 files changed

+28
-3
lines changed

4 files changed

+28
-3
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
.idea
44
/src/
55
/data
6+
/bin/config.json

bin/config.json

Lines changed: 0 additions & 1 deletion
This file was deleted.

comm.js

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,15 @@ export function setConfig(options){
3131
* @return {any}
3232
*/
3333
export function getConfig() {
34-
return getJsonFile(path.join(__dirname,"bin/config.json"));
34+
let cfgPath = path.join(__dirname,"bin/config.json");
35+
let cfg = getJsonFile(cfgPath);
36+
if (cfg === null){
37+
let res = {"excludeDir":null,"excludeReg":"((component(s)?)|(utils)|(route(r)?))","excludePath":null,"pagePath":"pages","type":"simple"};
38+
setJsonFile(cfgPath,res);
39+
return res;
40+
}
41+
return cfg
42+
3543
}
3644

3745
/**
@@ -47,6 +55,23 @@ export function getJsonFile(dir) {
4755
return null;
4856
}
4957
}
58+
/**
59+
* 从Json文件中获取JSON数据
60+
* @param dir 路径
61+
* @param data 数据
62+
* @return {JSON}
63+
*/
64+
export function setJsonFile(dir,data) {
65+
try {
66+
if (typeof data !== "string"){
67+
data = JSON.stringify(data);
68+
}
69+
fs.writeFileSync(dir,data,{encoding:'utf-8'});
70+
return true;
71+
}catch (e){
72+
return false;
73+
}
74+
}
5075
/**
5176
* 获取基础路径信息
5277
* @return {{filename: string, dir: string, dirname: string}}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "auto-router-vue3",
3-
"version": "1.2.5",
3+
"version": "1.2.6",
44
"description": "生成router, 基于vue",
55
"main": "index.js",
66
"type": "module",

0 commit comments

Comments
 (0)