Skip to content

Commit 08de3af

Browse files
committed
refactor: remove react-toastify, use sonner
Signed-off-by: Innei <[email protected]>
1 parent b2bb2de commit 08de3af

File tree

21 files changed

+178
-398
lines changed

21 files changed

+178
-398
lines changed

eslint.config.mjs

+1
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ export default defineConfig(
5959
rules: {
6060
'package-json/valid-package-def': 0,
6161
'package-json/valid-name': 0,
62+
'package-json/valid-package-definition': 0,
6263
},
6364
},
6465
)

package.json

+5-4
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@
99
},
1010
"scripts": {
1111
"analyze": "cross-env NODE_ENV=production ANALYZE=true BUNDLE_ANALYZE=browser next build",
12+
"prebuild": "rimraf .next || exit 0",
1213
"build": "cross-env NODE_ENV=production NODE_OPTIONS=--max_old_space_size=4096 next build",
1314
"build:ci": "cross-env NODE_ENV=production NODE_OPTIONS=--max_old_space_size=4096 NEXT_TELEMETRY_DISABLED=1 CI=true next build",
1415
"dev": "cross-env NODE_ENV=development next dev -p 2323",
1516
"dev:turbo": "cross-env NODE_ENV=development next dev -p 2323 --turbo",
1617
"lint": "eslint --fix",
17-
"prebuild": "rimraf .next || exit 0",
1818
"prepare": "pnpm exec simple-git-hooks && test -f .env || cp .env.template .env",
1919
"prod:pm2": "cross-env NODE_ENV=production pm2 restart ecosystem.config.cjs",
2020
"prod:reload": "pm2 reload ecosystem.config.cjs",
@@ -71,6 +71,7 @@
7171
"dayjs": "1.11.13",
7272
"emoji-mart": "5.6.0",
7373
"emoji-picker-react": "4.12.0",
74+
"es-toolkit": "1.32.0",
7475
"foxact": "0.2.43",
7576
"fuse.js": "7.0.0",
7677
"idb-keyval": "6.2.1",
@@ -82,7 +83,6 @@
8283
"jsondiffpatch": "^0.6.0",
8384
"katex": "^0.16.21",
8485
"kbar": "0.1.0-beta.45",
85-
"lodash.get": "4.4.2",
8686
"markdown-escape": "2.0.0",
8787
"markdown-to-jsx": "npm:@innei/[email protected]",
8888
"marked": "15.0.6",
@@ -104,13 +104,14 @@
104104
"react-intersection-observer": "9.15.1",
105105
"react-responsive-masonry": "2.7.1",
106106
"react-router-dom": "7.1.3",
107-
"react-toastify": "11.0.3",
107+
"react-shadow": "20.6.0",
108108
"react-tweet": "3.2.1",
109109
"remark-directive": "3.0.1",
110110
"remove-markdown": "0.6.0",
111111
"rss": "1.2.2",
112112
"server-only": "^0.0.1",
113113
"socket.io-client": "4.8.1",
114+
"sonner": "1.7.4",
114115
"tailwind-merge": "2.6.0",
115116
"unidata.js": "0.8.0",
116117
"unified": "^11.0.5",
@@ -213,4 +214,4 @@
213214
"browserslist": [
214215
"defaults and fully supports es6-module"
215216
]
216-
}
217+
}

pnpm-lock.yaml

+44-24
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/app/(app)/layout.tsx

+2-4
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,10 @@
33
import type { Metadata, Viewport } from 'next'
44
import { PublicEnvScript } from 'next-runtime-env'
55
import type { PropsWithChildren } from 'react'
6-
import { ToastContainer } from 'react-toastify'
76

87
import PKG from '~/../package.json'
98
import { Global } from '~/components/common/Global'
109
import { HydrationEndDetector } from '~/components/common/HydrationEndDetector'
11-
import { ScrollTop } from '~/components/common/ScrollTop'
1210
import { SyncServerTime } from '~/components/common/SyncServerTime'
1311
import { Root } from '~/components/layout/root/Root'
1412
import { AccentColorStyleInjector } from '~/components/modules/shared/AccentColorStyleInjector'
@@ -192,8 +190,8 @@ export default async function RootLayout(props: PropsWithChildren) {
192190
<SearchPanelWithHotKey />
193191
<Analyze />
194192
<SyncServerTime />
195-
<ToastContainer />
196-
<ScrollTop />
193+
194+
{/* <ScrollTop /> */}
197195
<div className="fixed inset-y-0 right-0 w-[var(--removed-body-scroll-bar-size)]" />
198196
</WebAppProviders>
199197
</body>

src/app/(dashboard)/dashboard/[[...catch_all]]/route-builder.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
// @ts-expect-error
2-
import get from 'lodash.get'
1+
import { get } from 'es-toolkit/compat'
32
import { Fragment } from 'react/jsx-runtime'
43
import type { RouteObject } from 'react-router-dom'
54

src/app/(dashboard)/layout.tsx

-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import type { Viewport } from 'next'
22
import { PublicEnvScript } from 'next-runtime-env'
33
import type { PropsWithChildren } from 'react'
4-
import { ToastContainer } from 'react-toastify'
54

65
import { ClientOnly } from '~/components/common/ClientOnly'
76
import { HydrationEndDetector } from '~/components/common/HydrationEndDetector'
@@ -75,7 +74,6 @@ export default async function RootLayout({ children }: PropsWithChildren) {
7574
<FABContainer />
7675
</ClientOnly>
7776
</DashboardAppProviders>
78-
<ToastContainer />
7977
</body>
8078
</html>
8179
)

src/atoms/owner.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export const login = async (username?: string, password?: string) => {
2727
jotaiStore.set(isLoggedAtom, true)
2828

2929
await fetchAppUrl()
30-
toast(`欢迎回来,${jotaiStore.get(ownerAtom)?.name}`, 'success')
30+
toast.success(`欢迎回来,${jotaiStore.get(ownerAtom)?.name}`)
3131
}
3232

3333
return true

src/components/modules/note/NoteActionAside.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ const LikeButton = () => {
108108
control.start('tap', {
109109
repeat: 5,
110110
})
111-
toast('谢谢你!', undefined, {
111+
toast.success('谢谢你!', {
112112
iconElement: (
113113
<m.i
114114
className="i-mingcute-heart-fill text-uk-red-light"

src/components/modules/note/NoteHideIfSecret.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export const NoteHideIfSecret: Component = ({ children }) => {
2424
const MAX_TIMEOUT = (2 ^ 31) - 1
2525
if (isSecret && timeout && timeout < MAX_TIMEOUT) {
2626
timer = setTimeout(() => {
27-
toast('刷新以查看解锁的文章', 'info', { autoClose: false })
27+
toast.info('刷新以查看解锁的文章', { autoClose: false })
2828
}, timeout)
2929
}
3030

src/components/modules/post/PostActionAside.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ const LikeButton = () => {
112112
onClick={() => {
113113
handleLike()
114114
control.start('tap')
115-
toast('捕捉一只大佬!', undefined, {
115+
toast.success('捕捉一只大佬!', {
116116
iconElement: (
117117
<m.i
118118
className="text-uk-orange-light"

src/components/modules/shared/ShareModal.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ const shareList = [
3838
icon: <i className="i-mingcute-copy-fill" />,
3939
onClick: (data: ShareData) => {
4040
navigator.clipboard.writeText(data.url)
41-
toast('已复制到剪贴板')
41+
toast.success('已复制到剪贴板')
4242
},
4343
},
4444
]

src/components/modules/shared/ToastCard.tsx

-62
This file was deleted.

0 commit comments

Comments
 (0)