diff --git a/ui/.eslintrc.js b/ui/.eslintrc.js index 476a91a3f4ffb48db9c6ac3461931fd499ca4d64..0afc9fd37a76fed47e452d4eddd9a831d873cc0e 100644 --- a/ui/.eslintrc.js +++ b/ui/.eslintrc.js @@ -55,7 +55,7 @@ module.exports = { 'no-unused-vars': 0, '@typescript-eslint/no-unused-vars': [1, { vars: 'all', args: 'after-used' }], // 未定义前不能使用 - 'no-use-before-define': 2, + 'no-use-before-define': 1, // 不能有无法执行的代码 'no-unreachable': 2, // 不能使用未定义的变量 diff --git a/ui/src/components/data/json-view/JsonViewItem.vue b/ui/src/components/data/json-view/JsonViewItem.vue new file mode 100644 index 0000000000000000000000000000000000000000..47004f59e42010768f4c8a440ae780fc921bb4a4 --- /dev/null +++ b/ui/src/components/data/json-view/JsonViewItem.vue @@ -0,0 +1,204 @@ + + + + + diff --git a/ui/src/components/data/json-view/index.vue b/ui/src/components/data/json-view/index.vue new file mode 100644 index 0000000000000000000000000000000000000000..6ec8caf01aeea2fbcda20f06fa67f57eec9976c9 --- /dev/null +++ b/ui/src/components/data/json-view/index.vue @@ -0,0 +1,153 @@ + + + + + diff --git a/ui/src/components/data/json-view/types.ts b/ui/src/components/data/json-view/types.ts new file mode 100644 index 0000000000000000000000000000000000000000..efe070ea6518069ef627bace298570d26e5889e0 --- /dev/null +++ b/ui/src/components/data/json-view/types.ts @@ -0,0 +1,42 @@ +export enum JsonDataType { + ARRAY = 'array', + VALUE = 'value', + OBJECT = 'object', +} + +interface JsonDataBase { + key: string; + type: JsonDataType; + depth: number; + path: string; +} + +export type JsonData = JsonDataArray | JsonDataObject | JsonDataValue; + +export interface JsonDataArray extends JsonDataBase { + type: JsonDataType.ARRAY; + length: number; + children: Array; +} + +export interface JsonDataObject extends JsonDataBase { + type: JsonDataType.OBJECT; + length: number; + children: Array; +} + +export interface JsonDataValue extends JsonDataBase { + type: JsonDataType.VALUE; + value?: any; +} + +export interface SelectedJsonData { + key: string; + value: string; + path: string; +} + +export enum ColorMode { + LIGHT = 'light', + DARK = 'dark', +} diff --git a/ui/src/views/common/webhook-drawer.vue b/ui/src/views/common/webhook-drawer.vue index 20a8511572632e6edc60739c38e073a02b4b90e4..f88a5b63013c22b878092c0c73526ca9485f17e9 100644 --- a/ui/src/views/common/webhook-drawer.vue +++ b/ui/src/views/common/webhook-drawer.vue @@ -101,15 +101,25 @@ top="5vh" >
-
触发器
-
Payload
+
触发器
+
Payload
+
JsonView
-
+
+ +
+
Json路径:
+ + +
+
+ +
-
+
@@ -195,6 +205,12 @@ import { ParamTypeEnum } from '@/api/dto/enumeration'; import JmTextViewer from '@/components/text-viewer/index.vue'; import ParamValue from '@/views/common/param-value.vue'; +enum TabState { + TRIGGER = 'TRIGGER', + PAYLOAD = 'PAYLOAD', + JSONVIEW = 'JSONVIEW', +} + export default defineComponent({ components: { JmTextViewer, ParamValue }, props: { @@ -221,7 +237,9 @@ export default defineComponent({ const scrollRef = ref(); const webhookDrawerRef = ref>(); const loadState = ref(StateEnum.NONE); - const payloadTab = ref(true); + const payloadTab = ref(TabState.TRIGGER); + // JsonPath + const jsonPath = ref(''); // 列表id const webhookListId = ref(''); // webhook参数详情 @@ -278,6 +296,8 @@ export default defineComponent({ }); // 请求列表 const webhookRequestList = ref([]); + // JsonPayload + const jsonPayload = ref(); // 日志 const webhookLog = ref(''); // webhookUrl @@ -429,9 +449,25 @@ export default defineComponent({ const rowkey = (row: any) => { return row.id; }; + const jsonItemSelected = (data: any) => { + jsonPath.value = data.path; + }; + // JsonView + const toJsonView = async () => { + payloadTab.value = TabState.JSONVIEW; + try { + payloadLoading.value = true; + const payloadContent = await getPayloadParams(webhookListId.value); + jsonPayload.value = JSON.parse(payloadContent.payload); + } catch (err) { + proxy.$throw(err, proxy); + } finally { + payloadLoading.value = false; + } + }; // payload const toTrigger = async () => { - payloadTab.value = false; + payloadTab.value = TabState.PAYLOAD; try { payloadLoading.value = true; const payloadContent = await getPayloadParams(webhookListId.value); @@ -444,14 +480,14 @@ export default defineComponent({ }; // 触发器 const toPayload = () => { - payloadTab.value = true; + payloadTab.value = TabState.TRIGGER; // 还原密钥显示 secretVisible.value = true; }; // 弹窗关闭 const dialogClose = () => { // 还原tab - payloadTab.value = true; + payloadTab.value = TabState.TRIGGER; // 还原密钥显示 secretVisible.value = true; }; @@ -496,6 +532,10 @@ export default defineComponent({ retry, seePayload, payloadDialogVisible, + // Json Payload + jsonPayload, + jsonItemSelected, + jsonPath, // 日志 webhookLog, btnDown, @@ -504,8 +544,10 @@ export default defineComponent({ tableLoading, // 切换tab payloadTab, + TabState, toTrigger, toPayload, + toJsonView, // 请求详情 webhookParamsDetail, webhookAuth, @@ -556,6 +598,7 @@ export default defineComponent({ background: #eff4f9; box-sizing: border-box; padding: 20px 25px 0 25px; + // 项目名称 .project-name { margin-bottom: 14px; @@ -592,6 +635,7 @@ export default defineComponent({ margin-right: 10px; border-radius: 2px; display: flex; + // 图标 .jm-icon-input-hook { content: '\e818'; @@ -733,6 +777,15 @@ export default defineComponent({ } } + ::v-deep(.jm-text-copy) { + font-size: 20px; + + .jm-icon-button-copy { + color: #082340; + opacity: 1; + } + } + // 查看paload ::v-deep(.el-dialog) { .el-dialog__header { @@ -788,6 +841,38 @@ export default defineComponent({ } } + // JsonView + .path-bar { + align-items: center; + display: flex; + flex: 1; + height: 25px; + padding: 20px; + border: 1px solid #e6ebf2; + } + + .path-bar-item { + height: 100%; + padding: 0 10px; + } + + #path-bar-item-label { + align-items: center; + display: flex; + border-right: 1px solid #ccc; + } + + #path-bar-item-input { + flex: 1; + } + + #path-bar-item-copy { + background-color: #fff; + height: 25px; + width: 70px; + border-left: 1px solid #ccc; + } + // payload/trigger .payload-content, .trigger-content { @@ -880,6 +965,7 @@ export default defineComponent({ .display-container { display: flex; align-items: center; + //justify-content: space-between; .param-value { flex: 1; diff --git a/ui/yarn.lock b/ui/yarn.lock index eaf3c2e1e081f59ee132112dd4fa3d3a0f8f93a7..5097e0b4497d7d6e7c0dde92d82ba7c5a8fa6386 100644 --- a/ui/yarn.lock +++ b/ui/yarn.lock @@ -940,6 +940,11 @@ ansi-styles@^6.0.0: resolved "https://registry.npmmirror.com/ansi-styles/-/ansi-styles-6.1.1.tgz#63cd61c72283a71cb30bd881dbb60adada74bc70" integrity sha512-qDOv24WjnYuL+wbwHdlsYZFy+cgPtrYw0Tn7GLORicQp9BkQLzrgI3Pm4VyR9ERZ41YTn7KlMPuL1n05WdZvmg== +ansi_up@^5.2.1: + version "5.2.1" + resolved "https://registry.npmmirror.com/ansi_up/-/ansi_up-5.2.1.tgz#9437082c7ad4975c15ec57d30a6b55da295bee36" + integrity sha512-5bz5T/7FRmlxA37zDXhG6cAwlcZtfnmNLDJra66EEIT3kYlw5aPJdbkJEhm59D6kA4Wi5ict6u6IDYHJaQlH+g== + anymatch@~3.1.1: version "3.1.2" resolved "https://registry.npmmirror.com/anymatch/-/anymatch-3.1.2.tgz#c0557c096af32f106198f4f4e2a383537e378716"