fix: 修复用户管理页裁剪图片上传组件逻辑问题

- 当用户avatar字段为空时,使用平台默认图片,以确保裁剪组件能正确加载
This commit is contained in:
ZM25XC
2024-03-25 10:29:50 +08:00
committed by GitHub
parent e38610ff67
commit f4e1404b6e

View File

@@ -10,6 +10,7 @@ import { usePublicHooks } from "../../hooks";
import { addDialog } from "@/components/ReDialog"; import { addDialog } from "@/components/ReDialog";
import type { PaginationProps } from "@pureadmin/table"; import type { PaginationProps } from "@pureadmin/table";
import type { FormItemProps, RoleFormItemProps } from "../utils/types"; import type { FormItemProps, RoleFormItemProps } from "../utils/types";
import userAvatar from "@/assets/user.jpg";
import { import {
getKeyList, getKeyList,
isAllEmpty, isAllEmpty,
@@ -85,8 +86,8 @@ export function useUser(tableRef: Ref, treeRef: Ref) {
<el-image <el-image
fit="cover" fit="cover"
preview-teleported={true} preview-teleported={true}
src={row.avatar} src={row.avatar || userAvatar}
preview-src-list={Array.of(row.avatar)} preview-src-list={Array.of(row.avatar || userAvatar)}
class="w-[24px] h-[24px] rounded-full align-middle" class="w-[24px] h-[24px] rounded-full align-middle"
/> />
), ),
@@ -370,7 +371,7 @@ export function useUser(tableRef: Ref, treeRef: Ref) {
contentRenderer: () => contentRenderer: () =>
h(croppingUpload, { h(croppingUpload, {
ref: cropRef, ref: cropRef,
imgSrc: row.avatar, imgSrc: row.avatar || userAvatar,
onCropper: info => (avatarInfo.value = info) onCropper: info => (avatarInfo.value = info)
}), }),
beforeSure: done => { beforeSure: done => {