Skip to content

Commit fd0a3f7

Browse files
committed
cleanup
1 parent 0e8cc3b commit fd0a3f7

File tree

9 files changed

+169
-127
lines changed

9 files changed

+169
-127
lines changed

bun.lock

Lines changed: 26 additions & 28 deletions
Large diffs are not rendered by default.

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@
1010
"dependencies": {
1111
"@ant-design/icons": "^6.0.2",
1212
"@ant-design/v5-patch-for-react-19": "^1.0.3",
13-
"@rsbuild/core": "^1.5.6",
13+
"@rsbuild/core": "^1.5.10",
1414
"@rsbuild/plugin-react": "^1.4.0",
1515
"@rsbuild/plugin-sass": "^1.4.0",
1616
"@rsbuild/plugin-svgr": "^1.2.2",
17-
"@tanstack/react-query": "^5.87.4",
18-
"antd": "^5.27.3",
17+
"@tanstack/react-query": "^5.89.0",
18+
"antd": "^5.27.4",
1919
"dayjs": "^1.11.18",
2020
"git-url-parse": "^16.1.0",
2121
"hash-wasm": "^4.12.0",

src/components/main-layout.tsx

Lines changed: 59 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ import { useUserInfo } from "@/utils/hooks";
1313
import Footer from "./footer";
1414
import Sider from "./sider";
1515

16+
interface Style {
17+
header: React.CSSProperties;
18+
body: React.CSSProperties;
19+
}
20+
1621
const MainLayout = () => {
1722
const { user } = useUserInfo();
1823

@@ -22,41 +27,59 @@ const MainLayout = () => {
2227
<Layout>
2328
<Layout.Header style={style.header}>
2429
<Row className="h-full" justify="end">
25-
<Menu mode="horizontal" selectable={false}>
26-
<Menu.Item key="issues" icon={<CommentOutlined />}>
27-
<ExtLink href="https://github.com/reactnativecn/react-native-pushy/issues">
28-
讨论
29-
</ExtLink>
30-
</Menu.Item>
31-
<Menu.Item key="document" icon={<ReadOutlined />}>
32-
<ExtLink href="https://pushy.reactnative.cn/docs/getting-started.html">
33-
文档
34-
</ExtLink>
35-
</Menu.Item>
36-
<Menu.Item key="about" icon={<InfoCircleOutlined />}>
37-
<ExtLink href="https://reactnative.cn/about.html">
38-
关于我们
39-
</ExtLink>
40-
</Menu.Item>
41-
{user && (
42-
<Menu.SubMenu
43-
key="user"
44-
icon={<UserOutlined />}
45-
title={user.name}
46-
>
47-
<Menu.Item
48-
key="logout"
49-
onClick={() => {
50-
logout();
51-
message.info("您已退出登录");
52-
}}
53-
icon={<LogoutOutlined />}
54-
>
55-
退出登录
56-
</Menu.Item>
57-
</Menu.SubMenu>
58-
)}
59-
</Menu>
30+
<Menu
31+
mode="horizontal"
32+
selectable={false}
33+
items={[
34+
{
35+
key: "issues",
36+
icon: <CommentOutlined />,
37+
label: (
38+
<ExtLink href="https://github.com/reactnativecn/react-native-pushy/issues">
39+
讨论
40+
</ExtLink>
41+
),
42+
},
43+
{
44+
key: "document",
45+
icon: <ReadOutlined />,
46+
label: (
47+
<ExtLink href="https://pushy.reactnative.cn/docs/getting-started.html">
48+
文档
49+
</ExtLink>
50+
),
51+
},
52+
{
53+
key: "about",
54+
icon: <InfoCircleOutlined />,
55+
label: (
56+
<ExtLink href="https://reactnative.cn/about.html">
57+
关于我们
58+
</ExtLink>
59+
),
60+
},
61+
...(user
62+
? [
63+
{
64+
key: "user",
65+
icon: <UserOutlined />,
66+
label: user.name,
67+
children: [
68+
{
69+
key: "logout",
70+
icon: <LogoutOutlined />,
71+
label: "退出登录",
72+
onClick: () => {
73+
logout();
74+
message.info("您已退出登录");
75+
},
76+
},
77+
],
78+
},
79+
]
80+
: []),
81+
]}
82+
/>
6083
</Row>
6184
</Layout.Header>
6285
<Layout.Content id="main-body" style={style.body}>
@@ -81,7 +104,7 @@ const ExtLink = ({ children, href }: ExtLinkProps) => (
81104
<a
82105
href={href}
83106
target="_blank"
84-
onClick={(e) => e.stopPropagation()}
107+
// onClick={(e) => e.stopPropagation()}
85108
rel="noreferrer"
86109
>
87110
{children}

src/components/sider.tsx

Lines changed: 63 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,7 @@ import { rootRouterPath } from "@/router";
44
import { api } from "@/services/api";
55
import { useAppList, useUserInfo } from "@/utils/hooks";
66
import {
7-
AndroidFilled,
8-
AppleFilled,
97
AppstoreOutlined,
10-
HarmonyOSOutlined,
118
PlusOutlined,
129
UserOutlined,
1310
} from "@ant-design/icons";
@@ -28,6 +25,14 @@ import { Link, useLocation } from "react-router-dom";
2825
import { ReactComponent as LogoH } from "../assets/logo-h.svg";
2926
import PlatformIcon from "./platform-icon";
3027

28+
interface SiderMenuProps {
29+
selectedKeys: string[];
30+
}
31+
32+
interface Style {
33+
sider: React.CSSProperties;
34+
}
35+
3136
function addApp() {
3237
let name = "";
3338
let platform = "android";
@@ -173,44 +178,62 @@ const SiderMenu = ({ selectedKeys }: SiderMenuProps) => {
173178
defaultOpenKeys={["apps"]}
174179
selectedKeys={selectedKeys}
175180
mode="inline"
176-
>
177-
<Menu.Item key="user" icon={<UserOutlined />}>
178-
<Link to={rootRouterPath.user}>账户设置</Link>
179-
</Menu.Item>
180-
<Menu.SubMenu key="apps" title="应用管理" icon={<AppstoreOutlined />}>
181-
{apps?.map((i) => (
182-
<Menu.Item key={i.id} className="!h-16">
183-
<div className="flex flex-row items-center gap-4">
184-
<div className="flex flex-col justify-center">
185-
<PlatformIcon platform={i.platform} className="!text-xl" />
186-
</div>
187-
<Link
188-
to={`/apps/${i.id}`}
189-
className="flex flex-col h-16 justify-center"
190-
>
191-
<div className="flex flex-row items-center font-bold">
192-
{i.name}
193-
{i.status === "paused" && <Tag className="ml-2">暂停</Tag>}
194-
</div>
195-
{i.checkCount && (
196-
<div className="text-xs text-gray-500 mb-2">
197-
<Tooltip
198-
mouseEnterDelay={1}
199-
title="今日此应用查询热更的次数"
200-
>
201-
<a>{i.checkCount.toLocaleString()}</a>
202-
</Tooltip>
181+
items={[
182+
{
183+
key: "user",
184+
icon: <UserOutlined />,
185+
label: <Link to={rootRouterPath.user}>账户设置</Link>,
186+
},
187+
{
188+
key: "apps",
189+
icon: <AppstoreOutlined />,
190+
label: "应用管理",
191+
children: [
192+
...(apps?.map((i) => ({
193+
key: i.id,
194+
className: "!h-16",
195+
label: (
196+
<div className="flex flex-row items-center gap-4">
197+
<div className="flex flex-col justify-center">
198+
<PlatformIcon
199+
platform={i.platform}
200+
className="!text-xl"
201+
/>
203202
</div>
204-
)}
205-
</Link>
206-
</div>
207-
</Menu.Item>
208-
))}
209-
<Menu.Item key="add-app" icon={<PlusOutlined />} onClick={addApp}>
210-
添加应用
211-
</Menu.Item>
212-
</Menu.SubMenu>
213-
</Menu>
203+
<Link
204+
to={`/apps/${i.id}`}
205+
className="flex flex-col h-16 justify-center"
206+
>
207+
<div className="flex flex-row items-center font-bold">
208+
{i.name}
209+
{i.status === "paused" && (
210+
<Tag className="ml-2">暂停</Tag>
211+
)}
212+
</div>
213+
{i.checkCount && (
214+
<div className="text-xs text-gray-500 mb-2">
215+
<Tooltip
216+
mouseEnterDelay={1}
217+
title="今日此应用查询热更的次数"
218+
>
219+
<a>{i.checkCount.toLocaleString()}</a>
220+
</Tooltip>
221+
</div>
222+
)}
223+
</Link>
224+
</div>
225+
),
226+
})) || []),
227+
{
228+
key: "add-app",
229+
icon: <PlusOutlined />,
230+
label: "添加应用",
231+
onClick: addApp,
232+
},
233+
],
234+
},
235+
]}
236+
/>
214237
</div>
215238
);
216239
};

src/pages/register.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ export const Register = () => {
103103
validator: (_, value) =>
104104
value
105105
? Promise.resolve()
106-
: Promise.reject(new Error("请阅读并同意后勾选此处")),
106+
: Promise.reject(Error("请阅读并同意后勾选此处")),
107107
},
108108
]}
109109
hasFeedback

src/pages/reset-password/components/set-password.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,7 @@ export default function SetPassword() {
3636
validator(_, value: string) {
3737
if (value && !isPasswordValid(value)) {
3838
return Promise.reject(
39-
new Error(
40-
"密码中需要同时包含大、小写字母和数字,且长度不少于6位"
41-
)
39+
Error("密码中需要同时包含大、小写字母和数字,且长度不少于6位")
4240
);
4341
}
4442
return Promise.resolve();
@@ -56,7 +54,7 @@ export default function SetPassword() {
5654
({ getFieldValue }) => ({
5755
validator(_, value: string) {
5856
if (getFieldValue("newPwd") !== value) {
59-
return Promise.reject(new Error("两次输入的密码不一致"));
57+
return Promise.reject(Error("两次输入的密码不一致"));
6058
}
6159
return Promise.resolve();
6260
},

src/pages/user.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ function UserPanel() {
129129
<Descriptions
130130
title="账户信息"
131131
column={1}
132-
labelStyle={{ width: 134 }}
132+
styles={{ label: { width: 134 } }}
133133
bordered
134134
>
135135
<Descriptions.Item label="用户名">{name}</Descriptions.Item>

src/services/api.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,15 @@ export const api = {
2626
}),
2727
createApp: (params: { name: string; platform: string }) =>
2828
request<{ id: number }>("post", "/app/create", params).then((response) => {
29-
if (!response) throw new Error("Failed to create app");
29+
if (!response) throw Error("Failed to create app");
3030
const { id } = response;
3131
queryClient.setQueryData(["appList"], ({ data }: { data: App[] }) => ({
3232
data: [...(data || []), { ...params, id }],
3333
}));
3434
}),
3535
updateApp: (
3636
appId: number,
37-
params: Omit<App, "appKey" | "checkCount" | "id" | "platform">,
37+
params: Omit<App, "appKey" | "checkCount" | "id" | "platform">
3838
) =>
3939
request("put", `/app/${appId}`, params).then(() => {
4040
queryClient.setQueryData(["app", appId], (old: App | undefined) => ({
@@ -49,7 +49,7 @@ export const api = {
4949
getPackages: (appId: number) =>
5050
request<{ data: Package[]; count: number }>(
5151
"get",
52-
`/app/${appId}/package/list?limit=1000`,
52+
`/app/${appId}/package/list?limit=1000`
5353
),
5454
updatePackage: ({
5555
appId,
@@ -69,9 +69,9 @@ export const api = {
6969
["packages", appId],
7070
({ data }: { data: Package[] }) => ({
7171
data: data?.map((i) =>
72-
i.id === packageId ? { ...i, ...params } : i,
72+
i.id === packageId ? { ...i, ...params } : i
7373
),
74-
}),
74+
})
7575
);
7676
if (params.versionId !== undefined) {
7777
queryClient.invalidateQueries({ queryKey: ["versions", appId] });
@@ -83,7 +83,7 @@ export const api = {
8383
["packages", appId],
8484
({ data }: { data: Package[] }) => ({
8585
data: data?.filter((i) => i.id !== packageId),
86-
}),
86+
})
8787
);
8888
}),
8989
// version
@@ -98,7 +98,7 @@ export const api = {
9898
}) =>
9999
request<{ data: Version[]; count: number }>(
100100
"get",
101-
`/app/${appId}/version/list?offset=${offset}&limit=${limit}`,
101+
`/app/${appId}/version/list?offset=${offset}&limit=${limit}`
102102
),
103103
updateVersion: ({
104104
versionId,
@@ -117,10 +117,10 @@ export const api = {
117117
? {
118118
...old,
119119
data: old.data?.map((i) =>
120-
i.id === versionId ? { ...i, ...params } : i,
120+
i.id === versionId ? { ...i, ...params } : i
121121
),
122122
}
123-
: undefined,
123+
: undefined
124124
);
125125
}),
126126
deleteVersion: ({ appId, versionId }: { appId: number; versionId: number }) =>
@@ -133,7 +133,7 @@ export const api = {
133133
...old,
134134
data: old.data?.filter((i) => i.id !== versionId),
135135
}
136-
: undefined,
136+
: undefined
137137
);
138138
}),
139139
// order

0 commit comments

Comments
 (0)