From 6ebf3bc7d407d2d40f5222ff7f8734d245529cbb Mon Sep 17 00:00:00 2001 From: tianvier Date: Mon, 22 May 2023 16:48:07 +0800 Subject: [PATCH 01/14] =?UTF-8?q?fix:=20=F0=9F=90=9B=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E5=88=86=E9=A1=B5=E7=BB=84=E4=BB=B6=E6=9B=B4=E6=96=B0=E7=88=B6?= =?UTF-8?q?=E7=BB=84=E4=BB=B6=E5=8F=82=E6=95=B0=E8=AD=A6=E5=91=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Former-commit-id: 8edbb1f048eb9bce38fcfdcac25a6f3b10b00cba --- src/components/Pagination/index.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/Pagination/index.vue b/src/components/Pagination/index.vue index 2953fab8..1aee707c 100644 --- a/src/components/Pagination/index.vue +++ b/src/components/Pagination/index.vue @@ -55,7 +55,7 @@ const props = defineProps({ }, }); -const emit = defineEmits(["pagination"]); +const emit = defineEmits(["pagination", "update:page", "update:limit"]); const currentPage = useVModel(props, "page", emit); From dfcface95d10d0dc21b7d8dfb9d2239ad9d4cccb Mon Sep 17 00:00:00 2001 From: haoxr <1490493387@qq.com> Date: Fri, 2 Jun 2023 23:05:47 +0800 Subject: [PATCH 02/14] =?UTF-8?q?chore:=20:hammer:=20=E5=8D=87=E7=BA=A7`el?= =?UTF-8?q?ement-plus`=E7=89=88=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Former-commit-id: ad6189a62a1025eba9b4273596c86470db73fb1e --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index b5cefd87..4bd2b5dc 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "axios": "^1.4.0", "codemirror": "^5.65.13", "echarts": "^5.2.2", - "element-plus": "^2.3.4", + "element-plus": "^2.3.6", "lodash-es": "^4.17.21", "nprogress": "^0.2.0", "path-browserify": "^1.0.1", @@ -102,4 +102,4 @@ "repository": "https://gitee.com/youlaiorg/vue3-element-admin.git", "author": "有来开源组织", "license": "MIT" -} \ No newline at end of file +} From 68cb0ee20ad19f96952e4d4746c1689d829f6bb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=83=9D=E5=85=88=E7=91=9E?= <1490493387@qq.com> Date: Sat, 3 Jun 2023 11:12:17 +0800 Subject: [PATCH 03/14] =?UTF-8?q?feat:=20:sparkles:=20=E6=96=B0=E5=A2=9E`w?= =?UTF-8?q?ebsocket`=E6=B5=8B=E8=AF=95=E9=A1=B5=E9=9D=A2(=E5=AE=9E?= =?UTF-8?q?=E9=AA=8C=E9=98=B6=E6=AE=B5)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Former-commit-id: 8c5a49f95da85f6a245d9a3cc60d5f925cfc0861 --- src/api/user/types.ts | 1 + src/api/websocket/index.ts | 27 ++++++++ src/store/modules/user.ts | 6 ++ src/views/dashboard/index.vue | 10 +-- src/views/demo/websocket.vue | 119 ++++++++++++++++++++++++++++++++++ 5 files changed, 159 insertions(+), 4 deletions(-) create mode 100644 src/api/websocket/index.ts create mode 100644 src/views/demo/websocket.vue diff --git a/src/api/user/types.ts b/src/api/user/types.ts index 613ad6e1..057be5f3 100644 --- a/src/api/user/types.ts +++ b/src/api/user/types.ts @@ -2,6 +2,7 @@ * 登录用户信息 */ export interface UserInfo { + userId: number; nickname: string; avatar: string; roles: string[]; diff --git a/src/api/websocket/index.ts b/src/api/websocket/index.ts new file mode 100644 index 00000000..867a2a23 --- /dev/null +++ b/src/api/websocket/index.ts @@ -0,0 +1,27 @@ +import request from "@/utils/request"; + +/** + * 发送消息给所有人 + * + * @param file + */ +export function sendToAll(message: string) { + return request({ + url: "/websocket/sendToAll", + method: "post", + params: { message: message }, + }); +} + +/** + * 发送消息给指定用户 + * + * @param + */ +export function sendToUser(userId: number, message: string) { + return request({ + url: "/websocket/sendToUser/" + userId, + method: "post", + params: { message: message }, + }); +} diff --git a/src/store/modules/user.ts b/src/store/modules/user.ts index 72d806d5..d30fee09 100644 --- a/src/store/modules/user.ts +++ b/src/store/modules/user.ts @@ -12,6 +12,7 @@ import { useStorage } from "@vueuse/core"; export const useUserStore = defineStore("user", () => { // state + const userId = ref(); const token = useStorage("accessToken", ""); const nickname = ref(""); const avatar = ref(""); @@ -49,6 +50,7 @@ export const useUserStore = defineStore("user", () => { if (!data.roles || data.roles.length <= 0) { reject("getUserInfo: roles must be a non-null array!"); } + userId.value = data.userId; nickname.value = data.nickname; avatar.value = data.avatar; roles.value = data.roles; @@ -95,6 +97,10 @@ export const useUserStore = defineStore("user", () => { getInfo, logout, resetToken, + /** + * 当前登录用户ID + */ + userId, }; }); diff --git a/src/views/dashboard/index.vue b/src/views/dashboard/index.vue index 359c9c87..7e1d7d73 100644 --- a/src/views/dashboard/index.vue +++ b/src/views/dashboard/index.vue @@ -1,8 +1,10 @@ - - + + From 073d732a1d834ed92afe27b78ddb74f90e449e0e Mon Sep 17 00:00:00 2001 From: haoxr <1490493387@qq.com> Date: Sat, 3 Jun 2023 11:21:07 +0800 Subject: [PATCH 04/14] =?UTF-8?q?docs:=20:memo:=20=E4=BF=AE=E6=94=B9`githu?= =?UTF-8?q?b`=E9=A1=B9=E7=9B=AE=E4=BB=93=E5=BA=93=E5=9C=B0=E5=9D=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 9 #9 Former-commit-id: af3a2db8cc6222b6979931177a3ca3a27023f227 --- src/layout/components/Navbar.vue | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/layout/components/Navbar.vue b/src/layout/components/Navbar.vue index bc99f34c..a37df076 100644 --- a/src/layout/components/Navbar.vue +++ b/src/layout/components/Navbar.vue @@ -88,7 +88,10 @@ function logout() { {{ $t("navbar.dashboard") }} - + Github From eef1c9ce43752fa3b3f115c2e84b0470fe97389c Mon Sep 17 00:00:00 2001 From: haoxr <1490493387@qq.com> Date: Sat, 3 Jun 2023 11:27:29 +0800 Subject: [PATCH 05/14] =?UTF-8?q?docs:=20:memo:=20=E6=89=B9=E9=87=8F?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=A1=B9=E7=9B=AE=E6=96=87=E6=A1=A3=E5=9C=B0?= =?UTF-8?q?=E5=9D=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Former-commit-id: 0386fce902222cbdf91e39ae58f9c4bd8f4e0401 --- README.md | 2 +- src/components/GithubCorner/index.vue | 2 +- src/layout/components/Navbar.vue | 5 ++++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 74726d84..eb8a73cb 100644 --- a/README.md +++ b/README.md @@ -45,7 +45,7 @@ | 项目 | Gitee | Github |GitCode | | --- | --- | --- | --- | | 前端 | [vue3-element-admin](https://gitee.com/youlaiorg/vue3-element-admin) | [vue3-element-admin](https://github.com/youlaitech/vue3-element-admin) |[vue3-element-admin](https://gitcode.net/youlai/vue3-element-admin)| -| 后端 | [youlai-boot](https://gitee.com/youlaiorg/youlai-boot) | [youlai-boot](https://github.com/hxrui/youlai-boot.git) |[youlai-boot](https://gitcode.net/youlai/youlai-boot)| +| 后端 | [youlai-boot](https://gitee.com/youlaiorg/youlai-boot) | [youlai-boot](https://github.com/haoxianrui/youlai-boot.git) |[youlai-boot](https://gitcode.net/youlai/youlai-boot)| ## 环境准备 diff --git a/src/components/GithubCorner/index.vue b/src/components/GithubCorner/index.vue index 6fadd6c4..4b0bba98 100644 --- a/src/components/GithubCorner/index.vue +++ b/src/components/GithubCorner/index.vue @@ -1,6 +1,6 @@