Commit 107a4e27 authored by Medicean's avatar Medicean

Merge remote-tracking branch 'antoor/v2.0-beta' into v2.0-beta

parents e711fcba e470e551
...@@ -61,6 +61,12 @@ class Menubar { ...@@ -61,6 +61,12 @@ class Menubar {
click: event.sender.send.bind(event.sender, 'menubar', 'settings-display') click: event.sender.send.bind(event.sender, 'menubar', 'settings-display')
}, { }, {
type: 'separator' type: 'separator'
}, {
label: LANG['main']['encoders'],
accelerator: 'Shift+CmdOrCtrl+E',
click: event.sender.send.bind(event.sender, 'menubar', 'settings-encoders')
}, {
type: 'separator'
}, { }, {
label: LANG['main']['settings'], label: LANG['main']['settings'],
accelerator: 'Shift+CmdOrCtrl+S', accelerator: 'Shift+CmdOrCtrl+S',
......
...@@ -40,6 +40,11 @@ const antSword = window.antSword = { ...@@ -40,6 +40,11 @@ const antSword = window.antSword = {
* @type {Array} * @type {Array}
*/ */
logs: [], logs: [],
/**
* 核心模块
* @type {Object}
*/
encoders: {},
/** /**
* 核心模块 * 核心模块
* @type {Object} * @type {Object}
...@@ -68,6 +73,8 @@ const antSword = window.antSword = { ...@@ -68,6 +73,8 @@ const antSword = window.antSword = {
if (!value) { if (!value) {
return localStorage.getItem(key) || def; return localStorage.getItem(key) || def;
}; };
if (typeof(x) === "object")
value = JSON.stringify(value);
// 设置 // 设置
localStorage.setItem(key, value); localStorage.setItem(key, value);
}, },
...@@ -117,6 +124,33 @@ antSword['core'] = require('./core/'); ...@@ -117,6 +124,33 @@ antSword['core'] = require('./core/');
// 加载语言模板 // 加载语言模板
antSword['language'] = require('./language/'); antSword['language'] = require('./language/');
// 加载编码
antSword['encoders'] = (function(){
var encoders = {asp:[],aspx:[],php:[],custom:[]};
// custom
let es = fs.readdirSync(path.join(process.env.AS_WORKDIR,'antData/encoder'));
if(es){
es.map((_)=>{
let farr = _.split("#");
encoders[farr[0]].push(farr[1].slice(0,-3));
});
}
// default
['asp','aspx','php','custom'].map((t)=>{
antSword["core"][t].prototype.encoders.map((e)=>{
encoders[t].push(e);
});
encoders[t] = encoders[t].unique();
});
// fs.readdirSync(path.join(process.env.AS_WORKDIR,'encoder'),(err,f) => {
// if(err || !f) return ;
// console.debug(f);
// let farr = f.split("#");
// encoders[farr[0]].push(farr[1]);
// });
return encoders;
})();
// 加载代理 // 加载代理
const aproxy = { const aproxy = {
mode: antSword['storage']('aproxymode', false, 'noproxy'), mode: antSword['storage']('aproxymode', false, 'noproxy'),
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
const Base = require('../base'); const Base = require('../base');
class ASP extends Base { class ASP extends Base {
constructor(opts) { constructor(opts) {
super(opts); super(opts);
// 解析模板 // 解析模板
...@@ -33,7 +34,7 @@ class ASP extends Base { ...@@ -33,7 +34,7 @@ class ASP extends Base {
* @return {array} 编码器列表 * @return {array} 编码器列表
*/ */
get encoders() { get encoders() {
return ['xxxxdog']; return localStorage.getItem('encoders_asp').split(',') || ['xxxxdog'];
} }
/** /**
......
...@@ -37,7 +37,7 @@ class ASPX extends Base { ...@@ -37,7 +37,7 @@ class ASPX extends Base {
* @return {array} 编码器列表 * @return {array} 编码器列表
*/ */
get encoders() { get encoders() {
return ['base64', 'hex']; return localStorage.getItem('encoders_aspx').split(',') || ['base64', 'hex'];
} }
/** /**
......
...@@ -30,7 +30,7 @@ class CUSTOM extends Base { ...@@ -30,7 +30,7 @@ class CUSTOM extends Base {
* @return {array} 编码器列表 * @return {array} 编码器列表
*/ */
get encoders() { get encoders() {
return ['base64', 'hex']; return localStorage.getItem('encoders_custom').split(',') || ['base64', 'hex'];
} }
/** /**
......
...@@ -35,7 +35,7 @@ class PHP extends Base { ...@@ -35,7 +35,7 @@ class PHP extends Base {
* @return {array} 编码器列表 * @return {array} 编码器列表
*/ */
get encoders() { get encoders() {
return ['chr', 'chr16', 'base64']; return localStorage.getItem('encoders_php').split(',') || ['chr', 'base64'];
} }
/** /**
......
...@@ -15,6 +15,7 @@ module.exports = { ...@@ -15,6 +15,7 @@ module.exports = {
pluginStore: 'Plugin Store', pluginStore: 'Plugin Store',
settings: 'System setting', settings: 'System setting',
language: 'Language setting', language: 'Language setting',
encoders: 'Encoders manager',
aproxy: 'Proxy setting', aproxy: 'Proxy setting',
display: 'Display setting', display: 'Display setting',
update: 'Check update', update: 'Check update',
...@@ -455,6 +456,14 @@ module.exports = { ...@@ -455,6 +456,14 @@ module.exports = {
success: 'Update success! Please manually restart the application later!' success: 'Update success! Please manually restart the application later!'
} }
}, },
encoders:{
title: 'Encoder Manager',
form:{
shelltype: 'Shell Type',
encoderslist: 'Encoder Lists'
},
success: 'Loaded Encoder Successfully'
},
aproxy: { aproxy: {
title: 'Proxy setting', title: 'Proxy setting',
toolbar: { toolbar: {
......
...@@ -16,6 +16,7 @@ module.exports = { ...@@ -16,6 +16,7 @@ module.exports = {
pluginStore: '插件市场', pluginStore: '插件市场',
settings: '系统设置', settings: '系统设置',
language: '语言设置', language: '语言设置',
encoders: '编码设置',
aproxy: '代理设置', aproxy: '代理设置',
display: '显示设置', display: '显示设置',
update: '检查更新', update: '检查更新',
...@@ -456,6 +457,14 @@ module.exports = { ...@@ -456,6 +457,14 @@ module.exports = {
success: '更新成功!请稍后手动重启应用!' success: '更新成功!请稍后手动重启应用!'
} }
}, },
encoders:{
title: '编码管理',
form:{
shelltype: '脚本类型',
encoderslist: '编码器列表'
},
success: '编码器加载成功'
},
aproxy: { aproxy: {
title: '代理设置', title: '代理设置',
toolbar: { toolbar: {
......
...@@ -43,6 +43,18 @@ window.addEventListener('load', () => { ...@@ -43,6 +43,18 @@ window.addEventListener('load', () => {
return format; return format;
} }
Array.prototype.unique = function(){
var res = [];
var json = {};
for(var i = 0; i < this.length; i++){
if(!json[this[i]]){
res.push(this[i]);
json[this[i]] = 1;
}
}
return res;
}
/** /**
* 加载JS函数 * 加载JS函数
......
/**
* 中国蚁剑::编码器管理
* 创建:2017-05-30
* 更新:2017-05-30
* 作者:Virink <virink@outlook.com>
*
* 瞎折腾好了。。。
* 编辑保存什么的功能我就不弄了
* 累觉不爱。。。。。。。。
*/
const LANG = antSword['language']['settings']['encoders'];
const LANG_T = antSword['language']['toastr'];
const fs = require('fs');
const path = require('path');
class Encoders {
constructor(sidebar) {
var _me = this;
this.encoders = {asp:[],aspx:[],php:[],custom:[]};
this.getEncoders();
sidebar.addItem({
id: 'encoders',
text: `<i class="fa fa-file-code-o"></i> ${LANG['title']}`
});
this.cell = sidebar.cells('encoders');
// 并没有什么卵用的工具栏
const toolbar = this.cell.attachToolbar();
toolbar.loadStruct([
{ type: 'button', text: `${LANG['title']}`, icon: 'eye'}
]);
let layout = this.cell.attachLayout('2E');
this.a = layout.cells('a');
this.b = layout.cells('b');
this.a.hideHeader();
this.b.hideHeader();
this.a.setHeight(80);
this._createFrom({});
this.editor = this.b.attachEditor([{
name: 'editor', type: 'editor',
inputLeft:0, inputTop:0, inputHeight:this.b.getHeight(),inputWidth:this.b.getWidth(),
position:'absolute'
}]);
}
_createFrom(arg){
var _me = this;
const opt = Object.assign({}, {
type: 'asp',
encoder: []
}, arg);
const form = this.a.attachForm([
{ type: 'block', list: [
{
type: 'combo', label: `${LANG['form']['shelltype']}`, width: 100,
name: 'encodertype', readonly: true, options: this._parseEncodes(opt.type)
}
]}
], true);
form.enableLiveValidation(true);
form.attachEvent("onChange", function(name, value){
if (name == "encoder" && value != 'virink') {
let _ = form.getFormData();
_me._readEncoderSource(_.encodertype, value);
}
});
return form;
}
_readEncoderSource(_path,name){
let codes = fs.readFileSync(path.join(__dirname,`../../core/${_path}/encoder/${name}.js`));
if(codes){
let c = [];
codes.toString().split("\n").map((_)=>{
c.push(`<div>${_}</div>`);
});
this.editor.setContent(c.toString().replace(/,/ig,""));
}
}
_parseEncodes(_st){
let ret = [];
for (let t in this.encoders){
let es = this.encoders[t];
ret.push({
text: t.toUpperCase(),
selected: t === _st,
value: t,
list: ((t)=>{
let s = [{ text: 'Welcome', value: 'virink'}];
es.map((e)=>{
s.push({ text: e, value: e});
});
let _ = [{
type: 'combo', label: `${LANG['form']['encoderslist']}`, width: 200,
name: 'encoder', readonly: true, options: s
}];
return _;
})(t)
});
}
return ret;
}
getEncoders(){
var _me = this;
['asp','aspx','php','custom'].map((t)=>{
let me = fs.readdirSync(path.join(__dirname,`../../core/${t}/encoder`));
me.map((_) => {
if (_ != '.DS_Store')
_me.encoders[t].push(_.replace(/\.js/ig, ''));
});
localStorage.setItem(`encoders_${t}`,_me.encoders[t]);
});
toastr.success(`${LANG['success']}`, LANG_T['success']);
}
}
module.exports = Encoders;
...@@ -11,12 +11,13 @@ const About = require('./about'); ...@@ -11,12 +11,13 @@ const About = require('./about');
const Language = require('./language'); const Language = require('./language');
const AProxy = require('./aproxy'); const AProxy = require('./aproxy');
const Display = require('./display'); const Display = require('./display');
const Encoders = require('./encoders');
class Settings { class Settings {
constructor() { constructor() {
antSword['menubar'].reg('settings', this.open.bind(this)); antSword['menubar'].reg('settings', this.open.bind(this));
['about', 'update', 'language', 'aproxy', 'display'].map((_) => { ['about', 'update', 'language', 'aproxy','display', 'encoders'].map((_) => {
antSword['menubar'].reg(`settings-${_}`, this.setActive.bind(this, _)); antSword['menubar'].reg(`settings-${_}`, this.setActive.bind(this, _));
}); });
return this; return this;
...@@ -44,7 +45,8 @@ class Settings { ...@@ -44,7 +45,8 @@ class Settings {
// this.update = new Update(sidebar); // this.update = new Update(sidebar);
this.aproxy = new AProxy(sidebar); this.aproxy = new AProxy(sidebar);
this.display = new Display(sidebar); this.display = new Display(sidebar);
// Encoders
this.encoders = new Encoders(sidebar);
this.cell = cell; this.cell = cell;
this.sidebar = sidebar; this.sidebar = sidebar;
......
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