From e9feb6e03635d481bd437128e922f41fb9981d54 Mon Sep 17 00:00:00 2001 From: nanxun Date: Mon, 3 Nov 2025 15:07:36 +0800 Subject: [PATCH 1/2] =?UTF-8?q?add(IFriendService)=EF=BC=9A=E5=AE=8C?= =?UTF-8?q?=E5=96=84=E5=A5=BD=E5=8F=8B=E5=85=B3=E7=B3=BB=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/IM_API/Dtos/HandleFriendRequestDto.cs | 25 + .../Interface/Services/IFriendSerivce.cs | 32 + frontend/web/index.html | 1 + frontend/web/src/App.vue | 2 +- frontend/web/src/components/Layout.vue | 262 ------ frontend/web/src/components/Window.vue | 136 +++ frontend/web/src/router/index.js | 7 +- frontend/web/src/views/Main.vue | 829 ++++++++++++++++++ frontend/web/src/views/auth/Login.vue | 540 +++++------- 9 files changed, 1239 insertions(+), 595 deletions(-) create mode 100644 backend/IM_API/Dtos/HandleFriendRequestDto.cs delete mode 100644 frontend/web/src/components/Layout.vue create mode 100644 frontend/web/src/components/Window.vue create mode 100644 frontend/web/src/views/Main.vue diff --git a/backend/IM_API/Dtos/HandleFriendRequestDto.cs b/backend/IM_API/Dtos/HandleFriendRequestDto.cs new file mode 100644 index 0000000..637871d --- /dev/null +++ b/backend/IM_API/Dtos/HandleFriendRequestDto.cs @@ -0,0 +1,25 @@ +namespace IM_API.Dtos +{ + public class HandleFriendRequestDto + { + /// + /// 好友请求Id + /// + public int RequestId { get; set; } + /// + /// 处理操作 + /// + public HandleFriendRequestAction Action { get; set; } + } + public enum HandleFriendRequestAction + { + /// + /// 同意 + /// + Accept = 0, + /// + /// 拒绝 + /// + Reject = 1 + } +} diff --git a/backend/IM_API/Interface/Services/IFriendSerivce.cs b/backend/IM_API/Interface/Services/IFriendSerivce.cs index 2b5fc3a..4f0bfa2 100644 --- a/backend/IM_API/Interface/Services/IFriendSerivce.cs +++ b/backend/IM_API/Interface/Services/IFriendSerivce.cs @@ -28,5 +28,37 @@ namespace IM_API.Interface.Services /// /// Task GetFriendRequestListAsync(int userId,bool isReceived,int page,int limit); + /// + /// 处理好友请求 + /// + /// + /// + Task HandleFriendRequestAsync(HandleFriendRequestDto requestDto); + /// + /// 通过用户Id删除好友关系 + /// + /// 操作用户Id + /// 被删除用户ID + /// + Task DeleteFriendByUserIdAsync(int userId,int toUserId); + /// + /// 通过好友关系Id删除好友关系 + /// + /// 好友关系id + /// + Task DeleteFriendAsync(int friendId); + /// + /// 通过用户Id拉黑好友关系 + /// + /// 操作用户Id + /// 被拉黑用户ID + /// + Task BlockFriendByUserIdAsync(int userId, int toUserId); + /// + /// 通过好友关系Id拉黑好友关系 + /// + /// 好友关系id + /// + Task BlockeFriendAsync(int friendId); } } diff --git a/frontend/web/index.html b/frontend/web/index.html index b19040a..4c929da 100644 --- a/frontend/web/index.html +++ b/frontend/web/index.html @@ -3,6 +3,7 @@ + Vite App diff --git a/frontend/web/src/App.vue b/frontend/web/src/App.vue index af331b0..59f2b39 100644 --- a/frontend/web/src/App.vue +++ b/frontend/web/src/App.vue @@ -11,7 +11,7 @@ diff --git a/frontend/web/src/components/Layout.vue b/frontend/web/src/components/Layout.vue deleted file mode 100644 index c00ea60..0000000 --- a/frontend/web/src/components/Layout.vue +++ /dev/null @@ -1,262 +0,0 @@ - - - - - \ No newline at end of file diff --git a/frontend/web/src/components/Window.vue b/frontend/web/src/components/Window.vue new file mode 100644 index 0000000..874c1aa --- /dev/null +++ b/frontend/web/src/components/Window.vue @@ -0,0 +1,136 @@ + + + + + diff --git a/frontend/web/src/router/index.js b/frontend/web/src/router/index.js index 29e07eb..7fef57a 100644 --- a/frontend/web/src/router/index.js +++ b/frontend/web/src/router/index.js @@ -1,6 +1,11 @@ import { createRouter, createWebHistory } from 'vue-router' +import MainView from '@/views/Main.vue' -const routes = [{ path: '/auth/login', component: () => import('@/views/auth/Login.vue') }] +const routes = [ + { path: '/auth/login', component: () => import('@/views/auth/Login.vue') }, + { path: '/', component: MainView }, + { path: '/index', component: MainView }, +] const router = createRouter({ history: createWebHistory(import.meta.env.BASE_URL), diff --git a/frontend/web/src/views/Main.vue b/frontend/web/src/views/Main.vue new file mode 100644 index 0000000..265a33b --- /dev/null +++ b/frontend/web/src/views/Main.vue @@ -0,0 +1,829 @@ + + + + + \ No newline at end of file diff --git a/frontend/web/src/views/auth/Login.vue b/frontend/web/src/views/auth/Login.vue index 7bd501e..f5667df 100644 --- a/frontend/web/src/views/auth/Login.vue +++ b/frontend/web/src/views/auth/Login.vue @@ -1,58 +1,76 @@ @@ -62,325 +80,185 @@ import { ref } from 'vue' const username = ref('') const password = ref('') +const remember = ref(false) const errorMsg = ref('') +const loading = ref(false) + +const usernameFocused = ref(false) +const passwordFocused = ref(false) const handleLogin = () => { - if (!username.value || !password.value) { + errorMsg.value = '' + if (!username.value.trim() || !password.value) { errorMsg.value = '用户名或密码不能为空' return } - - if (username.value === 'admin' && password.value === '123456') { - alert('登录成功!') - errorMsg.value = '' - // TODO: 跳转到IM主界面 - } else { - errorMsg.value = '用户名或密码错误' - } + loading.value = true + // 模拟登录延迟(客户端示例),生产中替换为 API 调用 + setTimeout(() => { + loading.value = false + if (username.value === 'admin' && password.value === '123456') { + errorMsg.value = '' + alert('登录成功!') + // TODO: 跳转到 IM 主界面 + } else { + errorMsg.value = '用户名或密码错误' + } + }, 700) } \ No newline at end of file + From 45dc14d77b5dacf5be42f04578c288653c9e7d45 Mon Sep 17 00:00:00 2001 From: nanxun Date: Tue, 4 Nov 2025 16:17:23 +0800 Subject: [PATCH 2/2] =?UTF-8?q?add(IConversationService)=EF=BC=9A=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E4=BC=9A=E8=AF=9D=E6=9C=8D=E5=8A=A1=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/IM_API/Dtos/ClearConversationsDto.cs | 26 +++++++++++++++++++ .../Services/IConversationService.cs | 21 +++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 backend/IM_API/Dtos/ClearConversationsDto.cs create mode 100644 backend/IM_API/Interface/Services/IConversationService.cs diff --git a/backend/IM_API/Dtos/ClearConversationsDto.cs b/backend/IM_API/Dtos/ClearConversationsDto.cs new file mode 100644 index 0000000..0d8c5c9 --- /dev/null +++ b/backend/IM_API/Dtos/ClearConversationsDto.cs @@ -0,0 +1,26 @@ +namespace IM_API.Dtos +{ + public class ClearConversationsDto + { + public int UserId { get; set; } + /// + /// 聊天类型 + /// + public ChatType ChatType { get; set; } + /// + /// 目标ID,聊天类型为群则为群id,私聊为用户id + /// + public int TargetId { get; set; } + } + public enum ChatType + { + /// + /// 私聊 + /// + single = 0, + /// + /// 私聊 + /// + group = 1 + } +} diff --git a/backend/IM_API/Interface/Services/IConversationService.cs b/backend/IM_API/Interface/Services/IConversationService.cs new file mode 100644 index 0000000..9c4bf63 --- /dev/null +++ b/backend/IM_API/Interface/Services/IConversationService.cs @@ -0,0 +1,21 @@ +using IM_API.Dtos; +using IM_API.Models; + +namespace IM_API.Interface.Services +{ + public interface IConversationService + { + /// + /// 清除消息会话 + /// + /// + /// + Task ClearConversationsAsync(ClearConversationsDto clearConversationsDto); + /// + /// 获取用户当前消息会话 + /// + /// 用户id + /// + Task GetConversationsAsync(int userId); + } +}