first commit

This commit is contained in:
编码猿
2024-09-27 01:28:38 +08:00
commit a9bde91e8e
2653 changed files with 701970 additions and 0 deletions

View File

@@ -0,0 +1 @@
4ac2522b-c3cb-4af1-87fb-ee6e6242e0fc

View File

@@ -0,0 +1 @@
9d76d575-a956-4eba-b474-4daf9b6b8054

View File

@@ -0,0 +1,96 @@
/*
* Copyright (c) 2024. bmy
* Email2271608011@qq.com
* Githubhttps://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 } {
}
`
}
}

View File

@@ -0,0 +1,101 @@
<!--
~ Copyright (c) 2024. bmy
~ Email2271608011@qq.com
~ Githubhttps://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>

View File

@@ -0,0 +1,111 @@
/*
* Copyright (c) 2024. bmy
* Email2271608011@qq.com
* Githubhttps://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>', '文件类型: [pagelogicserviceimplless]')
.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)
}