2
0
mirror of https://github.com/tenrok/vue-json-viewer.git synced 2026-06-23 20:40:38 +03:00

feat: fix some issues

This commit is contained in:
风棋
2021-01-13 20:18:08 +08:00
parent 6f310879ef
commit 054b4089c7
7 changed files with 35 additions and 13 deletions
+6
View File
@@ -1,5 +1,11 @@
## 2.2.17 2020-12-29 ## 2.2.17 2020-12-29
- fix: issues [issues](https://github.com/chenfengjw163/vue-json-viewer/issues/64)
- fix: issues [issues](https://github.com/chenfengjw163/vue-json-viewer/issues/65)
- fix: issues [issues](https://github.com/chenfengjw163/vue-json-viewer/issues/66)
## 2.2.17 2020-12-29
- fix: long string expand arrow display error [pr](https://github.com/chenfengjw163/vue-json-viewer/pull/62) - fix: long string expand arrow display error [pr](https://github.com/chenfengjw163/vue-json-viewer/pull/62)
## 2.2.16 2020-11-13 ## 2.2.16 2020-11-13
+3
View File
@@ -1,3 +1,6 @@
.jv-number-float { .jv-number-float {
color: #faa !important; color: #faa !important;
}
.jv-key-node {
display: flex;
} }
+4 -2
View File
@@ -36,7 +36,8 @@ new Vue({
expand-depth={5} expand-depth={5}
copyable={{ copyable={{
copyText: '复制', copyText: '复制',
copiedText: '复制成功' copiedText: '复制成功',
align: 'left'
}} }}
boxed boxed
timeformat={time => new Date(time)} timeformat={time => new Date(time)}
@@ -46,7 +47,8 @@ new Vue({
value={this.jsonData} value={this.jsonData}
expand-depth={1} expand-depth={1}
copyable={{ copyable={{
timeout: 4000 timeout: 4000,
align: 'left'
}} }}
scopedSlots={scopedSlots} scopedSlots={scopedSlots}
onCopied={onCopied}></json-viewer> onCopied={onCopied}></json-viewer>
+4 -3
View File
@@ -70,9 +70,9 @@ export default {
} else if (typeof this.value === 'function') { } else if (typeof this.value === 'function') {
dataType = JsonFunction dataType = JsonFunction
} }
const toggle = this.keyName && (this.value && (Array.isArray(this.value) || (typeof this.value === 'object' && Object.prototype.toString.call(this.value) !== '[object Date]'))) const complex = this.keyName && (this.value && (Array.isArray(this.value) || (typeof this.value === 'object' && Object.prototype.toString.call(this.value) !== '[object Date]')))
if (!this.previewMode && toggle) { if (!this.previewMode && complex) {
elements.push(h('span', { elements.push(h('span', {
class: { class: {
'jv-toggle': true, 'jv-toggle': true,
@@ -117,7 +117,8 @@ export default {
return h('div', { return h('div', {
class: { class: {
'jv-node': true, 'jv-node': true,
'toggle': !this.previewMode && toggle 'jv-key-node': Boolean(this.keyName) && !complex,
'toggle': !this.previewMode && complex
} }
}, elements) }, elements)
} }
+16 -6
View File
@@ -2,7 +2,7 @@
<div :class="jvClass"> <div :class="jvClass">
<div <div
v-if="copyable" v-if="copyable"
class="jv-tooltip" :class="`jv-tooltip ${copyText.align || 'right'}`"
> >
<span <span
ref="clip" ref="clip"
@@ -108,12 +108,13 @@ export default {
return 'jv-container ' + this.theme + (this.boxed ? ' boxed' : '') return 'jv-container ' + this.theme + (this.boxed ? ' boxed' : '')
}, },
copyText() { copyText() {
const { copyText, copiedText, timeout } = this.copyable const { copyText, copiedText, timeout, align } = this.copyable
return { return {
copyText: copyText || 'copy', copyText: copyText || 'copy',
copiedText: copiedText || 'copied!', copiedText: copiedText || 'copied!',
timeout: timeout || 2000 timeout: timeout || 2000,
align,
} }
} }
}, },
@@ -236,6 +237,10 @@ export default {
color: #42b983; color: #42b983;
word-break: break-word; word-break: break-word;
white-space: normal; white-space: normal;
.jv-link {
color: #0366d6;
}
} }
} }
.jv-code { .jv-code {
@@ -255,7 +260,7 @@ export default {
.jv-code { .jv-code {
overflow: hidden; overflow: hidden;
padding: 20px; padding: 30px 20px;
&.boxed { &.boxed {
max-height: 300px; max-height: 300px;
@@ -357,8 +362,13 @@ export default {
.jv-tooltip { .jv-tooltip {
position: absolute; position: absolute;
right: 15px;
top: 10px; &.right {
right: 15px;
}
&.left {
left: 15px;
}
} }
.j-icon { .j-icon {
+1 -1
View File
@@ -51,7 +51,7 @@ export default {
ref: 'itemRef', ref: 'itemRef',
} }
if (islink) { if (islink) {
value = `<a href="${value}" target="_blank" style="color: #0366d6;">${value}</a>`; value = `<a href="${value}" target="_blank" class="jv-link">${value}</a>`;
domItem.domProps = { domItem.domProps = {
innerHTML: `"${value.toString()}"` innerHTML: `"${value.toString()}"`
} }
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "vue-json-viewer", "name": "vue-json-viewer",
"version": "2.2.17", "version": "2.2.18",
"description": "vuejs展示json的组件", "description": "vuejs展示json的组件",
"main": "vue-json-viewer.js", "main": "vue-json-viewer.js",
"files": [ "files": [