mirror of
https://github.com/fastapiadmin/FastapiAdmin.git
synced 2026-10-08 10:39:59 +00:00
refactor: 重构水印与AI助手逻辑,优化头像上传流程
1. 全局水印组件迁移至布局组件,支持用户名动态水印 2. 移除todo-list滚动条右侧内边距问题 3. 修复头像上传文件名丢失与非兼容格式跳过裁剪逻辑 4. 简化upload组件裁剪配置,移除冗余props 5. 清理gitignore新增忽略项
This commit is contained in:
@@ -20,7 +20,6 @@
|
||||
:tool="true"
|
||||
:show-preview="true"
|
||||
:original-graph="false"
|
||||
:file-type="cropFileType"
|
||||
:title="cropInnerTitle"
|
||||
:preview-title="cropPreviewTitle"
|
||||
@update:img-url="onCropConfirm"
|
||||
@@ -129,7 +128,6 @@ interface Props {
|
||||
cropCutWidth?: number;
|
||||
cropCutHeight?: number;
|
||||
cropQuality?: number;
|
||||
cropFileType?: "png" | "jpeg" | "webp";
|
||||
cropDialogTitle?: string;
|
||||
cropInnerTitle?: string;
|
||||
cropPreviewTitle?: string;
|
||||
@@ -151,7 +149,6 @@ const props = withDefaults(defineProps<Props>(), {
|
||||
cropCutWidth: 360,
|
||||
cropCutHeight: 200,
|
||||
cropQuality: 1,
|
||||
cropFileType: "jpeg",
|
||||
cropDialogTitle: "裁剪图片",
|
||||
cropInnerTitle: "调整图片",
|
||||
cropPreviewTitle: "预览",
|
||||
@@ -167,6 +164,7 @@ const internalFileList = ref<UploadUserFile[]>([]);
|
||||
|
||||
const cropVisible = ref(false);
|
||||
const cropSourceUrl = ref("");
|
||||
const cropFileName = ref("");
|
||||
|
||||
function revokeCropUrl() {
|
||||
if (cropSourceUrl.value.startsWith("blob:")) {
|
||||
@@ -185,9 +183,7 @@ function onCropError() {
|
||||
|
||||
async function onCropConfirm(dataURL: string) {
|
||||
try {
|
||||
const ext =
|
||||
props.cropFileType === "png" ? "png" : props.cropFileType === "webp" ? "webp" : "jpg";
|
||||
const file = dataURLToFile(dataURL, `upload.${ext}`);
|
||||
const file = dataURLToFile(dataURL, cropFileName.value);
|
||||
await uploadFileInternal(file);
|
||||
cropVisible.value = false;
|
||||
revokeCropUrl();
|
||||
@@ -293,6 +289,11 @@ function handleBeforeUpload(file: UploadRawFile) {
|
||||
}
|
||||
|
||||
if (props.enableCrop) {
|
||||
// 非 canvas 兼容格式(如 svg/gif/bmp 等),跳过裁剪直接上传
|
||||
if (file.type !== "image/png" && file.type !== "image/jpeg" && file.type !== "image/webp") {
|
||||
return true;
|
||||
}
|
||||
cropFileName.value = file.name;
|
||||
revokeCropUrl();
|
||||
cropSourceUrl.value = URL.createObjectURL(file);
|
||||
cropVisible.value = true;
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
<script setup lang="ts">
|
||||
import { computed } from "vue";
|
||||
import { storeToRefs } from "pinia";
|
||||
import AppConfig from "@/config";
|
||||
import { defaultSettings } from "@/config/setting";
|
||||
import { ThemeMode } from "@/enums";
|
||||
import { hexToRgba } from "@utils";
|
||||
@@ -52,7 +51,7 @@ interface Props {
|
||||
}
|
||||
|
||||
const props = withDefaults(defineProps<Props>(), {
|
||||
content: AppConfig.systemInfo.name,
|
||||
content: "",
|
||||
visible: false,
|
||||
fontSize: 16,
|
||||
fontColor: undefined,
|
||||
|
||||
Reference in New Issue
Block a user