Skip to content

Commit 59048bf

Browse files
committed
fix: build project error
1 parent 00415dc commit 59048bf

File tree

11 files changed

+78
-45
lines changed

11 files changed

+78
-45
lines changed

components/message/chat/window/ChatMessage.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ export const ChatMessage = ({
167167
</div>
168168

169169
{message.reaction && message.reaction.length > 0 && (
170-
<div className="grid grid-cols-5 gap-x-2 gap-y-1 mt-1">
170+
<div className="flex flex-wrap items-center gap-x-2 gap-y-1 mt-1">
171171
{message.reaction.length < 3
172172
? message.reaction.map((r: ChatMessageReaction) => (
173173
<Chip

components/message/chat/window/ChatMessageContextMenu.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,6 @@ export const ChatMessageContextMenu = ({
5050
onEdit,
5151
isOwner = false
5252
}: Props) => {
53-
if (!isMenuOpen) return null
54-
5553
const groupedReactions = useMemo(() => {
5654
if (!reactionArray || reactionArray.length === 0) {
5755
return {}
@@ -68,6 +66,8 @@ export const ChatMessageContextMenu = ({
6866
)
6967
}, [reactionArray])
7068

69+
if (!isMenuOpen) return null
70+
7171
const handleMenuAction = (key: Key) => {
7272
switch (key) {
7373
case 'reply':

config/app.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
export const KUN_VISUAL_NOVEL_PATCH_APP_ADDRESS =
2-
process.env.NODE_ENV === 'production'
3-
? `http://${process.env.NEXT_PUBLIC_KUN_PATCH_APP_ADDRESS_PROD_HOST}${process.env.NEXT_PUBLIC_KUN_PATCH_APP_ADDRESS_PROD_PORT ? `:${process.env.NEXT_PUBLIC_KUN_PATCH_APP_ADDRESS_PROD_PORT}` : ''}`
4-
: `http://${process.env.NEXT_PUBLIC_KUN_PATCH_APP_ADDRESS_DEV_HOST}${process.env.NEXT_PUBLIC_KUN_PATCH_APP_ADDRESS_DEV_PORT ? `:${process.env.NEXT_PUBLIC_KUN_PATCH_APP_ADDRESS_DEV_PORT}` : ''}`
1+
export const KUN_VISUAL_NOVEL_PATCH_APP_ADDRESS =
2+
process.env.NODE_ENV === 'production'
3+
? `http://${process.env.NEXT_PUBLIC_KUN_PATCH_APP_ADDRESS_PROD_HOST}${process.env.NEXT_PUBLIC_KUN_PATCH_APP_ADDRESS_PROD_PORT ? `:${process.env.NEXT_PUBLIC_KUN_PATCH_APP_ADDRESS_PROD_PORT}` : ''}`
4+
: `http://${process.env.NEXT_PUBLIC_KUN_PATCH_APP_ADDRESS_DEV_HOST}${process.env.NEXT_PUBLIC_KUN_PATCH_APP_ADDRESS_DEV_PORT ? `:${process.env.NEXT_PUBLIC_KUN_PATCH_APP_ADDRESS_DEV_PORT}` : ''}`
5+
6+
export const KUN_SOCKET_IO_ROUTE = '/ws'

context/SocketProvider.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import React, { createContext, useContext, useEffect, useState } from 'react'
44
import { io } from 'socket.io-client'
5+
import { KUN_SOCKET_IO_ROUTE } from '~/config/app'
56
import type { Socket } from 'socket.io-client'
67

78
interface SocketContextType {
@@ -34,7 +35,7 @@ export const SocketProvider = ({
3435
}
3536

3637
const socketInstance = io({
37-
path: '/api/socket',
38+
path: KUN_SOCKET_IO_ROUTE,
3839
query: { userId }
3940
// addTrailingSlash: false,
4041
})

ecosystem.config.cjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ module.exports = {
1010
autorestart: true,
1111
watch: false,
1212
max_memory_restart: '1G',
13-
script: './.next/standalone/server.js'
13+
script: './.next/kun/server.js'
1414
}
1515
]
1616
}

hooks/useSocket.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// hooks/useSocket.ts
22
import { useEffect, useState } from 'react'
33
import { io, Socket } from 'socket.io-client'
4+
import { KUN_SOCKET_IO_ROUTE } from '~/config/app'
45

56
export const useSocket = (userId: number | null) => {
67
const [socket, setSocket] = useState<Socket | null>(null)
@@ -11,7 +12,7 @@ export const useSocket = (userId: number | null) => {
1112
}
1213

1314
const newSocket = io({
14-
path: '/api/socket',
15+
path: KUN_SOCKET_IO_ROUTE,
1516
query: { userId }
1617
})
1718

next.config.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,11 @@ const nextConfig: NextConfig = {
4242
]
4343
},
4444

45-
output: 'standalone',
45+
// outputFileTracingIncludes: {
46+
// '/ws': ['./socket/**/*', './server.ts']
47+
// },
48+
49+
// output: 'standalone',
4650
experimental: {
4751
// turbotrace: {
4852
// logLevel: 'error',

package.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@
77
"scripts": {
88
"dev": "nodemon --exec esno server.ts",
99
"build:next": "next build",
10-
"build:server": "tsc --project tsconfig.server.json",
10+
"build:server": "tsc --project tsconfig.server.json && tsc-alias -p tsconfig.server.json",
11+
"build:sitemap": "esno scripts/generateKunSitemap.ts",
1112
"build": "pnpm build:next && pnpm build:server",
1213
"preview": "node .next/server/server.js",
13-
"postbuild": "esno scripts/postbuild.ts",
14+
"postbuild": "pnpm build:sitemap",
1415
"format": "prettier . --write",
1516
"lint": "next lint",
1617
"lint:fix": "next lint --fix",
@@ -70,7 +71,7 @@
7071
"@milkdown/plugin-automd": "^7.12.1",
7172
"@next/mdx": "^15.3.3",
7273
"@noble/hashes": "^1.8.0",
73-
"@prisma/client": "^6.8.2",
74+
"@prisma/client": "6.10.0",
7475
"@tailwindcss/postcss": "^4.1.8",
7576
"@tanstack/react-query": "^5.79.0",
7677
"@types/mdx": "^2.0.13",
@@ -168,7 +169,6 @@
168169
"@types/react-dom": "19.1.5",
169170
"autoprefixer": "^10.4.21",
170171
"dotenv": "^16.5.0",
171-
"env-cmd": "^10.1.0",
172172
"eslint": "^9.28.0",
173173
"eslint-config-next": "^15.3.3",
174174
"eslint-config-prettier": "^10.1.5",
@@ -195,6 +195,7 @@
195195
"stylelint-order": "^7.0.0",
196196
"tailwindcss": "^4.1.8",
197197
"ts-node-dev": "^2.0.0",
198+
"tsc-alias": "^1.8.16",
198199
"tsx": "^4.20.3",
199200
"typescript": "^5.8.3"
200201
},

pnpm-lock.yaml

Lines changed: 49 additions & 24 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

server.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { parse } from 'url'
44
import next from 'next'
55
import express from 'ultimate-express'
66
import { onSocketConnection } from './socket/handler'
7+
import { KUN_SOCKET_IO_ROUTE } from '~/config/app'
78

89
const dev = process.env.NODE_ENV !== 'production'
910
const hostname = process.env.NEXT_PUBLIC_KUN_PATCH_APP_ADDRESS_PROD_HOST
@@ -19,7 +20,7 @@ app.prepare().then(() => {
1920
const httpServer = createServer((req, res) => {
2021
const parsedUrl = parse(req.url!, true)
2122

22-
if (parsedUrl.pathname?.startsWith('/api/socket')) {
23+
if (parsedUrl.pathname?.startsWith(KUN_SOCKET_IO_ROUTE)) {
2324
expressApp(req, res)
2425
} else {
2526
handle(req, res, parsedUrl)
@@ -30,7 +31,7 @@ app.prepare().then(() => {
3031
})
3132

3233
const io = new Server(httpServer, {
33-
path: '/api/socket',
34+
path: KUN_SOCKET_IO_ROUTE,
3435
cors: {
3536
origin: process.env.NEXT_PUBLIC_KUN_PATCH_ADDRESS_DEV
3637
}
@@ -42,8 +43,6 @@ app.prepare().then(() => {
4243

4344
httpServer.listen(port, () => {
4445
console.log(`> Ready on http://${hostname}:${port}`)
45-
console.log(
46-
`> Socket.IO server listening on http://${hostname}:${port}/api/socket`
47-
)
46+
console.log(`> Socket.IO server listening on http://${hostname}:${port}/ws`)
4847
})
4948
})

0 commit comments

Comments
 (0)