Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
gateway-ui
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
ui
gateway-ui
Commits
68a2195c
Commit
68a2195c
authored
Dec 23, 2019
by
郝聪敏
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加prettier
parent
9216a9cc
Changes
15
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
3125 additions
and
2972 deletions
+3125
-2972
.eslintrc.js
.eslintrc.js
+4
-1
package-lock.json
package-lock.json
+2878
-2772
package.json
package.json
+3
-0
App.vue
src/App.vue
+3
-3
mainconfigguration.server.js
src/api/mainconfigguration.server.js
+45
-27
user.api.js
src/api/user.api.js
+10
-10
home.vue
src/components/home.vue
+43
-34
login.vue
src/components/login.vue
+61
-52
env.config.js
src/config/env.config.js
+2
-4
index.js
src/config/index.js
+4
-1
prod.config.js
src/config/prod.config.js
+2
-4
main.js
src/main.js
+10
-10
index.js
src/router/index.js
+13
-13
http.service.js
src/services/http.service.js
+30
-27
localStorage.service.js
src/services/localStorage.service.js
+17
-14
No files found.
.eslintrc.js
View file @
68a2195c
...
@@ -9,13 +9,16 @@ module.exports = {
...
@@ -9,13 +9,16 @@ module.exports = {
extends
:
[
extends
:
[
'
plugin:vue/essential
'
,
'
plugin:vue/essential
'
,
'
standard
'
,
'
standard
'
,
'
prettier
'
,
],
],
plugins
:
[
plugins
:
[
'
vue
'
,
'
vue
'
,
'
prettier
'
,
],
],
rules
:
{
rules
:
{
'
prettier/prettier
'
:
'
error
'
,
// 防止iview的标签报错
// 防止iview的标签报错
"
vue/no-parsing-error
"
:
[
2
,
{
"
x-invalid-end-tag
"
:
false
}],
'
vue/no-parsing-error
'
:
[
2
,
{
'
x-invalid-end-tag
'
:
false
}],
},
},
}
}
package-lock.json
View file @
68a2195c
This diff is collapsed.
Click to expand it.
package.json
View file @
68a2195c
...
@@ -41,11 +41,13 @@
...
@@ -41,11 +41,13 @@
"
cross-spawn
"
:
"
^5.0.1
"
,
"
cross-spawn
"
:
"
^5.0.1
"
,
"
css-loader
"
:
"
^0.28.0
"
,
"
css-loader
"
:
"
^0.28.0
"
,
"
eslint
"
:
"
^5.16.0
"
,
"
eslint
"
:
"
^5.16.0
"
,
"
eslint-config-prettier
"
:
"
^6.7.0
"
,
"
eslint-config-standard
"
:
"
^10.2.1
"
,
"
eslint-config-standard
"
:
"
^10.2.1
"
,
"
eslint-friendly-formatter
"
:
"
^3.0.0
"
,
"
eslint-friendly-formatter
"
:
"
^3.0.0
"
,
"
eslint-loader
"
:
"
^1.9.0
"
,
"
eslint-loader
"
:
"
^1.9.0
"
,
"
eslint-plugin-import
"
:
"
^2.19.1
"
,
"
eslint-plugin-import
"
:
"
^2.19.1
"
,
"
eslint-plugin-node
"
:
"
^5.2.1
"
,
"
eslint-plugin-node
"
:
"
^5.2.1
"
,
"
eslint-plugin-prettier
"
:
"
^3.1.2
"
,
"
eslint-plugin-promise
"
:
"
^3.8.0
"
,
"
eslint-plugin-promise
"
:
"
^3.8.0
"
,
"
eslint-plugin-standard
"
:
"
^3.1.0
"
,
"
eslint-plugin-standard
"
:
"
^3.1.0
"
,
"
eslint-plugin-vue
"
:
"
^6.0.1
"
,
"
eslint-plugin-vue
"
:
"
^6.0.1
"
,
...
@@ -63,6 +65,7 @@
...
@@ -63,6 +65,7 @@
"
postcss-import
"
:
"
^11.0.0
"
,
"
postcss-import
"
:
"
^11.0.0
"
,
"
postcss-loader
"
:
"
^2.0.8
"
,
"
postcss-loader
"
:
"
^2.0.8
"
,
"
postcss-url
"
:
"
^7.2.1
"
,
"
postcss-url
"
:
"
^7.2.1
"
,
"
prettier
"
:
"
^1.19.1
"
,
"
rimraf
"
:
"
^2.6.0
"
,
"
rimraf
"
:
"
^2.6.0
"
,
"
selenium-server
"
:
"
^3.0.1
"
,
"
selenium-server
"
:
"
^3.0.1
"
,
"
semver
"
:
"
^5.3.0
"
,
"
semver
"
:
"
^5.3.0
"
,
...
...
src/App.vue
View file @
68a2195c
...
@@ -6,13 +6,13 @@
...
@@ -6,13 +6,13 @@
<
script
>
<
script
>
export
default
{
export
default
{
name
:
'
App
'
name
:
"
App
"
}
}
;
</
script
>
</
script
>
<
style
>
<
style
>
#app
{
#app
{
font-family
:
'Avenir'
,
Helvetica
,
Arial
,
sans-serif
;
font-family
:
"Avenir"
,
Helvetica
,
Arial
,
sans-serif
;
-webkit-font-smoothing
:
antialiased
;
-webkit-font-smoothing
:
antialiased
;
-moz-osx-font-smoothing
:
grayscale
;
-moz-osx-font-smoothing
:
grayscale
;
/* text-align: center;
/* text-align: center;
...
...
src/api/mainconfigguration.server.js
View file @
68a2195c
import
axios
from
'
../services/http.service
'
import
axios
from
"
../services/http.service
"
;
import
{
import
{
sapi
}
from
"
../config
"
;
sapi
import
qs
from
"
qs
"
;
}
from
'
../config
'
import
qs
from
'
qs
'
// 获取服务列表
// 获取服务列表
export
function
getservicelist
()
{
export
function
getservicelist
()
{
return
axios
.
get
(
`/heimdallr/service/list`
)
return
axios
.
get
(
`/heimdallr/service/list`
)
;
}
}
// 获取文字说明
// 获取文字说明
export
function
getkey
(
key
)
{
export
function
getkey
(
key
)
{
return
axios
.
get
(
`/heimdallr/get-key-explain/
${
key
}
`
)
return
axios
.
get
(
`/heimdallr/get-key-explain/
${
key
}
`
)
;
}
}
// 获取配置列表
// 获取配置列表
export
function
getconfigurelist
(
data
)
{
export
function
getconfigurelist
(
data
)
{
return
axios
.
get
(
`/heimdallr/config/service/
${
data
.
key
}
/
${
data
.
service_name
}
`
)
return
axios
.
get
(
`/heimdallr/config/service/
${
data
.
key
}
/
${
data
.
service_name
}
`
);
}
}
// 发布
// 发布
export
function
postconfigurelist
(
data
,
params
)
{
export
function
postconfigurelist
(
data
,
params
)
{
return
axios
.
post
(
`/heimdallr/config/service/
${
data
.
key
}
/
${
data
.
service_name
}
`
,
params
,
{
headers
:
{
return
axios
.
post
(
'
Content-Type
'
:
'
application/json
'
`/heimdallr/config/service/
${
data
.
key
}
/
${
data
.
service_name
}
`
,
}})
params
,
{
headers
:
{
"
Content-Type
"
:
"
application/json
"
}
}
);
}
}
// 获取版本
// 获取版本
export
function
getVersionnumber
(
data
)
{
export
function
getVersionnumber
(
data
)
{
return
axios
.
get
(
`/heimdallr/config-version/service/
${
data
.
key
}
/
${
data
.
service_name
}
/list`
)
return
axios
.
get
(
`/heimdallr/config-version/service/
${
data
.
key
}
/
${
data
.
service_name
}
/list`
);
}
}
// 回滚版本
// 回滚版本
export
function
rollbacknum
(
data
)
{
export
function
rollbacknum
(
data
)
{
return
axios
.
get
(
`/heimdallr/config-version/service/
${
data
.
key
}
/
${
data
.
service_name
}
/set/
${
data
.
version
}
`
)
return
axios
.
get
(
`/heimdallr/config-version/service/
${
data
.
key
}
/
${
data
.
service_name
}
/set/
${
data
.
version
}
`
);
}
}
// 获取节点列表
// 获取节点列表
export
function
getnodelist
(
data
)
{
export
function
getnodelist
(
data
)
{
return
axios
.
get
(
`/heimdallr/node/list/
${
data
.
service_name
}
`
)
return
axios
.
get
(
`/heimdallr/node/list/
${
data
.
service_name
}
`
)
;
}
}
// 获取节点配置
// 获取节点配置
export
function
getnodeconfig
(
data
)
{
export
function
getnodeconfig
(
data
)
{
return
axios
.
get
(
`/heimdallr/config/node/
${
data
.
service_name
}
/
${
data
.
node_id
}
`
)
return
axios
.
get
(
`/heimdallr/config/node/
${
data
.
service_name
}
/
${
data
.
node_id
}
`
);
}
}
// 设置节点配置
// 设置节点配置
export
function
nodeconfig
(
data
,
weight
)
{
export
function
nodeconfig
(
data
,
weight
)
{
return
axios
.
post
(
`/heimdallr/config/node/
${
data
.
service_name
}
/
${
data
.
node_id
}
`
,
weight
,
{
headers
:
{
return
axios
.
post
(
'
Content-Type
'
:
'
application/json
'
`/heimdallr/config/node/
${
data
.
service_name
}
/
${
data
.
node_id
}
`
,
}})
weight
,
{
headers
:
{
"
Content-Type
"
:
"
application/json
"
}
}
);
}
}
src/api/user.api.js
View file @
68a2195c
import
axios
from
'
../services/http.service
'
import
axios
from
"
../services/http.service
"
;
import
{
import
{
sapi
}
from
"
../config
"
;
sapi
export
function
login
(
data
)
{
}
from
'
../config
'
return
axios
.
get
(
`/heimdallr/login`
,
{
export
function
login
(
data
)
{
headers
:
{
return
axios
.
get
(
`/heimdallr/login`
,
{
headers
:
{
"
heimdallr-user
"
:
data
'
heimdallr-user
'
:
data
}
}
})
}
);
}
}
export
function
logout
()
{
export
function
logout
()
{
return
axios
.
get
(
`/heimdallr/logout`
)
return
axios
.
get
(
`/heimdallr/logout`
)
;
}
}
src/components/home.vue
View file @
68a2195c
<
template
>
<
template
>
<div
class=
"layout"
>
<div
class=
"layout"
>
<Layout
class=
"layout_content"
>
<Layout
class=
"layout_content"
>
<Sider
breakpoint=
"md"
collapsible
:collapsed-width=
"78"
v-model=
"isCollapsed"
>
<Sider
breakpoint=
"md"
collapsible
:collapsed-width=
"78"
v-model=
"isCollapsed"
>
<div
class=
"title"
>
<div
class=
"title"
>
Quantgroup
Quantgroup
</div>
</div>
<Menu
active-name=
"1-2"
theme=
"dark"
width=
"auto"
:class=
"menuitemClasses"
>
<Menu
active-name=
"1-2"
theme=
"dark"
width=
"auto"
:class=
"menuitemClasses"
>
<MenuItem
name=
"1-1"
>
<MenuItem
name=
"1-1"
>
<Icon
type=
"ios-navigate"
></Icon>
<Icon
type=
"ios-navigate"
></Icon>
<span
@
click=
"go"
>
网关配置
</span>
<span
@
click=
"go"
>
网关配置
</span>
...
@@ -25,7 +35,9 @@
...
@@ -25,7 +35,9 @@
<Header
class=
"layout-header-bar"
>
<Header
class=
"layout-header-bar"
>
<span
class=
"signout"
@
click=
"logOut"
>
退出
</span>
<span
class=
"signout"
@
click=
"logOut"
>
退出
</span>
</Header>
</Header>
<Content
:style=
"
{margin: '20px', background: '#fff', minHeight: '220px'}">
<Content
:style=
"
{ margin: '20px', background: '#fff', minHeight: '220px' }"
>
<router-view></router-view>
<router-view></router-view>
</Content>
</Content>
</Layout>
</Layout>
...
@@ -33,35 +45,32 @@
...
@@ -33,35 +45,32 @@
</div>
</div>
</
template
>
</
template
>
<
script
>
<
script
>
import
{
logout
}
from
'
../api/user.api
'
import
{
logout
}
from
"
../api/user.api
"
;
export
default
{
export
default
{
data
()
{
data
()
{
return
{
return
{
isCollapsed
:
false
isCollapsed
:
false
}
}
;
},
},
computed
:
{
computed
:
{
menuitemClasses
:
function
()
{
menuitemClasses
:
function
()
{
return
[
return
[
"
menu-item
"
,
this
.
isCollapsed
?
"
collapsed-menu
"
:
""
];
'
menu-item
'
,
this
.
isCollapsed
?
'
collapsed-menu
'
:
''
]
}
}
},
},
methods
:
{
methods
:
{
go
()
{
go
()
{
this
.
$router
.
push
(
'
/mainconfiguration
'
)
this
.
$router
.
push
(
"
/mainconfiguration
"
);
},
},
logOut
()
{
logOut
()
{
logout
().
then
(
(
data
)
=>
{
logout
().
then
(
data
=>
{
this
.
$router
.
push
(
'
/
'
)
this
.
$router
.
push
(
"
/
"
);
})
})
;
}
}
}
}
}
}
;
</
script
>
</
script
>
<
style
scoped
>
<
style
scoped
>
.layout
{
.layout
{
border
:
1px
solid
#d7dde4
;
border
:
1px
solid
#d7dde4
;
background
:
#f5f7f9
;
background
:
#f5f7f9
;
position
:
relative
;
position
:
relative
;
...
@@ -69,45 +78,45 @@ export default {
...
@@ -69,45 +78,45 @@ export default {
overflow
:
hidden
;
overflow
:
hidden
;
height
:
100%
;
height
:
100%
;
}
}
.layout_content
{
.layout_content
{
height
:
100%
height
:
100%
;
}
}
.layout-header-bar
{
.layout-header-bar
{
background
:
#fff
;
background
:
#fff
;
box-shadow
:
0
1px
1px
rgba
(
0
,
0
,
0
,
.1
);
box-shadow
:
0
1px
1px
rgba
(
0
,
0
,
0
,
0
.1
);
}
}
.menu-item
span
{
.menu-item
span
{
display
:
inline-block
;
display
:
inline-block
;
overflow
:
hidden
;
overflow
:
hidden
;
width
:
69px
;
width
:
69px
;
text-overflow
:
ellipsis
;
text-overflow
:
ellipsis
;
white-space
:
nowrap
;
white-space
:
nowrap
;
vertical-align
:
bottom
;
vertical-align
:
bottom
;
transition
:
width
.2s
ease
.2s
;
transition
:
width
0.2s
ease
0
.2s
;
}
}
.menu-item
i
{
.menu-item
i
{
transform
:
translateX
(
0px
);
transform
:
translateX
(
0px
);
transition
:
font-size
.2s
ease
,
transform
.2s
ease
;
transition
:
font-size
0.2s
ease
,
transform
0
.2s
ease
;
vertical-align
:
middle
;
vertical-align
:
middle
;
font-size
:
16px
;
font-size
:
16px
;
}
}
.collapsed-menu
span
{
.collapsed-menu
span
{
width
:
0px
;
width
:
0px
;
transition
:
width
.2s
ease
;
transition
:
width
0
.2s
ease
;
}
}
.collapsed-menu
i
{
.collapsed-menu
i
{
transform
:
translateX
(
5px
);
transform
:
translateX
(
5px
);
transition
:
font-size
.2s
ease
.2s
,
transform
.2s
ease
.2s
;
transition
:
font-size
0.2s
ease
0.2s
,
transform
0.2s
ease
0
.2s
;
vertical-align
:
middle
;
vertical-align
:
middle
;
font-size
:
22px
;
font-size
:
22px
;
}
}
.signout
{
.signout
{
font-size
:
16px
;
font-size
:
16px
;
float
:
right
;
float
:
right
;
margin-right
:
30px
;
margin-right
:
30px
;
color
:
#0092ff
color
:
#0092ff
;
}
}
.title
{
.title
{
width
:
100%
;
width
:
100%
;
height
:
60px
;
height
:
60px
;
line-height
:
60px
;
line-height
:
60px
;
...
...
src/components/login.vue
View file @
68a2195c
...
@@ -4,12 +4,20 @@
...
@@ -4,12 +4,20 @@
<div
class=
"login"
>
<div
class=
"login"
>
<Form
ref=
"loginForm"
:model=
"loginForm"
:rules=
"ruleLoginForm"
>
<Form
ref=
"loginForm"
:model=
"loginForm"
:rules=
"ruleLoginForm"
>
<FormItem
prop=
"loginName"
>
<FormItem
prop=
"loginName"
>
<Input
v-model=
"loginForm.loginName"
type=
"text"
placeholder=
"Username"
>
<Input
v-model=
"loginForm.loginName"
type=
"text"
placeholder=
"Username"
>
<Icon
type=
"ios-person-outline"
slot=
"prepend"
></Icon>
<Icon
type=
"ios-person-outline"
slot=
"prepend"
></Icon>
</Input>
</Input>
</FormItem>
</FormItem>
<FormItem
prop=
"password"
>
<FormItem
prop=
"password"
>
<Input
type=
"password"
v-model=
"loginForm.password"
placeholder=
"Password"
>
<Input
type=
"password"
v-model=
"loginForm.password"
placeholder=
"Password"
>
<Icon
type=
"ios-lock-outline"
slot=
"prepend"
></Icon>
<Icon
type=
"ios-lock-outline"
slot=
"prepend"
></Icon>
</Input>
</Input>
</FormItem>
</FormItem>
...
@@ -17,86 +25,87 @@
...
@@ -17,86 +25,87 @@
<Button
@
click=
"login()"
type=
"primary"
long
>
登录
</Button>
<Button
@
click=
"login()"
type=
"primary"
long
>
登录
</Button>
</FormItem>
</FormItem>
</Form>
</Form>
<div
style=
"margin-top: 20px; color: #999; font-size: 10px;"
>
<div
style=
"margin-top: 20px; color: #999; font-size: 10px;"
></div>
</div>
</div>
</div>
</div>
</div>
</
template
>
</
template
>
<
script
>
<
script
>
import
{
login
}
from
'
../api/user.api
'
import
{
login
}
from
"
../api/user.api
"
;
import
localStorage
from
'
../services/localStorage.service.js
'
import
localStorage
from
"
../services/localStorage.service.js
"
;
export
default
{
export
default
{
data
()
{
data
()
{
var
that
=
this
var
that
=
this
;
const
validateMenuClassifyId
=
(
rule
,
value
,
callback
)
=>
{
const
validateMenuClassifyId
=
(
rule
,
value
,
callback
)
=>
{
if
(
this
.
status
)
{
if
(
this
.
status
)
{
callback
(
new
Error
(
'
用户名或密码错误
'
))
callback
(
new
Error
(
"
用户名或密码错误
"
));
this
.
status
=
false
this
.
status
=
false
;
}
else
{
}
else
{
callback
()
callback
();
}
}
}
};
return
{
return
{
loginForm
:
{
loginForm
:
{
loginName
:
''
,
loginName
:
""
,
password
:
''
password
:
""
},
},
error
:
''
,
error
:
""
,
status
:
false
,
status
:
false
,
ruleLoginForm
:
{
ruleLoginForm
:
{
loginName
:
[
loginName
:
[
{
required
:
true
,
message
:
'
请输入用户名
'
,
trigger
:
'
blur
'
}
{
required
:
true
,
message
:
"
请输入用户名
"
,
trigger
:
"
blur
"
}
],
],
password
:
[
password
:
[
{
required
:
true
,
message
:
'
请输入密码
'
,
trigger
:
'
blur
'
},
{
required
:
true
,
message
:
"
请输入密码
"
,
trigger
:
"
blur
"
},
{
required
:
true
,
validator
:
validateMenuClassifyId
,
trigger
:
'
blur
'
}
{
required
:
true
,
validator
:
validateMenuClassifyId
,
trigger
:
"
blur
"
}
]
]
}
}
}
}
;
},
},
methods
:
{
methods
:
{
login
()
{
login
()
{
this
.
$refs
[
'
loginForm
'
].
validate
((
valid
)
=>
{
this
.
$refs
[
"
loginForm
"
].
validate
(
valid
=>
{
if
(
valid
)
{
if
(
valid
)
{
let
data
=
btoa
(
`
${
this
.
loginForm
.
loginName
}
:
${
this
.
loginForm
.
password
}
`
)
let
data
=
btoa
(
login
(
data
).
then
((
data
)
=>
{
`
${
this
.
loginForm
.
loginName
}
:
${
this
.
loginForm
.
password
}
`
);
login
(
data
).
then
(
data
=>
{
if
(
data
.
code
===
400
)
{
if
(
data
.
code
===
400
)
{
this
.
error
=
data
.
body
this
.
error
=
data
.
body
;
this
.
status
=
true
this
.
status
=
true
;
this
.
$refs
[
'
loginForm
'
].
validate
()
this
.
$refs
[
"
loginForm
"
].
validate
();
}
else
{
}
else
{
this
.
status
=
false
this
.
status
=
false
;
localStorage
.
set
(
'
heimdallr-token
'
,
data
.
body
[
'
heimdallr-token
'
])
localStorage
.
set
(
"
heimdallr-token
"
,
data
.
body
[
"
heimdallr-token
"
]);
this
.
$Message
.
success
(
'
登陆成功
'
)
this
.
$Message
.
success
(
"
登陆成功
"
);
this
.
$router
.
push
(
'
/mainconfiguration
'
)
this
.
$router
.
push
(
"
/mainconfiguration
"
);
}
}
})
})
;
}
}
})
})
;
}
}
}
}
}
}
;
</
script
>
</
script
>
<
style
scoped
>
<
style
scoped
>
.wrapper
{
.wrapper
{
position
:
relative
;
position
:
relative
;
width
:
100%
;
width
:
100%
;
height
:
100%
;
height
:
100%
;
padding-top
:
100px
;
padding-top
:
100px
;
padding-bottom
:
200px
;
padding-bottom
:
200px
;
}
}
.wrapper
>
h1
{
.wrapper
>
h1
{
text-align
:
center
;
text-align
:
center
;
vertical-align
:
middle
;
vertical-align
:
middle
;
margin-bottom
:
20px
;
margin-bottom
:
20px
;
color
:
#000
;
color
:
#000
;
}
}
.login
{
.login
{
margin
:
0
auto
;
margin
:
0
auto
;
padding-top
:
15px
;
padding-top
:
15px
;
width
:
360px
;
width
:
360px
;
height
:
100%
;
height
:
100%
;
}
}
</
style
>
</
style
>
src/config/env.config.js
View file @
68a2195c
const
sapi
=
'
http://heimdallr-arch.liangkebang.net
'
const
sapi
=
"
http://heimdallr-arch.liangkebang.net
"
;
// const sapi = 'http://192.168.29.88:5555'
// const sapi = 'http://192.168.29.88:5555'
export
{
export
{
sapi
};
sapi
}
src/config/index.js
View file @
68a2195c
module
.
exports
=
process
.
env
.
NODE_ENV
===
'
production
'
?
require
(
'
./prod.config.js
'
)
:
require
(
'
./env.config.js
'
)
module
.
exports
=
process
.
env
.
NODE_ENV
===
"
production
"
?
require
(
"
./prod.config.js
"
)
:
require
(
"
./env.config.js
"
);
src/config/prod.config.js
View file @
68a2195c
const
sapi
=
'
//api.stantoo.com
'
const
sapi
=
"
//api.stantoo.com
"
;
export
{
export
{
sapi
};
sapi
}
src/main.js
View file @
68a2195c
// The Vue build version to load with the `import` command
// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import
Vue
from
'
vue
'
import
Vue
from
"
vue
"
;
import
App
from
'
./App
'
import
App
from
"
./App
"
;
import
router
from
'
./router
'
import
router
from
"
./router
"
;
import
iView
from
'
iview
'
import
iView
from
"
iview
"
;
import
'
iview/dist/styles/iview.css
'
import
"
iview/dist/styles/iview.css
"
;
Vue
.
use
(
iView
)
Vue
.
use
(
iView
)
;
Vue
.
config
.
productionTip
=
false
Vue
.
config
.
productionTip
=
false
;
/* eslint-disable no-new */
/* eslint-disable no-new */
new
Vue
({
new
Vue
({
el
:
'
#app
'
,
el
:
"
#app
"
,
router
,
router
,
components
:
{
App
},
components
:
{
App
},
template
:
'
<App/>
'
template
:
"
<App/>
"
})
})
;
src/router/index.js
View file @
68a2195c
import
Vue
from
'
vue
'
import
Vue
from
"
vue
"
;
import
Router
from
'
vue-router
'
import
Router
from
"
vue-router
"
;
import
login
from
'
@/components/login
'
import
login
from
"
@/components/login
"
;
import
home
from
'
@/components/home
'
import
home
from
"
@/components/home
"
;
import
mainconfiguration
from
'
../pages/mainconfiguration/mainconfiguration.vue
'
import
mainconfiguration
from
"
../pages/mainconfiguration/mainconfiguration.vue
"
;
Vue
.
use
(
Router
)
Vue
.
use
(
Router
)
;
export
default
new
Router
({
export
default
new
Router
({
routes
:
[
routes
:
[
{
{
path
:
'
/
'
,
path
:
"
/
"
,
name
:
'
login
'
,
name
:
"
login
"
,
component
:
login
component
:
login
},
},
{
{
path
:
'
/home
'
,
path
:
"
/home
"
,
name
:
'
home
'
,
name
:
"
home
"
,
component
:
home
,
component
:
home
,
children
:
[
children
:
[
{
{
path
:
'
/mainconfiguration
'
,
path
:
"
/mainconfiguration
"
,
name
:
'
mainconfiguration
'
,
name
:
"
mainconfiguration
"
,
component
:
mainconfiguration
component
:
mainconfiguration
}
}
]
]
}
}
]
]
})
})
;
src/services/http.service.js
View file @
68a2195c
import
axios
from
'
axios
'
import
axios
from
"
axios
"
;
import
{
Notice
}
from
'
iview
'
import
{
Notice
}
from
"
iview
"
;
import
localStorage
from
'
./localStorage.service
'
import
localStorage
from
"
./localStorage.service
"
;
// window.Promise = require('es6-promise').Promise
// window.Promise = require('es6-promise').Promise
const
config
=
{
const
config
=
{
timeout
:
600000
timeout
:
600000
// withCredentials: true // 允许携带cookie
// withCredentials: true // 允许携带cookie
}
}
;
const
instance
=
axios
.
create
(
Object
.
assign
({},
config
))
const
instance
=
axios
.
create
(
Object
.
assign
({},
config
))
;
instance
.
_extend
=
{}
instance
.
_extend
=
{}
;
function
requestInterceptor
(
config
)
{
function
requestInterceptor
(
config
)
{
config
.
headers
[
'
x-requested-with
'
]
=
'
XMLHttpRequest
'
config
.
headers
[
"
x-requested-with
"
]
=
"
XMLHttpRequest
"
;
// if (!config.headers['Content-Type']) {
// if (!config.headers['Content-Type']) {
// config.headers['Content-Type'] = 'application/x-www-form-urlencoded'
// config.headers['Content-Type'] = 'application/x-www-form-urlencoded'
// }
// }
if
(
!
config
.
headers
[
'
heimdallr-token
'
])
{
if
(
!
config
.
headers
[
"
heimdallr-token
"
])
{
config
.
headers
[
'
heimdallr-token
'
]
=
localStorage
.
get
(
'
heimdallr-token
'
)
||
''
config
.
headers
[
"
heimdallr-token
"
]
=
localStorage
.
get
(
"
heimdallr-token
"
)
||
""
;
}
}
return
config
return
config
;
}
}
function
responseInterceptor
(
response
)
{
function
responseInterceptor
(
response
)
{
if
(
response
.
status
<
200
||
response
.
status
>
300
)
{
if
(
response
.
status
<
200
||
response
.
status
>
300
)
{
Notice
.
error
({
Notice
.
error
({
title
:
'
请求发生错误
'
,
title
:
"
请求发生错误
"
,
desc
:
response
&&
response
.
data
&&
response
.
data
.
errorMsg
||
'
请联系系统管理员
'
desc
:
})
(
response
&&
response
.
data
&&
response
.
data
.
errorMsg
)
||
return
Promise
.
reject
(
response
&&
response
.
data
)
"
请联系系统管理员
"
});
return
Promise
.
reject
(
response
&&
response
.
data
);
}
}
// code是0000表示成功
// code是0000表示成功
if
(
response
.
data
.
code
===
200
||
response
.
data
.
code
===
400
)
{
if
(
response
.
data
.
code
===
200
||
response
.
data
.
code
===
400
)
{
return
Promise
.
resolve
(
response
.
data
||
null
)
return
Promise
.
resolve
(
response
.
data
||
null
)
;
}
}
// Notice.error({
// Notice.error({
// title: '',
// title: '',
// desc: response.data.errorMsg || response.data.message || '请联系客服'
// desc: response.data.errorMsg || response.data.message || '请联系客服'
// })
// })
return
Promise
.
reject
(
response
&&
response
.
data
)
return
Promise
.
reject
(
response
&&
response
.
data
)
;
}
}
/**
/**
...
@@ -50,22 +53,22 @@ function responseInterceptor (response) {
...
@@ -50,22 +53,22 @@ function responseInterceptor (response) {
* axios.interceptors.request.eject(0)
* axios.interceptors.request.eject(0)
* axios.interceptors.response.eject(0)
* axios.interceptors.response.eject(0)
*/
*/
instance
.
interceptors
.
request
.
use
(
requestInterceptor
,
(
error
)
=>
{
instance
.
interceptors
.
request
.
use
(
requestInterceptor
,
error
=>
{
// return Promise.reject(error)
// return Promise.reject(error)
})
})
;
instance
.
interceptors
.
response
.
use
(
responseInterceptor
,
error
=>
{
instance
.
interceptors
.
response
.
use
(
responseInterceptor
,
error
=>
{
if
(
error
.
response
&&
error
.
response
.
status
===
401
)
{
if
(
error
.
response
&&
error
.
response
.
status
===
401
)
{
window
.
location
.
href
=
window
.
location
.
origin
+
'
/login
'
window
.
location
.
href
=
window
.
location
.
origin
+
"
/login
"
;
}
}
if
(
error
.
message
.
indexOf
(
'
timeout
'
)
!==
-
1
)
{
if
(
error
.
message
.
indexOf
(
"
timeout
"
)
!==
-
1
)
{
Notice
.
error
({
Notice
.
error
({
title
:
''
,
title
:
""
,
desc
:
'
请求超时
'
desc
:
"
请求超时
"
})
})
;
}
}
// return Promise.reject(error)
// return Promise.reject(error)
})
})
;
export
default
instance
export
default
instance
;
src/services/localStorage.service.js
View file @
68a2195c
export
default
{
export
default
{
get
(
key
)
{
get
(
key
)
{
let
result
=
localStorage
.
getItem
(
key
)
let
result
=
localStorage
.
getItem
(
key
)
;
try
{
try
{
result
=
JSON
.
parse
(
result
)
result
=
JSON
.
parse
(
result
)
;
}
catch
(
e
)
{}
}
catch
(
e
)
{}
return
result
return
result
;
},
},
set
(
key
,
value
)
{
set
(
key
,
value
)
{
let
toString
=
Object
.
prototype
.
toString
let
toString
=
Object
.
prototype
.
toString
;
if
(
toString
.
call
(
value
)
===
'
[object Array]
'
||
toString
.
call
(
value
)
===
'
[object Object]
'
)
{
if
(
value
=
JSON
.
stringify
(
value
)
toString
.
call
(
value
)
===
"
[object Array]
"
||
toString
.
call
(
value
)
===
"
[object Object]
"
)
{
value
=
JSON
.
stringify
(
value
);
}
}
return
localStorage
.
setItem
(
key
,
value
)
return
localStorage
.
setItem
(
key
,
value
)
;
},
},
remove
(
key
)
{
remove
(
key
)
{
return
localStorage
.
removeItem
(
key
)
return
localStorage
.
removeItem
(
key
)
;
},
},
clear
()
{
clear
()
{
return
localStorage
.
clear
()
return
localStorage
.
clear
()
;
}
}
}
}
;
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