Commit 6182b2f5 by luoqi

fix(embed): 去掉「新建预约」插槽写死的 localhost 兜底(demo 接线泄漏)

上次把按钮从占位 toast 改成了 window.open('http://localhost:4100/appointment','_top'),
硬编码 URL 随部署上了生产 —— 线上点击会 _top 跳到用户本机 localhost 死链。
回退成原占位 toast;删除 action-urls.ts(带写死默认值的配置)。真实接入时 URL 由
宿主 actionUrls / env 下发,代码不写死。

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
parent 9cdf04ef
Pipeline #3341 failed in 0 seconds
...@@ -47,7 +47,6 @@ import { ReasonLine } from './reason-line'; ...@@ -47,7 +47,6 @@ import { ReasonLine } from './reason-line';
import { ScriptView, type ScriptViewMode } from './script-viewer'; import { ScriptView, type ScriptViewMode } from './script-viewer';
import { ScriptDeepProcess } from './script-deep-process'; import { ScriptDeepProcess } from './script-deep-process';
import { OutcomeForm } from './outcome-form'; import { OutcomeForm } from './outcome-form';
import { actionUrl } from '@/lib/action-urls';
import { Drawer, type DrawerKind } from './drawer'; import { Drawer, type DrawerKind } from './drawer';
import { Tabs, TabsList, TabsTrigger, TabsContent } from '@/components/ui/tabs'; import { Tabs, TabsList, TabsTrigger, TabsContent } from '@/components/ui/tabs';
import { useMediaQuery } from '@/hooks/use-media-query'; import { useMediaQuery } from '@/hooks/use-media-query';
...@@ -485,18 +484,10 @@ export function PlanDetailApp({ ...@@ -485,18 +484,10 @@ export function PlanDetailApp({
plan={effectivePlan} plan={effectivePlan}
onSubmit={submitOutcome} onSubmit={submitOutcome}
defaultChannel={effectivePlan.recommendedChannel} defaultChannel={effectivePlan.recommendedChannel}
onCreateAppointment={() => { onCreateAppointment={() =>
// 新建预约发生在宿主系统:直接打开宿主预约页(新标签),带患者 + 项目预填。 // 占位:真实接入时由宿主 actionUrls / env 下发 URL,代码不写死。
const url = actionUrl('createAppointment', { showToast('emerald', '打开宿主预约页', '带上患者 + 医生 + 治疗项预填')
patientId: patient.externalId, }
name: patient.nameMasked ?? patient.name,
phone: patient.phoneMasked,
reason: reasons[0]?.scenarioLabel,
cs: patient.dedicatedCs?.name,
});
window.open(url, '_top');
showToast('emerald', '已打开宿主预约页', '已带患者 + 项目预填');
}}
/> />
</div> </div>
</section> </section>
......
'use client';
/**
* 宿主动作 URL(actionUrls)——「插槽」配置。
*
* PAC 工作台里有些动作(新建预约 / 看患者档案 / 看影像原图)发生在**宿主系统**里,
* PAC 不实现,只在对应插槽用宿主提供的 URL 打开宿主页面(iframe 嵌入或跳转)。
*
* 生产:这些 URL 由宿主在接入时配置下发(换票 token / 配置接口),按 host 不同而不同。
* 这里给**演示默认值**(指向模拟宿主的新建预约页),并允许 env 覆盖,方便本地联调。
*/
const DEFAULT_ACTION_URLS = {
/** 新建预约 —— 带患者/项目预填,打开宿主预约中心 */
createAppointment: 'http://localhost:4100/appointment',
} as const;
type ActionKey = keyof typeof DEFAULT_ACTION_URLS;
const ENV_OVERRIDES: Partial<Record<ActionKey, string | undefined>> = {
createAppointment: process.env.NEXT_PUBLIC_HOST_APPOINTMENT_URL,
};
/** 取某个插槽的宿主基础 URL。 */
export function actionBaseUrl(key: ActionKey): string {
return ENV_OVERRIDES[key] || DEFAULT_ACTION_URLS[key];
}
/** 拼上下文参数,生成插槽最终 URL(供 iframe src / 跳转用)。 */
export function actionUrl(key: ActionKey, params: Record<string, string | undefined>): string {
const url = new URL(actionBaseUrl(key));
for (const [k, v] of Object.entries(params)) {
if (v) url.searchParams.set(k, v);
}
return url.toString();
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment