Skip to content

Commit b3ca4e7

Browse files
author
Druid
committed
feat: update to antd6
1 parent 7006138 commit b3ca4e7

File tree

25 files changed

+168
-123
lines changed

25 files changed

+168
-123
lines changed

package.json

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -33,60 +33,60 @@
3333
"examples/**/*.{js,jsx,ts,tsx}": "eslint --cache --ext .js,.jsx,.ts,.tsx --max-warnings 0"
3434
},
3535
"dependencies": {
36-
"@ant-design/v5-patch-for-react-19": "^1.0.3",
3736
"@dnd-kit/core": "^6.3.1",
3837
"@dnd-kit/sortable": "^10.0.0",
3938
"@dnd-kit/utilities": "^3.2.2",
4039
"@zhangsai/model": "^0.0.3",
4140
"admin-search-list": "^1.0.5",
42-
"antd": "^5.25.0",
43-
"axios": "^1.9.0",
41+
"antd": "^6.0.0",
42+
"axios": "^1.13.2",
4443
"classnames": "^2.5.1",
45-
"dayjs": "^1.11.13",
46-
"echarts": "^5.6.0",
47-
"framer-motion": "^12.10.4",
48-
"i18next": "^25.1.2",
49-
"immer": "^10.1.1",
44+
"dayjs": "^1.11.19",
45+
"echarts": "^6.0.0",
46+
"framer-motion": "^12.23.24",
47+
"i18next": "^25.6.3",
48+
"immer": "^11.0.0",
5049
"nprogress": "^0.2.0",
51-
"react": "^19.1.0",
50+
"react": "^19.2.0",
5251
"react-contexify": "^6.0.0",
53-
"react-dom": "^19.1.0",
54-
"react-i18next": "^15.5.1",
55-
"react-router": "^7.6.0",
52+
"react-dom": "^19.2.0",
53+
"react-i18next": "^16.3.5",
54+
"react-router": "^7.9.6",
5655
"react-router-toolset": "^0.0.9",
5756
"react-use": "^17.6.0",
5857
"store2": "^2.14.4"
5958
},
6059
"devDependencies": {
61-
"@types/node": "^22.15.17",
60+
"@types/node": "^24.10.1",
6261
"@types/nprogress": "^0.2.3",
63-
"@types/react": "^19.1.3",
64-
"@types/react-dom": "^19.1.3",
65-
"@typescript-eslint/eslint-plugin": "^8.32.0",
66-
"@typescript-eslint/parser": "^8.32.0",
67-
"@vitejs/plugin-react": "^4.4.1",
68-
"autoprefixer": "^10.4.21",
62+
"@types/react": "^19.2.7",
63+
"@types/react-dom": "^19.2.3",
64+
"@typescript-eslint/eslint-plugin": "^8.48.0",
65+
"@typescript-eslint/parser": "^8.48.0",
66+
"@vitejs/plugin-react": "^5.1.1",
67+
"autoprefixer": "^10.4.22",
6968
"eslint": "8.57.0",
7069
"eslint-plugin-react": "^7.37.5",
71-
"eslint-plugin-react-hooks": "^5.2.0",
72-
"eslint-plugin-react-refresh": "^0.4.20",
70+
"eslint-plugin-react-hooks": "^7.0.1",
71+
"eslint-plugin-react-refresh": "^0.4.24",
72+
"fast-glob": "^3.3.3",
7373
"husky": "^9.1.7",
74-
"less": "^4.3.0",
75-
"lint-staged": "^15.5.2",
76-
"mermaid": "^11.6.0",
77-
"msw": "^2.8.0",
78-
"typescript": "^5.8.3",
79-
"vite": "^6.3.5",
74+
"less": "^4.4.2",
75+
"lint-staged": "^16.2.7",
76+
"mermaid": "^11.12.1",
77+
"msw": "^2.12.3",
78+
"typescript": "^5.9.3",
79+
"vite": "^7.2.4",
8080
"vite-bundle-visualizer": "^1.2.1",
81-
"vite-plugin-sitemap": "^0.7.1",
81+
"vite-plugin-sitemap": "^0.8.2",
8282
"vite-plugin-svg-icons": "^2.0.1",
83-
"vite-plugin-svgr": "^4.3.0",
84-
"vitepress": "^1.6.3",
83+
"vite-plugin-svgr": "^4.5.0",
84+
"vitepress": "^1.6.4",
8585
"vitepress-plugin-mermaid": "^2.0.17"
8686
},
8787
"msw": {
8888
"workerDirectory": [
8989
"public"
9090
]
9191
}
92-
}
92+
}

public/mockServiceWorker.js

Lines changed: 105 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,23 @@
55
* Mock Service Worker.
66
* @see https://github.com/mswjs/msw
77
* - Please do NOT modify this file.
8-
* - Please do NOT serve this file on production.
98
*/
109

11-
const PACKAGE_VERSION = '2.8.0'
12-
const INTEGRITY_CHECKSUM = '00729d72e3b82faf54ca8b9621dbb96f'
10+
const PACKAGE_VERSION = '2.12.3'
11+
const INTEGRITY_CHECKSUM = '4db4a41e972cec1b64cc569c66952d82'
1312
const IS_MOCKED_RESPONSE = Symbol('isMockedResponse')
1413
const activeClientIds = new Set()
1514

16-
self.addEventListener('install', function () {
15+
addEventListener('install', function () {
1716
self.skipWaiting()
1817
})
1918

20-
self.addEventListener('activate', function (event) {
19+
addEventListener('activate', function (event) {
2120
event.waitUntil(self.clients.claim())
2221
})
2322

24-
self.addEventListener('message', async function (event) {
25-
const clientId = event.source.id
23+
addEventListener('message', async function (event) {
24+
const clientId = Reflect.get(event.source || {}, 'id')
2625

2726
if (!clientId || !self.clients) {
2827
return
@@ -72,11 +71,6 @@ self.addEventListener('message', async function (event) {
7271
break
7372
}
7473

75-
case 'MOCK_DEACTIVATE': {
76-
activeClientIds.delete(clientId)
77-
break
78-
}
79-
8074
case 'CLIENT_CLOSED': {
8175
activeClientIds.delete(clientId)
8276

@@ -94,69 +88,92 @@ self.addEventListener('message', async function (event) {
9488
}
9589
})
9690

97-
self.addEventListener('fetch', function (event) {
98-
const { request } = event
91+
addEventListener('fetch', function (event) {
92+
const requestInterceptedAt = Date.now()
9993

10094
// Bypass navigation requests.
101-
if (request.mode === 'navigate') {
95+
if (event.request.mode === 'navigate') {
10296
return
10397
}
10498

10599
// Opening the DevTools triggers the "only-if-cached" request
106100
// that cannot be handled by the worker. Bypass such requests.
107-
if (request.cache === 'only-if-cached' && request.mode !== 'same-origin') {
101+
if (
102+
event.request.cache === 'only-if-cached' &&
103+
event.request.mode !== 'same-origin'
104+
) {
108105
return
109106
}
110107

111108
// Bypass all requests when there are no active clients.
112109
// Prevents the self-unregistered worked from handling requests
113-
// after it's been deleted (still remains active until the next reload).
110+
// after it's been terminated (still remains active until the next reload).
114111
if (activeClientIds.size === 0) {
115112
return
116113
}
117114

118-
// Generate unique request ID.
119115
const requestId = crypto.randomUUID()
120-
event.respondWith(handleRequest(event, requestId))
116+
event.respondWith(handleRequest(event, requestId, requestInterceptedAt))
121117
})
122118

123-
async function handleRequest(event, requestId) {
119+
/**
120+
* @param {FetchEvent} event
121+
* @param {string} requestId
122+
* @param {number} requestInterceptedAt
123+
*/
124+
async function handleRequest(event, requestId, requestInterceptedAt) {
124125
const client = await resolveMainClient(event)
125-
const response = await getResponse(event, client, requestId)
126+
const requestCloneForEvents = event.request.clone()
127+
const response = await getResponse(
128+
event,
129+
client,
130+
requestId,
131+
requestInterceptedAt,
132+
)
126133

127134
// Send back the response clone for the "response:*" life-cycle events.
128135
// Ensure MSW is active and ready to handle the message, otherwise
129136
// this message will pend indefinitely.
130137
if (client && activeClientIds.has(client.id)) {
131-
;(async function () {
132-
const responseClone = response.clone()
133-
134-
sendToClient(
135-
client,
136-
{
137-
type: 'RESPONSE',
138-
payload: {
139-
requestId,
140-
isMockedResponse: IS_MOCKED_RESPONSE in response,
138+
const serializedRequest = await serializeRequest(requestCloneForEvents)
139+
140+
// Clone the response so both the client and the library could consume it.
141+
const responseClone = response.clone()
142+
143+
sendToClient(
144+
client,
145+
{
146+
type: 'RESPONSE',
147+
payload: {
148+
isMockedResponse: IS_MOCKED_RESPONSE in response,
149+
request: {
150+
id: requestId,
151+
...serializedRequest,
152+
},
153+
response: {
141154
type: responseClone.type,
142155
status: responseClone.status,
143156
statusText: responseClone.statusText,
144-
body: responseClone.body,
145157
headers: Object.fromEntries(responseClone.headers.entries()),
158+
body: responseClone.body,
146159
},
147160
},
148-
[responseClone.body],
149-
)
150-
})()
161+
},
162+
responseClone.body ? [serializedRequest.body, responseClone.body] : [],
163+
)
151164
}
152165

153166
return response
154167
}
155168

156-
// Resolve the main client for the given event.
157-
// Client that issues a request doesn't necessarily equal the client
158-
// that registered the worker. It's with the latter the worker should
159-
// communicate with during the response resolving phase.
169+
/**
170+
* Resolve the main client for the given event.
171+
* Client that issues a request doesn't necessarily equal the client
172+
* that registered the worker. It's with the latter the worker should
173+
* communicate with during the response resolving phase.
174+
* @param {FetchEvent} event
175+
* @returns {Promise<Client | undefined>}
176+
*/
160177
async function resolveMainClient(event) {
161178
const client = await self.clients.get(event.clientId)
162179

@@ -184,12 +201,17 @@ async function resolveMainClient(event) {
184201
})
185202
}
186203

187-
async function getResponse(event, client, requestId) {
188-
const { request } = event
189-
204+
/**
205+
* @param {FetchEvent} event
206+
* @param {Client | undefined} client
207+
* @param {string} requestId
208+
* @param {number} requestInterceptedAt
209+
* @returns {Promise<Response>}
210+
*/
211+
async function getResponse(event, client, requestId, requestInterceptedAt) {
190212
// Clone the request because it might've been already used
191213
// (i.e. its body has been read and sent to the client).
192-
const requestClone = request.clone()
214+
const requestClone = event.request.clone()
193215

194216
function passthrough() {
195217
// Cast the request headers to a new Headers instance
@@ -230,29 +252,18 @@ async function getResponse(event, client, requestId) {
230252
}
231253

232254
// Notify the client that a request has been intercepted.
233-
const requestBuffer = await request.arrayBuffer()
255+
const serializedRequest = await serializeRequest(event.request)
234256
const clientMessage = await sendToClient(
235257
client,
236258
{
237259
type: 'REQUEST',
238260
payload: {
239261
id: requestId,
240-
url: request.url,
241-
mode: request.mode,
242-
method: request.method,
243-
headers: Object.fromEntries(request.headers.entries()),
244-
cache: request.cache,
245-
credentials: request.credentials,
246-
destination: request.destination,
247-
integrity: request.integrity,
248-
redirect: request.redirect,
249-
referrer: request.referrer,
250-
referrerPolicy: request.referrerPolicy,
251-
body: requestBuffer,
252-
keepalive: request.keepalive,
262+
interceptedAt: requestInterceptedAt,
263+
...serializedRequest,
253264
},
254265
},
255-
[requestBuffer],
266+
[serializedRequest.body],
256267
)
257268

258269
switch (clientMessage.type) {
@@ -268,6 +279,12 @@ async function getResponse(event, client, requestId) {
268279
return passthrough()
269280
}
270281

282+
/**
283+
* @param {Client} client
284+
* @param {any} message
285+
* @param {Array<Transferable>} transferrables
286+
* @returns {Promise<any>}
287+
*/
271288
function sendToClient(client, message, transferrables = []) {
272289
return new Promise((resolve, reject) => {
273290
const channel = new MessageChannel()
@@ -280,14 +297,18 @@ function sendToClient(client, message, transferrables = []) {
280297
resolve(event.data)
281298
}
282299

283-
client.postMessage(
284-
message,
285-
[channel.port2].concat(transferrables.filter(Boolean)),
286-
)
300+
client.postMessage(message, [
301+
channel.port2,
302+
...transferrables.filter(Boolean),
303+
])
287304
})
288305
}
289306

290-
async function respondWithMock(response) {
307+
/**
308+
* @param {Response} response
309+
* @returns {Response}
310+
*/
311+
function respondWithMock(response) {
291312
// Setting response status code to 0 is a no-op.
292313
// However, when responding with a "Response.error()", the produced Response
293314
// instance will have status code set to 0. Since it's not possible to create
@@ -305,3 +326,24 @@ async function respondWithMock(response) {
305326

306327
return mockedResponse
307328
}
329+
330+
/**
331+
* @param {Request} request
332+
*/
333+
async function serializeRequest(request) {
334+
return {
335+
url: request.url,
336+
mode: request.mode,
337+
method: request.method,
338+
headers: Object.fromEntries(request.headers.entries()),
339+
cache: request.cache,
340+
credentials: request.credentials,
341+
destination: request.destination,
342+
integrity: request.integrity,
343+
redirect: request.redirect,
344+
referrer: request.referrer,
345+
referrerPolicy: request.referrerPolicy,
346+
body: await request.arrayBuffer(),
347+
keepalive: request.keepalive,
348+
}
349+
}

src/layouts/Header/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,11 @@ const Header = () => {
5252
<IconWrap show={isFullscreenEnabled}>
5353
<FullScreen />
5454
</IconWrap>
55-
<Divider type="vertical" />
55+
<Divider orientation="vertical" />
5656
<IconWrap>
5757
<Github />
5858
</IconWrap>
59-
<Divider type="vertical" />
59+
<Divider orientation="vertical" />
6060
<IconWrap>
6161
<Avatar />
6262
</IconWrap>

0 commit comments

Comments
 (0)