From b6f45dd7a7c1f74aef07fbaec7598e3ed5fffc75 Mon Sep 17 00:00:00 2001 From: Lazy <2211717435@qq.com> Date: Wed, 30 Aug 2023 21:16:27 +0800 Subject: [PATCH] Feat: add update user apikey --- frontend/src/components/MyselfInfoDialog.vue | 63 ++++++++++++-------- frontend/src/services/apis/index.ts | 29 ++++++--- 2 files changed, 59 insertions(+), 33 deletions(-) diff --git a/frontend/src/components/MyselfInfoDialog.vue b/frontend/src/components/MyselfInfoDialog.vue index 0221444e..25d3ea8d 100644 --- a/frontend/src/components/MyselfInfoDialog.vue +++ b/frontend/src/components/MyselfInfoDialog.vue @@ -3,37 +3,31 @@ import { t } from "@/lang/i18n"; import { useAppStateStore } from "@/stores/useAppStateStore"; import { useAppToolsStore } from "@/stores/useAppToolsStore"; import { reactive, toRaw } from "vue"; -const { state } = useAppStateStore(); +import { setUserApiKey } from "@/services/apis"; +import { message } from "ant-design-vue"; +const { state, updateUserInfo } = useAppStateStore(); const { state: tools } = useAppToolsStore(); -// const menus = [ -// { -// title: t("基本信息"), -// key: "baseInfo", -// icon: ProjectOutlined -// }, -// { -// title: t("第三方接口"), -// key: "api", -// icon: RobotOutlined -// }, -// { -// title: t("账号安全"), -// key: "password", -// icon: RobotOutlined -// } -// ]; +const { execute, isLoading } = setUserApiKey(); const formState = reactive({ resetPassword: false, - apikey: "", oldPassword: "", password1: "", password2: "" }); -const handleGenerateApiKey = () => { - formState.apikey = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; +const handleGenerateApiKey = async (enable: boolean) => { + const res = await execute({ + data: { + enable + } + }); + + if (res.value) { + updateUserInfo(); + return message.success(t("更新成功")); + } }; const handleChangePassword = () => {}; @@ -45,8 +39,8 @@ const onSubmit = () => {