Commit 922764d9 authored by Bill's avatar Bill

fix: 首页布局layout sort方法

parent c6143ab9
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
"start-noApi": "yarn scripts:build && cross-env NODE_OPTIONS=--max_old_space_size=4096 UMI_ENV=local umi dev", "start-noApi": "yarn scripts:build && cross-env NODE_OPTIONS=--max_old_space_size=4096 UMI_ENV=local umi dev",
"build": "yarn api && yarn scripts:build && yarn build:clean", "build": "yarn api && yarn scripts:build && yarn build:clean",
"build-noApi": "yarn scripts:build && yarn build:clean", "build-noApi": "yarn scripts:build && yarn build:clean",
"build:yxc": "yarn api && yarn scripts:build-yxc && umi bu ild", "build:yxc": "yarn api && yarn scripts:build-yxc && umi build",
"build:analyze": "cross-env NODE_OPTIONS=--max_old_space_size=16384 ANALYZE=1 UMI_ENV=prod umi build", "build:analyze": "cross-env NODE_OPTIONS=--max_old_space_size=16384 ANALYZE=1 UMI_ENV=prod umi build",
"build:dev": "pm2 start scripts/devServer.js", "build:dev": "pm2 start scripts/devServer.js",
"build:clean": "cross-env NODE_OPTIONS=--max_old_space_size=16384 UMI_ENV=prod umi build", "build:clean": "cross-env NODE_OPTIONS=--max_old_space_size=16384 UMI_ENV=prod umi build",
......
import { getAuth } from "@/utils/auth" import { getAuth } from "@/utils/auth"
import { useCallback, useMemo } from "react"; import { useCallback, useMemo } from "react";
import { sortBy } from 'lodash'
type AbilityNameType = "orderAbility" type AbilityNameType = "orderAbility"
| 'shopAbility' | 'shopAbility'
...@@ -170,6 +169,7 @@ const useGetAuth = () => { ...@@ -170,6 +169,7 @@ const useGetAuth = () => {
* *
* @param authLayouts 根据pass 平台勾选的大模块, 生成的names 即从getLayoutCenters 得到的值 * @param authLayouts 根据pass 平台勾选的大模块, 生成的names 即从getLayoutCenters 得到的值
* @param isCheckedLayouts 后台返回的已勾选的的大模块项 * @param isCheckedLayouts 后台返回的已勾选的的大模块项
*
*/ */
const generateLayoutData = useCallback((authLayouts: string[], isCheckedLayouts: isCheckedLayoutsType[]) => { const generateLayoutData = useCallback((authLayouts: string[], isCheckedLayouts: isCheckedLayoutsType[]) => {
const filterNameIsNull = isCheckedLayouts.filter((_item) => _item.name !== null); const filterNameIsNull = isCheckedLayouts.filter((_item) => _item.name !== null);
...@@ -183,11 +183,12 @@ const useGetAuth = () => { ...@@ -183,11 +183,12 @@ const useGetAuth = () => {
id: null, id: null,
code: index, code: index,
...target, ...target,
sort: target.sort ?? index + 2,
isShow: target?.id ? true : false, isShow: target?.id ? true : false,
} }
}) })
// console.log(newLayoutData);
return sortBy(newLayoutData, "sort"); return newLayoutData.sort((a, b) => a.sort - b.sort)
}, []) }, [])
return { return {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment