fix: 修复分享链接路由与登录回跳
- 统一生成包含部署基路径和 Hash 路由的知识库、工作流分享地址 - 未登录访问分享页时保留目标地址,并在登录成功后自动回跳 - 限定分享密钥作用域并补充失效、加载失败及回归测试
This commit is contained in:
@@ -45,6 +45,7 @@ import CardPage from '#/components/page/CardList.vue';
|
||||
import PageData from '#/components/page/PageData.vue';
|
||||
import PageSide from '#/components/page/PageSide.vue';
|
||||
import { copyTextWithFeedback } from '#/utils/clipboard-feedback';
|
||||
import { buildAbsoluteAppRouteUrl } from '#/utils/share-route-context';
|
||||
import DocumentCollectionModal from '#/views/ai/documentCollection/DocumentCollectionModal.vue';
|
||||
import AiResourceCornerMeta from '#/views/ai/shared/AiResourceCornerMeta.vue';
|
||||
import { confirmPublishSubmission } from '#/views/ai/shared/approval-application-reason';
|
||||
@@ -154,10 +155,16 @@ async function shareKnowledge(row: Record<string, any>) {
|
||||
const res = await api.post('/api/v1/knowledgeShare/url/create', {
|
||||
knowledgeId: row.id,
|
||||
});
|
||||
const shareUrl = String(res.data?.shareUrl || '').trim();
|
||||
if (res.errorCode !== 0 || !shareUrl) {
|
||||
const shareKey = String(res.data?.shareKey || '').trim();
|
||||
if (res.errorCode !== 0 || !shareKey) {
|
||||
return;
|
||||
}
|
||||
const shareUrl = buildAbsoluteAppRouteUrl(
|
||||
router.resolve({
|
||||
name: 'KnowledgeShare',
|
||||
query: { shareKey },
|
||||
}).href,
|
||||
);
|
||||
await copyTextWithFeedback(
|
||||
shareUrl,
|
||||
$t('message.copySuccess'),
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, ref } from 'vue';
|
||||
import { useRouter } from 'vue-router';
|
||||
|
||||
import { $t } from '@easyflow/locales';
|
||||
|
||||
@@ -8,6 +9,7 @@ import { ElButton, ElCard, ElIcon, ElInput, ElMessage } from 'element-plus';
|
||||
|
||||
import { api } from '#/api/request';
|
||||
import { copyTextWithFeedback } from '#/utils/clipboard-feedback';
|
||||
import { buildAbsoluteAppRouteUrl } from '#/utils/share-route-context';
|
||||
|
||||
type EndpointParam = {
|
||||
location: 'body' | 'query';
|
||||
@@ -38,6 +40,7 @@ const props = defineProps({
|
||||
},
|
||||
});
|
||||
|
||||
const router = useRouter();
|
||||
const createLoading = ref(false);
|
||||
const generatedUrl = ref('');
|
||||
const generatedExpireAt = ref('');
|
||||
@@ -189,7 +192,15 @@ const createShare = async () => {
|
||||
knowledgeId: props.knowledgeId,
|
||||
});
|
||||
if (res.errorCode === 0) {
|
||||
generatedUrl.value = res.data?.shareUrl || '';
|
||||
const shareKey = String(res.data?.shareKey || '').trim();
|
||||
generatedUrl.value = shareKey
|
||||
? buildAbsoluteAppRouteUrl(
|
||||
router.resolve({
|
||||
name: 'KnowledgeShare',
|
||||
query: { shareKey },
|
||||
}).href,
|
||||
)
|
||||
: '';
|
||||
generatedExpireAt.value = res.data?.expiresAt || '';
|
||||
ElMessage.success('已创建分享链接');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user