diff --git a/src/components/contenteditable.vue b/src/components/contenteditable.vue
index 743c430..27cc011 100644
--- a/src/components/contenteditable.vue
+++ b/src/components/contenteditable.vue
@@ -75,7 +75,7 @@ const functions = {
document.execCommand('italic', false, null);
},
- uploadImage: async() => {
+ uploadImage: async () => {
// 保存当前光标位置
savedRange.value = saveSelection();
@@ -84,7 +84,7 @@ const functions = {
fileInput.click();
- fileInput.onchange = async(e) => {
+ fileInput.onchange = async (e) => {
const [file] = e.target.files;
if (!file) return;
if (file.size > 2 * 1024 * 1024) {
@@ -96,12 +96,28 @@ const functions = {
const img = document.createElement('img');
img.src = data.url;
img.onload = () => {
- const scale = img.naturalHeight / 50;
- const width = (img.naturalWidth / scale).toFixed(0);
- const height = 50;
+ // const scale = img.naturalHeight / 50;
+ // const width = (img.naturalWidth / scale).toFixed(0);
+ // const height = 50;
+ // const maxWidth = img.naturalWidth;
+ // const maxHeight = img.naturalHeight;
+ // eslint-disable-next-line standard/no-callback-literal
+ // const style = `style="width:${width}px;
+ // height:${height}px;
+ // max-width:${maxWidth}px;
+ // max-height:${maxHeight}px"`;
+ // 使用原始高度
+ const height = img.naturalHeight;
+ // 根据宽高比计算宽度
+ const width = (height * 3) / 4;
const maxWidth = img.naturalWidth;
const maxHeight = img.naturalHeight;
- const style = `style="width:${width}px;height:${height}px;max-width:${maxWidth}px;max-height:${maxHeight}px"`;
+ // eslint-disable-next-line standard/no-callback-literal
+ const style = `style="width:${width}px;
+ height:${height}px;
+ max-width:${maxWidth}px;
+ max-height:${maxHeight}px"`;
+ // eslint-disable-next-line standard/no-callback-literal
insertImageAtCaret(``);
// 恢复光标位置
@@ -146,10 +162,10 @@ const isEmptyContent = (html) => {
const trimmedHtml = html.trim();
// 检查是否为空字符串、仅包含
或仅包含
选项1
', + option: '行标签1
', option_config: { image_url: [], title: '', @@ -22,26 +22,7 @@ export default { }, option_index: 1, parent_id: 0, - type: 0, - cascade: [], - config: [] - }, - { - id: '', - is_fixed: 0, - is_other: 0, - is_remove_other: 0, - option: '选项2
', - option_config: { - image_url: [], - title: '', - instructions: [], - option_type: 0, - limit_right_content: '' - }, - option_index: 1, - parent_id: 0, - type: 0, + type: 1, cascade: [], config: [] } @@ -67,35 +48,7 @@ export default { gradient: '', image_url: [], option_type: 0, - type: 0, - limit_right_content: '', - child_area: null, - binding_goods_id: '' - }, - disable_option_update: null, - cascade: [] - }, - { - option: '列标签2
', - id: '1049202', - type: 2, - is_other: 0, - is_fixed: 0, - is_remove_other: 0, - created_at: null, - created_user_id: null, - parent_id: null, - option_index: 4, - list_id: 74491, - option_code: '', - option_config: { - title: '', - instructions: [], - price: 0, - gradient: '', - image_url: [], - option_type: 0, - type: 0, + type: 2, limit_right_content: '', child_area: null, binding_goods_id: '' @@ -103,6 +56,34 @@ export default { disable_option_update: null, cascade: [] } + // { + // option: '列标签2
', + // id: '1049202', + // type: 2, + // is_other: 0, + // is_fixed: 0, + // is_remove_other: 0, + // created_at: null, + // created_user_id: null, + // parent_id: null, + // option_index: 4, + // list_id: 74491, + // option_code: '', + // option_config: { + // title: '', + // instructions: [], + // price: 0, + // gradient: '', + // image_url: [], + // option_type: 0, + // type: 0, + // limit_right_content: '', + // child_area: null, + // binding_goods_id: '' + // }, + // disable_option_update: null, + // cascade: [] + // } ] ], last_option_index: 1, diff --git a/src/views/Design/Index.vue b/src/views/Design/Index.vue index 2f18c95..4c01d03 100644 --- a/src/views/Design/Index.vue +++ b/src/views/Design/Index.vue @@ -52,8 +52,8 @@