Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
micro-system
/
micro-portal
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 7c1910f2
authored
Oct 29, 2020
by
冒粤蓉
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
fix
1 parent
ea0bf46e
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
156 additions
and
85 deletions
src/App.vue
src/components/DesktopLeftSider/Sub/Menu.vue
src/components/DesktopLeftSider/Sub/NavInfoCard.vue
src/components/DesktopRightSider/DesktopRightSider.vue
src/components/DesktopTopSider/Sub/UserButton.vue
src/components/HomeContent/Sub/LoginForm.vue
src/micro/apps.js
src/router/index.js
src/services/Menu.js
src/utils/globalAnt/ant.js
src/utils/http/http.js
src/App.vue
View file @
7c1910f
<
template
>
<div
id=
"app"
>
<keep-alive>
<div>
<dashboard
v-if=
"hasToken"
></dashboard>
<login
v-else
></login>
<a-config-provider
:locale=
"zhCN"
>
<div
id=
"app"
>
<keep-alive>
<div>
<dashboard
v-if=
"hasToken"
></dashboard>
<login
v-else
></login>
<!-- 全局loading提示 -->
<loading
v-if=
"showLoading"
></loading>
</div>
</keep-alive>
</div>
<!-- 全局loading提示 -->
<loading
v-if=
"showLoading"
></loading>
</div>
</keep-alive>
</div>
</a-config-provider>
</
template
>
<
script
>
...
...
@@ -17,8 +19,6 @@ import Dashboard from '@/views/Dashboard';
import
Login
from
'@/views/Login'
;
import
Loading
from
'components/Loading/Loading'
;
// import BaseService from 'services/Base';
import
{
onCreated
,
onMounted
,
computed
,
reactive
,
toRefs
}
from
'vue'
;
import
{
useStore
}
from
'vuex'
;
...
...
@@ -32,14 +32,6 @@ export default {
},
setup
()
{
const
store
=
useStore
();
// const baseService = new BaseService();
// baseService.getBaseConfig().then((res) => {
// const baseURL = res.axios.baseURL;
// store.dispatch('app/updateBaseURL', baseURL);
// }, (err) => {
// });
let
hasToken
=
computed
(()
=>
{
return
!!
store
.
getters
.
token
;
...
...
src/components/DesktopLeftSider/Sub/Menu.vue
View file @
7c1910f
...
...
@@ -24,7 +24,7 @@
style="padding-left: 48px;"
v-for="cItem in item.children"
:key="cItem.origin.menuNo"
@click.stop="cItemClick(cItem.origin.path || '', cItem)">
@click.stop="cItemClick(cItem.origin.path || '', cItem
, item
)">
{{
cItem
.
origin
.
menuName
}}
</li>
</ul>
...
...
@@ -72,7 +72,7 @@ export default {
};
// 点击二级菜单标题
const
cItemClick
=
(
path
,
cItem
)
=>
{
const
cItemClick
=
(
path
,
cItem
,
parentItem
)
=>
{
const
cOrigin
=
cItem
.
origin
;
// 激活active类
state
.
menuList
.
forEach
(
ele
=>
{
...
...
@@ -83,12 +83,14 @@ export default {
})
cItem
.
subItemActive
=
true
;
state
.
curBreadCrumb
.
parent
[
'menuName'
]
=
state
.
curMainTitl
e
;
state
.
curBreadCrumb
.
parent
[
'menuName'
]
=
parentItem
.
origin
.
menuNam
e
;
state
.
curBreadCrumb
.
children
=
[{
menuName
:
cOrigin
.
menuName
,
path
:
cOrigin
.
path
||
''
,
active
:
true
}];
path
=
path
?
path
:
'/404'
;
history
.
pushState
(
null
,
path
,
path
);
}
...
...
src/components/DesktopLeftSider/Sub/NavInfoCard.vue
View file @
7c1910f
<
template
>
<div
class=
"info-card"
:class=
"
{ infoActive: !isNavFilterActive }">
<DownOutlined
class=
"arrow-icon"
@
click=
"downClicked"
/>
<div
class=
"info-card-content"
:style=
"
{width: collapsed? '80px' : '100%'}">
<!-- 用户卡片头像:缩小时点击会出现用户信息 v-if="collapsed" -->
<!--
<a-popover
placement=
"right"
v-if=
"collapsed"
>
<template
v-slot:content
>
<p>
{{
username
}}
</p>
<p>
{{
professionalTitle
}}
</p>
</
template
>
<a-avatar
class=
"info-card-avatar"
size=
"large"
:style=
"{marginRight: collapsed? '0' : '15px'}"
>
<div>
<div
class=
"info-card"
:class=
"
{ infoActive: !isNavFilterActive }">
<!--
<DownOutlined
class=
"arrow-icon"
@
click=
"downClicked"
/>
-->
<div
class=
"info-card-content"
:style=
"
{width: collapsed? '80px' : '100%'}">
<!-- 用户卡片头像:缩小时点击会出现用户信息 v-if="collapsed" -->
<!--
<a-popover
placement=
"right"
v-if=
"collapsed"
>
<template
v-slot:content
>
<p>
{{
username
}}
</p>
<p>
{{
professionalTitle
}}
</p>
</
template
>
<a-avatar
class=
"info-card-avatar"
size=
"large"
:style=
"{marginRight: collapsed? '0' : '15px'}"
>
<
template
v-slot:icon
>
<UserOutlined
/>
</
template
>
</a-avatar>
</a-popover>
-->
<!-- 未缩小无点击效果处理 v-if="!collapsed"-->
<a-avatar
class=
"info-card-avatar"
size=
"large"
:style=
"{marginRight: '15px'}"
>
<
template
v-slot:icon
>
<UserOutlined
/>
</
template
>
</a-avatar>
</a-popover>
-->
<!-- 未缩小无点击效果处理 v-if="!collapsed"-->
<a-avatar
class=
"info-card-avatar"
size=
"large"
:style=
"{marginRight: '15px'}"
>
<
template
v-slot:icon
>
<UserOutlined
/>
</
template
>
</a-avatar>
<div
class=
"flex-column info-card-user"
:style=
"{display: 'block'}"
>
<span
class=
"two-line-ellipsis"
>
{{username || '用户名啦啦啦'}}
</span>
<span
class=
"two-line-ellipsis"
>
{{professionalTitle || '管理员'}}
</span>
<div
class=
"flex-column info-card-user"
:style=
"{display: 'block'}"
>
<span
class=
"two-line-ellipsis"
>
{{username || '用户名啦啦啦'}}
</span>
<span
class=
"two-line-ellipsis"
>
{{professionalTitle || '管理员'}}
</span>
</div>
</div>
</div>
</div
>
<!-- 菜单搜索 --
>
<div
class=
"search-menu"
:class=
"{ navActive: isNavFilterActive }"
>
<a-input
class=
"search-menu-input"
v-model:value=
"value"
placeholder=
"菜单搜索
"
/>
<
UpCircleOutlined
class=
"icon-arrow"
@
click=
"upClicked"
/
>
<!-- 菜单搜索 --
>
<div
class=
"search-menu"
:class=
"{ navActive: isNavFilterActive }"
>
<a-input
class=
"search-menu-input"
v-model:value=
"value"
placeholder=
"菜单搜索"
/>
<UpCircleOutlined
class=
"icon-arrow"
@
click=
"upClicked
"
/>
<
/div
>
</div>
</template>
...
...
@@ -41,7 +43,7 @@ import {
DownOutlined
,
UserOutlined
}
from
'@ant-design/icons-vue'
;
import
{
reactive
,
toRefs
,
computed
}
from
'vue'
;
import
{
reactive
,
toRefs
,
computed
,
onMounted
}
from
'vue'
;
import
{
useStore
}
from
'vuex'
;
export
default
{
...
...
@@ -73,6 +75,12 @@ export default {
state
.
isNavFilterActive
=
true
;
};
onMounted
(()
=>
{
const
userInfo
=
store
.
getters
.
userInfo
;
state
.
username
=
userInfo
.
username
;
state
.
professionalTitle
=
userInfo
.
roleName
;
})
return
{
...
toRefs
(
state
),
upClicked
,
...
...
src/components/DesktopRightSider/DesktopRightSider.vue
View file @
7c1910f
...
...
@@ -11,14 +11,17 @@
{{
item
.
name
}}
</a-breadcrumb-item>
</a-breadcrumb>
<!--
<a-empty
/>
-->
<div
id=
"sub-system-frame"
></div>
<div
v-show=
"showEmpty"
>
<a-empty
:description=
"false"
/>
<h1
class=
"empty-text"
>
暂无数据
</h1>
</div>
<div
v-show=
"!showEmpty"
id=
"sub-system-frame"
ref=
"elmSubMicro"
></div>
</a-layout-content>
</
template
>
<
script
>
import
{
useStore
}
from
'vuex'
;
import
{
reactive
,
toRefs
,
computed
}
from
'vue'
;
import
{
reactive
,
toRefs
,
computed
,
watch
,
onMounted
,
ref
}
from
'vue'
;
export
default
{
...
...
@@ -26,7 +29,30 @@ export default {
components
:
{
},
setup
(
props
,
context
)
{
const
elmSubMicro
=
ref
(
null
);
const
state
=
reactive
({
el_sub_innerH
:
''
});
const
store
=
useStore
();
onMounted
(()
=>
{
state
.
el_sub_innerH
=
elmSubMicro
.
_value
.
innerHTML
;
// 监听子系统挂载的元素内容变化
const
subMircroEle
=
document
.
getElementById
(
'sub-system-frame'
);
subMircroEle
.
addEventListener
(
'DOMNodeInserted'
,
function
(
e
)
{
const
target
=
e
.
currentTarget
,
tarInner
=
target
.
innerHTML
;
if
(
!
state
.
el_sub_innerH
!==
!
tarInner
)
{
state
.
el_sub_innerH
=
target
.
innerHTML
;
}
})
})
const
showEmpty
=
computed
(()
=>
{
return
!
state
.
el_sub_innerH
;
})
const
breadCrumbList
=
computed
(()
=>
{
const
curBreadCrumb
=
store
.
getters
.
curBreadCrumb
,
curParent
=
curBreadCrumb
[
'parent'
],
...
...
@@ -64,6 +90,8 @@ export default {
return
{
breadCrumbList
,
elmSubMicro
,
showEmpty
// routerGo
}
}
...
...
@@ -71,6 +99,13 @@ export default {
</
script
>
<
style
lang=
"less"
scoped
>
@import
'styles/variables.less'
;
.ant-empty
{
margin-top
:
200px
;
}
.empty-text
{
text-align
:
center
;
}
.breadcrumb-item
{
cursor
:
context-menu
;
...
...
@@ -79,6 +114,10 @@ export default {
}
}
#sub-system-frame
{
min-width
:
1190px
;
}
.pointer
{
//
cursor
:
pointer
;
}
...
...
src/components/DesktopTopSider/Sub/UserButton.vue
View file @
7c1910f
<
template
>
<a-popover
title=
"我的"
trigger=
"click"
>
<template
slot=
"content"
>
<p>
登出
</p>
</
template
>
<a-avatar
class=
"top-nav-right-btn avatar-btn"
:size=
"35"
>
<
template
v-slot:icon
>
<UserOutlined
/>
<div
class=
"pop-over"
>
<a-popover
title=
""
trigger=
"click"
>
<template
v-slot:content
>
<div
@
click=
"logout"
class=
"pop-over-item"
>
登出
</div>
</
template
>
</a-avatar>
</a-popover>
<a-avatar
class=
"top-nav-right-btn avatar-btn"
:size=
"35"
>
<
template
v-slot:icon
>
<UserOutlined
/>
</
template
>
</a-avatar>
</a-popover>
</div>
</template>
<
script
>
...
...
@@ -16,19 +18,40 @@ import {
UserOutlined
}
from
'@ant-design/icons-vue'
;
import
{
reactive
,
toRefs
}
from
'vue'
;
import
{
useRouter
}
from
"vue-router"
;
import
{
useStore
}
from
'vuex'
;
export
default
{
name
:
'UserButton'
,
components
:
{
UserOutlined
},
setup
()
{
const
store
=
useStore
();
const
router
=
useRouter
();
// 登出操作
const
logout
=
()
=>
{
localStorage
.
removeItem
(
'token'
);
localStorage
.
removeItem
(
'userInfo'
);
store
.
dispatch
(
'app/setToken'
,
''
);
setTimeout
(()
=>
{
window
.
location
.
reload
();
},
300
)
}
return
{
logout
}
}
}
</
script
>
<
style
lang=
"less"
scoped
>
@import
'styles/common.less'
;
@import
'styles/variables.less'
;
/
deep
/
.ant-popover-arrow
{
display
:
none
!important
;
.pop-over-item
{
&:active,
&:hover
{
color
:
@
defaultLightBlueColor
;
}
}
.avatar-btn
{
...
...
src/components/HomeContent/Sub/LoginForm.vue
View file @
7c1910f
...
...
@@ -119,6 +119,7 @@ export default {
if
(
res
.
code
===
200
)
{
const
{
token
,
user
}
=
res
.
data
;
localStorage
.
setItem
(
'token'
,
token
);
localStorage
.
setItem
(
'userInfo'
,
JSON
.
stringify
(
user
));
store
.
dispatch
(
'app/setUserInfo'
,
user
);
store
.
dispatch
(
'app/setToken'
,
token
);
console
.
log
(
'save token'
,
token
);
...
...
@@ -134,7 +135,8 @@ export default {
};
const
captchaUrl
=
computed
(()
=>
{
return
`
${
store
.
getters
.
baseURL
}
/usercenter/captcha?rand=
${
state
.
randomVal
}
`
;
const
getBaseUrlFromStorage
=
localStorage
.
getItem
(
'BASE_URL'
);
return
`
${
store
.
getters
.
baseURL
||
getBaseUrlFromStorage
}
/usercenter/captcha?rand=
${
state
.
randomVal
}
`
;
})
const
updateCaptcha
=
debounce
(()
=>
{
...
...
src/micro/apps.js
View file @
7c1910f
...
...
@@ -2,6 +2,7 @@ import store from '@/store';
import
router
from
'@/router'
;
let
defaultApp
=
null
;
const
isDev
=
process
.
env
.
NODE_ENV
===
'development'
;
const
apps
=
[
/**
...
...
@@ -12,7 +13,7 @@ const apps = [
*/
{
name
:
"GLSXManagementSystemSub"
,
entry
:
"//localhost:10200"
,
entry
:
isDev
?
"//localhost:10200"
:
''
,
container
:
"#sub-system-frame"
,
activeRule
:
"/system"
,
props
:
{
...
...
src/router/index.js
View file @
7c1910f
...
...
@@ -30,17 +30,17 @@ const router = createRouter({
routes
})
// const childRoute = ['/vue','/react
'];
// const isChildRoute = path => childRoute.some(item => path.startsWith(item))
const
childRoute
=
[
'/system
'
];
const
isChildRoute
=
path
=>
childRoute
.
some
(
item
=>
path
.
startsWith
(
item
));
// const rawAppendChild = HTMLHeadElement.prototype.appendChild;
// const rawAddEventListener = window.addEventListener;
//
router.beforeEach((to, from, next) => {
//
// 从子项目跳转到主项目
//
if(isChildRoute(from.path) && !isChildRoute(to.path)){
//
HTMLHeadElement.prototype.appendChild = rawAppendChild;
//
window.addEventListener = rawAddEventListener;
//
}
//
next();
//
});
router
.
beforeEach
((
to
,
from
,
next
)
=>
{
// 从子项目跳转到主项目
//
if(isChildRoute(from.path) && !isChildRoute(to.path)){
//
HTMLHeadElement.prototype.appendChild = rawAppendChild;
//
window.addEventListener = rawAddEventListener;
//
}
//
next();
});
export
default
router
src/services/Menu.js
View file @
7c1910f
...
...
@@ -2,11 +2,11 @@ import HTTP from '@/utils/http/http';
import
{
API
}
from
'@/config/api'
;
export
default
class
MenuService
extends
HTTP
{
getMenuTree
(
params
)
{
getMenuTree
()
{
return
new
Promise
((
resolve
,
reject
)
=>
{
this
.
axiosGet
({
url
:
API
.
MENU_TREE_ACTION
,
data
:
params
,
data
:
{}
,
success
(
data
)
{
resolve
(
data
);
},
...
...
src/utils/globalAnt/ant.js
View file @
7c1910f
...
...
@@ -12,7 +12,8 @@ import {
Dropdown
,
Spin
,
Breadcrumb
,
Empty
Empty
,
ConfigProvider
,
}
from
"ant-design-vue"
;
const
ant
=
{
...
...
@@ -36,6 +37,7 @@ const ant = {
Vue
.
component
(
Spin
.
name
,
Spin
);
Vue
.
component
(
Breadcrumb
.
name
,
Breadcrumb
);
Vue
.
component
(
Empty
.
name
,
Empty
);
Vue
.
component
(
ConfigProvider
.
name
,
ConfigProvider
);
},
};
...
...
src/utils/http/http.js
View file @
7c1910f
...
...
@@ -15,17 +15,17 @@ instance.defaults.headers.post['Content-Type'] = 'application/json';
/** 添加请求拦截器 **/
instance
.
interceptors
.
request
.
use
(
config
=>
{
config
.
headers
[
'Authorization'
]
=
localStorage
.
getItem
(
'token'
)
||
''
;
store
.
dispatch
(
'app/showLoading'
,
true
);
//
store.dispatch('app/showLoading', true);
return
config
},
error
=>
{
console
.
log
(
'请求错误,原因:'
,
error
)
store
.
dispatch
(
'app/showLoading'
,
false
);
//
store.dispatch('app/showLoading', false);
return
Promise
.
reject
(
error
)
})
/** 添加响应拦截器 **/
instance
.
interceptors
.
response
.
use
(
response
=>
{
store
.
dispatch
(
'app/showLoading'
,
false
);
//
store.dispatch('app/showLoading', false);
const
serverCode
=
response
.
data
.
code
;
if
(
serverCode
===
200
||
response
.
status
===
200
)
{
if
(
serverCode
!==
200
)
{
...
...
@@ -41,7 +41,7 @@ instance.interceptors.response.use(response => {
return
Promise
.
reject
(
response
.
data
.
message
)
}
},
error
=>
{
store
.
dispatch
(
'app/showLoading'
,
false
);
//
store.dispatch('app/showLoading', false);
const
errRes
=
error
.
response
;
if
(
errRes
)
{
const
{
data
,
config
,
status
,
statusText
}
=
errRes
;
...
...
@@ -97,6 +97,7 @@ const getBaseUrl = () => {
if
(
resData
)
{
const
resBaseURL
=
resData
.
axios
.
baseURL
;
store
.
dispatch
(
'app/updateBaseURL'
,
resBaseURL
);
localStorage
.
setItem
(
'BASE_URL'
,
resBaseURL
);
baseFlag
=
!!
resBaseURL
;
resolve
(
resBaseURL
);
}
else
{
...
...
@@ -128,7 +129,8 @@ const HTTP_POST = (baseUrl, options) => {
const
HTTP_GET
=
(
baseUrl
,
options
)
=>
{
instance
({
url
:
baseUrl
+
options
.
url
,
method
:
'get'
method
:
'get'
,
params
:
options
.
data
}).
then
((
res
)
=>
{
options
.
success
(
res
.
data
);
}).
catch
((
err
)
=>
{
...
...
Write
Preview
Markdown
is supported
Attach a file
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 post a comment