diff --git a/CHANGELOG.md b/CHANGELOG.md index 60de3e51..bfc93852 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## 2025-03-01 + +- 优化了移动端界面 [@guansss](https://github.com/guansss) +- 加入广告 [@guansss](https://github.com/guansss) + ## 2025-02-22 - 添加了关卡筛选器的联想输入功能 [@guansss](https://github.com/guansss) diff --git a/public/ads_mumu.jpg b/public/ads_mumu.jpg new file mode 100644 index 00000000..d0536e6a Binary files /dev/null and b/public/ads_mumu.jpg differ diff --git a/src/apis/announcement.ts b/src/apis/announcement.ts index c7b8e636..7d23801c 100644 --- a/src/apis/announcement.ts +++ b/src/apis/announcement.ts @@ -20,7 +20,6 @@ export function useAnnouncement() { .then((res) => res.text()) .catch((e) => { if ((e as Error).message === 'Failed to fetch') { - console.warn(e) throw new Error('网络错误') } diff --git a/src/components/NavExpandButton.tsx b/src/components/NavExpandButton.tsx index bc9dfc65..a4c6124b 100644 --- a/src/components/NavExpandButton.tsx +++ b/src/components/NavExpandButton.tsx @@ -6,14 +6,13 @@ import { navAtom, toggleExpandNavAtom } from 'store/nav' export const NavExpandButton = () => { const expanded = useAtomValue(navAtom) - const toggleExpaned = useSetAtom(toggleExpandNavAtom) + const toggleExpand = useSetAtom(toggleExpandNavAtom) return ( -
-
+ - )} - - - ))} - + /> + )} + + ))} + + { + setShowOperationSetDialog(true) + toggleNav() + }} + /> + ( + + )} + /> + + +
+ {SOCIAL_LINKS.map((link) => ( + + {link.icon} + {link.label} + + )).reduce((prev, curr) => ( + <> + {prev} +
·
+ {curr} + + ))}
- - + + + setShowOperationSetDialog(false)} + /> + ) } diff --git a/src/components/viewer/OperationViewer.tsx b/src/components/viewer/OperationViewer.tsx index c5e3cdda..3f8fed95 100644 --- a/src/components/viewer/OperationViewer.tsx +++ b/src/components/viewer/OperationViewer.tsx @@ -189,38 +189,33 @@ export const OperationViewer: ComponentType<{
- {operation.uploaderId === auth.userId && ( - onCloseDrawer()} - /> - } - > -
} > @@ -276,10 +271,10 @@ function OperationViewerInner({ handleRating: (decision: OpRatingType) => Promise }) { return ( -
+

{operation.parsedContent.doc.title}

-
+
@@ -330,20 +325,20 @@ function OperationViewerInner({
-
- +
+ {operation.views} - + - + -
+
{!operation.parsedContent.opers?.length && !operation.parsedContent.groups?.length && (
{group.name}
-
+
{group.opers ?.filter(Boolean) .map((operator) => ( diff --git a/src/layouts/AppLayout.tsx b/src/layouts/AppLayout.tsx index 372f0161..3697d656 100644 --- a/src/layouts/AppLayout.tsx +++ b/src/layouts/AppLayout.tsx @@ -1,4 +1,4 @@ -import { Button, IconName, Navbar, Tag } from '@blueprintjs/core' +import { Button, Navbar, Tag } from '@blueprintjs/core' import { Link, NavLink } from 'react-router-dom' import { FCC } from 'types' @@ -9,33 +9,13 @@ import { NavExpandButton } from 'components/NavExpandButton' import { ThemeSwitchButton } from 'components/ThemeSwitchButton' import { NavAside } from 'components/drawer/NavAside' -export const LINKS: { - to: string - label: string - icon: IconName -}[] = [ - { - to: '/', - label: '首页', - icon: 'home', - }, - { - to: '/create', - label: '创建作业', - icon: 'add', - }, - { - to: '/about', - label: '关于', - icon: 'info-sign', - }, -] +import { NAV_LINKS } from '../links' // const darkMode = localStorage.getItem('darkMode') === 'true' export const AppLayout: FCC = ({ children }) => (
- +
MAA Copilot @@ -48,8 +28,8 @@ export const AppLayout: FCC = ({ children }) => (
-
- {LINKS.map((link) => ( +
+ {NAV_LINKS.map((link) => ( (
-
+
diff --git a/src/links.tsx b/src/links.tsx new file mode 100644 index 00000000..45e83715 --- /dev/null +++ b/src/links.tsx @@ -0,0 +1,70 @@ +import { Icon as BlueprintIcon, IconName } from '@blueprintjs/core' +import simpleIconsGitHub from '@iconify/icons-simple-icons/github' +import simpleIconsQQ from '@iconify/icons-simple-icons/tencentqq' +import { Icon as IconifyIcon } from '@iconify/react' + +export const NAV_LINKS: { + to: string + label: string + icon: IconName +}[] = [ + { + to: '/', + label: '首页', + icon: 'home', + }, + { + to: '/create', + label: '创建作业', + icon: 'add', + }, + { + to: '/about', + label: '关于', + icon: 'info-sign', + }, +] + +export const SOCIAL_LINKS = [ + { + icon: , + href: 'https://maa.plus', + label: 'MAA 官网', + }, + { + icon: , + href: 'https://github.com/MaaAssistantArknights/maa-copilot-frontend/issues/new/choose', + label: '意见与反馈', + }, + { + icon: ( + + ), + href: 'https://github.com/MaaAssistantArknights/MaaAssistantArknights', + label: 'MAA GitHub Repo', + }, + { + icon: ( + + ), + href: 'https://github.com/MaaAssistantArknights/maa-copilot-frontend', + label: '前端 GitHub Repo', + }, + { + icon: ( + + ), + href: 'https://github.com/MaaAssistantArknights/MaaBackendCenter', + label: '后端 GitHub Repo', + }, + { + icon: , + href: 'https://jq.qq.com/?_wv=1027&k=ElimpMzQ', + label: '作业制作者交流群:1169188429', + }, + { + icon: , + href: 'https://ota.maa.plus/MaaAssistantArknights/api/qqgroup/index.html', + label: '作业分享群', + }, +] diff --git a/src/pages/index.tsx b/src/pages/index.tsx index dd4d3998..c96e8723 100644 --- a/src/pages/index.tsx +++ b/src/pages/index.tsx @@ -1,8 +1,6 @@ -import { Icon as BlueprintIcon, Card } from '@blueprintjs/core' -import simpleIconsGitHub from '@iconify/icons-simple-icons/github' -import simpleIconsQQ from '@iconify/icons-simple-icons/tencentqq' -import { Icon as IconifyIcon } from '@iconify/react' +import { Card } from '@blueprintjs/core' +import dayjs from 'dayjs' import { ComponentType } from 'react' import { CardTitle } from 'components/CardTitle' @@ -14,94 +12,76 @@ import { OperationSetEditorLauncher } from 'components/operation-set/OperationSe import { OperationUploaderLauncher } from 'components/uploader/OperationUploaderLauncher' import { AnnPanel } from '../components/announcement/AnnPanel' - -const SOCIAL_LINKS = [ - { - icon: , - href: 'https://maa.plus', - label: 'MAA 官网', - }, - { - icon: , - href: 'https://github.com/MaaAssistantArknights/maa-copilot-frontend/issues/new/choose', - label: '意见与反馈', - }, - { - icon: ( - - ), - href: 'https://github.com/MaaAssistantArknights/MaaAssistantArknights', - label: 'MAA GitHub Repo', - }, - { - icon: ( - - ), - href: 'https://github.com/MaaAssistantArknights/maa-copilot-frontend', - label: '前端 GitHub Repo', - }, - { - icon: ( - - ), - href: 'https://github.com/MaaAssistantArknights/MaaBackendCenter', - label: '后端 GitHub Repo', - }, - { - icon: , - href: 'https://jq.qq.com/?_wv=1027&k=ElimpMzQ', - label: '作业制作者交流群:1169188429', - }, - { - icon: , - href: 'https://ota.maa.plus/MaaAssistantArknights/api/qqgroup/index.html', - label: '作业分享群', - }, -] +import { SOCIAL_LINKS } from '../links' +import { useCurrentSize } from '../utils/useCurrenSize' export const IndexPage: ComponentType = withGlobalErrorBoundary(() => { + const { isMD } = useCurrentSize() return ( -
-
+
+ {isMD && } +
-
-
- - - 创建新作业 - + {!isMD && ( +
+
+ + + 创建新作业 + + + + + + - - - - + - +
+ {SOCIAL_LINKS.map((link) => ( + + {link.icon} + {link.label} + + )).reduce((prev, curr) => ( + <> + {prev} +
·
+ {curr} + + ))} +
-
- {SOCIAL_LINKS.map((link) => ( - - {link.icon} - {link.label} - - )).reduce((prev, curr) => ( - <> - {prev} -
·
- {curr} - - ))} +
-
+ )}
) }) + +const Ads = + dayjs().isAfter('2025-03-02 00:00:00+8') && + dayjs().isBefore('2025-04-02 00:00:00+8') + ? () => ( + // eslint-disable-next-line react/jsx-no-target-blank + + MuMu模拟器 +
+ 广告 +
+
+ ) + : () => null diff --git a/src/store/nav.ts b/src/store/nav.ts index 6d0b2625..3e7ecd37 100644 --- a/src/store/nav.ts +++ b/src/store/nav.ts @@ -8,7 +8,7 @@ export const navAtom = atom({ expanded: false, }) -export const toggleExpandNavAtom = atom(null, (get, set, value) => { +export const toggleExpandNavAtom = atom(null, (get, set, value: void) => { set(navAtom, { ...get(navAtom), expanded: !get(navAtom).expanded, diff --git a/src/utils/useCurrenSize.ts b/src/utils/useCurrenSize.ts index a0ac2d66..32116119 100644 --- a/src/utils/useCurrenSize.ts +++ b/src/utils/useCurrenSize.ts @@ -5,11 +5,14 @@ import { useWindowSize } from 'react-use' export const useCurrentSize = () => { const { width } = useWindowSize() - const isSM = useMemo(() => width < 640, [width]) - const isMD = useMemo(() => width >= 640 && width < 768, [width]) - const isLG = useMemo(() => width >= 768 && width < 1024, [width]) - const isXL = useMemo(() => width >= 1024 && width < 1280, [width]) - const is2XL = useMemo(() => width >= 1280 && width < 1536, [width]) - - return { isSM, isMD, isLG, isXL, is2XL } + return useMemo( + () => ({ + isSM: width < 640, + isMD: width < 768, + isLG: width < 1024, + isXL: width < 1280, + is2XL: width < 1536, + }), + [width], + ) }