feat(api): 新增问卷设计相关接口并优化问卷创建流程

- 新增问卷设计相关接口: snQuestions, saveQuestion, sync, questionDetails
- 实现问卷创建功能,包括生成问卷模板和保存问卷标题、介绍等信息
-优化内容可编辑组件,增加失焦时保存内容的功能
- 更新环境变量和代理配置,以适应新的后端接口地址
This commit is contained in:
陈昱达
2025-03-11 16:21:47 +08:00
parent fe56872f72
commit 2c6f86bfc6
12 changed files with 222 additions and 264 deletions

View File

@@ -23,7 +23,7 @@ const props = defineProps({
const editor = ref(null);
const editorAction = ref(null);
const emit = defineEmits(['update:modelValue']);
const emit = defineEmits(['update:modelValue', 'blur']);
const save = (e) => {
emit('update:modelValue', e.innerHTML);
};
@@ -42,6 +42,9 @@ const functions = {
};
const funEvent = (item) => {
// 保持焦点在编辑器
const selection = window.getSelection();
selection.getRangeAt(0);
functions[item.fun]();
};
@@ -81,16 +84,40 @@ const actions = [
fun: 'italic'
}
];
const checkContains = (element, target) => {
try {
return element?.contains(target) ?? false;
} catch (e) {
console.error('Contains check failed:', e);
return false;
}
};
onMounted(() => {
editor.value.addEventListener('focus', () => {
showAction.value = true;
});
editor.value.addEventListener('blur', () => {
setTimeout(() => {
// 如果点击了 editor 与 editorAction 其他地方就触发保存
document.addEventListener('click', (e) => {
if (!editor.value || !editorAction.value) return;
const target = e.composedPath?.()?.[0] || e.target;
const isEditor = checkContains(editor.value, target);
const isActionBar = checkContains(editorAction.value, target);
if (!isEditor && !isActionBar) {
showAction.value = false;
});
save(editor.value);
emit('blur', editor.value);
}
});
// editor.value.addEventListener('blur', () => {
// setTimeout(() => {
// showAction.value = false;
// });
// });
document.addEventListener('resize', () => {
showAction.value = false;
});