mirror of
https://github.com/fastapiadmin/FastapiAdmin.git
synced 2026-10-13 04:39:41 +00:00
feat(theme): 添加侧边栏logo的文本颜色和背景色变量
feat(editor): 替换模拟文件上传为实际API调用 fix(validator): 为日期和时间类型添加格式验证器
This commit is contained in:
@@ -23,27 +23,11 @@
|
||||
import "@wangeditor-next/editor/dist/css/style.css";
|
||||
import { Toolbar, Editor } from "@wangeditor-next/editor-for-vue";
|
||||
import { IToolbarConfig, IEditorConfig } from "@wangeditor-next/editor";
|
||||
import ResourceAPI from "@/api/module_monitor/resource";
|
||||
|
||||
// 上传图片回调函数类型
|
||||
type InsertFnType = (_url: string, _alt: string, _href: string) => void;
|
||||
|
||||
// 模拟文件上传API,根据实际项目进行调整
|
||||
interface UploadResult {
|
||||
url: string;
|
||||
name: string;
|
||||
}
|
||||
|
||||
const FileAPI = {
|
||||
uploadFile: async (file: File): Promise<UploadResult> => {
|
||||
// 这里应该是实际的文件上传逻辑
|
||||
// 暂时返回一个mock数据
|
||||
return Promise.resolve({
|
||||
url: "https://example.com/image.jpg",
|
||||
name: file.name,
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
const props = defineProps({
|
||||
height: {
|
||||
type: String,
|
||||
@@ -82,12 +66,19 @@ const editorConfig = ref<Partial<IEditorConfig>>({
|
||||
scroll: props.scroll,
|
||||
MENU_CONF: {
|
||||
uploadImage: {
|
||||
customUpload(file: File, insertFn: InsertFnType) {
|
||||
// 上传图片
|
||||
FileAPI.uploadFile(file).then((res) => {
|
||||
// 插入图片
|
||||
insertFn(res.url, res.name, res.url);
|
||||
});
|
||||
async customUpload(file: File, insertFn: InsertFnType) {
|
||||
const formData = new FormData();
|
||||
formData.append("file", file);
|
||||
|
||||
try {
|
||||
const res = await ResourceAPI.uploadFile(formData);
|
||||
const data = res.data.data;
|
||||
|
||||
insertFn(data.file_url, data.filename, data.file_url);
|
||||
} catch (error: any) {
|
||||
console.error("图片上传失败:", error);
|
||||
ElMessage.error("图片上传失败");
|
||||
}
|
||||
},
|
||||
} as any,
|
||||
},
|
||||
|
||||
@@ -338,4 +338,6 @@ html.dark {
|
||||
--sidebar-active-bg: rgba(64, 128, 255, 0.15);
|
||||
--sidebar-active-hover-bg: rgba(64, 128, 255, 0.2);
|
||||
--sidebar-hover: var(--el-fill-color-light);
|
||||
--sidebar-logo-text-color: var(--el-color-primary);
|
||||
--sidebar-logo-background: var(--el-fill-color);
|
||||
}
|
||||
|
||||
@@ -333,4 +333,6 @@
|
||||
--sidebar-active-bg: #f8fafc;
|
||||
--sidebar-active-hover-bg: #f1f5f9;
|
||||
--sidebar-hover: #fafafa;
|
||||
--sidebar-logo-text-color: var(--el-color-primary);
|
||||
--sidebar-logo-background: #ffffff;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user