first commit
This commit is contained in:
1
陈海波/投标平台/admin_v2/bin/.pydio
Normal file
1
陈海波/投标平台/admin_v2/bin/.pydio
Normal file
@@ -0,0 +1 @@
|
||||
7334c68c-3907-4f75-a38a-735928b20d52
|
||||
1
陈海波/投标平台/admin_v2/bin/config/.pydio
Normal file
1
陈海波/投标平台/admin_v2/bin/config/.pydio
Normal file
@@ -0,0 +1 @@
|
||||
b99e8213-c9d7-4bee-80f2-23a898868d5a
|
||||
101
陈海波/投标平台/admin_v2/bin/config/index.js
Normal file
101
陈海波/投标平台/admin_v2/bin/config/index.js
Normal file
@@ -0,0 +1,101 @@
|
||||
module.exports = {
|
||||
pageConfig: (name) => {
|
||||
return `
|
||||
import "@pageLess/${name}.less";
|
||||
import { Component, Vue } from 'vue-property-decorator';
|
||||
import { ${name}Logic } from "@logic/page/${name}.logic";
|
||||
import { Route, RawLocation } from 'vue-router';
|
||||
import { BaseLayout, RouterMeta } from "@layout/base.layout";
|
||||
import MainLayoutComponents from "@components/MainLayoutComponents";
|
||||
|
||||
@Component
|
||||
export default class ${name} extends BaseLayout {
|
||||
private service: ${name}Logic = new ${name}Logic(this);
|
||||
private RouterMeta: RouterMeta = {
|
||||
title: '${name}',
|
||||
showNav: true,
|
||||
isLogin: true
|
||||
};
|
||||
|
||||
created() {
|
||||
this.service.StartUp();
|
||||
};
|
||||
|
||||
// 路由拦截器
|
||||
beforeRouteEnter(to: Route, from: Route, next: (to?: RawLocation | false | ((vm: Vue) => void)) => void) {
|
||||
next();
|
||||
}
|
||||
|
||||
protected render() {
|
||||
return (
|
||||
<div class="${name}">
|
||||
<MainLayoutComponents
|
||||
title="${name}"
|
||||
action={
|
||||
<div>操作栏目</div>
|
||||
}
|
||||
content={
|
||||
<div>内容栏目</div>
|
||||
}>
|
||||
</MainLayoutComponents>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
}
|
||||
`
|
||||
},
|
||||
logicConfig: (name) => {
|
||||
return `
|
||||
import { BaseLogic, VueType, Methods } from "@logic/Base.logic";
|
||||
import { Inject } from "@ann/Ioc.annotation";
|
||||
import { UserServiceImpl } from "@impl/User.service.impl";
|
||||
import { Vue } from "vue-property-decorator";
|
||||
import { MessageBox } from 'element-ui';
|
||||
|
||||
export class ${name}Logic extends BaseLogic implements Methods {
|
||||
|
||||
@Inject()
|
||||
public readonly UserServiceImpl!: UserServiceImpl;
|
||||
|
||||
constructor(point: any) {
|
||||
super();
|
||||
this.VueApp = point;
|
||||
}
|
||||
|
||||
public async StartUp(): Promise<void> {
|
||||
|
||||
}
|
||||
}
|
||||
`
|
||||
},
|
||||
serviceConfig: (name) => {
|
||||
return `
|
||||
export interface ${name}Service {
|
||||
IndexClass(params: object): Promise<any>;
|
||||
}
|
||||
`
|
||||
},
|
||||
implPathConfig: (name) => {
|
||||
return`
|
||||
import { ${name}Service } from "@service/${name}.service";
|
||||
import { Injectable } from "@ann/Ioc.annotation";
|
||||
import { GET } from "@ann/Http.annotation";
|
||||
|
||||
@Injectable()
|
||||
export class ${name}ServiceImpl implements ${name}Service {
|
||||
|
||||
@GET({ useHandle: false })
|
||||
public async IndexClass(params: object): Promise<any> { }
|
||||
|
||||
}
|
||||
`
|
||||
},
|
||||
lessConfig: (name) => {
|
||||
return `
|
||||
@import "../color/index";
|
||||
@import "../mixin/index";
|
||||
.${name} {
|
||||
}
|
||||
`
|
||||
}
|
||||
}
|
||||
101
陈海波/投标平台/admin_v2/bin/tinit
Executable file
101
陈海波/投标平台/admin_v2/bin/tinit
Executable file
@@ -0,0 +1,101 @@
|
||||
#!/usr/bin/env node
|
||||
const { program } = require('commander');
|
||||
const packageConfig = require("../package.json");
|
||||
const fs = require("fs");
|
||||
const path = require('path');
|
||||
const Config = require("./config");
|
||||
|
||||
program
|
||||
.requiredOption('-t, --file-type <type>', '文件类型: [page,logic,service,impl,less]')
|
||||
.option('-n, --file-name <name>', '被创建的文件名称')
|
||||
.option('-i, --is-create <is>', '是否为 -t 参数自动创建相关文件类型', false);
|
||||
program.version(packageConfig.version, '-v, --version', '显示当前的版本');
|
||||
|
||||
program.parse(process.argv);
|
||||
|
||||
// 存储终端的参数
|
||||
let programOptions = program.opts();
|
||||
let OtherFileType = program.parse(process.argv).args
|
||||
|
||||
// tsx 页面路径
|
||||
let PagePath = pathJoin(`../src/application/page/${UpperCase(programOptions.fileName)}.tsx`);
|
||||
// logic 页面路径
|
||||
let LogicPath = pathJoin(`../src/application/logic/page/${UpperCase(programOptions.fileName)}.logic.ts`);
|
||||
// service 页面路径
|
||||
let ServicePath = pathJoin(`../src/core/service/${UpperCase(programOptions.fileName)}.service.ts`);
|
||||
// Impl 页面路径
|
||||
let ImplPath = pathJoin(`../src/core/service/impl/${UpperCase(programOptions.fileName)}.service.impl.ts`);
|
||||
// Less 页面路径
|
||||
let LessPath = pathJoin(`../src/application/assets/less/page/${UpperCase(programOptions.fileName)}.less`);
|
||||
|
||||
// 需要创建的文件类型
|
||||
let FileList = ['page', 'logic', 'service', 'impl', 'less'];
|
||||
|
||||
// 是否需要为 controller 联合创建所有文件
|
||||
if (programOptions.isCreate) {
|
||||
FileList.forEach(val => replaceTplText(val));
|
||||
console.log("成功创建文件...");
|
||||
} else {
|
||||
// 循环创建多个文件
|
||||
if (OtherFileType.length !=0 ) {
|
||||
[...OtherFileType, programOptions.fileType].forEach(v => replaceTplText(v))
|
||||
} else {
|
||||
replaceTplText(programOptions.fileType)
|
||||
}
|
||||
console.log("成功创建文件...");
|
||||
}
|
||||
|
||||
/**
|
||||
* 替换模板的内容,并将内容写入文件。
|
||||
*/
|
||||
let FileText = ""
|
||||
function replaceTplText (action) {
|
||||
switch (action) {
|
||||
case 'page':
|
||||
fs.writeFileSync(PagePath, Config.pageConfig(UpperCase(programOptions.fileName)));
|
||||
break;
|
||||
case 'logic':
|
||||
fs.writeFileSync(LogicPath, Config.logicConfig(UpperCase(programOptions.fileName)));
|
||||
break;
|
||||
case 'service':
|
||||
fs.writeFileSync(ServicePath, Config.serviceConfig(UpperCase(programOptions.fileName)));
|
||||
break;
|
||||
case 'impl':
|
||||
fs.writeFileSync(ImplPath, Config.implPathConfig(UpperCase(programOptions.fileName)));
|
||||
break;
|
||||
case 'less':
|
||||
fs.writeFileSync(LessPath, Config.lessConfig(UpperCase(programOptions.fileName)));
|
||||
break;
|
||||
default:
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 单词首字母大写
|
||||
* @param str
|
||||
* @returns {void | string | *}
|
||||
* @constructor
|
||||
*/
|
||||
function UpperCase (str) {
|
||||
return str.replace(str[0],str[0].toUpperCase())
|
||||
}
|
||||
|
||||
/**
|
||||
* 读取文件内容
|
||||
* @param path
|
||||
* @returns {*}
|
||||
* @constructor
|
||||
*/
|
||||
function GetFileText (path) {
|
||||
return (fs.readFileSync( pathJoin(path), 'utf-8' )).toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 拼接路径
|
||||
* @param paths
|
||||
* @returns {string}
|
||||
*/
|
||||
function pathJoin (paths) {
|
||||
return path.join(__dirname, paths)
|
||||
}
|
||||
Reference in New Issue
Block a user