@jx3box/jx3box-ui 2.4.12 → 2.4.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/css/single/thx.less +103 -94
- package/assets/css/wiki/wiki-panel.less +9 -0
- package/assets/css/wiki/wiki-revisions.less +40 -21
- package/i18n/messages/en-US.js +1 -0
- package/i18n/messages/vi.js +1 -0
- package/i18n/messages/zh-CN.js +1 -0
- package/i18n/messages/zh-TW.js +1 -0
- package/index.js +2 -0
- package/package.json +1 -1
- package/src/interact/BoxcoinRecords.vue +16 -20
- package/src/single/VersionDialog.vue +12 -5
- package/src/wiki/ResponsiveCodeDiff.vue +93 -0
- package/src/wiki/WikiRevisions.vue +6 -4
- package/tests/wiki-mobile-layout.test.js +61 -0
|
@@ -125,131 +125,140 @@
|
|
|
125
125
|
}
|
|
126
126
|
}
|
|
127
127
|
|
|
128
|
+
// 打赏记录:宽屏对齐列,窄容器保留寄语与时间。
|
|
129
|
+
.w-boxcoin-records {
|
|
130
|
+
container-type: inline-size;
|
|
131
|
+
}
|
|
128
132
|
.w-boxcoin-records-list {
|
|
129
133
|
max-width: 960px;
|
|
130
|
-
border: 1px solid #eee;
|
|
131
134
|
margin: 0 auto;
|
|
132
|
-
border-radius: 6px;
|
|
133
135
|
overflow: hidden;
|
|
136
|
+
border: 1px solid #e9ebf0;
|
|
137
|
+
border-radius: 8px;
|
|
138
|
+
background: #fff;
|
|
134
139
|
|
|
135
140
|
.u-list {
|
|
136
|
-
|
|
137
|
-
.x(left);
|
|
138
|
-
margin: 0 auto;
|
|
141
|
+
margin: 0;
|
|
139
142
|
padding: 0;
|
|
143
|
+
list-style: none;
|
|
144
|
+
text-align: left;
|
|
140
145
|
}
|
|
141
146
|
.u-item {
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
a {
|
|
153
|
-
color: var(--el-color-primary);
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
.u-meta {
|
|
157
|
-
.db;
|
|
158
|
-
.fl;
|
|
147
|
+
display: grid;
|
|
148
|
+
grid-template-columns: 22px minmax(0, 1fr) minmax(0, 1fr) 84px minmax(0, 1.4fr) 142px;
|
|
149
|
+
align-items: center;
|
|
150
|
+
gap: 12px;
|
|
151
|
+
padding: 10px 16px;
|
|
152
|
+
border-bottom: 1px solid #f0f1f5;
|
|
153
|
+
font-size: 13px;
|
|
154
|
+
line-height: 1.6;
|
|
155
|
+
&:last-child { border-bottom: 0; }
|
|
159
156
|
}
|
|
157
|
+
.u-meta { min-width: 0; }
|
|
160
158
|
.u-action {
|
|
161
|
-
|
|
162
|
-
.db;
|
|
163
|
-
padding-right: 10px;
|
|
164
|
-
.flex;
|
|
159
|
+
display: flex;
|
|
165
160
|
align-items: center;
|
|
166
161
|
justify-content: center;
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
.auto(x);
|
|
171
|
-
}
|
|
172
|
-
.x;
|
|
162
|
+
i { display: flex; }
|
|
163
|
+
svg, img { display: block; width: 20px; height: 20px; }
|
|
164
|
+
.el-icon svg { width: 16px; height: 16px; }
|
|
173
165
|
}
|
|
174
166
|
.u-user {
|
|
175
|
-
|
|
176
|
-
.nobreak;
|
|
177
|
-
.flex;
|
|
167
|
+
display: flex;
|
|
178
168
|
align-items: center;
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
&.u-default {
|
|
185
|
-
color: @color;
|
|
186
|
-
&:hover {
|
|
187
|
-
text-decoration: none;
|
|
188
|
-
}
|
|
189
|
-
}
|
|
169
|
+
gap: 6px;
|
|
170
|
+
color: #475569;
|
|
171
|
+
text-decoration: none;
|
|
172
|
+
span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
173
|
+
&[href]:hover { color: var(--el-color-primary); }
|
|
190
174
|
.u-user-avatar {
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
175
|
+
flex: 0 0 24px;
|
|
176
|
+
width: 24px;
|
|
177
|
+
height: 24px;
|
|
178
|
+
border-radius: 50%;
|
|
179
|
+
object-fit: cover;
|
|
180
|
+
background: #f5f6f8;
|
|
195
181
|
}
|
|
196
182
|
}
|
|
197
|
-
.u-count {
|
|
198
|
-
.w(120px);
|
|
199
|
-
}
|
|
200
183
|
.u-head {
|
|
201
|
-
|
|
202
|
-
|
|
184
|
+
padding-top: 8px;
|
|
185
|
+
padding-bottom: 8px;
|
|
186
|
+
background: #f8f9fb;
|
|
187
|
+
color: #7b8798;
|
|
188
|
+
font-size: 12px;
|
|
189
|
+
font-weight: 500;
|
|
190
|
+
.u-user { color: inherit; }
|
|
203
191
|
}
|
|
204
192
|
.u-body {
|
|
193
|
+
&:hover { background: #fdfbfc; }
|
|
205
194
|
.u-count {
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
color:
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
.nobreak;
|
|
214
|
-
.w(280px);
|
|
215
|
-
color: @color;
|
|
216
|
-
}
|
|
217
|
-
.u-delete {
|
|
218
|
-
.ml(20px);
|
|
219
|
-
color: #c00;
|
|
220
|
-
i {
|
|
221
|
-
.mr(3px);
|
|
222
|
-
}
|
|
223
|
-
.pointer;
|
|
224
|
-
&:hover {
|
|
225
|
-
color: #f00;
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
.u-client {
|
|
229
|
-
color: @v4focus;
|
|
195
|
+
justify-self: start;
|
|
196
|
+
padding: 2px 8px;
|
|
197
|
+
border-radius: 4px;
|
|
198
|
+
background: #fff0f5;
|
|
199
|
+
color: #db5181;
|
|
200
|
+
font-variant-numeric: tabular-nums;
|
|
201
|
+
white-space: nowrap;
|
|
230
202
|
}
|
|
203
|
+
.u-remark { color: #596273; overflow-wrap: anywhere; white-space: pre-wrap; }
|
|
204
|
+
.u-time { color: #8b95a5; font-size: 12px; font-variant-numeric: tabular-nums; white-space: nowrap; }
|
|
205
|
+
}
|
|
206
|
+
.u-operations {
|
|
207
|
+
display: flex;
|
|
208
|
+
align-items: center;
|
|
209
|
+
justify-content: flex-end;
|
|
210
|
+
flex-wrap: wrap;
|
|
211
|
+
gap: 6px;
|
|
212
|
+
min-width: 0;
|
|
231
213
|
}
|
|
214
|
+
.u-client { color: #929aaa; font-size: 11px; overflow-wrap: anywhere; }
|
|
215
|
+
.u-delete {
|
|
216
|
+
padding: 3px 6px;
|
|
217
|
+
border: 0;
|
|
218
|
+
border-radius: 4px;
|
|
219
|
+
background: transparent;
|
|
220
|
+
color: #b76b73;
|
|
221
|
+
font: inherit;
|
|
222
|
+
font-size: 12px;
|
|
223
|
+
white-space: nowrap;
|
|
224
|
+
cursor: pointer;
|
|
225
|
+
&:hover { background: #fff0f0; color: #d94757; }
|
|
226
|
+
}
|
|
227
|
+
a:focus-visible, button:focus-visible { outline: 2px solid var(--el-color-primary); outline-offset: 2px; }
|
|
228
|
+
}
|
|
229
|
+
.w-boxcoin-records.is-admin .u-item {
|
|
230
|
+
grid-template-columns: 22px minmax(0, 1fr) minmax(0, 1fr) 76px minmax(0, 1.2fr) 142px 90px;
|
|
231
|
+
column-gap: 10px;
|
|
232
232
|
}
|
|
233
233
|
.w-boxcoin-records-pages {
|
|
234
|
+
display: flex;
|
|
234
235
|
justify-content: center;
|
|
235
|
-
|
|
236
|
+
margin-top: 12px;
|
|
236
237
|
}
|
|
237
|
-
|
|
238
|
-
@media screen and (max-width: @phone) {
|
|
238
|
+
.boxcoin-records-compact() {
|
|
239
239
|
.w-boxcoin-records-list {
|
|
240
|
-
|
|
241
|
-
.u-
|
|
242
|
-
|
|
240
|
+
.u-head { display: none; }
|
|
241
|
+
.u-item.u-body {
|
|
242
|
+
grid-template-columns: 20px minmax(0, 1fr) auto;
|
|
243
|
+
gap: 8px;
|
|
244
|
+
padding: 12px;
|
|
243
245
|
}
|
|
244
|
-
.u-
|
|
245
|
-
|
|
246
|
-
}
|
|
247
|
-
.u-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
.u-remark {
|
|
252
|
-
.none;
|
|
246
|
+
.u-action { grid-column: 1; grid-row: 1; }
|
|
247
|
+
.u-participant { grid-column: 2; grid-row: 1; }
|
|
248
|
+
.u-count { grid-column: 3; grid-row: 1; }
|
|
249
|
+
.u-author {
|
|
250
|
+
grid-column: 2 / -1;
|
|
251
|
+
&::before { content: attr(data-label); flex-shrink: 0; color: #8b95a5; font-size: 12px; }
|
|
252
|
+
.u-user-avatar { flex-basis: 22px; width: 22px; height: 22px; }
|
|
253
253
|
}
|
|
254
|
+
.u-remark { grid-column: 2 / -1; }
|
|
255
|
+
.u-time { grid-column: 2 / -1; }
|
|
256
|
+
.u-operations { grid-column: 2 / -1; justify-content: flex-start; }
|
|
254
257
|
}
|
|
255
258
|
}
|
|
259
|
+
@container (max-width: 800px) {
|
|
260
|
+
.boxcoin-records-compact();
|
|
261
|
+
}
|
|
262
|
+
@media screen and (max-width: @phone) {
|
|
263
|
+
.boxcoin-records-compact();
|
|
264
|
+
}
|
|
@@ -407,3 +407,12 @@
|
|
|
407
407
|
display: none;
|
|
408
408
|
}
|
|
409
409
|
}
|
|
410
|
+
|
|
411
|
+
@media screen and (max-width: 720px) {
|
|
412
|
+
.c-wiki-panel.is-surface > .m-panel-body > .m-wiki-metas {
|
|
413
|
+
.u-meta { max-width: 100%; flex-wrap: wrap; gap: 6px; }
|
|
414
|
+
.u-label { flex-shrink: 0; margin-right: 2px; white-space: nowrap; }
|
|
415
|
+
.u-creator { margin-right: 0; }
|
|
416
|
+
.u-value:not(.u-creator) { min-width: 0; overflow-wrap: anywhere; }
|
|
417
|
+
}
|
|
418
|
+
}
|
|
@@ -116,26 +116,45 @@
|
|
|
116
116
|
}
|
|
117
117
|
|
|
118
118
|
@media screen and (max-width: 720px) {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
119
|
+
.c-wiki-revisions.is-surface > .m-panel-body .m-revisions-panel {
|
|
120
|
+
min-width: 0;
|
|
121
|
+
max-width: 100%;
|
|
122
|
+
overflow-x: visible;
|
|
123
|
+
box-shadow: none;
|
|
124
|
+
.m-histories {
|
|
125
|
+
display: block;
|
|
126
|
+
width: 100%;
|
|
127
|
+
min-width: 0;
|
|
128
|
+
max-width: 100%;
|
|
129
|
+
margin: 0;
|
|
130
|
+
box-sizing: border-box;
|
|
131
|
+
thead { display: none; }
|
|
132
|
+
tbody { display: grid; gap: 10px; }
|
|
133
|
+
tbody, tr { min-width: 0; max-width: 100%; }
|
|
134
|
+
tr {
|
|
135
|
+
display: grid;
|
|
136
|
+
grid-template-columns: minmax(64px, 0.7fr) minmax(0, 1.3fr);
|
|
137
|
+
border: 1px solid #e4e7ed;
|
|
138
|
+
border-radius: 6px;
|
|
139
|
+
background: #fff;
|
|
140
|
+
overflow: hidden;
|
|
141
|
+
}
|
|
142
|
+
td, td:first-child {
|
|
143
|
+
display: flex;
|
|
144
|
+
flex-direction: column;
|
|
145
|
+
gap: 2px;
|
|
146
|
+
width: auto;
|
|
147
|
+
min-width: 0;
|
|
148
|
+
padding: 8px;
|
|
149
|
+
border: 0;
|
|
150
|
+
font-size: 12px;
|
|
151
|
+
white-space: normal;
|
|
152
|
+
overflow: visible;
|
|
153
|
+
overflow-wrap: anywhere;
|
|
154
|
+
&::before { content: attr(data-label); color: #909399; font-size: 11px; line-height: 1.4; white-space: normal; }
|
|
155
|
+
> a { white-space: normal; overflow: visible; overflow-wrap: anywhere; }
|
|
156
|
+
}
|
|
157
|
+
td:nth-child(3), td:nth-child(4) { grid-column: 1 / -1; border-top: 1px solid #ebeef5; }
|
|
158
|
+
}
|
|
139
159
|
}
|
|
140
|
-
}
|
|
141
160
|
}
|
package/i18n/messages/en-US.js
CHANGED
package/i18n/messages/vi.js
CHANGED
package/i18n/messages/zh-CN.js
CHANGED
package/i18n/messages/zh-TW.js
CHANGED
package/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<div class="w-boxcoin-records" v-loading="loading">
|
|
2
|
+
<div class="w-boxcoin-records" :class="{ 'is-admin': isSuperAdmin }" v-loading="loading">
|
|
3
3
|
<div class="w-boxcoin-records-list" v-if="list && list.length">
|
|
4
4
|
<ul class="u-list">
|
|
5
5
|
<li class="u-item u-head">
|
|
6
6
|
<span class="u-meta u-action">
|
|
7
7
|
<el-icon><Trophy /></el-icon>
|
|
8
8
|
</span>
|
|
9
|
-
<span class="u-meta u-user">{{ $jx3boxT("jx3boxUi.boxcoinRecords.participant", "参与打赏") }}</span>
|
|
10
|
-
<span class="u-meta u-user">{{ $jx3boxT("jx3boxUi.boxcoinRecords.author", "收益作者") }}</span>
|
|
9
|
+
<span class="u-meta u-user u-participant">{{ $jx3boxT("jx3boxUi.boxcoinRecords.participant", "参与打赏") }}</span>
|
|
10
|
+
<span class="u-meta u-user u-author">{{ $jx3boxT("jx3boxUi.boxcoinRecords.author", "收益作者") }}</span>
|
|
11
11
|
<span class="u-meta u-count">{{ $jx3boxT("jx3boxUi.boxcoinRecords.boxcoin", "盒币") }}</span>
|
|
12
12
|
<span class="u-meta u-remark">{{ $jx3boxT("jx3boxUi.boxcoinRecords.remark", "寄语") }}</span>
|
|
13
|
-
<
|
|
13
|
+
<span class="u-meta u-time">{{ $jx3boxT("jx3boxUi.boxcoinRecords.time", "时间") }}</span>
|
|
14
14
|
</li>
|
|
15
15
|
<li v-for="(item, i) in list" :key="i" class="u-item u-body">
|
|
16
16
|
<span class="u-meta u-action">
|
|
@@ -22,18 +22,18 @@
|
|
|
22
22
|
</template>
|
|
23
23
|
</span>
|
|
24
24
|
<template v-if="item.ext_operate_user_info?.id == 1">
|
|
25
|
-
<span class="u-meta u-user u-default">
|
|
25
|
+
<span class="u-meta u-user u-participant u-default">
|
|
26
26
|
<img class="u-user-avatar" :src="showAvatar(item.ext_operate_user_info.avatar)" alt />
|
|
27
27
|
<span>{{ $jx3boxT("jx3boxUi.boxcoinRecords.system", "系统") }}</span>
|
|
28
28
|
</span>
|
|
29
29
|
</template>
|
|
30
|
-
<a v-else class="u-meta u-user" :href="authorLink(item.operate_user_id)" target="_blank">
|
|
30
|
+
<a v-else class="u-meta u-user u-participant" :href="authorLink(item.operate_user_id)" target="_blank">
|
|
31
31
|
<img class="u-user-avatar" :src="showAvatar(item.ext_operate_user_info.avatar)" alt />
|
|
32
|
-
<span>{{ item.ext_operate_user_info.display_name }}</span>
|
|
32
|
+
<span :title="item.ext_operate_user_info.display_name">{{ item.ext_operate_user_info.display_name }}</span>
|
|
33
33
|
</a>
|
|
34
|
-
<a class="u-meta u-user" :href="authorLink(item.user_id)" target="_blank">
|
|
34
|
+
<a class="u-meta u-user u-author" :data-label="$jx3boxT('jx3boxUi.boxcoinRecords.author', '收益作者')" :href="authorLink(item.user_id)" target="_blank">
|
|
35
35
|
<img class="u-user-avatar" :src="showAvatar(item.ext_user_info.avatar)" alt />
|
|
36
|
-
<span>{{ item.ext_user_info.display_name }}</span>
|
|
36
|
+
<span :title="item.ext_user_info.display_name">{{ item.ext_user_info.display_name }}</span>
|
|
37
37
|
</a>
|
|
38
38
|
<span class="u-meta u-count">
|
|
39
39
|
+
|
|
@@ -41,9 +41,11 @@
|
|
|
41
41
|
</span>
|
|
42
42
|
<span class="u-meta u-remark">{{ item.remark }}</span>
|
|
43
43
|
<time class="u-meta u-time">{{ showTime(item.created_at) }}</time>
|
|
44
|
-
<span class="u-
|
|
45
|
-
<
|
|
46
|
-
|
|
44
|
+
<span class="u-operations" v-if="isSuperAdmin">
|
|
45
|
+
<button type="button" class="u-delete" @click="recovery(item, i)">
|
|
46
|
+
{{ $jx3boxT("jx3boxUi.boxcoinRecords.revoke", "撤销") }}
|
|
47
|
+
</button>
|
|
48
|
+
<span class="u-client" v-if="item.client">({{ item.client }})</span>
|
|
47
49
|
</span>
|
|
48
50
|
</li>
|
|
49
51
|
</ul>
|
|
@@ -190,14 +192,8 @@ export default {
|
|
|
190
192
|
};
|
|
191
193
|
</script>
|
|
192
194
|
|
|
193
|
-
|
|
194
195
|
<style lang="less">
|
|
195
|
-
|
|
196
|
-
.w-boxcoin-records-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
.flex(x);
|
|
201
|
-
margin-top:5px;
|
|
196
|
+
@media screen and (max-width: 720px) {
|
|
197
|
+
.w-boxcoin-records .u-delete { display: none; }
|
|
202
198
|
}
|
|
203
199
|
</style>
|
|
@@ -56,17 +56,16 @@
|
|
|
56
56
|
</div>
|
|
57
57
|
</div>
|
|
58
58
|
<div v-if="type === 'code'" class="m-content-container">
|
|
59
|
-
<
|
|
59
|
+
<ResponsiveCodeDiff
|
|
60
60
|
class="m-content-view"
|
|
61
61
|
:old-string="content1"
|
|
62
62
|
:new-string="content2"
|
|
63
63
|
:context="1024"
|
|
64
|
-
output-format="side-by-side"
|
|
65
64
|
maxHeight="520px"
|
|
66
65
|
:filename="`${content1Len}字`"
|
|
67
66
|
:newFilename="`${content2Len}字`"
|
|
68
67
|
ignoreMatchingLines="data:image/png;base64,"
|
|
69
|
-
></
|
|
68
|
+
></ResponsiveCodeDiff>
|
|
70
69
|
</div>
|
|
71
70
|
</div>
|
|
72
71
|
</el-dialog>
|
|
@@ -75,11 +74,11 @@
|
|
|
75
74
|
<script>
|
|
76
75
|
import { getCommitByHash } from "../../service/commit-history";
|
|
77
76
|
import Article from "@jx3box/jx3box-editor/src/Article.vue";
|
|
78
|
-
import
|
|
77
|
+
import ResponsiveCodeDiff from "../wiki/ResponsiveCodeDiff.vue";
|
|
79
78
|
export default {
|
|
80
79
|
name: "VersionDialog",
|
|
81
80
|
components: {
|
|
82
|
-
|
|
81
|
+
ResponsiveCodeDiff,
|
|
83
82
|
Article,
|
|
84
83
|
},
|
|
85
84
|
props: {
|
|
@@ -236,4 +235,12 @@ export default {
|
|
|
236
235
|
}
|
|
237
236
|
}
|
|
238
237
|
}
|
|
238
|
+
@media screen and (max-width: 720px) {
|
|
239
|
+
.m-version-contrast-dialog {
|
|
240
|
+
.m-toolbar { flex-direction: column; align-items: stretch; gap: 12px; }
|
|
241
|
+
.m-toolbar .m-select { flex-direction: column; gap: 10px; }
|
|
242
|
+
.m-content-container { flex-direction: column; max-height: none; overflow: visible; }
|
|
243
|
+
.m-content-container .u-content { min-width: 0; width: 100%; height: auto; }
|
|
244
|
+
}
|
|
245
|
+
}
|
|
239
246
|
</style>
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="w-responsive-code-diff">
|
|
3
|
+
<div v-if="isMobile" class="m-stacked-diff">
|
|
4
|
+
<section v-for="side in ['old', 'new']" :key="side" class="m-version-panel" :class="'is-' + side">
|
|
5
|
+
<h3>{{ side === 'old' ? filename : newFilename }}</h3>
|
|
6
|
+
<CodeDiff v-bind="$attrs" :old-string="oldString" :new-string="newString" :context="Number.MAX_SAFE_INTEGER" output-format="side-by-side" :hide-header="true" :max-height="mobileMaxHeight" />
|
|
7
|
+
</section>
|
|
8
|
+
</div>
|
|
9
|
+
<CodeDiff v-else v-bind="$attrs" :old-string="oldString" :new-string="newString" :filename="filename" :new-filename="newFilename" :context="context" output-format="side-by-side" :max-height="maxHeight" />
|
|
10
|
+
</div>
|
|
11
|
+
</template>
|
|
12
|
+
|
|
13
|
+
<script>
|
|
14
|
+
import { CodeDiff } from "v-code-diff";
|
|
15
|
+
|
|
16
|
+
export default {
|
|
17
|
+
name: "ResponsiveCodeDiff",
|
|
18
|
+
inheritAttrs: false,
|
|
19
|
+
components: { CodeDiff },
|
|
20
|
+
props: {
|
|
21
|
+
oldString: { type: String, default: "" },
|
|
22
|
+
newString: { type: String, default: "" },
|
|
23
|
+
filename: { type: String, default: "" },
|
|
24
|
+
newFilename: { type: String, default: "" },
|
|
25
|
+
context: { type: Number, default: 1024 },
|
|
26
|
+
maxHeight: { type: String, default: "600px" },
|
|
27
|
+
mobileMaxHeight: { type: String, default: "420px" },
|
|
28
|
+
},
|
|
29
|
+
data() {
|
|
30
|
+
return { isMobile: typeof window !== "undefined" && window.matchMedia("(max-width: 720px)").matches };
|
|
31
|
+
},
|
|
32
|
+
mounted() {
|
|
33
|
+
this.mobileQuery = window.matchMedia("(max-width: 720px)");
|
|
34
|
+
this.isMobile = this.mobileQuery.matches;
|
|
35
|
+
this.mobileQuery.addEventListener("change", this.updateLayout);
|
|
36
|
+
},
|
|
37
|
+
beforeUnmount() {
|
|
38
|
+
this.mobileQuery?.removeEventListener("change", this.updateLayout);
|
|
39
|
+
},
|
|
40
|
+
methods: {
|
|
41
|
+
updateLayout(event) { this.isMobile = event.matches; },
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
</script>
|
|
45
|
+
|
|
46
|
+
<style lang="less">
|
|
47
|
+
.w-responsive-code-diff {
|
|
48
|
+
width: 100%;
|
|
49
|
+
min-width: 0;
|
|
50
|
+
.file-header .file-info { height: auto; min-height: 24px; flex-wrap: wrap; gap: 8px; }
|
|
51
|
+
.file-header .info-left, .file-header .info-right { min-width: 0; overflow-wrap: anywhere; }
|
|
52
|
+
.m-stacked-diff {
|
|
53
|
+
display: grid;
|
|
54
|
+
gap: 16px;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.m-version-panel {
|
|
58
|
+
min-width: 0;
|
|
59
|
+
border: 1px solid #e4e7ed;
|
|
60
|
+
border-radius: 8px;
|
|
61
|
+
overflow: hidden;
|
|
62
|
+
|
|
63
|
+
h3 {
|
|
64
|
+
margin: 0;
|
|
65
|
+
padding: 10px 12px;
|
|
66
|
+
background: #f6f7fa;
|
|
67
|
+
border-bottom: 1px solid #e4e7ed;
|
|
68
|
+
font-size: 12px;
|
|
69
|
+
font-weight: 500;
|
|
70
|
+
line-height: 1.6;
|
|
71
|
+
white-space: normal;
|
|
72
|
+
overflow-wrap: anywhere;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.code-diff-view { margin: 0; border: 0; border-radius: 0; }
|
|
76
|
+
.diff-table { table-layout: fixed; }
|
|
77
|
+
.blob-num { min-width: 32px; padding: 0 5px; font-size: 11px; }
|
|
78
|
+
.blob-code { padding: 0 8px; font-size: 12px; }
|
|
79
|
+
.blob-code-inner { white-space: pre-wrap; overflow-wrap: anywhere; }
|
|
80
|
+
|
|
81
|
+
&.is-old {
|
|
82
|
+
col:nth-child(n + 3), td:nth-child(n + 3) { display: none; }
|
|
83
|
+
col:first-child { width: 32px; }
|
|
84
|
+
}
|
|
85
|
+
&.is-new {
|
|
86
|
+
col:nth-child(-n + 2), td:nth-child(-n + 2) { display: none; }
|
|
87
|
+
col:nth-child(3) { width: 32px; }
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
}
|
|
93
|
+
</style>
|
|
@@ -20,20 +20,22 @@
|
|
|
20
20
|
<th>{{ $jx3boxT('jx3boxUi.wikiRevisions.remark', '修订说明') }}</th>
|
|
21
21
|
</tr>
|
|
22
22
|
</thead>
|
|
23
|
+
<tbody>
|
|
23
24
|
<tr class="history" v-for="(ver, key) in versions" :key="key">
|
|
24
|
-
<td>
|
|
25
|
+
<td :data-label="$jx3boxT('jx3boxUi.wikiRevisions.version', '版本')">
|
|
25
26
|
<a
|
|
26
27
|
:href="link(type, `${ver.source_id}/${ver.id}`)"
|
|
27
28
|
v-text="'v' + (versions.length - key)"
|
|
28
29
|
@click="redirectRevision(ver, $event)"
|
|
29
30
|
></a>
|
|
30
31
|
</td>
|
|
31
|
-
<td v-text="ts2str(ver.updated)"></td>
|
|
32
|
-
<td>
|
|
32
|
+
<td :data-label="$jx3boxT('jx3boxUi.wikiPanel.updatedAt', '更新时间')" v-text="ts2str(ver.updated)"></td>
|
|
33
|
+
<td :data-label="$jx3boxT('jx3boxUi.wikiRevisions.contributor', '贡献者')">
|
|
33
34
|
<a :href="ver.user_id ? author_url(ver.user_id) : null" v-text="ver.user_nickname"></a>
|
|
34
35
|
</td>
|
|
35
|
-
<td v-text="ver.remark"></td>
|
|
36
|
+
<td :data-label="$jx3boxT('jx3boxUi.wikiRevisions.remark', '修订说明')" v-text="ver.remark"></td>
|
|
36
37
|
</tr>
|
|
38
|
+
</tbody>
|
|
37
39
|
</table>
|
|
38
40
|
</div>
|
|
39
41
|
</template>
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
const test = require('node:test');
|
|
2
|
+
const assert = require('node:assert/strict');
|
|
3
|
+
const fs = require('node:fs');
|
|
4
|
+
const Vue = require('vue');
|
|
5
|
+
const { parse } = require('@vue/compiler-sfc');
|
|
6
|
+
const { compile } = require('@vue/compiler-dom');
|
|
7
|
+
const { renderToString } = require('@vue/server-renderer');
|
|
8
|
+
|
|
9
|
+
function loadViewer() {
|
|
10
|
+
const source = fs.readFileSync(require.resolve('../src/wiki/ResponsiveCodeDiff.vue'), 'utf8');
|
|
11
|
+
const { descriptor } = parse(source);
|
|
12
|
+
const CodeDiff = {
|
|
13
|
+
props: ['oldString', 'newString', 'outputFormat', 'hideHeader'],
|
|
14
|
+
render() {
|
|
15
|
+
return Vue.h('pre', { 'data-format': this.outputFormat, 'data-hidden-header': this.hideHeader }, this.oldString + '|' + this.newString);
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
const component = new Function('CodeDiff', descriptor.script.content.replace(/^import .*;$/gm, '').replace('export default', 'return'))(CodeDiff);
|
|
19
|
+
component.render = new Function('Vue', compile(descriptor.template.content, { mode: 'function' }).code)(Vue);
|
|
20
|
+
return component;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
test('手机端两个独立版本容器保留原始对比数据,桌面端只渲染一组左右对比', async () => {
|
|
24
|
+
for (const mobile of [true, false]) {
|
|
25
|
+
const component = loadViewer();
|
|
26
|
+
component.data = () => ({ isMobile: mobile });
|
|
27
|
+
const html = await renderToString(Vue.createSSRApp(component, {
|
|
28
|
+
oldString: 'old <p>内容</p>', newString: 'new 内容', filename: 'v2 长说明', newFilename: 'v3 长说明',
|
|
29
|
+
}));
|
|
30
|
+
assert.equal((html.match(/<pre/g) || []).length, mobile ? 2 : 1);
|
|
31
|
+
assert.equal((html.match(/data-format="side-by-side"/g) || []).length, mobile ? 2 : 1);
|
|
32
|
+
if (mobile) {
|
|
33
|
+
assert.match(html, /is-old/);
|
|
34
|
+
assert.match(html, /is-new/);
|
|
35
|
+
assert.match(html, /<h3>v2 长说明<\/h3>/);
|
|
36
|
+
assert.match(html, /<h3>v3 长说明<\/h3>/);
|
|
37
|
+
}
|
|
38
|
+
assert.match(html, /old <p>内容<\/p>\|new 内容/);
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
test('屏幕宽度变化更新布局,卸载时移除监听', () => {
|
|
43
|
+
const component = loadViewer();
|
|
44
|
+
const previousWindow = global.window;
|
|
45
|
+
let handler;
|
|
46
|
+
let removed = false;
|
|
47
|
+
const query = { matches: true, addEventListener(name, fn) { assert.equal(name, 'change'); handler = fn; }, removeEventListener(name, fn) { removed = name === 'change' && fn === handler; } };
|
|
48
|
+
global.window = { matchMedia: () => query };
|
|
49
|
+
try {
|
|
50
|
+
const context = { isMobile: false, updateLayout: component.methods.updateLayout };
|
|
51
|
+
component.mounted.call(context);
|
|
52
|
+
assert.equal(context.isMobile, true);
|
|
53
|
+
handler.call(context, { matches: false });
|
|
54
|
+
assert.equal(context.isMobile, false);
|
|
55
|
+
component.beforeUnmount.call(context);
|
|
56
|
+
assert.equal(removed, true);
|
|
57
|
+
} finally {
|
|
58
|
+
if (previousWindow === undefined) delete global.window;
|
|
59
|
+
else global.window = previousWindow;
|
|
60
|
+
}
|
|
61
|
+
});
|