@liujitcn/kratos-admin-core 0.0.70 → 0.0.71

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.
Files changed (30) hide show
  1. package/dist/package/declarations/src/locales/generated.d.ts +4 -0
  2. package/dist/package/declarations/src/tenant.d.ts +9 -1
  3. package/dist/package/src/locales/en-US.json +1 -0
  4. package/dist/package/src/locales/ja-JP.json +1 -0
  5. package/dist/package/src/locales/zh-CN.json +1 -0
  6. package/dist/package/src/locales/zh-TW.json +1 -0
  7. package/dist/package/src/rpc/base/v1/config.ts +1 -1
  8. package/dist/package/src/rpc/base/v1/file.ts +1 -1
  9. package/dist/package/src/rpc/base/v1/language.ts +1 -1
  10. package/dist/package/src/rpc/base/v1/login.ts +1 -1
  11. package/dist/package/src/rpc/base/v1/mfa.ts +1 -1
  12. package/dist/package/src/rpc/base/v1/oauth.ts +1 -1
  13. package/dist/package/src/rpc/base/v1/oauth_client.ts +1 -1
  14. package/dist/package/src/rpc/base/v1/secret_crypto.ts +1 -1
  15. package/dist/package/src/rpc/common/v1/common.ts +1 -1
  16. package/dist/package/src/rpc/common/v1/enum.ts +1 -1
  17. package/dist/package/src/rpc/common/v1/types.ts +1 -1
  18. package/dist/package/src/rpc/google/protobuf/empty.ts +1 -1
  19. package/dist/package/src/rpc/google/protobuf/struct.ts +1 -1
  20. package/dist/package/src/rpc/google/protobuf/wrappers.ts +1 -1
  21. package/dist/package/src/rpc/system/admin/v1/auth.ts +1 -1
  22. package/dist/package/src/rpc/system/admin/v1/base_dict.ts +1 -1
  23. package/dist/package/src/rpc/system/admin/v1/base_i18n.ts +1 -1
  24. package/dist/package/src/rpc/system/admin/v1/base_tenant.ts +1 -1
  25. package/dist/package/src/rpc/system/admin/v1/common.ts +1 -1
  26. package/dist/package/src/rpc/system/common/v1/common.ts +1 -1
  27. package/dist/package/src/tenant.ts +41 -6
  28. package/dist/package/types/generated/components.d.ts +1 -0
  29. package/package.json +1 -1
  30. package/types/generated/components.d.ts +1 -0
@@ -362,6 +362,7 @@ export declare const LOCALE_MESSAGES: {
362
362
  "common.field.sort": string;
363
363
  "common.field.status": string;
364
364
  "common.field.tenant": string;
365
+ "common.field.tenant_global": string;
365
366
  "common.field.project": string;
366
367
  "common.field.updated_at": string;
367
368
  "common.field.user": string;
@@ -849,6 +850,7 @@ export declare const LOCALE_MESSAGES: {
849
850
  "common.field.sort": string;
850
851
  "common.field.status": string;
851
852
  "common.field.tenant": string;
853
+ "common.field.tenant_global": string;
852
854
  "common.field.project": string;
853
855
  "common.field.updated_at": string;
854
856
  "common.field.user": string;
@@ -1336,6 +1338,7 @@ export declare const LOCALE_MESSAGES: {
1336
1338
  "common.field.sort": string;
1337
1339
  "common.field.status": string;
1338
1340
  "common.field.tenant": string;
1341
+ "common.field.tenant_global": string;
1339
1342
  "common.field.project": string;
1340
1343
  "common.field.updated_at": string;
1341
1344
  "common.field.user": string;
@@ -1823,6 +1826,7 @@ export declare const LOCALE_MESSAGES: {
1823
1826
  "common.field.sort": string;
1824
1827
  "common.field.status": string;
1825
1828
  "common.field.tenant": string;
1829
+ "common.field.tenant_global": string;
1826
1830
  "common.field.project": string;
1827
1831
  "common.field.updated_at": string;
1828
1832
  "common.field.user": string;
@@ -7,6 +7,10 @@ export * from "./utils/tenant";
7
7
  export declare function requestTenantCodeOptions(): Promise<{
8
8
  data: EnumProps[];
9
9
  }>;
10
+ /** 查询包含全局选项的租户选项,值为零表示全局。 */
11
+ export declare function requestGlobalTenantOptions(): Promise<{
12
+ data: SelectOptionResponse_Option[];
13
+ }>;
10
14
  /** 租户上下文状态。 */
11
15
  export interface TenantScope {
12
16
  /** 当前账号是否为默认租户。 */
@@ -18,7 +22,7 @@ export interface TenantScope {
18
22
  /** 加载默认租户可选择的租户。 */
19
23
  loadTenantOptions: (includeCurrentTenant?: boolean) => Promise<void>;
20
24
  /** 将页面租户筛选值转换成后端请求值。 */
21
- toRequestTenantId: (value: unknown) => number | undefined;
25
+ toRequestTenantId: (value: unknown, allowGlobal?: boolean) => number | undefined;
22
26
  /** 创建默认租户可见的表单字段。 */
23
27
  tenantFormField: (options: TenantFormFieldOptions) => ProFormField;
24
28
  /** 创建默认租户可见的表格租户列。 */
@@ -36,6 +40,8 @@ export interface TenantFormFieldOptions {
36
40
  props?: Record<string, any>;
37
41
  /** 是否允许编辑态修改租户。 */
38
42
  disabledOnEdit?: boolean;
43
+ /** 是否在选项最前面追加全局选项(值为零)。 */
44
+ includeGlobal?: boolean;
39
45
  }
40
46
  /** 租户表格列配置。 */
41
47
  export interface TenantColumnOptions {
@@ -61,6 +67,8 @@ export interface TenantColumnOptions {
61
67
  searchEl?: SearchType;
62
68
  /** 自定义单元格展示。 */
63
69
  render?: (scope: RenderScope) => ReturnType<NonNullable<ColumnProps["render"]>>;
70
+ /** 是否在选项最前面追加全局选项(值为零)。 */
71
+ includeGlobal?: boolean;
64
72
  }
65
73
  /** 创建租户范围能力,统一默认租户和普通租户的前端行为。 */
66
74
  export declare function useTenantScope(): TenantScope;
@@ -357,6 +357,7 @@
357
357
  "common.field.sort": "Sort order",
358
358
  "common.field.status": "Status",
359
359
  "common.field.tenant": "Tenant",
360
+ "common.field.tenant_global": "Global",
360
361
  "common.field.project": "Project",
361
362
  "common.field.updated_at": "Updated at",
362
363
  "common.field.user": "User",
@@ -357,6 +357,7 @@
357
357
  "common.field.sort": "並べ替え",
358
358
  "common.field.status": "ステータス",
359
359
  "common.field.tenant": "テナント",
360
+ "common.field.tenant_global": "グローバル",
360
361
  "common.field.project": "プロジェクト",
361
362
  "common.field.updated_at": "更新時間",
362
363
  "common.field.user": "ユーザー",
@@ -357,6 +357,7 @@
357
357
  "common.field.sort": "排序",
358
358
  "common.field.status": "状态",
359
359
  "common.field.tenant": "租户",
360
+ "common.field.tenant_global": "全局",
360
361
  "common.field.project": "项目",
361
362
  "common.field.updated_at": "更新时间",
362
363
  "common.field.user": "用户",
@@ -357,6 +357,7 @@
357
357
  "common.field.sort": "排序",
358
358
  "common.field.status": "狀態",
359
359
  "common.field.tenant": "租戶",
360
+ "common.field.tenant_global": "全域",
360
361
  "common.field.project": "專案",
361
362
  "common.field.updated_at": "更新時間",
362
363
  "common.field.user": "使用者",
@@ -1,6 +1,6 @@
1
1
  // Code generated by protoc-gen-ts_proto. DO NOT EDIT.
2
2
  // versions:
3
- // protoc-gen-ts_proto v2.11.8
3
+ // protoc-gen-ts_proto v2.12.1
4
4
  // protoc unknown
5
5
  // source: base/v1/config.proto
6
6
 
@@ -1,6 +1,6 @@
1
1
  // Code generated by protoc-gen-ts_proto. DO NOT EDIT.
2
2
  // versions:
3
- // protoc-gen-ts_proto v2.11.8
3
+ // protoc-gen-ts_proto v2.12.1
4
4
  // protoc unknown
5
5
  // source: base/v1/file.proto
6
6
 
@@ -1,6 +1,6 @@
1
1
  // Code generated by protoc-gen-ts_proto. DO NOT EDIT.
2
2
  // versions:
3
- // protoc-gen-ts_proto v2.11.8
3
+ // protoc-gen-ts_proto v2.12.1
4
4
  // protoc unknown
5
5
  // source: base/v1/language.proto
6
6
 
@@ -1,6 +1,6 @@
1
1
  // Code generated by protoc-gen-ts_proto. DO NOT EDIT.
2
2
  // versions:
3
- // protoc-gen-ts_proto v2.11.8
3
+ // protoc-gen-ts_proto v2.12.1
4
4
  // protoc unknown
5
5
  // source: base/v1/login.proto
6
6
 
@@ -1,6 +1,6 @@
1
1
  // Code generated by protoc-gen-ts_proto. DO NOT EDIT.
2
2
  // versions:
3
- // protoc-gen-ts_proto v2.11.8
3
+ // protoc-gen-ts_proto v2.12.1
4
4
  // protoc unknown
5
5
  // source: base/v1/mfa.proto
6
6
 
@@ -1,6 +1,6 @@
1
1
  // Code generated by protoc-gen-ts_proto. DO NOT EDIT.
2
2
  // versions:
3
- // protoc-gen-ts_proto v2.11.8
3
+ // protoc-gen-ts_proto v2.12.1
4
4
  // protoc unknown
5
5
  // source: base/v1/oauth.proto
6
6
 
@@ -1,6 +1,6 @@
1
1
  // Code generated by protoc-gen-ts_proto. DO NOT EDIT.
2
2
  // versions:
3
- // protoc-gen-ts_proto v2.11.8
3
+ // protoc-gen-ts_proto v2.12.1
4
4
  // protoc unknown
5
5
  // source: base/v1/oauth_client.proto
6
6
 
@@ -1,6 +1,6 @@
1
1
  // Code generated by protoc-gen-ts_proto. DO NOT EDIT.
2
2
  // versions:
3
- // protoc-gen-ts_proto v2.11.8
3
+ // protoc-gen-ts_proto v2.12.1
4
4
  // protoc unknown
5
5
  // source: base/v1/secret_crypto.proto
6
6
 
@@ -1,6 +1,6 @@
1
1
  // Code generated by protoc-gen-ts_proto. DO NOT EDIT.
2
2
  // versions:
3
- // protoc-gen-ts_proto v2.11.8
3
+ // protoc-gen-ts_proto v2.12.1
4
4
  // protoc unknown
5
5
  // source: common/v1/common.proto
6
6
 
@@ -1,6 +1,6 @@
1
1
  // Code generated by protoc-gen-ts_proto. DO NOT EDIT.
2
2
  // versions:
3
- // protoc-gen-ts_proto v2.11.8
3
+ // protoc-gen-ts_proto v2.12.1
4
4
  // protoc unknown
5
5
  // source: common/v1/enum.proto
6
6
 
@@ -1,6 +1,6 @@
1
1
  // Code generated by protoc-gen-ts_proto. DO NOT EDIT.
2
2
  // versions:
3
- // protoc-gen-ts_proto v2.11.8
3
+ // protoc-gen-ts_proto v2.12.1
4
4
  // protoc unknown
5
5
  // source: common/v1/types.proto
6
6
 
@@ -1,6 +1,6 @@
1
1
  // Code generated by protoc-gen-ts_proto. DO NOT EDIT.
2
2
  // versions:
3
- // protoc-gen-ts_proto v2.11.8
3
+ // protoc-gen-ts_proto v2.12.1
4
4
  // protoc unknown
5
5
  // source: google/protobuf/empty.proto
6
6
 
@@ -1,6 +1,6 @@
1
1
  // Code generated by protoc-gen-ts_proto. DO NOT EDIT.
2
2
  // versions:
3
- // protoc-gen-ts_proto v2.11.8
3
+ // protoc-gen-ts_proto v2.12.1
4
4
  // protoc unknown
5
5
  // source: google/protobuf/struct.proto
6
6
 
@@ -1,6 +1,6 @@
1
1
  // Code generated by protoc-gen-ts_proto. DO NOT EDIT.
2
2
  // versions:
3
- // protoc-gen-ts_proto v2.11.8
3
+ // protoc-gen-ts_proto v2.12.1
4
4
  // protoc unknown
5
5
  // source: google/protobuf/wrappers.proto
6
6
 
@@ -1,6 +1,6 @@
1
1
  // Code generated by protoc-gen-ts_proto. DO NOT EDIT.
2
2
  // versions:
3
- // protoc-gen-ts_proto v2.11.8
3
+ // protoc-gen-ts_proto v2.12.1
4
4
  // protoc unknown
5
5
  // source: system/admin/v1/auth.proto
6
6
 
@@ -1,6 +1,6 @@
1
1
  // Code generated by protoc-gen-ts_proto. DO NOT EDIT.
2
2
  // versions:
3
- // protoc-gen-ts_proto v2.11.8
3
+ // protoc-gen-ts_proto v2.12.1
4
4
  // protoc unknown
5
5
  // source: system/admin/v1/base_dict.proto
6
6
 
@@ -1,6 +1,6 @@
1
1
  // Code generated by protoc-gen-ts_proto. DO NOT EDIT.
2
2
  // versions:
3
- // protoc-gen-ts_proto v2.11.8
3
+ // protoc-gen-ts_proto v2.12.1
4
4
  // protoc unknown
5
5
  // source: system/admin/v1/base_i18n.proto
6
6
 
@@ -1,6 +1,6 @@
1
1
  // Code generated by protoc-gen-ts_proto. DO NOT EDIT.
2
2
  // versions:
3
- // protoc-gen-ts_proto v2.11.8
3
+ // protoc-gen-ts_proto v2.12.1
4
4
  // protoc unknown
5
5
  // source: system/admin/v1/base_tenant.proto
6
6
 
@@ -1,6 +1,6 @@
1
1
  // Code generated by protoc-gen-ts_proto. DO NOT EDIT.
2
2
  // versions:
3
- // protoc-gen-ts_proto v2.11.8
3
+ // protoc-gen-ts_proto v2.12.1
4
4
  // protoc unknown
5
5
  // source: system/admin/v1/common.proto
6
6
 
@@ -1,6 +1,6 @@
1
1
  // Code generated by protoc-gen-ts_proto. DO NOT EDIT.
2
2
  // versions:
3
- // protoc-gen-ts_proto v2.11.8
3
+ // protoc-gen-ts_proto v2.12.1
4
4
  // protoc unknown
5
5
  // source: system/common/v1/common.proto
6
6
 
@@ -1,6 +1,7 @@
1
1
  import { computed, ref, type ComputedRef, type Ref } from "vue";
2
2
  import type { ProFormField } from "./components/ProForm/interface";
3
3
  import type { ColumnProps, EnumProps, RenderScope, SearchType } from "./components/ProTable/interface";
4
+ import { t } from "./locales";
4
5
  import { defBaseTenantService } from "./api/system/admin/v1/base_tenant";
5
6
  import type { SelectOptionResponse_Option } from "./rpc/common/v1/common";
6
7
  import { useUserStore } from "./stores/runtime";
@@ -25,6 +26,22 @@ export async function requestTenantCodeOptions() {
25
26
  return { data: options };
26
27
  }
27
28
 
29
+ /** 查询包含全局选项的租户选项,值为零表示全局。 */
30
+ export async function requestGlobalTenantOptions() {
31
+ const { data } = await requestTenantOptionData();
32
+ return { data: [globalTenantOption(), ...data] };
33
+ }
34
+
35
+ /** 构造全局租户选项。 */
36
+ function globalTenantOption(): SelectOptionResponse_Option {
37
+ return { label: t("common.field.tenant_global"), value: 0, disabled: false };
38
+ }
39
+
40
+ /** 在租户选项前插入全局选项。 */
41
+ function prependGlobalTenantOption(options: SelectOptionResponse_Option[]) {
42
+ return [globalTenantOption(), ...options];
43
+ }
44
+
28
45
  /** 租户上下文状态。 */
29
46
  export interface TenantScope {
30
47
  /** 当前账号是否为默认租户。 */
@@ -36,7 +53,7 @@ export interface TenantScope {
36
53
  /** 加载默认租户可选择的租户。 */
37
54
  loadTenantOptions: (includeCurrentTenant?: boolean) => Promise<void>;
38
55
  /** 将页面租户筛选值转换成后端请求值。 */
39
- toRequestTenantId: (value: unknown) => number | undefined;
56
+ toRequestTenantId: (value: unknown, allowGlobal?: boolean) => number | undefined;
40
57
  /** 创建默认租户可见的表单字段。 */
41
58
  tenantFormField: (options: TenantFormFieldOptions) => ProFormField;
42
59
  /** 创建默认租户可见的表格租户列。 */
@@ -55,6 +72,8 @@ export interface TenantFormFieldOptions {
55
72
  props?: Record<string, any>;
56
73
  /** 是否允许编辑态修改租户。 */
57
74
  disabledOnEdit?: boolean;
75
+ /** 是否在选项最前面追加全局选项(值为零)。 */
76
+ includeGlobal?: boolean;
58
77
  }
59
78
 
60
79
  /** 租户表格列配置。 */
@@ -81,6 +100,8 @@ export interface TenantColumnOptions {
81
100
  searchEl?: SearchType;
82
101
  /** 自定义单元格展示。 */
83
102
  render?: (scope: RenderScope) => ReturnType<NonNullable<ColumnProps["render"]>>;
103
+ /** 是否在选项最前面追加全局选项(值为零)。 */
104
+ includeGlobal?: boolean;
84
105
  }
85
106
 
86
107
  /** 创建租户范围能力,统一默认租户和普通租户的前端行为。 */
@@ -96,10 +117,13 @@ export function useTenantScope(): TenantScope {
96
117
  tenantOptions.value = await loadSharedTenantOptions();
97
118
  }
98
119
 
99
- function toRequestTenantId(value: unknown) {
120
+ function toRequestTenantId(value: unknown, allowGlobal = false) {
100
121
  if (!isDefaultTenant.value || value === undefined || value === null || value === "") return undefined;
101
122
  const tenantId = Number(value);
102
- return Number.isFinite(tenantId) && tenantId > 0 ? tenantId : undefined;
123
+ if (!Number.isFinite(tenantId) || tenantId < 0) return undefined;
124
+ // 允许全局时零值原样透传,由后端筛选全局策略。
125
+ if (tenantId === 0) return allowGlobal ? 0 : undefined;
126
+ return tenantId;
103
127
  }
104
128
 
105
129
  function tenantFormField(options: TenantFormFieldOptions): ProFormField {
@@ -110,6 +134,7 @@ export function useTenantScope(): TenantScope {
110
134
  component: "tenant-select",
111
135
  props: (model: Record<string, any>) => ({
112
136
  filterable: true,
137
+ ...(options.includeGlobal ? { options: prependGlobalTenantOption(tenantOptions.value) } : {}),
113
138
  ...(options.disabledOnEdit ? { disabled: Boolean(model.id) } : {}),
114
139
  ...options.props
115
140
  }),
@@ -120,6 +145,7 @@ export function useTenantScope(): TenantScope {
120
145
  function tenantColumns(options: TenantColumnOptions): ColumnProps[] {
121
146
  if (!isDefaultTenant.value) return [];
122
147
  const prop = options.prop ?? "tenant_id";
148
+ const includeGlobal = options.includeGlobal === true;
123
149
  return [
124
150
  {
125
151
  prop,
@@ -135,11 +161,18 @@ export function useTenantScope(): TenantScope {
135
161
  : {
136
162
  el: options.searchEl ?? "tenant-select",
137
163
  key: options.searchKey ?? prop,
138
- props: { filterable: true },
164
+ props: {
165
+ filterable: true,
166
+ ...(includeGlobal ? { options: prependGlobalTenantOption(tenantOptions.value) } : {})
167
+ },
139
168
  order: options.order ?? 1
140
169
  },
141
- enum: options.enum ?? requestTenantOptionData,
142
- render: options.render ?? (scope => resolveTenantLabel(scope.row, prop))
170
+ enum: options.enum ?? (includeGlobal ? requestGlobalTenantOptions : requestTenantOptionData),
171
+ render:
172
+ options.render ??
173
+ (scope =>
174
+ // 租户编号为零表示全局数据。
175
+ includeGlobal && Number(scope.row[prop]) === 0 ? t("common.field.tenant_global") : resolveTenantLabel(scope.row, prop))
143
176
  }
144
177
  ];
145
178
  }
@@ -149,6 +182,8 @@ export function useTenantScope(): TenantScope {
149
182
  if (directLabel) return String(directLabel);
150
183
  const value = row[field];
151
184
  if (value === undefined || value === null || value === "") return "";
185
+ // 租户编号为零表示全局数据。
186
+ if (Number(value) === 0) return t("common.field.tenant_global");
152
187
  const nameMap = new Map(options.map(item => [String(item.value), item.label] as const));
153
188
  return nameMap.get(String(value)) ?? String(value);
154
189
  }
@@ -19,6 +19,7 @@ declare module 'vue' {
19
19
  ElBreadcrumbItem: typeof import('element-plus/es')['ElBreadcrumbItem']
20
20
  ElButton: typeof import('element-plus/es')['ElButton']
21
21
  ElCard: typeof import('element-plus/es')['ElCard']
22
+ ElCascader: typeof import('element-plus/es')['ElCascader']
22
23
  ElCheckbox: typeof import('element-plus/es')['ElCheckbox']
23
24
  ElCheckboxGroup: typeof import('element-plus/es')['ElCheckboxGroup']
24
25
  ElCol: typeof import('element-plus/es')['ElCol']
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@liujitcn/kratos-admin-core",
3
3
  "private": false,
4
- "version": "0.0.70",
4
+ "version": "0.0.71",
5
5
  "type": "module",
6
6
  "description": "kratos-admin frontend runtime and base modules",
7
7
  "author": {
@@ -19,6 +19,7 @@ declare module 'vue' {
19
19
  ElBreadcrumbItem: typeof import('element-plus/es')['ElBreadcrumbItem']
20
20
  ElButton: typeof import('element-plus/es')['ElButton']
21
21
  ElCard: typeof import('element-plus/es')['ElCard']
22
+ ElCascader: typeof import('element-plus/es')['ElCascader']
22
23
  ElCheckbox: typeof import('element-plus/es')['ElCheckbox']
23
24
  ElCheckboxGroup: typeof import('element-plus/es')['ElCheckboxGroup']
24
25
  ElCol: typeof import('element-plus/es')['ElCol']