@jx3box/jx3box-ui 2.4.13 → 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.
@@ -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
- .c-wiki-revisions.is-surface {
120
- .m-revisions-panel {
121
- scrollbar-width: thin;
122
- box-shadow: inset -12px 0 12px -12px rgba(15, 23, 42, 0.2);
123
- }
124
-
125
- .m-histories {
126
- min-width: 560px;
127
-
128
- th,
129
- td {
130
- min-width: 100px;
131
- padding: 8px;
132
- font-size: 12px;
133
- }
134
-
135
- th:first-child,
136
- td:first-child {
137
- min-width: 44px;
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/index.js CHANGED
@@ -96,3 +96,5 @@ export {
96
96
  setJx3boxUiLocale,
97
97
  createJx3boxTrafficAnalytics,
98
98
  };
99
+
100
+ export { default as ResponsiveCodeDiff } from "./src/wiki/ResponsiveCodeDiff.vue";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jx3box/jx3box-ui",
3
- "version": "2.4.13",
3
+ "version": "2.4.14",
4
4
  "description": "JX3BOX Vue3 UI",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -191,3 +191,9 @@ export default {
191
191
  },
192
192
  };
193
193
  </script>
194
+
195
+ <style lang="less">
196
+ @media screen and (max-width: 720px) {
197
+ .w-boxcoin-records .u-delete { display: none; }
198
+ }
199
+ </style>
@@ -56,17 +56,16 @@
56
56
  </div>
57
57
  </div>
58
58
  <div v-if="type === 'code'" class="m-content-container">
59
- <code-diff
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
- ></code-diff>
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 { CodeDiff } from "v-code-diff";
77
+ import ResponsiveCodeDiff from "../wiki/ResponsiveCodeDiff.vue";
79
78
  export default {
80
79
  name: "VersionDialog",
81
80
  components: {
82
- CodeDiff,
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 &lt;p&gt;内容&lt;\/p&gt;\|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
+ });