@jari-ace/element-plus-component 0.3.2 → 0.3.3

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 (148) hide show
  1. package/dist/components/autoComplete/JaAutoComplete.vue.d.ts +956 -1179
  2. package/dist/components/autoComplete/JaAutoComplete.vue.d.ts.map +1 -1
  3. package/dist/components/button/JaButton.vue.d.ts +114 -450
  4. package/dist/components/button/JaButton.vue.d.ts.map +1 -1
  5. package/dist/components/checkbox/JaCheckbox.vue.d.ts +228 -150
  6. package/dist/components/checkbox/JaCheckbox.vue.d.ts.map +1 -1
  7. package/dist/components/checkboxGroup/JaCheckboxGroup.vue.d.ts +215 -137
  8. package/dist/components/checkboxGroup/JaCheckboxGroup.vue.d.ts.map +1 -1
  9. package/dist/components/dropdownButton/JaDropdownButton.vue.d.ts +700 -1596
  10. package/dist/components/dropdownButton/JaDropdownButton.vue.d.ts.map +1 -1
  11. package/dist/components/form/JaForm.vue.d.ts +1 -1
  12. package/dist/components/formItem/JaFormItem.vue.d.ts +83 -293
  13. package/dist/components/formItem/JaFormItem.vue.d.ts.map +1 -1
  14. package/dist/components/input/JaInput.vue.d.ts +244 -609
  15. package/dist/components/input/JaInput.vue.d.ts.map +1 -1
  16. package/dist/components/inputI18n/I18nBundleEditor.vue.d.ts +1 -1
  17. package/dist/components/inputI18n/I18nBundleEditor.vue.d.ts.map +1 -1
  18. package/dist/components/inputI18n/I18nBundleEditor.vue.js +1 -1
  19. package/dist/components/inputI18n/I18nBundleEditor.vue.js.map +1 -1
  20. package/dist/components/inputI18n/InputI18n.vue.d.ts.map +1 -1
  21. package/dist/components/inputI18n/InputI18n.vue.js +14 -5
  22. package/dist/components/inputI18n/InputI18n.vue.js.map +1 -1
  23. package/dist/components/inputNumber/JaInputNumber.vue.d.ts +117 -471
  24. package/dist/components/inputNumber/JaInputNumber.vue.d.ts.map +1 -1
  25. package/dist/components/inputNumber/JaInputNumber.vue.js +4 -1
  26. package/dist/components/inputNumber/JaInputNumber.vue.js.map +1 -1
  27. package/dist/components/properyPicker/PropertyPicker.vue.d.ts.map +1 -1
  28. package/dist/components/properyPicker/PropertyPicker.vue.js +4 -8
  29. package/dist/components/properyPicker/PropertyPicker.vue.js.map +1 -1
  30. package/dist/components/radioGroup/JaRadioGroup.vue.d.ts +96 -287
  31. package/dist/components/radioGroup/JaRadioGroup.vue.d.ts.map +1 -1
  32. package/dist/components/rolePicker/RoleCategorySelector.vue.d.ts +14 -0
  33. package/dist/components/rolePicker/RoleCategorySelector.vue.d.ts.map +1 -0
  34. package/dist/components/rolePicker/RoleCategorySelector.vue.js +410 -0
  35. package/dist/components/rolePicker/RoleCategorySelector.vue.js.map +1 -0
  36. package/dist/components/rolePicker/RoleEditor.vue.d.ts +1 -0
  37. package/dist/components/rolePicker/RoleEditor.vue.d.ts.map +1 -1
  38. package/dist/components/rolePicker/RoleEditor.vue.js +64 -31
  39. package/dist/components/rolePicker/RoleEditor.vue.js.map +1 -1
  40. package/dist/components/rolePicker/baseRolePicker.vue.d.ts.map +1 -1
  41. package/dist/components/rolePicker/baseRolePicker.vue.js +7 -9
  42. package/dist/components/rolePicker/baseRolePicker.vue.js.map +1 -1
  43. package/dist/components/rolePicker/index.d.ts +2 -0
  44. package/dist/components/rolePicker/index.d.ts.map +1 -1
  45. package/dist/components/rolePicker/index.js +2 -0
  46. package/dist/components/rolePicker/index.js.map +1 -1
  47. package/dist/components/scrollbar/Scrollbar.vue.d.ts +110 -378
  48. package/dist/components/scrollbar/Scrollbar.vue.d.ts.map +1 -1
  49. package/dist/components/switch/JaSwitch.vue.d.ts +96 -431
  50. package/dist/components/switch/JaSwitch.vue.d.ts.map +1 -1
  51. package/dist/components/upload/JaUploader.vue.d.ts +50 -6
  52. package/dist/components/upload/JaUploader.vue.d.ts.map +1 -1
  53. package/dist/components/upload/index.d.ts +76 -9
  54. package/dist/components/upload/index.d.ts.map +1 -1
  55. package/dist/components/upload/index.js +1 -0
  56. package/dist/components/upload/index.js.map +1 -1
  57. package/dist/components/upload/types.d.ts +3 -0
  58. package/dist/components/upload/types.d.ts.map +1 -0
  59. package/dist/components/upload/types.js +2 -0
  60. package/dist/components/upload/types.js.map +1 -0
  61. package/dist/components/upload/uploader.vue.d.ts +26 -3
  62. package/dist/components/upload/uploader.vue.d.ts.map +1 -1
  63. package/dist/components/upload/uploader.vue.js +28 -11
  64. package/dist/components/upload/uploader.vue.js.map +1 -1
  65. package/dist/components/userGroupTree/src/userGroupTree.vue.d.ts +1808 -0
  66. package/dist/components/userGroupTree/src/userGroupTree.vue.d.ts.map +1 -0
  67. package/dist/components/userGroupTree/src/userGroupTree.vue.js +23 -14
  68. package/dist/components/userGroupTree/src/userGroupTree.vue.js.map +1 -1
  69. package/dist/components/userSelectDialog/src/userSelectDialog.vue.d.ts.map +1 -1
  70. package/dist/components/userSelectDialog/src/userSelectDialog.vue.js +2 -0
  71. package/dist/components/userSelectDialog/src/userSelectDialog.vue.js.map +1 -1
  72. package/dist/hooks/useAppInstances.d.ts +17 -4
  73. package/dist/hooks/useAppInstances.d.ts.map +1 -1
  74. package/dist/hooks/useAppInstances.js +109 -24
  75. package/dist/hooks/useAppInstances.js.map +1 -1
  76. package/dist/hooks/useClassificationLevels.d.ts.map +1 -1
  77. package/dist/hooks/useClassificationLevels.js +30 -7
  78. package/dist/hooks/useClassificationLevels.js.map +1 -1
  79. package/dist/hooks/useConstraintProviders.d.ts +5 -0
  80. package/dist/hooks/useConstraintProviders.d.ts.map +1 -0
  81. package/dist/hooks/useConstraintProviders.js +31 -0
  82. package/dist/hooks/useConstraintProviders.js.map +1 -0
  83. package/dist/hooks/useEntities.d.ts +9 -0
  84. package/dist/hooks/useEntities.d.ts.map +1 -0
  85. package/dist/hooks/useEntities.js +40 -0
  86. package/dist/hooks/useEntities.js.map +1 -0
  87. package/dist/hooks/useEntityPropDataTypes.d.ts +5 -0
  88. package/dist/hooks/useEntityPropDataTypes.d.ts.map +1 -0
  89. package/dist/hooks/useEntityPropDataTypes.js +31 -0
  90. package/dist/hooks/useEntityPropDataTypes.js.map +1 -0
  91. package/dist/hooks/useFileConfigurations.d.ts +6 -0
  92. package/dist/hooks/useFileConfigurations.d.ts.map +1 -0
  93. package/dist/hooks/useFileConfigurations.js +37 -0
  94. package/dist/hooks/useFileConfigurations.js.map +1 -0
  95. package/dist/hooks/useGroups.d.ts +7 -0
  96. package/dist/hooks/useGroups.d.ts.map +1 -0
  97. package/dist/hooks/useGroups.js +75 -0
  98. package/dist/hooks/useGroups.js.map +1 -0
  99. package/dist/hooks/useNumberTemplates.d.ts +6 -0
  100. package/dist/hooks/useNumberTemplates.d.ts.map +1 -0
  101. package/dist/hooks/useNumberTemplates.js +37 -0
  102. package/dist/hooks/useNumberTemplates.js.map +1 -0
  103. package/dist/hooks/useProperties.d.ts +9 -0
  104. package/dist/hooks/useProperties.d.ts.map +1 -0
  105. package/dist/hooks/useProperties.js +40 -0
  106. package/dist/hooks/useProperties.js.map +1 -0
  107. package/dist/hooks/useRoleCategories.d.ts +6 -0
  108. package/dist/hooks/useRoleCategories.d.ts.map +1 -0
  109. package/dist/hooks/useRoleCategories.js +37 -0
  110. package/dist/hooks/useRoleCategories.js.map +1 -0
  111. package/dist/hooks/useRoles.d.ts +6 -0
  112. package/dist/hooks/useRoles.d.ts.map +1 -0
  113. package/dist/hooks/useRoles.js +38 -0
  114. package/dist/hooks/useRoles.js.map +1 -0
  115. package/dist/index.d.ts +9 -0
  116. package/dist/index.d.ts.map +1 -1
  117. package/dist/index.js +9 -0
  118. package/dist/index.js.map +1 -1
  119. package/lib/index.css +1 -1
  120. package/lib/index.js +9264 -8794
  121. package/lib/index.umd.cjs +34 -34
  122. package/package.json +7 -7
  123. package/packages/components/input/JaInput.vue +1 -1
  124. package/packages/components/inputI18n/I18nBundleEditor.vue +2 -2
  125. package/packages/components/inputI18n/InputI18n.vue +33 -25
  126. package/packages/components/inputNumber/JaInputNumber.vue +6 -5
  127. package/packages/components/properyPicker/PropertyPicker.vue +4 -8
  128. package/packages/components/rolePicker/RoleCategorySelector.vue +154 -0
  129. package/packages/components/rolePicker/RoleEditor.vue +16 -7
  130. package/packages/components/rolePicker/baseRolePicker.vue +6 -13
  131. package/packages/components/rolePicker/index.ts +3 -0
  132. package/packages/components/upload/index.ts +1 -0
  133. package/packages/components/upload/types.ts +4 -0
  134. package/packages/components/upload/uploader.vue +456 -381
  135. package/packages/components/userGroupTree/src/userGroupTree.vue +54 -17
  136. package/packages/components/userSelectDialog/src/userSelectDialog.vue +1 -1
  137. package/packages/hooks/useAppInstances.ts +121 -25
  138. package/packages/hooks/useClassificationLevels.ts +31 -7
  139. package/packages/hooks/useConstraintProviders.ts +36 -0
  140. package/packages/hooks/useEntities.ts +44 -0
  141. package/packages/hooks/useEntityPropDataTypes.ts +37 -0
  142. package/packages/hooks/useFileConfigurations.ts +41 -0
  143. package/packages/hooks/useGroups.ts +81 -0
  144. package/packages/hooks/useNumberTemplates.ts +43 -0
  145. package/packages/hooks/useProperties.ts +44 -0
  146. package/packages/hooks/useRoleCategories.ts +42 -0
  147. package/packages/hooks/useRoles.ts +44 -0
  148. package/packages/index.ts +9 -0
@@ -18,7 +18,7 @@
18
18
  import {computed, ref, shallowReactive, watch} from "vue";
19
19
  import {
20
20
  createAxiosWithoutCache,
21
- type Group,
21
+ type Group, type ProjectedGroup,
22
22
  useAppApi,
23
23
  useLoading,
24
24
  useUserGroupApi,
@@ -26,20 +26,47 @@ import {
26
26
  import {type TreeNodeType, useTreeData} from "../../../hooks/useTreeData";
27
27
  import {ElOption, ElSelect, ElTree, vLoading} from "element-plus";
28
28
  import type {TreeNodeData} from "element-plus/es/components/tree/src/tree.type";
29
+ import {useAppInstances} from "../../../hooks/useAppInstances";
30
+ import {useGroups} from "../../../hooks/useGroups";
29
31
 
30
32
  interface Props {
33
+ /**
34
+ * 用户域ID
35
+ */
31
36
  realmId?: string;
37
+ /**
38
+ * 是否多选
39
+ */
32
40
  multiple?: boolean;
41
+ /**
42
+ * 是否显示控制台应用
43
+ */
33
44
  showConsoleApp?: boolean
45
+ /**
46
+ * 只显示指定应用下的用户组(不可自选应用)
47
+ */
34
48
  appId?: string;
49
+ /**
50
+ * 节点高度
51
+ */
35
52
  nodeHeight?: string;
53
+ /**
54
+ * 业务类别
55
+ */
56
+ category?: string;
57
+ /**
58
+ * 是否全局用户组
59
+ */
60
+ global?: boolean;
61
+ /**
62
+ * 是否显示所有分类
63
+ */
64
+ showAllCategory? :boolean;
36
65
  }
37
66
 
38
67
  const groupTree = ref<typeof ElTree>();
39
68
  const axios = createAxiosWithoutCache()
40
69
  const loading = useLoading(axios);
41
- const departmentApi = useUserGroupApi(axios);
42
- const appApi = useAppApi(axios);
43
70
  const props = withDefaults(defineProps<Props>(), {nodeHeight: 'auto'});
44
71
  const emits = defineEmits(["change", "loaded"]);
45
72
  const selected = defineModel<Group | null>();
@@ -53,23 +80,28 @@ const id = computed({
53
80
  }
54
81
  })
55
82
 
56
- const [globalApp, apps] = await Promise.all([
57
- appApi.getGlobalApp(),
58
- appApi.getAccessible()
83
+ const {getGlobal, getAccessible} = useAppInstances()
84
+ const {getGroups, getGlobalGroups} = useGroups()
85
+
86
+ let [globalApp, _apps] = await Promise.all([
87
+ getGlobal(),
88
+ getAccessible(),
59
89
  ])
90
+ _apps = [..._apps];
91
+ _apps.unshift(globalApp);
60
92
 
61
- apps.unshift(globalApp);
62
93
  if (!props.showConsoleApp) {
63
- const index = apps.findIndex(a => a.name == "ace-app-manage");
94
+ const index = _apps.findIndex(a => a.name == "ace-app-manage");
64
95
  if (index >= 0) {
65
- apps.splice(index, 1);
96
+ _apps.splice(index, 1);
66
97
  }
67
98
  }
99
+ const apps = ref(_apps)
100
+
68
101
  if (!currentApp.value) {
69
102
  currentApp.value = globalApp.id;
70
103
  }
71
104
 
72
-
73
105
  const state = shallowReactive<{
74
106
  groups: (TreeNodeType & Group)[];
75
107
  }>({
@@ -78,7 +110,12 @@ const state = shallowReactive<{
78
110
 
79
111
  const getList = async () => {
80
112
  if (!props.realmId || !currentApp.value) return;
81
- const res = await departmentApi.getByAppIdAndRealm(currentApp.value, props.realmId);
113
+ let res: ProjectedGroup[]
114
+ if (props.global) {
115
+ res = await getGlobalGroups(props.realmId);
116
+ } else {
117
+ res = await getGroups(currentApp.value, props.realmId, props.category, props.showAllCategory);
118
+ }
82
119
  state.groups = [
83
120
  ...useTreeData<Group>(res, "name"),
84
121
  ];
@@ -94,25 +131,25 @@ const currentChange = (data: TreeNodeType & Group) => {
94
131
  };
95
132
 
96
133
  watch(
97
- () => props.realmId,
134
+ () => (
135
+ {appId: props.appId, realmId: props.realmId, category: props.category}
136
+ ),
98
137
  () => {
99
138
  //重新获取
100
139
  getList();
140
+ }, {
141
+ deep: true,
142
+ immediate: true,
101
143
  }
102
144
  );
103
145
  watch(() => props.appId, () => {
104
146
  currentApp.value = props.appId;
105
147
  })
106
- watch(currentApp, () => {
107
- getList();
108
- })
109
148
 
110
149
  defineExpose({
111
150
  reload: getList,
112
151
  elTree: groupTree
113
152
  });
114
-
115
- getList();
116
153
  </script>
117
154
 
118
155
  <style lang="scss" scoped>
@@ -351,7 +351,7 @@ defineExpose({
351
351
  </el-tab-pane>
352
352
  <el-tab-pane name="group" label="按用户组">
353
353
  <el-scrollbar height="400">
354
- <ja-user-group-tree v-model="currentGroup"
354
+ <ja-user-group-tree v-model="currentGroup" show-all-category
355
355
  :realm-id="localRealmId"></ja-user-group-tree>
356
356
  </el-scrollbar>
357
357
  </el-tab-pane>
@@ -1,34 +1,130 @@
1
- import {type AppInstance, createAxiosWithoutCache, useAppApi} from "@jari-ace/app-bolts";
1
+ import {
2
+ type AppInstance,
3
+ createAxiosWithoutCache,
4
+ type IAceAxios,
5
+ useAppApi
6
+ } from "@jari-ace/app-bolts";
7
+ import {ref, readonly, type Ref} from 'vue'; // 1. 引入 ref 和 readonly
2
8
 
9
+ type LoadType = "all" | "accessible" | "manageable" | "global"
10
+ const appCache: Map<LoadType, AppInstance[]> = new Map()
11
+ const promises: Map<LoadType, Promise<AppInstance[]>> = new Map();
3
12
 
4
- let appCache: AppInstance[] = [];
13
+ let axios: IAceAxios = null
14
+ let api: ReturnType<typeof useAppApi>
5
15
 
6
- export async function useAppInstances() {
7
- const axios = createAxiosWithoutCache()
8
- const api = useAppApi(axios)
9
- if (appCache.length === 0) {
10
- appCache = await api.getAll(true);
16
+ async function loadApps(load: () => Promise<AppInstance[]>, loadType: LoadType): Promise<AppInstance[]> {
17
+ let result = appCache.get(loadType)
18
+ // 如果已经有数据或正在加载,则直接返回
19
+ if (result) {
20
+ return result;
11
21
  }
12
- return {
13
- async getById(appId: string) {
14
- let app = appCache.find(a => a.id === appId);
15
- if (!app) {
16
- app = await api.getById(appId);
17
- if (app) {
18
- appCache.push(app);
19
- }
22
+ let promise = promises.get(loadType)
23
+ if (promise) {
24
+ return await promise;
25
+ }
26
+ promise = load()
27
+ .then(data => {
28
+ appCache.set(loadType, data)
29
+ return data;
30
+ })
31
+ .finally(() => {
32
+ // 成功后也重置,但保留数据
33
+ promises.delete(loadType)
34
+ });
35
+ promises.set(loadType, promise)
36
+ return await promise;
37
+ }
38
+
39
+ async function getAll(includeConsoleApp?: boolean) {
40
+ if (!api) {
41
+ axios = axios || createAxiosWithoutCache();
42
+ api = api || useAppApi(axios);
43
+ }
44
+ const apps =await loadApps(() => api.getAll(true), "all");
45
+ if (includeConsoleApp) {
46
+ return apps
47
+ } else {
48
+ return apps.filter(a=>a.name !== 'ace-app-manage')
49
+ }
50
+ }
51
+ async function getById(appId: string) {
52
+ if (!api) {
53
+ axios = axios || createAxiosWithoutCache();
54
+ api = api || useAppApi(axios);
55
+ }
56
+ await loadApps(() => api.getAll(true), "all")
57
+ let app = appCache.get("all").find(a => a.id === appId);
58
+ if (!app) {
59
+ axios = axios || createAxiosWithoutCache();
60
+ api = api || useAppApi(axios);
61
+ app = await api.getById(appId);
62
+ if (app) {
63
+ if (!appCache.get("all").find(a => a.id === app.id)) {
64
+ appCache.get("all").push(app); // 这将触发UI更新
20
65
  }
21
- return app;
22
- },
23
- async getByName(appName: string) {
24
- let app = appCache.find(a => a.name === appName);
25
- if (!app) {
26
- app = await api.getByName(appName);
27
- if (app) {
28
- appCache.push(app);
29
- }
66
+ }
67
+ }
68
+ return app;
69
+ }
70
+ async function getByName(appName: string) {
71
+ if (!api) {
72
+ axios = axios || createAxiosWithoutCache();
73
+ api = api || useAppApi(axios);
74
+ }
75
+ await loadApps(() => api.getAll(true), "all")
76
+ let app = appCache.get("all").find(a => a.name === appName);
77
+ if (!app) {
78
+ axios = axios || createAxiosWithoutCache();
79
+ api = api || useAppApi(axios);
80
+ app = await api.getByName(appName);
81
+ if (app) {
82
+ if (!appCache.get("all").find(a => a.id === app.id)) {
83
+ appCache.get("all").push(app);
30
84
  }
31
- return app;
32
85
  }
33
86
  }
87
+ return app;
88
+ }
89
+
90
+ async function getManageable() {
91
+ if (!api) {
92
+ axios = axios || createAxiosWithoutCache();
93
+ api = api || useAppApi(axios);
94
+ }
95
+ return await loadApps(api.getManageable, "manageable")
96
+ }
97
+
98
+ async function getAccessible() {
99
+ if (!api) {
100
+ axios = axios || createAxiosWithoutCache();
101
+ api = api || useAppApi(axios);
102
+ }
103
+ return await loadApps(api.getAccessible, "accessible")
104
+ }
105
+
106
+ async function getGlobal() {
107
+ if (!api) {
108
+ axios = axios || createAxiosWithoutCache();
109
+ api = api || useAppApi(axios);
110
+ }
111
+ return (await loadApps(()=> api.getGlobalApp().then(a=>[a]), "global"))[0]
112
+ }
113
+
114
+ async function refresh() {
115
+ appCache.clear()
116
+ await Promise.all([getAll(), getManageable(), getAccessible(), getGlobal()])
117
+ }
118
+
119
+ // --- 导出的 Hook (非 async) ---
120
+ export function useAppInstances() {
121
+ return {
122
+ getAll,
123
+ getByName,
124
+ getById,
125
+ getManageable,
126
+ getAccessible,
127
+ getGlobal,
128
+ refresh
129
+ };
34
130
  }
@@ -5,15 +5,38 @@ import {
5
5
  } from "@jari-ace/app-bolts";
6
6
  import {ref} from "vue";
7
7
 
8
- const levelList = ref<ClassificationLevelList>()
8
+ let levelList = ref<ClassificationLevelList>()
9
+ let loadingPromise: Promise<ClassificationLevelList> = undefined
9
10
 
10
11
  async function loadLevels(serviceName: string) {
11
- if (!levelList.value) {
12
- if (!serviceName) serviceName = 'ace-global-app'
13
- const axios = createAxiosWithoutCache()
14
- const api = useAppServiceApi(axios)
15
- levelList.value = await api.getClassificationLevels(serviceName)
12
+ if (levelList.value) {
13
+ return levelList.value
16
14
  }
15
+ if (loadingPromise) {
16
+ return await loadingPromise
17
+ }
18
+ if (!serviceName) serviceName = 'ace-global-app'
19
+ const axios = createAxiosWithoutCache()
20
+ const api = useAppServiceApi(axios)
21
+ loadingPromise = api.getClassificationLevels(serviceName)
22
+ .then(levels => {
23
+ if (levels) {
24
+ // 检查并按 value 倒序排序 system 数组
25
+ if (levels.system) {
26
+ // 修改点:b.value - a.value 实现降序
27
+ levels.system.sort((a, b) => b.value - a.value);
28
+ }
29
+ // 检查并按 value 倒序排序 user 数组
30
+ if (levels.user) {
31
+ // 修改点:b.value - a.value 实现降序
32
+ levels.user.sort((a, b) => b.value - a.value);
33
+ }
34
+ }
35
+ levelList.value = levels
36
+ return levels
37
+ })
38
+ .finally(() => loadingPromise = undefined)
39
+ return await loadingPromise;
17
40
  }
18
41
 
19
42
  /**
@@ -47,11 +70,12 @@ export async function useUserClassificationLevelMap(serviceName?: string) {
47
70
  }
48
71
  return map;
49
72
  }
73
+
50
74
  /**
51
75
  * 获取系统密级反向映射,可以根据密级获取密级对应的中文标签
52
76
  * @param serviceName 服务名
53
77
  */
54
- export async function useSystemClassificationLevelMap(serviceName?: string){
78
+ export async function useSystemClassificationLevelMap(serviceName?: string) {
55
79
  await loadLevels(serviceName);
56
80
  const map = new Map<number, string>()
57
81
  for (let i = 0; i < levelList.value.system.length; i++) {
@@ -0,0 +1,36 @@
1
+ import {
2
+ type ConstraintProvider,
3
+ createAxiosWithoutCache, useConstraintApi
4
+ } from "@jari-ace/app-bolts";
5
+
6
+ let cache: ConstraintProvider[] = null
7
+ let loadingPromise:Promise<ConstraintProvider[]> = undefined
8
+
9
+ export function useConstraintProviders() {
10
+ return {
11
+ async getConstraintProviders() {
12
+ let dataTypes = cache;
13
+ if (dataTypes) {
14
+ return dataTypes;
15
+ }
16
+ if (loadingPromise) {
17
+ return await loadingPromise
18
+ }
19
+ // 3. 没有缓存,也没有正在进行的请求,创建新请求
20
+ const axios = createAxiosWithoutCache();
21
+ const api = useConstraintApi(axios);
22
+
23
+ // 创建 Promise
24
+ loadingPromise = api.getConstraintProviders()
25
+ .then(result => {
26
+ // 缓存结果
27
+ cache = result
28
+ return result;
29
+ })
30
+ .finally(() => {
31
+ loadingPromise = undefined
32
+ });
33
+ return await loadingPromise;
34
+ }
35
+ }
36
+ }
@@ -0,0 +1,44 @@
1
+ import {
2
+ createAxiosWithoutCache, type EntityDefinitionReference, useEntityApi
3
+ } from "@jari-ace/app-bolts";
4
+
5
+ const cache: Map<string, EntityDefinitionReference[] | undefined> = new Map()
6
+ let loadingPromises: Map<string, Promise<EntityDefinitionReference[]>> = new Map()
7
+
8
+ /**
9
+ * 实体定义信息加载Hooks
10
+ */
11
+ export function useEntities() {
12
+ return {
13
+ refreshEntitiesCache(datasourceId: string) {
14
+ cache.delete(datasourceId)
15
+ },
16
+ async getEntities(datasourceId: string) {
17
+ let entities = cache.get(datasourceId);
18
+ if (entities) {
19
+ return entities;
20
+ }
21
+ let loadingPromise = loadingPromises.get(datasourceId);
22
+ if (loadingPromise) {
23
+ return await loadingPromise
24
+ }
25
+ // 3. 没有缓存,也没有正在进行的请求,创建新请求
26
+ const axios = createAxiosWithoutCache();
27
+ const api = useEntityApi(axios);
28
+
29
+ // 创建 Promise
30
+ loadingPromise = api.getAll(datasourceId)
31
+ .then(result => {
32
+ cache.set(datasourceId, result);
33
+ return result;
34
+ })
35
+ .finally(() => {
36
+ loadingPromises.delete(datasourceId);
37
+ });
38
+ // 4. 将新创建的 Promise 存入 Map
39
+ loadingPromises.set(datasourceId, loadingPromise);
40
+ // 5. 等待这个新的 Promise 完成并返回
41
+ return await loadingPromise;
42
+ }
43
+ }
44
+ }
@@ -0,0 +1,37 @@
1
+
2
+
3
+ import {
4
+ createAxiosWithoutCache, type PropertyDataType, useEntityApi
5
+ } from "@jari-ace/app-bolts";
6
+
7
+ let cache: Partial<Record<PropertyDataType, string>> = null
8
+ let loadingPromise:Promise<Partial<Record<PropertyDataType, string>>> = undefined
9
+
10
+ export function useEntityPropDataTypes() {
11
+ return {
12
+ async getDataTypes() {
13
+ let dataTypes = cache;
14
+ if (dataTypes) {
15
+ return dataTypes;
16
+ }
17
+ if (loadingPromise) {
18
+ return await loadingPromise
19
+ }
20
+ // 3. 没有缓存,也没有正在进行的请求,创建新请求
21
+ const axios = createAxiosWithoutCache();
22
+ const api = useEntityApi(axios);
23
+
24
+ // 创建 Promise
25
+ loadingPromise = api.getPropertyDataTypes()
26
+ .then(result => {
27
+ // 缓存结果
28
+ cache = result
29
+ return result;
30
+ })
31
+ .finally(() => {
32
+ loadingPromise = undefined
33
+ });
34
+ return await loadingPromise;
35
+ }
36
+ }
37
+ }
@@ -0,0 +1,41 @@
1
+ import {
2
+ createAxiosWithoutCache, type ProjectedFileConfiguration, useFileConfigurationApi,
3
+ } from "@jari-ace/app-bolts";
4
+
5
+ const cache: Map<string, ProjectedFileConfiguration[] | undefined> = new Map()
6
+ let loadingPromises: Map<string, Promise<ProjectedFileConfiguration[]>> = new Map()
7
+
8
+ export function useFileConfigurations() {
9
+ return {
10
+ refreshFileConfigurationCache(serviceName: string) {
11
+ cache.delete(serviceName)
12
+ },
13
+ async getFileConfigurations(serviceName: string) {
14
+ let roles = cache.get(serviceName);
15
+ if (roles) {
16
+ return roles;
17
+ }
18
+ let loadingPromise = loadingPromises.get(serviceName);
19
+ if (loadingPromise) {
20
+ return await loadingPromise
21
+ }
22
+ // 3. 没有缓存,也没有正在进行的请求,创建新请求
23
+ const axios = createAxiosWithoutCache();
24
+ const api = useFileConfigurationApi(axios);
25
+
26
+ // 创建 Promise
27
+ loadingPromise = api.getByAppService(serviceName, 0, 9999999)
28
+ .then(result => {
29
+ cache.set(serviceName, result.content);
30
+ return result.content;
31
+ })
32
+ .finally(() => {
33
+ loadingPromises.delete(serviceName);
34
+ });
35
+ // 4. 将新创建的 Promise 存入 Map
36
+ loadingPromises.set(serviceName, loadingPromise);
37
+ // 5. 等待这个新的 Promise 完成并返回
38
+ return await loadingPromise;
39
+ }
40
+ }
41
+ }
@@ -0,0 +1,81 @@
1
+ import {
2
+ createAxiosWithoutCache, type ProjectedGroup,
3
+ useUserGroupApi
4
+ } from "@jari-ace/app-bolts";
5
+
6
+ const rolesCache: Map<string, ProjectedGroup[] | undefined> = new Map()
7
+ let loadingPromises: Map<string, Promise<ProjectedGroup[]>> = new Map()
8
+
9
+ function getKey(appId: string, realmId: string, category?: string, showAllCategory?: boolean) {
10
+ return appId +":" + realmId + ":" + (category ?? "") + ":" + (showAllCategory ? "all" : "by-category");
11
+ }
12
+
13
+ export function useGroups() {
14
+ return {
15
+ refreshGroupsCache() {
16
+ rolesCache.clear();
17
+ },
18
+ async getGroups(appId: string, realmId: string, category?: string, showAllCategory?: boolean) {
19
+ const key = getKey(appId, realmId, category, showAllCategory);
20
+ let groups = rolesCache.get(key);
21
+ if (groups) {
22
+ return groups;
23
+ }
24
+ let loadingPromise = loadingPromises.get(key);
25
+ if (loadingPromise) {
26
+ return await loadingPromise
27
+ }
28
+ // 3. 没有缓存,也没有正在进行的请求,创建新请求
29
+ const axios = createAxiosWithoutCache();
30
+ const api = useUserGroupApi(axios);
31
+
32
+ // 创建 Promise
33
+ if (showAllCategory) {
34
+ loadingPromise = api.getAll(appId, realmId)
35
+ } else {
36
+ loadingPromise = api.getByAppIdAndRealm(appId, realmId, category)
37
+ }
38
+ loadingPromise = loadingPromise
39
+ .then(result => {
40
+ rolesCache.set(key, result);
41
+ return result;
42
+ })
43
+ .finally(() => {
44
+ loadingPromises.delete(key);
45
+ });
46
+ // 4. 将新创建的 Promise 存入 Map
47
+ loadingPromises.set(key, loadingPromise);
48
+ // 5. 等待这个新的 Promise 完成并返回
49
+ return await loadingPromise;
50
+ },
51
+ async getGlobalGroups(realmId: string, category?: string) {
52
+ const appId = "[global-app]"
53
+ const key = getKey(appId, realmId, category, true);
54
+ let groups = rolesCache.get(key);
55
+ if (groups) {
56
+ return groups;
57
+ }
58
+ let loadingPromise = loadingPromises.get(key);
59
+ if (loadingPromise) {
60
+ return await loadingPromise
61
+ }
62
+ // 3. 没有缓存,也没有正在进行的请求,创建新请求
63
+ const axios = createAxiosWithoutCache();
64
+ const api = useUserGroupApi(axios);
65
+
66
+ // 创建 Promise
67
+ loadingPromise = api.getGlobalGroups(realmId, category)
68
+ .then(result => {
69
+ rolesCache.set(key, result);
70
+ return result;
71
+ })
72
+ .finally(() => {
73
+ loadingPromises.delete(key);
74
+ });
75
+ // 4. 将新创建的 Promise 存入 Map
76
+ loadingPromises.set(key, loadingPromise);
77
+ // 5. 等待这个新的 Promise 完成并返回
78
+ return await loadingPromise;
79
+ }
80
+ }
81
+ }
@@ -0,0 +1,43 @@
1
+ import {
2
+ createAxiosWithoutCache, type ProjectedFileConfiguration,
3
+ type ProjectedStringIdTemplate, useFileConfigurationApi,
4
+ useStringIdTemplateApi,
5
+ } from "@jari-ace/app-bolts";
6
+
7
+ const cache: Map<string, ProjectedStringIdTemplate[] | undefined> = new Map()
8
+ let loadingPromises: Map<string, Promise<ProjectedStringIdTemplate[]>> = new Map()
9
+
10
+ export function useNumberTemplates() {
11
+ return {
12
+ refreshNumberTemplatesCache(appName: string) {
13
+ cache.delete(appName)
14
+ },
15
+ async getNumberTemplates(appName: string) {
16
+ let roles = cache.get(appName);
17
+ if (roles) {
18
+ return roles;
19
+ }
20
+ let loadingPromise = loadingPromises.get(appName);
21
+ if (loadingPromise) {
22
+ return await loadingPromise
23
+ }
24
+ // 3. 没有缓存,也没有正在进行的请求,创建新请求
25
+ const axios = createAxiosWithoutCache();
26
+ const api = useStringIdTemplateApi(axios);
27
+
28
+ // 创建 Promise
29
+ loadingPromise = api.getByApp(appName, 0, 9999999)
30
+ .then(result => {
31
+ cache.set(appName, result.content);
32
+ return result.content;
33
+ })
34
+ .finally(() => {
35
+ loadingPromises.delete(appName);
36
+ });
37
+ // 4. 将新创建的 Promise 存入 Map
38
+ loadingPromises.set(appName, loadingPromise);
39
+ // 5. 等待这个新的 Promise 完成并返回
40
+ return await loadingPromise;
41
+ }
42
+ }
43
+ }