Skip to content

Commit 02e5264

Browse files
wn0x00claude
andcommitted
fix(template): UX bug batch — locale key, banner dupes, HTTPS, i18n holes, query signal
Bugs - `pages/user/setting/info.tsx`: `Message.success` passed the literal locale key `'userSetting.saveSuccess'` instead of `t['…']`, so the toast rendered the raw key. - `pages/login/banner.tsx`: all three carousel slides used the same ByteDance CDN URL. Replaced with three distinct local SVGs under `pages/login/assets/banner-{1,2,3}.svg` — also kills the HTTPS / CN-availability concerns for the login screen. i18n - `NavBar.onMenuItemClick` was firing `Message.info(\`You clicked ${key}\`)` — English-only literal. Now reads the new `navbar.menu.notImplemented` locale key (en + zh-CN), templated with `.replace('{key}', key)`. - `welcome/code-block.tsx` had hardcoded `"点击复制命令"` / `"复制成功"`. Moved to `welcome/locale/index.ts` as `welcome.codeBlock.copyTooltip` + `…copySuccess`. HTTPS - Three `http://p1-arco.byteimg.com/…` refs in `dashboard/monitor/{data-statistic-list,studio}.tsx` upgraded to `https://`. Mixed-content blocks under any HTTPS deploy were silently dropping those images. Perf — request cancellation - All 22 `useQuery` callsites across `src/api/*.ts` now destructure `{ signal }` from `QueryFunctionContext` and forward it into the axios config. TanStack Query already passes the signal in — we were dropping it, so navigating away mid-flight kept downloading the response. - `useSearchTableQuery` keeps `placeholderData: keepPreviousData` but now needs an explicit `Promise<SearchTableResponse>` return annotation: with the destructured-arg queryFn, TS infers a wider union (`T | typeof keepPreviousData`) and `data?.list` access at the call site breaks. The annotation is the minimal-touch fix. - Patched three regressions where the bulk-rewrite injected `signal` inside a nested `{ params: { type } }` instead of as a sibling — verified by typecheck. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent e651e65 commit 02e5264

22 files changed

Lines changed: 166 additions & 61 deletions

File tree

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@ Format loosely follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/);
55
versions follow [SemVer](https://semver.org/). The npm registry is the
66
source of truth: <https://www.npmjs.com/package/@guanzhu.me/arco-cli>.
77

8+
## [0.11.1] — 2026-05-21
9+
- **Fix** `pages/user/setting/info.tsx`: `Message.success('userSetting.saveSuccess')` was passing the literal locale **key** instead of the translated string — users saw the raw key in the toast.
10+
- **Fix** `pages/login/banner.tsx`: all three carousel slides referenced the same image URL. Replaced the three ByteDance CDN URLs with three distinct local SVG illustrations under `pages/login/assets/`.
11+
- **Fix** i18n holes: `NavBar` menu-item placeholder toast was hardcoded English; `welcome/code-block` had hardcoded zh-CN copy/copied strings. Both now read locale keys.
12+
- **Security** `http://p1-arco.byteimg.com/...` refs in `dashboard/monitor/{data-statistic-list,studio}.tsx` upgraded to `https://` to avoid mixed-content blocks under HTTPS deploys.
13+
- **Perf** All `useQuery` hooks across `src/api/*.ts` now forward `signal` from `QueryFunctionContext` into the axios call. TanStack Query aborts the underlying request when the component unmounts or the queryKey changes — previously the response was downloaded and silently dropped. `useSearchTableQuery` gained an explicit `Promise<SearchTableResponse>` annotation to keep type inference clean alongside `placeholderData: keepPreviousData`.
14+
815
## [0.11.0] — 2026-05-21
916
- **Feat** `arco add api <name>` — scaffold a TanStack Query hook + zod schema + MSW handler in one shot, and auto-register the handler in `src/mock/handlers.ts`. `--method get` (default) generates `useXxxQuery` + list response schema; `--method post|put|delete` generates `useXxxMutation` + input schema + cache invalidation. `--skip-mock` skips the mock generation when the consumer brings their own backend.
1017

@@ -136,6 +143,7 @@ source of truth: <https://www.npmjs.com/package/@guanzhu.me/arco-cli>.
136143
## [0.1.0] — 2026-05
137144
- **Initial fork** of the abandoned `arco-cli` under `@guanzhu.me/arco-cli`. Preserves the original interactive template selection and `init` flow; modernises packaging, types, and engines.
138145

146+
[0.11.1]: https://github.com/wn0x00/arco-cli/releases/tag/v0.11.1
139147
[0.11.0]: https://github.com/wn0x00/arco-cli/releases/tag/v0.11.0
140148
[0.10.21]: https://github.com/wn0x00/arco-cli/releases/tag/v0.10.21
141149
[0.10.20]: https://github.com/wn0x00/arco-cli/releases/tag/v0.10.20

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@guanzhu.me/arco-cli",
3-
"version": "0.11.0",
3+
"version": "0.11.1",
44
"description": "Scaffold a modern Arco Design admin (Vite 7 + React 18 + strict TS) — community-maintained CLI with a bundled, modernized arco-design-pro starter.",
55
"keywords": [
66
"arco",

templates/arco-pro-recommend-full/src/api/analysis.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ export const analysisKeys = {
3939
export function useOverviewCardQuery(type: string) {
4040
return useQuery({
4141
queryKey: analysisKeys.overview(type),
42-
queryFn: () =>
42+
queryFn: ({ signal }) =>
4343
http
44-
.get<PublicOpinionCard>('/api/data-analysis/overview', { params: { type } })
44+
.get<PublicOpinionCard>('/api/data-analysis/overview', { params: { type }, signal })
4545
.then((r) => r.data),
4646
});
4747
}
@@ -55,9 +55,9 @@ export function useOverviewCardsQuery(types: Array<{ key: string; type: string }
5555
const results = useQueries({
5656
queries: types.map(({ key, type }) => ({
5757
queryKey: [...analysisKeys.overview(type), key],
58-
queryFn: () =>
58+
queryFn: ({ signal }) =>
5959
http
60-
.get<PublicOpinionCard>('/api/data-analysis/overview', { params: { type } })
60+
.get<PublicOpinionCard>('/api/data-analysis/overview', { params: { type }, signal })
6161
.then((r) => r.data)
6262
.then((data) => ({ ...data, key, chartType: type })),
6363
})),
@@ -71,19 +71,19 @@ export function useOverviewCardsQuery(types: Array<{ key: string; type: string }
7171
export function useContentPublishingQuery() {
7272
return useQuery({
7373
queryKey: analysisKeys.contentPublishing(),
74-
queryFn: () =>
74+
queryFn: ({ signal }) =>
7575
http
76-
.get<ContentPublishingPoint[]>('/api/data-analysis/content-publishing')
76+
.get<ContentPublishingPoint[]>('/api/data-analysis/content-publishing', { signal })
7777
.then((r) => r.data),
7878
});
7979
}
8080

8181
export function useAuthorListQuery() {
8282
return useQuery({
8383
queryKey: analysisKeys.authorList(),
84-
queryFn: () =>
84+
queryFn: ({ signal }) =>
8585
http
86-
.get<{ list: AuthorListRow[] }>('/api/data-analysis/author-list')
86+
.get<{ list: AuthorListRow[] }>('/api/data-analysis/author-list', { signal })
8787
.then((r) => r.data.list),
8888
});
8989
}

templates/arco-pro-recommend-full/src/api/list.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,11 @@ export const listKeys = {
3131
export function useCardListQuery() {
3232
return useQuery({
3333
queryKey: listKeys.cards(),
34-
queryFn: () => http.get<CardListBundle>('/api/cardList').then((r) => r.data),
34+
// `signal` is forwarded to axios so navigating away mid-flight
35+
// aborts the request — TanStack Query passes one in automatically
36+
// and we hand it straight to axios's request config.
37+
queryFn: ({ signal }) =>
38+
http.get<CardListBundle>('/api/cardList', { signal }).then((r) => r.data),
3539
});
3640
}
3741

@@ -43,8 +47,15 @@ export function useCardListQuery() {
4347
export function useSearchTableQuery(params: Record<string, unknown>) {
4448
return useQuery({
4549
queryKey: listKeys.searchTable(params),
46-
queryFn: () =>
47-
http.get<SearchTableResponse>('/api/list', { params }).then((r) => r.data),
50+
// Explicit Promise<T> return annotation — without it, TanStack's
51+
// generic infers a union including `typeof keepPreviousData`,
52+
// which collapses `data` to `T | <fn>` at the call site and breaks
53+
// `data?.list` access. Tightening the annotation is cheaper than
54+
// narrowing every consumer.
55+
queryFn: ({ signal }): Promise<SearchTableResponse> =>
56+
http
57+
.get<SearchTableResponse>('/api/list', { params, signal })
58+
.then((r) => r.data),
4859
placeholderData: keepPreviousData,
4960
});
5061
}

templates/arco-pro-recommend-full/src/api/messages.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export const messageKeys = {
2121
export function useMessagesQuery() {
2222
return useQuery({
2323
queryKey: messageKeys.list(),
24-
queryFn: () => http.get<Message[]>('/api/message/list').then((r) => r.data),
24+
queryFn: ({ signal }) => http.get<Message[]>('/api/message/list', { signal }).then((r) => r.data),
2525
});
2626
}
2727

templates/arco-pro-recommend-full/src/api/monitor.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export const monitorKeys = {
1717
export function useChatListQuery() {
1818
return useQuery({
1919
queryKey: monitorKeys.chatList(),
20-
queryFn: () => http.get<ChatMessage[]>('/api/chatList').then((r) => r.data),
20+
queryFn: ({ signal }) => http.get<ChatMessage[]>('/api/chatList', { signal }).then((r) => r.data),
2121
// Live-ish chat list — refetch every 8s while the page is open.
2222
refetchInterval: 8000,
2323
});

templates/arco-pro-recommend-full/src/api/multi-dim.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,24 +45,24 @@ export const multiDimKeys = {
4545
export function useMultiDimOverviewQuery() {
4646
return useQuery({
4747
queryKey: multiDimKeys.overview(),
48-
queryFn: () =>
49-
http.get<MultiDimOverview>('/api/multi-dimension/overview').then((r) => r.data),
48+
queryFn: ({ signal }) =>
49+
http.get<MultiDimOverview>('/api/multi-dimension/overview', { signal }).then((r) => r.data),
5050
});
5151
}
5252

5353
export function useActivityQuery() {
5454
return useQuery({
5555
queryKey: multiDimKeys.activity(),
56-
queryFn: () =>
57-
http.get<ActivityRow[]>('/api/multi-dimension/activity').then((r) => r.data),
56+
queryFn: ({ signal }) =>
57+
http.get<ActivityRow[]>('/api/multi-dimension/activity', { signal }).then((r) => r.data),
5858
});
5959
}
6060

6161
export function usePolarQuery() {
6262
return useQuery({
6363
queryKey: multiDimKeys.polar(),
64-
queryFn: () =>
65-
http.get<PolarResponse>('/api/multi-dimension/polar').then((r) => r.data),
64+
queryFn: ({ signal }) =>
65+
http.get<PolarResponse>('/api/multi-dimension/polar', { signal }).then((r) => r.data),
6666
});
6767
}
6868

@@ -73,9 +73,9 @@ export function useMultiDimCardsQuery(infos: Array<{ key: string; type: string }
7373
// collapse into a single cache entry (which would give multiple
7474
// <Col> children the same React key).
7575
queryKey: [...multiDimKeys.card(type), key],
76-
queryFn: () =>
76+
queryFn: ({ signal }) =>
7777
http
78-
.get<MultiDimCard>('/api/multi-dimension/card', { params: { type } })
78+
.get<MultiDimCard>('/api/multi-dimension/card', { params: { type }, signal })
7979
.then((r) => r.data)
8080
.then((data) => ({ ...data, key, chartType: type })),
8181
})),
@@ -91,9 +91,9 @@ export function useMultiDimCardsQuery(infos: Array<{ key: string; type: string }
9191
export function useContentSourceQuery() {
9292
return useQuery({
9393
queryKey: multiDimKeys.contentSource(),
94-
queryFn: () =>
94+
queryFn: ({ signal }) =>
9595
http
96-
.get<ContentSourceRow[]>('/api/multi-dimension/content-source')
96+
.get<ContentSourceRow[]>('/api/multi-dimension/content-source', { signal })
9797
.then((r) => r.data),
9898
});
9999
}

templates/arco-pro-recommend-full/src/api/profile.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,13 @@ export const profileKeys = {
3636
export function useBasicProfileQuery() {
3737
return useQuery({
3838
queryKey: profileKeys.basic(),
39-
queryFn: () => http.get<BasicProfile>('/api/basicProfile').then((r) => r.data),
39+
queryFn: ({ signal }) => http.get<BasicProfile>('/api/basicProfile', { signal }).then((r) => r.data),
4040
});
4141
}
4242

4343
export function useAdjustmentsQuery() {
4444
return useQuery({
4545
queryKey: profileKeys.adjustments(),
46-
queryFn: () => http.get<AdjustmentRow[]>('/api/adjustment').then((r) => r.data),
46+
queryFn: ({ signal }) => http.get<AdjustmentRow[]>('/api/adjustment', { signal }).then((r) => r.data),
4747
});
4848
}

templates/arco-pro-recommend-full/src/api/user-center.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -60,49 +60,49 @@ export const userCenterKeys = {
6060
export function useMyProjectsQuery() {
6161
return useQuery({
6262
queryKey: userCenterKeys.projects(),
63-
queryFn: () =>
64-
http.get<ProjectRow[]>('/api/user/projectList').then((r) => r.data),
63+
queryFn: ({ signal }) =>
64+
http.get<ProjectRow[]>('/api/user/projectList', { signal }).then((r) => r.data),
6565
});
6666
}
6767

6868
export function useMyTeamsQuery() {
6969
return useQuery({
7070
queryKey: userCenterKeys.teams(),
71-
queryFn: () =>
72-
http.get<TeamRow[]>('/api/users/teamList').then((r) => r.data),
71+
queryFn: ({ signal }) =>
72+
http.get<TeamRow[]>('/api/users/teamList', { signal }).then((r) => r.data),
7373
});
7474
}
7575

7676
export function useLatestNewsQuery() {
7777
return useQuery({
7878
queryKey: userCenterKeys.news(),
79-
queryFn: () =>
80-
http.get<NewsRow[]>('/api/user/latestNews').then((r) => r.data),
79+
queryFn: ({ signal }) =>
80+
http.get<NewsRow[]>('/api/user/latestNews', { signal }).then((r) => r.data),
8181
});
8282
}
8383

8484
export function useUserNoticeQuery() {
8585
return useQuery({
8686
queryKey: userCenterKeys.notice(),
87-
queryFn: () => http.get<unknown[]>('/api/user/notice').then((r) => r.data),
87+
queryFn: ({ signal }) => http.get<unknown[]>('/api/user/notice', { signal }).then((r) => r.data),
8888
});
8989
}
9090

9191
export function useEnterpriseVerificationQuery() {
9292
return useQuery({
9393
queryKey: userCenterKeys.enterprise(),
94-
queryFn: () =>
94+
queryFn: ({ signal }) =>
9595
http
96-
.get<EnterpriseVerification>('/api/user/verified/enterprise')
96+
.get<EnterpriseVerification>('/api/user/verified/enterprise', { signal })
9797
.then((r) => r.data),
9898
});
9999
}
100100

101101
export function useAuthListQuery() {
102102
return useQuery({
103103
queryKey: userCenterKeys.authList(),
104-
queryFn: () =>
105-
http.get<AuthRow[]>('/api/user/verified/authList').then((r) => r.data),
104+
queryFn: ({ signal }) =>
105+
http.get<AuthRow[]>('/api/user/verified/authList', { signal }).then((r) => r.data),
106106
});
107107
}
108108

templates/arco-pro-recommend-full/src/api/user.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export const userKeys = {
3333
export function useUserInfoQuery() {
3434
return useQuery({
3535
queryKey: userKeys.info(),
36-
queryFn: () => http.get<UserInfo>('/api/user/userInfo').then((r) => r.data),
36+
queryFn: ({ signal }) => http.get<UserInfo>('/api/user/userInfo', { signal }).then((r) => r.data),
3737
});
3838
}
3939

0 commit comments

Comments
 (0)