header排序

This commit is contained in:
黄心宇 2023-09-28 16:04:57 +08:00
parent f45d31b489
commit 06374112d8
1 changed files with 14 additions and 2 deletions

View File

@ -48,6 +48,7 @@ class NewHeader extends Component {
mygetHelmetapi2: null,
goshowqqgtounp: false,
visiblemyss: false,
navbar: []
}
}
componentDidMount() {
@ -536,6 +537,11 @@ class NewHeader extends Component {
this.setState({
mygetHelmetapi2: chromesettingArray
});
if (mygetHelmetapi2.navbar && mygetHelmetapi2.navbar.length) {
this.setState({ navbar: mygetHelmetapi2.navbar.sort((a, b) => {return a.index - b.index}) }, () => {
console.log('');
});
}
if (chromesettingArray.tab_logo_url) {
this.gettablogourldata(chromesettingresponseArray);
} else {
@ -553,6 +559,11 @@ class NewHeader extends Component {
this.setState({ mygetHelmetapi2: response.data.setting }, () => {
console.log('');
});
if (response.data.setting.navbar && response.data.setting.navbar.length) {
this.setState({ navbar: response.data.setting.navbar.sort((a, b) => {return a.index - b.index}) }, () => {
console.log('');
});
}
// localStorage.setItem('chromesetting', JSON.stringify(response.data.setting));
// localStorage.setItem('chromesettingresponse', JSON.stringify(response));
try {
@ -633,6 +644,7 @@ class NewHeader extends Component {
isRender,
mygetHelmetapi2,
goshowqqgtounp,
navbar
} = this.state;
const filterPersonal = mygetHelmetapi2 && mygetHelmetapi2.personal && mygetHelmetapi2.personal.filter(i=>i.key === "userinfo");
@ -668,10 +680,10 @@ class NewHeader extends Component {
</a>
<div className="head-nav pr" id={"head-navpre1"}>
{
mygetHelmetapi2 && mygetHelmetapi2.navbar && mygetHelmetapi2.navbar.length > 0 ?
navbar && navbar.length > 0 ?
<ul id="header-nav">
{
mygetHelmetapi2.navbar && mygetHelmetapi2.navbar.map((item, key) => {
navbar && navbar.map((item, key) => {
var new_link = item.link;
var user_login = this.props.user && this.props.user.login;
var is_hidden = item.hidden