Commit 9a0fbbd7 authored by antoor's avatar antoor

Fix call core module

修复调用核心模块
parent b6092dde
......@@ -33,9 +33,7 @@ const antSword = window.antSword = {
};
// 加载模板代码
['php', 'asp', 'aspx', 'custom'].map((_) => {
antSword['core'][_] = require(`./core/${_}/index`);
});
antSword['core'] = require('./core/index');
// 加载显示语言
let _lang = localStorage.getItem('language') || navigator.language;
......
//
//
// 数据库驱动::ASP
// 支持数据库:access,sqlserver,mysql
//
//
class ASP {
......@@ -9,9 +9,9 @@ class ASP {
this.opt = opt;
this.core = this.opt.core;
this.manager = this.opt.super;
//
//
// * 数据库驱动列表
//
//
this.conns = {
'dsn': 'Dsn=DsnName;',
'mysql': 'Driver={MySQL};Server=localhost;database=mysql;UID=root;PWD=',
......@@ -254,11 +254,15 @@ class ASP {
_id: this.manager.opt['_id'],
id: id
});
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'
}, (ret) => {
this.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'
})
).then((res) => {
let ret = res['text'];
const arr = ret.split('\t');
if (arr.length === 1 && ret === '') {
toastr.warning('执行完毕,没有结果返回')
......@@ -279,7 +283,7 @@ class ASP {
this.manager.list.imgs[1]);
});
this.manager.list.layout.progressOff();
}, (err) => {
}).catch((err) => {
toastr.error('获取数据库列表失败!' + err['status'] || JSON.stringify(err), 'ERROR');
this.manager.list.layout.progressOff();
});
......@@ -293,11 +297,15 @@ class ASP {
_id: this.manager.opt['_id'],
id: id
});
this.core[`database_${conf['type']}`].show_tables(
{
conn: conf['conn'],
dbname: db
}, (ret) => {
this.core.request(
this.core[`database_${conf['type']}`].show_tables(
{
conn: conf['conn'],
dbname: db
})
).then((res) => {
let ret = res['text'];
const arr = ret.split('\t');
const _db = new Buffer(db).toString('base64');
// 删除子节点
......@@ -328,11 +336,15 @@ class ASP {
_id: this.manager.opt['_id'],
id: id
});
this.core[`database_${conf['type']}`].show_columns(
{
conn: conf['conn'],
table: conf['type'] === 'oracle' ? `SELECT * FROM (SELECT A.*,ROWNUM N FROM ${table} A) WHERE N=1` : `SELECT TOP 1 * FROM ${table}`
}, (ret) => {
this.core.request(
this.core[`database_${conf['type']}`].show_columns(
{
conn: conf['conn'],
table: conf['type'] === 'oracle' ? `SELECT * FROM (SELECT A.*,ROWNUM N FROM ${table} A) WHERE N=1` : `SELECT TOP 1 * FROM ${table}`
})
).then((res) => {
let ret = res['text'];
const arr = ret.split('\t');
const _db = new Buffer(db).toString('base64');
const _table = new Buffer(table).toString('base64');
......@@ -363,14 +375,18 @@ class ASP {
// 执行SQL
execSQL(sql) {
this.manager.query.layout.progressOn();
this.core[`database_${this.dbconf['type']}`].query({
conn: this.dbconf['conn'],
sql: sql
}, (ret) => {
this.core.request(
this.core[`database_${this.dbconf['type']}`].query({
conn: this.dbconf['conn'],
sql: sql
})
).then((res) => {
let ret = res['text'];
// 更新执行结果
this.updateResult(ret);
this.manager.query.layout.progressOff();
}, (err) => {
}).catch((err) => {
console.error(err);
});
}
......@@ -455,4 +471,4 @@ class ASP {
}
module.exports = ASP;
\ No newline at end of file
module.exports = ASP;
......@@ -250,12 +250,14 @@ class ASP {
_id: this.manager.opt['_id'],
id: id
});
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'
}, (ret) => {
this.core.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'
})
).then((res) => {
let ret = res['text'];
const arr = ret.split('\t');
if (arr.length === 1 && ret === '') {
toastr.warning('执行完毕,没有结果返回')
......@@ -276,7 +278,7 @@ class ASP {
this.manager.list.imgs[1]);
});
this.manager.list.layout.progressOff();
}, (err) => {
}).catch((err) => {
toastr.error('获取数据库列表失败!' + err['status'] || JSON.stringify(err), 'ERROR');
this.manager.list.layout.progressOff();
});
......@@ -290,12 +292,16 @@ class ASP {
_id: this.manager.opt['_id'],
id: id
});
this.core[`database_${conf['type']}`].show_tables(
{
conn: conf['conn'],
encode: this.manager.opt.encode,
db: db
}, (ret) => {
this.core.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');
const _db = new Buffer(db).toString('base64');
// 删除子节点
......@@ -326,13 +332,17 @@ class ASP {
_id: this.manager.opt['_id'],
id: id
});
this.core[`database_${conf['type']}`].show_columns(
{
conn: conf['conn'],
encode: this.manager.opt.encode,
db: db,
table: table
}, (ret) => {
this.core.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');
const _db = new Buffer(db).toString('base64');
const _table = new Buffer(table).toString('base64');
......@@ -363,15 +373,19 @@ class ASP {
// 执行SQL
execSQL(sql) {
this.manager.query.layout.progressOn();
this.core[`database_${this.dbconf['type']}`].query({
conn: this.dbconf['conn'],
encode: this.manager.opt.encode,
sql: sql
}, (ret) => {
this.core.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'];
// 更新执行结果
this.updateResult(ret);
this.manager.query.layout.progressOff();
}, (err) => {
}).catch((err) => {
console.error(err);
});
}
......
//
//
// 数据库驱动::PHP
// 支持数据库:mysql,mssql,oracle,informix
//
//
const LANG = antSword['language']['database'];
const LANG_T = antSword['language']['toastr'];
......@@ -271,12 +271,14 @@ class PHP {
_id: this.manager.opt['_id'],
id: id
});
this.core[`database_${conf['type']}`].show_databases(
{
host: conf['host'],
user: conf['user'],
passwd: conf['passwd']
}, (ret) => {
this.core.request(
this.core[`database_${conf['type']}`].show_databases({
host: conf['host'],
user: conf['user'],
passwd: conf['passwd']
})
).then((res) => {
let ret = res['text'];
const arr = ret.split('\t');
if (arr.length === 1 && ret === '') {
toastr.warning(LANG['result']['warning'], LANG_T['warning']);
......@@ -297,7 +299,7 @@ class PHP {
this.manager.list.imgs[1]);
});
this.manager.list.layout.progressOff();
}, (err) => {
}).catch((err) => {
toastr.error(LANG['result']['error']['database'](err['status'] || JSON.stringify(err)), LANG_T['error']);
this.manager.list.layout.progressOff();
});
......@@ -311,13 +313,16 @@ class PHP {
_id: this.manager.opt['_id'],
id: id
});
this.core[`database_${conf['type']}`].show_tables(
{
host: conf['host'],
user: conf['user'],
passwd: conf['passwd'],
db: db
}, (ret) => {
this.core.request(
this.core[`database_${conf['type']}`].show_tables({
host: conf['host'],
user: conf['user'],
passwd: conf['passwd'],
db: db
})
).then((res) => {
let ret = res['text'];
const arr = ret.split('\t');
const _db = new Buffer(db).toString('base64');
// 删除子节点
......@@ -337,7 +342,7 @@ class PHP {
);
});
this.manager.list.layout.progressOff();
}, (err) => {
}).catch((err) => {
toastr.error(LANG['result']['error']['table'](err['status'] || JSON.stringify(err)), LANG_T['error']);
this.manager.list.layout.progressOff();
});
......@@ -351,14 +356,17 @@ class PHP {
_id: this.manager.opt['_id'],
id: id
});
this.core[`database_${conf['type']}`].show_columns(
{
host: conf['host'],
user: conf['user'],
passwd: conf['passwd'],
db: db,
table: table
}, (ret) => {
this.core.request(
this.core[`database_${conf['type']}`].show_columns({
host: conf['host'],
user: conf['user'],
passwd: conf['passwd'],
db: db,
table: table
})
).then((res) => {
let ret = res['text'];
const arr = ret.split('\t');
const _db = new Buffer(db).toString('base64');
const _table = new Buffer(table).toString('base64');
......@@ -380,7 +388,7 @@ class PHP {
// 更新编辑器SQL语句
this.manager.query.editor.session.setValue(`SELECT * FROM \`${table}\` ORDER BY 1 DESC LIMIT 0,20;`);
this.manager.list.layout.progressOff();
}, (err) => {
}).catch((err) => {
toastr.error(LANG['result']['error']['column'](err['status'] || JSON.stringify(err)), LANG_T['error']);
this.manager.list.layout.progressOff();
});
......@@ -389,18 +397,22 @@ class PHP {
// 执行SQL
execSQL(sql) {
this.manager.query.layout.progressOn();
this.core[`database_${this.dbconf['type']}`].query({
host: this.dbconf['host'],
user: this.dbconf['user'],
passwd: this.dbconf['passwd'],
db: this.dbconf['database'],
sql: sql,
encode: this.dbconf['encode'] || 'utf8'
}, (ret) => {
this.core.request(
this.core[`database_${this.dbconf['type']}`].query({
host: this.dbconf['host'],
user: this.dbconf['user'],
passwd: this.dbconf['passwd'],
db: this.dbconf['database'],
sql: sql,
encode: this.dbconf['encode'] || 'utf8'
})
).then((res) => {
let ret = res['text'];
// 更新执行结果
this.updateResult(ret);
this.manager.query.layout.progressOff();
}, (err) => {
}).catch((err) => {
toastr.error(LANG['result']['error']['query'](err['status'] || JSON.stringify(err)), LANG_T['error']);
this.manager.query.layout.progressOff();
});
......@@ -484,4 +496,4 @@ class PHP {
}
module.exports = PHP;
\ No newline at end of file
module.exports = PHP;
......@@ -194,6 +194,7 @@ class Files {
grid.setInitWidths("40,*,150,100,100");
grid.setColAlign("center,left,left,right,center");
grid.enableMultiselect(true);
grid.enableDragAndDrop(true);
// grid.enableMultiline(true);
// grid右键
......@@ -368,6 +369,23 @@ class Files {
// 剪贴板
this.Clipboard = {};
// 文件拖拽上传
$(this.cell.cell).on({
dragleave: (e) => { e.preventDefault() },
drop: (e) => {
e.preventDefault();
let filePaths = [];
let files = e.originalEvent['dataTransfer']['files'] || {};
for (let i = 0; i < files.length; i++) {
let f = files.item(i);
filePaths.push(f['path']);
}
this.manager.uploadFile(filePaths);
},
dragenter: (e) => { e.preventDefault() },
dragover: (e) => { e.preventDefault() }
});
}
// 刷新当前目录
......
......@@ -11,7 +11,6 @@ class Folder {
// 1.cell: 左侧layout.cell对象
constructor(cell, manager) {
cell.setWidth(250);
cell.setText(`<i class="fa fa-folder-o"></i> ${LANG['title']}`);
// 创建tree
let tree = cell.attachTree();
// tree事件
......@@ -23,6 +22,7 @@ class Folder {
this.cell = cell;
this.cache = {};
this.manager = manager;
this.setTitle(0);
}
......@@ -44,12 +44,15 @@ class Folder {
self.cache[curPath] = 0;
});
// 2. 解析当前子目录
let folderNum = 0;
files.map((f) => {
let _ = f['name'];
if (!_.endsWith('/') || ['./', '../'].indexOf(_) !== -1) {return};
self.cache[`${curPath}${_}`] = 0;
folderNum ++;
});
// 设置标题
this.setTitle(folderNum);
// 3. 解析缓存为树形菜单虚拟对象
// /var/www/html 根据/分割为数组,循环,相加,增加到虚拟缓存
......@@ -100,6 +103,14 @@ class Folder {
this.cell.progressOff();
}
/**
* 设置标题
* @param {Number} num 当前目录数
*/
setTitle(num) {
this.cell.setText(`<i class="fa fa-folder-o"></i> ${LANG['title']} (${num})`);
}
}
export default Folder;
This diff is collapsed.
This diff is collapsed.
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