diff --git a/CHANGELOG.md b/CHANGELOG.md index 0a2ea04c..b2507ec9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,15 @@ +## 2024-06-19 + +- 修复了不能通过神秘代码搜索作业集的问题 [@guansss](https://github.com/guansss) +- 增加了对未激活账号的提示 [@guansss](https://github.com/guansss) +- 在作业编辑器中添加了额外的提交按钮 [@aojunhao123](https://github.com/aojunhao123) +- 添加了 Google Analytics [@AlisaAkiron](https://github.com/AlisaAkiron) +- 改善了 SEO [@HauKuen](https://github.com/HauKuen) +- 修复暗黑模式下干员筛选标签背景色 [@aojunhao123](https://github.com/aojunhao123) +- 搜索时填写的包含/排除干员将会自动保存 [@zhangchi0104](https://github.com/zhangchi0104) +- 修复了切换搜索模式时输入框显示不正常的问题 [@guansss](https://github.com/guansss) +- 修复了暗黑模式的一些显示问题 [@ssoda01](https://github.com/ssoda01) + ## 2024-04-03 - 修复了因部分作业缺少动作列表而渲染失败的问题 diff --git a/index.html b/index.html index 5af610d9..8d4ebe8d 100644 --- a/index.html +++ b/index.html @@ -3,6 +3,8 @@ + + MAA Copilot refresh((key) => key.includes('operationSets')) + return () => + refresh( + (key) => + key.includes('operationSets') || + (key.includes('operationSet') && key.includes('fromList')), + ) +} + +export function useOperationSetSearch({ + keyword, + suspense, + disabled, + ...params +}: UseOperationSetsParams) { + if (!suspense) { + throw new Error('useOperationSetSearch must be used with suspense') + } + if (disabled) { + throw new Error('useOperationSetSearch cannot be disabled') + } + + let id: number | undefined + + if (keyword) { + const shortCodeContent = parseShortCode(keyword) + + if (shortCodeContent) { + id = shortCodeContent.id + } + } + + const { data: operationSet } = useOperationSet({ id, suspense }) + + const listResponse = useOperationSets({ + keyword, + suspense, + ...params, + + // disable the list query if we are fetching a single operation set + disabled: !!id, + }) + + if (id) { + return { + operationSets: [operationSet], + isReachingEnd: true, + setSize: noop, + + // these are fixed values in suspense mode + error: undefined, + isValidating: false, + } + } + + return listResponse } interface UseOperationSetParams { diff --git a/src/apis/operation.ts b/src/apis/operation.ts index 1a280bbf..2e127cf2 100644 --- a/src/apis/operation.ts +++ b/src/apis/operation.ts @@ -4,7 +4,7 @@ import useSWRInfinite from 'swr/infinite' import { toCopilotOperation } from 'models/converter' import { OpRatingType, Operation } from 'models/operation' -import { parseShortCode } from 'models/shortCode' +import { ShortCodeContent, parseShortCode } from 'models/shortCode' import { OperationApi } from 'utils/maa-copilot-client' import { useSWRRefresh } from 'utils/swr' @@ -48,15 +48,21 @@ export function useOperations({ return null // reached the end } - // 用户输入 maa://xxxxxx 时,只传这个 id,其他参数都不传 + // 用户输入神秘代码时,只传这个 id,其他参数都不传 if (keyword) { - const id = parseShortCode(keyword) + let content: ShortCodeContent | null = null - if (id) { + try { + content = parseShortCode(keyword) + } catch (e) { + console.warn(e) + } + + if (content) { return [ 'operations', { - copilotIds: [id], + copilotIds: [content.id], } satisfies QueriesCopilotRequest, ] } diff --git a/src/components/AccountManager.tsx b/src/components/AccountManager.tsx index 94b85616..20615e98 100644 --- a/src/components/AccountManager.tsx +++ b/src/components/AccountManager.tsx @@ -14,7 +14,7 @@ import { } from '@blueprintjs/core' import { Popover2 } from '@blueprintjs/popover2' -import { useAtom, useSetAtom } from 'jotai' +import { useAtom } from 'jotai' import { ComponentType, FC, useState } from 'react' import { LoginPanel } from 'components/account/LoginPanel' @@ -30,7 +30,7 @@ import { EditDialog } from './account/EditDialog' import { RegisterPanel } from './account/RegisterPanel' const AccountMenu: FC = () => { - const setAuthState = useSetAtom(authAtom) + const [authState, setAuthState] = useAtom(authAtom) const [logoutDialogOpen, setLogoutDialogOpen] = useState(false) const [editDialogOpen, setEditDialogOpen] = useState(false) @@ -64,6 +64,14 @@ const AccountMenu: FC = () => { /> + {!authState.activated && ( + + )} + = ({ title, children }) => (
- + {children} - {title} + {title}
) diff --git a/src/components/FactItem.tsx b/src/components/FactItem.tsx index 5c147269..c57df083 100644 --- a/src/components/FactItem.tsx +++ b/src/components/FactItem.tsx @@ -19,8 +19,8 @@ export const FactItem: FCC<{ className, )} > - {icon && } -
{title}
+ {icon && } +
{title}
{children} ) diff --git a/src/components/HelperText.tsx b/src/components/HelperText.tsx index 27bd3d3e..6c851254 100644 --- a/src/components/HelperText.tsx +++ b/src/components/HelperText.tsx @@ -22,7 +22,7 @@ export const HelperText: FCC<{ } return ( -
+
{child()}
diff --git a/src/components/OperationCard.tsx b/src/components/OperationCard.tsx index 8c8b2905..6cbeceb7 100644 --- a/src/components/OperationCard.tsx +++ b/src/components/OperationCard.tsx @@ -2,7 +2,7 @@ import { Button, Card, Elevation, H4, H5, Icon, Tag } from '@blueprintjs/core' import { Tooltip2 } from '@blueprintjs/popover2' import clsx from 'clsx' -import { handleCopyShortCode, handleDownloadJSON } from 'services/operation' +import { copyShortCode, handleDownloadJSON } from 'services/operation' import { ReLink } from 'components/ReLink' import { RelativeTime } from 'components/RelativeTime' @@ -61,7 +61,7 @@ export const NeoOperationCard = ({ operation }: { operation: Operation }) => { />
-
+
干员/干员组
@@ -187,7 +187,7 @@ export const OperationCard = ({ operation }: { operation: Operation }) => { />
-
+
干员/干员组
@@ -263,7 +263,7 @@ const CardActions = ({