feat(接口测试): 调整接口文档分享和校验

This commit is contained in:
xinxin.wu 2024-10-17 17:32:28 +08:00 committed by Craftsman
parent 3d3ffa6a68
commit 16203cfe1d
7 changed files with 69 additions and 14 deletions

View File

@ -666,7 +666,7 @@ export function deleteShare(id: string) {
}
// 接口测试-接口管理-分享列表
export function getSharePage(data: TableQueryParams) {
return MSR.post<CommonList<shareItem>>({ url: `${GetSharePageUrl}`, data });
return MSR.post<CommonList<shareItem>>({ url: `${GetSharePageUrl}`, data }, { ignoreCancelToken: true });
}
// 接口测试-接口管理-分享详情
export function shareDetail(id: string) {

View File

@ -19,6 +19,14 @@ const useDocShareCheckStore = defineStore('shareCheckStore', {
localStorage.setItem(key, 'true');
}
},
// 将 docShareId 和 userId 已经验证更新密码后移除验证重新验证
removeDocAsVerified(docShareId: string, userId: string) {
const key: string = `verified_${docShareId}_${userId}`;
if (!this.verifiedDocs.includes(key)) {
this.verifiedDocs = this.verifiedDocs.filter((e) => e === key);
localStorage.removeItem(key);
}
},
},
});

View File

@ -13,6 +13,7 @@
<template #right>
<ShareButton
v-if="hasAnyPermission(['PROJECT_API_DEFINITION_DOC:READ+SHARE'])"
ref="shareButtonRef"
@create="createShare"
@show-share-list="showShareList"
/>
@ -1108,6 +1109,7 @@
showShareModal.value = true;
}
const shareListRef = ref<InstanceType<typeof ShareListDrawer>>();
const shareButtonRef = ref<InstanceType<typeof ShareButton>>();
function cancelHandler() {
showShareModal.value = false;
@ -1120,6 +1122,7 @@
} else {
shareListRef.value?.searchList();
}
shareButtonRef.value?.initShareList();
}
watch(

View File

@ -62,10 +62,11 @@
<MsTimeSelectorVue v-model="invalidTimeValue" @change="handleTimeChange" />
</a-form-item>
<div class="mb-[16px] flex items-center">
<a-switch v-model:model-value="form.isPrivate" class="mr-[8px]" size="small" />
<a-switch v-model:model-value="form.isPrivate" class="mr-[8px]" size="small" @change="changePrivate" />
{{ t('apiTestManagement.passwordAccess') }}
</div>
<a-form-item
v-if="form.isPrivate"
field="password"
:label="t('apiTestManagement.effectiveTime')"
asterisk-position="end"
@ -88,8 +89,14 @@
</div>
</a-form>
<template #footer>
<a-button type="secondary" @click="handleCancel">{{ t('common.cancel') }}</a-button>
<a-button class="ml-[12px]" type="primary" :loading="confirmLoading" @click="handleConfirm">
<a-button type="secondary" :disabled="confirmLoading" @click="handleCancel">{{ t('common.cancel') }}</a-button>
<a-button
class="ml-[12px]"
:disabled="isDisabledSave"
type="primary"
:loading="confirmLoading"
@click="handleConfirm"
>
{{ okText }}
</a-button>
</template>
@ -108,13 +115,18 @@
import { addShare, getEnvModules, updateShare } from '@/api/modules/api-test/management';
import { useI18n } from '@/hooks/useI18n';
import { useAppStore } from '@/store';
import { useAppStore, useUserStore } from '@/store';
import useDocShareCheckStore from '@/store/modules/api/docShareCheck';
import { TreeNode } from '@/utils';
import type { ShareDetail } from '@/models/apiTest/management';
import type { ModuleTreeNode } from '@/models/common';
import { OperatorEnum } from '@/enums/advancedFilterEnum';
const userStore = useUserStore();
const docCheckStore = useDocShareCheckStore();
const { t } = useI18n();
const appStore = useAppStore();
@ -243,7 +255,7 @@
});
const confirmLoading = ref<boolean>(false);
const originPassword = ref<string>('');
function handleConfirm() {
formRef.value?.validate(async (errors) => {
if (!errors) {
@ -262,6 +274,12 @@
params.rangeMatchVal = moduleIds.value.join(',');
}
if (props?.record?.id) {
if (originPassword.value !== form.value.password) {
//
if (docCheckStore.isDocVerified(props?.record?.id, userStore.id || '')) {
docCheckStore.removeDocAsVerified(props?.record?.id, userStore.id || '');
}
}
await updateShare(params);
} else {
await addShare(params);
@ -310,6 +328,7 @@
function initDetail() {
if (props.record?.id) {
originPassword.value = form.value.password;
form.value = {
...props.record,
};
@ -324,6 +343,10 @@
}
}
function changePrivate() {
form.value.password = '';
}
watch(
() => innerVisible.value,
(val) => {
@ -333,6 +356,19 @@
}
}
);
const isDisabledSave = computed(() => {
switch (form.value.apiRange) {
case 'MODULE':
return !moduleIds.value.length;
case 'PATH':
return !form.value.rangeMatchVal.length;
case 'TAG':
return !tags.value.length;
default:
return false;
}
});
</script>
<style scoped></style>

View File

@ -40,12 +40,16 @@
{{ item.name }}
</div>
</a-tooltip>
<a-tooltip :disabled="!!item.apiShareNum" position="tr" :content="t('apiTestManagement.apiShareNumberTip')">
<MsIcon
type="icon-icon_copy_outlined"
class="cursor-pointer text-[var(--color-text-4)] hover:text-[rgb(var(--primary-5))]"
:class="`text-[var(--color-text-4)] ${
item.apiShareNum ? 'cursor-pointer hover:text-[rgb(var(--primary-5))]' : ''
}`"
:size="16"
@click="copyShareLink(item.id as string)"
/>
</a-tooltip>
</div>
</div>
</div>
@ -159,6 +163,10 @@
onBeforeMount(() => {
initShareList();
});
defineExpose({
initShareList,
});
</script>
<style scoped lang="less">

View File

@ -183,7 +183,7 @@ export default {
'apiTestManagement.sharePasswordPlaceholder': 'Please enter the share password',
'apiTestManagement.apiShareNum': 'Api number',
'apiTestManagement.apiShareNumberTip': 'The number of shared interfaces is 0, please check!',
'apiTestManagement.apiSharePsdError': 'Password error!',
'apiTestManagement.apiSharePsdError': 'Password error',
'apiTestManagement.allowExport': 'Allow export',
'apiTestManagement.pleaseEnterName': 'Please enter name',
'apiTestManagement.module': 'Module',

View File

@ -176,7 +176,7 @@ export default {
'apiTestManagement.sharePasswordPlaceholder': '请输入分享密码',
'apiTestManagement.apiShareNum': '接口数量',
'apiTestManagement.apiShareNumberTip': '分享的接口数量为0请检查',
'apiTestManagement.apiSharePsdError': '密码错误',
'apiTestManagement.apiSharePsdError': '密码错误',
'apiTestManagement.allowExport': '允许导出',
'apiTestManagement.pleaseEnterName': '请输入名称',
'apiTestManagement.module': '模块',