@wanlianyida/portal-kit 0.1.5 → 0.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -26,11 +26,11 @@ pnpm add @wanlianyida/portal-kit
26
26
 
27
27
  ```vue
28
28
  <script setup lang="ts">
29
- import { FeedbackWidget } from '@wanlianyida/portal-kit';
30
- import { useRoute } from 'vue-router';
29
+ import { FeedbackWidget } from "@wanlianyida/portal-kit";
30
+ import { useRoute } from "vue-router";
31
31
 
32
32
  const route = useRoute();
33
- const webhookUrl = import.meta.env.VITE_FEEDBACK_WEBHOOK_URL?.trim() ?? '';
33
+ const webhookUrl = import.meta.env.VITE_FEEDBACK_WEBHOOK_URL?.trim() ?? "";
34
34
  </script>
35
35
 
36
36
  <template>
@@ -50,7 +50,7 @@ const webhookUrl = import.meta.env.VITE_FEEDBACK_WEBHOOK_URL?.trim() ?? '';
50
50
 
51
51
  ```vue
52
52
  <script setup lang="ts">
53
- import { SelectionComment } from '@wanlianyida/portal-kit';
53
+ import { SelectionComment } from "@wanlianyida/portal-kit";
54
54
  </script>
55
55
 
56
56
  <template>
@@ -73,25 +73,25 @@ admin 的预览和 docs 的文章正文都将 Markdown 直接传给 `MarkdownPre
73
73
 
74
74
  ```vue
75
75
  <script setup lang="ts">
76
- import { ref } from 'vue';
77
- import { MarkdownPreview, type HeadingSection } from '@wanlianyida/portal-kit';
76
+ import { ref } from "vue";
77
+ import { MarkdownPreview, type HeadingSection } from "@wanlianyida/portal-kit";
78
78
 
79
79
  defineProps<{ markdown: string }>();
80
80
  const sections = ref<HeadingSection[]>([]);
81
81
 
82
82
  // 下面的基址来自宿主,公共包不读取宿主的环境变量。
83
83
  const assetBase = import.meta.env.VITE_DOC_BASE || import.meta.env.BASE_URL;
84
- const routeBase = import.meta.env.BASE_URL.replace(/\/+$/, '');
84
+ const routeBase = import.meta.env.BASE_URL.replace(/\/+$/, "");
85
85
 
86
86
  function resolveAssetUrl(src: string): string {
87
87
  if (/^(https?:\/\/|\/\/|data:|blob:)/i.test(src)) return src;
88
- return `${assetBase.replace(/\/+$/, '')}/${src.replace(/^\/+/, '')}`;
88
+ return `${assetBase.replace(/\/+$/, "")}/${src.replace(/^\/+/, "")}`;
89
89
  }
90
90
 
91
91
  function resolveLink(href: string): string | null {
92
92
  // docs 的发布产物已将内部引用重写为 /s/...;残留 doc:// 显示为失效引用。
93
93
  if (/^doc:\/\//i.test(href)) return null;
94
- return href.startsWith('/s/') ? `${routeBase}${href}` : href;
94
+ return href.startsWith("/s/") ? `${routeBase}${href}` : href;
95
95
  }
96
96
  </script>
97
97
 
@@ -197,3 +197,68 @@ npm pack --dry-run
197
197
  消毒与正文 DOM 测试使用 jsdom:happy-dom 对当前 DOMPurify 的 DOM 遍历模拟不完整,不适合验证消毒结果。其它既有组件测试继续使用 happy-dom。
198
198
 
199
199
  发布前使用 `pnpm pack` 生成 tarball,在宿主项目安装该产物并检查类型、样式及运行效果;正式发布沿用 `prepublishOnly` 的测试与构建检查。
200
+
201
+ ## 回调字段卡片(0.1.6)
202
+
203
+ ```vue
204
+ <script setup lang="ts">
205
+ import { CallbackCards, type CallbackEvent } from '@wanlianyida/portal-kit';
206
+ defineProps<{ items: CallbackEvent[] }>();
207
+ </script>
208
+ <template><CallbackCards :items="items" /></template>
209
+ ```
210
+
211
+ `items` 接收事件数组:`eventName / msgType / description / outFields / samplePayload / status / retryMaxReconsume / delayPolicy`。每个 `outFields[].sourcePath` 一张卡片,标题用 `desc`,编码标签用字段路径。必填来自该字段;名称、事件编码、触发说明、状态、重试规则来自所属事件,不表示每个字段都有独立投递配置。无字段的历史快照回退为事件卡片。
212
+
213
+ 首张默认展开,其余可独立展开;替换 `items` 重置展开状态。没有 `samplePayload` 时不渲染示例区及占位提示;示例仍是事件原报文,以「所属事件回调示例」标明,不推测字段级示例。合法 JSON 格式化后可复制,历史非 JSON 原文安全展示。
214
+
215
+ 组件不发请求、不修改配置。所有新增 CSS 均使用 `portal-callback-*` 命名并限制在 Vue scoped 范围,沿用 CodePreview,未修改已有组件样式及全局变量。
216
+
217
+ 回调卡片恢复原先白色标题区及紧凑细边框重试测算表,字段路径和所属事件编码使用与 feature/errorcode 分支业务域标签一致的蓝色(文字 #526bff、底色 #eef2ff、边框 #d5ddff);包含字段必填、最大重试次数、重试延迟策略的整块信息面板保留浅蓝底色、蓝色重试次数及暖色必填标签。现有 Markdown 表格及其 CSS 保持原样。
218
+
219
+ ## 公共导航与共享会话(0.1.6-beta.0)
220
+
221
+ 导航独立入口不引入 Element Plus 或正文组件的全局 CSS;首页只依赖 Vue 即可接入。
222
+
223
+ ```vue
224
+ <script setup lang="ts">
225
+ import { PortalNavigation } from "@wanlianyida/portal-kit/navigation";
226
+ import { createSharedSession } from "@wanlianyida/portal-kit/session";
227
+
228
+ const session = createSharedSession({
229
+ mode: import.meta.env.MODE,
230
+ loginUrl: import.meta.env.VITE_SSO_LOGIN_URL,
231
+ sysType: import.meta.env.VITE_SSO_SYS_TYPE,
232
+ });
233
+ // 初始化可先于导航挂载。session.watch 返回清理函数;订阅本身不会发请求或切换企业。
234
+ // 登录信息校验、路由守卫和企业切换继续由宿主业务适配器处理。
235
+ </script>
236
+
237
+ <template>
238
+ <PortalNavigation
239
+ home-url="/"
240
+ docs-url="/docs/"
241
+ console-url="/developer"
242
+ login-url="/developer"
243
+ theme="light"
244
+ locale="zh-CN"
245
+ :show-console-button="true"
246
+ :show-theme-switch="false"
247
+ :account="{ status: 'anonymous' }"
248
+ />
249
+ </template>
250
+ ```
251
+
252
+ - `theme`:`light` / `dark`,只设置导航主题;`update:theme` 交给宿主原有主题流程。
253
+ - `locale`:`zh-CN` / `en-US`,控制公共文案。`showLanguageSwitch` 默认 `false`,开启后通过 `language` 插槽接入宿主原有语言控件;翻译加载、偏好保存及失败处理均由宿主负责。
254
+ - `showConsoleButton`:默认 `true`;设为 `false` 同时隐藏桌面和移动菜单的控制台入口。
255
+ - `showThemeSwitch`:默认 `false`;`theme` 插槽保留原项目的主题按钮。
256
+ - `fixed` / `scrolled`:首页保留吸顶和滚动态;其他项目可按原布局接入。
257
+ - `account.status`:`anonymous` / `checking` / `authenticated` / `unavailable`,须根据登录信息接口确认;不能通过企业列表为空推断未登录。
258
+ - `account.enterpriseStatus`:`unknown` / `loading` / `available` / `empty` / `unavailable`。`empty` 保持已登录并显示账号名,不额外提示;`unavailable` 提供企业信息重试。企业名优先于账号名展示。
259
+ - `console` 插槽保留原有控制台按钮样式;`account-extension` 插槽接入 `NavigationEnterprises`,它只在用户选择时发出 `select(loginId)`,不会自行初始化或切换企业。
260
+ - `logout` / `retry` / `retry-enterprises` 由宿主处理;`docs-click(MouseEvent)` 可保留文档站内 SPA 跳转。
261
+
262
+ `createSharedSession` 统一根路径 Cookie、旧 Cookie 迁移、会话变化通知和 SSO 回跳地址。Token 只保存在 Cookie;localStorage 通知仅保存随机标记。所有应用必须使用同域名与相同 MODE,Cookie 为 Path=/、SameSite=Lax,HTTPS 使用 Secure,不扩大 Domain。
263
+
264
+ 控制台使用 `session.watch(callback, { focusedOnly: true })`,只在前台感知外部 Token 改变后重新进入既有认证流程;本页写入不会造成自身重复刷新。公开页面可使用 `revalidateOnFocus: true` 重新校验会话,保持匿名阅读。
package/dist/index.d.ts CHANGED
@@ -78,6 +78,37 @@ declare type __VLS_WithTemplateSlots_2<T, S> = T & {
78
78
 
79
79
  export declare function buildFeedbackPayload(input: FeedbackInput, now?: Date): FeedbackPayload;
80
80
 
81
+ export declare const CallbackCards: DefineComponent<CallbackCardsProps, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<CallbackCardsProps> & Readonly<{}>, {}, {}, {}, {}, string, ComponentProvideOptions, false, {}, HTMLDivElement>;
82
+
83
+ export declare interface CallbackCardsProps {
84
+ items: CallbackEvent[];
85
+ }
86
+
87
+ /** 只读数据,不负责事件查询、配置修改或订阅映射。 */
88
+ export declare interface CallbackEvent {
89
+ msgType: string;
90
+ eventName: string;
91
+ description?: string | null;
92
+ outFields?: CallbackField[];
93
+ samplePayload?: string | null;
94
+ status?: 'enabled' | 'disabled' | null;
95
+ retryMaxReconsume?: number | null;
96
+ delayPolicy?: string | null;
97
+ }
98
+
99
+ export declare interface CallbackField {
100
+ sourcePath: string;
101
+ required: boolean | null;
102
+ desc?: string | null;
103
+ }
104
+
105
+ /** 根据已提供的策略生成相对时间;缺失或未知策略不推测。 */
106
+ export declare function callbackRetrySchedule(count?: number | null, policy?: string | null): {
107
+ nth: number;
108
+ delay: string;
109
+ elapsed: string;
110
+ }[];
111
+
81
112
  /** 公共代码主题使用的 token 分组,供可编辑文本范围与预览 HTML 共用。 */
82
113
  export declare const CODE_HIGHLIGHT_CLASSES: {
83
114
  readonly comment: readonly ["hljs-comment", "hljs-quote"];
@@ -198,6 +229,11 @@ export declare interface FeedbackWidgetProps {
198
229
  merchant?: string;
199
230
  }
200
231
 
232
+ /** 只读展示,不为历史快照伪造运行配置。未知策略原样显示。 */
233
+ export declare function formatCallbackDelay(policy?: string | null): string;
234
+
235
+ export declare function formatCallbackSample(sample?: string | null): string;
236
+
201
237
  export declare function formatFeedbackTime(date: Date): string;
202
238
 
203
239
  export declare interface HeadingSection {