diff --git a/packages/devui-vue/devui/code-review/src/composables/use-code-review-comment.ts b/packages/devui-vue/devui/code-review/src/composables/use-code-review-comment.ts index f9ceeb0d5e..6a86b07983 100644 --- a/packages/devui-vue/devui/code-review/src/composables/use-code-review-comment.ts +++ b/packages/devui-vue/devui/code-review/src/composables/use-code-review-comment.ts @@ -118,7 +118,7 @@ export function useCodeReviewComment(reviewContentRef: Ref, props: } }; // 获代码行 取值方法 - const getLineNumbers = (currentNumber: number, currentNumbers: Array) => { + const getLineNumbers = (currentNumber: number, currentNumbers: Array, moveDirection: 'up' | 'down') => { if (currentNumber === -1) { // 当前行没数据不代表之前选中的没数据,此时返回原来的 return currentNumbers; @@ -129,12 +129,12 @@ export function useCodeReviewComment(reviewContentRef: Ref, props: const numbers = [...currentNumbers]; let max = Math.max(...numbers); let min = Math.min(...numbers); - if (currentNumber < min) { - min = currentNumber; - } - if (currentNumber > max) { + if (moveDirection === 'down') { max = currentNumber; } + if (moveDirection === 'up') { + min = currentNumber; + } return Array.from({ length: max - min + 1 }, (_, i) => i + min); }; // 获取一些公共类和判断 @@ -211,11 +211,13 @@ export function useCodeReviewComment(reviewContentRef: Ref, props: } getDoubleCheckedLineCode(shouldRenderClass); } - function updateLineNumbers() { + function updateLineNumbers(moveDirection: 'up' | 'down') { currentLeftLineNumbers = - currentLeftLineNumber === -1 ? currentLeftLineNumbers : getLineNumbers(currentLeftLineNumber, currentLeftLineNumbers); + currentLeftLineNumber === -1 ? currentLeftLineNumbers : getLineNumbers(currentLeftLineNumber, currentLeftLineNumbers, moveDirection); currentRightLineNumbers = - currentRightLineNumber === -1 ? currentRightLineNumbers : getLineNumbers(currentRightLineNumber, currentRightLineNumbers); + currentRightLineNumber === -1 + ? currentRightLineNumbers + : getLineNumbers(currentRightLineNumber, currentRightLineNumbers, moveDirection); getCheckedLineCode(false); afterCheckLinesEmitData = { left: currentLeftLineNumber, diff --git a/packages/devui-vue/devui/code-review/src/composables/use-code-review-line-selection.ts b/packages/devui-vue/devui/code-review/src/composables/use-code-review-line-selection.ts index 6d0592bb25..38edc38257 100644 --- a/packages/devui-vue/devui/code-review/src/composables/use-code-review-line-selection.ts +++ b/packages/devui-vue/devui/code-review/src/composables/use-code-review-line-selection.ts @@ -6,7 +6,7 @@ import { findParentTrNode } from '../utils'; export function useCodeReviewLineSelection( reviewContentRef: Ref, props: CodeReviewProps, - mouseMoveCb: () => void, + mouseMoveCb: (moveDirection: 'up' | 'down') => void, mouseupCb: () => void ) { const ns = useNamespace('code-review'); @@ -16,6 +16,7 @@ export function useCodeReviewLineSelection( let isClickedLeft: boolean | undefined; let shouldClear: boolean; let isMouseMoved: boolean; + let startClientY: number; const onMousedown = (e: MouseEvent) => { // 鼠标左键按下 @@ -44,6 +45,7 @@ export function useCodeReviewLineSelection( dragging = true; shouldClear = true; isMouseMoved = false; + startClientY = e.clientY; e.preventDefault(); e.stopPropagation(); document.addEventListener('mousemove', onMousemove); @@ -74,7 +76,7 @@ export function useCodeReviewLineSelection( if (endIndex === -1) { return; } - mouseMoveCb(); + mouseMoveCb(e.clientY > startClientY ? 'down' : 'up'); if (startIndex > endIndex) { [startIndex, endIndex] = [endIndex, startIndex]; } diff --git a/packages/devui-vue/package.json b/packages/devui-vue/package.json index fa6b791d3a..1d38592356 100644 --- a/packages/devui-vue/package.json +++ b/packages/devui-vue/package.json @@ -1,6 +1,6 @@ { "name": "vue-devui", - "version": "1.6.24", + "version": "1.6.25", "license": "MIT", "description": "DevUI components based on Vite and Vue3", "keywords": [