Skip to content

Commit

Permalink
fix: 选中时不显示辅助功能(防止hover上一个时重叠)以及修复添加题目插入位置计算问题
Browse files Browse the repository at this point in the history
  • Loading branch information
skique committed Dec 9, 2024
1 parent 11d9c8c commit 8f11424
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ const itemClass = computed(() => {
}
})
const showHover = computed(() => {
return isHover.value || props.isSelected
return isHover.value
})
const showUp = computed(() => {
return !props.isFirst
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
:list="item.questionList"
:group="{ name: DND_GROUP, pull: 'clone', put: false }"
:clone="createNewQuestion"
@end="onDragEnd"
item-key="path"
>
<template #item="{ element }">
Expand Down Expand Up @@ -53,9 +52,8 @@ import { useEditStore } from '@/management/stores/edit'
import { ref } from 'vue'
const editStore = useEditStore()
const { newQuestionIndex, schema } = storeToRefs(editStore)
const { addQuestion, setCurrentEditOne, getSorter, createNewQuestion } = editStore
const { newQuestionIndex } = storeToRefs(editStore)
const { addQuestion, setCurrentEditOne, createNewQuestion } = editStore
const activeNames = ref([0, 1, 2])
const previewImg = ref('')
Expand All @@ -67,18 +65,10 @@ questionLoader.init({
})
const onQuestionType = ({ type }) => {
const newQuestion = createNewQuestion({ type });
addQuestion({ question: newQuestion, index: newQuestionIndex.value });
const { endIndex } = getSorter();
setTimeout(() => {
setCurrentEditOne(endIndex - 1);
});
};
const onDragEnd = (event) => {
const { startIndex } = getSorter();
setCurrentEditOne(schema.pageEditOne === 1 ? event.newIndex : startIndex + event.newIndex);
};
const newQuestion = createNewQuestion({ type })
addQuestion({ question: newQuestion, index: newQuestionIndex.value })
setCurrentEditOne(newQuestionIndex.value)
}
const showPreview = ({ snapshot }, id) => {
previewImg.value = snapshot
Expand Down
9 changes: 1 addition & 8 deletions web/src/management/stores/edit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,16 +166,10 @@ export const useEditStore = defineStore('edit', () => {
if (!questCount) {
return startIndex
}
return endIndex - 1
return endIndex
}
})

const hasSetCurrentEditOne = (value: number) => {
if(!currentEditOne.value) {
setCurrentEditOne(value)
}
}

// 题目操作:增删改
const { copyQuestion, addQuestion, deleteQuestion, moveQuestion } = useQuestionData({
questionDataList,
Expand All @@ -200,7 +194,6 @@ export const useEditStore = defineStore('edit', () => {
currentEditMeta,
newQuestionIndex,
setCurrentEditOne,
hasSetCurrentEditOne,
changeCurrentEditStatus,

pageEditOne,
Expand Down

0 comments on commit 8f11424

Please sign in to comment.