diff --git a/config/routes.ts b/config/routes.ts index c1c1b32..23f9b1e 100644 --- a/config/routes.ts +++ b/config/routes.ts @@ -66,6 +66,7 @@ const routes: IRoute[] = [ path: '/topic/:id/edit', exact: true, component: '@/page/topic/edit', + access: 'canPostTopic', }, { path: '/user/:loginname', diff --git a/src/component/MessageList/index.less b/src/component/MessageList/index.less index 2655d9e..b541f7e 100644 --- a/src/component/MessageList/index.less +++ b/src/component/MessageList/index.less @@ -1,4 +1,4 @@ -@import '~antd/dist/antd.less'; +@import '~antd/es/style/variable.less'; .list { :global { diff --git a/src/component/TopicList/index.less b/src/component/TopicList/index.less index 2655d9e..b541f7e 100644 --- a/src/component/TopicList/index.less +++ b/src/component/TopicList/index.less @@ -1,4 +1,4 @@ -@import '~antd/dist/antd.less'; +@import '~antd/es/style/variable.less'; .list { :global { diff --git a/src/layout/component/UserInfo.tsx b/src/layout/component/UserInfo.tsx index 422926e..cc76b48 100644 --- a/src/layout/component/UserInfo.tsx +++ b/src/layout/component/UserInfo.tsx @@ -21,7 +21,7 @@ const UserInfo: React.FC = (props) => { return; } - const res = await API.getUserInfo({ loginname }); + const res = await API.loadUser({ loginname }); return res.data; }, { diff --git a/src/layout/index.tsx b/src/layout/index.tsx index 7800d89..f841659 100644 --- a/src/layout/index.tsx +++ b/src/layout/index.tsx @@ -32,6 +32,7 @@ const getCurrentRoute = (route: IRoute, path: string): IRoute | undefined => { const BREADCRUMB_NAME_MAP = { user: '用户', topic: '话题', + edit: '编辑', }; const Layout: React.FC> = (props) => { @@ -46,7 +47,7 @@ const Layout: React.FC> = (props) => { const detailPaths = location.pathname.match(/\/(topic|user)\/(\w+)(\/\w+)?/); if (detailPaths) { - const [, category, id, status] = detailPaths; + const [pathname, category, id, status] = detailPaths; const isEdit = status === '/edit'; @@ -60,17 +61,15 @@ const Layout: React.FC> = (props) => { breadcrumbName: BREADCRUMB_NAME_MAP[category as 'user' | 'topic'], }, { - path: isEdit - ? location.pathname.replace(status, '') - : location.pathname, + path: `/${category}/${id}`, breadcrumbName: id, }, ]; if (isEdit) { routes.push({ - path: location.pathname, - breadcrumbName: '编辑', + path: pathname, + breadcrumbName: BREADCRUMB_NAME_MAP['edit'], }); } diff --git a/src/model/message.ts b/src/model/message.ts index 888a641..cb0d260 100644 --- a/src/model/message.ts +++ b/src/model/message.ts @@ -24,7 +24,7 @@ export default () => { return; } - const { data } = await API.getMessageCount({ + const { data } = await API.countMessage({ accesstoken: token, }); @@ -36,7 +36,7 @@ export default () => { return; } - const { data } = await API.getMessages({ + const { data } = await API.listMessage({ accesstoken: token, mdrender: false, }); diff --git a/src/page/auth/index.tsx b/src/page/auth/index.tsx index 53b04c2..910ef81 100644 --- a/src/page/auth/index.tsx +++ b/src/page/auth/index.tsx @@ -34,7 +34,7 @@ const AuthPage: React.FC = () => { const { accessToken } = values; if (type === FORM_TYPE.LOGIN) { - const data = await API.verifyAccessToken({ + const data = await API.authByAccessToken({ accesstoken: accessToken, }); diff --git a/src/page/message/index.tsx b/src/page/message/index.tsx index ae36802..b71a4ab 100644 --- a/src/page/message/index.tsx +++ b/src/page/message/index.tsx @@ -7,9 +7,6 @@ import MessageList from '@/component/MessageList'; const MessagePage: React.FC = (props) => { const { message, unreadMessage, mark, markAll } = useModel('message'); - console.debug('===message', message); - console.debug('===unreadMessage', unreadMessage); - const renderUnreadMessage = () => { if (unreadMessage?.length === 0) { return 暂无新消息; diff --git a/src/page/topic/detail.tsx b/src/page/topic/detail.tsx index e4bf917..ecd2b6a 100644 --- a/src/page/topic/detail.tsx +++ b/src/page/topic/detail.tsx @@ -31,7 +31,7 @@ const TopicDetailPage: React.FC> = (props) => { return; } - const res = await API.readTopic({ + const res = await API.loadTopic({ id: topicId, mdrender: false, }); @@ -48,8 +48,6 @@ const TopicDetailPage: React.FC> = (props) => { } const onComment = async (data: { content: string; reply_id?: string }) => { - console.debug('===onComment', topicId, token, data); - if (!token) { return; } diff --git a/src/page/topic/edit/index.tsx b/src/page/topic/edit/index.tsx index 46405aa..7bcfd28 100644 --- a/src/page/topic/edit/index.tsx +++ b/src/page/topic/edit/index.tsx @@ -21,7 +21,7 @@ const TopicEditPage: React.FC = (props) => { useRequest( async () => { if (!id) return; - const { data } = await API.readTopic({ + const { data } = await API.loadTopic({ id, mdrender: false, }); @@ -43,8 +43,6 @@ const TopicEditPage: React.FC = (props) => { ); const onFinish = async (values: any) => { - console.debug('===create.values', values); - if (!token) { return; } diff --git a/src/page/topic/index.tsx b/src/page/topic/index.tsx index 2407743..622d578 100644 --- a/src/page/topic/index.tsx +++ b/src/page/topic/index.tsx @@ -86,7 +86,6 @@ const TopicListPage: React.FC = (props) => { // console.debug('===scrollHeight', scrollHeight); if (pageYOffset + offsetHeight === scrollHeight) { - // console.log('===onReachEnd', hasNext, loading); onReachEnd(); } }; diff --git a/src/page/user/index.tsx b/src/page/user/index.tsx index 5f3158d..c3c0d91 100644 --- a/src/page/user/index.tsx +++ b/src/page/user/index.tsx @@ -7,7 +7,7 @@ import { Avatar, Divider, Space, Typography } from 'antd'; import ProCard from '@ant-design/pro-card'; import TopicList from '@/component/TopicList'; -import { getUserInfo } from '@/service/user'; +import * as API from '@/service/user'; import * as styles from './index.less'; @@ -19,7 +19,7 @@ const UserDetailPage: React.FC = (props) => { const { data } = useRequest(async () => { if (!params) return; const { loginname } = params; - const { data } = await getUserInfo({ loginname }); + const { data } = await API.loadUser({ loginname }); return data; }); diff --git a/src/service/message.ts b/src/service/message.ts index c81a753..e413c7c 100644 --- a/src/service/message.ts +++ b/src/service/message.ts @@ -1,7 +1,7 @@ import { request } from 'umi'; import { BASE_URL } from '@/constants'; -export const getMessageCount = async (params: { +export const countMessage = async (params: { accesstoken: string; }): Promise<{ data: number; @@ -14,7 +14,7 @@ export const getMessageCount = async (params: { return res; }; -export const getMessages = async (params: { +export const listMessage = async (params: { accesstoken: string; mdrender?: boolean; }): Promise<{ diff --git a/src/service/topic.ts b/src/service/topic.ts index 816a5dc..5186af0 100644 --- a/src/service/topic.ts +++ b/src/service/topic.ts @@ -54,7 +54,7 @@ export const updateTopic = async (data: { return request(`${BASE_URL}/api/v1/topics/update`, options); }; -export const readTopic = async (params: { +export const loadTopic = async (params: { id: string; mdrender?: boolean; accesstoken?: boolean; diff --git a/src/service/user.ts b/src/service/user.ts index 3068f1c..61571e9 100644 --- a/src/service/user.ts +++ b/src/service/user.ts @@ -1,7 +1,7 @@ import { request } from 'umi'; import { BASE_URL } from '@/constants'; -export const verifyAccessToken = async (data: { +export const authByAccessToken = async (data: { accesstoken: string; }): Promise<{ id: string; loginname: string; avatar_url: string }> => { const options: any = { @@ -13,7 +13,7 @@ export const verifyAccessToken = async (data: { return res; }; -export const getUserInfo = async (params: { +export const loadUser = async (params: { loginname: string; }): Promise<{ data: {