From ba3d33c24e70d2d698e51029a6e76290ed51a7cd Mon Sep 17 00:00:00 2001 From: RubyLiu Date: Mon, 15 Jan 2024 20:34:24 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E7=8E=AF=E5=A2=83=E7=AE=A1=E7=90=86):=20?= =?UTF-8?q?=E6=96=AD=E8=A8=80=E5=9F=BA=E6=9C=AC=E9=A1=B5=E9=9D=A2&?= =?UTF-8?q?=E8=AF=84=E8=AE=BA=E9=80=BB=E8=BE=91=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../business/ms-assertion/index.vue | 152 ++++++++++++++++++ .../business/ms-assertion/locale/en-US.ts | 3 + .../business/ms-assertion/locale/zh-CN.ts | 9 ++ .../business/ms-comment/comment-item.vue | 9 +- .../business/ms-comment/comment.tsx | 66 ++++++-- .../components/business/ms-comment/input.vue | 13 +- frontend/src/locale/en-US/common.ts | 1 + frontend/src/locale/zh-CN/common.ts | 1 + .../components/{envGroup => }/EnvGroupBox.vue | 2 +- .../{envParams => }/EnvParamBox.vue | 20 +-- .../components/allParams/AllParamsTable.vue | 2 +- .../components/envParams/AssertTab.vue | 6 +- .../environmental/index.vue | 4 +- .../environmental/locale/zh-CN.ts | 1 + 14 files changed, 250 insertions(+), 39 deletions(-) create mode 100644 frontend/src/components/business/ms-assertion/index.vue create mode 100644 frontend/src/components/business/ms-assertion/locale/en-US.ts create mode 100644 frontend/src/components/business/ms-assertion/locale/zh-CN.ts rename frontend/src/views/project-management/environmental/components/{envGroup => }/EnvGroupBox.vue (98%) rename frontend/src/views/project-management/environmental/components/{envParams => }/EnvParamBox.vue (86%) diff --git a/frontend/src/components/business/ms-assertion/index.vue b/frontend/src/components/business/ms-assertion/index.vue new file mode 100644 index 0000000000..52419b8463 --- /dev/null +++ b/frontend/src/components/business/ms-assertion/index.vue @@ -0,0 +1,152 @@ + + + + + diff --git a/frontend/src/components/business/ms-assertion/locale/en-US.ts b/frontend/src/components/business/ms-assertion/locale/en-US.ts new file mode 100644 index 0000000000..8ddc6428df --- /dev/null +++ b/frontend/src/components/business/ms-assertion/locale/en-US.ts @@ -0,0 +1,3 @@ +export default { + 'ms.assertion.button': 'Assertion', +}; diff --git a/frontend/src/components/business/ms-assertion/locale/zh-CN.ts b/frontend/src/components/business/ms-assertion/locale/zh-CN.ts new file mode 100644 index 0000000000..fb8b4b416e --- /dev/null +++ b/frontend/src/components/business/ms-assertion/locale/zh-CN.ts @@ -0,0 +1,9 @@ +export default { + 'ms.assertion.button': '断言', + 'ms.assertion.statusCode': '状态码', + 'ms.assertion.responseHeader': '响应头', + 'ms.assertion.responseBody': '响应体', + 'ms.assertion.responseTime': '响应时间', + 'ms.assertion.param': '变量', + 'ms.assertion.script': '脚本', +}; diff --git a/frontend/src/components/business/ms-comment/comment-item.vue b/frontend/src/components/business/ms-comment/comment-item.vue index 5be414d669..f2f1b92c1a 100644 --- a/frontend/src/components/business/ms-comment/comment-item.vue +++ b/frontend/src/components/business/ms-comment/comment-item.vue @@ -26,7 +26,7 @@ {{ t('ms.comment.edit') }} -
+
{{ t('ms.comment.delete') }}
@@ -51,14 +51,19 @@ const userStore = useUserStore(); const { t } = useI18n(); + defineOptions({ name: 'MsCommentItem' }); + const props = defineProps<{ element: CommentItem; // 评论的具体内容 mode: 'parent' | 'child'; // 父级评论还是子级评论 + onReply?: () => void; // 回复 + onEdit?: () => void; // 编辑 + onDelete?: () => void; // 删除 }>(); // 是否拥有编辑|删除权限 const hasEditAuth = computed(() => { - return props.element.commentUserInfo.id === userStore.id; + return props.element.createUser === userStore.id; }); const emit = defineEmits<{ diff --git a/frontend/src/components/business/ms-comment/comment.tsx b/frontend/src/components/business/ms-comment/comment.tsx index a702ba6053..4e537988ae 100644 --- a/frontend/src/components/business/ms-comment/comment.tsx +++ b/frontend/src/components/business/ms-comment/comment.tsx @@ -16,6 +16,10 @@ export default defineComponent({ type: Array as PropType, default: () => [], }, + disabled: { + type: Boolean as PropType, + default: false, + }, }, emits: { /* eslint-disable @typescript-eslint/no-unused-vars */ @@ -23,11 +27,19 @@ export default defineComponent({ delete: (value: string) => true, // 删除评论 }, setup(props, { emit }) { - const { commentList } = toRefs(props); - const currentItem = reactive<{ id: string; parentId: string }>({ id: '', parentId: '' }); + const { commentList, disabled } = toRefs(props); + const currentItem = reactive<{ id: string; parentId?: string }>({ + id: '', + parentId: '', + }); const { t } = useI18n(); const { openModal } = useModal(); + const resetCurrentItem = () => { + currentItem.id = ''; + currentItem.parentId = ''; + }; + const handlePublish = (content: string, item: CommentItem) => { const params: CommentParams = { ...item, @@ -36,9 +48,10 @@ export default defineComponent({ }; emit('updateOrAdd', params, (result: boolean) => { if (result) { - message.success(t('common.publishSuccess')); + message.success(t('common.publishSuccessfully')); + resetCurrentItem(); } else { - message.error(t('common.publishFail')); + message.error(t('common.publishFailed')); } }); }; @@ -60,12 +73,30 @@ export default defineComponent({ }); }; + const handleReply = (item: CommentItem) => { + if (item.childComments) { + // 父级评论 + currentItem.id = item.id; + } else { + // 子级评论 + currentItem.id = item.parentId || ''; + currentItem.parentId = item.id; + } + }; + + const handelEdit = (item: CommentItem) => { + currentItem.id = item.id; + currentItem.parentId = item.parentId || ''; + }; + const renderInput = (item: CommentItem) => { return ( handlePublish(content, item)} + defaultValue={item.content || ''} + onCancel={() => resetCurrentItem()} {...item} /> ); @@ -79,14 +110,8 @@ export default defineComponent({ return (
{ - currentItem.id = item.id; - currentItem.parentId = item.parentId || ''; - }} - onEdit={() => { - currentItem.id = item.id; - currentItem.parentId = item.parentId || ''; - }} + onReply={() => handleReply(item)} + onEdit={() => handelEdit(item)} onDelete={() => handleDelete(item)} mode={'child'} element={item} @@ -100,11 +125,18 @@ export default defineComponent({ const renderParentList = (list: CommentItem[]) => { return list.map((item) => { return ( - handleDelete(item)} element={item}> -
- {renderChildrenList(item.childComments)} -
-
+ <> + handleReply(item)} + onEdit={() => handelEdit(item)} + onDelete={() => handleDelete(item)} + element={item} + > +
+
+ {item.id === currentItem.id && renderInput(item)} + ); }); }; diff --git a/frontend/src/components/business/ms-comment/input.vue b/frontend/src/components/business/ms-comment/input.vue index 572307316d..0d8b131074 100644 --- a/frontend/src/components/business/ms-comment/input.vue +++ b/frontend/src/components/business/ms-comment/input.vue @@ -22,28 +22,32 @@ diff --git a/frontend/src/locale/en-US/common.ts b/frontend/src/locale/en-US/common.ts index 6b49250fa8..f5e8eca78b 100644 --- a/frontend/src/locale/en-US/common.ts +++ b/frontend/src/locale/en-US/common.ts @@ -82,6 +82,7 @@ export default { 'common.newSuccess': 'Added successfully', 'common.publish': 'Publish', 'common.publishSuccessfully': 'Published successfully', + 'common.publishFailed': 'Published failed', 'common.string': 'String', 'common.number': 'Number', 'common.boolean': 'Boolean', diff --git a/frontend/src/locale/zh-CN/common.ts b/frontend/src/locale/zh-CN/common.ts index ef0169539e..c251210e02 100644 --- a/frontend/src/locale/zh-CN/common.ts +++ b/frontend/src/locale/zh-CN/common.ts @@ -83,6 +83,7 @@ export default { 'common.newSuccess': '新增成功', 'common.publish': '发布', 'common.publishSuccessfully': '发布成功', + 'common.publishFailed': '发布失败', 'common.string': '字符串', 'common.number': '数字', 'common.boolean': '布尔', diff --git a/frontend/src/views/project-management/environmental/components/envGroup/EnvGroupBox.vue b/frontend/src/views/project-management/environmental/components/EnvGroupBox.vue similarity index 98% rename from frontend/src/views/project-management/environmental/components/envGroup/EnvGroupBox.vue rename to frontend/src/views/project-management/environmental/components/EnvGroupBox.vue index 3a820d77ba..5a4899af8d 100644 --- a/frontend/src/views/project-management/environmental/components/envGroup/EnvGroupBox.vue +++ b/frontend/src/views/project-management/environmental/components/EnvGroupBox.vue @@ -49,7 +49,7 @@