Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
bdc
/
bdcjg-web
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
46a705e8
authored
2023-03-21 16:09:39 +0800
by
xiaomiao
Browse Files
Options
Browse Files
Tag
Download
Plain Diff
--no commit message
2 parents
f167020b
49397ded
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
57 additions
and
31 deletions
src/api/user.js
src/main.js
src/store/modules/permission.js
src/utils/asyncRouter.js
src/utils/request.js
src/api/user.js
View file @
46a705e
import
Vue
from
'vue'
import
request
from
'@/utils/request'
console
.
log
(
Vue
.
prototype
,
Vue
.
prototype
.
BASE_API
);
import
SERVER
from
'./config'
// 获取用户信息
export
function
getUserInfo
()
{
...
...
src/main.js
View file @
46a705e
...
...
@@ -2,7 +2,7 @@
* @Author: yangwei
* @Date: 2023-01-16 09:10:12
* @LastEditors: Please set LastEditors
* @LastEditTime: 2023-03-21 1
4:15:40
* @LastEditTime: 2023-03-21 1
5:00:04
* @FilePath: \bdcjg-web\src\main.js
* @Description:
*
...
...
@@ -51,7 +51,7 @@ Vue.directive('fo', {
import
'./image/icons'
// icon
import
store
from
'./store'
import
router
from
'./router'
import
_
,
{
set
}
from
'lodash'
import
_
from
'lodash'
Vue
.
use
(
Element
,
{
size
:
'small'
,
zIndex
:
1000
})
Vue
.
use
(
Base
)
Vue
.
component
(
'icon'
,
Icon
);
...
...
@@ -60,16 +60,12 @@ Vue.use(dataV)
axios
.
get
(
"./config.json"
)
.
then
((
res
)
=>
{
Vue
.
prototype
.
BASE_API
=
res
.
data
localStorage
.
setItem
(
'ApiUrl'
,
JSON
.
stringify
(
res
.
data
));
require
(
'./permission'
)
setTimeout
(()
=>
{
new
Vue
({
el
:
'#app'
,
router
,
store
,
render
:
h
=>
h
(
App
)
})
},
20
)
})
new
Vue
({
el
:
'#app'
,
router
,
store
,
render
:
h
=>
h
(
App
)
})
})
\ No newline at end of file
...
...
src/store/modules/permission.js
View file @
46a705e
...
...
@@ -2,13 +2,13 @@
* @Author: xiaomiao 1158771342@qq.com
* @Date: 2023-03-09 15:24:53
* @LastEditors: Please set LastEditors
* @LastEditTime: 2023-03-21 1
4:05:43
* @LastEditTime: 2023-03-21 1
6:05:39
* @FilePath: \上报\bdcjg-web\src\store\modules\permission.js
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
import
Vue
from
'vue'
import
{
constantRoutes
}
from
'@/router'
import
asyncRouter
from
'@/utils/asyncRouter.js'
//
import asyncRouter from '@/utils/asyncRouter.js'
const
state
=
{
routes
:
[],
addRoutes
:
false
,
...
...
@@ -26,6 +26,38 @@ const mutations = {
const
actions
=
{
// 添加全部菜单
generateRoutes
({
commit
},
getMenuInfo
)
{
let
Layout
;
if
(
Vue
.
prototype
.
BASE_API
.
THEME
==
'sb'
)
{
Layout
=
r
=>
require
.
ensure
([],
()
=>
r
(
require
(
`@/layout1`
)))
}
else
{
Layout
=
r
=>
require
.
ensure
([],
()
=>
r
(
require
(
`@/layout`
)))
}
function
asyncRouter
(
routers
)
{
routers
.
forEach
(
item
=>
{
if
(
!
item
.
children
)
{
delete
item
.
children
}
else
{
item
.
children
=
asyncRouter
(
item
.
children
)
}
item
.
path
=
JSON
.
parse
(
item
.
metadata
)?.
path
||
'/'
if
(
!
item
.
parentId
)
{
item
.
component
=
Layout
console
.
log
(
item
.
component
);
}
else
{
item
.
component
=
loadView
(
item
.
uri
)
}
item
.
meta
=
{
title
:
item
.
name
,
icon
:
item
.
icon
}
})
return
routers
}
function
loadView
(
view
)
{
return
r
=>
require
.
ensure
([],
()
=>
r
(
require
(
`@/views
${
view
}
.vue`
)))
}
return
new
Promise
(
resolve
=>
{
// 将权限菜单数组转成路由树数据结构
let
permission_tree
=
asyncRouter
(
getMenuInfo
)
...
...
src/utils/asyncRouter.js
View file @
46a705e
/*
* @Description:
* @Autor: renchao
* @LastEditTime: 2023-03-21 14:45:26
*/
import
Vue
from
'vue'
import
Layout
from
'@/layout'
const
config
=
require
(
'/public/config.json'
)
console
.
log
(
config
,
'Vue.2222222222222.BASE_API'
);
var
Layout
;
let
ApiUrl
=
localStorage
.
getItem
(
'ApiUrl'
)
if
(
ApiUrl
.
THEME
==
'sb'
)
{
Layout
=
r
=>
require
.
ensure
([],
()
=>
r
(
require
(
`@/layout1`
)))
}
else
{
Layout
=
r
=>
require
.
ensure
([],
()
=>
r
(
require
(
`@/layout`
)))
}
export
default
function
filterAsyncRouter
(
routers
)
{
routers
.
forEach
(
item
=>
{
if
(
!
item
.
children
)
{
...
...
@@ -19,6 +19,7 @@ export default function filterAsyncRouter (routers) {
item
.
component
=
Layout
}
else
{
item
.
component
=
loadView
(
item
.
uri
)
console
.
log
(
item
.
component
,
'item.componentitem.component'
);
}
item
.
meta
=
{
title
:
item
.
name
,
...
...
src/utils/request.js
View file @
46a705e
/*
* @Description:
* @Description:
此文件主要创建 axios 实例,然后添加请求拦截器和响应拦截器
* @Autor: renchao
* @LastEditTime: 2023-03-21 13:46:56
*/
/**
* 此文件主要创建 axios 实例,然后添加请求拦截器和响应拦截器
* @LastEditTime: 2023-03-21 15:03:37
*/
import
axios
from
"axios"
;
import
{
Message
}
from
"element-ui"
;
...
...
@@ -17,6 +14,7 @@ const service = axios.create({
headers
:
{
"Content-Type"
:
"application/json; charset=utf-8"
,
},
timeout
:
15000
,
});
...
...
Please
register
or
sign in
to post a comment