Skip to content

Commit 7f891b4

Browse files
author
linyuan.yang
committed
界面布局
1 parent dd6416c commit 7f891b4

9 files changed

Lines changed: 59 additions & 14 deletions

File tree

‎packages/tools-core/src/tools/devtool/jwt/JwtView.vue‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ async function copyValue(key: string, value: string) {
9191
</template>
9292

9393
<style scoped>
94-
.tool { max-width: 1100px; margin: 0 auto; }
94+
.tool { max-width: 92%; margin: 0 auto; }
9595
.lead { color: var(--fg-muted); margin-bottom: 16px; }
9696
9797
.card {

‎packages/tools-core/src/tools/devtool/timestamp/TimestampView.vue‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ async function copyValue(key: string, value: string) {
193193
</template>
194194

195195
<style scoped>
196-
.tool { max-width: 1100px; margin: 0 auto; }
196+
.tool { max-width: 92%; margin: 0 auto; }
197197
.lead { color: var(--fg-muted); margin-bottom: 16px; }
198198
199199
.card {

‎packages/tools-core/src/tools/encode/codec/CodecView.vue‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ const tabs: { key: Tab; label: string }[] = [
311311
</template>
312312

313313
<style scoped>
314-
.codec { max-width: 1100px; margin: 0 auto; }
314+
.codec { max-width: 92%; margin: 0 auto; }
315315
.lead { color: var(--fg-muted); margin-bottom: 16px; }
316316
317317
.tab-bar {

‎packages/tools-core/src/tools/encode/json-convert/JsonConvertView.vue‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ const fromLabel = computed(() =>
139139
</template>
140140

141141
<style scoped>
142-
.tool { max-width: 1100px; margin: 0 auto; }
142+
.tool { max-width: 92%; margin: 0 auto; }
143143
.lead { color: var(--fg-muted); margin-bottom: 16px; }
144144
145145
.card {

‎packages/tools-core/src/tools/encode/json/JsonNode.vue‎

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,32 @@ const entries = computed<[string | number, unknown][]>(() => {
3030
const count = computed(() => entries.value.length)
3131
const bracket = computed(() => (type.value === 'array' ? ['[', ']'] : ['{', '}']))
3232
33+
// 长字符串默认截断为单行,点击「展开」查看完整内容
34+
const MAX_STR = 160
35+
const rawString = computed(() => (type.value === 'string' ? (props.value as string) : ''))
36+
const stringTooLong = computed(() => rawString.value.length > MAX_STR)
37+
const expandedStr = ref(false)
38+
3339
const displayValue = computed(() => {
34-
if (type.value === 'string') return JSON.stringify(props.value)
40+
if (type.value === 'string') {
41+
if (stringTooLong.value && !expandedStr.value) {
42+
return JSON.stringify(rawString.value.slice(0, MAX_STR)) + `… (+${rawString.value.length - MAX_STR} 字符)`
43+
}
44+
return JSON.stringify(rawString.value)
45+
}
3546
return String(props.value)
3647
})
3748
49+
// 字符串本身是 JSON(对象/数组)时,可内联解析成子树
50+
const subJson = computed<unknown>(() => {
51+
if (type.value !== 'string') return null
52+
const s = rawString.value.trim()
53+
if (s.length > 200_000) return null
54+
if (!(s.startsWith('{') && s.endsWith('}')) && !(s.startsWith('[') && s.endsWith(']'))) return null
55+
try { return JSON.parse(s) } catch { return null }
56+
})
57+
const showSubJson = ref(false)
58+
3859
function childPath(key: string | number): string {
3960
if (typeof key === 'number') return `${props.path}[${key}]`
4061
return /^[A-Za-z_$][\w$]*$/.test(key) ? `${props.path}.${key}` : `${props.path}[${JSON.stringify(key)}]`
@@ -69,8 +90,18 @@ async function copy(what: 'value' | 'path') {
6990
</span>
7091
<span v-if="!collapsed" class="muted count">{{ count }} 项</span>
7192
</template>
93+
<span v-else-if="type === 'string'" class="val string" :class="{ expanded: expandedStr }">{{ displayValue }}</span>
7294
<span v-else class="val" :class="type">{{ displayValue }}</span>
7395

96+
<template v-if="type === 'string'">
97+
<button v-if="stringTooLong" class="mini inline" @click="expandedStr = !expandedStr">
98+
{{ expandedStr ? '收起' : `展开 (共 ${rawString.length} 字符)` }}
99+
</button>
100+
<button v-if="subJson !== null" class="mini inline" @click="showSubJson = !showSubJson">
101+
{{ showSubJson ? '收起解析' : '解析为 JSON' }}
102+
</button>
103+
</template>
104+
74105
<span class="actions">
75106
<button class="mini" @click="copy('value')" title="复制该节点的值(JSON)">{{ copiedWhat === 'value' ? '✓' : '复制值' }}</button>
76107
<button class="mini" @click="copy('path')" title="复制访问路径">{{ copiedWhat === 'path' ? '✓' : '路径' }}</button>
@@ -88,6 +119,11 @@ async function copy(what: 'value' | 'path') {
88119
/>
89120
<div class="line closing"><span class="toggle spacer" /><span class="brace">{{ bracket[1] }}</span></div>
90121
</div>
122+
123+
<!-- 字符串值本身是 JSON 时,内联展示解析后的子树 -->
124+
<div v-if="!isBranch && showSubJson && subJson !== null" class="children sub-json">
125+
<JsonNode :k="null" :value="subJson" :path="path" :depth="0" />
126+
</div>
91127
</div>
92128
</template>
93129

@@ -107,17 +143,23 @@ async function copy(what: 'value' | 'path') {
107143
.muted { color: var(--fg-muted); }
108144
.count { font-size: 11px; margin-left: 4px; }
109145
146+
.val { min-width: 0; }
110147
.val.string { color: var(--success); }
148+
.val.string:not(.expanded) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 0 1 auto; }
149+
.val.string.expanded { white-space: pre-wrap; overflow-wrap: anywhere; flex: 1 1 auto; }
111150
.val.number { color: #b8860b; }
112151
.val.boolean { color: #8250df; }
113152
.val.null { color: var(--fg-muted); font-style: italic; }
114153
115154
.children { padding-left: 16px; border-left: 1px solid var(--border); margin-left: 6px; }
155+
.children.sub-json { margin-top: 2px; background: var(--bg); border-radius: 4px; padding: 6px 8px 6px 16px; }
116156
117-
.actions { opacity: 0; display: inline-flex; gap: 4px; margin-left: 8px; transition: opacity 0.1s; }
157+
.actions { opacity: 0; display: inline-flex; gap: 4px; margin-left: 8px; flex: 0 0 auto; transition: opacity 0.1s; }
118158
.mini {
119159
background: none; border: 1px solid var(--border); border-radius: 3px;
120160
font-size: 10px; padding: 0 6px; line-height: 16px; color: var(--fg-muted); cursor: pointer;
161+
white-space: nowrap; flex: 0 0 auto;
121162
}
163+
.mini.inline { flex: 0 0 auto; opacity: 0.8; }
122164
.mini:hover { border-color: var(--primary); color: var(--primary); }
123165
</style>

‎packages/tools-core/src/tools/encode/json/JsonView.vue‎

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ const stats = computed(() => {
116116
</template>
117117

118118
<style scoped>
119-
.tool { max-width: 1100px; margin: 0 auto; }
119+
.tool { max-width: 92%; margin: 0 auto; height: 100%; display: flex; flex-direction: column; }
120120
.lead { color: var(--fg-muted); margin-bottom: 16px; }
121121
122122
.card {
@@ -132,11 +132,11 @@ const stats = computed(() => {
132132
.indent-select { flex: 0 0 64px; }
133133
.stats { font-size: 12px; color: var(--fg-muted); }
134134
135-
.io-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
136-
.io-col { display: flex; flex-direction: column; }
137-
.label-row { margin-bottom: 6px; }
135+
.io-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; flex: 1 1 auto; min-height: 0; }
136+
.io-col { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
137+
.label-row { margin-bottom: 6px; flex: 0 0 auto; }
138138
139-
.tree { padding: 12px; overflow: auto; max-height: 560px; min-height: 120px; }
139+
.tree { padding: 12px; overflow: auto; flex: 1 1 auto; min-height: 320px; }
140140
.placeholder { color: var(--fg-muted); font-size: 13px; margin: 0; }
141141
142142
.input {
@@ -151,6 +151,9 @@ const stats = computed(() => {
151151
152152
.textarea {
153153
width: 100%;
154+
min-width: 0;
155+
flex: 1 1 auto;
156+
min-height: 320px;
154157
padding: 8px 10px;
155158
border: 1px solid var(--border);
156159
border-radius: 4px;

‎packages/tools-core/src/tools/genverify/checksum/ChecksumView.vue‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ const algos: { v: HashAlgorithm; label: string }[] = [
122122
</template>
123123

124124
<style scoped>
125-
.tool { max-width: 880px; margin: 0 auto; }
125+
.tool { max-width: 92%; margin: 0 auto; }
126126
.lead { color: var(--fg-muted); margin-bottom: 16px; }
127127
128128
.card {

‎packages/tools-core/src/tools/genverify/random-gen/RandomGenView.vue‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ function switchTab(t: Tab) { activeTab.value = t; results.value = []; error.valu
162162
</template>
163163

164164
<style scoped>
165-
.tool { max-width: 880px; margin: 0 auto; }
165+
.tool { max-width: 92%; margin: 0 auto; }
166166
.lead { color: var(--fg-muted); margin-bottom: 16px; }
167167
168168
.tab-bar { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }

‎packages/tools-core/src/tools/media/qrcode/QrView.vue‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ const tabs: { key: Tab; label: string }[] = [
189189
</template>
190190

191191
<style scoped>
192-
.tool { max-width: 1000px; margin: 0 auto; }
192+
.tool { max-width: 92%; margin: 0 auto; }
193193
.lead { color: var(--fg-muted); margin-bottom: 16px; }
194194
195195
.tab-bar { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }

0 commit comments

Comments
 (0)