Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
胡锦波
/
org-manager-web
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
e9234cbd
authored
Mar 29, 2022
by
胡锦波
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
1. init 添加兼容以前的代码
parent
b0271a7b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
79 additions
and
0 deletions
src/router/compatible-url.ts
src/router/index.ts
src/router/compatible-url.ts
0 → 100644
View file @
e9234cbd
import
{
RouteConfig
}
from
'vue-router'
;
import
{
Direction
}
from
'./direction'
;
interface
RedirectPath
{
path
:
string
,
redirect
:
string
,
}
const
compatibleUrl
=
[
{
oldPath
:
"/SelectOrg"
,
direction
:
Direction
.
Home
},
{
oldPath
:
"/workadmin/addressbook/home"
,
direction
:
Direction
.
AddressBook
},
{
oldPath
:
"/workadmin/applicationrecord"
,
direction
:
Direction
.
ApplicationRecord
},
{
oldPath
:
"/workadmin/OrgManage/Invoicetitles"
,
direction
:
Direction
.
InvoiceTitles
},
{
oldPath
:
"/workadmin/OrgManage/OrgInfo"
,
direction
:
Direction
.
EnterpriseInfo
},
{
oldPath
:
"/workadmin/workadmin/OrgManage/ApplySetting"
,
direction
:
Direction
.
ApplicationSetting
},
{
oldPath
:
"/workadmin/workadmin/OrgManage/AuthorityManage"
,
direction
:
Direction
.
ManagerSetting
},
{
oldPath
:
"/workadmin/workadmin/OrgManage/Logs"
,
direction
:
Direction
.
ManagerLog
},
];
const
direction4AbsolutePathMap
=
new
Map
<
Direction
,
string
>
();
/**
* 根据path 和 direction拿到需要重定向的路径, 主要是适配之前的路由
*/
const
setDirectionEnum4Url
=
function
(
routes
:
RouteConfig
[],
prefix
=
''
)
{
for
(
let
i
=
0
;
i
<
routes
.
length
;
i
++
)
{
const
route
=
routes
[
i
];
if
(
route
.
meta
&&
route
.
meta
.
direction
)
{
const
direction
=
route
.
meta
.
direction
;
const
curPath
=
`
${
prefix
}
/
${
route
.
path
}
`
;
direction4AbsolutePathMap
.
set
(
direction
,
curPath
.
replace
(
'//'
,
'/'
));
continue
;
}
if
(
route
.
children
)
{
const
curPath
=
`
${
prefix
}
/
${
route
.
path
}
`
;
setDirectionEnum4Url
(
route
.
children
,
curPath
.
replace
(
'//'
,
'/'
));
}
}
};
const
setCompatibleUrl
=
function
(
routes
:
RouteConfig
[]):
RedirectPath
[]
{
setDirectionEnum4Url
(
routes
);
return
compatibleUrl
.
map
(
i
=>
{
return
{
path
:
i
.
oldPath
,
redirect
:
direction4AbsolutePathMap
.
get
(
i
.
direction
)
}
as
RedirectPath
;
})
||
[];
};
export
{
setCompatibleUrl
};
src/router/index.ts
View file @
e9234cbd
...
...
@@ -2,6 +2,7 @@ import Vue from 'vue';
import
VueRouter
,
{
RouteConfig
}
from
'vue-router'
;
import
{
Direction
}
from
'./direction'
;
import
{
MetaHeader
}
from
'./meta-header'
;
import
{
setCompatibleUrl
}
from
'./compatible-url'
;
Vue
.
use
(
VueRouter
);
...
...
@@ -64,6 +65,9 @@ const routes: Array<RouteConfig> = [
}
];
const
redirectPath
=
setCompatibleUrl
(
routes
);
routes
.
unshift
(...
redirectPath
);
const
router
=
new
VueRouter
({
mode
:
'history'
,
base
:
process
.
env
.
BASE_URL
,
...
...
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