|
@@ -4,7 +4,7 @@ import { useModel } from 'umi';
|
|
import Avatar from './AvatarDropdown';
|
|
import Avatar from './AvatarDropdown';
|
|
import styles from './index.less';
|
|
import styles from './index.less';
|
|
import { exitFullScreen, requestFullScreen, isFull } from '@/utils/fullScreen'
|
|
import { exitFullScreen, requestFullScreen, isFull } from '@/utils/fullScreen'
|
|
-import { BellOutlined, UserOutlined } from '@ant-design/icons';
|
|
+import { BellOutlined, CloseOutlined, UserOutlined } from '@ant-design/icons';
|
|
import { getAppListApi } from '@/services/iaaData';
|
|
import { getAppListApi } from '@/services/iaaData';
|
|
import { useAjax } from '@/Hook/useAjax';
|
|
import { useAjax } from '@/Hook/useAjax';
|
|
import { groupBy } from '@/utils/utils';
|
|
import { groupBy } from '@/utils/utils';
|
|
@@ -33,9 +33,8 @@ const GlobalHeaderRight: React.FC<{}> = () => {
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
const [appData, setAppData] = useState<{ [x: string]: { [x: string]: any[] } }>({})
|
|
const [appData, setAppData] = useState<{ [x: string]: { [x: string]: any[] } }>({})
|
|
- const [appList, setApplist] = useState<{ label: string, value: string, productType: string; mediaPlatform: string; icon?: string }[]>([])
|
|
+ const [appList, setApplist] = useState<{ label: string, value: number, productType: string; mediaPlatform: string; icon?: string }[]>([])
|
|
const getAppList = useAjax(() => getAppListApi())
|
|
const getAppList = useAjax(() => getAppListApi())
|
|
- const [productType, setProductType] = useState<string>()
|
|
|
|
const [isJr, setIsJr] = useState<boolean>(false)
|
|
const [isJr, setIsJr] = useState<boolean>(false)
|
|
const [firstPath, setFirstPath] = useState<{ [x: string]: string }>()
|
|
const [firstPath, setFirstPath] = useState<{ [x: string]: string }>()
|
|
|
|
|
|
@@ -135,7 +134,7 @@ const GlobalHeaderRight: React.FC<{}> = () => {
|
|
'PRODUCT_TYPE_PLAYLET': ['playlet_tencent', 'playlet_ocenaengine'],
|
|
'PRODUCT_TYPE_PLAYLET': ['playlet_tencent', 'playlet_ocenaengine'],
|
|
};
|
|
};
|
|
|
|
|
|
- let toData: { label: string, value: string, productType: string; mediaPlatform: string; icon?: string }[] = []
|
|
+ let toData: { label: string, value: number, productType: string; mediaPlatform: string; icon?: string }[] = []
|
|
|
|
|
|
Object.keys(appTypeGroupList).forEach(productType => {
|
|
Object.keys(appTypeGroupList).forEach(productType => {
|
|
let data = groupBy(appTypeGroupList[productType], (item) => item.mediaPlatform, true) || {};
|
|
let data = groupBy(appTypeGroupList[productType], (item) => item.mediaPlatform, true) || {};
|
|
@@ -147,7 +146,7 @@ const GlobalHeaderRight: React.FC<{}> = () => {
|
|
delete data['MEDIA_PLATFORM_TENCENT'];
|
|
delete data['MEDIA_PLATFORM_TENCENT'];
|
|
} else {
|
|
} else {
|
|
if (data['MEDIA_PLATFORM_TENCENT']) {
|
|
if (data['MEDIA_PLATFORM_TENCENT']) {
|
|
- const tencentData = data['MEDIA_PLATFORM_TENCENT'].map((item: { name: any; id: string; productType: string; mediaPlatform: any; icon: any; }) => ({ label: item.name, value: item.id + '||' + item.productType, productType: item.productType, mediaPlatform: item.mediaPlatform, icon: item.icon }))
|
|
+ const tencentData = data['MEDIA_PLATFORM_TENCENT'].map((item: { name: any; id: number; productType: string; mediaPlatform: any; icon: any; }) => ({ label: item.name, value: item.id, productType: item.productType, mediaPlatform: item.mediaPlatform, icon: item.icon }))
|
|
data['MEDIA_PLATFORM_TENCENT'] = tencentData
|
|
data['MEDIA_PLATFORM_TENCENT'] = tencentData
|
|
toData.push(...tencentData)
|
|
toData.push(...tencentData)
|
|
}
|
|
}
|
|
@@ -156,7 +155,7 @@ const GlobalHeaderRight: React.FC<{}> = () => {
|
|
delete data['MEDIA_PLATFORM_OCENAENGINE'];
|
|
delete data['MEDIA_PLATFORM_OCENAENGINE'];
|
|
} else {
|
|
} else {
|
|
if (data['MEDIA_PLATFORM_OCENAENGINE']) {
|
|
if (data['MEDIA_PLATFORM_OCENAENGINE']) {
|
|
- const ocenaengineData = data['MEDIA_PLATFORM_OCENAENGINE'].map((item: { name: any; id: string; productType: string; mediaPlatform: any; icon: any; }) => ({ label: item.name, value: item.id + '||' + item.productType, productType: item.productType, mediaPlatform: item.mediaPlatform, icon: item.icon }))
|
|
+ const ocenaengineData = data['MEDIA_PLATFORM_OCENAENGINE'].map((item: { name: any; id: number; productType: string; mediaPlatform: any; icon: any; }) => ({ label: item.name, value: item.id, productType: item.productType, mediaPlatform: item.mediaPlatform, icon: item.icon }))
|
|
data['MEDIA_PLATFORM_OCENAENGINE'] = ocenaengineData
|
|
data['MEDIA_PLATFORM_OCENAENGINE'] = ocenaengineData
|
|
toData.push(...ocenaengineData)
|
|
toData.push(...ocenaengineData)
|
|
}
|
|
}
|
|
@@ -169,25 +168,18 @@ const GlobalHeaderRight: React.FC<{}> = () => {
|
|
});
|
|
});
|
|
console.log(appDataList, toData, firstPath)
|
|
console.log(appDataList, toData, firstPath)
|
|
setAppData(appDataList)
|
|
setAppData(appDataList)
|
|
- const app = initialState?.iaaApp
|
|
+ if (toData?.length) {
|
|
- let iaaApp: string;
|
|
+ let iaaAppData: any;
|
|
- let mediaPlatform: string;
|
|
+ let mediaPlatform: string;
|
|
- const d = toData.find(item => item.value === app)
|
|
+ iaaAppData = toData?.find(item => item.productType === 'PRODUCT_TYPE_GAME') || toData?.[0] || undefined as any
|
|
- if (app && d) {
|
|
|
|
- iaaApp = app
|
|
|
|
- mediaPlatform = d.mediaPlatform
|
|
|
|
- } else {
|
|
|
|
- iaaApp = toData?.find(item => item.productType === 'PRODUCT_TYPE_GAME')?.value || toData?.[0].value || undefined as any
|
|
|
|
mediaPlatform = toData?.[0].mediaPlatform || undefined as any
|
|
mediaPlatform = toData?.[0].mediaPlatform || undefined as any
|
|
|
|
+ const productType = iaaAppData?.productType
|
|
|
|
+ sessionStorage.setItem('mediaPlatform', mediaPlatform)
|
|
|
|
+ setInitialState({ ...initialState, iaaApp: iaaAppData?.value ? [iaaAppData?.value] : [], productType, mediaPlatform })
|
|
|
|
+ setApplist(toData)
|
|
|
|
+ setFirstPath(firstPath)
|
|
|
|
+ haveTo(mediaPlatform as any, productType as any, firstPath)
|
|
}
|
|
}
|
|
- const productType = iaaApp ? iaaApp.split('||')?.[1] : undefined
|
|
|
|
- // haveTo(mediaPlatform as any)
|
|
|
|
- sessionStorage.setItem('mediaPlatform', mediaPlatform)
|
|
|
|
- setProductType(productType)
|
|
|
|
- setInitialState({ ...initialState, iaaApp, mediaPlatform })
|
|
|
|
- setApplist(toData)
|
|
|
|
- setFirstPath(firstPath)
|
|
|
|
- haveTo(mediaPlatform as any, productType as any, firstPath)
|
|
|
|
} else {
|
|
} else {
|
|
message.error('没有菜单')
|
|
message.error('没有菜单')
|
|
}
|
|
}
|
|
@@ -273,10 +265,9 @@ const GlobalHeaderRight: React.FC<{}> = () => {
|
|
let firstNewApp = newApplist[0]
|
|
let firstNewApp = newApplist[0]
|
|
sessionStorage.setItem('mediaPlatform', firstNewApp.mediaPlatform)
|
|
sessionStorage.setItem('mediaPlatform', firstNewApp.mediaPlatform)
|
|
firstNewApp.mediaPlatform && haveTo(newApplist?.[0]?.mediaPlatform as any, type as any);
|
|
firstNewApp.mediaPlatform && haveTo(newApplist?.[0]?.mediaPlatform as any, type as any);
|
|
- setInitialState({ ...initialState, iaaApp: firstNewApp.value, mediaPlatform: firstNewApp.mediaPlatform })
|
|
+ setInitialState({ ...initialState, iaaApp: [firstNewApp.value], productType: type, mediaPlatform: firstNewApp.mediaPlatform })
|
|
- setProductType(type)
|
|
|
|
}}
|
|
}}
|
|
- value={productType}
|
|
+ value={initialState?.productType}
|
|
options={Object.keys(appData).map(key => ({ label: PRODUCT_TYPE[key as keyof typeof PRODUCT_TYPE], value: key }))}
|
|
options={Object.keys(appData).map(key => ({ label: PRODUCT_TYPE[key as keyof typeof PRODUCT_TYPE], value: key }))}
|
|
/>
|
|
/>
|
|
<Select
|
|
<Select
|
|
@@ -287,27 +278,33 @@ const GlobalHeaderRight: React.FC<{}> = () => {
|
|
(option?.label as any)?.toLowerCase().indexOf(input.toLowerCase()) >= 0
|
|
(option?.label as any)?.toLowerCase().indexOf(input.toLowerCase()) >= 0
|
|
}
|
|
}
|
|
onChange={(type) => {
|
|
onChange={(type) => {
|
|
- let newApplist = appList.filter(item => item.productType === productType).filter(item => item.mediaPlatform === type)
|
|
+ let newApplist = appList.filter(item => item.productType === initialState?.productType).filter(item => item.mediaPlatform === type)
|
|
sessionStorage.setItem('mediaPlatform', type)
|
|
sessionStorage.setItem('mediaPlatform', type)
|
|
- haveTo(type as any, productType as any)
|
|
+ haveTo(type as any, initialState?.productType as any)
|
|
- setInitialState({ ...initialState, iaaApp: newApplist?.[0]?.value, mediaPlatform: type })
|
|
+ setInitialState({ ...initialState, iaaApp: [newApplist?.[0]?.value], mediaPlatform: type })
|
|
}}
|
|
}}
|
|
value={initialState?.mediaPlatform}
|
|
value={initialState?.mediaPlatform}
|
|
- options={(productType && appData?.[productType]) ? Object.keys(appData?.[productType]).map(key => ({ label: MediaPlatform[key as keyof typeof MediaPlatform], value: key })) : []}
|
|
+ options={(initialState?.productType && appData?.[initialState?.productType]) ? Object.keys(appData?.[initialState?.productType]).map(key => ({ label: MediaPlatform[key as keyof typeof MediaPlatform], value: key })) : []}
|
|
/>
|
|
/>
|
|
<Select
|
|
<Select
|
|
showSearch
|
|
showSearch
|
|
- style={{ width: 200, marginLeft: 10 }}
|
|
+ style={{ minWidth: 200, marginLeft: 10 }}
|
|
placeholder={'请选择应用'}
|
|
placeholder={'请选择应用'}
|
|
filterOption={(input, option) => (option?.name as any)?.toLowerCase().indexOf(input.toLowerCase()) >= 0}
|
|
filterOption={(input, option) => (option?.name as any)?.toLowerCase().indexOf(input.toLowerCase()) >= 0}
|
|
value={initialState?.iaaApp}
|
|
value={initialState?.iaaApp}
|
|
- onChange={(e) => setInitialState({ ...initialState, iaaApp: e })}
|
|
+ onChange={(e) => {
|
|
|
|
+ if (e?.length > 0)
|
|
|
|
+ setInitialState({ ...initialState, iaaApp: e })
|
|
|
|
+ }}
|
|
loading={getAppList.loading}
|
|
loading={getAppList.loading}
|
|
|
|
+ mode="multiple"
|
|
|
|
+ maxTagCount={1}
|
|
|
|
+ removeIcon={<CloseOutlined style={{ color: '#000' }} />}
|
|
>
|
|
>
|
|
- {appList.filter(item => item.productType === productType).filter(item => item.mediaPlatform === initialState?.mediaPlatform).map(item => {
|
|
+ {appList.filter(item => item.productType === initialState?.productType).filter(item => item.mediaPlatform === initialState?.mediaPlatform).map(item => {
|
|
return <Select.Option key={item.value} value={item.value} name={item.label}>
|
|
return <Select.Option key={item.value} value={item.value} name={item.label}>
|
|
<Space align='center'>
|
|
<Space align='center'>
|
|
- <AntdAvatar shape="square" style={{ marginBottom: 4 }} size={24} icon={<UserOutlined />} src={item?.icon} />
|
|
+ <AntdAvatar shape="square" style={{ marginBottom: 4 }} size={16} icon={<UserOutlined />} src={item?.icon} />
|
|
<span>{item.label}</span>
|
|
<span>{item.label}</span>
|
|
</Space>
|
|
</Space>
|
|
</Select.Option>
|
|
</Select.Option>
|