Merge branch 'main' into fix

This commit is contained in:
Jin Mao
2026-01-23 13:48:54 +08:00
committed by GitHub
7 changed files with 84 additions and 14 deletions

View File

@@ -17,6 +17,7 @@ import type { BaseFormComponentType } from '@vben/common-ui';
import type { Recordable } from '@vben/types';
import {
computed,
defineAsyncComponent,
defineComponent,
h,
@@ -383,12 +384,17 @@ const withPreviewUpload = () => {
attrs?.fileList || attrs?.['file-list'] || [],
);
const maxSize = computed(() => attrs?.maxSize ?? attrs?.['max-size']);
const aspectRatio = computed(
() => attrs?.aspectRatio ?? attrs?.['aspect-ratio'],
);
const handleBeforeUpload = async (
file: UploadFile,
originFileList: Array<File>,
) => {
if (attrs.maxSize && (file.size || 0) / 1024 / 1024 > attrs.maxSize) {
message.error($t('ui.formRules.sizeLimit', [attrs.maxSize]));
if (maxSize.value && (file.size || 0) / 1024 / 1024 > maxSize.value) {
message.error($t('ui.formRules.sizeLimit', [maxSize.value]));
file.status = 'removed';
return false;
}
@@ -401,7 +407,7 @@ const withPreviewUpload = () => {
) {
file.status = 'removed';
// antd Upload组件问题 file参数获取的是UploadFile类型对象无法取到File类型 所以通过originFileList[0]获取
const blob = await cropImage(originFileList[0], attrs.aspectRatio);
const blob = await cropImage(originFileList[0], aspectRatio.value);
return new Promise((resolve, reject) => {
if (!blob) {
return reject(new Error($t('ui.crop.errorTip')));

View File

@@ -78,15 +78,22 @@ export const useAuthStore = defineStore('auth', () => {
};
}
const isLoggingOut = ref(false); // 正在 logout 标识, 防止 /logout 死循环.
async function logout(redirect: boolean = true) {
if (isLoggingOut.value) return; // 正在登出中, 说明已进入循环, 直接返回.
isLoggingOut.value = true; // 设置 标识
try {
await logoutApi();
} catch {
// 不做任何处理
}
} finally {
isLoggingOut.value = false; // 重置 标识
resetAllStores();
accessStore.setLoginExpired(false);
resetAllStores();
accessStore.setLoginExpired(false);
}
// 回登录页带上当前路由地址
await router.replace({