Skip to content

Commit 95b5191

Browse files
authored
refactor: rename methods (#26)
1 parent 4fe0bd1 commit 95b5191

File tree

13 files changed

+19
-27
lines changed

13 files changed

+19
-27
lines changed

config/routes.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ const routes: IRoute[] = [
6666
path: '/topic/:id/edit',
6767
exact: true,
6868
component: '@/page/topic/edit',
69+
access: 'canPostTopic',
6970
},
7071
{
7172
path: '/user/:loginname',

src/layout/component/UserInfo.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const UserInfo: React.FC<Props> = (props) => {
2121
return;
2222
}
2323

24-
const res = await API.getUserInfo({ loginname });
24+
const res = await API.loadUser({ loginname });
2525
return res.data;
2626
},
2727
{

src/layout/index.tsx

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ const getCurrentRoute = (route: IRoute, path: string): IRoute | undefined => {
3232
const BREADCRUMB_NAME_MAP = {
3333
user: '用户',
3434
topic: '话题',
35+
edit: '编辑',
3536
};
3637

3738
const Layout: React.FC<React.PropsWithChildren<Props>> = (props) => {
@@ -46,7 +47,7 @@ const Layout: React.FC<React.PropsWithChildren<Props>> = (props) => {
4647
const detailPaths = location.pathname.match(/\/(topic|user)\/(\w+)(\/\w+)?/);
4748

4849
if (detailPaths) {
49-
const [, category, id, status] = detailPaths;
50+
const [pathname, category, id, status] = detailPaths;
5051

5152
const isEdit = status === '/edit';
5253

@@ -60,17 +61,15 @@ const Layout: React.FC<React.PropsWithChildren<Props>> = (props) => {
6061
breadcrumbName: BREADCRUMB_NAME_MAP[category as 'user' | 'topic'],
6162
},
6263
{
63-
path: isEdit
64-
? location.pathname.replace(status, '')
65-
: location.pathname,
64+
path: `/${category}/${id}`,
6665
breadcrumbName: id,
6766
},
6867
];
6968

7069
if (isEdit) {
7170
routes.push({
72-
path: location.pathname,
73-
breadcrumbName: '编辑',
71+
path: pathname,
72+
breadcrumbName: BREADCRUMB_NAME_MAP['edit'],
7473
});
7574
}
7675

src/model/message.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export default () => {
2424
return;
2525
}
2626

27-
const { data } = await API.getMessageCount({
27+
const { data } = await API.countMessage({
2828
accesstoken: token,
2929
});
3030

@@ -36,7 +36,7 @@ export default () => {
3636
return;
3737
}
3838

39-
const { data } = await API.getMessages({
39+
const { data } = await API.listMessage({
4040
accesstoken: token,
4141
mdrender: false,
4242
});

src/page/auth/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ const AuthPage: React.FC<Props> = () => {
3434
const { accessToken } = values;
3535

3636
if (type === FORM_TYPE.LOGIN) {
37-
const data = await API.verifyAccessToken({
37+
const data = await API.authByAccessToken({
3838
accesstoken: accessToken,
3939
});
4040

src/page/message/index.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@ import MessageList from '@/component/MessageList';
77
const MessagePage: React.FC<Props> = (props) => {
88
const { message, unreadMessage, mark, markAll } = useModel('message');
99

10-
console.debug('===message', message);
11-
console.debug('===unreadMessage', unreadMessage);
12-
1310
const renderUnreadMessage = () => {
1411
if (unreadMessage?.length === 0) {
1512
return <span>暂无新消息</span>;

src/page/topic/detail.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ const TopicDetailPage: React.FC<React.PropsWithChildren<Props>> = (props) => {
3131
return;
3232
}
3333

34-
const res = await API.readTopic({
34+
const res = await API.loadTopic({
3535
id: topicId,
3636
mdrender: false,
3737
});
@@ -48,8 +48,6 @@ const TopicDetailPage: React.FC<React.PropsWithChildren<Props>> = (props) => {
4848
}
4949

5050
const onComment = async (data: { content: string; reply_id?: string }) => {
51-
console.debug('===onComment', topicId, token, data);
52-
5351
if (!token) {
5452
return;
5553
}

src/page/topic/edit/index.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const TopicEditPage: React.FC<Props> = (props) => {
2121
useRequest(
2222
async () => {
2323
if (!id) return;
24-
const { data } = await API.readTopic({
24+
const { data } = await API.loadTopic({
2525
id,
2626
mdrender: false,
2727
});
@@ -43,8 +43,6 @@ const TopicEditPage: React.FC<Props> = (props) => {
4343
);
4444

4545
const onFinish = async (values: any) => {
46-
console.debug('===create.values', values);
47-
4846
if (!token) {
4947
return;
5048
}

src/page/topic/index.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ const TopicListPage: React.FC<Props> = (props) => {
8686
// console.debug('===scrollHeight', scrollHeight);
8787

8888
if (pageYOffset + offsetHeight === scrollHeight) {
89-
// console.log('===onReachEnd', hasNext, loading);
9089
onReachEnd();
9190
}
9291
};

src/page/user/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { Avatar, Divider, Space, Typography } from 'antd';
77
import ProCard from '@ant-design/pro-card';
88

99
import TopicList from '@/component/TopicList';
10-
import { getUserInfo } from '@/service/user';
10+
import * as API from '@/service/user';
1111

1212
import * as styles from './index.less';
1313

@@ -19,7 +19,7 @@ const UserDetailPage: React.FC<Props> = (props) => {
1919
const { data } = useRequest(async () => {
2020
if (!params) return;
2121
const { loginname } = params;
22-
const { data } = await getUserInfo({ loginname });
22+
const { data } = await API.loadUser({ loginname });
2323
return data;
2424
});
2525

0 commit comments

Comments
 (0)