@wanlianyida/portal-kit 0.1.7 → 0.1.9

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.
@@ -1,7 +1,9 @@
1
1
  import { ComponentOptionsMixin } from 'vue';
2
2
  import { ComponentProvideOptions } from 'vue';
3
+ import { ComputedRef } from 'vue';
3
4
  import { DefineComponent } from 'vue';
4
5
  import { PublicProps } from 'vue';
6
+ import { Ref } from 'vue';
5
7
 
6
8
  declare const __VLS_component: DefineComponent<PortalNavigationProps, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {
7
9
  "update:theme": (theme: "light" | "dark") => any;
@@ -42,6 +44,12 @@ declare type __VLS_Props = {
42
44
  locale?: string;
43
45
  };
44
46
 
47
+ declare type __VLS_Props_2 = {
48
+ switcher: EnterpriseSwitcherState;
49
+ disabled?: boolean;
50
+ locale?: string;
51
+ };
52
+
45
53
  declare function __VLS_template(): {
46
54
  attrs: Partial<{}>;
47
55
  slots: {
@@ -76,6 +84,62 @@ declare type __VLS_WithTemplateSlots<T, S> = T & {
76
84
 
77
85
  declare function close_2(): void;
78
86
 
87
+ export declare interface EnterpriseAccount {
88
+ loginId: string;
89
+ merchantName: string;
90
+ defaultFlag?: number;
91
+ plfCompanyId?: string;
92
+ }
93
+
94
+ export declare interface EnterpriseChangedPayload {
95
+ previous: EnterpriseAccount | null;
96
+ current: EnterpriseAccount;
97
+ token: string;
98
+ }
99
+
100
+ export declare interface EnterpriseRequestOptions {
101
+ token: string;
102
+ body?: unknown;
103
+ }
104
+
105
+ declare type EnterpriseStatus = "unknown" | "loading" | "available" | "empty" | "unavailable";
106
+
107
+ export declare const EnterpriseSwitcher: DefineComponent<__VLS_Props_2, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {
108
+ changed: (payload: EnterpriseChangedPayload) => any;
109
+ switching: (pending: boolean) => any;
110
+ }, string, PublicProps, Readonly<__VLS_Props_2> & Readonly<{
111
+ onChanged?: ((payload: EnterpriseChangedPayload) => any) | undefined;
112
+ onSwitching?: ((pending: boolean) => any) | undefined;
113
+ }>, {}, {}, {}, {}, string, ComponentProvideOptions, false, {}, any>;
114
+
115
+ export declare interface EnterpriseSwitcherConfig {
116
+ mode: string;
117
+ sysType: string | (() => string);
118
+ serviceBase?: string;
119
+ /** 可复用宿主的请求拦截和会话失效处理;路径不包含 serviceBase。 */
120
+ request?: <T>(path: string, options: EnterpriseRequestOptions) => Promise<T>;
121
+ session?: {
122
+ getToken: () => string;
123
+ setToken: (token: string) => void;
124
+ };
125
+ /** 已有企业初始化流程的宿主传入状态,不再发起初始化请求。 */
126
+ items?: () => EnterpriseAccount[];
127
+ current?: () => string | undefined;
128
+ canSwitch?: () => boolean;
129
+ }
130
+
131
+ export declare interface EnterpriseSwitcherState {
132
+ items: Ref<EnterpriseAccount[]>;
133
+ current: Ref<EnterpriseAccount | null>;
134
+ status: Ref<EnterpriseStatus>;
135
+ loading: ComputedRef<boolean>;
136
+ switching: Ref<boolean>;
137
+ error: Ref<string>;
138
+ reload: () => Promise<void>;
139
+ reset: () => void;
140
+ switchEnterprise: (loginId: string) => Promise<EnterpriseChangedPayload | null>;
141
+ }
142
+
79
143
  export declare interface NavigationAccount {
80
144
  status: "anonymous" | "checking" | "authenticated" | "unavailable";
81
145
  loginName?: string;
@@ -110,4 +174,7 @@ export declare interface PortalNavigationProps {
110
174
  account?: NavigationAccount;
111
175
  }
112
176
 
177
+ /** 仅处理企业切换协议;初始化不会自动切企业,业务刷新由 changed 回调负责。 */
178
+ export declare function useEnterpriseSwitcher(config: EnterpriseSwitcherConfig): EnterpriseSwitcherState;
179
+
113
180
  export { }