32fb2cdeaf
Add chat file/image upload UX, attachment proxying, vision thumbnails, and per-turn image scoping so agents only use the current upload. Extend MindSpace asset context, billing token state, OA/scenario verify scripts, and related runtime config. Co-authored-by: Cursor <cursoragent@cursor.com>
64 lines
2.2 KiB
TypeScript
64 lines
2.2 KiB
TypeScript
import {
|
|
resolvePlazaHomePath,
|
|
resolvePlazaPostPath,
|
|
resolvePlazaPublicBase,
|
|
} from './public-site-bases.mjs';
|
|
|
|
export function resolvePublicPageUrl(publicUrl: string): string {
|
|
const value = String(publicUrl ?? '').trim();
|
|
if (!value) return value;
|
|
if (/^https?:\/\//i.test(value)) return value;
|
|
if (value.startsWith('//')) return `${window.location.protocol}${value}`;
|
|
if (value.startsWith('/')) return `${window.location.origin}${value}`;
|
|
return `${window.location.origin}/${value.replace(/^\/+/, '')}`;
|
|
}
|
|
|
|
function resolvedPlazaBase(): string {
|
|
return resolvePlazaPublicBase({
|
|
configuredBase: import.meta.env.VITE_PLAZA_BASE,
|
|
dev: import.meta.env.DEV,
|
|
hostname: typeof window !== 'undefined' ? window.location.hostname : '',
|
|
});
|
|
}
|
|
|
|
export function resolvePlazaPostUrl(postId: string): string {
|
|
return resolvePlazaPostPath(resolvedPlazaBase(), postId);
|
|
}
|
|
|
|
export function resolvePlazaHomeUrl(): string {
|
|
return resolvePlazaHomePath(resolvedPlazaBase());
|
|
}
|
|
|
|
export function resolveMindSpaceHomeUrl(): string {
|
|
const configured = String(import.meta.env.VITE_MINDSPACE_BASE ?? '').trim();
|
|
if (configured) {
|
|
return `${configured.replace(/\/$/, '')}/space`;
|
|
}
|
|
return `${window.location.origin}/space`;
|
|
}
|
|
|
|
/** 已发布页面的独立访问链接(非空间内编辑路由)。优先 MindSpace 工作区 URL。 */
|
|
export function resolveMindSpacePagePublicViewUrl(page: {
|
|
publicationUrl?: string | null;
|
|
workspacePublicUrl?: string | null;
|
|
}): string | null {
|
|
const workspace = String(page.workspacePublicUrl ?? '').trim();
|
|
if (workspace) return resolvePublicPageUrl(workspace);
|
|
const value = String(page.publicationUrl ?? '').trim();
|
|
if (!value) return null;
|
|
return resolvePublicPageUrl(value);
|
|
}
|
|
|
|
/** @deprecated 使用 resolveMindSpacePagePublicViewUrl */
|
|
export const resolveMindSpacePageViewUrl = resolveMindSpacePagePublicViewUrl;
|
|
|
|
/** 未发布时供本人查看的预览链接(需登录,不可对外分享)。 */
|
|
export function resolveMindSpacePageOwnerPreviewUrl(page: {
|
|
id: string;
|
|
versionNo?: number;
|
|
updatedAt?: number;
|
|
}): string {
|
|
const version = page.versionNo ?? page.updatedAt ?? Date.now();
|
|
return `${window.location.origin}/api/mindspace/v1/pages/${encodeURIComponent(page.id)}/preview?v=${version}`;
|
|
}
|