first commit
This commit is contained in:
1
王凯私活/TsxVueClassApi/bin/.pydio
Normal file
1
王凯私活/TsxVueClassApi/bin/.pydio
Normal file
@@ -0,0 +1 @@
|
||||
4ac2522b-c3cb-4af1-87fb-ee6e6242e0fc
|
||||
1
王凯私活/TsxVueClassApi/bin/config/.pydio
Normal file
1
王凯私活/TsxVueClassApi/bin/config/.pydio
Normal file
@@ -0,0 +1 @@
|
||||
9d76d575-a956-4eba-b474-4daf9b6b8054
|
||||
96
王凯私活/TsxVueClassApi/bin/config/index.js
Normal file
96
王凯私活/TsxVueClassApi/bin/config/index.js
Normal file
@@ -0,0 +1,96 @@
|
||||
/*
|
||||
* Copyright (c) 2024. bmy
|
||||
* Email:2271608011@qq.com
|
||||
* Github:https://github.com/helpcode
|
||||
*/
|
||||
|
||||
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 { VueCustomize, RouterMeta } from "@logic/base.type";
|
||||
import { Autowired } from "@ann/ioc.annotation";
|
||||
|
||||
@Component
|
||||
export default class ${ name } extends VueCustomize {
|
||||
private logic: ${name}Logic<${name}> = new ${name}Logic(this);
|
||||
private RouterMeta: RouterMeta = {
|
||||
title: '${ name }',
|
||||
showNav: true,
|
||||
isLogin: true
|
||||
};
|
||||
|
||||
public async created() {
|
||||
await this.logic.StartUp();
|
||||
};
|
||||
|
||||
// 路由拦截器
|
||||
beforeRouteEnter(to: Route, from: Route, next: (to?: RawLocation | false | ((vm: Vue) => void)) => void) {
|
||||
next();
|
||||
}
|
||||
|
||||
protected render() {
|
||||
return (
|
||||
<div class="${ name }">
|
||||
${ name }
|
||||
</div>
|
||||
)
|
||||
}
|
||||
}
|
||||
`
|
||||
},
|
||||
logicConfig: (name) => {
|
||||
return `
|
||||
import { Autowired } from "@ann/ioc.annotation";
|
||||
import { UserServiceImpl, ResponseType } from "@impl/user.service.impl";
|
||||
import { BaseLogic } from "@logic/base.logic";
|
||||
import { Methods, VueCustomize } from "@logic/base.type";
|
||||
|
||||
export class ${name}Logic<T extends ${name}> extends BaseLogic<T> implements Methods {
|
||||
|
||||
@Autowired()
|
||||
public readonly UserServiceImpl!: UserServiceImpl;
|
||||
|
||||
constructor(_: T) {
|
||||
super();
|
||||
this._ = _;
|
||||
}
|
||||
|
||||
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 { Autowired } from "@ann/Ioc.annotation";
|
||||
import { GET } from "@ann/Http.annotation";
|
||||
|
||||
export class ${ name }ServiceImpl implements ${ name }Service {
|
||||
|
||||
@GET({ useHandle: false })
|
||||
public async IndexClass(params: object): Promise<any> { }
|
||||
|
||||
}
|
||||
`
|
||||
},
|
||||
lessConfig: (name) => {
|
||||
return `
|
||||
@import "../mixin/_";
|
||||
.${ name } {
|
||||
}
|
||||
`
|
||||
}
|
||||
}
|
||||
101
王凯私活/TsxVueClassApi/bin/start-page.html
Normal file
101
王凯私活/TsxVueClassApi/bin/start-page.html
Normal file
@@ -0,0 +1,101 @@
|
||||
<!--
|
||||
~ Copyright (c) 2024. bmy
|
||||
~ Email:2271608011@qq.com
|
||||
~ Github:https://github.com/helpcode
|
||||
-->
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>启动页面</title>
|
||||
<meta id="viewport" content="width=device-width,initial-scale=1,minimum-scale=1, maximum-scale=1, user-scalable=no, viewport-fit=cover"
|
||||
name="viewport">
|
||||
<script src="https://at.alicdn.com/t/c/font_4318577_uqa853deiz.js"></script>
|
||||
<style>
|
||||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.icon {
|
||||
width: 1em;
|
||||
height: 1em;
|
||||
vertical-align: -0.15em;
|
||||
fill: currentColor;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.main {
|
||||
width: 100%;
|
||||
height: 100vh;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
margin-top: -150px;
|
||||
}
|
||||
|
||||
.main .icon {
|
||||
width: 150px;
|
||||
height: 150px;
|
||||
}
|
||||
|
||||
.main p {
|
||||
font-size: 20px;
|
||||
font-weight: bolder;
|
||||
letter-spacing: 2px;
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
|
||||
.main .pg {
|
||||
height: 15px;
|
||||
border: none;
|
||||
}
|
||||
|
||||
progress::-webkit-progress-bar {
|
||||
border-radius: 10px;
|
||||
background: #34495e;
|
||||
}
|
||||
|
||||
progress::-webkit-progress-value {
|
||||
border-radius: 10px;
|
||||
background: #41b883;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="main">
|
||||
<svg aria-hidden="true" class="icon">
|
||||
<use xlink:href="#json-Vue"></use>
|
||||
</svg>
|
||||
<p class="title">..</p>
|
||||
<progress class="pg" max="100" value="0"></progress>
|
||||
</div>
|
||||
<script>
|
||||
const pro = $('.pg');
|
||||
const title = $('.title');
|
||||
|
||||
async function getProgress() {
|
||||
return await fetch('/__progress').then(res => res.json());
|
||||
}
|
||||
|
||||
async function freshProgress() {
|
||||
let {progress} = await getProgress()
|
||||
let intProgress = ~~(progress * 100)
|
||||
pro.value = intProgress;
|
||||
title.innerText = `${intProgress}%`;
|
||||
if (progress < 1) {
|
||||
setTimeout(freshProgress, 500);
|
||||
}
|
||||
}
|
||||
|
||||
function $(className) {
|
||||
return document.querySelector(className);
|
||||
}
|
||||
|
||||
freshProgress();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
111
王凯私活/TsxVueClassApi/bin/tinit
Executable file
111
王凯私活/TsxVueClassApi/bin/tinit
Executable file
@@ -0,0 +1,111 @@
|
||||
/*
|
||||
* Copyright (c) 2024. bmy
|
||||
* Email:2271608011@qq.com
|
||||
* Github:https://github.com/helpcode
|
||||
*/
|
||||
|
||||
#!/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");
|
||||
|
||||
var isWin = /^win/.test(process.platform);
|
||||
const RootPath = process.cwd();
|
||||
|
||||
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 = isWin ? `${ RootPath }\\src\\application\\page\\${ UpperCase(programOptions.fileName) }.tsx` : `${ RootPath }/src/application/page/${ UpperCase(programOptions.fileName) }.tsx`;
|
||||
// logic 页面路径
|
||||
let LogicPath = isWin ? `${ RootPath }\\src\\application\\logic\\page\\${ UpperCase(programOptions.fileName) }.logic.ts` : `${ RootPath }/src/application/logic/page/${ UpperCase(programOptions.fileName) }.logic.ts`;
|
||||
// service 页面路径
|
||||
let ServicePath = isWin ? `${ RootPath }\\src\\core\\service\\${ UpperCase(programOptions.fileName) }.service.ts` : `${ RootPath }/src/core/service/${ UpperCase(programOptions.fileName) }.service.ts`;
|
||||
// Impl 页面路径
|
||||
let ImplPath = isWin ? `${ RootPath }\\src\\core\\service\\impl\\${ UpperCase(programOptions.fileName) }.service.impl.ts` : `${ RootPath }/src/core/service/impl/${ UpperCase(programOptions.fileName) }.service.impl.ts`;
|
||||
// Less 页面路径
|
||||
let LessPath = isWin ? `${ RootPath }\\src\\application\\assets\\less\\page\\${ UpperCase(programOptions.fileName) }.less` : `${ RootPath }/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