刘光辉
6 小时以前 cf11e63b659afcc9792ab3e395f1b45d844431a8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
<script lang="ts" setup>
import type { DmsCompareSession } from '#/api/x/dms/compare';
 
import { BasicModal } from '@jnpf/ui/modal';
 
import { CloseOutlined } from '@ant-design/icons-vue';
import { Tag, Tooltip } from 'ant-design-vue';
 
import OnlyOfficeCompareEditor from './OnlyOfficeCompareEditor.vue';
 
defineProps<{ session?: DmsCompareSession }>();
const emit = defineEmits<{ close: [] }>();
 
async function handleClose() {
  emit('close');
  return true;
}
</script>
 
<template>
  <BasicModal
    :open="!!session"
    :close-func="handleClose"
    :closable="false"
    :default-fullscreen="true"
    :can-fullscreen="false"
    :footer="null"
    :keyboard="true"
    :mask-closable="false"
    class="dms-file-compare-modal"
    destroy-on-close>
    <template #title>
      <div class="dms-file-compare-modal__header">
        <div class="header-main">
          <span class="header-title">{{ session?.title || '版本比较' }}</span>
          <Tag color="var(--primary-color)" class="header-readonly-tag">版本比较</Tag>
        </div>
        <Tooltip title="关闭" placement="bottom">
          <a-button aria-label="关闭" class="header-close-button" type="text" @click="handleClose">
            <CloseOutlined />
          </a-button>
        </Tooltip>
      </div>
    </template>
    <div class="dms-file-compare-modal__content">
      <OnlyOfficeCompareEditor v-if="session" :key="session.config.document.key" :session="session" @close="handleClose" />
    </div>
  </BasicModal>
</template>
 
<style lang="scss" scoped>
.dms-file-compare-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
 
  .header-main {
    display: flex;
    gap: 8px;
    align-items: center;
    min-width: 0;
  }
 
  .header-title {
    min-width: 0;
    overflow: hidden;
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
 
  .header-readonly-tag {
    flex-shrink: 0;
    margin-inline-end: 0;
  }
 
  .header-close-button {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    padding: 0;
  }
}
 
.dms-file-compare-modal__content {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  background: #fff;
}
</style>
 
<style lang="scss">
/* 非 scoped:BasicModal 的 DOM 是 teleport 到 body 的,scoped 的作用域属性够不着,
   按透传下去的 class 收敛即可(同 Preview.vue 的做法)。
   编辑器要占满整个弹窗,所以把 ScrollContainer 那层的内边距与留白全部清掉——
   来源是 @jnpf/ui 的 .ant-modal-body > .scrollbar { padding: 20px 10px }
   与 ScrollContainer 自带的 .scrollbar__wrap { margin-bottom: 18px } */
.dms-file-compare-modal {
  .ant-modal-header {
    height: 48px;
    padding: 8px 16px;
    background-color: var(--component-background);
    border-bottom: 1px solid var(--border-color-base1);
  }
 
  .ant-modal-body {
    padding: 0 !important;
 
    > .scroll-container {
      padding: 0 !important;
 
      > .scrollbar__wrap {
        margin-bottom: 0 !important;
 
        > .scrollbar__view {
          height: 100%;
          overflow: hidden;
 
          /* ModalWrapper#setModalHeight 会给这层算一个 inline height
             (全屏时 = innerHeight − modalFooterHeight − modalHeaderHeight − 28,
             后两个是 57 与经验值),和真实可用高度差出几十像素,表现为弹窗底部一条空白。
             编辑器要的是"填满剩余空间"而不是一个算出来的固定值,故用 !important 盖掉
             inline 样式,交给 .fullscreen-modal 既有的 flex 布局去撑。 */
          > div {
            height: 100% !important;
            max-height: none !important;
          }
        }
      }
    }
  }
}
</style>