添加游戏日志查询

This commit is contained in:
zpc 2024-12-01 02:38:08 +08:00
parent 5ca0ae9b19
commit 85d7953634
3 changed files with 161 additions and 34 deletions

View File

@ -82,6 +82,7 @@ declare module 'vue' {
BarChartTransverse: typeof import('./core/components/charts/BarChartTransverse.vue')['default'] BarChartTransverse: typeof import('./core/components/charts/BarChartTransverse.vue')['default']
ColumnSetting: typeof import('./core/components/curd/components/ColumnSetting.vue')['default'] ColumnSetting: typeof import('./core/components/curd/components/ColumnSetting.vue')['default']
ElAside: typeof import('element-plus/es')['ElAside'] ElAside: typeof import('element-plus/es')['ElAside']
ElButton: typeof import('element-plus/es')['ElButton']
ElCard: typeof import('element-plus/es')['ElCard'] ElCard: typeof import('element-plus/es')['ElCard']
ElCheckbox: typeof import('element-plus/es')['ElCheckbox'] ElCheckbox: typeof import('element-plus/es')['ElCheckbox']
ElCheckboxButton: typeof import('element-plus/es')['ElCheckboxButton'] ElCheckboxButton: typeof import('element-plus/es')['ElCheckboxButton']
@ -91,6 +92,7 @@ declare module 'vue' {
ElImage: typeof import('element-plus/es')['ElImage'] ElImage: typeof import('element-plus/es')['ElImage']
ElMain: typeof import('element-plus/es')['ElMain'] ElMain: typeof import('element-plus/es')['ElMain']
ElSpace: typeof import('element-plus/es')['ElSpace'] ElSpace: typeof import('element-plus/es')['ElSpace']
ElText: typeof import('element-plus/es')['ElText']
ElTimeline: typeof import('element-plus/es')['ElTimeline'] ElTimeline: typeof import('element-plus/es')['ElTimeline']
ElTimelineItem: typeof import('element-plus/es')['ElTimelineItem'] ElTimelineItem: typeof import('element-plus/es')['ElTimelineItem']
ExternalJump: typeof import('./core/components/ExternalJump.vue')['default'] ExternalJump: typeof import('./core/components/ExternalJump.vue')['default']

View File

@ -1,10 +1,20 @@
<script lang="ts" setup> <script lang="ts" setup>
import { reactive, ref } from "vue"; import {
import { FormInstance } from "ant-design-vue"; reactive,
import Tools from "@/core/utils/Tools"; ref,
import { MoreFilled } from "@element-plus/icons-vue"; onMounted,
// onBeforeUnmount,
nextTick,
watch,
} from "vue";
import * as monaco from "monaco-editor";
import "monaco-editor/min/vs/editor/editor.main.css";
const props = defineProps<{ onSuccess: () => void }>(); const props = defineProps<{ onSuccess: () => void }>();
let editorContainer = ref<HTMLElement>();
let editorInstance: monaco.editor.IStandaloneCodeEditor | null = null;
let responseEditorContainer = ref<HTMLElement>();
let responseEditorInstance: monaco.editor.IStandaloneCodeEditor | null = null;
const state = reactive({ const state = reactive({
vm: { vm: {
@ -15,32 +25,112 @@ const state = reactive({
loading: false, loading: false,
}); });
let jsonData = ref([]); let jsonData = ref([]);
//
defineExpose({ //
/** function initializeEditor(container: HTMLElement, value: string = "") {
* 打开表单初始化 const editor = monaco.editor.create(container, {
* @param jsonstr value,
*/ language: "json",
open: (jsonstr: string = "") => { theme: "vs-dark", //
state.visible = true; automaticLayout: true, //
if (state.visible) { wordWrap: "on", //
state.vm.id = jsonstr; minimap: {
var data = JSON.parse(jsonstr); enabled: false, //
console.log(data); },
jsonData.value.push(...data); lineNumbers: "on", //
console.log(jsonData.value); });
//
editor.onDidChangeModelContent(() => {
editor.setScrollTop(0); //
});
return editor;
} }
// //
state.loading = true; watch(
state.loading = false; () => state.visible,
(visible) => {
if (visible) {
nextTick(() => {
if (editorContainer.value && !editorInstance) {
editorInstance = initializeEditor(
editorContainer.value,
"// 请求消息"
);
}
if (responseEditorContainer.value && !responseEditorInstance) {
responseEditorInstance = initializeEditor(
responseEditorContainer.value,
"// 返回消息"
);
}
});
}
}
);
let totalMilliseconds = ref(0);
onBeforeUnmount(() => {
if (editorInstance) editorInstance.dispose();
if (responseEditorInstance) responseEditorInstance.dispose();
});
//
defineExpose({
open: (jsonstr: string = "") => {
state.visible = true;
totalMilliseconds.value = 0;
nextTick(() => {
const data = JSON.parse(jsonstr || "{}");
jsonData.value.slice(0, jsonData.value.length);
jsonData.value.push(...data);
setTimeout(() => {
if (editorInstance) {
editorInstance.setValue(JSON.stringify(data, null, 2));
}
if (responseEditorInstance) {
responseEditorInstance.setValue(
JSON.stringify(data.response || {}, null, 2)
);
}
}, 500);
});
}, },
}); });
/** //
*保存数据 function save() {
*/ if (editorInstance) {
function save() {} const requestContent = editorInstance.getValue();
console.log("请求内容:", requestContent);
}
if (responseEditorInstance) {
const responseContent = responseEditorInstance.getValue();
console.log("返回内容:", responseContent);
}
}
function showJyRequestData(t: any) {
if (editorInstance) {
if (t.RequestContent == null) {
editorInstance.setValue("");
} else {
editorInstance.setValue(
JSON.stringify(JSON.parse(t.RequestContent), null, 2)
);
}
totalMilliseconds.value = t.TotalMilliseconds;
}
if (responseEditorInstance) {
if (t.ResponseContent == null) {
responseEditorInstance.setValue("");
} else {
responseEditorInstance.setValue(
JSON.stringify(JSON.parse(t.ResponseContent), null, 2)
);
}
}
}
</script> </script>
<template> <template>
@ -50,35 +140,69 @@ function save() {}
centered centered
@ok="state.visible = false" @ok="state.visible = false"
:maskClosable="false" :maskClosable="false"
:width="900" width="80%"
> >
<template #footer> <template #footer>
<a-button type="primary" :loading="state.loading" @click="save()"> <a-button type="primary" :loading="state.loading" @click="save()">
提交</a-button 提交
> </a-button>
<a-button @click="state.visible = false">关闭</a-button> <a-button @click="state.visible = false">关闭</a-button>
</template> </template>
<a-spin :spinning="state.loading"> <a-spin :spinning="state.loading">
<el-container> <el-container>
<el-aside width="550px"> <el-aside width="550px">
<el-timeline style="max-width: 500px; max-height: 500px"> <el-timeline style="max-width: 500px; max-height: 80vh">
<el-timeline-item <el-timeline-item
@click="() => showJyRequestData(t)"
v-for="t in jsonData" v-for="t in jsonData"
:key="t.OperationDateTime"
:timestamp="t.OperationDateTime" :timestamp="t.OperationDateTime"
placement="top" placement="top"
:hide-timestamp="true"
> >
{{ t.Content }} <div v-if="t.RequestContent != null" style="cursor: pointer">
<div>
<el-text class="mx-1" type="primary">
{{ t.OperationDateTime }}</el-text
>
</div>
<div style="">
<el-text class="mx-1" type="primary">
{{ t.Content }}</el-text
>
</div>
</div>
<div v-else>
<div>
<el-text class="mx-1" type="info">
{{ t.OperationDateTime }}</el-text
>
</div>
<div style="">
<el-text class="mx-1" type="info"> {{ t.Content }}</el-text>
</div>
</div>
</el-timeline-item> </el-timeline-item>
</el-timeline> </el-timeline>
</el-aside> </el-aside>
<el-main> <el-main>
请求耗时
<el-text v-if="totalMilliseconds > 0" class="mx-1" type="success"
>{{ totalMilliseconds }} 毫秒</el-text
><el-text v-else class="mx-1" type="warning"></el-text><br />
请求信息
<div class="monaco-editor" ref="editorContainer"></div>
返回消息
<div class="monaco-editor" ref="responseEditorContainer"></div>
</el-main> </el-main>
</el-container> </el-container>
<!-- aaaa -->
<!-- {{ state.vm.id }} -->
</a-spin> </a-spin>
</a-modal> </a-modal>
</template> </template>
<style>
.monaco-editor {
width: 100%;
height: 40vh;
}
</style>

View File

@ -5,6 +5,7 @@ import vueJsx from "@vitejs/plugin-vue-jsx";
import AutoImport from 'unplugin-auto-import/vite' import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'; import Components from 'unplugin-vue-components/vite';
import { AntDesignVueResolver,ElementPlusResolver } from 'unplugin-vue-components/resolvers'; import { AntDesignVueResolver,ElementPlusResolver } from 'unplugin-vue-components/resolvers';
// import monacoEditorPlugin from "vite-plugin-monaco-editor";
// https://vitejs.dev/config/ // https://vitejs.dev/config/
export default defineConfig({ export default defineConfig({
plugins: [ plugins: [