Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions config/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ const routes: IRoute[] = [
path: '/topic/:id/edit',
exact: true,
component: '@/page/topic/edit',
access: 'canPostTopic',
},
{
path: '/user/:loginname',
Expand Down
2 changes: 1 addition & 1 deletion src/layout/component/UserInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const UserInfo: React.FC<Props> = (props) => {
return;
}

const res = await API.getUserInfo({ loginname });
const res = await API.loadUser({ loginname });
return res.data;
},
{
Expand Down
11 changes: 5 additions & 6 deletions src/layout/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const getCurrentRoute = (route: IRoute, path: string): IRoute | undefined => {
const BREADCRUMB_NAME_MAP = {
user: '用户',
topic: '话题',
edit: '编辑',
};

const Layout: React.FC<React.PropsWithChildren<Props>> = (props) => {
Expand All @@ -46,7 +47,7 @@ const Layout: React.FC<React.PropsWithChildren<Props>> = (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';

Expand All @@ -60,17 +61,15 @@ const Layout: React.FC<React.PropsWithChildren<Props>> = (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'],
});
}

Expand Down
4 changes: 2 additions & 2 deletions src/model/message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export default () => {
return;
}

const { data } = await API.getMessageCount({
const { data } = await API.countMessage({
accesstoken: token,
});

Expand All @@ -36,7 +36,7 @@ export default () => {
return;
}

const { data } = await API.getMessages({
const { data } = await API.listMessage({
accesstoken: token,
mdrender: false,
});
Expand Down
2 changes: 1 addition & 1 deletion src/page/auth/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const AuthPage: React.FC<Props> = () => {
const { accessToken } = values;

if (type === FORM_TYPE.LOGIN) {
const data = await API.verifyAccessToken({
const data = await API.authByAccessToken({
accesstoken: accessToken,
});

Expand Down
3 changes: 0 additions & 3 deletions src/page/message/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ import MessageList from '@/component/MessageList';
const MessagePage: React.FC<Props> = (props) => {
const { message, unreadMessage, mark, markAll } = useModel('message');

console.debug('===message', message);
console.debug('===unreadMessage', unreadMessage);

const renderUnreadMessage = () => {
if (unreadMessage?.length === 0) {
return <span>暂无新消息</span>;
Expand Down
4 changes: 1 addition & 3 deletions src/page/topic/detail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const TopicDetailPage: React.FC<React.PropsWithChildren<Props>> = (props) => {
return;
}

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

const onComment = async (data: { content: string; reply_id?: string }) => {
console.debug('===onComment', topicId, token, data);

if (!token) {
return;
}
Expand Down
4 changes: 1 addition & 3 deletions src/page/topic/edit/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const TopicEditPage: React.FC<Props> = (props) => {
useRequest(
async () => {
if (!id) return;
const { data } = await API.readTopic({
const { data } = await API.loadTopic({
id,
mdrender: false,
});
Expand All @@ -43,8 +43,6 @@ const TopicEditPage: React.FC<Props> = (props) => {
);

const onFinish = async (values: any) => {
console.debug('===create.values', values);

if (!token) {
return;
}
Expand Down
1 change: 0 additions & 1 deletion src/page/topic/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ const TopicListPage: React.FC<Props> = (props) => {
// console.debug('===scrollHeight', scrollHeight);

if (pageYOffset + offsetHeight === scrollHeight) {
// console.log('===onReachEnd', hasNext, loading);
onReachEnd();
}
};
Expand Down
4 changes: 2 additions & 2 deletions src/page/user/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand All @@ -19,7 +19,7 @@ const UserDetailPage: React.FC<Props> = (props) => {
const { data } = useRequest(async () => {
if (!params) return;
const { loginname } = params;
const { data } = await getUserInfo({ loginname });
const { data } = await API.loadUser({ loginname });
return data;
});

Expand Down
4 changes: 2 additions & 2 deletions src/service/message.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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<{
Expand Down
2 changes: 1 addition & 1 deletion src/service/topic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/service/user.ts
Original file line number Diff line number Diff line change
@@ -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 = {
Expand All @@ -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: {
Expand Down