feat: 🚀 文章分类添加图片
This commit is contained in:
Binary file not shown.
@@ -19,7 +19,7 @@ export const getArticleClassDelApi = (params: any) => {
|
||||
};
|
||||
//文章分类更新(用于编辑后)
|
||||
export const getArticleClassEditUpApi = (params: any) => {
|
||||
const { id, name, sort, is_show, pid, seo_title, seo_keywords, seo_desc } = params;
|
||||
const { id, name, sort, is_show, pid, seo_title, seo_keywords, seo_desc, icon } = params;
|
||||
|
||||
return http.put<any>(`/article/category/update/${id}`, {
|
||||
name,
|
||||
@@ -28,7 +28,8 @@ export const getArticleClassEditUpApi = (params: any) => {
|
||||
pid,
|
||||
seo_title,
|
||||
seo_keywords,
|
||||
seo_desc
|
||||
seo_desc,
|
||||
icon
|
||||
});
|
||||
};
|
||||
//文章分类详情(用于编辑)
|
||||
|
||||
117
src/auto-import.d.ts
vendored
117
src/auto-import.d.ts
vendored
@@ -4,67 +4,66 @@
|
||||
// Generated by unplugin-auto-import
|
||||
export {}
|
||||
declare global {
|
||||
const EffectScope: typeof import('vue')['EffectScope']
|
||||
const ElNotification: typeof import('element-plus/es')['ElNotification']
|
||||
const computed: typeof import('vue')['computed']
|
||||
const createApp: typeof import('vue')['createApp']
|
||||
const customRef: typeof import('vue')['customRef']
|
||||
const defineAsyncComponent: typeof import('vue')['defineAsyncComponent']
|
||||
const defineComponent: typeof import('vue')['defineComponent']
|
||||
const effectScope: typeof import('vue')['effectScope']
|
||||
const getCurrentInstance: typeof import('vue')['getCurrentInstance']
|
||||
const getCurrentScope: typeof import('vue')['getCurrentScope']
|
||||
const h: typeof import('vue')['h']
|
||||
const inject: typeof import('vue')['inject']
|
||||
const isProxy: typeof import('vue')['isProxy']
|
||||
const isReactive: typeof import('vue')['isReactive']
|
||||
const isReadonly: typeof import('vue')['isReadonly']
|
||||
const isRef: typeof import('vue')['isRef']
|
||||
const markRaw: typeof import('vue')['markRaw']
|
||||
const nextTick: typeof import('vue')['nextTick']
|
||||
const onActivated: typeof import('vue')['onActivated']
|
||||
const onBeforeMount: typeof import('vue')['onBeforeMount']
|
||||
const onBeforeRouteLeave: typeof import('vue-router')['onBeforeRouteLeave']
|
||||
const onBeforeRouteUpdate: typeof import('vue-router')['onBeforeRouteUpdate']
|
||||
const onBeforeUnmount: typeof import('vue')['onBeforeUnmount']
|
||||
const onBeforeUpdate: typeof import('vue')['onBeforeUpdate']
|
||||
const onDeactivated: typeof import('vue')['onDeactivated']
|
||||
const onErrorCaptured: typeof import('vue')['onErrorCaptured']
|
||||
const onMounted: typeof import('vue')['onMounted']
|
||||
const onRenderTracked: typeof import('vue')['onRenderTracked']
|
||||
const onRenderTriggered: typeof import('vue')['onRenderTriggered']
|
||||
const onScopeDispose: typeof import('vue')['onScopeDispose']
|
||||
const onServerPrefetch: typeof import('vue')['onServerPrefetch']
|
||||
const onUnmounted: typeof import('vue')['onUnmounted']
|
||||
const onUpdated: typeof import('vue')['onUpdated']
|
||||
const provide: typeof import('vue')['provide']
|
||||
const reactive: typeof import('vue')['reactive']
|
||||
const readonly: typeof import('vue')['readonly']
|
||||
const ref: typeof import('vue')['ref']
|
||||
const resolveComponent: typeof import('vue')['resolveComponent']
|
||||
const shallowReactive: typeof import('vue')['shallowReactive']
|
||||
const shallowReadonly: typeof import('vue')['shallowReadonly']
|
||||
const shallowRef: typeof import('vue')['shallowRef']
|
||||
const toRaw: typeof import('vue')['toRaw']
|
||||
const toRef: typeof import('vue')['toRef']
|
||||
const toRefs: typeof import('vue')['toRefs']
|
||||
const toValue: typeof import('vue')['toValue']
|
||||
const triggerRef: typeof import('vue')['triggerRef']
|
||||
const unref: typeof import('vue')['unref']
|
||||
const useAttrs: typeof import('vue')['useAttrs']
|
||||
const useCssModule: typeof import('vue')['useCssModule']
|
||||
const useCssVars: typeof import('vue')['useCssVars']
|
||||
const useLink: typeof import('vue-router')['useLink']
|
||||
const useRoute: typeof import('vue-router')['useRoute']
|
||||
const useRouter: typeof import('vue-router')['useRouter']
|
||||
const useSlots: typeof import('vue')['useSlots']
|
||||
const watch: typeof import('vue')['watch']
|
||||
const watchEffect: typeof import('vue')['watchEffect']
|
||||
const watchPostEffect: typeof import('vue')['watchPostEffect']
|
||||
const watchSyncEffect: typeof import('vue')['watchSyncEffect']
|
||||
const EffectScope: typeof import("vue")["EffectScope"];
|
||||
const computed: typeof import("vue")["computed"];
|
||||
const createApp: typeof import("vue")["createApp"];
|
||||
const customRef: typeof import("vue")["customRef"];
|
||||
const defineAsyncComponent: typeof import("vue")["defineAsyncComponent"];
|
||||
const defineComponent: typeof import("vue")["defineComponent"];
|
||||
const effectScope: typeof import("vue")["effectScope"];
|
||||
const getCurrentInstance: typeof import("vue")["getCurrentInstance"];
|
||||
const getCurrentScope: typeof import("vue")["getCurrentScope"];
|
||||
const h: typeof import("vue")["h"];
|
||||
const inject: typeof import("vue")["inject"];
|
||||
const isProxy: typeof import("vue")["isProxy"];
|
||||
const isReactive: typeof import("vue")["isReactive"];
|
||||
const isReadonly: typeof import("vue")["isReadonly"];
|
||||
const isRef: typeof import("vue")["isRef"];
|
||||
const markRaw: typeof import("vue")["markRaw"];
|
||||
const nextTick: typeof import("vue")["nextTick"];
|
||||
const onActivated: typeof import("vue")["onActivated"];
|
||||
const onBeforeMount: typeof import("vue")["onBeforeMount"];
|
||||
const onBeforeRouteLeave: typeof import("vue-router")["onBeforeRouteLeave"];
|
||||
const onBeforeRouteUpdate: typeof import("vue-router")["onBeforeRouteUpdate"];
|
||||
const onBeforeUnmount: typeof import("vue")["onBeforeUnmount"];
|
||||
const onBeforeUpdate: typeof import("vue")["onBeforeUpdate"];
|
||||
const onDeactivated: typeof import("vue")["onDeactivated"];
|
||||
const onErrorCaptured: typeof import("vue")["onErrorCaptured"];
|
||||
const onMounted: typeof import("vue")["onMounted"];
|
||||
const onRenderTracked: typeof import("vue")["onRenderTracked"];
|
||||
const onRenderTriggered: typeof import("vue")["onRenderTriggered"];
|
||||
const onScopeDispose: typeof import("vue")["onScopeDispose"];
|
||||
const onServerPrefetch: typeof import("vue")["onServerPrefetch"];
|
||||
const onUnmounted: typeof import("vue")["onUnmounted"];
|
||||
const onUpdated: typeof import("vue")["onUpdated"];
|
||||
const provide: typeof import("vue")["provide"];
|
||||
const reactive: typeof import("vue")["reactive"];
|
||||
const readonly: typeof import("vue")["readonly"];
|
||||
const ref: typeof import("vue")["ref"];
|
||||
const resolveComponent: typeof import("vue")["resolveComponent"];
|
||||
const shallowReactive: typeof import("vue")["shallowReactive"];
|
||||
const shallowReadonly: typeof import("vue")["shallowReadonly"];
|
||||
const shallowRef: typeof import("vue")["shallowRef"];
|
||||
const toRaw: typeof import("vue")["toRaw"];
|
||||
const toRef: typeof import("vue")["toRef"];
|
||||
const toRefs: typeof import("vue")["toRefs"];
|
||||
const toValue: typeof import("vue")["toValue"];
|
||||
const triggerRef: typeof import("vue")["triggerRef"];
|
||||
const unref: typeof import("vue")["unref"];
|
||||
const useAttrs: typeof import("vue")["useAttrs"];
|
||||
const useCssModule: typeof import("vue")["useCssModule"];
|
||||
const useCssVars: typeof import("vue")["useCssVars"];
|
||||
const useLink: typeof import("vue-router")["useLink"];
|
||||
const useRoute: typeof import("vue-router")["useRoute"];
|
||||
const useRouter: typeof import("vue-router")["useRouter"];
|
||||
const useSlots: typeof import("vue")["useSlots"];
|
||||
const watch: typeof import("vue")["watch"];
|
||||
const watchEffect: typeof import("vue")["watchEffect"];
|
||||
const watchPostEffect: typeof import("vue")["watchPostEffect"];
|
||||
const watchSyncEffect: typeof import("vue")["watchSyncEffect"];
|
||||
}
|
||||
// for type re-export
|
||||
declare global {
|
||||
// @ts-ignore
|
||||
export type { Component, ComponentPublicInstance, ComputedRef, InjectionKey, PropType, Ref, VNode } from 'vue'
|
||||
export type { Component, ComponentPublicInstance, ComputedRef, InjectionKey, PropType, Ref, VNode } from "vue";
|
||||
}
|
||||
|
||||
@@ -108,7 +108,7 @@ const options = reactive({
|
||||
["blockquote", "code-block"], // 引用 代码块
|
||||
[{ list: "ordered" }, { list: "bullet" }], // 有序、无序列表
|
||||
[{ indent: "-1" }, { indent: "+1" }], // 缩进
|
||||
[{ size: ["small", false, "large", "huge"] }], // 字体大小
|
||||
[{ size: fontSizeStyle.whitelist }], // 字体大小
|
||||
[{ header: [1, 2, 3, 4, 5, 6, false] }], // 标题
|
||||
[{ color: [] }, { background: [] }], // 字体颜色、字体背景颜色
|
||||
[{ align: [] }], // 对齐方式
|
||||
|
||||
@@ -1,260 +0,0 @@
|
||||
<template>
|
||||
<el-upload
|
||||
:id="uuid"
|
||||
action="#"
|
||||
:multiple="true"
|
||||
:show-file-list="false"
|
||||
:http-request="() => {}"
|
||||
:before-upload="() => false"
|
||||
@change="handleFileChange"
|
||||
class="editor-img-uploader"
|
||||
accept=".jpeg,.jpg,.png,.gif"
|
||||
>
|
||||
<i ref="uploadRef" class="Plus editor-img-uploader"></i>
|
||||
</el-upload>
|
||||
<input
|
||||
type="file"
|
||||
accept="video/*"
|
||||
name="file"
|
||||
ref="uploadFileVideo"
|
||||
id="uploadFileVideo"
|
||||
@change="handleVideoUpload"
|
||||
style="width: 0; height: 0; cursor: pointer; opacity: 0"
|
||||
/>
|
||||
<div class="editor">
|
||||
<QuillEditor
|
||||
id="editorId"
|
||||
ref="myQuillEditor"
|
||||
v-model:content="editorContent"
|
||||
contentType="html"
|
||||
@update:content="onContentChange"
|
||||
:options="options"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup name="Editor">
|
||||
import { QuillEditor, Quill } from "@vueup/vue-quill";
|
||||
import "@vueup/vue-quill/dist/vue-quill.snow.css";
|
||||
import { getCurrentInstance, reactive, ref, toRaw, computed, onMounted } from "vue";
|
||||
import { generateUUID } from "@/utils";
|
||||
import { h } from "@/utils/url";
|
||||
import { routerObj } from "./utils.js";
|
||||
import { titleConfig } from "./titleConfig.js";
|
||||
import { uploadVideo, uploadImg } from "@/api/modules/upload";
|
||||
|
||||
// 字体配置
|
||||
let fontSizeStyle = Quill.import("attributors/style/size");
|
||||
fontSizeStyle.whitelist = ["12px", "14px", "16px", "18px", "20px", "22px", "24px", "26px", "28px", "30px", "32px"];
|
||||
Quill.register(fontSizeStyle, true);
|
||||
|
||||
// 自定义模块
|
||||
import ImageBlot from "./quill-image";
|
||||
import Video from "./quill-video";
|
||||
Quill.register(Video);
|
||||
Quill.register(ImageBlot);
|
||||
|
||||
// 路由相关
|
||||
const $router = useRouter();
|
||||
const routerValueName = $router.currentRoute.value.name;
|
||||
const routerName = ref(routerObj[routerValueName]);
|
||||
|
||||
// 核心:上传队列 + 临时去重集合
|
||||
const uploadQueue = ref([]);
|
||||
const isProcessing = ref(false);
|
||||
const uuid = ref(generateUUID());
|
||||
const tempProcessedFiles = ref(new Set());
|
||||
|
||||
// 编辑器基础
|
||||
const { proxy } = getCurrentInstance();
|
||||
const emit = defineEmits(["update:content", "handleRichTextContentChange"]);
|
||||
const uploadFileVideo = ref(null);
|
||||
const myQuillEditor = ref(null);
|
||||
const oldContent = ref("");
|
||||
|
||||
// Props
|
||||
const props = defineProps({
|
||||
content: { type: String, default: "" },
|
||||
readOnly: { type: Boolean, default: false },
|
||||
fileSizeLimit: { type: Number, default: 10 }
|
||||
});
|
||||
|
||||
// 内容双向绑定
|
||||
const editorContent = computed({
|
||||
get: () => props.content,
|
||||
set: val => emit("update:content", val)
|
||||
});
|
||||
|
||||
// 编辑器配置
|
||||
const options = reactive({
|
||||
theme: "snow",
|
||||
modules: {
|
||||
toolbar: {
|
||||
container: [
|
||||
["bold", "italic", "underline", "strike"],
|
||||
["blockquote", "code-block"],
|
||||
[{ list: "ordered" }, { list: "bullet" }],
|
||||
[{ indent: "-1" }, { indent: "+1" }],
|
||||
[{ size: fontSizeStyle.whitelist }],
|
||||
[{ header: [1, 2, 3, 4, 5, 6, false] }],
|
||||
[{ color: [] }, { background: [] }],
|
||||
[{ align: [] }],
|
||||
["clean"],
|
||||
["link", "image", "video"]
|
||||
],
|
||||
handlers: {
|
||||
image: () => proxy.$refs.uploadRef.click(),
|
||||
video: () => document.querySelector("#uploadFileVideo")?.click()
|
||||
}
|
||||
}
|
||||
},
|
||||
placeholder: "请输入内容...",
|
||||
readOnly: props.readOnly
|
||||
});
|
||||
|
||||
// 处理文件选择(关键修改:记录原始顺序)
|
||||
const handleFileChange = (file, fileList) => {
|
||||
if (!fileList.length) return;
|
||||
|
||||
const rawEditor = toRaw(myQuillEditor.value);
|
||||
const quill = rawEditor?.getQuill();
|
||||
if (!quill) return;
|
||||
|
||||
// 生成文件唯一标识
|
||||
const getFileKey = file => `${file.name}-${file.size}-${file.lastModified}`;
|
||||
|
||||
// 过滤重复文件
|
||||
const newFiles = fileList.filter(item => {
|
||||
const file = item.raw;
|
||||
const key = getFileKey(file);
|
||||
if (tempProcessedFiles.value.has(key)) {
|
||||
console.log(`跳过重复文件: ${file.name}`);
|
||||
return false;
|
||||
}
|
||||
if (!validateFile(file)) return false;
|
||||
tempProcessedFiles.value.add(key);
|
||||
return true;
|
||||
});
|
||||
|
||||
if (!newFiles.length) return;
|
||||
|
||||
// 获取初始光标位置(所有图片将按顺序插入此位置之后)
|
||||
const baseCursorIndex = quill.selection.savedRange?.index || quill.getLength();
|
||||
|
||||
// 按用户选择顺序添加到队列(关键修改:使用原始索引)
|
||||
newFiles.forEach((item, index) => {
|
||||
uploadQueue.value.push({
|
||||
file: item.raw,
|
||||
originalIndex: index, // 记录用户选择的原始顺序
|
||||
baseCursorIndex // 所有图片共享同一个基础位置
|
||||
});
|
||||
});
|
||||
|
||||
if (!isProcessing.value) {
|
||||
processQueue();
|
||||
}
|
||||
};
|
||||
|
||||
// 文件校验
|
||||
const validateFile = file => {
|
||||
const isImage = file.type.startsWith("image/");
|
||||
if (!isImage) {
|
||||
alert("请上传图片文件");
|
||||
return false;
|
||||
}
|
||||
|
||||
const fileSizeMB = file.size / 1024 / 1024;
|
||||
if (fileSizeMB > props.fileSizeLimit) {
|
||||
alert(`文件 ${file.name} 大小超过 ${props.fileSizeLimit} MB`);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
// 处理上传队列(关键修改:按原始顺序插入)
|
||||
const processQueue = async () => {
|
||||
if (isProcessing.value || uploadQueue.value.length === 0) return;
|
||||
|
||||
isProcessing.value = true;
|
||||
const { file, originalIndex, baseCursorIndex } = uploadQueue.value[0];
|
||||
|
||||
try {
|
||||
const formData = new FormData();
|
||||
formData.append("image", file);
|
||||
const result = await uploadImg(formData, routerName.value);
|
||||
|
||||
if (result?.code === 0) {
|
||||
const rawEditor = toRaw(myQuillEditor.value);
|
||||
const quill = rawEditor.getQuill();
|
||||
|
||||
// 关键修改:计算正确的插入位置(基于原始顺序和基础位置)
|
||||
const insertPosition = baseCursorIndex + originalIndex;
|
||||
|
||||
quill.insertEmbed(insertPosition, "image", {
|
||||
url: h + result.data.path,
|
||||
id: generateUUID()
|
||||
});
|
||||
|
||||
// 不更新光标位置,确保后续图片按原始顺序插入
|
||||
// quill.setSelection(insertPosition + 1);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(`文件 ${file.name} 上传失败:`, error);
|
||||
} finally {
|
||||
uploadQueue.value.shift();
|
||||
if (uploadQueue.value.length === 0) {
|
||||
tempProcessedFiles.value.clear();
|
||||
}
|
||||
isProcessing.value = false;
|
||||
processQueue();
|
||||
}
|
||||
};
|
||||
|
||||
// 视频上传
|
||||
const handleVideoUpload = async evt => {
|
||||
if (evt.target.files.length === 0) return;
|
||||
|
||||
const file = evt.target.files[0];
|
||||
const formData = new FormData();
|
||||
formData.append("video", file);
|
||||
|
||||
try {
|
||||
const rawEditor = toRaw(myQuillEditor.value);
|
||||
const quill = rawEditor.getQuill();
|
||||
const cursorIndex = quill.selection.savedRange?.index || 0;
|
||||
|
||||
const { data } = await uploadVideo(formData);
|
||||
quill.insertEmbed(cursorIndex, "video", {
|
||||
url: h + data.path,
|
||||
id: generateUUID()
|
||||
});
|
||||
quill.setSelection(cursorIndex + 1);
|
||||
} catch (error) {
|
||||
console.error("视频上传失败:", error);
|
||||
} finally {
|
||||
evt.target.value = "";
|
||||
}
|
||||
};
|
||||
|
||||
// 内容变化监听
|
||||
const onContentChange = content => {
|
||||
emit("handleRichTextContentChange", content);
|
||||
};
|
||||
|
||||
// 初始化标题提示
|
||||
const initTitle = () => {
|
||||
for (const item of titleConfig.value) {
|
||||
const tip = document.querySelector(`.ql-toolbar ${item.Choice}`);
|
||||
if (tip) tip.setAttribute("title", item.title);
|
||||
}
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
initTitle();
|
||||
oldContent.value = props.content;
|
||||
});
|
||||
</script>
|
||||
<style lang="scss">
|
||||
@import "./index.scss";
|
||||
</style>
|
||||
@@ -1,10 +0,0 @@
|
||||
//lineHeight.js
|
||||
import Quill from "quill";
|
||||
const Parchment = Quill.import("parchment");
|
||||
class lineHeightAttributor extends Parchment.Attributor.Style {}
|
||||
const lineHeightStyle = new lineHeightAttributor("lineHeight", "line-height", {
|
||||
scope: Parchment.Scope.INLINE,
|
||||
whitelist: ["1", "2", "3", "4", "5"]
|
||||
});
|
||||
|
||||
export { lineHeightStyle };
|
||||
@@ -1,124 +0,0 @@
|
||||
// 自定义字体大小模块,支持预设选项和输入框
|
||||
export class CustomFontSize {
|
||||
constructor(quill, options) {
|
||||
this.quill = quill;
|
||||
this.options = options;
|
||||
|
||||
// 创建工具栏容器
|
||||
const container = quill.getModule("toolbar").container;
|
||||
|
||||
// 创建字体大小选择器
|
||||
this.selector = document.createElement("select");
|
||||
this.selector.classList.add("ql-size");
|
||||
|
||||
// 添加预设选项
|
||||
options.presets.forEach(size => {
|
||||
if (size === false) {
|
||||
// 添加分隔线
|
||||
const option = document.createElement("option");
|
||||
option.disabled = true;
|
||||
option.innerHTML = "──────────";
|
||||
this.selector.appendChild(option);
|
||||
} else {
|
||||
// 添加预设大小选项
|
||||
const option = document.createElement("option");
|
||||
option.value = size;
|
||||
option.innerHTML = this.getSizeLabel(size);
|
||||
this.selector.appendChild(option);
|
||||
}
|
||||
});
|
||||
|
||||
// 添加自定义输入选项
|
||||
const inputOption = document.createElement("option");
|
||||
inputOption.value = "custom";
|
||||
inputOption.innerHTML = "自定义";
|
||||
this.selector.appendChild(inputOption);
|
||||
|
||||
// 创建自定义输入框
|
||||
this.input = document.createElement("input");
|
||||
this.input.type = "number";
|
||||
this.input.placeholder = "输入字号";
|
||||
this.input.min = 1;
|
||||
this.input.style.width = "50px";
|
||||
this.input.style.display = "none"; // 默认隐藏
|
||||
|
||||
// 将选择器和输入框添加到工具栏
|
||||
container.appendChild(this.selector);
|
||||
container.appendChild(this.input);
|
||||
|
||||
// 绑定事件
|
||||
this.selector.addEventListener("change", this.onSelectChange.bind(this));
|
||||
this.input.addEventListener("change", this.onInputChange.bind(this));
|
||||
this.quill.on("text-change", this.update.bind(this));
|
||||
|
||||
// 初始化
|
||||
this.update();
|
||||
}
|
||||
|
||||
// 获取大小标签
|
||||
getSizeLabel(size) {
|
||||
const labels = {
|
||||
small: "小",
|
||||
normal: "正常",
|
||||
large: "大",
|
||||
huge: "超大"
|
||||
};
|
||||
return labels[size] || size;
|
||||
}
|
||||
|
||||
// 选择器变更事件
|
||||
onSelectChange() {
|
||||
const value = this.selector.value;
|
||||
|
||||
if (value === "custom") {
|
||||
// 显示输入框
|
||||
this.input.style.display = "inline-block";
|
||||
this.input.focus();
|
||||
} else {
|
||||
// 隐藏输入框并应用选择的大小
|
||||
this.input.style.display = "none";
|
||||
this.quill.format("size", value);
|
||||
}
|
||||
}
|
||||
|
||||
// 输入框变更事件
|
||||
onInputChange() {
|
||||
const value = this.input.value;
|
||||
if (value) {
|
||||
this.quill.format("size", `${value}px`);
|
||||
}
|
||||
// 选择"自定义"选项,保持输入框显示
|
||||
this.selector.value = "custom";
|
||||
}
|
||||
|
||||
// 更新当前选中状态
|
||||
update() {
|
||||
const selection = this.quill.getSelection();
|
||||
if (selection) {
|
||||
const [format] = this.quill.getFormat(selection.index, 1);
|
||||
const size = format.size;
|
||||
|
||||
if (size && size.endsWith("px")) {
|
||||
const sizeValue = size.replace("px", "");
|
||||
this.input.value = sizeValue;
|
||||
|
||||
// 如果是预设值,选中对应的选项
|
||||
if (this.options.presets.includes(size)) {
|
||||
this.selector.value = size;
|
||||
this.input.style.display = "none";
|
||||
} else {
|
||||
// 否则选中"自定义"并显示输入框
|
||||
this.selector.value = "custom";
|
||||
this.input.style.display = "inline-block";
|
||||
}
|
||||
} else {
|
||||
// 没有选中的大小,重置为默认
|
||||
this.selector.value = "normal";
|
||||
this.input.style.display = "none";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// // 注册自定义模块
|
||||
// Quill.register("modules/customFontSize", CustomFontSize);
|
||||
@@ -271,5 +271,5 @@
|
||||
white-space: nowrap;
|
||||
}
|
||||
.el-message__wrapper {
|
||||
z-index: 9999 !important; /* 一个较大的值,确保在抽屉之上 */
|
||||
z-index: 3000 !important; /* 一个较大的值,确保在抽屉之上 */
|
||||
}
|
||||
|
||||
@@ -53,13 +53,19 @@ export const EDIT_FORM_DATA: FormItem[] = [
|
||||
type: "treeSelect",
|
||||
label: "所属分类: ",
|
||||
options: []
|
||||
},
|
||||
{
|
||||
prop: "icon",
|
||||
type: "upImg",
|
||||
label: "图片: "
|
||||
}
|
||||
];
|
||||
export const EDIT_RULE_FORM = {
|
||||
is_show: 1,
|
||||
sort: 1,
|
||||
sort: 0,
|
||||
name: "",
|
||||
pid: 0
|
||||
pid: 0,
|
||||
icon: ""
|
||||
};
|
||||
// editRuleForm: {},
|
||||
//editFormData: [],
|
||||
|
||||
@@ -76,6 +76,7 @@
|
||||
|
||||
<script setup lang="ts" name="articleClassListIndex">
|
||||
import rulesForm from "@/components/rulesForm/index.vue";
|
||||
import SearchForm from "@/components/SearchForm/index.vue";
|
||||
import { integerRexg } from "@/utils/regexp/index";
|
||||
import { addLabelValue } from "@/utils/addLabelValue";
|
||||
import { h } from "@/utils/url";
|
||||
@@ -174,7 +175,6 @@ const getArticleClassAddSave = async () => {
|
||||
};
|
||||
//文章编辑
|
||||
const getArticleClassUpEdit = async () => {
|
||||
console.log("编辑");
|
||||
const result = await getArticleClassEditUpApi(dataStore.editRuleForm);
|
||||
const { msg, code } = result;
|
||||
|
||||
|
||||
@@ -121,6 +121,7 @@ const dataStore = reactive<any>({
|
||||
formData: FORM_DATA, // 搜索配置项 dataStore.formData
|
||||
visible: false,
|
||||
data: [],
|
||||
type: "image",
|
||||
isFirstRequest: true
|
||||
});
|
||||
|
||||
@@ -140,6 +141,7 @@ const getProductCategoryList = async () => {
|
||||
const result = await getProductCategoryListApi();
|
||||
if (result?.code === 0) {
|
||||
let dataClone: any = cloneDeep(result?.data);
|
||||
console.log(dataClone, "=dataClone=");
|
||||
dataStore.editFormData[7].options = addLabelValue(dataClone);
|
||||
}
|
||||
};
|
||||
@@ -164,6 +166,7 @@ const buildTree = (data: any, outerLinkTo: any = "") => {
|
||||
};
|
||||
// let isFirstRequest = true;
|
||||
const handleRadioGroupEmits = (value: any) => {
|
||||
dataStore.type = value;
|
||||
if (value === "video") {
|
||||
dataStore.editFormData = EDIT_FORM_DATA1;
|
||||
dataStore.rules = RULES1;
|
||||
@@ -205,6 +208,7 @@ const getSystemUrls = async (node: any, resolve: any) => {
|
||||
}
|
||||
};
|
||||
const setImgOrVideo = (result: any) => {
|
||||
dataStore.type = result?.data?.type;
|
||||
if (result?.data?.type === "image") {
|
||||
dataStore.editFormData = cloneDeep(EDIT_FORM_DATA);
|
||||
}
|
||||
@@ -224,7 +228,7 @@ const getBannerRead = async (id: any) => {
|
||||
if (result?.code === 0) {
|
||||
setImgOrVideo(result);
|
||||
getProductCategoryList();
|
||||
if (!result?.data?.desc) {
|
||||
if (result?.data?.type === "image" && !result?.data?.desc) {
|
||||
formRef?.value?.editorRef[0]?.clearEditor();
|
||||
}
|
||||
nextTick(() => {
|
||||
@@ -251,6 +255,7 @@ const getBannerRead = async (id: any) => {
|
||||
};
|
||||
const handleCheck = (checkedNodes: any, values: any) => {
|
||||
const { checkedKeys } = values;
|
||||
console.log(checkedKeys, "=checkedKeys=");
|
||||
if (checkedKeys.length) {
|
||||
dataStore.editRuleForm.link = checkedNodes.url;
|
||||
dataStore.editRuleForm.link_to = checkedNodes.link_to;
|
||||
@@ -333,7 +338,9 @@ const handleConfirmClick = () => {
|
||||
const resetFields = () => {
|
||||
if (!formRef.value!.ruleFormRef) return;
|
||||
formRef!.value!.ruleFormRef.resetFields();
|
||||
if (dataStore.type === "image") {
|
||||
formRef?.value?.editorRef[0]?.clearEditor();
|
||||
}
|
||||
};
|
||||
// 抽屉重置
|
||||
const handleResetClick = () => {
|
||||
|
||||
@@ -61,7 +61,7 @@ const $route = useRoute();
|
||||
import { getCategorysApi } from "@/api/modules/downloadClass";
|
||||
import { recursiveCompare } from "@/utils/recursiveCompare";
|
||||
import { addLabelValue } from "@/utils/addLabelValue";
|
||||
|
||||
import { ElNotification } from "element-plus";
|
||||
//深拷贝方法
|
||||
import { cloneDeep } from "lodash-es";
|
||||
import {
|
||||
@@ -156,7 +156,6 @@ const excelUploadSuccess = (response: any, row: any) => {
|
||||
if (response?.code === 0) {
|
||||
row.file_path = response.data.path; // 假设后端返回的文件路径在 data.path 中
|
||||
}
|
||||
console.log(row, "====row========");
|
||||
ElNotification({
|
||||
title: "温馨提示",
|
||||
message: `文件上传成功!`,
|
||||
|
||||
Reference in New Issue
Block a user