修复切换<视频智能分析>与<蚕茧仪评分析>Tab页后其他页面无法正常加载的问题
This commit is contained in:
@@ -8,6 +8,12 @@ export namespace AuthApi {
|
|||||||
account?: string;
|
account?: string;
|
||||||
password?: string;
|
password?: string;
|
||||||
}
|
}
|
||||||
|
/** 注册 */
|
||||||
|
export interface RegisterParams {
|
||||||
|
account?: string;
|
||||||
|
code?: string;
|
||||||
|
password?: string;
|
||||||
|
}
|
||||||
|
|
||||||
export interface Token {
|
export interface Token {
|
||||||
token: string;
|
token: string;
|
||||||
@@ -39,6 +45,22 @@ export async function loginApi(data: AuthApi.LoginParams) {
|
|||||||
return requestClient.post<AuthApi.LoginResult>('/user/login', data);
|
return requestClient.post<AuthApi.LoginResult>('/user/login', data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发送验证码
|
||||||
|
*/
|
||||||
|
export async function sendCodeApi(str: string) {
|
||||||
|
return requestClient.post<any>('/user/sendCode', { str });
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 注册
|
||||||
|
*/
|
||||||
|
export async function registerApi(data: AuthApi.RegisterParams) {
|
||||||
|
// 密码加密
|
||||||
|
data.password = sha256(data.password?.toString() || '');
|
||||||
|
return requestClient.post<any>('/user/register', data);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 刷新accessToken
|
* 刷新accessToken
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -46,5 +46,6 @@ export const overridesPreferences = defineOverridesPreferences({
|
|||||||
},
|
},
|
||||||
tabbar: {
|
tabbar: {
|
||||||
middleClickToClose: true,
|
middleClickToClose: true,
|
||||||
|
keepAlive: false,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ const routes: RouteRecordRaw[] = [
|
|||||||
authority: ['iva'],
|
authority: ['iva'],
|
||||||
icon: 'mdi:video',
|
icon: 'mdi:video',
|
||||||
title: $t('ai.intelligence_video_analysis'),
|
title: $t('ai.intelligence_video_analysis'),
|
||||||
keepAlive: false,
|
keepAlive: true,
|
||||||
},
|
},
|
||||||
component: () => import('#/views/ai/iva/index.vue'),
|
component: () => import('#/views/ai/iva/index.vue'),
|
||||||
},
|
},
|
||||||
@@ -33,6 +33,7 @@ const routes: RouteRecordRaw[] = [
|
|||||||
authority: ['sca'],
|
authority: ['sca'],
|
||||||
icon: 'mdi:ice-cream',
|
icon: 'mdi:ice-cream',
|
||||||
title: $t('ai.silkworm_cocoon_analysis'),
|
title: $t('ai.silkworm_cocoon_analysis'),
|
||||||
|
keepAlive: false,
|
||||||
},
|
},
|
||||||
component: () => import('#/views/ai/sca/index.vue'),
|
component: () => import('#/views/ai/sca/index.vue'),
|
||||||
},
|
},
|
||||||
@@ -43,6 +44,7 @@ const routes: RouteRecordRaw[] = [
|
|||||||
authority: ['ysa'],
|
authority: ['ysa'],
|
||||||
icon: 'mdi:account-key-outline',
|
icon: 'mdi:account-key-outline',
|
||||||
title: $t('ai.young_silkworm_analysis'),
|
title: $t('ai.young_silkworm_analysis'),
|
||||||
|
keepAlive: false,
|
||||||
},
|
},
|
||||||
component: () => import('#/views/ai/ysa/index.vue'),
|
component: () => import('#/views/ai/ysa/index.vue'),
|
||||||
},
|
},
|
||||||
@@ -53,7 +55,7 @@ const routes: RouteRecordRaw[] = [
|
|||||||
meta: {
|
meta: {
|
||||||
icon: 'mdi:wall-fire',
|
icon: 'mdi:wall-fire',
|
||||||
iframeSrc: 'http://171.212.101.199:13010/',
|
iframeSrc: 'http://171.212.101.199:13010/',
|
||||||
keepAlive: true,
|
keepAlive: false,
|
||||||
title: '检索增强生成',
|
title: '检索增强生成',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -2,25 +2,72 @@
|
|||||||
import type { VbenFormSchema } from '@vben/common-ui';
|
import type { VbenFormSchema } from '@vben/common-ui';
|
||||||
import type { Recordable } from '@vben/types';
|
import type { Recordable } from '@vben/types';
|
||||||
|
|
||||||
import { computed, h, ref } from 'vue';
|
import { computed, h, ref, useTemplateRef } from 'vue';
|
||||||
|
|
||||||
import { AuthenticationRegister, z } from '@vben/common-ui';
|
import { AuthenticationRegister, z } from '@vben/common-ui';
|
||||||
import { $t } from '@vben/locales';
|
import { $t } from '@vben/locales';
|
||||||
|
|
||||||
|
import { registerApi, sendCodeApi } from '#/api';
|
||||||
|
import { useAuthStore } from '#/store';
|
||||||
|
|
||||||
defineOptions({ name: 'Register' });
|
defineOptions({ name: 'Register' });
|
||||||
|
|
||||||
const loading = ref(false);
|
const loading = ref(false);
|
||||||
|
const CODE_LENGTH = 4;
|
||||||
|
|
||||||
|
const registerRef =
|
||||||
|
useTemplateRef<InstanceType<typeof AuthenticationRegister>>('registerRef');
|
||||||
|
const sending = ref(false);
|
||||||
const formSchema = computed((): VbenFormSchema[] => {
|
const formSchema = computed((): VbenFormSchema[] => {
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
component: 'VbenInput',
|
component: 'VbenInput',
|
||||||
componentProps: {
|
componentProps: {
|
||||||
placeholder: $t('authentication.usernameTip'),
|
placeholder: $t('authentication.emailTip'),
|
||||||
},
|
},
|
||||||
fieldName: 'username',
|
fieldName: 'account',
|
||||||
label: $t('authentication.username'),
|
label: $t('authentication.email'),
|
||||||
rules: z.string().min(1, { message: $t('authentication.usernameTip') }),
|
rules: z
|
||||||
|
.string()
|
||||||
|
.min(1, { message: $t('authentication.emailTip') })
|
||||||
|
.refine((v) => /^[^\s@]+@[^\s@][^\s.@]*\.[^\s@]+$/.test(v), {
|
||||||
|
message: $t('邮箱格式错误'),
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
component: 'VbenPinInput',
|
||||||
|
componentProps: {
|
||||||
|
codeLength: CODE_LENGTH,
|
||||||
|
createText(countdown: number) {
|
||||||
|
if (sending.value) {
|
||||||
|
return $t('正在发送中');
|
||||||
|
}
|
||||||
|
return countdown > 0
|
||||||
|
? $t('authentication.sendText', [countdown])
|
||||||
|
: $t('authentication.sendCode');
|
||||||
|
},
|
||||||
|
placeholder: $t('authentication.code'),
|
||||||
|
async handleSendCode() {
|
||||||
|
sending.value = true;
|
||||||
|
try {
|
||||||
|
const formApi = registerRef.value?.getFormApi();
|
||||||
|
if (!formApi) throw new Error('formApi is not ready');
|
||||||
|
|
||||||
|
await formApi.validateField('account');
|
||||||
|
const isPhoneReady = await formApi.isFieldValid('account');
|
||||||
|
if (!isPhoneReady) throw new Error('邮箱不可为空');
|
||||||
|
|
||||||
|
const { account } = await formApi.getValues();
|
||||||
|
await sendCodeApi(account);
|
||||||
|
} finally {
|
||||||
|
sending.value = false;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
fieldName: 'code',
|
||||||
|
label: $t('authentication.code'),
|
||||||
|
rules: z.string().length(CODE_LENGTH, {
|
||||||
|
message: $t('authentication.codeTip', [CODE_LENGTH]),
|
||||||
|
}),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
component: 'VbenInputPassword',
|
component: 'VbenInputPassword',
|
||||||
@@ -80,15 +127,32 @@ const formSchema = computed((): VbenFormSchema[] => {
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
});
|
});
|
||||||
|
async function handleSubmit(value: Recordable<any>) {
|
||||||
|
loading.value = true;
|
||||||
|
try {
|
||||||
|
const params = {
|
||||||
|
account: value.account,
|
||||||
|
code: value.code,
|
||||||
|
password: value.password,
|
||||||
|
};
|
||||||
|
const { accessToken } = await registerApi(params);
|
||||||
|
|
||||||
function handleSubmit(value: Recordable<any>) {
|
if (accessToken) {
|
||||||
// eslint-disable-next-line no-console
|
// 注册成功后,把 token 交给 authStore 走统一流程
|
||||||
console.log('register submit:', value);
|
const authStore = useAuthStore();
|
||||||
|
authStore.authLogin({ account: value.account, password: value.password });
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('注册失败', error);
|
||||||
|
} finally {
|
||||||
|
loading.value = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<AuthenticationRegister
|
<AuthenticationRegister
|
||||||
|
ref="registerRef"
|
||||||
:form-schema="formSchema"
|
:form-schema="formSchema"
|
||||||
:loading="loading"
|
:loading="loading"
|
||||||
@submit="handleSubmit"
|
@submit="handleSubmit"
|
||||||
|
|||||||
@@ -345,6 +345,7 @@ function onListItemClick(video: any) {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
<div class="flex h-full w-full flex-col">
|
||||||
<BaseModal />
|
<BaseModal />
|
||||||
<CreateVideoTaskModal />
|
<CreateVideoTaskModal />
|
||||||
<div class="flex h-full w-full bg-gray-50">
|
<div class="flex h-full w-full bg-gray-50">
|
||||||
@@ -494,4 +495,5 @@ function onListItemClick(video: any) {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import type { EchartsUIType } from '@vben/plugins/echarts';
|
import type { EchartsUIType } from '@vben/plugins/echarts';
|
||||||
|
|
||||||
import { onMounted, ref, watch } from 'vue';
|
import { onActivated, onDeactivated, onMounted, ref, watch } from 'vue';
|
||||||
|
|
||||||
import { useVbenModal } from '@vben/common-ui';
|
import { useVbenModal } from '@vben/common-ui';
|
||||||
import { EchartsUI, useEcharts } from '@vben/plugins/echarts';
|
import { EchartsUI, useEcharts } from '@vben/plugins/echarts';
|
||||||
@@ -144,9 +144,21 @@ function refreshLineChart() {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onDeactivated(() => {
|
||||||
|
// 离开路由时清理状态
|
||||||
|
selectedItem.value = null;
|
||||||
|
showInfoStr.value = {};
|
||||||
|
});
|
||||||
|
|
||||||
|
onActivated(() => {
|
||||||
|
// 回来的时候重新刷新一次列表
|
||||||
|
loadList();
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
<div class="flex h-full w-full flex-col">
|
||||||
<BaseModal />
|
<BaseModal />
|
||||||
<CreateYSATaskModal />
|
<CreateYSATaskModal />
|
||||||
<div class="flex h-full w-full bg-gray-50">
|
<div class="flex h-full w-full bg-gray-50">
|
||||||
@@ -204,7 +216,9 @@ function refreshLineChart() {
|
|||||||
:key="key"
|
:key="key"
|
||||||
class="mb-2 flex text-sm text-gray-700"
|
class="mb-2 flex text-sm text-gray-700"
|
||||||
>
|
>
|
||||||
<div class="w-32 font-medium text-gray-900">{{ key }}:</div>
|
<div class="w-32 font-medium text-gray-900">
|
||||||
|
{{ key }}:
|
||||||
|
</div>
|
||||||
<div class="flex-1 break-all text-gray-600">
|
<div class="flex-1 break-all text-gray-600">
|
||||||
{{ value || '—' }}
|
{{ value || '—' }}
|
||||||
</div>
|
</div>
|
||||||
@@ -252,4 +266,5 @@ function refreshLineChart() {
|
|||||||
</template>
|
</template>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -46,7 +46,7 @@
|
|||||||
"sendResetLink": "发送重置链接",
|
"sendResetLink": "发送重置链接",
|
||||||
"sendText": "{0}秒后重新获取",
|
"sendText": "{0}秒后重新获取",
|
||||||
"signUp": "注册",
|
"signUp": "注册",
|
||||||
"signUpSubtitle": "让您的应用程序管理变得简单而有趣",
|
"signUpSubtitle": "让您的人工智能体验变得简单而有趣",
|
||||||
"terms": "条款",
|
"terms": "条款",
|
||||||
"thirdPartyLogin": "其他登录方式",
|
"thirdPartyLogin": "其他登录方式",
|
||||||
"username": "账号",
|
"username": "账号",
|
||||||
|
|||||||
Reference in New Issue
Block a user