refactor(src): 优化代码格式和功能
- 调整了部分组件中的代码格式,提高了可读性 - 优化了图像上传功能,增加了对高度的处理逻辑 - 移除了不必要的注释代码 - 统一了异步函数的定义方式
This commit is contained in:
@@ -107,7 +107,14 @@ const functions = {
|
|||||||
// max-width:${maxWidth}px;
|
// max-width:${maxWidth}px;
|
||||||
// max-height:${maxHeight}px"`;
|
// max-height:${maxHeight}px"`;
|
||||||
// 使用原始高度
|
// 使用原始高度
|
||||||
const height = img.naturalHeight;
|
const minimum = 50;
|
||||||
|
let height = img.naturalHeight;
|
||||||
|
const scale = img.naturalHeight / 50;
|
||||||
|
if (height > minimum * 3) {
|
||||||
|
height = height / scale;
|
||||||
|
} else {
|
||||||
|
height = minimum;
|
||||||
|
}
|
||||||
// 根据宽高比计算宽度
|
// 根据宽高比计算宽度
|
||||||
const width = (height * 3) / 4;
|
const width = (height * 3) / 4;
|
||||||
const maxWidth = img.naturalWidth;
|
const maxWidth = img.naturalWidth;
|
||||||
|
|||||||
@@ -313,7 +313,7 @@ const actionEvent = (item, el) => {
|
|||||||
};
|
};
|
||||||
// 总事件注册
|
// 总事件注册
|
||||||
const actionFun = {
|
const actionFun = {
|
||||||
// 单选事件 添加选项
|
// 单选事件 添加选项 无限制添加
|
||||||
radioAddOption: (element) => {
|
radioAddOption: (element) => {
|
||||||
element.options.map((item) => {
|
element.options.map((item) => {
|
||||||
item.push({
|
item.push({
|
||||||
|
|||||||
@@ -82,22 +82,22 @@
|
|||||||
</van-field>
|
</van-field>
|
||||||
|
|
||||||
<van-divider></van-divider>
|
<van-divider></van-divider>
|
||||||
<van-field label="文件格式" :border="false" label-align="top">
|
<!-- <van-field label="文件格式" :border="false" label-align="top">-->
|
||||||
<template #input>
|
<!-- <template #input>-->
|
||||||
<div style="width: 100%">
|
<!-- <div style="width: 100%">-->
|
||||||
<YLCascader
|
<!-- <YLCascader-->
|
||||||
v-if="fileTypeList.length > 0"
|
<!-- v-if="fileTypeList.length > 0"-->
|
||||||
v-model="fileType"
|
<!-- v-model="fileType"-->
|
||||||
:options="fileTypeList"
|
<!-- :options="fileTypeList"-->
|
||||||
@update:model-value="changeFileType"
|
<!-- @update:model-value="changeFileType"-->
|
||||||
></YLCascader>
|
<!-- ></YLCascader>-->
|
||||||
</div>
|
<!-- </div>-->
|
||||||
</template>
|
<!-- </template>-->
|
||||||
</van-field>
|
<!-- </van-field>-->
|
||||||
</template>
|
</template>
|
||||||
<script setup>
|
<script setup>
|
||||||
import { computed, defineEmits, onMounted, ref } from 'vue';
|
import { computed, defineEmits, onMounted, ref } from 'vue';
|
||||||
import YLCascader from '@/components/YLCascader.vue';
|
// import YLCascader from '@/components/YLCascader.vue';
|
||||||
|
|
||||||
import { getFileType } from './Api/Index.js';
|
import { getFileType } from './Api/Index.js';
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
@@ -151,23 +151,23 @@ const getFileTypeList = () => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const changeFileType = (value) => {
|
// const changeFileType = (value) => {
|
||||||
if (value === [['0']]) {
|
// if (value === [['0']]) {
|
||||||
actionQuestion.value.config.file_type = '0';
|
// actionQuestion.value.config.file_type = '0';
|
||||||
emit('saveOption');
|
// emit('saveOption');
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
const ls = [];
|
// const ls = [];
|
||||||
value.map((item) => {
|
// value.map((item) => {
|
||||||
const obj = [];
|
// const obj = [];
|
||||||
item.map((s) => {
|
// item.map((s) => {
|
||||||
obj.push(s);
|
// obj.push(s);
|
||||||
});
|
// });
|
||||||
ls.push(obj.join('-'));
|
// ls.push(obj.join('-'));
|
||||||
});
|
// });
|
||||||
actionQuestion.value.config.file_type = ls.join(',');
|
// actionQuestion.value.config.file_type = ls.join(',');
|
||||||
emit('saveOption');
|
// emit('saveOption');
|
||||||
};
|
// };
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
getFileTypeList();
|
getFileTypeList();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -84,6 +84,9 @@ const element = defineModel('element', {
|
|||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
// if (props.index + 1 !== Number(element.value.title)) {
|
||||||
|
// element.value.title = props.index + 1;
|
||||||
|
// }
|
||||||
|
|
||||||
// 选中题目后出现的操作
|
// 选中题目后出现的操作
|
||||||
const emit = defineEmits(['getChooseQuestionId', 'move', 'copy', 'setting', 'logics']);
|
const emit = defineEmits(['getChooseQuestionId', 'move', 'copy', 'setting', 'logics']);
|
||||||
|
|||||||
Reference in New Issue
Block a user