diff --git a/Yi.Ai.Vue3/.eslintrc-auto-import.json b/Yi.Ai.Vue3/.eslintrc-auto-import.json index af1083b7..313e6711 100644 --- a/Yi.Ai.Vue3/.eslintrc-auto-import.json +++ b/Yi.Ai.Vue3/.eslintrc-auto-import.json @@ -5,6 +5,8 @@ "ComputedRef": true, "DirectiveBinding": true, "EffectScope": true, + "ElMessage": true, + "ElMessageBox": true, "ExtractDefaultPropTypes": true, "ExtractPropTypes": true, "ExtractPublicPropTypes": true, diff --git a/Yi.Ai.Vue3/src/components/LoginDialog/components/QrCodeLogin/index.vue b/Yi.Ai.Vue3/src/components/LoginDialog/components/QrCodeLogin/index.vue index 61ef60a4..601387d1 100644 --- a/Yi.Ai.Vue3/src/components/LoginDialog/components/QrCodeLogin/index.vue +++ b/Yi.Ai.Vue3/src/components/LoginDialog/components/QrCodeLogin/index.vue @@ -189,23 +189,28 @@ function stopPolling() { } /** 刷新二维码 */ -async function handleRefresh() { - isExpired.value = false; - isQrCodeError.value = false; - isScanned.value = false; - isConfirming.value = false; - stopPolling(); +// async function handleRefresh() { +// isExpired.value = false; +// isQrCodeError.value = false; +// isScanned.value = false; +// isConfirming.value = false; +// stopPolling(); +// +// const success = await fetchQRCodeInfo(); +// if (success) { +// qrStart(shallowRef(600)); +// startStatusPolling(); +// } +// else { +// isQrCodeError.value = true; +// stopPolling(); +// ElMessage.error('刷新二维码失败'); +// } +// } - const success = await fetchQRCodeInfo(); - if (success) { - qrStart(shallowRef(600)); - startStatusPolling(); - } - else { - isQrCodeError.value = true; - stopPolling(); - ElMessage.error('刷新二维码失败'); - } +/** 刷新二维码按钮 */ +async function handleRefresh() { + await initQRCode(); } /** 启动状态轮询 */ @@ -221,17 +226,41 @@ function startStatusPolling() { /** 组件初始化 */ onMounted(async () => { + await initQRCode(); + // const success = await fetchQRCodeInfo(); + // if (success) { + // qrStart(); + // startStatusPolling(); + // } + // else { + // isQrCodeError.value = true; + // stopPolling(); + // ElMessage.error('初始化二维码失败'); + // } +}); + +/** 初始化或刷新二维码 */ +async function initQRCode() { + // 清理旧的定时器和轮询 + qrStop(); + confirmStop(); + stopPolling(); + const success = await fetchQRCodeInfo(); if (success) { - qrStart(); - startStatusPolling(); + isExpired.value = false; + isQrCodeError.value = false; + isScanned.value = false; + isConfirming.value = false; + + qrStart(); // 重新开始倒计时 + startStatusPolling(); // 开始轮询 } else { isQrCodeError.value = true; - stopPolling(); - ElMessage.error('初始化二维码失败'); + ElMessage.error('获取二维码失败'); } -}); +} /** 组件卸载清理 */ onBeforeUnmount(() => { diff --git a/Yi.Ai.Vue3/src/components/LoginDialog/index.vue b/Yi.Ai.Vue3/src/components/LoginDialog/index.vue index 1de72a8e..7d400858 100644 --- a/Yi.Ai.Vue3/src/components/LoginDialog/index.vue +++ b/Yi.Ai.Vue3/src/components/LoginDialog/index.vue @@ -23,7 +23,7 @@ const loginFormType = computed(() => loginFromStore.LoginFormType); // 使用 defineModel 定义双向绑定的 visible(需 Vue 3.4+) const visible = defineModel('visible'); const showMask = ref(false); // 控制遮罩层显示的独立状态 -const isQrMode = ref(true); +const isQrMode = ref(false); const userStore = useUserStore(); const router = useRouter(); const sessionStore = useSessionStore(); @@ -56,6 +56,8 @@ function handleMaskClick() { // 过渡动画结束回调 function onAfterLeave() { if (!visible.value) { + isQrMode.value = false; + showMask.value = false; // 动画结束后隐藏遮罩 } } diff --git a/Yi.Ai.Vue3/types/components.d.ts b/Yi.Ai.Vue3/types/components.d.ts index 8e9b414c..ef586459 100644 --- a/Yi.Ai.Vue3/types/components.d.ts +++ b/Yi.Ai.Vue3/types/components.d.ts @@ -11,6 +11,33 @@ declare module 'vue' { AccountPassword: typeof import('./../src/components/LoginDialog/components/FormLogin/AccountPassword.vue')['default'] APIKeyManagement: typeof import('./../src/components/userPersonalCenter/components/APIKeyManagement.vue')['default'] DeepThinking: typeof import('./../src/components/DeepThinking/index.vue')['default'] + ElAlert: typeof import('element-plus/es')['ElAlert'] + ElAvatar: typeof import('element-plus/es')['ElAvatar'] + ElButton: typeof import('element-plus/es')['ElButton'] + ElButtonGroup: typeof import('element-plus/es')['ElButtonGroup'] + ElCard: typeof import('element-plus/es')['ElCard'] + ElCollapse: typeof import('element-plus/es')['ElCollapse'] + ElCollapseItem: typeof import('element-plus/es')['ElCollapseItem'] + ElContainer: typeof import('element-plus/es')['ElContainer'] + ElDescriptions: typeof import('element-plus/es')['ElDescriptions'] + ElDescriptionsItem: typeof import('element-plus/es')['ElDescriptionsItem'] + ElDialog: typeof import('element-plus/es')['ElDialog'] + ElDivider: typeof import('element-plus/es')['ElDivider'] + ElEmpty: typeof import('element-plus/es')['ElEmpty'] + ElForm: typeof import('element-plus/es')['ElForm'] + ElFormItem: typeof import('element-plus/es')['ElFormItem'] + ElHeader: typeof import('element-plus/es')['ElHeader'] + ElIcon: typeof import('element-plus/es')['ElIcon'] + ElImage: typeof import('element-plus/es')['ElImage'] + ElInput: typeof import('element-plus/es')['ElInput'] + ElMain: typeof import('element-plus/es')['ElMain'] + ElMenu: typeof import('element-plus/es')['ElMenu'] + ElMenuItem: typeof import('element-plus/es')['ElMenuItem'] + ElPagination: typeof import('element-plus/es')['ElPagination'] + ElTable: typeof import('element-plus/es')['ElTable'] + ElTableColumn: typeof import('element-plus/es')['ElTableColumn'] + ElTag: typeof import('element-plus/es')['ElTag'] + ElTooltip: typeof import('element-plus/es')['ElTooltip'] FilesSelect: typeof import('./../src/components/FilesSelect/index.vue')['default'] IconSelect: typeof import('./../src/components/IconSelect/index.vue')['default'] Indexl: typeof import('./../src/components/SupportModelProducts/indexl.vue')['default'] @@ -32,4 +59,7 @@ declare module 'vue' { VerificationCode: typeof import('./../src/components/LoginDialog/components/FormLogin/VerificationCode.vue')['default'] WelecomeText: typeof import('./../src/components/WelecomeText/index.vue')['default'] } + export interface GlobalDirectives { + vLoading: typeof import('element-plus/es')['ElLoadingDirective'] + } }