From 26bf11018b2b145942631421c7e634c5df91aea6 Mon Sep 17 00:00:00 2001 From: zhaowei <zhaowei> Date: 星期二, 21 一月 2025 15:33:53 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/master' --- src/views/dnc/base/modules/ProductStructure/Document/FileCompareModal.vue | 77 ++++++++++++++++++++++++++++++++++++++ 1 files changed, 77 insertions(+), 0 deletions(-) diff --git a/src/views/dnc/base/modules/ProductStructure/Document/FileCompareModal.vue b/src/views/dnc/base/modules/ProductStructure/Document/FileCompareModal.vue new file mode 100644 index 0000000..4cb7928 --- /dev/null +++ b/src/views/dnc/base/modules/ProductStructure/Document/FileCompareModal.vue @@ -0,0 +1,77 @@ +<template> + <a-modal width="100%" :visible="visible" :title="title" @cancel="visible=false" :footer="null" :maskClosable="false"> + <a-row> + <a-col :span="12"><span class="file-version-text">鐗堟湰鍙凤細{{fileVersionArray[0]}}</span></a-col> + <a-col :span="12"><span class="file-version-text">鐗堟湰鍙凤細{{fileVersionArray[1]}}</span></a-col> + </a-row> + <div class="code-diff-container"> + <CodeDiff :old-string="oldVersionContent" :new-string="newVersionContent" outputFormat="side-by-side"/> + </div> + </a-modal> +</template> + +<script> + import CodeDiff from 'vue-code-diff' + + export default { + name: 'FileCompareModal', + components: { CodeDiff }, + props: { + fileDiffObject: { + type: Object + }, + fileVersionArray: { + type: Array + } + }, + watch: { + visible: { + handler(value) { + if (value) { + const { fileDiffObject } = this + let fileContent = '' + for (let key in fileDiffObject) { + if (fileDiffObject.hasOwnProperty(key)) { + fileDiffObject[key].forEach((content, index) => { + fileContent += content + if (index !== fileDiffObject[key].length - 1) { + fileContent += '\n' + } + }) + if (key === 'first') { + this.oldVersionContent = fileContent + fileContent = '' + } + else this.newVersionContent = fileContent + } + } + } + else this.newVersionContent = this.oldVersionContent = '' + } + } + }, + data() { + return { + visible: false, + title: '', + oldVersionContent: '', + newVersionContent: '' + } + }, + methods: {} + } +</script> + +<style scoped> + .file-version-text { + font-weight: bold; + font-size: 16px; + margin-left: 5%; + } + + .code-diff-container { + height: 500px; + overflow: auto; + margin-top: 20px + } +</style> \ No newline at end of file -- Gitblit v1.9.3