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
d89c9ebe
Commit
d89c9ebe
authored
Apr 16, 2016
by
antoor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactoring language template loading scheme
重构语言模板加载方案
parent
fb74243c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
46 additions
and
13 deletions
+46
-13
app.entry.jsx
source/app.entry.jsx
+30
-13
index.jsx
source/language/index.jsx
+16
-0
No files found.
source/app.entry.jsx
View file @
d89c9ebe
/
/
/
**
//
程序入口
* 中国蚁剑::
程序入口
// -------
* 创建:2015/12/20
// create: 2015/12/20
* 更新:2016/04/16
// update: 2016/04/02
* 作者:蚁逅 <https://github.com/antoor>
/
/
*
/
'use strict'
;
'use strict'
;
...
@@ -15,13 +15,32 @@ import Menubar from './base/menubar';
...
@@ -15,13 +15,32 @@ import Menubar from './base/menubar';
import
CacheManager
from
'./base/cachemanager'
;
import
CacheManager
from
'./base/cachemanager'
;
const
antSword
=
window
.
antSword
=
{
const
antSword
=
window
.
antSword
=
{
/**
* XSS过滤函数
* @param {String} html 过滤前字符串
* @return {String} 过滤后的字符串
*/
noxss
:
(
html
)
=>
{
noxss
:
(
html
)
=>
{
return
String
(
html
).
replace
(
/&/g
,
"&"
).
replace
(
/>/g
,
">"
).
replace
(
/</g
,
"<"
).
replace
(
/"/g
,
"""
);
return
String
(
html
).
replace
(
/&/g
,
"&"
).
replace
(
/>/g
,
">"
).
replace
(
/</g
,
"<"
).
replace
(
/"/g
,
"""
);
},
},
/**
* 核心模块
* @type {Object}
*/
core
:
{},
core
:
{},
/**
* 操作模块
* @type {Object}
*/
modules
:
{},
modules
:
{},
// localStorage存储
/**
// 参数{key:存储键值,[value]:存储内容,[def]:默认内容}
* localStorage存储API
* ? 如果只有一个key参数,则返回内容,否则进行设置
* @param {String} key 存储键值,必选
* @param {String} value 存储内容,可选
* @param {String} def 默认内容,可选
* @return {None} [description]
*/
storage
:
(
key
,
value
,
def
)
=>
{
storage
:
(
key
,
value
,
def
)
=>
{
// 读取
// 读取
if
(
!
value
)
{
if
(
!
value
)
{
...
@@ -32,13 +51,11 @@ const antSword = window.antSword = {
...
@@ -32,13 +51,11 @@ const antSword = window.antSword = {
}
}
};
};
// 加载
模板代码
// 加载
核心模板
antSword
[
'core'
]
=
require
(
'./core/index'
);
antSword
[
'core'
]
=
require
(
'./core/index'
);
// 加载显示语言
// 加载语言模板
let
_lang
=
localStorage
.
getItem
(
'language'
)
||
navigator
.
language
;
antSword
[
'language'
]
=
require
(
'./language/index'
);
_lang
=
[
'en'
,
'zh'
].
indexOf
(
_lang
)
===
-
1
?
'en'
:
_lang
;
antSword
[
'language'
]
=
require
(
`./language/
${
_lang
}
`
);
// 加载代理
// 加载代理
const
aproxy
=
{
const
aproxy
=
{
...
...
source/language/index.jsx
0 → 100644
View file @
d89c9ebe
/**
* 中国蚁剑::语言模板
*/
'use strict'
;
// 获取本地设置语言(如若没有,则获取浏览器语言
let
lang
=
antSword
[
'storage'
](
'language'
,
false
,
navigator
.
language
);
// 判断本地设置语言是否符合语言模板
lang
=
[
'en'
,
'zh'
].
indexOf
(
lang
)
===
-
1
?
'en'
:
lang
;
// 返回语言模板
module
.
exports
=
require
(
`./
${
lang
}
`
);
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