Skip to content

引入

ts
import { supportPrePublish } from 't-comm';

// 不支持 tree-shaking 的项目
import { supportPrePublish} from 't-comm/lib/debug/index';

// 只支持 ESM 的项目
import { supportPrePublish} from 't-comm/es/debug/index';

supportPrePublish()

描述:支持预发布环境切换。 检测当前页面 URL 中的 tip_debug_cgi_env 参数,自动将环境标识写入 sessionStorage

  • 当 URL 包含 tip_debug_cgi_env=prod 时,将环境设置为正式环境(写入 sessionStorage)。
  • 当 URL 包含 tip_debug_cgi_env=test 时,移除环境标识(回退到测试环境)。
仅在浏览器环境下生效,SSR / Node 环境中会直接跳过。

参数

示例

ts
// 在应用入口处调用
supportPrePublish();