Skip to content

Commit ba43aee

Browse files
authored
Merge pull request #393 from MaaAssistantArknights/dev
Release to Production
2 parents 2ab1020 + 5bad3cc commit ba43aee

26 files changed

+1201
-449
lines changed

.env.development

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
PORT=3000
33

44
# 如果需要使用生产环境的API,请把下面一行注释掉,或者在.env.development.local中覆盖
5-
VITE_API=https://maa-docker.kkdy.tech
5+
VITE_API=https://maa-backend-dev.theresa.wiki

CHANGELOG.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
## 2025-04-04
2+
3+
- 优化了首页列表的性能 [@Aliothmoon](https://github.com/Aliothmoon)
4+
- 添加了私有作业功能 [@guansss](https://github.com/guansss) [@dragove](https://github.com/dragove)
5+
- 添加了关闭评论区功能 [@guansss](https://github.com/guansss) [@dragove](https://github.com/dragove)
6+
- 添加了按用户筛选功能 [@guansss](https://github.com/guansss) [@Pleasurecruise](https://github.com/Pleasurecruise) [@dragove](https://github.com/dragove)
7+
- 重新设计了主页的搜索面板 [@guansss](https://github.com/guansss)
8+
- 搜索功能的全文索引优化 [@Aliothmoon](https://github.com/Aliothmoon) [@Handiwork](https://github.com/Handiwork)
9+
- 修复了按干员筛选时和异格冲突的问题 [@LuoRenMu](https://github.com/LuoRenMu)
10+
- 优化了敏感词检测 [@dragove](https://github.com/dragove) [@Daydreamer114](https://github.com/Daydreamer114)
11+
12+
从现在起,后端的更新和贡献者也会一并列出 (~ ̄▽ ̄)~
13+
14+
## 2025-03-15
15+
16+
- 优化了暗色模式界面显示 [@zhangchi0104](https://github.com/zhangchi0104)
17+
118
## 2025-03-01
219

320
- 优化了移动端界面 [@guansss](https://github.com/guansss)

README.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,14 @@
22

33
MAA 作业站前端!
44

5-
## 开发流程
5+
## 文档
6+
7+
- ~~后端接口文档~~ (暂无,请参考 [maa-copilot-client](https://github.com/MaaAssistantArknights/maa-copilot-client-ts) 的 TS 类型,或者从后端 [Actions](https://github.com/MaaAssistantArknights/MaaBackendCenter/actions/workflows/openapi.yml) 的 Artifacts 里下载最新的 OpenAPI 文档)
8+
- 作业格式:[MAA 战斗流程协议](https://maa.plus/docs/zh-cn/protocol/copilot-schema.html)
69

7-
后端接口文档:https://maa-docker.kkdy.tech/swagger-ui/index.html
10+
更新 maa-copilot-client 时,需要在 [Tags](https://github.com/MaaAssistantArknights/maa-copilot-client-ts/tags) 中复制版本号,然后替换掉 `package.json` 中的 `maa-copilot-client` 版本号,再运行 `yarn` 安装依赖
11+
12+
## 开发流程
813

914
该仓库的主分支为 `dev`,线上分支为 `main`,代码合并到 `main` 后将会自动部署到线上
1015

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
"linkify-react": "^3.0.4",
4545
"linkifyjs": "^3.0.5",
4646
"lodash-es": "^4.17.21",
47-
"maa-copilot-client": "https://github.com/MaaAssistantArknights/maa-copilot-client-ts.git#0.1.0-SNAPSHOT.784.58f96e5",
47+
"maa-copilot-client": "https://github.com/MaaAssistantArknights/maa-copilot-client-ts.git#0.1.0-SNAPSHOT.824.f8ad839",
4848
"normalize.css": "^8.0.1",
4949
"prettier": "^3.2.5",
5050
"react": "^18.0.0",

src/apis/operation.ts

Lines changed: 43 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
import { uniqBy } from 'lodash-es'
2-
import { QueriesCopilotRequest } from 'maa-copilot-client'
2+
import {
3+
BanCommentsStatusEnum,
4+
CopilotInfoStatusEnum,
5+
QueriesCopilotRequest,
6+
} from 'maa-copilot-client'
37
import useSWR from 'swr'
48
import useSWRInfinite from 'swr/infinite'
59

@@ -11,13 +15,18 @@ import { useSWRRefresh } from 'utils/swr'
1115

1216
export type OrderBy = 'views' | 'hot' | 'id'
1317

18+
export interface OperatorFilterParams {
19+
included: string[]
20+
excluded: string[]
21+
}
22+
1423
export interface UseOperationsParams {
1524
limit?: number
1625
orderBy?: OrderBy
1726
descending?: boolean
1827
keyword?: string
1928
levelKeyword?: string
20-
operator?: string
29+
operator?: OperatorFilterParams
2130
operationIds?: number[]
2231
uploaderId?: string
2332

@@ -80,7 +89,12 @@ export function useOperations({
8089
page: pageIndex + 1,
8190
document: keyword,
8291
levelKeyword,
83-
operator,
92+
operator: operator
93+
? [
94+
...operator.included,
95+
...operator.excluded.map((o) => `~${o}`),
96+
].join(',') || undefined
97+
: undefined,
8498
orderBy,
8599
desc: descending,
86100
copilotIds: operationIds,
@@ -178,16 +192,29 @@ export async function getOperation(req: { id: number }): Promise<Operation> {
178192
}
179193
}
180194

181-
export async function createOperation(req: { content: string }) {
195+
export async function createOperation(req: {
196+
content: string
197+
status: CopilotInfoStatusEnum
198+
}) {
182199
await new OperationApi().uploadCopilot({ copilotCUDRequest: req })
183200
}
184201

185-
export async function updateOperation(req: { id: number; content: string }) {
202+
export async function updateOperation(req: {
203+
id: number
204+
content: string
205+
status: CopilotInfoStatusEnum
206+
}) {
186207
await new OperationApi().updateCopilot({ copilotCUDRequest: req })
187208
}
188209

189210
export async function deleteOperation(req: { id: number }) {
190-
await new OperationApi().deleteCopilot({ copilotCUDRequest: req })
211+
await new OperationApi().deleteCopilot({
212+
copilotCUDRequest: {
213+
content: '',
214+
status: CopilotInfoStatusEnum.Public,
215+
...req,
216+
},
217+
})
191218
}
192219

193220
export async function rateOperation(req: { id: number; rating: OpRatingType }) {
@@ -204,3 +231,13 @@ export async function rateOperation(req: { id: number; rating: OpRatingType }) {
204231
},
205232
})
206233
}
234+
235+
export async function banComments(req: {
236+
operationId: number
237+
status: BanCommentsStatusEnum
238+
}) {
239+
await new OperationApi().banComments({
240+
copilotId: req.operationId,
241+
...req,
242+
})
243+
}

src/apis/user.ts

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import useSWR from 'swr'
22

3-
import { NotFoundError } from '../utils/error'
43
import { UserApi } from '../utils/maa-copilot-client'
54

65
export function useUserInfo({
@@ -20,13 +19,27 @@ export function useUserInfo({
2019
userId,
2120
})
2221

23-
// FIXME: 严谨一点!!!
24-
if (res.data.userName === '未知用户:(') {
25-
throw new NotFoundError()
26-
}
27-
2822
return res.data
2923
},
3024
{ suspense },
3125
)
3226
}
27+
28+
export function useUserSearch({ keyword }: { keyword?: string }) {
29+
return useSWR(
30+
keyword ? ['userSearch', keyword] : null,
31+
async ([, keyword]) => {
32+
const res = await new UserApi({
33+
sendToken: 'never',
34+
requireData: true,
35+
}).searchUsers({
36+
userName: keyword,
37+
})
38+
return res.data
39+
},
40+
{
41+
revalidateOnFocus: false,
42+
keepPreviousData: true,
43+
},
44+
)
45+
}

src/components/Confirm.tsx

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
import { Alert, AlertProps } from '@blueprintjs/core'
2+
3+
import { useEffect, useState } from 'react'
4+
5+
import { FCC } from '../types'
6+
7+
interface ConfirmProps extends Omit<AlertProps, 'isOpen' | 'onConfirm'> {
8+
repeats?: number
9+
trigger: (params: { handleClick: () => void }) => React.ReactNode
10+
onConfirm?: () => void | Promise<void>
11+
}
12+
13+
export const Confirm: FCC<ConfirmProps> = ({
14+
repeats = 0,
15+
confirmButtonText = '确定',
16+
intent = 'primary',
17+
trigger,
18+
onConfirm,
19+
...props
20+
}) => {
21+
const [isOpen, setIsOpen] = useState(false)
22+
const [confirming, setConfirming] = useState(false)
23+
const [remainingRepeats, setRemainingRepeats] = useState(repeats)
24+
25+
useEffect(() => {
26+
if (isOpen) {
27+
setRemainingRepeats(repeats)
28+
}
29+
}, [isOpen, repeats])
30+
31+
const handleConfirm = async () => {
32+
if (confirming) return
33+
if (remainingRepeats > 1) {
34+
setRemainingRepeats((prev) => prev - 1)
35+
return
36+
}
37+
38+
setConfirming(true)
39+
try {
40+
await onConfirm?.()
41+
} catch (e) {
42+
console.error(e)
43+
}
44+
setConfirming(false)
45+
setIsOpen(false)
46+
}
47+
48+
return (
49+
<>
50+
{trigger({ handleClick: () => setIsOpen(true) })}
51+
<Alert
52+
cancelButtonText="取消"
53+
icon={
54+
intent === 'danger' || intent === 'warning' ? 'error' : 'info-sign'
55+
}
56+
{...props}
57+
isOpen={isOpen}
58+
loading={confirming}
59+
intent={intent}
60+
confirmButtonText={
61+
repeats
62+
? `${confirmButtonText} (${remainingRepeats})`
63+
: confirmButtonText
64+
}
65+
onCancel={() => {
66+
if (confirming) return
67+
setIsOpen(false)
68+
}}
69+
onConfirm={handleConfirm}
70+
/>
71+
</>
72+
)
73+
}

0 commit comments

Comments
 (0)