Commit a5640c98 authored by Medicean's avatar Medicean

(UE: Database) 优化检测和测试连接异常时提示

parent 74a67740
......@@ -52,7 +52,7 @@ class PHP extends Base {
// 组合完整的代码
let tmpCode = data['_'];
data['_'] = `@ini_set("display_errors", "0");@set_time_limit(0);echo "${tag_s}";${tmpCode};echo "${tag_e}";die();`;
data['_'] = `@ini_set("display_errors", "0");@set_time_limit(0);echo "${tag_s}";try{${tmpCode};}catch(Exception $e){echo "ERROR://".$e->getMessage();};echo "${tag_e}";die();`;
// 使用编码器进行处理并返回
return this.encodeComplete(tag_s, tag_e, data);
......
......@@ -528,6 +528,7 @@ module.exports = {
},
probedb: {
title: 'Detect database function support',
success: 'Check completed',
coltype: 'ConnType',
issupport: 'Support',
}
......
......@@ -529,6 +529,7 @@ module.exports = {
},
probedb: {
title: '检测数据库函数支持',
success: '检测完毕',
coltype: '连接类型',
issupport: '状态',
}
......
......@@ -245,6 +245,9 @@ class ASP {
})
).then((res) => {
if(res['text'].length > 0){
if(res['text'].indexOf("ERROR://") > -1) {
throw res["text"];
}
toastr.success(LANG['form']['test_success'], LANG_T['success']);
}else{
toastr.warning(LANG['form']['test_warning'], LANG_T['warning']);
......@@ -360,6 +363,9 @@ class ASP {
})
).then((res) => {
if(res['text'].length > 0){
if(res['text'].indexOf("ERROR://") > -1) {
throw res["text"];
}
toastr.success(LANG['form']['test_success'], LANG_T['success']);
}else{
toastr.warning(LANG['form']['test_warning'], LANG_T['warning']);
......
......@@ -241,6 +241,9 @@ class CUSTOM {
})
).then((res) => {
if(res['text'].length > 0){
if(res['text'].indexOf("ERROR://") > -1) {
throw res["text"];
}
toastr.success(LANG['form']['test_success'], LANG_T['success']);
}else{
toastr.warning(LANG['form']['test_warning'], LANG_T['warning']);
......@@ -357,6 +360,9 @@ class CUSTOM {
})
).then((res) => {
if(res['text'].length > 0){
if(res['text'].indexOf("ERROR://") > -1) {
throw res["text"];
}
toastr.success(LANG['form']['test_success'], LANG_T['success']);
}else{
toastr.warning(LANG['form']['test_warning'], LANG_T['warning']);
......
......@@ -7,6 +7,7 @@
// import AceEditor from 'react-ace';
const LANG = antSword['language']['database'];
const LANG_T = antSword['language']['toastr'];
class Database {
......@@ -238,6 +239,9 @@ class Database {
that.drive.core.request(
that.drive.core.base.probedb()
).then((ret) => {
if(ret['text'].indexOf("ERROR://") > -1){
throw res["text"];
}
let _data = ret['text'].split('\n');
let data_arr = [];
for (let i = 0; i < _data.length; i ++) {
......@@ -255,8 +259,10 @@ class Database {
grid.parse({
'rows': data_arr
}, 'json');
toastr.success(LANG['probedb']['success'], LANG_T['success']);
win.progressOff();
}).catch((err)=>{
toastr.error(JSON.stringify(err), LANG_T['error']);
win.progressOff();
});
}
......
......@@ -359,7 +359,7 @@ class PHP {
{ type: 'label', label: LANG['form']['encode'] },
{ type: 'combo', label: '', name: 'encode', options: (() => {
let ret = [];
['gbk', 'gb2312', 'utf-8', 'big5', 'dec8', 'cp850', 'hp8', 'koi8r', 'latin1', 'latin2', 'ascii', 'euckr'].map((_) => {
['utf8', 'big5', 'dec8', 'cp850', 'hp8', 'koi8r', 'latin1', 'latin2', 'ascii', 'euckr', 'gb2312', 'gbk'].map((_) => {
ret.push({
text: _,
value: _,
......@@ -373,7 +373,7 @@ class PHP {
{ type: 'label', label: LANG['form']['encode'] },
{ type: 'combo', label: '', name: 'encode', options: (() => {
let ret = [];
['gbk', 'gb2312', 'utf-8', 'big5', 'dec8', 'cp850', 'hp8', 'koi8r', 'latin1', 'latin2', 'ascii', 'euckr'].map((_) => {
['utf8', 'big5', 'dec8', 'cp850', 'hp8', 'koi8r', 'latin1', 'latin2', 'ascii', 'euckr', 'gb2312', 'gbk'].map((_) => {
ret.push({
text: _,
value: _,
......@@ -458,6 +458,9 @@ class PHP {
})
).then((res) => {
if(res['text'].length > 0){
if(res['text'].indexOf("ERROR://") > -1) {
throw res["text"];
}
toastr.success(LANG['form']['test_success'], LANG_T['success']);
}else{
toastr.warning(LANG['form']['test_warning'], LANG_T['warning']);
......@@ -555,7 +558,7 @@ class PHP {
{ type: 'label', label: LANG['form']['encode'] },
{ type: 'combo', label: '', name: 'encode', options: (() => {
let ret = [];
['gbk', 'gb2312', 'utf-8', 'big5', 'dec8', 'cp850', 'hp8', 'koi8r', 'latin1', 'latin2', 'ascii', 'euckr'].map((_) => {
['utf8', 'big5', 'dec8', 'cp850', 'hp8', 'koi8r', 'latin1', 'latin2', 'ascii', 'euckr', 'gb2312', 'gbk'].map((_) => {
ret.push({
text: _,
value: _,
......@@ -569,7 +572,7 @@ class PHP {
{ type: 'label', label: LANG['form']['encode'] },
{ type: 'combo', label: '', name: 'encode', options: (() => {
let ret = [];
['gbk', 'gb2312', 'utf-8', 'big5', 'dec8', 'cp850', 'hp8', 'koi8r', 'latin1', 'latin2', 'ascii', 'euckr'].map((_) => {
['utf8', 'big5', 'dec8', 'cp850', 'hp8', 'koi8r', 'latin1', 'latin2', 'ascii', 'euckr', 'gb2312', 'gbk'].map((_) => {
ret.push({
text: _,
value: _,
......@@ -659,6 +662,9 @@ class PHP {
})
).then((res) => {
if(res['text'].length > 0){
if(res['text'].indexOf("ERROR://") > -1) {
throw res["text"];
}
toastr.success(LANG['form']['test_success'], LANG_T['success']);
}else{
toastr.warning(LANG['form']['test_warning'], LANG_T['warning']);
......
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