5.9 高质量运营优化

This commit is contained in:
jl-zhoujl2
2023-05-09 09:56:52 +08:00
parent c47f65dc36
commit 10bb13b13e
3 changed files with 29 additions and 14 deletions

View File

@ -178,6 +178,7 @@ const Detail: React.FC<DetailLocationProps> = (props) => {
<List <List
itemLayout="horizontal" itemLayout="horizontal"
dataSource={commentList} dataSource={commentList}
locale={{ emptyText: "暂无评论" }}
renderItem={(item, index) => ( renderItem={(item, index) => (
<List.Item id={`item${index}`}> <List.Item id={`item${index}`}>
<Skeleton loading={item.loading} active avatar title={false}> <Skeleton loading={item.loading} active avatar title={false}>

View File

@ -6,10 +6,12 @@ import React, { useState } from 'react';
import { useRef } from 'react'; import { useRef } from 'react';
import EventMaintenanceModal from './components/EventMaintenanceModal'; import EventMaintenanceModal from './components/EventMaintenanceModal';
import { changeEventStatus, deleteEvent, getEventList } from './service'; import { changeEventStatus, deleteEvent, getEventList } from './service';
import { managerAuthority } from '../../utils'; import { authCheck, managerAuthority } from '../../utils';
const EventMaintenance: React.FC<{}> = () => { const EventMaintenance: React.FC<{}> = () => {
const actionRef = useRef<ActionType>(); const actionRef = useRef<ActionType>();
//权限校验
const auth = useRef<boolean>(authCheck(["ebtp-party-admin"]));
//新建 编辑 查看 //新建 编辑 查看
const [modalVisible, setModalVisible] = useState<boolean>(false); const [modalVisible, setModalVisible] = useState<boolean>(false);
//行数据 //行数据
@ -192,23 +194,20 @@ const EventMaintenance: React.FC<{}> = () => {
actionRef={actionRef} actionRef={actionRef}
loading={loading} loading={loading}
request={async (params) => { request={async (params) => {
setLoading(true); if (auth.current) {
return await getEventList(params).then(res => { setLoading(true);
if (res?.success) { return await getEventList(params).then(res => {
return { return {
data: res?.data.records, data: res?.data.records,
success: res?.success, success: res?.success,
total: res?.data.total total: res?.data.total
}; };
} }).finally(() => {
return { setLoading(false);
data: [], })
success: false, } else {
total: 0, return {};
}; }
}).finally(() => {
setLoading(false);
})
}} }}
rowKey="id" rowKey="id"
options={false} options={false}

View File

@ -1,6 +1,7 @@
import { pictureDisplayPath } from "@/utils/DownloadUtils"; import { pictureDisplayPath } from "@/utils/DownloadUtils";
import { getSessionUserData } from "@/utils/session"; import { getSessionUserData } from "@/utils/session";
import moment from "moment"; import moment from "moment";
import { history } from 'umi';
/** /**
* 图片路径拼接 * 图片路径拼接
* @param filePath 图片路径 * @param filePath 图片路径
@ -96,4 +97,18 @@ export const formatCreateTime = (createTime: string) => {
} else { } else {
return `${Math.floor(diff / (60 * 60 * 24 * 365))}年前`; return `${Math.floor(diff / (60 * 60 * 24 * 365))}年前`;
} }
}; };
//角色校验
export const authCheck = (authority: string[]) => {
//获取角色列表
const authorityList: any[] | undefined = getSessionUserData()?.authorityList;
if (isEmpty(authorityList)) {
history.replace({ pathname: "/404" });
return false;
}
if (authority.findIndex(item => authorityList?.findIndex(ite => ite.roleCode == item) != -1) == -1) {//角色权限校验
history.replace({ pathname: "/401", query: { code: "405" } });
return false;
}
return true;
}