Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
dcxy-system
Project
Overview
Details
Activity
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
姜雷
dcxy-system
Commits
d39bbbc2
Commit
d39bbbc2
authored
Mar 26, 2019
by
姜雷
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改api挂载方式
parent
7a9830f4
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
84 deletions
+17
-84
main.js
src/lib/main.js
+13
-7
main.js
src/main.js
+4
-6
permission.js
src/permission.js
+0
-71
No files found.
src/lib/main.js
View file @
d39bbbc2
...
@@ -13,16 +13,18 @@ import { formatRouteLink } from '@/utils/route';
...
@@ -13,16 +13,18 @@ import { formatRouteLink } from '@/utils/route';
import
storeModule
from
'./storeModule'
;
import
storeModule
from
'./storeModule'
;
import
mixinModule
from
'./mixins'
;
import
mixinModule
from
'./mixins'
;
const
fetch
=
createBaseFetch
(
{
timeout
:
10000
,
},
store
);
const
createSystem
=
({
routers
,
routeFilter
})
=>
{
const
createSystem
=
({
routers
,
routeFilter
})
=>
{
class
SystemShell
{
class
SystemShell
{
constructor
()
{
constructor
()
{
this
.
createBaseFetch
=
createBaseFetch
;
this
.
createBaseFetch
=
createBaseFetch
;
this
.
fetch
=
createBaseFetch
(
this
.
fetch
=
fetch
;
{
timeout
:
10000
,
},
store
);
this
.
initSystem
();
this
.
initSystem
();
}
}
...
@@ -68,4 +70,8 @@ const createSystem = ({ routers, routeFilter }) => {
...
@@ -68,4 +70,8 @@ const createSystem = ({ routers, routeFilter }) => {
return
systemShell
;
return
systemShell
;
};
};
export
default
createSystem
;
export
default
{
createBaseFetch
,
Api
:
fetch
,
createSystem
,
};
src/main.js
View file @
d39bbbc2
import
createSystem
from
'./lib/main'
;
import
System
from
'./lib/main'
;
console
.
log
(
System
);
let
allAasyncRouterMap
=
[
let
allAasyncRouterMap
=
[
...
customerManage
.
default
,
...
customerManage
.
default
,
...
@@ -6,12 +8,8 @@ let allAasyncRouterMap = [
...
@@ -6,12 +8,8 @@ let allAasyncRouterMap = [
...
systemManage
.
default
,
...
systemManage
.
default
,
];
];
let
app
=
createSystem
({
let
app
=
System
.
createSystem
({
routers
:
allAasyncRouterMap
,
routers
:
allAasyncRouterMap
,
// routeFilter: allRoute => {
// let filterRoute = allRoute.find(menu => menu.menuCode == '0001');
// return filterRoute ? [filterRoute] : [];
// },
});
});
app
.
mount
();
app
.
mount
();
src/permission.js
deleted
100644 → 0
View file @
7a9830f4
import
router
,
{
asyncRouterMap
}
from
'./router'
;
import
store
from
'./store'
;
import
NProgress
from
'nprogress'
;
// Progress 进度条
import
'nprogress/nprogress.css'
;
// Progress 进度条样式
import
{
getToken
}
from
'@/utils/auth'
;
// 验权
import
{
getAuthRoute
}
from
'./utils/route'
;
let
allAasyncRouterMap
=
[
...
customerManage
.
default
,
...
baseManage
.
default
,
...
systemManage
.
default
,
];
NProgress
.
configure
({
showSpinner
:
false
});
// NProgress Configuration
const
whiteList
=
process
.
env
.
VUE_APP_WHITE_LIST
.
split
(
','
);
// 不重定向白名单
const
getRouteAdd
=
()
=>
{
let
allRoute
=
store
.
getters
.
asyncRoutes
;
let
asyncRouters
=
getAuthRoute
(
allAasyncRouterMap
,
allRoute
);
router
.
addRoutes
(
asyncRouters
);
// 动态添加可访问路由表
router
.
addRoutes
(
asyncRouterMap
);
};
router
.
beforeEach
((
to
,
from
,
next
)
=>
{
NProgress
.
start
();
// 进度条Progress
if
(
getToken
())
{
if
(
to
.
path
===
'/login'
)
{
next
({
path
:
'/'
});
NProgress
.
done
();
}
else
{
if
(
store
.
getters
.
isRouteDone
)
{
next
();
//
}
else
{
let
addRoute
=
store
.
getters
.
asyncRoutes
;
if
(
addRoute
&&
addRoute
.
length
)
{
getRouteAdd
();
store
.
dispatch
(
'GenerateRoutes'
);
next
({
...
to
,
replace
:
true
});
}
else
{
store
.
dispatch
(
'TokenLogin'
,
{
data
:
{
token
:
getToken
()
},
})
.
then
(()
=>
{
getRouteAdd
();
store
.
dispatch
(
'GenerateRoutes'
);
next
({
...
to
,
replace
:
true
});
})
.
catch
(
err
=>
{
console
.
log
(
err
);
store
.
dispatch
(
'FedLogOut'
).
then
(()
=>
{
next
({
path
:
'/login'
});
});
});
}
}
}
}
else
{
if
(
whiteList
.
indexOf
(
to
.
path
)
!==
-
1
)
{
next
();
}
else
{
next
(
'/login'
);
NProgress
.
done
();
}
}
});
router
.
afterEach
(()
=>
{
NProgress
.
done
();
// 结束Progress
});
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