Skip to content

Commit

Permalink
feat: 【告警策略】数据预览格式化
Browse files Browse the repository at this point in the history
  • Loading branch information
yzygyin committed Nov 15, 2024
1 parent 2fec2f7 commit 05817cd
Showing 1 changed file with 29 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,17 +63,25 @@
:width="700"
:title="detailTitle"
>
<pre class="log-content">
{{ logDetail }}
</pre>
<JsonViewer
class="log-content"
:preview-mode="true"
:value="logDetail"
/>
</bk-dialog>
</div>
</template>
<script lang="ts">
import dayjs from 'dayjs';
import { Component, Emit, Prop, Vue } from 'vue-property-decorator';
import JsonViewer from 'vue-json-viewer';

@Component({ name: 'strategy-view-log' })
@Component({
name: 'strategy-view-log',
components: {
JsonViewer
}
})
export default class StrategyViewLog extends Vue {
@Prop({ default: () => [], type: Array }) private readonly data!: any[];
@Prop({ default: false, type: Boolean }) private readonly isLast!: boolean;
Expand Down Expand Up @@ -104,7 +112,14 @@ export default class StrategyViewLog extends Vue {
}
}
handleShowDetai(row) {
this.logDetail = row.content || row['event.content'];
const content = row.content || row['event.content']
this.logDetail = (() => {
try {
return JSON.parse(content);
} catch {
return content;
}
})();
this.showLogDetail = true;
}

Expand Down Expand Up @@ -135,11 +150,19 @@ export default class StrategyViewLog extends Vue {

&-content {
height: 380px;
padding: 15px 20px;
padding: 15px 20px;
overflow: auto;
word-break: break-all;
background: #f5f6fa;
border-radius: 2px;

&.jv-light {
background: #f5f6fa;
}

:deep(.jv-code) {
padding: 0;
}
}
}

Expand Down

0 comments on commit 05817cd

Please sign in to comment.