feat(接口测试): 调整接口文档分享和校验
This commit is contained in:
parent
3d3ffa6a68
commit
16203cfe1d
|
@ -666,7 +666,7 @@ export function deleteShare(id: string) {
|
||||||
}
|
}
|
||||||
// 接口测试-接口管理-分享列表
|
// 接口测试-接口管理-分享列表
|
||||||
export function getSharePage(data: TableQueryParams) {
|
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) {
|
export function shareDetail(id: string) {
|
||||||
|
|
|
@ -19,6 +19,14 @@ const useDocShareCheckStore = defineStore('shareCheckStore', {
|
||||||
localStorage.setItem(key, 'true');
|
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);
|
||||||
|
}
|
||||||
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
<template #right>
|
<template #right>
|
||||||
<ShareButton
|
<ShareButton
|
||||||
v-if="hasAnyPermission(['PROJECT_API_DEFINITION_DOC:READ+SHARE'])"
|
v-if="hasAnyPermission(['PROJECT_API_DEFINITION_DOC:READ+SHARE'])"
|
||||||
|
ref="shareButtonRef"
|
||||||
@create="createShare"
|
@create="createShare"
|
||||||
@show-share-list="showShareList"
|
@show-share-list="showShareList"
|
||||||
/>
|
/>
|
||||||
|
@ -1108,6 +1109,7 @@
|
||||||
showShareModal.value = true;
|
showShareModal.value = true;
|
||||||
}
|
}
|
||||||
const shareListRef = ref<InstanceType<typeof ShareListDrawer>>();
|
const shareListRef = ref<InstanceType<typeof ShareListDrawer>>();
|
||||||
|
const shareButtonRef = ref<InstanceType<typeof ShareButton>>();
|
||||||
|
|
||||||
function cancelHandler() {
|
function cancelHandler() {
|
||||||
showShareModal.value = false;
|
showShareModal.value = false;
|
||||||
|
@ -1120,6 +1122,7 @@
|
||||||
} else {
|
} else {
|
||||||
shareListRef.value?.searchList();
|
shareListRef.value?.searchList();
|
||||||
}
|
}
|
||||||
|
shareButtonRef.value?.initShareList();
|
||||||
}
|
}
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
|
|
|
@ -62,10 +62,11 @@
|
||||||
<MsTimeSelectorVue v-model="invalidTimeValue" @change="handleTimeChange" />
|
<MsTimeSelectorVue v-model="invalidTimeValue" @change="handleTimeChange" />
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
<div class="mb-[16px] flex items-center">
|
<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') }}
|
{{ t('apiTestManagement.passwordAccess') }}
|
||||||
</div>
|
</div>
|
||||||
<a-form-item
|
<a-form-item
|
||||||
|
v-if="form.isPrivate"
|
||||||
field="password"
|
field="password"
|
||||||
:label="t('apiTestManagement.effectiveTime')"
|
:label="t('apiTestManagement.effectiveTime')"
|
||||||
asterisk-position="end"
|
asterisk-position="end"
|
||||||
|
@ -88,8 +89,14 @@
|
||||||
</div>
|
</div>
|
||||||
</a-form>
|
</a-form>
|
||||||
<template #footer>
|
<template #footer>
|
||||||
<a-button type="secondary" @click="handleCancel">{{ t('common.cancel') }}</a-button>
|
<a-button type="secondary" :disabled="confirmLoading" @click="handleCancel">{{ t('common.cancel') }}</a-button>
|
||||||
<a-button class="ml-[12px]" type="primary" :loading="confirmLoading" @click="handleConfirm">
|
<a-button
|
||||||
|
class="ml-[12px]"
|
||||||
|
:disabled="isDisabledSave"
|
||||||
|
type="primary"
|
||||||
|
:loading="confirmLoading"
|
||||||
|
@click="handleConfirm"
|
||||||
|
>
|
||||||
{{ okText }}
|
{{ okText }}
|
||||||
</a-button>
|
</a-button>
|
||||||
</template>
|
</template>
|
||||||
|
@ -108,13 +115,18 @@
|
||||||
|
|
||||||
import { addShare, getEnvModules, updateShare } from '@/api/modules/api-test/management';
|
import { addShare, getEnvModules, updateShare } from '@/api/modules/api-test/management';
|
||||||
import { useI18n } from '@/hooks/useI18n';
|
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 { TreeNode } from '@/utils';
|
||||||
|
|
||||||
import type { ShareDetail } from '@/models/apiTest/management';
|
import type { ShareDetail } from '@/models/apiTest/management';
|
||||||
import type { ModuleTreeNode } from '@/models/common';
|
import type { ModuleTreeNode } from '@/models/common';
|
||||||
import { OperatorEnum } from '@/enums/advancedFilterEnum';
|
import { OperatorEnum } from '@/enums/advancedFilterEnum';
|
||||||
|
|
||||||
|
const userStore = useUserStore();
|
||||||
|
|
||||||
|
const docCheckStore = useDocShareCheckStore();
|
||||||
|
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const appStore = useAppStore();
|
const appStore = useAppStore();
|
||||||
|
|
||||||
|
@ -243,7 +255,7 @@
|
||||||
});
|
});
|
||||||
|
|
||||||
const confirmLoading = ref<boolean>(false);
|
const confirmLoading = ref<boolean>(false);
|
||||||
|
const originPassword = ref<string>('');
|
||||||
function handleConfirm() {
|
function handleConfirm() {
|
||||||
formRef.value?.validate(async (errors) => {
|
formRef.value?.validate(async (errors) => {
|
||||||
if (!errors) {
|
if (!errors) {
|
||||||
|
@ -262,6 +274,12 @@
|
||||||
params.rangeMatchVal = moduleIds.value.join(',');
|
params.rangeMatchVal = moduleIds.value.join(',');
|
||||||
}
|
}
|
||||||
if (props?.record?.id) {
|
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);
|
await updateShare(params);
|
||||||
} else {
|
} else {
|
||||||
await addShare(params);
|
await addShare(params);
|
||||||
|
@ -310,6 +328,7 @@
|
||||||
|
|
||||||
function initDetail() {
|
function initDetail() {
|
||||||
if (props.record?.id) {
|
if (props.record?.id) {
|
||||||
|
originPassword.value = form.value.password;
|
||||||
form.value = {
|
form.value = {
|
||||||
...props.record,
|
...props.record,
|
||||||
};
|
};
|
||||||
|
@ -324,6 +343,10 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function changePrivate() {
|
||||||
|
form.value.password = '';
|
||||||
|
}
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => innerVisible.value,
|
() => innerVisible.value,
|
||||||
(val) => {
|
(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>
|
</script>
|
||||||
|
|
||||||
<style scoped></style>
|
<style scoped></style>
|
||||||
|
|
|
@ -40,12 +40,16 @@
|
||||||
{{ item.name }}
|
{{ item.name }}
|
||||||
</div>
|
</div>
|
||||||
</a-tooltip>
|
</a-tooltip>
|
||||||
|
<a-tooltip :disabled="!!item.apiShareNum" position="tr" :content="t('apiTestManagement.apiShareNumberTip')">
|
||||||
<MsIcon
|
<MsIcon
|
||||||
type="icon-icon_copy_outlined"
|
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"
|
:size="16"
|
||||||
@click="copyShareLink(item.id as string)"
|
@click="copyShareLink(item.id as string)"
|
||||||
/>
|
/>
|
||||||
|
</a-tooltip>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -159,6 +163,10 @@
|
||||||
onBeforeMount(() => {
|
onBeforeMount(() => {
|
||||||
initShareList();
|
initShareList();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
defineExpose({
|
||||||
|
initShareList,
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="less">
|
<style scoped lang="less">
|
||||||
|
|
|
@ -183,7 +183,7 @@ export default {
|
||||||
'apiTestManagement.sharePasswordPlaceholder': 'Please enter the share password',
|
'apiTestManagement.sharePasswordPlaceholder': 'Please enter the share password',
|
||||||
'apiTestManagement.apiShareNum': 'Api number',
|
'apiTestManagement.apiShareNum': 'Api number',
|
||||||
'apiTestManagement.apiShareNumberTip': 'The number of shared interfaces is 0, please check!',
|
'apiTestManagement.apiShareNumberTip': 'The number of shared interfaces is 0, please check!',
|
||||||
'apiTestManagement.apiSharePsdError': 'Password error!',
|
'apiTestManagement.apiSharePsdError': 'Password error',
|
||||||
'apiTestManagement.allowExport': 'Allow export',
|
'apiTestManagement.allowExport': 'Allow export',
|
||||||
'apiTestManagement.pleaseEnterName': 'Please enter name',
|
'apiTestManagement.pleaseEnterName': 'Please enter name',
|
||||||
'apiTestManagement.module': 'Module',
|
'apiTestManagement.module': 'Module',
|
||||||
|
|
|
@ -176,7 +176,7 @@ export default {
|
||||||
'apiTestManagement.sharePasswordPlaceholder': '请输入分享密码',
|
'apiTestManagement.sharePasswordPlaceholder': '请输入分享密码',
|
||||||
'apiTestManagement.apiShareNum': '接口数量',
|
'apiTestManagement.apiShareNum': '接口数量',
|
||||||
'apiTestManagement.apiShareNumberTip': '分享的接口数量为0,请检查!',
|
'apiTestManagement.apiShareNumberTip': '分享的接口数量为0,请检查!',
|
||||||
'apiTestManagement.apiSharePsdError': '密码错误!',
|
'apiTestManagement.apiSharePsdError': '密码错误',
|
||||||
'apiTestManagement.allowExport': '允许导出',
|
'apiTestManagement.allowExport': '允许导出',
|
||||||
'apiTestManagement.pleaseEnterName': '请输入名称',
|
'apiTestManagement.pleaseEnterName': '请输入名称',
|
||||||
'apiTestManagement.module': '模块',
|
'apiTestManagement.module': '模块',
|
||||||
|
|
Loading…
Reference in New Issue