project init
This commit is contained in:
commit
c78bb5195e
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
.vscode
|
||||
dist
|
||||
tmp
|
57
app/main.js
Normal file
57
app/main.js
Normal file
@ -0,0 +1,57 @@
|
||||
const electron = require('electron');
|
||||
// Module to control application life.
|
||||
const {app} = electron;
|
||||
// Module to create native browser window.
|
||||
const {BrowserWindow} = electron;
|
||||
|
||||
// Keep a global reference of the window object, if you don't, the window will
|
||||
// be closed automatically when the JavaScript object is garbage collected.
|
||||
let win;
|
||||
|
||||
function createWindow() {
|
||||
// Create the browser window.
|
||||
win = new BrowserWindow({
|
||||
width: 800,
|
||||
height: 600,
|
||||
webPreferences: {
|
||||
nodeIntegration: true
|
||||
}
|
||||
});
|
||||
|
||||
// and load the index.html of the app.
|
||||
// win.loadURL("http://127.0.0.1:12345/index.html");
|
||||
win.loadFile('../dist/index.html')
|
||||
|
||||
// Open the DevTools.
|
||||
// win.webContents.openDevTools();
|
||||
|
||||
// Emitted when the window is closed.
|
||||
win.on('closed', () => {
|
||||
// Dereference the window object, usually you would store windows
|
||||
// in an array if your app supports multi windows, this is the time
|
||||
// when you should delete the corresponding element.
|
||||
win = null;
|
||||
});
|
||||
}
|
||||
|
||||
// This method will be called when Electron has finished
|
||||
// initialization and is ready to create browser windows.
|
||||
// Some APIs can only be used after this event occurs.
|
||||
app.on('ready', createWindow);
|
||||
|
||||
// Quit when all windows are closed.
|
||||
app.on('window-all-closed', () => {
|
||||
// On OS X it is common for applications and their menu bar
|
||||
// to stay active until the user quits explicitly with Cmd + Q
|
||||
if (process.platform !== 'darwin') {
|
||||
app.quit();
|
||||
}
|
||||
});
|
||||
|
||||
app.on('activate', () => {
|
||||
// On OS X it's common to re-create a window in the app when the
|
||||
// dock icon is clicked and there are no other windows open.
|
||||
if (win === null) {
|
||||
createWindow();
|
||||
}
|
||||
});
|
8
app/package.json
Normal file
8
app/package.json
Normal file
@ -0,0 +1,8 @@
|
||||
{
|
||||
"name": "configtools",
|
||||
"version": "0.1.0",
|
||||
"main": "main.js",
|
||||
"scripts": {
|
||||
"start": "electron ."
|
||||
}
|
||||
}
|
5
copy.bat
Normal file
5
copy.bat
Normal file
@ -0,0 +1,5 @@
|
||||
echo 开始copy
|
||||
|
||||
robocopy .\dist ..\..\release\dataparse /MIR
|
||||
|
||||
pause
|
2128
libs/jszip.js
Normal file
2128
libs/jszip.js
Normal file
File diff suppressed because it is too large
Load Diff
11656
libs/xlsx.js
Normal file
11656
libs/xlsx.js
Normal file
File diff suppressed because one or more lines are too long
246
src/Defines.ts
Normal file
246
src/Defines.ts
Normal file
@ -0,0 +1,246 @@
|
||||
/**
|
||||
* 全局配置
|
||||
*/
|
||||
interface GlobalCfg {
|
||||
/**
|
||||
* 远程的配置路径
|
||||
*/
|
||||
remote?: string;
|
||||
|
||||
/**
|
||||
* 项目名称
|
||||
*/
|
||||
project: string;
|
||||
|
||||
/**
|
||||
* 客户端配置导出路径
|
||||
*/
|
||||
clientPath: string;
|
||||
|
||||
/**
|
||||
* 服务端配置导出路径
|
||||
*/
|
||||
serverPath?: string;
|
||||
|
||||
/**
|
||||
* 服务端用于注册常量和引用的类
|
||||
*/
|
||||
serverRegClass?: [string, string];
|
||||
|
||||
/**
|
||||
* 客户端用于注册常量和引用的类
|
||||
*/
|
||||
clientRegClass?: [string, string];
|
||||
/**
|
||||
* 执行完成后调用的脚本
|
||||
*/
|
||||
endScript?: string;
|
||||
|
||||
/**
|
||||
* 执行完成后调用的url
|
||||
*/
|
||||
endAction?: string;
|
||||
|
||||
/**
|
||||
* 屏蔽字源文件名称
|
||||
*/
|
||||
dirtyName?: string;
|
||||
|
||||
/**
|
||||
* 保存服务端屏蔽字数据文件名称
|
||||
*/
|
||||
dirtyServerName?: string;
|
||||
|
||||
/**
|
||||
* 保存客户端屏蔽字数据文件名称
|
||||
*/
|
||||
dirtyClientName?: string;
|
||||
|
||||
/**
|
||||
* 客户端屏蔽字文件保存路径
|
||||
*/
|
||||
dirtyClientPath?: string;
|
||||
|
||||
|
||||
/**
|
||||
* 名字库源文件名称
|
||||
*/
|
||||
nameLib?: string;
|
||||
|
||||
/**
|
||||
* 保存客户端数据文件名称
|
||||
*/
|
||||
nameLibClientName?: string;
|
||||
|
||||
/**
|
||||
* 名字库源文件保存路径
|
||||
*/
|
||||
nameLibClientPath?: string;
|
||||
|
||||
/**
|
||||
* 是否自动更新svn
|
||||
*/
|
||||
isAutoSvn?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* 属性定义
|
||||
*/
|
||||
interface ProDefine {
|
||||
|
||||
/**
|
||||
* 属性名称
|
||||
*/
|
||||
name: string;
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
desc: string;
|
||||
|
||||
/**
|
||||
* 是否导出客户端数据
|
||||
* 0 不解析
|
||||
* 1 解析,并在代码生成时,生成类型对应的字段
|
||||
* 2 解析,生成代码时,在decode方法中,由临时变量记录数据,不生成方法
|
||||
*/
|
||||
client: number;
|
||||
|
||||
/**
|
||||
* 是否导出服务端数据
|
||||
* 0 不解析
|
||||
* 1 解析,并在代码生成时,生成类型对应的字段
|
||||
* 2 解析,生成代码时,在decode方法中,由临时变量记录数据,不生成方法
|
||||
*/
|
||||
server: number;
|
||||
|
||||
/**
|
||||
* 数据类型检查器
|
||||
*/
|
||||
checker: TypeChecker;
|
||||
|
||||
/**
|
||||
* 数据类型服务器解析用
|
||||
*/
|
||||
type: String;
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查数据是否符合类型,否则抛错
|
||||
*
|
||||
* @interface TypeChecker
|
||||
*/
|
||||
interface TypeChecker {
|
||||
|
||||
type: string;
|
||||
|
||||
/**
|
||||
* java类型
|
||||
*/
|
||||
javaType:string;
|
||||
|
||||
/**
|
||||
* 类型索引值
|
||||
*/
|
||||
idx: number;
|
||||
|
||||
/**
|
||||
* 检查并返回处理后的数据
|
||||
*
|
||||
* @param {string} value 待处理的数据
|
||||
* @returns {any}
|
||||
*/
|
||||
check(value: string): any;
|
||||
|
||||
/**
|
||||
* 检查并返回处理后的服务器数据
|
||||
*/
|
||||
checkServer(value: string): any;
|
||||
|
||||
solveString?: string;
|
||||
|
||||
solveJavaString?:string;
|
||||
}
|
||||
|
||||
interface IPluginData {
|
||||
gcfg: GlobalCfg;
|
||||
/**
|
||||
* 文件名
|
||||
* @type {string}
|
||||
*/
|
||||
filename: string;
|
||||
/**原始数据 */
|
||||
rawData: any[];
|
||||
/**服务器数据 */
|
||||
sdatas: any[];
|
||||
/**客户端数据 */
|
||||
cdatas: any[];
|
||||
/**
|
||||
* 列定义
|
||||
*/
|
||||
defines: ProDefine[];
|
||||
/**
|
||||
* 数据起始行
|
||||
*/
|
||||
dataRowStart: number;
|
||||
|
||||
/**
|
||||
* 行配置对应的行数
|
||||
* Key {string} 配置名称
|
||||
"程序配置内容": "cfgRow",
|
||||
"前端解析": "clientRow",
|
||||
"后端解析": "serverRow",
|
||||
"默认值": "defaultRow",
|
||||
"数据类型": "typeRow",
|
||||
"描述": "desRow",
|
||||
"属性名称": "nameRow"
|
||||
|
||||
Value {number} 行号
|
||||
*
|
||||
* @type {{ [index: string]: number }}
|
||||
*/
|
||||
rowCfg: { [index: string]: number };
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* 插件回调
|
||||
* @interface IPluginCallback
|
||||
*/
|
||||
interface IPluginCallback {
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @param {Error} [err] 错误信息
|
||||
* @param {string} [output] 输出的字符串
|
||||
* @param {any[]} [sdatas] 处理后的服务端数据
|
||||
* @param {any[]} [cdatas] 处理后的客户端数据
|
||||
*/
|
||||
(err: Error, output?: string, sdatas?: any[], cdatas?: any[]): void
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* 插件定义
|
||||
* @interface IPlugin
|
||||
*/
|
||||
interface IPlugin {
|
||||
|
||||
/**
|
||||
*
|
||||
* 运行插件
|
||||
* @param {IPluginData} data
|
||||
* @param {IPluginCallback} callback
|
||||
*/
|
||||
execute(data: IPluginData, callback: IPluginCallback);
|
||||
}
|
||||
|
||||
interface IPluginLoaderCallback {
|
||||
type: string;
|
||||
error?: number;
|
||||
err?: Error;
|
||||
output?: string;
|
||||
sdatas?: any[];
|
||||
cdatas?: any[];
|
||||
}
|
101
src/MenualCodeHelper.ts
Normal file
101
src/MenualCodeHelper.ts
Normal file
@ -0,0 +1,101 @@
|
||||
var fs = nodeRequire("fs");
|
||||
/**
|
||||
* 手写代码的默认提示
|
||||
*/
|
||||
const ManualCodeDefaultComment = {
|
||||
/**
|
||||
* 类上方提示
|
||||
*/
|
||||
$area1: "!这里填写类上方的手写内容!",
|
||||
/**
|
||||
* 类中提示
|
||||
*/
|
||||
$area2: "!这里填写类里面的手写内容!",
|
||||
/**
|
||||
* 类下方提示
|
||||
*/
|
||||
$area3: "!这里填写类下发的手写内容!",
|
||||
/**
|
||||
* 处理函数提示
|
||||
*/
|
||||
$decode: "!这里填写方法中的手写内容!",
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成手动代码区域的文本
|
||||
*/
|
||||
function genManualAreaCode(key: string, cinfo: { [index: string]: string }) {
|
||||
let yuanyou = cinfo[key];
|
||||
let tab = `\t`;
|
||||
if (key == "$area2") tab += `\t`;
|
||||
if (key == "$decode") tab += `\t\t`;
|
||||
let desc = `${ManualCodeDefaultComment[key]}`;
|
||||
return `/*-*begin ${key} ${desc}*-*/
|
||||
${tab}${yuanyou?yuanyou:""}
|
||||
${tab}/*-*end ${key}*-*/`
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取手动写的代码信息
|
||||
*/
|
||||
function getManualCodeInfo(file: string) {
|
||||
let dict: { [index: string]: string } = {};
|
||||
if (fs.existsSync(file)) {
|
||||
//读取文件内容
|
||||
let content = fs.readFileSync(file, "utf8");
|
||||
//找到手写内容
|
||||
let reg = /[/][*]-[*]begin[ ]([$]?[a-zA-Z0-9]+)[ ](.*?)[*]-[*][/]([^]*?)[/][*]-[*]end[ ]\1[*]-[*][/]/g;
|
||||
while (true) {
|
||||
let result = reg.exec(content);
|
||||
if (result) {
|
||||
let key = result[1];
|
||||
let manual = result[3].trim();
|
||||
if (!manual) {//没有注释
|
||||
continue;
|
||||
} else if (key in ManualCodeDefaultComment) {
|
||||
if (ManualCodeDefaultComment[key] == manual) {//类上中下的注释
|
||||
continue;
|
||||
}
|
||||
}
|
||||
dict[key] = manual;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return dict;
|
||||
}
|
||||
|
||||
function getGConfigCodeInfo(file: string, scriptName: string, sortName?: string) {
|
||||
sortName = sortName ? `, "${sortName}"` : "";
|
||||
let addstr = `rP("${scriptName}", ${scriptName}Cfg${sortName});`;
|
||||
if (fs.existsSync(file)) {
|
||||
//读取文件内容
|
||||
let content: string = fs.readFileSync(file, "utf8");
|
||||
if (content.indexOf(`${addstr}`) != -1) return "";
|
||||
let sstr = "//begin";
|
||||
let estr = "//end";
|
||||
let si = content.indexOf(sstr);
|
||||
let ei = content.indexOf(estr);
|
||||
if (ei > si && si != -1){
|
||||
let fcon = content.substring(si + sstr.length, ei).replace(/\t/g, "").replace(/\r/g, "");
|
||||
let temp = fcon.split("\n");//`rP("${tempfilename}", chuanqi.${tempfilename}Cfg);`
|
||||
let rarg: string[] = [];
|
||||
for (let i = 0, l = temp.length; i < l; i++) {
|
||||
let s = temp[i];
|
||||
if (s && s.indexOf(`rP("${scriptName}`) == -1){
|
||||
rarg.push(temp[i]);
|
||||
}
|
||||
}
|
||||
rarg.push(addstr);
|
||||
console.log(rarg);
|
||||
return rarg.join("\n\t\t");
|
||||
}
|
||||
return addstr;
|
||||
}
|
||||
else {
|
||||
return addstr;
|
||||
}
|
||||
}
|
||||
|
||||
export {genManualAreaCode, getManualCodeInfo, ManualCodeDefaultComment, getGConfigCodeInfo}
|
338
src/PackageData.ts
Normal file
338
src/PackageData.ts
Normal file
@ -0,0 +1,338 @@
|
||||
/**
|
||||
* 用于打包全部配置,将配置全部打包成一个文件
|
||||
* 服务端版本处理ani.json和pst.json的时候,不会打入帧数据
|
||||
*/
|
||||
module pakdata
|
||||
{
|
||||
|
||||
let path, fs;
|
||||
let require = window["nodeRequire"];
|
||||
if (typeof require === "function") { //是Electron环境
|
||||
path = require("path");
|
||||
fs = require("fs");
|
||||
}
|
||||
|
||||
const cfgsSpiltInfoName = "CfgsSpiltInfo.json";
|
||||
|
||||
|
||||
// 此处地址实际从外部传入解析
|
||||
let IP_HOST = `192.168.92.178`;
|
||||
let svnRoot = `//${IP_HOST}/web/`;
|
||||
let clientDir = `//${IP_HOST}/web/config/zhcn/raw/`;
|
||||
let packageRoot = `//${IP_HOST}/web/config/zhcn/`;
|
||||
let aniPath = `//${IP_HOST}/web/resource/zhcn/ef/`;
|
||||
let pstPath = `//${IP_HOST}/web/resource/zhcn/n/a/`;
|
||||
|
||||
export function initPathVars(url: string){
|
||||
let boo = true;
|
||||
let reg = /\/\/(.*?)\/(.*?)\//;
|
||||
if (reg.test(url)){
|
||||
let arg = reg.exec(url);
|
||||
if (arg){
|
||||
IP_HOST = arg[0];
|
||||
svnRoot = `${IP_HOST}`;
|
||||
clientDir = `${IP_HOST}config/zhcn/raw/`;
|
||||
packageRoot = `${IP_HOST}config/zhcn/`;
|
||||
aniPath = `${IP_HOST}resource/zhcn/ef/`;
|
||||
pstPath = `${IP_HOST}resource/zhcn/n/a/`;
|
||||
|
||||
boo = false;
|
||||
}
|
||||
}
|
||||
if (boo){
|
||||
|
||||
clientDir = url;
|
||||
packageRoot = path.join(url, "..");
|
||||
svnRoot = packageRoot;
|
||||
|
||||
IP_HOST = ``;
|
||||
aniPath = ``;
|
||||
pstPath = ``;
|
||||
|
||||
}
|
||||
|
||||
console.log(`IP_HOST=${IP_HOST}`);
|
||||
console.log(`svnRoot=${svnRoot}`);
|
||||
console.log(`clientDir=${clientDir}`);
|
||||
console.log(`packageRoot=${packageRoot}`);
|
||||
console.log(`aniPath=${aniPath}`);
|
||||
console.log(`pstPath=${pstPath}`);
|
||||
}
|
||||
|
||||
export var endCallBack;
|
||||
export var traceLog;
|
||||
export var traceErrorLog;
|
||||
export var ifErrorCallBack;
|
||||
export var isAutoSvn;
|
||||
|
||||
export async function packageForClient(){
|
||||
|
||||
let aniOutFile = path.join(clientDir, "ani.json");
|
||||
let pstOutFile = path.join(clientDir, "pst.json");
|
||||
let cfgsOutFile = path.join(packageRoot, "cfgs.json");
|
||||
let firstOutFile = path.join(packageRoot, "basic.json");
|
||||
let runningOutFile = path.join(packageRoot, "running.json");
|
||||
|
||||
let p = fs.statSync(clientDir);
|
||||
if (!p.isDirectory()) {
|
||||
console.error("文件夹有误");
|
||||
if (ifErrorCallBack ) ifErrorCallBack();
|
||||
return;
|
||||
}
|
||||
// if (isAutoSvn){
|
||||
// try{
|
||||
// await svncmd.update(svnRoot);
|
||||
// } catch (e) {
|
||||
// log(`[error svncmdUpdate] @@@ ${svnRoot}`);
|
||||
// }
|
||||
// }
|
||||
// ani文件夹特殊处理
|
||||
let cfgsOutData = {};
|
||||
let aniData = parseAni(aniPath);
|
||||
let pstData = parsePst(pstPath);
|
||||
|
||||
let cfgsSpiltInfoData = getCfgsSpiltInfo(clientDir);
|
||||
console.log("++++++cfgsSpiltInfoData+++++++");
|
||||
console.log(cfgsSpiltInfoData);
|
||||
console.log("++++++cfgsSpiltInfoData+++++++");
|
||||
|
||||
let firstData = {};
|
||||
let runningData = {};
|
||||
let flist = fs.readdirSync(clientDir);
|
||||
let basic = cfgsSpiltInfoData.basic || [];
|
||||
let firstKeys = basic.length > 0 ? basic : ["Function", "FunctionOpen", "MapLine", "TribeType"];
|
||||
let runningKeys = cfgsSpiltInfoData.running || [];
|
||||
|
||||
if (aniData){
|
||||
if (firstKeys.indexOf("ani") != -1){
|
||||
firstData["ani"] = aniData;
|
||||
} else if (runningKeys.indexOf("ani") != -1){
|
||||
runningData["ani"] = aniData;
|
||||
} else {
|
||||
cfgsOutData["ani"] = aniData;
|
||||
}
|
||||
}
|
||||
if (pstData) {
|
||||
if (firstKeys.indexOf("pst") != -1){
|
||||
firstData["pst"] = pstData;
|
||||
} else if (runningKeys.indexOf("pst") != -1){
|
||||
runningData["pst"] = pstData;
|
||||
} else {
|
||||
cfgsOutData["pst"] = pstData;
|
||||
}
|
||||
}
|
||||
|
||||
flist.forEach(file => {
|
||||
let re = path.parse(file);
|
||||
let fname = re.name;
|
||||
if (re.ext != ".json") {
|
||||
return;
|
||||
}
|
||||
if (file == "ani.json" || file == "pst.json") {
|
||||
// 此2文件已添加到outData中
|
||||
return;
|
||||
}
|
||||
if (file == cfgsSpiltInfoName) {
|
||||
return;// 配置分包信息不计入配置
|
||||
}
|
||||
let data = getData(path.join(clientDir, file));
|
||||
if (data){
|
||||
if (firstKeys.indexOf(fname) != -1){
|
||||
firstData[fname] = data;
|
||||
} else if (runningKeys.indexOf(fname) != -1){
|
||||
runningData[fname] = data;
|
||||
} else {
|
||||
cfgsOutData[fname] = data;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// let t = JSON.stringify(cfgsOutData);
|
||||
// let buf = new Buffer(t, "binary");
|
||||
// if (buf instanceof Uint8Array){
|
||||
// buf = new Buffer(buf);
|
||||
// }
|
||||
// console.log(buf);buf.toJSON();
|
||||
// let tempP = path.join(packageRoot, "cfgs.bin");
|
||||
// fs.writeFileSync(tempP, buf);
|
||||
|
||||
// let t1 = JSON.stringify(runningData);
|
||||
// let buf1 = new Buffer(t1, "binary");
|
||||
// console.log(buf1);
|
||||
// let tempP1 = path.join(packageRoot, "running.bin");
|
||||
// fs.writeFileSync(tempP1, buf1);
|
||||
|
||||
if (cfgsOutData) fs.writeFileSync(cfgsOutFile, JSON.stringify(cfgsOutData));
|
||||
if (aniData) fs.writeFileSync(aniOutFile, JSON.stringify(aniData));
|
||||
if (pstData) fs.writeFileSync(pstOutFile, JSON.stringify(pstData));
|
||||
if (firstData) fs.writeFileSync(firstOutFile, JSON.stringify(firstData));
|
||||
if (runningData) fs.writeFileSync(runningOutFile, JSON.stringify(runningData));
|
||||
|
||||
// if (isAutoSvn){
|
||||
// try{
|
||||
// await svncmd.add(packageRoot);
|
||||
// } catch (e) {
|
||||
// errorLog(`[error svncmdAdd]packageRoot:${packageRoot}`, e);
|
||||
// }
|
||||
|
||||
// try{
|
||||
// await svncmd.commit(packageRoot, "工具自动提交");
|
||||
// } catch (e) {
|
||||
// errorLog(`[error svncmdCommit]packageRoot:${packageRoot}`, e);
|
||||
// }
|
||||
// }
|
||||
log("PackageData 脚本执行完成");
|
||||
if( endCallBack ){
|
||||
endCallBack();
|
||||
}
|
||||
}
|
||||
|
||||
function log(msg)
|
||||
{
|
||||
if (traceLog) traceLog( msg );
|
||||
else console.log(msg);
|
||||
}
|
||||
|
||||
function errorLog(msg: string, err?: Error)
|
||||
{
|
||||
if (traceErrorLog) traceErrorLog(msg, err);
|
||||
else if (err) console.error(msg, err.message, err.stack);
|
||||
else console.log(msg);
|
||||
}
|
||||
|
||||
function getData(file)
|
||||
{
|
||||
if (!fs.existsSync(file) || !fs.statSync(file).isFile()) {
|
||||
errorLog(`找不到文件${file}`);
|
||||
return null;
|
||||
}
|
||||
log(`getData ${file}`);
|
||||
let data;
|
||||
try {
|
||||
data = JSON.parse(fs.readFileSync(file, "utf8"));
|
||||
}
|
||||
catch (e) {
|
||||
errorLog(`解析${file}数据,${file}时出错`, e);
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
function getCfgsSpiltInfo(root)
|
||||
{
|
||||
let file = path.join(root, cfgsSpiltInfoName);
|
||||
let data = getData(file);
|
||||
let basic = [];
|
||||
let running = [];
|
||||
if (data){
|
||||
data.forEach(list=>{
|
||||
let b = list[0];
|
||||
let r = list[1];
|
||||
if (b) basic.push(b);
|
||||
if (r) running.push(r);
|
||||
});
|
||||
}
|
||||
return { "basic": basic, "running":running };
|
||||
}
|
||||
/**
|
||||
* 处理ani文件夹
|
||||
*
|
||||
* @param {string} aniPath ani文件处理路径
|
||||
*/
|
||||
function parseAni(aniPath, saveTexture = true)
|
||||
{
|
||||
log(`parseAni:${aniPath}`);
|
||||
if(!fs.existsSync(aniPath)){
|
||||
errorLog(`no aniPath:${aniPath}`);
|
||||
return null;
|
||||
}
|
||||
var data = {};
|
||||
let p = fs.statSync(aniPath);
|
||||
if (!p.isDirectory()) {
|
||||
errorLog("给的ani路径文件夹有误");
|
||||
return null;
|
||||
}
|
||||
// 读取子文件夹
|
||||
let flist = fs.readdirSync(aniPath);
|
||||
flist.forEach(subDir => {
|
||||
//ani文件夹应该为 a0.png和d.json两个文件
|
||||
let p = path.join(aniPath, subDir);
|
||||
let dp = path.join(p, "d.json");
|
||||
//检查子文件夹文件
|
||||
if (fs.existsSync(path.join(p, "a0.png")) && fs.existsSync(dp)) {
|
||||
//有这两个文件,ani文件夹有效
|
||||
let aniDat;
|
||||
try {
|
||||
aniDat = JSON.parse(fs.readFileSync(dp, "utf8"));
|
||||
}
|
||||
catch (e) {
|
||||
errorLog(`解析ani数据,${dp}时出错`, e);
|
||||
return;
|
||||
}
|
||||
if (!aniDat || !Array.isArray(aniDat)) {
|
||||
errorLog(`解析ani数据,${dp}数据有误,不是数组`);
|
||||
return;
|
||||
}
|
||||
if (!saveTexture) {
|
||||
aniDat.length = 1;
|
||||
}
|
||||
data[subDir] = aniDat;
|
||||
}
|
||||
});
|
||||
return data;
|
||||
}
|
||||
/**
|
||||
* 处理pst文件夹
|
||||
*
|
||||
* @param {string} pstPath pst文件处理路径
|
||||
*/
|
||||
function parsePst(pstPath)
|
||||
{
|
||||
log(`parsePst:${pstPath}`);
|
||||
if(!fs.existsSync(pstPath)){
|
||||
errorLog(`no pstPath:${pstPath}`);
|
||||
return null;
|
||||
}
|
||||
var data = {};
|
||||
let p = fs.statSync(pstPath);
|
||||
if (!p.isDirectory()) {
|
||||
errorLog("给的pst路径文件夹有误");
|
||||
return null;
|
||||
}
|
||||
// 读取子文件夹
|
||||
let flist = fs.readdirSync(pstPath);
|
||||
flist.forEach(subDir => {
|
||||
//pst文件夹应该都包含 pst.json和d.json两个文件
|
||||
let p = path.join(pstPath, subDir);
|
||||
let dfile = path.join(p, "d.json");
|
||||
let pfile = path.join(p, "pst.json");
|
||||
//检查子文件夹文件
|
||||
if (fs.existsSync(pfile) && fs.existsSync(dfile)) {
|
||||
//有这两个文件,pst文件夹有效
|
||||
let pstDat;
|
||||
try {
|
||||
let temp = JSON.parse(fs.readFileSync(pfile, "utf8"));
|
||||
for (let key in temp){
|
||||
pstDat = temp[key];
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
errorLog(`解析ani数据,${pfile}时出错`, e);
|
||||
return;
|
||||
}
|
||||
if (!pstDat || !Array.isArray(pstDat)) {
|
||||
errorLog(`解析ani数据,${pfile}数据有误,不是数组`);
|
||||
return;
|
||||
}
|
||||
/*
|
||||
if (subDir == "A10") subDir = "1_0";
|
||||
else if (subDir == "A11") subDir = "1_1";
|
||||
*/
|
||||
data[subDir] = pstDat;
|
||||
}
|
||||
});
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
}
|
14
src/PluginErrorType.ts
Normal file
14
src/PluginErrorType.ts
Normal file
@ -0,0 +1,14 @@
|
||||
export var PluginErrorType = {
|
||||
/**
|
||||
* 加载失败
|
||||
*/
|
||||
LoadFailed: 1,
|
||||
/**
|
||||
* 初始化失败
|
||||
*/
|
||||
InitFailed: 2,
|
||||
/**
|
||||
* 执行失败
|
||||
*/
|
||||
ExecuteFailed: 3
|
||||
}
|
48
src/PluginLoader.ts
Normal file
48
src/PluginLoader.ts
Normal file
@ -0,0 +1,48 @@
|
||||
import {PluginErrorType} from "./PluginErrorType";
|
||||
import asyncFileLoad from "./asyncFileLoad";
|
||||
import $vm = require("vm");
|
||||
export default class PluginLoader {
|
||||
private plugin: IPlugin;
|
||||
private callback: { (data: IPluginLoaderCallback) };
|
||||
public constructor(pluginPath: string, m: IPluginData, callback: { (data: IPluginLoaderCallback) }) {
|
||||
this.callback = callback;
|
||||
var code = asyncFileLoad(pluginPath, (err, data) => {
|
||||
if (err) {
|
||||
this.sendError(PluginErrorType.LoadFailed, err);
|
||||
return;
|
||||
}
|
||||
var vm: typeof $vm = nodeRequire("vm");
|
||||
let str = data.toString();
|
||||
let plugin = <IPlugin>vm.createContext({ require: nodeRequire, console: console });
|
||||
try {
|
||||
vm.runInContext(str, plugin);
|
||||
} catch (err) {
|
||||
this.sendError(PluginErrorType.InitFailed, err);
|
||||
return;
|
||||
}
|
||||
this.plugin = plugin;
|
||||
this.execute(m);
|
||||
});
|
||||
}
|
||||
|
||||
private sendError(code: number, err?: Error) {
|
||||
// 插件代码有误
|
||||
this.callback({ type: "error", error: code, err: err });
|
||||
}
|
||||
|
||||
private execute(m: IPluginData) {
|
||||
try {
|
||||
this.plugin.execute(m, (err, output, sdatas, cdatas) => {
|
||||
if (err) {
|
||||
this.sendError(PluginErrorType.ExecuteFailed, err);
|
||||
return;
|
||||
}
|
||||
this.callback({ type: "success", output: output, sdatas: sdatas, cdatas: cdatas });
|
||||
});
|
||||
} catch (err) {
|
||||
this.sendError(PluginErrorType.ExecuteFailed, err);
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
209
src/SvnCmd.ts
Normal file
209
src/SvnCmd.ts
Normal file
@ -0,0 +1,209 @@
|
||||
module svncmd {
|
||||
|
||||
let path, fs, buffer, cp;
|
||||
let require = window["nodeRequire"];
|
||||
if (typeof require === "function") { //是Electron环境
|
||||
path = require("path");
|
||||
fs = require("fs");
|
||||
buffer = require("buffer");
|
||||
cp = require("child_process");
|
||||
}
|
||||
|
||||
export var errorLog;
|
||||
|
||||
/**
|
||||
* svn update 指定目录内容
|
||||
*/
|
||||
export function update(root: string)
|
||||
{
|
||||
return new Promise((suc, failed)=>{
|
||||
let exec = cp.exec;
|
||||
exec(`svn update ${root}`, function callback(err, stdout, stderr){
|
||||
if (stderr) {
|
||||
traceError("svn update failed【失败 失败 失败】" + `[${root}] __ ${stderr}`);
|
||||
failed("svn update failed【失败 失败 失败】" + `[${root}] __ ${stderr}`);
|
||||
}
|
||||
else {
|
||||
suc("svn update ok【 successful successful successful 】");
|
||||
console.log(`svn update successful`, stdout);
|
||||
}
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加指定svn目录下所有文件到 svn 版本控制
|
||||
*/
|
||||
export function add(addRoot)
|
||||
{
|
||||
return new Promise((suc, failed)=>{
|
||||
var exec = cp.exec;
|
||||
exec(`svn status ${addRoot}`,function callback(error, stdout, stderr) {
|
||||
try{
|
||||
let result: string = stdout;
|
||||
if (result){
|
||||
let arg = result.split("\r\n");
|
||||
if (arg && arg.length > 0){
|
||||
let next = async ()=>{
|
||||
if (arg.length > 0){
|
||||
let temp = arg.pop().replace(/\s/g, "");
|
||||
if (temp){
|
||||
if(temp.substring(0,1)=='?'){
|
||||
try{
|
||||
let filepath = temp.substring(temp.indexOf(addRoot.substring(2, 8)) - 2);
|
||||
filepath = getPathFromOldByNew(addRoot, filepath);
|
||||
await realAdd(filepath);
|
||||
} catch (e) {
|
||||
traceError("svn status function === ", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
next();
|
||||
} else {
|
||||
suc("ok");
|
||||
}
|
||||
}
|
||||
next();
|
||||
}
|
||||
} else {
|
||||
suc("ok");
|
||||
}
|
||||
} catch (e) {
|
||||
traceError("svn add failed【失败 失败 失败】", e);
|
||||
failed(e.message);
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 提交内容到 svn 服务器
|
||||
*/
|
||||
export function commit(commitRoot, desc)
|
||||
{
|
||||
return new Promise((suc, failed)=>{
|
||||
var exec = cp.exec;
|
||||
exec(`svn status ${commitRoot}`,function callback(error, stdout, stderr) {
|
||||
console.log(error, stdout, stderr);
|
||||
try{
|
||||
if (stdout){
|
||||
let result: string = stdout;
|
||||
if (result){
|
||||
let arg = result.split("\r\n");
|
||||
if (arg && arg.length > 0){
|
||||
let next = async()=>{
|
||||
if (arg.length > 0){
|
||||
let temp = arg.pop().replace(/\s/g, "");
|
||||
if (temp){
|
||||
let f = temp.substring(0,1);
|
||||
if (["?","!","M","A"].indexOf(f) != -1) {
|
||||
let filepath = temp.substring(temp.indexOf(commitRoot.substring(2, 8)) - 2);
|
||||
filepath = getPathFromOldByNew(commitRoot, filepath);
|
||||
if(f=='?'){
|
||||
try{ await realAdd(filepath); } catch (e) { traceError("", e); }
|
||||
}
|
||||
try{ await realCommit(filepath, desc); } catch (e) { traceError("", e); }
|
||||
}
|
||||
}
|
||||
next();
|
||||
} else {
|
||||
suc("ok");
|
||||
}
|
||||
}
|
||||
next();
|
||||
} else {
|
||||
suc("ok");
|
||||
}
|
||||
} else {
|
||||
suc("ok");
|
||||
}
|
||||
}
|
||||
else if (stderr) {
|
||||
traceError("[commit]svn status stderr"+stderr);
|
||||
failed("[commit]svn status stderr"+stderr);
|
||||
} else {
|
||||
suc("ok");
|
||||
}
|
||||
} catch (e) {
|
||||
traceError("failed", e);
|
||||
failed(e.message);
|
||||
}
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
export function cleanup(root: string)
|
||||
{
|
||||
return new Promise((suc, failed)=>{
|
||||
let exec = cp.exec;
|
||||
exec(`svn cleanup ${root}`, function callback(err, stdout, stderr){
|
||||
if (stderr) {
|
||||
traceError("svn cleanup failed【失败 失败 失败】" + `[${root}] __ ${stderr}`);
|
||||
failed("svn cleanup failed【失败 失败 失败】" + `[${root}] __ ${stderr}`);
|
||||
}
|
||||
else {
|
||||
suc("svn cleanup ok【 successful successful successful 】");
|
||||
console.log(`svn cleanup successful`, stdout);
|
||||
}
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
function traceError(msg, e?)
|
||||
{
|
||||
if (errorLog) errorLog(msg, e);
|
||||
else console.error(msg + ` ___ ${e?e.message:""}`);
|
||||
}
|
||||
|
||||
function getPathFromOldByNew(oldpath: string, newpath: string)
|
||||
{
|
||||
let oldNames = path.normalize(oldpath).split(path.sep);
|
||||
let newNames = path.normalize(newpath).split(path.sep);
|
||||
let prex = oldpath.indexOf("\\") == 0 || oldpath.indexOf("//") == 0 ? `\\\\` : "";
|
||||
let rpath = "";
|
||||
for (let i = 0, l= newNames.length; i < l; i++){
|
||||
if (!rpath) rpath = oldNames[i];
|
||||
else {
|
||||
let t = oldNames[i] || newNames[i];
|
||||
rpath = path.join(rpath, t);
|
||||
}
|
||||
}
|
||||
rpath = prex + rpath;
|
||||
return rpath;
|
||||
}
|
||||
|
||||
function realAdd(filepath)
|
||||
{
|
||||
return new Promise((ssuc, sfail)=>{
|
||||
var exec = cp.exec;
|
||||
exec(`svn add ${filepath}`,function callback(error, stdout, stderr) {
|
||||
console.log("realAdd error:"+error);
|
||||
console.log("realAdd stdout:"+stdout);
|
||||
if (stderr) {
|
||||
traceError("svn add failed【失败 失败 失败】" + `[${filepath}]`);
|
||||
sfail("sfailed");
|
||||
}
|
||||
else {
|
||||
console.log("svn add ok【 successful successful successful 】");
|
||||
ssuc("sok");
|
||||
}
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
function realCommit(filepath, desc)
|
||||
{
|
||||
return new Promise((ssuc, sfail)=>{
|
||||
var exec = cp.exec;
|
||||
exec(`svn commit ${filepath} -m "${desc}`,function callback(error, stdout, stderr) {
|
||||
console.log("realCommit error:"+error);
|
||||
console.log("realCommit stdout:"+stdout);
|
||||
if (stderr) sfail("svncommit sfail");
|
||||
else {
|
||||
console.log("svn commit ok【 successful successful successful 】");
|
||||
ssuc("svncommit ok");
|
||||
}
|
||||
});
|
||||
})
|
||||
}
|
||||
}
|
451
src/TypeCheckers.ts
Normal file
451
src/TypeCheckers.ts
Normal file
@ -0,0 +1,451 @@
|
||||
/**
|
||||
* 数值类型在解析json的时候,字符串会多两个"",数值更节省
|
||||
*
|
||||
* @param {*} value (description)
|
||||
* @returns (description)
|
||||
*/
|
||||
function tryParseNumber(value: any) {
|
||||
if (typeof value === "boolean") {
|
||||
return value ? 1 : 0;
|
||||
}
|
||||
if (value == +value && value.length == (+value + "").length) { // 数值类型
|
||||
// "12132123414.12312312"==+"12132123414.12312312"
|
||||
// true
|
||||
// "12132123414.12312312".length==(+"12132123414.12312312"+"").length
|
||||
// false
|
||||
return +value;
|
||||
} else {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 处理 any 类型的数据
|
||||
*
|
||||
* @class AnyChecker
|
||||
* @implements {TypeChecker}
|
||||
*/
|
||||
class AnyChecker implements TypeChecker {
|
||||
get type() {
|
||||
return "any";
|
||||
}
|
||||
|
||||
get javaType(){
|
||||
return "String";
|
||||
}
|
||||
|
||||
get idx() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
check(value: any) {
|
||||
return tryParseNumber(value);
|
||||
}
|
||||
|
||||
checkServer(value: string){
|
||||
return this.check(value);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理 string 类型的数据
|
||||
*
|
||||
* @class StringChecker
|
||||
* @implements {TypeChecker}
|
||||
*/
|
||||
class StringChecker implements TypeChecker {
|
||||
get type() {
|
||||
return "string";
|
||||
}
|
||||
|
||||
get javaType(){
|
||||
return "String";
|
||||
}
|
||||
|
||||
get idx() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
check(value: string) {
|
||||
return value;
|
||||
}
|
||||
|
||||
checkServer(value: string){
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 处理 number 类型的数据
|
||||
*
|
||||
* @class NumberChekcer
|
||||
* @implements {TypeChecker}
|
||||
*/
|
||||
class IntChekcer implements TypeChecker {
|
||||
get type() {
|
||||
return "number";
|
||||
}
|
||||
get javaType(){
|
||||
return "int";
|
||||
}
|
||||
get idx() {
|
||||
return 2;
|
||||
}
|
||||
check(value: string) {
|
||||
value = value.trim();
|
||||
if (!value) {
|
||||
return 0;
|
||||
}
|
||||
if (value.split(".").length <= 2 && (/^-?[0-9.]+e[0-9]+$/i.test(value) ||/^-?0b[01]+$/.test(value) || /^-?0x[0-9a-f]+$/i.test(value) || /^-?[0-9.]+$/.test(value))) {
|
||||
return +value;
|
||||
} else {
|
||||
throw new ValueTypeError("number", value);
|
||||
}
|
||||
}
|
||||
|
||||
checkServer(value: string){
|
||||
return this.check(value);
|
||||
}
|
||||
}
|
||||
|
||||
class FloatChekcer implements TypeChecker {
|
||||
get type() {
|
||||
return "number";
|
||||
}
|
||||
get javaType(){
|
||||
return "float";
|
||||
}
|
||||
get idx() {
|
||||
return 8;
|
||||
}
|
||||
check(value: string) {
|
||||
value = value.trim();
|
||||
if (!value) {
|
||||
return 0;
|
||||
}
|
||||
if (value.split(".").length <= 4 && (/^-?[0-9.]+e[0-9]+$/i.test(value) ||/^-?0b[01]+$/.test(value) || /^-?0x[0-9a-f]+$/i.test(value) || /^-?[0-9.]+$/.test(value))) {
|
||||
return +value;
|
||||
} else {
|
||||
throw new ValueTypeError("number", value);
|
||||
}
|
||||
}
|
||||
|
||||
checkServer(value: string){
|
||||
return this.check(value);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理 number 类型的数据
|
||||
*
|
||||
* @class NumberChekcer
|
||||
* @implements {TypeChecker}
|
||||
*/
|
||||
class LongChekcer implements TypeChecker {
|
||||
get type() {
|
||||
return "number";
|
||||
}
|
||||
get javaType(){
|
||||
return "long";
|
||||
}
|
||||
get idx() {
|
||||
return 9;
|
||||
}
|
||||
check(value: string) {
|
||||
value = value.trim();
|
||||
if (!value) {
|
||||
return 0;
|
||||
}
|
||||
if (value.split(".").length <= 2 && (/^-?[0-9.]+e[0-9]+$/i.test(value) ||/^-?0b[01]+$/.test(value) || /^-?0x[0-9a-f]+$/i.test(value) || /^-?[0-9.]+$/.test(value))) {
|
||||
return +value;
|
||||
} else {
|
||||
throw new ValueTypeError("number", value);
|
||||
}
|
||||
}
|
||||
|
||||
checkServer(value: string){
|
||||
return this.check(value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 处理 boolean 类型的数据
|
||||
*
|
||||
* @class BooleanChecker
|
||||
* @implements {TypeChecker}
|
||||
*/
|
||||
class BooleanChecker implements TypeChecker {
|
||||
get type() {
|
||||
return "boolean";
|
||||
}
|
||||
get javaType(){
|
||||
return "boolean";
|
||||
}
|
||||
get idx() {
|
||||
return 3;
|
||||
}
|
||||
solveString = `!!{value}`;
|
||||
check(value: string) {
|
||||
if (!value || value == "false" || value == "0") {
|
||||
return 0;
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
checkServer(value: string){
|
||||
return this.check(value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 处理 | 类型的数据
|
||||
*
|
||||
* @class ArrayCheker
|
||||
* @implements {TypeChecker}
|
||||
*/
|
||||
class ArrayCheker implements TypeChecker {
|
||||
get type() {
|
||||
return "any[]";
|
||||
}
|
||||
get javaType(){
|
||||
return "String";
|
||||
}
|
||||
get idx() {
|
||||
return 4;
|
||||
}
|
||||
check(value: string) {
|
||||
if (!value) return [];
|
||||
if (value.indexOf(":")!=-1){
|
||||
throw new ValueTypeError("array(:)", value + "(包含中文[:]冒号)");
|
||||
} else {
|
||||
let arr = value.split(":");
|
||||
arr.forEach((item, idx) => {
|
||||
arr[idx] = tryParseNumber(item);
|
||||
})
|
||||
return arr;
|
||||
}
|
||||
}
|
||||
|
||||
checkServer(value: string){
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理 |: 类型的二维数组的数据
|
||||
*
|
||||
* @class Array2DCheker
|
||||
* @implements {TypeChecker}
|
||||
*/
|
||||
class Array2DCheker implements TypeChecker {
|
||||
get type() {
|
||||
return "any[][]";
|
||||
}
|
||||
get javaType(){
|
||||
return "String";
|
||||
}
|
||||
get idx() {
|
||||
return 5;
|
||||
}
|
||||
check(value: string) {
|
||||
if (!value) return [];
|
||||
if (value.indexOf(":")!=-1){
|
||||
throw new ValueTypeError("array(|:)", value + "(包含中文[:]冒号)");
|
||||
} else {
|
||||
let arr: any[] = value.split("|");
|
||||
arr.forEach((item, idx) => {
|
||||
let subArr: any[] = item.split(":");
|
||||
arr[idx] = subArr;
|
||||
subArr.forEach((sitem, idx) => {
|
||||
subArr[idx] = tryParseNumber(sitem);
|
||||
});
|
||||
})
|
||||
return arr;
|
||||
}
|
||||
}
|
||||
|
||||
checkServer(value: string){
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
function isLeapYear(year: number) {
|
||||
return (year % 4 == 0 && year % 100 != 0) || (year % 100 == 0 && year % 400 == 0);
|
||||
}
|
||||
|
||||
const nday = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
|
||||
|
||||
function checkDate(value: string) {
|
||||
let res = /^(20[1-9][0-9])-(0\d+|1[0,1,2])-(\d+)$/.exec(value)
|
||||
if (res) {
|
||||
var year = +res[1];
|
||||
var month = +res[2];
|
||||
var day = +res[3];
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
if (day < 1) {
|
||||
return false;
|
||||
}
|
||||
let maxDay: number;
|
||||
if (month == 2 && isLeapYear(year)) {
|
||||
maxDay = 29;
|
||||
} else {
|
||||
maxDay = nday[month - 1];
|
||||
}
|
||||
if (day > maxDay) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function checkTime(value: string) {
|
||||
// let res = /^(\d{2}):(\d{2})$/.exec(value)
|
||||
if (value.indexOf(":") != -1){
|
||||
value = value.trim();
|
||||
var res = value.split(":");
|
||||
var h = +res[0];
|
||||
var m = +res[1];
|
||||
var s = +res[2];
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
if (h < 0 || h >= 24) {
|
||||
return null;
|
||||
}
|
||||
if (m < 0 || m >= 60) {
|
||||
return null;
|
||||
}
|
||||
if (s < 0 || s >= 60){
|
||||
return null;
|
||||
}
|
||||
return { h: h, m: m, s: s };
|
||||
}
|
||||
|
||||
/**
|
||||
* 日期检查器 yyyy-MM-dd
|
||||
*
|
||||
* @class DateChecker
|
||||
* @implements {TypeChecker}
|
||||
*/
|
||||
class DateChecker implements TypeChecker {
|
||||
get type() {
|
||||
return "Date";
|
||||
}
|
||||
get javaType(){
|
||||
return "String";
|
||||
}
|
||||
get idx() {
|
||||
return 6;
|
||||
}
|
||||
solveString = `new Date({value}*1000)`;
|
||||
|
||||
check(value: string) {
|
||||
if (!checkDate(value)) {
|
||||
throw new ValueTypeError("yyyy-MM-dd", value);
|
||||
}
|
||||
// 用8位数字代替 10位字符串(JSON后变成12位)
|
||||
return new Date(value).getTime() * 0.001;
|
||||
// return new Date(value + " UTC").getTime() * 0.001;
|
||||
}
|
||||
|
||||
checkServer(value: string){
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 时间检查器 HH:mm
|
||||
*
|
||||
* @class TimeChecker
|
||||
* @implements {TypeChecker}
|
||||
*/
|
||||
class TimeChecker implements TypeChecker {
|
||||
get type() {
|
||||
return "TimeVO";
|
||||
}
|
||||
get javaType(){
|
||||
return "String";
|
||||
}
|
||||
get idx() {
|
||||
return 7;
|
||||
}
|
||||
solveString = `new TimeVO({value})`;
|
||||
check(value: string) {
|
||||
let time = checkTime(value);
|
||||
if (!time) {
|
||||
throw new ValueTypeError("HH:mm | HH:mm:ss", value);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
checkServer(value: string){
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 日期时间检查器 yyyy-MM-dd HH:mm
|
||||
*
|
||||
* @class DateTimeChecker
|
||||
* @implements {TypeChecker}
|
||||
*/
|
||||
class DateTimeChecker implements TypeChecker {
|
||||
get type() {
|
||||
return "Date";
|
||||
}
|
||||
get javaType(){
|
||||
return "String";
|
||||
}
|
||||
get idx() {
|
||||
return 8;
|
||||
}
|
||||
solveString = `new Date({value}*1000)`;
|
||||
check(value: string) {
|
||||
let t = value.split(" ");
|
||||
let date = t[0];
|
||||
let time = t[1];
|
||||
if (!checkDate(date) || !checkTime(time)) {
|
||||
throw new ValueTypeError("yyyy-MM-dd HH:mm | yyyy-MM-dd HH:mm:ss", value);
|
||||
}
|
||||
// 使用UTC时间进行存储,解析的时候,改用服务器时区
|
||||
return new Date(value).getTime() * 0.001;
|
||||
// return new Date(value + " UTC").getTime() * 0.001;
|
||||
}
|
||||
|
||||
checkServer(value: string){
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* ValueTypeError
|
||||
*/
|
||||
class ValueTypeError extends Error {
|
||||
constructor(type: string, value: string) {
|
||||
super();
|
||||
this.message = `数据和类型不匹配,当前类型:${type},数据:${value}`;
|
||||
}
|
||||
}
|
||||
|
||||
let checkers: { [index: string]: TypeChecker } = {};
|
||||
// number string boolean : |: yyyy-MM-dd yyyy-MM-dd HH:mm HH:mm
|
||||
|
||||
checkers["any"] = new AnyChecker;
|
||||
checkers["int"] = new IntChekcer;
|
||||
checkers["float"] = new FloatChekcer;
|
||||
checkers["long"] = new LongChekcer;
|
||||
checkers["string"] = new StringChecker;
|
||||
checkers["boolean"] = new BooleanChecker;
|
||||
checkers[":"] = new ArrayCheker;
|
||||
checkers["|:"] = new Array2DCheker;
|
||||
checkers["yyyy-MM-dd"] = new DateChecker;
|
||||
checkers["HH:mm"] = new TimeChecker;
|
||||
checkers["yyyy-MM-dd HH:mm"] = new DateTimeChecker;
|
||||
|
||||
export default TypeChecker;
|
||||
export {checkers as TypeCheckers};
|
||||
export {ValueTypeError};
|
27
src/asyncFileLoad.ts
Normal file
27
src/asyncFileLoad.ts
Normal file
@ -0,0 +1,27 @@
|
||||
import $fs = require("fs");
|
||||
import $http = require("http");
|
||||
export default function asyncFileLoad(url: string, callback: { (err: Error, data?: Buffer) }) {
|
||||
if (/^http:\/\//.test(url)) {
|
||||
var http: typeof $http = nodeRequire("http");
|
||||
http.get(url, res => {
|
||||
let chunks: Buffer[] = [];
|
||||
res.on("data", chunk => {
|
||||
chunks.push(chunk);
|
||||
});
|
||||
res.on("end", () => {
|
||||
callback(null, Buffer.concat(chunks));
|
||||
});
|
||||
}).on("error", (e) => {
|
||||
callback(e);
|
||||
})
|
||||
} else {
|
||||
var fs: typeof $fs = nodeRequire("fs");
|
||||
fs.exists(url, exists => {
|
||||
if (exists) {
|
||||
fs.readFile(url, callback);
|
||||
} else {
|
||||
callback(Error(`无法找到指定文件${url}`));
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
1140
src/indexJava.ts
Normal file
1140
src/indexJava.ts
Normal file
File diff suppressed because it is too large
Load Diff
57
src/plugins/MsgCodeParser.ts
Normal file
57
src/plugins/MsgCodeParser.ts
Normal file
@ -0,0 +1,57 @@
|
||||
function writeJSONData(fname: string, directory: string, data: any): string {
|
||||
const path = require("path");
|
||||
const fs = require("fs");
|
||||
if (fs.existsSync(directory)) {
|
||||
let stat = fs.statSync(directory);
|
||||
if (stat.isDirectory()) {
|
||||
let outpath = path.join(directory + "", fname + ".json");
|
||||
fs.writeFileSync(outpath, JSON.stringify(data));
|
||||
return outpath;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
function execute(data: IPluginData, callback: IPluginCallback) {
|
||||
let list = data.rawData;
|
||||
// 检查第一行
|
||||
let cfg = {
|
||||
code: 1,//默认第一列
|
||||
msg: 2//默认第二列
|
||||
}
|
||||
let title: any[] = list[data.rowCfg["nameRow"]];
|
||||
let KeyFlag = 0;
|
||||
for (let col = 0, len = title.length; col <= len; col++) {
|
||||
let cell = title[col];
|
||||
if (cell) {
|
||||
cell = cell.trim();
|
||||
}
|
||||
if (cell == "code") {
|
||||
cfg.code = col;
|
||||
KeyFlag |= 0b1;
|
||||
} else if (cell == "msg") {
|
||||
cfg.msg = col;
|
||||
KeyFlag |= 0b10;
|
||||
}
|
||||
}
|
||||
if (KeyFlag != 0b11) {
|
||||
callback(Error(`code码表中第一列必须有抬头"code"和"msg"`));
|
||||
return;
|
||||
}
|
||||
let msgDict = {};
|
||||
// 去掉第一行说明
|
||||
for (let i = data.dataRowStart, len = list.length; i < len; i++) {
|
||||
let rowData = list[i];
|
||||
msgDict[rowData[cfg.code]] = rowData[cfg.msg];
|
||||
}
|
||||
// 存储文件
|
||||
let output = "";
|
||||
let fname = data.filename;
|
||||
let cpath = writeJSONData(fname, data.gcfg.clientPath, msgDict);
|
||||
if (cpath) {
|
||||
output = `处理code码文件${fname},将客户端数据保存至:${cpath}`;
|
||||
} else {
|
||||
output = `文件code码文件${fname},未将客户端数据保存到${cpath},请检查`;
|
||||
}
|
||||
callback(null, output);
|
||||
}
|
BIN
testsample/0.测试数据/CeShiBiao.xlsx
Normal file
BIN
testsample/0.测试数据/CeShiBiao.xlsx
Normal file
Binary file not shown.
BIN
testsample/0.测试数据/CeShiBiao1.xlsx
Normal file
BIN
testsample/0.测试数据/CeShiBiao1.xlsx
Normal file
Binary file not shown.
BIN
testsample/0.测试数据/CeShiBiao2.xlsx
Normal file
BIN
testsample/0.测试数据/CeShiBiao2.xlsx
Normal file
Binary file not shown.
16
testsample/csrc/chuanqi/GConfig.ts
Normal file
16
testsample/csrc/chuanqi/GConfig.ts
Normal file
@ -0,0 +1,16 @@
|
||||
|
||||
module giant.game {
|
||||
export function initData() {
|
||||
var rP = DataLocator.regCommonParser.bind(DataLocator);
|
||||
let P = chuanqi;
|
||||
//begin
|
||||
rP("Ce0ShiBiao", chuanqi.Ce0ShiBiaoCfg);
|
||||
rP("Ce1ShiBiao", chuanqi.Ce1ShiBiaoCfg);
|
||||
rP("Ce2ShiBiao", chuanqi.Ce2ShiBiaoCfg);
|
||||
rP("Ce3ShiBiao", chuanqi.Ce3ShiBiaoCfg);
|
||||
rP("CeShiBiao", chuanqi.CeShiBiaoCfg);
|
||||
rP("GongNeng", chuanqi.GongNengCfg);
|
||||
//end
|
||||
}
|
||||
|
||||
}
|
78
testsample/csrc/chuanqi/module/gongneng/cfg/GongNengCfg.ts
Normal file
78
testsample/csrc/chuanqi/module/gongneng/cfg/GongNengCfg.ts
Normal file
@ -0,0 +1,78 @@
|
||||
|
||||
module giant.chuanqi
|
||||
{
|
||||
/*-*begin $area1 !这里填写类上方的手写内容!*-*/
|
||||
|
||||
/*-*end $area1*-*/
|
||||
/**
|
||||
* 来自:D:\workspace\cqh5\cehua\trunk\数值\功能\GongNeng.xlsx
|
||||
**/
|
||||
export class GongNengCfg
|
||||
{
|
||||
|
||||
public constructor() { }
|
||||
|
||||
|
||||
/**
|
||||
* 功能标识
|
||||
*/
|
||||
public id: number;
|
||||
|
||||
|
||||
/**
|
||||
* 是否关闭此功能(不开放)
|
||||
*/
|
||||
public close: number;
|
||||
|
||||
|
||||
/**
|
||||
* 帮助说明
|
||||
*/
|
||||
public des: string;
|
||||
|
||||
|
||||
/**
|
||||
* 执行类型
|
||||
*/
|
||||
public type: number;
|
||||
|
||||
|
||||
/**
|
||||
* 容器ID
|
||||
*/
|
||||
public containerID: number;
|
||||
|
||||
|
||||
|
||||
/////////////////////
|
||||
|
||||
/*-*begin $area2 !这里填写类里面的手写内容!*-*/
|
||||
|
||||
/*-*end $area2*-*/
|
||||
|
||||
public decode(data:any[]){
|
||||
|
||||
let i = 0;
|
||||
|
||||
|
||||
this.id = data[i++];
|
||||
this.close = data[i++];
|
||||
this.des = data[i++];
|
||||
this.type = data[i++];
|
||||
this.containerID = data[i++];
|
||||
|
||||
/*-*begin $decode !这里填写方法中的手写内容!*-*/
|
||||
|
||||
/*-*end $decode*-*/
|
||||
}
|
||||
}
|
||||
|
||||
/*-*begin $area3 !这里填写类下发的手写内容!*-*/
|
||||
|
||||
/*-*end $area3*-*/
|
||||
}
|
||||
module giant {
|
||||
export interface CfgName {
|
||||
GongNeng: { [index: number]: chuanqi.GongNengCfg };
|
||||
}
|
||||
}
|
128
testsample/csrc/chuanqi/module/test/cfg/CeShiBiaoCfg.ts
Normal file
128
testsample/csrc/chuanqi/module/test/cfg/CeShiBiaoCfg.ts
Normal file
@ -0,0 +1,128 @@
|
||||
|
||||
module giant.chuanqi
|
||||
{
|
||||
/*-*begin $area1 !这里填写类上方的手写内容!*-*/
|
||||
//这里填写类上方的手写内容
|
||||
/*-*end $area1*-*/
|
||||
/**
|
||||
* 来自:D:\workspace\cqh5\cehua\trunk\数值\0.测试数据\CeShiBiao.xlsx
|
||||
**/
|
||||
export class CeShiBiaoCfg
|
||||
{
|
||||
|
||||
public constructor() { }
|
||||
|
||||
|
||||
/**
|
||||
* 测试数据标识
|
||||
*/
|
||||
public id: number;
|
||||
|
||||
|
||||
/**
|
||||
* 需求等级
|
||||
*/
|
||||
public level: number;
|
||||
|
||||
|
||||
/**
|
||||
* 奖励物品
|
||||
*/
|
||||
public items: any[][];
|
||||
|
||||
|
||||
/**
|
||||
* 奖励金钱
|
||||
*/
|
||||
public money: any;
|
||||
|
||||
|
||||
/**
|
||||
* 奖励宝石
|
||||
*/
|
||||
public gold: number;
|
||||
|
||||
|
||||
/**
|
||||
* 展示道具
|
||||
*/
|
||||
public showitems: any[];
|
||||
|
||||
|
||||
/**
|
||||
* 是否可pk
|
||||
*/
|
||||
public pk: boolean;
|
||||
|
||||
|
||||
/**
|
||||
* vip特殊奖励
|
||||
*/
|
||||
public vipitem: string;
|
||||
|
||||
|
||||
/**
|
||||
* 测试日期
|
||||
*/
|
||||
public date: Date;
|
||||
|
||||
|
||||
/**
|
||||
* 测试时间
|
||||
*/
|
||||
public datetime: Date;
|
||||
|
||||
|
||||
/**
|
||||
* 测试时间
|
||||
*/
|
||||
public time: TimeVO;
|
||||
|
||||
|
||||
/**
|
||||
* 新增
|
||||
*/
|
||||
public xinzeng: number;
|
||||
|
||||
|
||||
|
||||
/////////////////////
|
||||
|
||||
/*-*begin $area2 !这里填写类里面的手写内容!*-*/
|
||||
//这里填写类里面的手写内容
|
||||
private thisIsTemp: number = 1;
|
||||
/*-*end $area2*-*/
|
||||
|
||||
public decode(data:any[]){
|
||||
|
||||
let i = 0;
|
||||
|
||||
|
||||
this.id = data[i++];
|
||||
this.level = data[i++];
|
||||
this.items = data[i++];
|
||||
this.money = data[i++];
|
||||
this.gold = data[i++];
|
||||
this.showitems = data[i++];
|
||||
this.pk = !!data[i++];
|
||||
this.vipitem = data[i++];
|
||||
this.date = new Date(data[i++]*1000);
|
||||
this.datetime = new Date(data[i++]*1000);
|
||||
this.time = new TimeVO(data[i++]);
|
||||
this.xinzeng = data[i++];
|
||||
|
||||
/*-*begin $decode !这里填写方法中的手写内容!*-*/
|
||||
//这里填写方法中的手写内容
|
||||
/*-*end $decode*-*/
|
||||
}
|
||||
}
|
||||
|
||||
/*-*begin $area3 !这里填写类下发的手写内容!*-*/
|
||||
//这里填写类下发的手写内容
|
||||
/*-*end $area3*-*/
|
||||
}
|
||||
module giant {
|
||||
export interface CfgName {
|
||||
CeShiBiao: { [index: number]: chuanqi.CeShiBiaoCfg };
|
||||
}
|
||||
}
|
103
testsample/csrc/huaqiangu/test/CeShiBiaoCfg.ts
Normal file
103
testsample/csrc/huaqiangu/test/CeShiBiaoCfg.ts
Normal file
@ -0,0 +1,103 @@
|
||||
|
||||
module giant.chuanqi
|
||||
{
|
||||
/*-*begin $area1*-*/
|
||||
//这里填写类上方的手写内容
|
||||
/*-*end $area1*-*/
|
||||
/**
|
||||
* 数据由工具自动生成,源文件地址:D:\workspace\bitbucket\coderesource\tools\code\DataTools\testsample\0.测试数据\CeShiBiao.xlsx
|
||||
* 创建时间:2018-04-27 18:44:24
|
||||
**/
|
||||
export class CeShiBiaoCfg
|
||||
{
|
||||
|
||||
public constructor()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 测试数据标识
|
||||
*/
|
||||
public id: number;
|
||||
|
||||
|
||||
/**
|
||||
* 需求等级
|
||||
*/
|
||||
public level: number;
|
||||
|
||||
|
||||
/**
|
||||
* 展示道具
|
||||
*/
|
||||
public showitems: any[];
|
||||
|
||||
|
||||
/**
|
||||
* 是否可pk
|
||||
*/
|
||||
public pk: boolean;
|
||||
|
||||
|
||||
/**
|
||||
* vip特殊奖励
|
||||
*/
|
||||
public vipitem: string;
|
||||
|
||||
|
||||
/**
|
||||
* 测试日期
|
||||
*/
|
||||
public date: Date;
|
||||
|
||||
|
||||
/**
|
||||
* 测试时间
|
||||
*/
|
||||
public datetime: Date;
|
||||
|
||||
|
||||
/**
|
||||
* 测试时间
|
||||
*/
|
||||
public time: TimeVO;
|
||||
|
||||
|
||||
|
||||
/////////////////////
|
||||
|
||||
/*-*begin $area2*-*/
|
||||
//这里填写类里面的手写内容
|
||||
/*-*end $area2*-*/
|
||||
|
||||
public decode(data:any[]){
|
||||
|
||||
let i = 0;
|
||||
|
||||
|
||||
this.id = data[i++];
|
||||
this.level = data[i++];
|
||||
this.showitems = data[i++];
|
||||
this.pk = !!data[i++];
|
||||
this.vipitem = data[i++];
|
||||
this.date = new Date(data[i++]*1000);
|
||||
this.datetime = new Date(data[i++]*1000);
|
||||
this.time = new TimeVO(data[i++]);
|
||||
|
||||
/*-*begin $decode*-*/
|
||||
//这里填写方法中的手写内容
|
||||
/*-*end $decode*-*/
|
||||
}
|
||||
}
|
||||
|
||||
/*-*begin $area3*-*/
|
||||
//这里填写类下发的手写内容
|
||||
/*-*end $area3*-*/
|
||||
}
|
||||
module giant {
|
||||
export interface CfgName {
|
||||
CeShiBiao: { [index: number]: chuanqi.CeShiBiaoCfg };
|
||||
}
|
||||
}
|
1
testsample/data/client/basic.json
Normal file
1
testsample/data/client/basic.json
Normal file
@ -0,0 +1 @@
|
||||
{}
|
1
testsample/data/client/cfgs.json
Normal file
1
testsample/data/client/cfgs.json
Normal file
@ -0,0 +1 @@
|
||||
{"CeShiBiao":[[123,12,[[1001,12],[1213,1]],12,12.1,[1001,1213],1,"s001",1482451200,1482506280,"23:18",1],[124,12,[[1001,12],[1213,2]],12,12.2,[1001,1214],1,"s002",1482537600,1482506340,"23:19",2],[125,12,[[1001,12],[1213,3]],12,12.3,[1001,1215],1,"s003",1482624000,1482506400,"23:20",3],[126,12,[[1001,12],[1213,4]],12,12.4,[1001,1216],1,"s004",1482710400,1482506460,"23:21",4],[127,12,[[1001,12],[1213,5]],12,12.5,[1001,1217],1,"s005",1482796800,1482506520,"23:22",5],[128,12,[[1001,12],[1213,6]],12,12.6,[1001,1218],1,"s006",1482883200,1482506580,"23:23",6],[129,12,[[1001,12],[1213,7]],12,12.7,[1001,1219],1,"s007",1482969600,1482506640,"23:24",7],[130,12,[[1001,12],[1213,8]],12,12.8,[1001,1220],1,"s008",1483056000,1482506700,"23:25",8],[131,12,[[1001,12],[1213,9]],12,12.9,[1001,1221],1,"s009",1483142400,1482506760,"23:26",9],[132,12,[[1001,12],[1213,10]],12,12.1,[1001,1222],1,"s010",1483142400,1482506820,"23:27",10]]}
|
1
testsample/data/client/raw/CeShiBiao.json
Normal file
1
testsample/data/client/raw/CeShiBiao.json
Normal file
@ -0,0 +1 @@
|
||||
[[123,12,[[1001,12],[1213,1]],12,12.1,[1001,1213],1,"s001",1482451200,1482506280,"23:18",1],[124,12,[[1001,12],[1213,2]],12,12.2,[1001,1214],1,"s002",1482537600,1482506340,"23:19",2],[125,12,[[1001,12],[1213,3]],12,12.3,[1001,1215],1,"s003",1482624000,1482506400,"23:20",3],[126,12,[[1001,12],[1213,4]],12,12.4,[1001,1216],1,"s004",1482710400,1482506460,"23:21",4],[127,12,[[1001,12],[1213,5]],12,12.5,[1001,1217],1,"s005",1482796800,1482506520,"23:22",5],[128,12,[[1001,12],[1213,6]],12,12.6,[1001,1218],1,"s006",1482883200,1482506580,"23:23",6],[129,12,[[1001,12],[1213,7]],12,12.7,[1001,1219],1,"s007",1482969600,1482506640,"23:24",7],[130,12,[[1001,12],[1213,8]],12,12.8,[1001,1220],1,"s008",1483056000,1482506700,"23:25",8],[131,12,[[1001,12],[1213,9]],12,12.9,[1001,1221],1,"s009",1483142400,1482506760,"23:26",9],[132,12,[[1001,12],[1213,10]],12,12.1,[1001,1222],1,"s010",1483142400,1482506820,"23:27",10]]
|
1
testsample/data/client/running.json
Normal file
1
testsample/data/client/running.json
Normal file
@ -0,0 +1 @@
|
||||
{}
|
1
testsample/data/server/CeShiBiao.json
Normal file
1
testsample/data/server/CeShiBiao.json
Normal file
@ -0,0 +1 @@
|
||||
[{"id":123,"level":12,"items":[[1001,12],[1213,1]],"money":12,"gold":12.1,"showitems":[1001,1213],"pk":1,"vipitem":"s001","date":148245120,"datetime":148253508,"time":"23:18","xinzeng":1},{"id":124,"level":12,"items":[[1001,12],[1213,2]],"money":12,"gold":12.2,"showitems":[1001,1214],"pk":1,"vipitem":"s002","date":148253760,"datetime":148253514,"time":"23:19","xinzeng":2},{"id":125,"level":12,"items":[[1001,12],[1213,3]],"money":12,"gold":12.3,"showitems":[1001,1215],"pk":1,"vipitem":"s003","date":148262400,"datetime":148253520,"time":"23:20","xinzeng":3},{"id":126,"level":12,"items":[[1001,12],[1213,4]],"money":12,"gold":12.4,"showitems":[1001,1216],"pk":1,"vipitem":"s004","date":148271040,"datetime":148253526,"time":"23:21","xinzeng":4},{"id":127,"level":12,"items":[[1001,12],[1213,5]],"money":12,"gold":12.5,"showitems":[1001,1217],"pk":1,"vipitem":"s005","date":148279680,"datetime":148253532,"time":"23:22","xinzeng":5},{"id":128,"level":12,"items":[[1001,12],[1213,6]],"money":12,"gold":12.6,"showitems":[1001,1218],"pk":1,"vipitem":"s006","date":148288320,"datetime":148253538,"time":"23:23","xinzeng":6},{"id":129,"level":12,"items":[[1001,12],[1213,7]],"money":12,"gold":12.7,"showitems":[1001,1219],"pk":1,"vipitem":"s007","date":148296960,"datetime":148253544,"time":"23:24","xinzeng":7},{"id":130,"level":12,"items":[[1001,12],[1213,8]],"money":12,"gold":12.8,"showitems":[1001,1220],"pk":1,"vipitem":"s008","date":148305600,"datetime":148253550,"time":"23:25","xinzeng":8},{"id":131,"level":12,"items":[[1001,12],[1213,9]],"money":12,"gold":12.9,"showitems":[1001,1221],"pk":1,"vipitem":"s009","date":148314240,"datetime":148253556,"time":"23:26","xinzeng":9},{"id":132,"level":12,"items":[[1001,12],[1213,10]],"money":12,"gold":12.1,"showitems":[1001,1222],"pk":1,"vipitem":"s010","date":148314240,"datetime":148253562,"time":"23:27","xinzeng":10}]
|
4
testsample/globalConfig.json
Normal file
4
testsample/globalConfig.json
Normal file
@ -0,0 +1,4 @@
|
||||
{
|
||||
"project":"chuanqi",
|
||||
"clientPath":"D:/workspace/bitbucket/coderesource/tools/code/DataTools/testsample/out/client"
|
||||
}
|
1
testsample/out/client/CeShiBiao.json
Normal file
1
testsample/out/client/CeShiBiao.json
Normal file
@ -0,0 +1 @@
|
||||
[[123,12,[[1001,12],[1213,1]],12,12.1,[1001,1213],1,"s001",148245120,148253508,"23:18",1],[124,12,[[1001,12],[1213,2]],12,12.2,[1001,1214],1,"s002",148253760,148253514,"23:19",2],[125,12,[[1001,12],[1213,3]],12,12.3,[1001,1215],1,"s003",148262400,148253520,"23:20",3],[126,12,[[1001,12],[1213,4]],12,12.4,[1001,1216],1,"s004",148271040,148253526,"23:21",4],[127,12,[[1001,12],[1213,5]],12,12.5,[1001,1217],1,"s005",148279680,148253532,"23:22",5],[128,12,[[1001,12],[1213,6]],12,12.6,[1001,1218],1,"s006",148288320,148253538,"23:23",6],[129,12,[[1001,12],[1213,7]],12,12.7,[1001,1219],1,"s007",148296960,148253544,"23:24",7],[130,12,[[1001,12],[1213,8]],12,12.8,[1001,1220],1,"s008",148305600,148253550,"23:25",8],[131,12,[[1001,12],[1213,9]],12,12.9,[1001,1221],1,"s009",148314240,148253556,"23:26",9],[132,12,[[1001,12],[1213,10]],12,12.1,[1001,1222],1,"s010",148314240,148253562,"23:27",10]]
|
1
testsample/out/client/CeShiBiao1.json
Normal file
1
testsample/out/client/CeShiBiao1.json
Normal file
@ -0,0 +1 @@
|
||||
[[123,12,[1001,1213],1,"s001",148245120,148253508,"23:18"],[124,12,[1001,1214],1,"s002",148253760,148253514,"23:19"],[125,12,[1001,1215],1,"s003",148262400,148253520,"23:20"],[126,12,[1001,1216],1,"s004",148271040,148253526,"23:21"],[127,12,[1001,1217],1,"s005",148279680,148253532,"23:22"],[128,12,[1001,1218],1,"s006",148288320,148253538,"23:23"],[129,12,[1001,1219],1,"s007",148296960,148253544,"23:24"],[130,12,[1001,1220],1,"s008",148305600,148253550,"23:25"],[131,12,[1001,1221],1,"s009",148314240,148253556,"23:26"],[132,12,[1001,1222],1,"s010",148253562,"23:27"]]
|
1
testsample/out/client/CeShiBiao2.json
Normal file
1
testsample/out/client/CeShiBiao2.json
Normal file
@ -0,0 +1 @@
|
||||
[[123,12,[1001,1213],1,"s001",148245120,148253508,"23:18"],[124,12,[1001,1214],1,"s002",148253760,148253514,"23:19"],[125,12,[1001,1215],1,"s003",148262400,148253520,"23:20"],[126,12,[1001,1216],1,"s004",148271040,148253526,"23:21"],[127,12,[1001,1217],1,"s005",148279680,148253532,"23:22"],[128,12,[1001,1218],1,"s006",148288320,148253538,"23:23"],[129,12,[1001,1219],1,"s007",148296960,148253544,"23:24"],[130,12,[1001,1220],1,"s008",148305600,148253550,"23:25"],[131,12,[1001,1221],1,"s009",148314240,148253556,"23:26"],[132,12,[1001,1222],1,"s010",148253562,"23:27"]]
|
1
testsample/out/server/CeShiBiao.json
Normal file
1
testsample/out/server/CeShiBiao.json
Normal file
@ -0,0 +1 @@
|
||||
[{"id":123,"level":12,"items":[[1001,12],[1213,1]],"money":12,"gold":12.1,"showitems":[1001,1213],"pk":1,"vipitem":"s001","date":148245120,"datetime":148253508,"time":"23:18","xinzeng":1},{"id":124,"level":12,"items":[[1001,12],[1213,2]],"money":12,"gold":12.2,"showitems":[1001,1214],"pk":1,"vipitem":"s002","date":148253760,"datetime":148253514,"time":"23:19","xinzeng":2},{"id":125,"level":12,"items":[[1001,12],[1213,3]],"money":12,"gold":12.3,"showitems":[1001,1215],"pk":1,"vipitem":"s003","date":148262400,"datetime":148253520,"time":"23:20","xinzeng":3},{"id":126,"level":12,"items":[[1001,12],[1213,4]],"money":12,"gold":12.4,"showitems":[1001,1216],"pk":1,"vipitem":"s004","date":148271040,"datetime":148253526,"time":"23:21","xinzeng":4},{"id":127,"level":12,"items":[[1001,12],[1213,5]],"money":12,"gold":12.5,"showitems":[1001,1217],"pk":1,"vipitem":"s005","date":148279680,"datetime":148253532,"time":"23:22","xinzeng":5},{"id":128,"level":12,"items":[[1001,12],[1213,6]],"money":12,"gold":12.6,"showitems":[1001,1218],"pk":1,"vipitem":"s006","date":148288320,"datetime":148253538,"time":"23:23","xinzeng":6},{"id":129,"level":12,"items":[[1001,12],[1213,7]],"money":12,"gold":12.7,"showitems":[1001,1219],"pk":1,"vipitem":"s007","date":148296960,"datetime":148253544,"time":"23:24","xinzeng":7},{"id":130,"level":12,"items":[[1001,12],[1213,8]],"money":12,"gold":12.8,"showitems":[1001,1220],"pk":1,"vipitem":"s008","date":148305600,"datetime":148253550,"time":"23:25","xinzeng":8},{"id":131,"level":12,"items":[[1001,12],[1213,9]],"money":12,"gold":12.9,"showitems":[1001,1221],"pk":1,"vipitem":"s009","date":148314240,"datetime":148253556,"time":"23:26","xinzeng":9},{"id":132,"level":12,"items":[[1001,12],[1213,10]],"money":12,"gold":12.1,"showitems":[1001,1222],"pk":1,"vipitem":"s010","date":148314240,"datetime":148253562,"time":"23:27","xinzeng":10}]
|
15
testsample/out/server/CeShiBiao.xml
Normal file
15
testsample/out/server/CeShiBiao.xml
Normal file
@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<root>
|
||||
<CeShiBiao>
|
||||
<entry id="123" level="12" items="1001,12,1213,1" money="12" gold="12" showitems="1001,1213" pk="1" vipitem="s001" date="148245120" datetime="148253508" time="23:18" />
|
||||
<entry id="124" level="12" items="1001,12,1213,2" money="12" gold="12" showitems="1001,1214" pk="1" vipitem="s002" date="148253760" datetime="148253514" time="23:19" />
|
||||
<entry id="125" level="12" items="1001,12,1213,3" money="12" gold="12" showitems="1001,1215" pk="1" vipitem="s003" date="148262400" datetime="148253520" time="23:20" />
|
||||
<entry id="126" level="12" items="1001,12,1213,4" money="12" gold="12" showitems="1001,1216" pk="1" vipitem="s004" date="148271040" datetime="148253526" time="23:21" />
|
||||
<entry id="127" level="12" items="1001,12,1213,5" money="12" gold="12" showitems="1001,1217" pk="1" vipitem="s005" date="148279680" datetime="148253532" time="23:22" />
|
||||
<entry id="128" level="12" items="1001,12,1213,6" money="12" gold="12" showitems="1001,1218" pk="1" vipitem="s006" date="148288320" datetime="148253538" time="23:23" />
|
||||
<entry id="129" level="12" items="1001,12,1213,7" money="12" gold="12" showitems="1001,1219" pk="1" vipitem="s007" date="148296960" datetime="148253544" time="23:24" />
|
||||
<entry id="130" level="12" items="1001,12,1213,8" money="12" gold="12" showitems="1001,1220" pk="1" vipitem="s008" date="148305600" datetime="148253550" time="23:25" />
|
||||
<entry id="131" level="12" items="1001,12,1213,9" money="12" gold="12" showitems="1001,1221" pk="1" vipitem="s009" date="148314240" datetime="148253556" time="23:26" />
|
||||
<entry id="132" level="12" items="1001,12,1213,10" money="12" gold="12" showitems="1001,1222" pk="1" vipitem="s010" date="148314240" datetime="148253562" time="23:27" />
|
||||
</CeShiBiao>
|
||||
</root>
|
1
testsample/out/server/CeShiBiao1.json
Normal file
1
testsample/out/server/CeShiBiao1.json
Normal file
@ -0,0 +1 @@
|
||||
[[123,12,[[1001,12],[1213,1]],12,1,"s001",148245120,148253508,"23:18"],[124,12,[[1001,12],[1213,2]],12,1,"s002",148253760,148253514,"23:19"],[125,12,[[1001,12],[1213,3]],12,1,"s003",148262400,148253520,"23:20"],[126,12,[[1001,12],[1213,4]],12,1,"s004",148271040,148253526,"23:21"],[127,12,[[1001,12],[1213,5]],12,1,"s005",148279680,148253532,"23:22"],[128,12,[[1001,12],[1213,6]],12,1,"s006",148288320,148253538,"23:23"],[129,12,[[1001,12],[1213,7]],12,1,"s007",148296960,148253544,"23:24"],[130,12,[[1001,12],[1213,8]],12,1,"s008",148305600,148253550,"23:25"],[131,12,[[1001,12],[1213,9]],12,1,"s009",148314240,148253556,"23:26"],[132,12,[[1001,12],[1213,10]],12,1,"s010",148253562,"23:27"]]
|
3
testsample/out/server/CeShiBiao1.xml
Normal file
3
testsample/out/server/CeShiBiao1.xml
Normal file
@ -0,0 +1,3 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<root>
|
||||
</root>
|
1
testsample/out/server/CeShiBiao2.json
Normal file
1
testsample/out/server/CeShiBiao2.json
Normal file
@ -0,0 +1 @@
|
||||
[[123,12,[[1001,12],[1213,1]],12,1,"s001",148245120,148253508,"23:18"],[124,12,[[1001,12],[1213,2]],12,1,"s002",148253760,148253514,"23:19"],[125,12,[[1001,12],[1213,3]],12,1,"s003",148262400,148253520,"23:20"],[126,12,[[1001,12],[1213,4]],12,1,"s004",148271040,148253526,"23:21"],[127,12,[[1001,12],[1213,5]],12,1,"s005",148279680,148253532,"23:22"],[128,12,[[1001,12],[1213,6]],12,1,"s006",148288320,148253538,"23:23"],[129,12,[[1001,12],[1213,7]],12,1,"s007",148296960,148253544,"23:24"],[130,12,[[1001,12],[1213,8]],12,1,"s008",148305600,148253550,"23:25"],[131,12,[[1001,12],[1213,9]],12,1,"s009",148314240,148253556,"23:26"],[132,12,[[1001,12],[1213,10]],12,1,"s010",148253562,"23:27"]]
|
112
testsample/ssrc/huaqiangu/test/CeShiBiaoTemplate.java
Normal file
112
testsample/ssrc/huaqiangu/test/CeShiBiaoTemplate.java
Normal file
@ -0,0 +1,112 @@
|
||||
|
||||
package com.game.resources.template.gen.huaqiangu.test;
|
||||
|
||||
import com.game.resources.annotation.Attribute;
|
||||
import com.game.resources.annotation.Template;
|
||||
|
||||
@Template( res = "CeShiBiao.json")
|
||||
public abstract class CeShiBiaoTemplate {
|
||||
|
||||
|
||||
@Attribute("id")
|
||||
private int id;
|
||||
|
||||
/**
|
||||
* 测试数据标识
|
||||
*/
|
||||
public int getId(){
|
||||
return id;
|
||||
}
|
||||
|
||||
@Attribute("level")
|
||||
private int level;
|
||||
|
||||
/**
|
||||
* 需求等级
|
||||
*/
|
||||
public int getLevel(){
|
||||
return level;
|
||||
}
|
||||
|
||||
@Attribute("items")
|
||||
private String items;
|
||||
|
||||
/**
|
||||
* 奖励物品
|
||||
*/
|
||||
public String getItems(){
|
||||
return items;
|
||||
}
|
||||
|
||||
@Attribute("money")
|
||||
private int money;
|
||||
|
||||
/**
|
||||
* 奖励金钱
|
||||
*/
|
||||
public int getMoney(){
|
||||
return money;
|
||||
}
|
||||
|
||||
@Attribute("gold")
|
||||
private int gold;
|
||||
|
||||
/**
|
||||
* 奖励宝石
|
||||
*/
|
||||
public int getGold(){
|
||||
return gold;
|
||||
}
|
||||
|
||||
@Attribute("pk")
|
||||
private boolean pk;
|
||||
|
||||
/**
|
||||
* 是否可pk
|
||||
*/
|
||||
public boolean getPk(){
|
||||
return pk;
|
||||
}
|
||||
|
||||
@Attribute("vipitem")
|
||||
private String vipitem;
|
||||
|
||||
/**
|
||||
* vip特殊奖励
|
||||
*/
|
||||
public String getVipitem(){
|
||||
return vipitem;
|
||||
}
|
||||
|
||||
@Attribute("date")
|
||||
private String date;
|
||||
|
||||
/**
|
||||
* 测试日期
|
||||
*/
|
||||
public String getDate(){
|
||||
return date;
|
||||
}
|
||||
|
||||
@Attribute("datetime")
|
||||
private String datetime;
|
||||
|
||||
/**
|
||||
* 测试时间
|
||||
*/
|
||||
public String getDatetime(){
|
||||
return datetime;
|
||||
}
|
||||
|
||||
@Attribute("time")
|
||||
private String time;
|
||||
|
||||
/**
|
||||
* 测试时间
|
||||
*/
|
||||
public String getTime(){
|
||||
return time;
|
||||
}
|
||||
|
||||
|
||||
}
|
132
testsample/ssrc/test/CeShiBiaoTemplate.java
Normal file
132
testsample/ssrc/test/CeShiBiaoTemplate.java
Normal file
@ -0,0 +1,132 @@
|
||||
|
||||
package com.game.resources.template.gen.test;
|
||||
|
||||
import com.game.resources.annotation.Attribute;
|
||||
import com.game.resources.annotation.Template;
|
||||
|
||||
@Template( res = "CeShiBiao.json")
|
||||
public abstract class CeShiBiaoTemplate {
|
||||
|
||||
|
||||
@Attribute("id")
|
||||
private int id;
|
||||
|
||||
/**
|
||||
* 测试数据标识
|
||||
*/
|
||||
public int getId(){
|
||||
return id;
|
||||
}
|
||||
|
||||
@Attribute("level")
|
||||
private int level;
|
||||
|
||||
/**
|
||||
* 需求等级
|
||||
*/
|
||||
public int getLevel(){
|
||||
return level;
|
||||
}
|
||||
|
||||
@Attribute("items")
|
||||
private String items;
|
||||
|
||||
/**
|
||||
* 奖励物品
|
||||
*/
|
||||
public String getItems(){
|
||||
return items;
|
||||
}
|
||||
|
||||
@Attribute("money")
|
||||
private String money;
|
||||
|
||||
/**
|
||||
* 奖励金钱
|
||||
*/
|
||||
public String getMoney(){
|
||||
return money;
|
||||
}
|
||||
|
||||
@Attribute("gold")
|
||||
private float gold;
|
||||
|
||||
/**
|
||||
* 奖励宝石
|
||||
*/
|
||||
public float getGold(){
|
||||
return gold;
|
||||
}
|
||||
|
||||
@Attribute("showitems")
|
||||
private String showitems;
|
||||
|
||||
/**
|
||||
* 展示道具
|
||||
*/
|
||||
public String getShowitems(){
|
||||
return showitems;
|
||||
}
|
||||
|
||||
@Attribute("pk")
|
||||
private boolean pk;
|
||||
|
||||
/**
|
||||
* 是否可pk
|
||||
*/
|
||||
public boolean getPk(){
|
||||
return pk;
|
||||
}
|
||||
|
||||
@Attribute("vipitem")
|
||||
private String vipitem;
|
||||
|
||||
/**
|
||||
* vip特殊奖励
|
||||
*/
|
||||
public String getVipitem(){
|
||||
return vipitem;
|
||||
}
|
||||
|
||||
@Attribute("date")
|
||||
private String date;
|
||||
|
||||
/**
|
||||
* 测试日期
|
||||
*/
|
||||
public String getDate(){
|
||||
return date;
|
||||
}
|
||||
|
||||
@Attribute("datetime")
|
||||
private String datetime;
|
||||
|
||||
/**
|
||||
* 测试时间
|
||||
*/
|
||||
public String getDatetime(){
|
||||
return datetime;
|
||||
}
|
||||
|
||||
@Attribute("time")
|
||||
private String time;
|
||||
|
||||
/**
|
||||
* 测试时间
|
||||
*/
|
||||
public String getTime(){
|
||||
return time;
|
||||
}
|
||||
|
||||
@Attribute("xinzeng")
|
||||
private float xinzeng;
|
||||
|
||||
/**
|
||||
* 新增
|
||||
*/
|
||||
public float getXinzeng(){
|
||||
return xinzeng;
|
||||
}
|
||||
|
||||
|
||||
}
|
13
tsconfig.json
Normal file
13
tsconfig.json
Normal file
@ -0,0 +1,13 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "amd",
|
||||
"target": "es2015",
|
||||
"sourceMap": false,
|
||||
"rootDir": "src",
|
||||
"outDir": "dist"
|
||||
},
|
||||
"exclude": [
|
||||
"node_modules",
|
||||
"testsample"
|
||||
]
|
||||
}
|
10
typings/electron.d.ts
vendored
Normal file
10
typings/electron.d.ts
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
interface File{
|
||||
/**
|
||||
* Electron环境下文件的物理路径
|
||||
*/
|
||||
path : string;
|
||||
}
|
||||
|
||||
interface Window{
|
||||
nodeRequire:NodeRequire;
|
||||
}
|
2340
typings/node/node.d.ts
vendored
Normal file
2340
typings/node/node.d.ts
vendored
Normal file
File diff suppressed because it is too large
Load Diff
43
typings/tsd.d.ts
vendored
Normal file
43
typings/tsd.d.ts
vendored
Normal file
@ -0,0 +1,43 @@
|
||||
/// <reference path="xlsx/xlsx.d.ts" />
|
||||
/// <reference path="node/node.d.ts" />
|
||||
interface String {
|
||||
/**
|
||||
* 替换字符串中{0}{1}{2}{a} {b}这样的数据,用obj对应key替换,或者是数组中对应key的数据替换
|
||||
*/
|
||||
substitute(...args): string;
|
||||
}
|
||||
interface Date {
|
||||
/**
|
||||
* 格式化日期
|
||||
*/
|
||||
format(mask: string): string;
|
||||
}
|
||||
|
||||
declare function ready(hander: () => void);
|
||||
declare var nodeRequire: NodeRequire;
|
||||
|
||||
|
||||
interface cookiesUtils {
|
||||
/**
|
||||
* 设置cookie
|
||||
*
|
||||
* @param name
|
||||
* @param value
|
||||
*/
|
||||
setCookie(name: string, value: string);
|
||||
/**
|
||||
* 获取cookie
|
||||
*
|
||||
* @param name
|
||||
* @returns
|
||||
*/
|
||||
getCookie(name: string);
|
||||
/**
|
||||
* 删除cookie
|
||||
*
|
||||
* @param name
|
||||
*/
|
||||
delCookie(name: string);
|
||||
}
|
||||
|
||||
declare var cookie: cookiesUtils;
|
148
typings/xlsx/xlsx.d.ts
vendored
Normal file
148
typings/xlsx/xlsx.d.ts
vendored
Normal file
@ -0,0 +1,148 @@
|
||||
// Type definitions for xlsx
|
||||
// Project: https://github.com/SheetJS/js-xlsx
|
||||
// Definitions by: themauveavenger <https://github.com/themauveavenger/>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare module 'xlsx' {
|
||||
|
||||
export function readFile(filename:string, opts?:IParsingOptions):IWorkBook;
|
||||
export function read(data:any, opts?:IParsingOptions):IWorkBook;
|
||||
export var utils:IUtils;
|
||||
|
||||
export interface IProperties {
|
||||
LastAuthor?:string
|
||||
Author?:string;
|
||||
CreatedDate?:Date;
|
||||
ModifiedDate?:Date
|
||||
Application?:string;
|
||||
AppVersion?:string;
|
||||
Company?:string;
|
||||
DocSecurity?:string;
|
||||
Manager?:string;
|
||||
HyperlinksChanged?: boolean;
|
||||
SharedDoc?:boolean;
|
||||
LinksUpToDate?:boolean;
|
||||
ScaleCrop?:boolean;
|
||||
Worksheets?:number;
|
||||
SheetNames?:string[];
|
||||
}
|
||||
|
||||
export interface IParsingOptions {
|
||||
cellFormula?:boolean;
|
||||
cellHTML?:boolean;
|
||||
cellNF?:boolean;
|
||||
cellStyles?:boolean;
|
||||
cellDates?:boolean;
|
||||
sheetStubs?:boolean;
|
||||
sheetRows?:number;
|
||||
bookDeps?:boolean;
|
||||
bookFiles?:boolean;
|
||||
bookProps?:boolean;
|
||||
bookSheets?:boolean;
|
||||
bookVBA?:boolean;
|
||||
password?:string;
|
||||
|
||||
/**
|
||||
* Possible options: 'binary', 'base64', 'buffer', 'file'
|
||||
*/
|
||||
type?:string;
|
||||
}
|
||||
|
||||
export interface IWorkBook {
|
||||
/**
|
||||
* A dictionary of the worksheets in the workbook.
|
||||
* Use SheetNames to reference these.
|
||||
*/
|
||||
Sheets:{[sheet:string]:IWorkSheet};
|
||||
|
||||
/**
|
||||
* ordered list of the sheet names in the workbook
|
||||
*/
|
||||
SheetNames:string[];
|
||||
|
||||
/**
|
||||
* an object storing the standard properties. wb.Custprops stores custom properties.
|
||||
* Since the XLS standard properties deviate from the XLSX standard, XLS parsing stores core properties in both places.
|
||||
*/
|
||||
Props:IProperties;
|
||||
}
|
||||
|
||||
/**
|
||||
* object representing the worksheet
|
||||
*/
|
||||
export interface IWorkSheet {
|
||||
[cell:string]:IWorkSheetCell;
|
||||
}
|
||||
|
||||
export interface IWorkSheetCell {
|
||||
/**
|
||||
* The Excel Data Type of the cell.
|
||||
* b Boolean, n Number, e error, s String, d Date
|
||||
*/
|
||||
t: string;
|
||||
|
||||
/**
|
||||
* The raw value of the cell.
|
||||
*/
|
||||
v: string;
|
||||
|
||||
/**
|
||||
* rich text encoding (if applicable)
|
||||
*/
|
||||
r?: string;
|
||||
|
||||
/**
|
||||
* HTML rendering of the rich text (if applicable)
|
||||
*/
|
||||
h?: string;
|
||||
|
||||
/**
|
||||
* formatted text (if applicable)
|
||||
*/
|
||||
w?: string;
|
||||
|
||||
/**
|
||||
* cell formula (if applicable)
|
||||
*/
|
||||
f?: string;
|
||||
|
||||
/**
|
||||
* comments associated with the cell **
|
||||
*/
|
||||
c?: string;
|
||||
|
||||
/**
|
||||
* number format string associated with the cell (if requested)
|
||||
*/
|
||||
z?: string;
|
||||
|
||||
/**
|
||||
* cell hyperlink object (.Target holds link, .tooltip is tooltip)
|
||||
*/
|
||||
l?: string;
|
||||
|
||||
/**
|
||||
* the style/theme of the cell (if applicable)
|
||||
*/
|
||||
s?: string;
|
||||
}
|
||||
|
||||
|
||||
export interface IUtils {
|
||||
sheet_to_json<T>(worksheet:IWorkSheet,opts?:{
|
||||
raw?:boolean;
|
||||
range?:string|number|{e:{c:number,r:number},s:{c:number,r:number}};
|
||||
header?:string[]|"A"|number;
|
||||
}):T[];
|
||||
sheet_to_csv(worksheet:IWorkSheet):any;
|
||||
sheet_to_formulae(worksheet:IWorkSheet):any;
|
||||
/**
|
||||
*
|
||||
* 将列号处理为Excel的A B C D....Z AA AB...的形式
|
||||
* @param {number} col
|
||||
* @returns {string}
|
||||
*/
|
||||
encode_col(col:number):string;
|
||||
}
|
||||
|
||||
}
|
64
web.js
Normal file
64
web.js
Normal file
@ -0,0 +1,64 @@
|
||||
var PORT = 12345;
|
||||
|
||||
var http = require('http');
|
||||
var url = require('url');
|
||||
var fs = require('fs');
|
||||
var path = require('path');
|
||||
const mime = {
|
||||
"css": "text/css",
|
||||
"gif": "image/gif",
|
||||
"html": "text/html",
|
||||
"ico": "image/x-icon",
|
||||
"jpeg": "image/jpeg",
|
||||
"jpg": "image/jpeg",
|
||||
"js": "text/javascript",
|
||||
"json": "application/json",
|
||||
"pdf": "application/pdf",
|
||||
"png": "image/png",
|
||||
"svg": "image/svg+xml",
|
||||
"swf": "application/x-shockwave-flash",
|
||||
"tiff": "image/tiff",
|
||||
"txt": "text/plain",
|
||||
"wav": "audio/x-wav",
|
||||
"wma": "audio/x-ms-wma",
|
||||
"wmv": "video/x-ms-wmv",
|
||||
"xml": "text/xml"
|
||||
};
|
||||
|
||||
var server = http.createServer(function (request, response) {
|
||||
var realPath = url.parse(request.url).pathname.trim();
|
||||
if (!realPath || realPath == "/") {
|
||||
realPath = "/index.html";
|
||||
}
|
||||
realPath = path.join(__dirname, "dist", realPath);
|
||||
console.log(realPath);
|
||||
var ext = path.extname(realPath);
|
||||
ext = ext ? ext.slice(1) : 'unknown';
|
||||
fs.exists(realPath, function (exists) {
|
||||
if (!exists) {
|
||||
response.writeHead(404, {
|
||||
'Content-Type': 'text/plain'
|
||||
});
|
||||
|
||||
response.write(`无法找到文件${realPath}`);
|
||||
response.end();
|
||||
} else {
|
||||
fs.readFile(realPath, "binary", function (err, file) {
|
||||
if (err) {
|
||||
response.writeHead(500, {
|
||||
'Content-Type': 'text/plain'
|
||||
});
|
||||
response.end(err);
|
||||
} else {
|
||||
var contentType = mime[ext] || "text/plain";
|
||||
response.writeHead(200, {
|
||||
'Content-Type': contentType
|
||||
});
|
||||
response.write(file, "binary");
|
||||
response.end();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
server.listen(PORT);
|
Loading…
x
Reference in New Issue
Block a user