Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
antSword
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
HuangJunbo
antSword
Commits
358d6c31
Commit
358d6c31
authored
May 12, 2016
by
Medicean
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Asp DB Conf i18n
ASP 数据库配置操作国际化
parent
2b77ed1b
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
44 additions
and
19 deletions
+44
-19
en.js
source/language/en.js
+1
-0
zh.js
source/language/zh.js
+1
-0
index.js
source/modules/database/asp/index.js
+42
-19
No files found.
source/language/en.js
View file @
358d6c31
...
@@ -369,6 +369,7 @@ module.exports = {
...
@@ -369,6 +369,7 @@ module.exports = {
clear
:
'Clear'
,
clear
:
'Clear'
,
edit
:
'Edit'
edit
:
'Edit'
},
},
conn
:
'Connection String'
,
type
:
'Database type'
,
type
:
'Database type'
,
encode
:
'Database encode'
,
encode
:
'Database encode'
,
host
:
'Host'
,
host
:
'Host'
,
...
...
source/language/zh.js
View file @
358d6c31
...
@@ -370,6 +370,7 @@ module.exports = {
...
@@ -370,6 +370,7 @@ module.exports = {
clear
:
'清空'
,
clear
:
'清空'
,
edit
:
'编辑'
edit
:
'编辑'
},
},
conn
:
'连接字符串'
,
type
:
'数据库类型'
,
type
:
'数据库类型'
,
encode
:
'数据库编码'
,
encode
:
'数据库编码'
,
host
:
'数据库地址'
,
host
:
'数据库地址'
,
...
...
source/modules/database/asp/index.js
View file @
358d6c31
...
@@ -3,6 +3,9 @@
...
@@ -3,6 +3,9 @@
// 支持数据库:access,sqlserver,mysql
// 支持数据库:access,sqlserver,mysql
//
//
const
LANG
=
antSword
[
'language'
][
'database'
];
const
LANG_T
=
antSword
[
'language'
][
'toastr'
];
class
ASP
{
class
ASP
{
constructor
(
opt
)
{
constructor
(
opt
)
{
...
@@ -91,13 +94,19 @@ class ASP {
...
@@ -91,13 +94,19 @@ class ASP {
this
.
tree
.
callEvent
(
'onClick'
,
[
id
]);
this
.
tree
.
callEvent
(
'onClick'
,
[
id
]);
bmenu
([
bmenu
([
{
{
text
:
'添加配置'
,
text
:
LANG
[
'list'
][
'menu'
][
'add'
]
,
icon
:
'fa fa-plus-circle'
,
icon
:
'fa fa-plus-circle'
,
action
:
this
.
addConf
.
bind
(
this
)
action
:
this
.
addConf
.
bind
(
this
)
},
{
},
{
divider
:
true
divider
:
true
},
{
},
{
text
:
'删除配置'
,
text
:
LANG
[
'list'
][
'menu'
][
'edit'
],
icon
:
'fa fa-edit'
,
action
:
this
.
editConf
.
bind
(
this
)
},
{
divider
:
true
},
{
text
:
LANG
[
'list'
][
'menu'
][
'del'
],
icon
:
'fa fa-remove'
,
icon
:
'fa fa-remove'
,
action
:
this
.
delConf
.
bind
(
this
)
action
:
this
.
delConf
.
bind
(
this
)
}
}
...
@@ -140,7 +149,7 @@ class ASP {
...
@@ -140,7 +149,7 @@ class ASP {
const
hash
=
(
+
new
Date
*
Math
.
random
()).
toString
(
16
).
substr
(
2
,
8
);
const
hash
=
(
+
new
Date
*
Math
.
random
()).
toString
(
16
).
substr
(
2
,
8
);
// 创建窗口
// 创建窗口
const
win
=
this
.
manager
.
win
.
createWindow
(
hash
,
0
,
0
,
450
,
300
);
const
win
=
this
.
manager
.
win
.
createWindow
(
hash
,
0
,
0
,
450
,
300
);
win
.
setText
(
'添加配置'
);
win
.
setText
(
LANG
[
'form'
][
'title'
]
);
win
.
centerOnScreen
();
win
.
centerOnScreen
();
win
.
button
(
'minmax'
).
hide
();
win
.
button
(
'minmax'
).
hide
();
win
.
setModal
(
true
);
win
.
setModal
(
true
);
...
@@ -151,21 +160,21 @@ class ASP {
...
@@ -151,21 +160,21 @@ class ASP {
id
:
'add'
,
id
:
'add'
,
type
:
'button'
,
type
:
'button'
,
icon
:
'plus-circle'
,
icon
:
'plus-circle'
,
text
:
'添加'
text
:
LANG
[
'form'
][
'toolbar'
][
'add'
]
},
{
},
{
type
:
'separator'
type
:
'separator'
},
{
},
{
id
:
'clear'
,
id
:
'clear'
,
type
:
'button'
,
type
:
'button'
,
icon
:
'remove'
,
icon
:
'remove'
,
text
:
'清空'
text
:
LANG
[
'form'
][
'toolbar'
][
'clear'
]
}]);
}]);
// form
// form
const
form
=
win
.
attachForm
([
const
form
=
win
.
attachForm
([
{
type
:
'settings'
,
position
:
'label-left'
,
labelWidth
:
80
,
inputWidth
:
280
},
{
type
:
'settings'
,
position
:
'label-left'
,
labelWidth
:
80
,
inputWidth
:
280
},
{
type
:
'block'
,
inputWidth
:
'auto'
,
offsetTop
:
12
,
list
:
[
{
type
:
'block'
,
inputWidth
:
'auto'
,
offsetTop
:
12
,
list
:
[
{
type
:
'combo'
,
label
:
'数据库类型'
,
readonly
:
true
,
name
:
'type'
,
options
:
(()
=>
{
{
type
:
'combo'
,
label
:
LANG
[
'form'
][
'type'
]
,
readonly
:
true
,
name
:
'type'
,
options
:
(()
=>
{
let
ret
=
[];
let
ret
=
[];
for
(
let
_
in
this
.
conns
)
{
for
(
let
_
in
this
.
conns
)
{
ret
.
push
({
ret
.
push
({
...
@@ -175,7 +184,7 @@ class ASP {
...
@@ -175,7 +184,7 @@ class ASP {
}
}
return
ret
;
return
ret
;
})()
},
})()
},
{
type
:
'input'
,
label
:
'连接字符串'
,
name
:
'conn'
,
required
:
true
,
value
:
'Dsn=DsnName;'
,
rows
:
9
}
{
type
:
'input'
,
label
:
LANG
[
'form'
][
'conn'
]
,
name
:
'conn'
,
required
:
true
,
value
:
'Dsn=DsnName;'
,
rows
:
9
}
]}
]}
],
true
);
],
true
);
...
@@ -194,8 +203,8 @@ class ASP {
...
@@ -194,8 +203,8 @@ class ASP {
break
;
break
;
case
'add'
:
case
'add'
:
if
(
!
form
.
validate
())
{
if
(
!
form
.
validate
())
{
return
'填写完整!'
;
//
return '填写完整!';
//
return toastr.warning(LANG['list']['add']['warning'], LANG_T['warning']);
return
toastr
.
warning
(
LANG
[
'list'
][
'add'
][
'warning'
],
LANG_T
[
'warning'
]);
};
};
// 解析数据
// 解析数据
let
data
=
form
.
getValues
();
let
data
=
form
.
getValues
();
...
@@ -205,7 +214,7 @@ class ASP {
...
@@ -205,7 +214,7 @@ class ASP {
data
:
data
data
:
data
});
});
win
.
close
();
win
.
close
();
toastr
.
success
(
'添加配置成功!'
);
toastr
.
success
(
LANG
[
'form'
][
'success'
],
LANG_T
[
'success'
]
);
this
.
tree
.
insertNewItem
(
0
,
this
.
tree
.
insertNewItem
(
0
,
`conn::
${
id
}
`
,
`conn::
${
id
}
`
,
// `${data['type']}:\/\/${data['user']}@${data['host']}`,
// `${data['type']}:\/\/${data['user']}@${data['host']}`,
...
@@ -220,12 +229,17 @@ class ASP {
...
@@ -220,12 +229,17 @@ class ASP {
});
});
}
}
// 修改配置
editConf
()
{
}
// 删除配置
// 删除配置
delConf
()
{
delConf
()
{
const
id
=
this
.
tree
.
getSelected
().
split
(
'::'
)[
1
];
const
id
=
this
.
tree
.
getSelected
().
split
(
'::'
)[
1
];
layer
.
confirm
(
'确定删除此配置吗?'
,
{
layer
.
confirm
(
LANG
[
'form'
][
'del'
][
'confirm'
]
,
{
icon
:
2
,
shift
:
6
,
icon
:
2
,
shift
:
6
,
title
:
'删除配置'
title
:
LANG
[
'form'
][
'del'
][
'title'
]
},
(
_
)
=>
{
},
(
_
)
=>
{
layer
.
close
(
_
);
layer
.
close
(
_
);
const
ret
=
antSword
[
'ipcRenderer'
].
sendSync
(
'shell-delDataConf'
,
{
const
ret
=
antSword
[
'ipcRenderer'
].
sendSync
(
'shell-delDataConf'
,
{
...
@@ -233,7 +247,7 @@ class ASP {
...
@@ -233,7 +247,7 @@ class ASP {
id
:
id
id
:
id
});
});
if
(
ret
===
1
)
{
if
(
ret
===
1
)
{
toastr
.
success
(
'删除配置成功!'
);
toastr
.
success
(
LANG
[
'form'
][
'del'
][
'success'
],
LANG_T
[
'success'
]
);
this
.
tree
.
deleteItem
(
`conn::
${
id
}
`
);
this
.
tree
.
deleteItem
(
`conn::
${
id
}
`
);
// 禁用按钮
// 禁用按钮
this
.
disableToolbar
();
this
.
disableToolbar
();
...
@@ -241,7 +255,7 @@ class ASP {
...
@@ -241,7 +255,7 @@ class ASP {
// ['edit', 'del'].map(this.toolbar::this.toolbar.disableItem);
// ['edit', 'del'].map(this.toolbar::this.toolbar.disableItem);
// this.parse();
// this.parse();
}
else
{
}
else
{
toastr
.
error
(
'删除配置失败!<br/>'
+
ret
);
toastr
.
error
(
LANG
[
'form'
][
'del'
][
'error'
](
ret
),
LANG_T
[
'error'
]
);
}
}
});
});
}
}
...
@@ -265,7 +279,7 @@ class ASP {
...
@@ -265,7 +279,7 @@ class ASP {
let
ret
=
res
[
'text'
];
let
ret
=
res
[
'text'
];
const
arr
=
ret
.
split
(
'
\
t'
);
const
arr
=
ret
.
split
(
'
\
t'
);
if
(
arr
.
length
===
1
&&
ret
===
''
)
{
if
(
arr
.
length
===
1
&&
ret
===
''
)
{
toastr
.
warning
(
'执行完毕,没有结果返回'
)
toastr
.
warning
(
LANG
[
'result'
][
'warning'
],
LANG_T
[
'warning'
]);
return
this
.
manager
.
list
.
layout
.
progressOff
();
return
this
.
manager
.
list
.
layout
.
progressOff
();
};
};
// 删除子节点
// 删除子节点
...
@@ -284,7 +298,7 @@ class ASP {
...
@@ -284,7 +298,7 @@ class ASP {
});
});
this
.
manager
.
list
.
layout
.
progressOff
();
this
.
manager
.
list
.
layout
.
progressOff
();
}).
catch
((
err
)
=>
{
}).
catch
((
err
)
=>
{
toastr
.
error
(
'获取数据库列表失败!'
+
err
[
'status'
]
||
JSON
.
stringify
(
err
),
'ERROR'
);
toastr
.
error
(
LANG
[
'result'
][
'error'
][
'database'
](
err
[
'status'
]
||
JSON
.
stringify
(
err
)),
LANG_T
[
'error'
]
);
this
.
manager
.
list
.
layout
.
progressOff
();
this
.
manager
.
list
.
layout
.
progressOff
();
});
});
}
}
...
@@ -325,6 +339,9 @@ class ASP {
...
@@ -325,6 +339,9 @@ class ASP {
);
);
});
});
this
.
manager
.
list
.
layout
.
progressOff
();
this
.
manager
.
list
.
layout
.
progressOff
();
}).
catch
((
err
)
=>
{
toastr
.
error
(
LANG
[
'result'
][
'error'
][
'table'
](
err
[
'status'
]
||
JSON
.
stringify
(
err
)),
LANG_T
[
'error'
]);
this
.
manager
.
list
.
layout
.
progressOff
();
});
});
}
}
...
@@ -369,6 +386,9 @@ class ASP {
...
@@ -369,6 +386,9 @@ class ASP {
?
`SELECT * FROM (SELECT A.*,ROWNUM N FROM
${
table
}
A ORDER BY 1 DESC) WHERE N>0 AND N<=20`
?
`SELECT * FROM (SELECT A.*,ROWNUM N FROM
${
table
}
A ORDER BY 1 DESC) WHERE N>0 AND N<=20`
:
`SELECT TOP 20 * FROM
${
table
}
ORDER BY 1 DESC;`
);
:
`SELECT TOP 20 * FROM
${
table
}
ORDER BY 1 DESC;`
);
this
.
manager
.
list
.
layout
.
progressOff
();
this
.
manager
.
list
.
layout
.
progressOff
();
}).
catch
((
err
)
=>
{
toastr
.
error
(
LANG
[
'result'
][
'error'
][
'column'
](
err
[
'status'
]
||
JSON
.
stringify
(
err
)),
LANG_T
[
'error'
]);
this
.
manager
.
list
.
layout
.
progressOff
();
});
});
}
}
...
@@ -387,7 +407,8 @@ class ASP {
...
@@ -387,7 +407,8 @@ class ASP {
this
.
updateResult
(
ret
);
this
.
updateResult
(
ret
);
this
.
manager
.
query
.
layout
.
progressOff
();
this
.
manager
.
query
.
layout
.
progressOff
();
}).
catch
((
err
)
=>
{
}).
catch
((
err
)
=>
{
console
.
error
(
err
);
toastr
.
error
(
LANG
[
'result'
][
'error'
][
'query'
](
err
[
'status'
]
||
JSON
.
stringify
(
err
)),
LANG_T
[
'error'
]);
this
.
manager
.
query
.
layout
.
progressOff
();
});
});
}
}
...
@@ -402,12 +423,12 @@ class ASP {
...
@@ -402,12 +423,12 @@ class ASP {
// console.log(_arr, arr);
// console.log(_arr, arr);
// 2.判断数据
// 2.判断数据
if
(
arr
.
length
<
2
)
{
if
(
arr
.
length
<
2
)
{
return
console
.
log
(
'数据不正确'
);
return
toastr
.
error
(
LANG
[
'result'
][
'error'
][
'parse'
],
LANG_T
[
'error'
]
);
};
};
// 3.行头
// 3.行头
let
header_arr
=
arr
[
0
].
split
(
'
\
t|
\
t'
);
let
header_arr
=
arr
[
0
].
split
(
'
\
t|
\
t'
);
if
(
header_arr
.
length
===
1
)
{
if
(
header_arr
.
length
===
1
)
{
return
toastr
.
warning
(
'没有查询结果'
);
return
toastr
.
warning
(
LANG
[
'result'
][
'error'
][
'noresult'
],
LANG_T
[
'warning'
]
);
};
};
if
(
header_arr
[
header_arr
.
length
-
1
]
===
'
\
r'
)
{
if
(
header_arr
[
header_arr
.
length
-
1
]
===
'
\
r'
)
{
header_arr
.
pop
();
header_arr
.
pop
();
...
@@ -446,11 +467,13 @@ class ASP {
...
@@ -446,11 +467,13 @@ class ASP {
// 禁用toolbar按钮
// 禁用toolbar按钮
disableToolbar
()
{
disableToolbar
()
{
this
.
manager
.
list
.
toolbar
.
disableItem
(
'del'
);
this
.
manager
.
list
.
toolbar
.
disableItem
(
'del'
);
this
.
manager
.
list
.
toolbar
.
disableItem
(
'edit'
);
}
}
// 启用toolbar按钮
// 启用toolbar按钮
enableToolbar
()
{
enableToolbar
()
{
this
.
manager
.
list
.
toolbar
.
enableItem
(
'del'
);
this
.
manager
.
list
.
toolbar
.
enableItem
(
'del'
);
this
.
manager
.
list
.
toolbar
.
enableItem
(
'edit'
);
}
}
// 禁用SQL编辑框
// 禁用SQL编辑框
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment