Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
CivWeb
Project
Project
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
ReactWeb5
CivWeb
Commits
383a9651
Commit
383a9651
authored
Nov 18, 2021
by
邓晓峰
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 添加首页
parent
4230c42a
Pipeline
#38192
passed with stages
in 5 minutes 21 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
61 additions
and
26 deletions
+61
-26
micor.js
config/micor.js
+7
-7
reducer.js
src/containers/App/store/reducer.js
+35
-9
micro.js
src/micro.js
+14
-8
routes.js
src/utils/routes.js
+5
-2
No files found.
config/micor.js
View file @
383a9651
...
...
@@ -3,12 +3,12 @@ export function genActiveRule(routerPrefix) {
}
export
default
{
dev
:
[
{
name
:
'civ_energy'
,
entry
:
`//
${
window
.
location
.
hostname
}
:8081/civ_energy`
,
container
:
'#micro-container'
,
activeRule
:
'/civbase/civ_energy'
,
},
//
{
//
name: 'civ_energy',
//
entry: `//${window.location.hostname}:8081/civ_energy`,
//
container: '#micro-container',
//
activeRule: '/civbase/civ_energy',
//
},
// {
// name: 'civ_water',
// entry: `//${window.location.hostname}:8081/civ_water`,
...
...
@@ -35,7 +35,7 @@ export default {
},
{
name
:
'middleground'
,
entry
:
`//
${
window
.
location
.
hostname
}
:808
1
/middleground`
,
entry
:
`//
${
window
.
location
.
hostname
}
:808
2
/middleground`
,
container
:
'#micro-container'
,
activeRule
:
'/civbase/middleground'
,
},
...
...
src/containers/App/store/reducer.js
View file @
383a9651
...
...
@@ -100,23 +100,49 @@ const appReducer = (state = initialState, action) => {
const
config
=
window
.
globalConfig
;
// config.access_token = "";
// eslint-disable-next-line no-case-declarations
const
generMenu
=
generRoutes
(
config
.
widgets
||
[]);
// eslint-disable-next-line no-case-declarations
const
{
homepage
}
=
window
.
globalConfig
;
if
(
homepage
!==
''
)
{
// const index = generMenu.findIndex(item => item.level === -1);
// if (index > -1) {
// generMenu = generMenu.reverse();
// }
const
modulePkg
=
{};
window
.
globalConfig
.
products
.
map
(
item
=>
{
modulePkg
[
item
.
PackageName
]
=
item
;
})
const
generMenu
=
generRoutes
(
config
.
widgets
||
[],
null
,
0
,
modulePkg
);
const
flatMenu
=
generFlatRoutes
(
generMenu
||
[],
null
,
null
,
modulePkg
);
const
home
=
flatMenu
.
find
(
item
=>
{
let
path
=
item
.
path
.
split
(
"|"
);
let
currentPath
=
path
[
0
];
if
(
/^
\/
/
.
test
(
currentPath
))
{
currentPath
=
currentPath
.
replace
(
/^
\/
/
,
''
);
}
return
currentPath
===
homepage
});
let
currentMenuIndex
=
0
;
if
(
home
)
{
console
.
log
(
"home"
,
home
);
const
parent
=
home
.
level
>=
2
?
home
.
parent
.
parent
:
home
.
level
>=
3
?
home
.
parent
.
parent
.
parent
:
home
.
parent
;
if
(
parent
)
{
currentMenuIndex
=
generMenu
.
findIndex
(
item
=>
item
.
name
===
parent
.
label
);
currentProduct
.
set
(
'currentMenuIndex'
,
currentMenuIndex
);
store
.
set
(
'updateMenuIndex'
,
currentMenuIndex
)
}
}
// eslint-disable-next-line no-case-declarations
const
flatMenu
=
generFlatRoutes
(
generMenu
||
[]);
// eslint-disable-next-line no-case-declarations
window
.
globalConfig
.
home
=
home
;
Cookies
.
set
(
'city'
,
Cookies
.
get
(
'city'
)
||
window
.
globalConfig
.
client
);
return
state
.
merge
({
globalConfig
:
config
,
menu
:
generMenu
,
flatMenu
,
currentMenu
:
generMenu
[
state
.
currentMenuIndex
],
currentMenu
:
generMenu
[
currentMenuIndex
||
state
.
currentMenuIndex
],
currentMenuIndex
:
currentMenuIndex
||
0
});
case
GET_ERROR_CONFIG
:
return
state
.
merge
({
...
...
src/micro.js
View file @
383a9651
...
...
@@ -180,19 +180,25 @@ export const defaultApp = () => {
const
config
=
createStoreage
.
get
(
'globalConfig'
);
if
(
config
&&
config
.
token
)
{
// console.log(config)
// const startWith = config.homepage ? config.homepage.split('/') : [];
// console.log(findPathByLeafId(config.homepage, '', 'url'))
//
//
const startWith = config.homepage ? config.homepage.split('/') : [];
//
//
console.log(findPathByLeafId(config.homepage, '', 'url'))
const
basePath
=
config
.
homepage
!==
''
&&
FILTER_FOLER_REG
.
test
(
config
.
homepage
)
?
'civweb4'
:
'civweb4'
;
const
defaultURL
=
config
.
homepage
===
''
?
`/
${
pkg
.
name
.
toLocaleLowerCase
()}
/
${
basePath
}
?client=
${
config
.
client
}
`
:
`/
${
pkg
.
name
.
toLocaleLowerCase
()}
/
${
basePath
}
/
${
config
.
homepage
}
`
;
setDefaultMountApp
(
defaultURL
);
// const defaultURL =
// config.homepage === '' ?
// `/${pkg.name.toLocaleLowerCase()}/${basePath}?client=${config.client}` :
// `/${pkg.name.toLocaleLowerCase()}/${basePath}/${config.homepage}`;
// console.log("config.home.path", config.home.path)
if
(
config
&&
config
.
home
)
{
setDefaultMountApp
(
`/civbase/
${
config
.
home
.
path
.
replace
(
/^
\/
/
,
''
)}
`
);
}
else
{
setDefaultMountApp
(
`/
${
pkg
.
name
.
toLocaleLowerCase
()}
/
${
basePath
}
/
${
config
.
homepage
}
`
)
}
}
};
...
...
src/utils/routes.js
View file @
383a9651
...
...
@@ -64,6 +64,7 @@ const generRotes = (widgets, parent, level = 0) => {
item
.
widgets
,
Object
.
assign
({},
item
,
{
path
,
key
:
subKey
}),
_level_
,
item
.
label
),
extData
:
{
...
item
,
...
...
@@ -123,16 +124,18 @@ export function simpleNormalizeChildren(children) {
return
children
;
}
export
const
generFlatRoutes
=
(
widgets
,
parent
,
subSystem
)
=>
{
export
const
generFlatRoutes
=
(
widgets
,
parent
,
subSystem
,
modulePkg
)
=>
{
const
treeKeys
=
[];
const
flatMenu
=
[];
(
widgets
||
[]).
forEach
(
item
=>
{
if
(
item
.
hasOwnProperty
(
'routes'
))
{
const
route
=
generFlatRoutes
(
item
.
routes
,
item
,
item
.
name
);
const
route
=
generFlatRoutes
(
item
.
routes
,
item
,
item
.
name
,
modulePkg
);
flatMenu
.
push
(
simpleNormalizeChildren
(
route
));
}
else
{
flatMenu
.
push
({
...
item
,
origin
:
item
,
moduleName
:
modulePkg
[
item
.
alias
],
treeKeys
,
subSystem
,
parent
,
...
...
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