From 0754b4128febc3214b2ecfdbc9b193ad54c28892 Mon Sep 17 00:00:00 2001 From: CrescentLeaf Date: Sun, 23 Nov 2025 13:27:43 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8A=BD=E5=8F=96=E5=85=AC=E5=85=B1=E9=83=A8?= =?UTF-8?q?=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client-protocol/ApiCallbackMessage.ts | 18 ++------ client-protocol/ApiDeclare.ts | 63 +------------------------- client-protocol/deno.jsonc | 3 +- client/api/ApiCallbackMessage.ts | 18 ++------ client/api/ApiDeclare.ts | 63 +------------------------- client/deno.jsonc | 8 ++-- deno.jsonc | 3 +- internal-shared/ApiCallbackMessage.ts | 16 +++++++ internal-shared/ApiDeclare.ts | 63 ++++++++++++++++++++++++++ internal-shared/deno.jsonc | 0 internal-shared/mod.ts | 4 ++ server/api/ApiCallbackMessage.ts | 18 ++------ server/api/ApiDeclare.ts | 64 +-------------------------- 13 files changed, 102 insertions(+), 239 deletions(-) create mode 100644 internal-shared/ApiCallbackMessage.ts create mode 100644 internal-shared/ApiDeclare.ts create mode 100644 internal-shared/deno.jsonc create mode 100644 internal-shared/mod.ts diff --git a/client-protocol/ApiCallbackMessage.ts b/client-protocol/ApiCallbackMessage.ts index dc4f58f..c5f98ee 100644 --- a/client-protocol/ApiCallbackMessage.ts +++ b/client-protocol/ApiCallbackMessage.ts @@ -1,15 +1,3 @@ -type ApiCallbackMessage = { - msg: string, - /** - * 200: 成功 - * 400: 伺服器端無法理解客戶端請求 - * 401: 需要身份驗證 - * 403: 伺服器端拒絕執行客戶端請求 - * 404: Not Found - * 500: 伺服器端錯誤 - * 501: 伺服器端不支持請求的功能 - */ - code: 200 | 400 | 401 | 403 | 404 | 500 | 501 | -1, - data?: { [key: string]: unknown }, -} -export default ApiCallbackMessage +import { ApiCallbackMessage } from 'lingchair-internal-shared' + +export type { ApiCallbackMessage as default } diff --git a/client-protocol/ApiDeclare.ts b/client-protocol/ApiDeclare.ts index 6b5d0a0..e9868c2 100644 --- a/client-protocol/ApiDeclare.ts +++ b/client-protocol/ApiDeclare.ts @@ -1,62 +1 @@ -export type CallMethod = - // 用户验证 - "User.auth" | - "User.register" | - "User.login" | - "User.refreshAccessToken" | - - // 账号 - "User.setAvatar" | - "User.updateProfile" | - "User.getMyInfo" | - "User.resetPassword" | - - // 用户资料 - "User.getInfo" | - - // 收藏对话列表 - "User.getMyContacts" | - "User.addContacts" | - "User.removeContacts" | - - // 最近对话列表 - "User.getMyRecentChats" | - - // 所有对话列表 - "User.getMyAllChats" | - - // 对话信息 - "Chat.getInfo" | - "Chat.getAnotherUserIdFromPrivate" | - "Chat.getMembers" | - - // 对话设置 - "Chat.updateSettings" | - "Chat.setAvatar" | - - // 对话创建 - "Chat.createGroup" | - "Chat.getIdForPrivate" | - - // 入群请求 - "Chat.processJoinRequest" | - "Chat.sendJoinRequest" | - "Chat.getJoinRequests" | - - // 对话消息 - "Chat.sendMessage" | - "Chat.getMessageHistory" - - // (废弃) 文件上传 - // "Chat.uploadFile" - -export type ClientEvent = - // 对话收消息 - "Client.onMessage" - -export const CallableMethodBeforeAuth = [ - "User.auth", - "User.register", - "User.login", - "User.refreshAccessToken", -] \ No newline at end of file +export * from 'lingchair-internal-shared' diff --git a/client-protocol/deno.jsonc b/client-protocol/deno.jsonc index 4cdc1bc..818504e 100644 --- a/client-protocol/deno.jsonc +++ b/client-protocol/deno.jsonc @@ -1,5 +1,6 @@ { "imports": { - "socket.io-client": "npm:socket.io-client@4.8.1" + "socket.io-client": "npm:socket.io-client@4.8.1", + "lingchair-internal-shared": "../internal-shared/mod.ts" } } \ No newline at end of file diff --git a/client/api/ApiCallbackMessage.ts b/client/api/ApiCallbackMessage.ts index dc4f58f..c5f98ee 100644 --- a/client/api/ApiCallbackMessage.ts +++ b/client/api/ApiCallbackMessage.ts @@ -1,15 +1,3 @@ -type ApiCallbackMessage = { - msg: string, - /** - * 200: 成功 - * 400: 伺服器端無法理解客戶端請求 - * 401: 需要身份驗證 - * 403: 伺服器端拒絕執行客戶端請求 - * 404: Not Found - * 500: 伺服器端錯誤 - * 501: 伺服器端不支持請求的功能 - */ - code: 200 | 400 | 401 | 403 | 404 | 500 | 501 | -1, - data?: { [key: string]: unknown }, -} -export default ApiCallbackMessage +import { ApiCallbackMessage } from 'lingchair-internal-shared' + +export type { ApiCallbackMessage as default } diff --git a/client/api/ApiDeclare.ts b/client/api/ApiDeclare.ts index 6b5d0a0..e9868c2 100644 --- a/client/api/ApiDeclare.ts +++ b/client/api/ApiDeclare.ts @@ -1,62 +1 @@ -export type CallMethod = - // 用户验证 - "User.auth" | - "User.register" | - "User.login" | - "User.refreshAccessToken" | - - // 账号 - "User.setAvatar" | - "User.updateProfile" | - "User.getMyInfo" | - "User.resetPassword" | - - // 用户资料 - "User.getInfo" | - - // 收藏对话列表 - "User.getMyContacts" | - "User.addContacts" | - "User.removeContacts" | - - // 最近对话列表 - "User.getMyRecentChats" | - - // 所有对话列表 - "User.getMyAllChats" | - - // 对话信息 - "Chat.getInfo" | - "Chat.getAnotherUserIdFromPrivate" | - "Chat.getMembers" | - - // 对话设置 - "Chat.updateSettings" | - "Chat.setAvatar" | - - // 对话创建 - "Chat.createGroup" | - "Chat.getIdForPrivate" | - - // 入群请求 - "Chat.processJoinRequest" | - "Chat.sendJoinRequest" | - "Chat.getJoinRequests" | - - // 对话消息 - "Chat.sendMessage" | - "Chat.getMessageHistory" - - // (废弃) 文件上传 - // "Chat.uploadFile" - -export type ClientEvent = - // 对话收消息 - "Client.onMessage" - -export const CallableMethodBeforeAuth = [ - "User.auth", - "User.register", - "User.login", - "User.refreshAccessToken", -] \ No newline at end of file +export * from 'lingchair-internal-shared' diff --git a/client/deno.jsonc b/client/deno.jsonc index 8c259ba..5b5c93f 100644 --- a/client/deno.jsonc +++ b/client/deno.jsonc @@ -9,10 +9,6 @@ "jsxImportSource": "react", "jsxImportSourceTypes": "@types/react" }, - "links": [ - "./mdui_patched", - ], - "nodeModulesDir": "auto", "imports": { "@deno/vite-plugin": "npm:@deno/vite-plugin@1.0.5", "@types/react": "npm:@types/react@18.3.1", @@ -34,6 +30,8 @@ "socket.io-client": "npm:socket.io-client@4.8.1", "marked": "npm:marked@16.3.0", "dompurify": "npm:dompurify@3.2.7", - "pinch-zoom-element": "npm:pinch-zoom-element@1.1.1" + "pinch-zoom-element": "npm:pinch-zoom-element@1.1.1", + + "lingchair-internal-shared": "../internal-shared/mod.ts" } } diff --git a/deno.jsonc b/deno.jsonc index ced1114..37d6f14 100644 --- a/deno.jsonc +++ b/deno.jsonc @@ -10,6 +10,7 @@ "express": "npm:express@5.1.0", "socket.io": "npm:socket.io@4.8.1", "cookie-parser": "npm:cookie-parser@1.4.7", - "express-fileupload": "npm:express-fileupload@1.5.2" + "express-fileupload": "npm:express-fileupload@1.5.2", + "lingchair-internal-shared": "./internal-shared/mod.ts" } } \ No newline at end of file diff --git a/internal-shared/ApiCallbackMessage.ts b/internal-shared/ApiCallbackMessage.ts new file mode 100644 index 0000000..2ad20ba --- /dev/null +++ b/internal-shared/ApiCallbackMessage.ts @@ -0,0 +1,16 @@ +type ApiCallbackMessage = { + msg: string, + /** + * 200: 成功 + * 400: 伺服器端無法理解客戶端請求 + * 401: 需要身份驗證 + * 403: 伺服器端拒絕執行客戶端請求 + * 404: Not Found + * 500: 伺服器端錯誤 + * 501: 伺服器端不支持請求的功能 + * -1: 请求错误 + */ + code: 200 | 400 | 401 | 403 | 404 | 500 | 501 | -1, + data?: { [key: string]: unknown }, +} +export default ApiCallbackMessage diff --git a/internal-shared/ApiDeclare.ts b/internal-shared/ApiDeclare.ts new file mode 100644 index 0000000..c94b59d --- /dev/null +++ b/internal-shared/ApiDeclare.ts @@ -0,0 +1,63 @@ +export type CallMethod = + // 用户验证 + "User.auth" | + "User.register" | + "User.login" | + "User.refreshAccessToken" | + + // 账号 + "User.setAvatar" | + "User.updateProfile" | + "User.getMyInfo" | + "User.resetPassword" | + + // 用户资料 + "User.getInfo" | + + // 收藏对话列表 + "User.getMyContacts" | + "User.addContacts" | + "User.removeContacts" | + + // 最近对话列表 + "User.getMyRecentChats" | + + // 对话信息 + "Chat.getInfo" | + "Chat.getAnotherUserIdFromPrivate" | + "Chat.getMembers" | + + // 对话设置 + "Chat.updateSettings" | + "Chat.setAvatar" | + + // 对话创建 + "Chat.createGroup" | + "Chat.getIdForPrivate" | + + // 入群请求 + "Chat.processJoinRequest" | + "Chat.sendJoinRequest" | + "Chat.getJoinRequests" | + + // 对话成员 + "Chat.removeMembers" | + "Chat.quit" | + + // 对话消息 + "Chat.sendMessage" | + "Chat.getMessageHistory" + + // (废弃) 文件上传 + // "Chat.uploadFile" + +export type ClientEvent = + // 对话收消息 + "Client.onMessage" + +export const CallableMethodBeforeAuth = [ + "User.auth", + "User.register", + "User.login", + "User.refreshAccessToken", +] \ No newline at end of file diff --git a/internal-shared/deno.jsonc b/internal-shared/deno.jsonc new file mode 100644 index 0000000..e69de29 diff --git a/internal-shared/mod.ts b/internal-shared/mod.ts new file mode 100644 index 0000000..da8f128 --- /dev/null +++ b/internal-shared/mod.ts @@ -0,0 +1,4 @@ +export * from './ApiDeclare.ts' + +import ApiCallbackMessage from './ApiCallbackMessage.ts' +export type { ApiCallbackMessage } diff --git a/server/api/ApiCallbackMessage.ts b/server/api/ApiCallbackMessage.ts index e94b2df..c5f98ee 100644 --- a/server/api/ApiCallbackMessage.ts +++ b/server/api/ApiCallbackMessage.ts @@ -1,15 +1,3 @@ -type ApiCallbackMessage = { - msg: string, - /** - * 200: 成功 - * 400: 伺服器端無法理解客戶端請求 - * 401: 需要身份驗證 - * 403: 伺服器端拒絕執行客戶端請求 - * 404: Not Found - * 500: 伺服器端錯誤 - * 501: 伺服器端不支持請求的功能 - */ - code: 200 | 400 | 401 | 403 | 404 | 500 | 501, - data?: { [key: string]: unknown }, -} -export default ApiCallbackMessage +import { ApiCallbackMessage } from 'lingchair-internal-shared' + +export type { ApiCallbackMessage as default } diff --git a/server/api/ApiDeclare.ts b/server/api/ApiDeclare.ts index c94b59d..e9868c2 100644 --- a/server/api/ApiDeclare.ts +++ b/server/api/ApiDeclare.ts @@ -1,63 +1 @@ -export type CallMethod = - // 用户验证 - "User.auth" | - "User.register" | - "User.login" | - "User.refreshAccessToken" | - - // 账号 - "User.setAvatar" | - "User.updateProfile" | - "User.getMyInfo" | - "User.resetPassword" | - - // 用户资料 - "User.getInfo" | - - // 收藏对话列表 - "User.getMyContacts" | - "User.addContacts" | - "User.removeContacts" | - - // 最近对话列表 - "User.getMyRecentChats" | - - // 对话信息 - "Chat.getInfo" | - "Chat.getAnotherUserIdFromPrivate" | - "Chat.getMembers" | - - // 对话设置 - "Chat.updateSettings" | - "Chat.setAvatar" | - - // 对话创建 - "Chat.createGroup" | - "Chat.getIdForPrivate" | - - // 入群请求 - "Chat.processJoinRequest" | - "Chat.sendJoinRequest" | - "Chat.getJoinRequests" | - - // 对话成员 - "Chat.removeMembers" | - "Chat.quit" | - - // 对话消息 - "Chat.sendMessage" | - "Chat.getMessageHistory" - - // (废弃) 文件上传 - // "Chat.uploadFile" - -export type ClientEvent = - // 对话收消息 - "Client.onMessage" - -export const CallableMethodBeforeAuth = [ - "User.auth", - "User.register", - "User.login", - "User.refreshAccessToken", -] \ No newline at end of file +export * from 'lingchair-internal-shared'