@jx3box/jx3box-ui 2.4.13 → 2.4.15
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/wiki/wiki-panel.less +9 -0
- package/assets/css/wiki/wiki-revisions.less +40 -21
- package/docs/agents/filter-segmented-skin.md +12 -0
- package/index.js +2 -0
- package/package.json +1 -1
- package/src/App.vue +1 -1
- package/src/filters/clientBy.vue +9 -1
- package/src/filters/segmented-skin.less +28 -0
- package/src/filters/versionBy.vue +9 -1
- package/src/interact/BoxcoinRecords.vue +6 -0
- 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
|
@@ -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
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# 分段筛选皮肤
|
|
2
|
+
|
|
3
|
+
`clientBy` 与 `versionBy` 均支持 Boolean 类型的 `segmented` prop,默认 `false`,保持原有样式。
|
|
4
|
+
|
|
5
|
+
```vue
|
|
6
|
+
<clientBy segmented :type="client" @filter="filterClient" />
|
|
7
|
+
<versionBy segmented :value="is_wujie" @filter="filterVersion" />
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
开启后使用浅灰分段底、白底紫字选中态与轻微阴影。两组件通过 `src/filters/segmented-skin.less` 共用皮肤,仅在根元素具有 `is-segmented` 类时生效。筛选值与事件协议不变。
|
|
11
|
+
|
|
12
|
+
业务页面升级公共组件后按需传入 `segmented`,不需要重复添加本地覆盖样式。
|
package/index.js
CHANGED
package/package.json
CHANGED
package/src/App.vue
CHANGED
package/src/filters/clientBy.vue
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<div class="w-filter-client">
|
|
2
|
+
<div class="w-filter-client" :class="{ 'is-segmented': segmented }">
|
|
3
3
|
<ul>
|
|
4
4
|
<li class="u-client" :class="{on: client == ''}" @click="filter('')" v-if="clients">
|
|
5
5
|
{{ $jx3boxT("jx3boxUi.clientBy.all", "全部") }}
|
|
@@ -24,6 +24,10 @@ export default {
|
|
|
24
24
|
mixins: [i18nMixin],
|
|
25
25
|
emits: ["filter"],
|
|
26
26
|
props: {
|
|
27
|
+
segmented: {
|
|
28
|
+
type: Boolean,
|
|
29
|
+
default: false,
|
|
30
|
+
},
|
|
27
31
|
type: {
|
|
28
32
|
type: String,
|
|
29
33
|
default: "",
|
|
@@ -82,6 +86,7 @@ export default {
|
|
|
82
86
|
</script>
|
|
83
87
|
|
|
84
88
|
<style lang="less">
|
|
89
|
+
@import "./segmented-skin.less";
|
|
85
90
|
/* src/filters/clientBy.vue */
|
|
86
91
|
.w-filter-client {
|
|
87
92
|
font-size: 0;
|
|
@@ -116,4 +121,7 @@ export default {
|
|
|
116
121
|
}
|
|
117
122
|
}
|
|
118
123
|
}
|
|
124
|
+
.w-filter-client.is-segmented {
|
|
125
|
+
.filter-segmented-skin();
|
|
126
|
+
}
|
|
119
127
|
</style>
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
.filter-segmented-skin() {
|
|
2
|
+
ul {
|
|
3
|
+
padding: 3px;
|
|
4
|
+
background-color: #f1f2f5;
|
|
5
|
+
border-color: #eceef2;
|
|
6
|
+
border-radius: 6px;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
li {
|
|
10
|
+
color: #606775;
|
|
11
|
+
padding: 3px 10px;
|
|
12
|
+
border-right: none;
|
|
13
|
+
border-radius: 4px;
|
|
14
|
+
transition: background-color 0.15s, color 0.15s, box-shadow 0.15s;
|
|
15
|
+
|
|
16
|
+
&:hover {
|
|
17
|
+
background-color: #e8eaf0;
|
|
18
|
+
color: #5140c9;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
&.on {
|
|
22
|
+
background-color: #fff;
|
|
23
|
+
color: #5140c9;
|
|
24
|
+
font-weight: 600;
|
|
25
|
+
box-shadow: 0 1px 3px rgba(31, 35, 48, 0.1);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<div class="w-filter-version">
|
|
2
|
+
<div class="w-filter-version" :class="{ 'is-segmented': segmented }">
|
|
3
3
|
<ul>
|
|
4
4
|
<li class="u-client" :class="{on: version == ''}" @click="filter('')">
|
|
5
5
|
{{ $jx3boxT("jx3boxUi.versionBy.all", "双端") }}
|
|
@@ -21,6 +21,10 @@ export default {
|
|
|
21
21
|
name: "versionBy",
|
|
22
22
|
mixins: [i18nMixin],
|
|
23
23
|
props: {
|
|
24
|
+
segmented: {
|
|
25
|
+
type: Boolean,
|
|
26
|
+
default: false,
|
|
27
|
+
},
|
|
24
28
|
value: {
|
|
25
29
|
type: [String, Number],
|
|
26
30
|
default: "",
|
|
@@ -52,6 +56,7 @@ export default {
|
|
|
52
56
|
</script>
|
|
53
57
|
|
|
54
58
|
<style lang="less">
|
|
59
|
+
@import "./segmented-skin.less";
|
|
55
60
|
/* src/filters/versionBy.vue */
|
|
56
61
|
.w-filter-version {
|
|
57
62
|
font-size: 0;
|
|
@@ -86,4 +91,7 @@ export default {
|
|
|
86
91
|
}
|
|
87
92
|
}
|
|
88
93
|
}
|
|
94
|
+
.w-filter-version.is-segmented {
|
|
95
|
+
.filter-segmented-skin();
|
|
96
|
+
}
|
|
89
97
|
</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
|
+
});
|