Skip to content

Commit

Permalink
fix: some bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
bs32g1038 committed Mar 24, 2024
1 parent 9e52e10 commit dcb905c
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 53 deletions.
7 changes: 4 additions & 3 deletions web/components/LoginModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Modal from '../Modal';
import { Form, Input, Button, message, Space, Image, Checkbox } from 'antd';
import { LockOutlined, MailOutlined, UserOutlined } from '@ant-design/icons';
import axios from 'axios';
import { useRouter } from 'next/router';
import { useRouter } from 'next/navigation';
import { useForm } from 'antd/lib/form/Form';
import Cookies from 'js-cookie';
import styles from './index.module.scss';
Expand Down Expand Up @@ -32,7 +32,7 @@ export default function LoginModal() {
const { isShowLoginModal, setUser, showLoginModal } = useAppStore();
const [form] = useForm();
const [tab, setTab] = useState(LOGIN_TYPE.login);
// const router = useRouter();
const router = useRouter();
const { trigger: login } = useSWRMutation('/api/v1/auth/login', sendRequest);
const { trigger: register } = useSWRMutation('/api/v1/auth/signup', sendRequest);
const onFinish = (values: any) => {
Expand All @@ -43,7 +43,8 @@ export default function LoginModal() {
message.success('登录成功!');
Cookies.set('token', token);
setUser(res.data?.data);
// router.reload();
router.refresh();
showLoginModal(false);
});
return;
}
Expand Down
7 changes: 3 additions & 4 deletions web/components/Write/index.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
'use client';

import React, { use, useRef } from 'react';
import React, { useRef } from 'react';
import styles from './index.module.scss';
import { Button, Form, Input, Select, Upload, message } from 'antd';
import { useForm } from 'antd/lib/form/Form';
import JEditor from '../JEditor';
import TagGroup from '../TagGroup';
import { useRouter } from 'next/navigation';
import { useSWR, useSWRMutation } from '@/hooks';
import Layout from '../Layout';
Expand All @@ -17,7 +16,7 @@ const Write = () => {
const router = useRouter();
const { user } = useAppStore();
const { data, isLoading } = useSWR({ url: '/api/v1/tags' });
const { trigger: createPost } = useSWRMutation({ url: '/api/v1/posts' });
const { trigger: createPost, isMutating } = useSWRMutation({ url: '/api/v1/posts' });
const ref = useRef(null);
const handleUpload = (info) => {
if (Array.isArray(info)) {
Expand Down Expand Up @@ -77,7 +76,7 @@ const Write = () => {
</Select>
</Form.Item>
<div className={styles.ctrl}>
<Button onClick={() => form.submit()} type="primary">
<Button onClick={() => form.submit()} type="primary" loading={isMutating}>
发布
</Button>
</div>
Expand Down
1 change: 0 additions & 1 deletion web/components/home/components/TopTip/index.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
img {
width: 32px;
height: 32px;
margin-right: 10px;
}
h2 {
font-size: 14px;
Expand Down
20 changes: 9 additions & 11 deletions web/components/home/components/TopTip/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,15 @@ export default function TopTip() {
</div>
<div className={styles.footer}>
<Skeleton loading={getUserLoading} paragraph={false}>
<Avatar.Group>
{data?.data?.content?.map((item) => {
return (
<Tooltip title={item.username} placement="top" key={item.id}>
<Link href={`/profile/${item?.account}`}>
<Avatar src={item?.image} />
</Link>
</Tooltip>
);
})}
</Avatar.Group>
{data?.data?.content?.map((item) => {
return (
<Tooltip title={item.username} placement="top" key={item.id}>
<Link href={`/profile/${item?.account}`}>
<Avatar src={item?.image} />
</Link>
</Tooltip>
);
})}
</Skeleton>
</div>
</div>
Expand Down
34 changes: 0 additions & 34 deletions web/components/home/index.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,6 @@
// 'use client';

import { useState } from 'react';
import Layout from '../../components/Layout';
import { Empty, Pagination } from 'antd';
import styles from './index.module.scss';
import TopicItem from './components/TopicItem';
import CategoryList from './components/CategoryList';
import { isUndefined, omitBy } from 'lodash';
import { useParams, useRouter } from 'next/navigation';
import PinnedList from './components/PinnedList';
import axios from '@/libs/axios';
import TopTip from './components/TopTip';
import LoadAsyncMore from '../LoadAsyncMore';
import Articles from './components/Articles';

const Home = async (props: { searchParams: any }) => {
Expand All @@ -24,26 +13,3 @@ const Home = async (props: { searchParams: any }) => {
return <Articles data={data} searchParams={props.searchParams}></Articles>;
};
export default Home;

// export async function getServerSideProps(context) {
// const { query } = context;
// const { categoryId, sort, type, q, page = 1 } = query;
// console.log("categoryId", categoryId, 'sadsdssss', query)
// const reqParams = omitBy(
// {
// // categoryId,
// isHot: categoryId === 'hot',
// type,
// query: q,
// page: page - 1,
// },
// isUndefined
// );
// const url = '/api/v1/posts';
// const res = await axios.get(url, { params: reqParams }).then((res) => res.data);
// return {
// props: {
// data: res,
// },
// };
// }

0 comments on commit dcb905c

Please sign in to comment.