Skip to content

Commit

Permalink
Merge pull request #1915 from DevCloudFE/dev
Browse files Browse the repository at this point in the history
chore: update main
  • Loading branch information
GreatZPP authored Nov 24, 2024
2 parents 3160137 + 315bce7 commit 2d90a56
Show file tree
Hide file tree
Showing 7 changed files with 306 additions and 121 deletions.
18 changes: 18 additions & 0 deletions packages/devui-vue/devui/code-review/src/code-review.scss
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,10 @@
content: '';
}

.d2h-code-linenumber {
border-right: 2px solid transparent;
}

.d2h-code-line-ctn {
word-break: break-all;
word-wrap: break-word !important;
Expand Down Expand Up @@ -222,6 +226,11 @@
position: static;
display: table-cell;
}

.d-code-left:nth-of-type(2) > .d2h-code-side-line,
.d-code-right:nth-of-type(4) > .d2h-code-side-line {
border-left: 2px solid transparent;
}
}

.d2h-file-diff {
Expand Down Expand Up @@ -269,6 +278,15 @@
background-color: #daf4ae; // 增加行中的number
}
}

&.d2h-code-linenumber {
border-right: 2px solid #fe7300;
}

&.d-code-left:nth-of-type(2) > .d2h-code-side-line,
&.d-code-right:nth-of-type(4) > .d2h-code-side-line {
border-left: 2px solid #fe7300;
}
}
}

Expand Down
42 changes: 27 additions & 15 deletions packages/devui-vue/devui/code-review/src/code-review.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* @jsxImportSource vue */
import { defineComponent, onMounted, provide, toRefs, onBeforeUnmount } from 'vue';
import { defineComponent, onMounted, provide, toRefs } from 'vue';
import type { SetupContext } from 'vue';
import CodeReviewHeader from './components/code-review-header';
import { CommentIcon } from './components/code-review-icons';
Expand All @@ -14,27 +14,40 @@ import './code-review.scss';
export default defineComponent({
name: 'DCodeReview',
props: codeReviewProps,
emits: ['foldChange', 'addComment', 'afterViewInit', 'contentRefresh'],
emits: ['foldChange', 'addComment', 'afterViewInit', 'contentRefresh', 'afterCheckLines'],
setup(props: CodeReviewProps, ctx: SetupContext) {
const ns = useNamespace('code-review');
const { diffType } = toRefs(props);
const { renderHtml, reviewContentRef, diffFile, onContentClick } = useCodeReview(props, ctx);
const { isFold, toggleFold } = useCodeReviewFold(props, ctx);
const { commentLeft, commentTop,
mouseEvent, onCommentMouseLeave,
onCommentIconClick, onCommentKeyDown,
unCommentKeyDown, insertComment,
removeComment, updateCheckedLineClass, clearCheckedLines } = useCodeReviewComment(reviewContentRef, props, ctx);
const {
commentLeft,
commentTop,
mouseEvent,
onCommentMouseLeave,
onCommentIconClick,
insertComment,
removeComment,
updateCheckedLineClass,
clearCheckedLines,
} = useCodeReviewComment(reviewContentRef, props, ctx);

onMounted(() => {
ctx.emit('afterViewInit', { toggleFold, insertComment, removeComment, updateCheckedLineClass, clearCheckedLines });
onCommentKeyDown();
ctx.emit('afterViewInit', {
toggleFold,
insertComment,
removeComment,
updateCheckedLineClass,
clearCheckedLines,
});
});
// 销毁
onBeforeUnmount(() => {
unCommentKeyDown();
provide(CodeReviewInjectionKey, {
diffType,
reviewContentRef,
diffInfo: diffFile.value[0],
isFold,
rootCtx: ctx,
});
provide(CodeReviewInjectionKey, { diffType, reviewContentRef, diffInfo: diffFile.value[0], isFold, rootCtx: ctx });

return () => (
<div class={ns.b()}>
Expand All @@ -59,8 +72,7 @@ export default defineComponent({
class="comment-icon"
style={{ left: commentLeft.value + 'px', top: commentTop.value + 'px' }}
onClick={onCommentIconClick}
onMouseleave={onCommentMouseLeave}
>
onMouseleave={onCommentMouseLeave}>
<CommentIcon />
</div>
)}
Expand Down
Loading

0 comments on commit 2d90a56

Please sign in to comment.