Commit 7c725661 authored by yzddmr6's avatar yzddmr6

(Enhance: core)简化新类型Shell创建步骤

parent 961b9e62
......@@ -75,6 +75,11 @@ const antSword = window.antSword = {
* @type {Object}
*/
core: {},
/**
* 核心模块类型列表
* @type {Object}
*/
core_types: {},
/**
* 插件列表
* @type {Object}
......@@ -162,6 +167,9 @@ const antSword = window.antSword = {
}
};
//核心模块类型列表
antSword['core_types'] = ['asp', 'aspx', 'php','php4', 'jsp','jspjs' , 'custom'];
// 加载核心模板
antSword['core'] = require('./core/');
......@@ -170,28 +178,19 @@ antSword['language'] = require('./language/');
// 加载编码
antSword['encoders'] = (function () {
var encoders = {
asp: [],
aspx: [],
jsp: [],
jspjs: [],
php: [],
custom: []
};
var encoders_path = {
asp: [],
aspx: [],
jsp: [],
jspjs: [],
php: [],
custom: []
};
var encoders = {};
var encoders_path = {};
for (var i in antSword['core_types']) {
encoders[antSword['core_types'][i]] = [];
encoders_path[antSword['core_types'][i]] = [];
}
let userencoder_path = path.join(remote.process.env.AS_WORKDIR, 'antData/encoders');
// 初始化
!fs.existsSync(userencoder_path) ?
fs.mkdirSync(userencoder_path) :
null;
['asp', 'aspx', 'php', 'jsp', 'jspjs','custom'].map((t) => {
antSword['core_types'].map((t) => {
!fs.existsSync(path.join(userencoder_path, `${t}`)) ?
fs.mkdirSync(path.join(userencoder_path, `${t}`)) :
null;
......@@ -227,28 +226,19 @@ antSword['encoders'] = (function () {
// 加载解码器
antSword['decoders'] = (function () {
var decoders = {
asp: [],
aspx: [],
php: [],
jsp: [],
jspjs: [],
custom: []
};
var decoders_path = {
asp: [],
aspx: [],
php: [],
jsp: [],
jspjs: [],
custom: []
};
var decoders = {};
var decoders_path = {};
for (var i in antSword['core_types']) {
decoders[antSword['core_types'][i]] = [];
decoders_path[antSword['core_types'][i]] = [];
}
let userdecoder_path = path.join(remote.process.env.AS_WORKDIR, 'antData/encoders');
// 初始化
!fs.existsSync(userdecoder_path) ?
fs.mkdirSync(userdecoder_path) :
null;
['asp', 'aspx', 'php', 'jsp','jspjs', 'custom'].map((t) => {
antSword['core_types'].map((t) => {
!fs.existsSync(path.join(userdecoder_path, `${t}`)) ?
fs.mkdirSync(path.join(userdecoder_path, `${t}`)) :
null;
......
......@@ -5,7 +5,6 @@
* 作者:蚁逅 <https://github.com/antoor>
*/
'use strict';
class Core {
/**
* AntSword Core init
......@@ -14,7 +13,7 @@ class Core {
constructor() {
// 加载子模块列表
let cores = {};
['php', 'asp', 'aspx', 'jsp','jspjs', 'custom', 'php4'].map((_) => {
antSword['core_types'].map((_) => {
cores[_] = require(`./${_}/index`);
});
// 返回子模块对象
......
......@@ -207,12 +207,9 @@ class Encoders {
grid.setColAlign("center,left,center,center");
grid.enableMultiselect(true);
var combobox = grid.getCombo(2);
combobox.put("asp", "ASP");
combobox.put("aspx", "ASPX");
combobox.put("php", "PHP");
combobox.put("jsp", "JSP");
combobox.put("jspjs", "JSPJS");
combobox.put("custom", "CUSTOM");
antSword['core_types'].map((t)=>{
combobox.put(t,t.toUpperCase());
});
grid.attachEvent("onEditCell", function (stage, rId, cInd, nValue, oValue) {
// 2 编辑完成
......@@ -778,28 +775,18 @@ module.exports = {
// 同步到全局编码器
syncencoders() {
antSword['encoders'] = (function () {
var encoders = {
asp: [],
aspx: [],
php: [],
jsp: [],
jspjs: [],
custom: [],
};
var encoders_path = {
asp: [],
aspx: [],
php: [],
jsp: [],
jspjs: [],
custom: [],
};
var encoders = {};
var encoders_path = {};
for (var i in antSword['core_types']) {
encoders[antSword['core_types'][i]] = [];
encoders_path[antSword['core_types'][i]] = [];
}
let userencoder_path = path.join(remote.process.env.AS_WORKDIR, 'antData/encoders');
// 初始化
!fs.existsSync(userencoder_path) ?
fs.mkdirSync(userencoder_path) :
null;
['asp', 'aspx', 'php', 'jsp','jspjs' , 'custom'].map((t) => {
antSword['core_types'].map((t) => {
!fs.existsSync(path.join(userencoder_path, `${t}`)) ?
fs.mkdirSync(path.join(userencoder_path, `${t}`)) :
null;
......@@ -829,28 +816,18 @@ module.exports = {
// 同步到全局编码器
syncdecoders() {
antSword['decoders'] = (function () {
var decoders = {
asp: [],
aspx: [],
php: [],
jsp: [],
jspjs: [],
custom: []
};
var decoders_path = {
asp: [],
aspx: [],
php: [],
jsp: [],
jspjs: [],
custom: []
};
var decoders = {};
var decoders_path = {};
for (var i in antSword['core_types']) {
decoders[antSword['core_types'][i]] = [];
decoders_path[antSword['core_types'][i]] = [];
}
let userdecoder_path = path.join(remote.process.env.AS_WORKDIR, 'antData/encoders');
// 初始化
!fs.existsSync(userdecoder_path) ?
fs.mkdirSync(userdecoder_path) :
null;
['asp', 'aspx', 'php', 'jsp','jspjs', 'custom'].map((t) => {
antSword['core_types'].map((t) => {
!fs.existsSync(path.join(userdecoder_path, `${t}`)) ?
fs.mkdirSync(path.join(userdecoder_path, `${t}`)) :
null;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment