🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.
TypeScript agentagent-collaborationagent-harnessloop-engineeringmcppersonal-assistantproactive-agentskillssuper-agenttask-management
✨ feat(page-share): add document share flow with business slot stubs (#15309)
Innei22c264bb7700
diff --git a/locales/en-US/pageShare.json b/locales/en-US/pageShare.jsonnew file mode 100644index 00000000000..87ad426121f--- /dev/null+++ b/locales/en-US/pageShare.json@@ -0,0 +1,26 @@+{+ "banner.copy": "Like this page? <strong>Create your own with {{appName}}</strong> — free workspace for AI-native docs.",+ "banner.signIn": "Sign in",+ "banner.signUp": "Sign up free",+ "error.notFound.desc": "This page no longer exists or has been removed.",+ "error.notFound.title": "Page not found",+ "error.private.action": "Sign in",+ "error.private.desc": "Sign in if you are the owner, or ask for access from the person who shared the page.",+ "error.private.title": "Page is private",+ "popover.copyLink": "Copy Link",+ "popover.copyLinkSuccess": "Link copied",+ "popover.linkHint": "Anyone with the link can view this page",+ "popover.permissionLink": "Anyone with the link",+ "popover.permissionPrivate": "Private",+ "popover.privateHint": "Only you can access this page",+ "popover.sectionViews_one": "{{count}} view",+ "popover.sectionViews_other": "{{count}} views",+ "popover.title": "Share Page",+ "popover.updateError": "Failed to update sharing settings",+ "popover.visibility": "Visibility",+ "popover.visibilityUpdated": "Visibility updated",+ "shareButton.label": "Share",+ "shell.footer": "Published on {{appName}}",+ "shell.sharedBy": "Shared by {{name}}",+ "shell.updatedAt": "Updated {{relative}}"+}diff --git a/locales/zh-CN/pageShare.json b/locales/zh-CN/pageShare.jsonnew file mode 100644index 00000000000..57ba90d26c2--- /dev/null+++ b/locales/zh-CN/pageShare.json@@ -0,0 +1,26 @@+{+ "banner.copy": "喜欢这个页面?<strong>来 {{appName}} 创建你自己的</strong>——AI 原生工作区,免费使用。",+ "banner.signIn": "登录",+ "banner.signUp": "免费注册",+ "error.notFound.desc": "该页面不存在或已被删除。",+ "error.notFound.title": "页面未找到",+ "error.private.action": "登录",+ "error.private.desc": "若你是作者请登录,否则请向分享人申请访问权限。",+ "error.private.title": "页面为私密",+ "popover.copyLink": "复制链接",+ "popover.copyLinkSuccess": "链接已复制",+ "popover.linkHint": "拥有链接的任何人都可查看此页面",+ "popover.permissionLink": "拥有链接者",+ "popover.permissionPrivate": "私密",+ "popover.privateHint": "仅你可访问此页面",+ "popover.sectionViews_one": "{{count}} 次浏览",+ "popover.sectionViews_other": "{{count}} 次浏览",+ "popover.title": "分享页面",+ "popover.updateError": "更新分享设置失败",+ "popover.visibility": "可见性",+ "popover.visibilityUpdated": "可见性已更新",+ "shareButton.label": "分享",+ "shell.footer": "由 {{appName}} 发布",+ "shell.sharedBy": "由 {{name}} 分享",+ "shell.updatedAt": "更新于 {{relative}}"+}diff --git a/packages/database/src/models/__tests__/documentShare.test.ts b/packages/database/src/models/__tests__/documentShare.test.tsnew file mode 100644index 00000000000..323823e2bfe--- /dev/null+++ b/packages/database/src/models/__tests__/documentShare.test.ts@@ -0,0 +1,239 @@+// @vitest-environment node+import { TRPCError } from '@trpc/server';+import { afterEach, beforeEach, describe, expect, it } from 'vitest';++import { getTestDB } from '../../core/getTestDB';+import { documents, documentShares, users } from '../../schemas';+import type { LobeChatDatabase } from '../../type';+import { DocumentShareModel } from '../documentShare';++const serverDB: LobeChatDatabase = await getTestDB();++const userId = 'doc-share-test-user-id';+const userId2 = 'doc-share-test-user-id-2';+const docId = 'doc-share-test-doc';+const docId2User2 = 'doc-share-test-doc-user2';++const shareModel = new DocumentShareModel(serverDB, userId);+const shareModelOther = new DocumentShareModel(serverDB, userId2);++const baseDocFields = {+ fileType: 'text/markdown',+ source: 'editor',+ sourceType: 'agent' as const,+ totalCharCount: 0,+ totalLineCount: 0,+};++beforeEach(async () => {+ await serverDB.delete(users);+ await serverDB.transaction(async (tx) => {+ await tx.insert(users).values([+ { id: userId, fullName: 'Alice', avatar: 'alice.png' },+ { id: userId2, fullName: 'Bob', avatar: 'bob.png' },+ ]);+ await tx.insert(documents).values([+ { id: docId, userId, title: 'Doc 1', ...baseDocFields },+ { id: docId2User2, userId: userId2, title: 'Doc 2', ...baseDocFields },+ ]);+ });+});++afterEach(async () => {+ await serverDB.delete(documentShares);+ await serverDB.delete(documents);+ await serverDB.delete(users);+});++describe('DocumentShareModel', () => {+ describe('create', () => {+ it('creates a share with default private visibility and read permission', async () => {+ const result = await shareModel.create(docId);+ expect(result).toBeDefined();+ expect(result!.documentId).toBe(docId);+ expect(result!.userId).toBe(userId);+ expect(result!.visibility).toBe('private');+ expect(result!.permission).toBe('read');+ });++ it('creates a share with link visibility', async () => {+ const result = await shareModel.create(docId, { visibility: 'link' });+ expect(result!.visibility).toBe('link');+ expect(result!.permission).toBe('read');+ });++ it('throws when document does not exist', async () => {+ await expect(shareModel.create('missing')).rejects.toThrow(+ 'Document not found or not owned by user',+ );+ });++ it('throws when document belongs to another user', async () => {+ await expect(shareModel.create(docId2User2)).rejects.toThrow(+ 'Document not found or not owned by user',+ );+ });++ it('returns the existing share on duplicate create', async () => {+ const first = await shareModel.create(docId, { visibility: 'link' });+ const second = await shareModel.create(docId);+ expect(second!.id).toBe(first!.id);+ expect(second!.visibility).toBe('link');+ });+ });++ describe('updateVisibility', () => {+ it('updates the visibility on an existing share', async () => {+ await shareModel.create(docId, { visibility: 'private' });+ const result = await shareModel.updateVisibility(docId, 'link');+ expect(result!.visibility).toBe('link');+ });++ it('returns null when no share exists', async () => {+ const result = await shareModel.updateVisibility(docId, 'link');+ expect(result).toBeNull();+ });++ it('does not affect another users share', async () => {+ await shareModelOther.create(docId2User2, { visibility: 'private' });+ const result = await shareModel.updateVisibility(docId2User2, 'link');+ expect(result).toBeNull();++ const owned = await shareModelOther.getByDocumentId(docId2User2);+ expect(owned!.visibility).toBe('private');+ });+ });++ describe('updatePermission', () => {+ it('updates the permission on an existing share', async () => {+ await shareModel.create(docId, { visibility: 'link' });+ const result = await shareModel.updatePermission(docId, 'comment');+ expect(result!.permission).toBe('comment');+ });++ it('returns null when no share exists', async () => {+ const result = await shareModel.updatePermission(docId, 'comment');+ expect(result).toBeNull();+ });+ });++ describe('deleteByDocumentId', () => {+ it('deletes the share row', async () => {+ await shareModel.create(docId);+ await shareModel.deleteByDocumentId(docId);+ const result = await shareModel.getByDocumentId(docId);+ expect(result).toBeNull();+ });++ it('does not delete another users share', async () => {+ await shareModelOther.create(docId2User2);+ await shareModel.deleteByDocumentId(docId2User2);+ const result = await shareModelOther.getByDocumentId(docId2User2);+ expect(result).not.toBeNull();+ });+ });++ describe('getByDocumentId', () => {+ it('returns null when no share', async () => {+ const result = await shareModel.getByDocumentId(docId);+ expect(result).toBeNull();+ });++ it('returns the share when owner queries', async () => {+ const created = await shareModel.create(docId, { visibility: 'link' });+ const result = await shareModel.getByDocumentId(docId);+ expect(result!.id).toBe(created!.id);+ expect(result!.visibility).toBe('link');+ });++ it('does not leak another users share', async () => {+ await shareModelOther.create(docId2User2);+ const result = await shareModel.getByDocumentId(docId2User2);+ expect(result).toBeNull();+ });+ });++ describe('findByDocumentIdWithAccessCheck (static)', () => {+ it('returns isOwner=true for the owner regardless of visibility', async () => {+ await shareModel.create(docId, { visibility: 'private' });+ const result = await DocumentShareModel.findByDocumentIdWithAccessCheck(+ serverDB,+ docId,+ userId,+ );+ expect(result.isOwner).toBe(true);+ expect(result.visibility).toBe('private');+ });++ it('returns isOwner=true for the owner even when no share row exists', async () => {+ const result = await DocumentShareModel.findByDocumentIdWithAccessCheck(+ serverDB,+ docId,+ userId,+ );+ expect(result.isOwner).toBe(true);+ expect(result.visibility).toBe('private');+ });++ it('returns isOwner=false for anonymous when visibility is link', async () => {+ await shareModel.create(docId, { visibility: 'link' });+ const result = await DocumentShareModel.findByDocumentIdWithAccessCheck(+ serverDB,+ docId,+ undefined,+ );+ expect(result.isOwner).toBe(false);+ expect(result.visibility).toBe('link');+ expect(result.ownerDisplayName).toBe('Alice');+ });++ it('throws NOT_FOUND when document does not exist', async () => {+ await expect(+ DocumentShareModel.findByDocumentIdWithAccessCheck(serverDB, 'missing', userId),+ ).rejects.toThrow(TRPCError);++ try {+ await DocumentShareModel.findByDocumentIdWithAccessCheck(serverDB, 'missing', userId);+ } catch (error) {+ expect((error as TRPCError).code).toBe('NOT_FOUND');+ }+ });++ it('throws FORBIDDEN when visibility is private and user is not owner', async () => {+ await shareModel.create(docId, { visibility: 'private' });+ await expect(+ DocumentShareModel.findByDocumentIdWithAccessCheck(serverDB, docId, userId2),+ ).rejects.toThrow(TRPCError);++ try {+ await DocumentShareModel.findByDocumentIdWithAccessCheck(serverDB, docId, userId2);+ } catch (error) {+ expect((error as TRPCError).code).toBe('FORBIDDEN');+ }+ });++ it('throws FORBIDDEN when no share row exists and user is not owner', async () => {+ try {+ await DocumentShareModel.findByDocumentIdWithAccessCheck(serverDB, docId, userId2);+ throw new Error('should not reach');+ } catch (error) {+ expect((error as TRPCError).code).toBe('FORBIDDEN');+ }+ });+ });++ describe('incrementPageViewCount (static)', () => {+ it('increments the count for an existing share', async () => {+ await shareModel.create(docId, { visibility: 'link' });++ const initial = await shareModel.getByDocumentId(docId);+ expect(initial!.pageViewCount).toBe(0);++ await DocumentShareModel.incrementPageViewCount(serverDB, docId);+ await DocumentShareModel.incrementPageViewCount(serverDB, docId);++ const after = await shareModel.getByDocumentId(docId);+ expect(after!.pageViewCount).toBe(2);+ });+ });+});diff --git a/packages/database/src/models/documentShare.ts b/packages/database/src/models/documentShare.tsnew file mode 100644index 00000000000..c0ea335ac6c--- /dev/null+++ b/packages/database/src/models/documentShare.ts@@ -0,0 +1,164 @@+import type { DocumentSharePermission, DocumentShareVisibility } from '@lobechat/types';+import { TRPCError } from '@trpc/server';+import { and, eq, sql } from 'drizzle-orm';++import { documents, documentShares, users } from '../schemas';+import type { LobeChatDatabase } from '../type';++export interface DocumentShareAccessResult {+ document: typeof documents.$inferSelect;+ isOwner: boolean;+ ownerAvatar: string | null;+ ownerDisplayName: string | null;+ pageViewCount: number;+ permission: DocumentSharePermission;+ visibility: DocumentShareVisibility;+}++export class DocumentShareModel {+ private userId: string;+ private db: LobeChatDatabase;++ constructor(db: LobeChatDatabase, userId: string) {+ this.userId = userId;+ this.db = db;+ }++ create = async (+ documentId: string,+ params: {+ permission?: DocumentSharePermission;+ visibility?: DocumentShareVisibility;+ } = {},+ ) => {+ const [doc] = await this.db+ .select({ id: documents.id })+ .from(documents)+ .where(and(eq(documents.id, documentId), eq(documents.userId, this.userId)))+ .limit(1);++ if (!doc) {+ throw new Error('Document not found or not owned by user');+ }++ const [result] = await this.db+ .insert(documentShares)+ .values({+ documentId,+ permission: params.permission ?? 'read',+ userId: this.userId,+ visibility: params.visibility ?? 'private',+ })+ .onConflictDoNothing({ target: documentShares.documentId })+ .returning();++ if (!result) {+ return this.getByDocumentId(documentId);+ }++ return result;+ };++ updateVisibility = async (documentId: string, visibility: DocumentShareVisibility) => {+ const [result] = await this.db+ .update(documentShares)+ .set({ updatedAt: new Date(), visibility })+ .where(and(eq(documentShares.documentId, documentId), eq(documentShares.userId, this.userId)))+ .returning();++ return result || null;+ };++ updatePermission = async (documentId: string, permission: DocumentSharePermission) => {+ const [result] = await this.db+ .update(documentShares)+ .set({ permission, updatedAt: new Date() })+ .where(and(eq(documentShares.documentId, documentId), eq(documentShares.userId, this.userId)))+ .returning();++ return result || null;+ };++ deleteByDocumentId = async (documentId: string) => {+ return this.db+ .delete(documentShares)+ .where(+ and(eq(documentShares.documentId, documentId), eq(documentShares.userId, this.userId)),+ );+ };++ getByDocumentId = async (documentId: string) => {+ const result = await this.db+ .select({+ documentId: documentShares.documentId,+ id: documentShares.id,+ pageViewCount: documentShares.pageViewCount,+ permission: documentShares.permission,+ userId: documentShares.userId,+ visibility: documentShares.visibility,+ })+ .from(documentShares)+ .where(and(eq(documentShares.documentId, documentId), eq(documentShares.userId, this.userId)))+ .limit(1);++ return result[0] || null;+ };++ static findByDocumentId = async (db: LobeChatDatabase, documentId: string) => {+ const result = await db+ .select({+ document: documents,+ ownerAvatar: users.avatar,+ ownerDisplayName: users.fullName,+ pageViewCount: documentShares.pageViewCount,+ permission: documentShares.permission,+ shareUserId: documentShares.userId,+ visibility: documentShares.visibility,+ })+ .from(documents)+ .leftJoin(documentShares, eq(documentShares.documentId, documents.id))+ .leftJoin(users, eq(users.id, documents.userId))+ .where(eq(documents.id, documentId))+ .limit(1);++ return result[0] || null;+ };++ static incrementPageViewCount = async (db: LobeChatDatabase, documentId: string) => {+ await db+ .update(documentShares)+ .set({ pageViewCount: sql`${documentShares.pageViewCount} + 1` })+ .where(eq(documentShares.documentId, documentId));+ };++ static findByDocumentIdWithAccessCheck = async (+ db: LobeChatDatabase,+ documentId: string,+ accessUserId?: string,+ ): Promise<DocumentShareAccessResult> => {+ const row = await DocumentShareModel.findByDocumentId(db, documentId);++ if (!row) {+ throw new TRPCError({ code: 'NOT_FOUND', message: 'Document not found' });+ }++ const isOwner = !!accessUserId && row.document.userId === accessUserId;++ if (!isOwner) {+ const hasShare = !!row.visibility;+ if (!hasShare || row.visibility === 'private') {+ throw new TRPCError({ code: 'FORBIDDEN', message: 'This page is private' });+ }+ }++ return {+ document: row.document,+ isOwner,+ ownerAvatar: row.ownerAvatar,+ ownerDisplayName: row.ownerDisplayName,+ pageViewCount: row.pageViewCount ?? 0,+ permission: (row.permission ?? 'read') as DocumentSharePermission,+ visibility: (row.visibility ?? 'private') as DocumentShareVisibility,+ };+ };+}diff --git a/packages/types/src/document/index.ts b/packages/types/src/document/index.tsindex c2519127e7f..ca39da51ec8 100644--- a/packages/types/src/document/index.ts+++ b/packages/types/src/document/index.ts@@ -1,3 +1,5 @@+export * from './share';+/*** Document object in LobeChat*/diff --git a/packages/types/src/document/share.ts b/packages/types/src/document/share.tsnew file mode 100644index 00000000000..8b7e6790c69--- /dev/null+++ b/packages/types/src/document/share.ts@@ -0,0 +1,36 @@+export type DocumentShareVisibility = 'private' | 'link';++export type DocumentSharePermission = 'read' | 'comment' | 'edit';++export interface DocumentShareInfo {+ documentId: string;+ pageViewCount: number;+ permission: DocumentSharePermission;+ visibility: DocumentShareVisibility;+}++export interface SharedDocumentOwnerMeta {+ avatar: string | null;+ displayName: string | null;+}++export interface SharedDocumentPayload {+ content: string | null;+ description: string | null;+ editorData: Record<string, unknown> | null;+ fileType: string;+ id: string;+ metadata: Record<string, unknown> | null;+ pages: unknown[] | null;+ title: string | null;+ updatedAt: Date;+}++export interface SharedDocumentData {+ document: SharedDocumentPayload;+ isOwner: boolean;+ ownerMeta: SharedDocumentOwnerMeta;+ pageViewCount: number;+ permission: DocumentSharePermission;+ visibility: DocumentShareVisibility;+}diff --git a/src/business/client/features/PageShare/PublishedShell.tsx b/src/business/client/features/PageShare/PublishedShell.tsxnew file mode 100644index 00000000000..be6e53bede6--- /dev/null+++ b/src/business/client/features/PageShare/PublishedShell.tsx@@ -0,0 +1,12 @@+import { type SharedDocumentData } from '@lobechat/types';+import { type ReactNode } from 'react';++interface PublishedShellProps {+ children: ReactNode;+ data?: SharedDocumentData;+ error?: unknown;+}++export default function PublishedShell({ children }: PublishedShellProps) {+ return <>{children}</>;+}diff --git a/src/business/client/features/PageShare/ReadOnlyPageViewer.tsx b/src/business/client/features/PageShare/ReadOnlyPageViewer.tsxnew file mode 100644index 00000000000..3486282605c--- /dev/null+++ b/src/business/client/features/PageShare/ReadOnlyPageViewer.tsx@@ -0,0 +1,5 @@+import { type SharedDocumentData } from '@lobechat/types';++export default function ReadOnlyPageViewer(_: { data: SharedDocumentData }) {+ return null;+}diff --git a/src/business/client/features/PageShare/ShareButton.tsx b/src/business/client/features/PageShare/ShareButton.tsxnew file mode 100644index 00000000000..20546461d7d--- /dev/null+++ b/src/business/client/features/PageShare/ShareButton.tsx@@ -0,0 +1,3 @@+export default function ShareButton(_: { documentId: string }) {+ return null;+}diff --git a/src/business/server/lambda-routers/pageShare.ts b/src/business/server/lambda-routers/pageShare.tsnew file mode 100644index 00000000000..4acbe3f7484--- /dev/null+++ b/src/business/server/lambda-routers/pageShare.ts@@ -0,0 +1,29 @@+import type { SharedDocumentData } from '@lobechat/types';+import { TRPCError } from '@trpc/server';+import { z } from 'zod';++import { authedProcedure, publicProcedure, router } from '@/libs/trpc/lambda';++export const pageShareRouter = router({+ getShareSettings: authedProcedure+ .input(z.object({ id: z.string() }))+ .query(+ async () => null as { pageViewCount: number; permission: string; visibility: string } | null,+ ),++ updateShareSettings: authedProcedure+ .input(+ z.object({+ id: z.string(),+ permission: z.enum(['read']).default('read'),+ visibility: z.enum(['private', 'link']),+ }),+ )+ .mutation(async () => null),++ getSharedDocument: publicProcedure+ .input(z.object({ documentId: z.string() }))+ .query(async (): Promise<SharedDocumentData> => {+ throw new TRPCError({ code: 'NOT_FOUND', message: 'Page sharing is not available' });+ }),+});diff --git a/src/features/PageEditor/Header/index.tsx b/src/features/PageEditor/Header/index.tsxindex 9c06b59c646..c07704397d9 100644--- a/src/features/PageEditor/Header/index.tsx+++ b/src/features/PageEditor/Header/index.tsx@@ -5,6 +5,7 @@ import { ArrowLeftIcon, MoreHorizontal } from 'lucide-react';import { memo } from 'react';import { useTranslation } from 'react-i18next';+import ShareButton from '@/business/client/features/PageShare/ShareButton';import { DESKTOP_HEADER_ICON_SMALL_SIZE } from '@/const/layoutTokens';import { AutoSaveHint } from '@/features/EditorCanvas';import NavHeader from '@/features/NavHeader';@@ -50,6 +51,7 @@ const Header = memo(() => {}right={<>+ {documentId && <ShareButton documentId={documentId} />}{/* Three-dot menu */}<DropdownMenuiconSpaceMode="group"diff --git a/src/locales/default/index.ts b/src/locales/default/index.tsindex 149f2635320..0207bec38a3 100644--- a/src/locales/default/index.ts+++ b/src/locales/default/index.ts@@ -31,6 +31,7 @@ import notification from './notification';import oauth from './oauth';import onboarding from './onboarding';import openInApp from './openInApp';+import pageShare from './pageShare';import plugin from './plugin';import portal from './portal';import providers from './providers';@@ -81,6 +82,7 @@ const resources = {oauth,onboarding,openInApp,+ pageShare,plugin,portal,providers,diff --git a/src/locales/default/pageShare.ts b/src/locales/default/pageShare.tsnew file mode 100644index 00000000000..759609fec97--- /dev/null+++ b/src/locales/default/pageShare.ts@@ -0,0 +1,29 @@+// Cloud-only feature; namespace kept here so locale dictionary stays centralized.+export default {+ 'banner.copy':+ 'Like this page? <strong>Create your own with {{appName}}</strong> — free workspace for AI-native docs.',+ 'banner.signIn': 'Sign in',+ 'banner.signUp': 'Sign up free',+ 'error.notFound.desc': 'This page no longer exists or has been removed.',+ 'error.notFound.title': 'Page not found',+ 'error.private.action': 'Sign in',+ 'error.private.desc':+ 'Sign in if you are the owner, or ask for access from the person who shared the page.',+ 'error.private.title': 'Page is private',+ 'popover.copyLink': 'Copy Link',+ 'popover.copyLinkSuccess': 'Link copied',+ 'popover.linkHint': 'Anyone with the link can view this page',+ 'popover.permissionLink': 'Anyone with the link',+ 'popover.permissionPrivate': 'Private',+ 'popover.privateHint': 'Only you can access this page',+ 'popover.sectionViews_one': '{{count}} view',+ 'popover.sectionViews_other': '{{count}} views',+ 'popover.title': 'Share Page',+ 'popover.updateError': 'Failed to update sharing settings',+ 'popover.visibility': 'Visibility',+ 'popover.visibilityUpdated': 'Visibility updated',+ 'shareButton.label': 'Share',+ 'shell.footer': 'Published on {{appName}}',+ 'shell.sharedBy': 'Shared by {{name}}',+ 'shell.updatedAt': 'Updated {{relative}}',+};diff --git a/src/routes/(main)/page/[id]/index.tsx b/src/routes/(main)/page/[id]/index.tsxindex e588b555ad7..5f0b945b531 100644--- a/src/routes/(main)/page/[id]/index.tsx+++ b/src/routes/(main)/page/[id]/index.tsx@@ -15,12 +15,13 @@ const PagesPage = memo(() => {const params = useParams<{ id: string }>();const pageId = getIdFromIdentifier(params.id ?? '', 'docs');- storeUpdater('selectedPageId', pageId);useUnmount(() => {usePageStore.setState({ selectedPageId: undefined });});+ storeUpdater('selectedPageId', pageId);+return (<Suspense fallback={<Loading debugId="PagesPage" />}><PageExplorer pageId={pageId} />diff --git a/src/routes/share/page/[id]/index.tsx b/src/routes/share/page/[id]/index.tsxnew file mode 100644index 00000000000..f5c672b4dc5--- /dev/null+++ b/src/routes/share/page/[id]/index.tsx@@ -0,0 +1,41 @@+'use client';++import { Center } from '@lobehub/ui';+import { memo } from 'react';+import { useParams } from 'react-router-dom';+import useSWR from 'swr';++import PublishedShell from '@/business/client/features/PageShare/PublishedShell';+import ReadOnlyPageViewer from '@/business/client/features/PageShare/ReadOnlyPageViewer';+import Loading from '@/components/Loading/BrandTextLoading';+import { lambdaClient } from '@/libs/trpc/client';+import { getIdFromIdentifier } from '@/utils/identifier';++const SharePagePage = memo(() => {+ const { id } = useParams<{ id: string }>();+ const documentId = getIdFromIdentifier(id ?? '', 'docs');++ const { data, error, isLoading } = useSWR(+ documentId ? ['pageShare.getSharedDocument', documentId] : null,+ () => lambdaClient.pageShare.getSharedDocument.query({ documentId }),+ { revalidateOnFocus: false },+ );++ if (!error && isLoading) {+ return (+ <Center height={'100vh'}>+ <Loading debugId="SharePagePage" />+ </Center>+ );+ }++ return (+ <PublishedShell data={data} error={error}>+ {data ? <ReadOnlyPageViewer data={data} /> : null}+ </PublishedShell>+ );+});++SharePagePage.displayName = 'SharePagePage';++export default SharePagePage;diff --git a/src/server/routers/lambda/index.ts b/src/server/routers/lambda/index.tsindex 4d95ff9ab12..230b6fbd1d9 100644--- a/src/server/routers/lambda/index.ts+++ b/src/server/routers/lambda/index.ts@@ -2,6 +2,7 @@* This file contains the root router of Lobe Chat tRPC-backend*/import { accountDeletionRouter } from '@/business/server/lambda-routers/accountDeletion';+import { pageShareRouter } from '@/business/server/lambda-routers/pageShare';import { referralRouter } from '@/business/server/lambda-routers/referral';import { spendRouter } from '@/business/server/lambda-routers/spend';import { subscriptionRouter } from '@/business/server/lambda-routers/subscription';@@ -129,6 +130,7 @@ export const lambdaRouter = router({video: videoRouter,webBrowsing: webBrowsingRouter,accountDeletion: accountDeletionRouter,+ pageShare: pageShareRouter,referral: referralRouter,spend: spendRouter,subscription: subscriptionRouter,diff --git a/src/spa/router/desktopRouter.config.desktop.tsx b/src/spa/router/desktopRouter.config.desktop.tsxindex e922c1c02ae..56e8cb834bb 100644--- a/src/spa/router/desktopRouter.config.desktop.tsx+++ b/src/spa/router/desktopRouter.config.desktop.tsx@@ -91,6 +91,7 @@ import { settingsRouteMeta } from '@/routes/(main)/settings/features/routeMeta';import { ProviderDetailPage, ProviderLayout } from '@/routes/(main)/settings/provider';import TaskDetailRoute from '@/routes/(main)/task/[taskId]';import AllTasksPage from '@/routes/(main)/tasks';+import SharePagePage from '@/routes/share/page/[id]';import ShareTopicPage from '@/routes/share/t/[id]';import ShareTopicLayout from '@/routes/share/t/[id]/_layout';import { routeMeta } from '@/spa/router/routeMeta';@@ -596,6 +597,17 @@ export const desktopRoutes: RouteObject[] = [path: '/share/t',},+ // Share page route (outside main layout)+ {+ children: [+ {+ element: <SharePagePage />,+ path: ':id',+ },+ ],+ path: '/share/page',+ },+// Devtools route (outside main layout, dev-only)...(__DEV__? [diff --git a/src/spa/router/desktopRouter.config.tsx b/src/spa/router/desktopRouter.config.tsxindex 84877b27b04..564b4d0e086 100644--- a/src/spa/router/desktopRouter.config.tsx+++ b/src/spa/router/desktopRouter.config.tsx@@ -720,6 +720,17 @@ export const desktopRoutes: RouteObject[] = [path: '/share/t',},+ // Share page route (outside main layout)+ {+ children: [+ {+ element: dynamicElement(() => import('@/routes/share/page/[id]'), 'Desktop > Share > Page'),+ path: ':id',+ },+ ],+ path: '/share/page',+ },+// Devtools route (outside main layout, dev-only)...(__DEV__? [diff --git a/src/spa/router/mobileRouter.config.tsx b/src/spa/router/mobileRouter.config.tsxindex 2ccac8a6e8e..075f564e75e 100644--- a/src/spa/router/mobileRouter.config.tsx+++ b/src/spa/router/mobileRouter.config.tsx@@ -397,4 +397,15 @@ export const mobileRoutes: RouteObject[] = [),path: '/share/t',},++ // Share page route (outside main layout)+ {+ children: [+ {+ element: dynamicElement(() => import('@/routes/share/page/[id]'), 'Mobile > Share > Page'),+ path: ':id',+ },+ ],+ path: '/share/page',+ },];