Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(bugs): 无法删除历史记录 #222

Merged
merged 1 commit into from
Dec 25, 2024
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
4 changes: 3 additions & 1 deletion src/common/utils/fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ const refreshToken = async () => {

const request = async (
url = '',
method: 'GET' | 'POST' = 'GET',
method: 'GET' | 'POST' | 'PUT' = 'GET',
data = {},
isToken = true
) => {
Expand Down Expand Up @@ -129,3 +129,5 @@ const request1 = async (url = '', method: 'GET' | 'POST' = 'GET', data = {}) =>
//为了躲避审核
export const postBool = (url = '', data = {}): Promise<unknown> =>
request1(url, 'POST', data);

export const put = (url = '', data = {}) => request(url, 'PUT', data, true);
27 changes: 27 additions & 0 deletions src/pages/editUser/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ const EditUser: React.FC = () => {
KeStackPartner: false,
None: false,
});

const titleRequirements = {
CaringSenior: 80,
KeStackPartner: 150,
CCNUWithMe: 300,
};

useEffect(() => {
const fetchUser = async () => {
try {
Expand Down Expand Up @@ -98,6 +105,26 @@ const EditUser: React.FC = () => {
const handleTitleSelect = (title: string) => {
if (titleOwnership[title]) {
setSelectedTitle(title);
} else {
const requirement = titleRequirements[title];
let titleName = '';
switch (title) {
case 'CaringSenior':
titleName = '知心学长';
break;
case 'KeStackPartner':
titleName = '课栈合伙人';
break;
case 'CCNUWithMe':
titleName = '华师有我';
break;
}
void Taro.showModal({
title: '称号获取条件',
content: `经验值达到${requirement},可获得"${titleName}"称号`,
showCancel: false,
confirmText: '知道了',
});
}
};
// Taro.redirectTo({url:'pages/login/index'});
Expand Down
9 changes: 3 additions & 6 deletions src/pages/feedback/index.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { Button, Textarea, View } from '@tarojs/components';
import { Textarea, View } from '@tarojs/components';
import Taro from '@tarojs/taro';
import React, { useState } from 'react';
import React from 'react';

import './index.scss';

const Feedback: React.FC = React.memo(() => {
const [textareaValue, setTextareaValue] = useState('');
// const [textareaValue, setTextareaValue] = useState('');
const copyText = '764752182';

const handleCopy = () => {
Expand Down Expand Up @@ -43,9 +43,6 @@ const Feedback: React.FC = React.memo(() => {
</View>
</View>
</View>
<View>
<Button>提交</Button>
</View>
</>
);
});
Expand Down
31 changes: 22 additions & 9 deletions src/pages/research/research.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import Label1 from '@/common/components/label1/label1';
import Label2 from '@/common/components/label2/label2';
import SearchInput from '@/common/components/SearchInput/SearchInput';
import { get } from '@/common/utils';
import { put } from '@/common/utils/fetch';

export interface Course {
id: number;
Expand Down Expand Up @@ -53,10 +54,21 @@ const Research: React.FC = () => {
setSpread(false);
};

const handleClick = () => {
// Taro.switchTab({
// url: '/pages/main/index',
// });
const handleDelete = () => {
put('/search/history', {
remove_all: true,
remove_history_ids: [],
search_location: 'Home',
}).then((res) => {
console.log(res);
if (res.code === 0) {
setHrs([]);
Taro.showToast({
title: '删除成功',
icon: 'success',
});
}
});
};

const handleSearch = (searchText: string) => {
Expand Down Expand Up @@ -92,9 +104,9 @@ const Research: React.FC = () => {
return (
<View
className="flex h-[100vh] w-[100vw] flex-col items-center overflow-auto"
onClick={() => {
handleClick();
}}
// onClick={() => {
// handleClick();
// }}
>
<SearchInput
autoFocus
Expand All @@ -109,14 +121,15 @@ const Research: React.FC = () => {
classes={classes}
hrs={hrs}
handleSearch={handleSearch}
handleDelete={handleDelete}
/>
</View>
);
};

export default Research;

const ConditionalRender = ({ isSpread, classes, hrs, handleSearch }) => {
const ConditionalRender = ({ isSpread, classes, hrs, handleSearch, handleDelete }) => {
return isSpread ? (
<View className="tj">
{classes.map((each) => (
Expand All @@ -127,7 +140,7 @@ const ConditionalRender = ({ isSpread, classes, hrs, handleSearch }) => {
<View className="relative flex flex-col items-center">
<View className="mt-[4vh] flex w-[80vw] flex-row justify-between">
<Text className="lsss">历史搜索</Text>
<View className="button">
<View className="button" onClick={handleDelete}>
<Image
style={{ width: '29.37rpx', height: '30.83rpx' }}
src="https://s2.loli.net/2023/08/26/3XBEGlN2UuJdejv.png"
Expand Down
Loading