Skip to content

Commit aec80c6

Browse files
添加显示文章分类;添加只审题解按钮;release 0.6.0
1 parent c53ef23 commit aec80c6

File tree

4 files changed

+54
-30
lines changed

4 files changed

+54
-30
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"author": "Mr. Python",
77
"repository": "https://github.com/Mr-Python-in-China/lg-admin-extend.git",
88
"license": "LGPL-2.1-or-later",
9-
"version": "0.5.0",
9+
"version": "0.6.0",
1010
"private": true,
1111
"packageManager": "yarn@4.3.1",
1212
"scripts": {

src/app/features/article/index.tsx

Lines changed: 39 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import emptyQueueImage from 'assets/emptyQueue.webp';
2828
import { isCancel } from 'axios';
2929
import { useNotUndefinedContext } from '../../../notUndefinedContext';
3030
import { MyInfoContext } from '../../contexts';
31-
import { oldDifficultySystem } from '../../../constants';
31+
import { ArticleCategory, oldDifficultySystem } from '../../../constants';
3232
import { getArticle, submitArticleCheckResult } from '../../../fetch';
3333
import {
3434
ErrorDiv,
@@ -55,6 +55,7 @@ export default function Article() {
5555
const [viewSourceCode, setViewSourceCode] = useState(false);
5656
const myProfile = useNotUndefinedContext(MyInfoContext);
5757
const [showHistory, setShowHistory] = useState(false);
58+
const [solutionOnly, setSolutionOnly] = useState(true);
5859

5960
let refuseCommit = otherRefuseCommit;
6061
if (refuseCommit)
@@ -63,7 +64,9 @@ export default function Article() {
6364

6465
useEffect(() => {
6566
const cancel = new AbortController();
66-
getArticle(skipBefore / 1000, { signal: cancel.signal })
67+
getArticle(skipBefore / 1000, solutionOnly ? [2] : [], {
68+
signal: cancel.signal
69+
})
6770
.then(v => {
6871
setStatus({ details: v }),
6972
v.article && setSkipBefore(v.article.promoteResult.updateAt * 1000);
@@ -76,7 +79,7 @@ export default function Article() {
7679
}, []);
7780
function updateArticle() {
7881
setStatus(null);
79-
getArticle(skipBefore / 1000)
82+
getArticle(skipBefore / 1000, solutionOnly ? [2] : [])
8083
.then(v => {
8184
setStatus({ details: v });
8285
if (v.article) setSkipBefore(v.article.promoteResult.updateAt * 1000);
@@ -175,32 +178,35 @@ export default function Article() {
175178
{details.article.lid}
176179
</Link>
177180
</Text>
178-
{details.article.solutionFor && (
179-
<Text>
180-
关联于题目{' '}
181-
<ProblemNameWithDifficulty
182-
pid={details.article.solutionFor.pid}
183-
name={details.article.solutionFor.title}
184-
difficulty={oldDifficultySystem.findIndex(
185-
x => x >= details.article.solutionFor!.difficulty
181+
<Text>
182+
文章分类:{ArticleCategory[details.article.category]}
183+
{details.article.solutionFor && (
184+
<>
185+
关联于题目{' '}
186+
<ProblemNameWithDifficulty
187+
pid={details.article.solutionFor.pid}
188+
name={details.article.solutionFor.title}
189+
difficulty={oldDifficultySystem.findIndex(
190+
x => x >= details.article.solutionFor!.difficulty
191+
)}
192+
/>
193+
194+
{details.countForProblem && (
195+
<>
196+
共有 {details.countForProblem.pending} 篇待审核题解,
197+
{details.countForProblem.available}
198+
<Link
199+
href={`https://www.luogu.com.cn/problem/solution/${details.article.solutionFor.pid}`}
200+
target="_blank"
201+
>
202+
已通过题解
203+
</Link>
204+
205+
</>
186206
)}
187-
/>
188-
189-
{details.countForProblem && (
190-
<>
191-
共有 {details.countForProblem.pending} 篇待审核题解,
192-
{details.countForProblem.available}
193-
<Link
194-
href={`https://www.luogu.com.cn/problem/solution/${details.article.solutionFor.pid}`}
195-
target="_blank"
196-
>
197-
已通过题解
198-
</Link>
199-
200-
</>
201-
)}
202-
</Text>
203-
)}
207+
</>
208+
)}
209+
</Text>
204210
<div className="adminCommit">
205211
<Text>管理员备注:</Text>
206212
<textarea
@@ -261,6 +267,11 @@ export default function Article() {
261267
</Field>
262268
<div className="submitButton">
263269
<Text as="span">队列中还有 {details?.count || 0} 篇文章。</Text>
270+
<Switch
271+
label="只审题解"
272+
checked={solutionOnly}
273+
onChange={(e, x) => setSolutionOnly(x.checked)}
274+
/>
264275
<Button
265276
appearance="primary"
266277
disabled={!(details?.article && !status?.submiting)}

src/constants.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,14 @@ export const UsernameColor = {
2020
Gray: 'rgb(191, 191, 191)',
2121
Cheater: 'rgb(173, 139, 0)'
2222
};
23+
24+
export const ArticleCategory: Record<number, string> = {
25+
'1': '个人记录',
26+
'2': '题解',
27+
'3': '科技·工程',
28+
'4': '算法·理论',
29+
'5': '生活·游记',
30+
'6': '学习·文化课',
31+
'7': '休闲·娱乐',
32+
'8': '闲话'
33+
};

src/fetch/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ export const fetchMyInfo = (config: AxiosRequestConfig = {}) =>
3838

3939
export const getArticle = (
4040
skipBefore: number,
41+
category: number[] = [],
4142
config: AxiosRequestConfig = {}
4243
) =>
4344
axios
@@ -47,7 +48,8 @@ export const getArticle = (
4748
deepmerge(
4849
{
4950
params: {
50-
skipBefore: skipBefore || 0
51+
skipBefore: skipBefore || 0,
52+
category: category.join(',')
5153
}
5254
},
5355
config

0 commit comments

Comments
 (0)