@jari-ace/element-plus-component 0.3.2 → 0.3.4
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/dist/components/autoComplete/JaAutoComplete.vue.d.ts +956 -1179
- package/dist/components/autoComplete/JaAutoComplete.vue.d.ts.map +1 -1
- package/dist/components/button/JaButton.vue.d.ts +114 -450
- package/dist/components/button/JaButton.vue.d.ts.map +1 -1
- package/dist/components/checkbox/JaCheckbox.vue.d.ts +228 -150
- package/dist/components/checkbox/JaCheckbox.vue.d.ts.map +1 -1
- package/dist/components/checkboxGroup/JaCheckboxGroup.vue.d.ts +215 -137
- package/dist/components/checkboxGroup/JaCheckboxGroup.vue.d.ts.map +1 -1
- package/dist/components/dropdownButton/JaDropdownButton.vue.d.ts +700 -1596
- package/dist/components/dropdownButton/JaDropdownButton.vue.d.ts.map +1 -1
- package/dist/components/form/JaForm.vue.d.ts +1 -1
- package/dist/components/formItem/JaFormItem.vue.d.ts +83 -293
- package/dist/components/formItem/JaFormItem.vue.d.ts.map +1 -1
- package/dist/components/input/JaInput.vue.d.ts +244 -609
- package/dist/components/input/JaInput.vue.d.ts.map +1 -1
- package/dist/components/inputI18n/I18nBundleEditor.vue.d.ts +1 -1
- package/dist/components/inputI18n/I18nBundleEditor.vue.d.ts.map +1 -1
- package/dist/components/inputI18n/I18nBundleEditor.vue.js +1 -1
- package/dist/components/inputI18n/I18nBundleEditor.vue.js.map +1 -1
- package/dist/components/inputI18n/InputI18n.vue.d.ts.map +1 -1
- package/dist/components/inputI18n/InputI18n.vue.js +14 -5
- package/dist/components/inputI18n/InputI18n.vue.js.map +1 -1
- package/dist/components/inputNumber/JaInputNumber.vue.d.ts +117 -471
- package/dist/components/inputNumber/JaInputNumber.vue.d.ts.map +1 -1
- package/dist/components/inputNumber/JaInputNumber.vue.js +4 -1
- package/dist/components/inputNumber/JaInputNumber.vue.js.map +1 -1
- package/dist/components/properyPicker/PropertyPicker.vue.d.ts.map +1 -1
- package/dist/components/properyPicker/PropertyPicker.vue.js +4 -8
- package/dist/components/properyPicker/PropertyPicker.vue.js.map +1 -1
- package/dist/components/radioGroup/JaRadioGroup.vue.d.ts +96 -287
- package/dist/components/radioGroup/JaRadioGroup.vue.d.ts.map +1 -1
- package/dist/components/rolePicker/RoleCategorySelector.vue.d.ts +14 -0
- package/dist/components/rolePicker/RoleCategorySelector.vue.d.ts.map +1 -0
- package/dist/components/rolePicker/RoleCategorySelector.vue.js +410 -0
- package/dist/components/rolePicker/RoleCategorySelector.vue.js.map +1 -0
- package/dist/components/rolePicker/RoleEditor.vue.d.ts +1 -0
- package/dist/components/rolePicker/RoleEditor.vue.d.ts.map +1 -1
- package/dist/components/rolePicker/RoleEditor.vue.js +64 -31
- package/dist/components/rolePicker/RoleEditor.vue.js.map +1 -1
- package/dist/components/rolePicker/baseRolePicker.vue.d.ts.map +1 -1
- package/dist/components/rolePicker/baseRolePicker.vue.js +7 -9
- package/dist/components/rolePicker/baseRolePicker.vue.js.map +1 -1
- package/dist/components/rolePicker/index.d.ts +2 -0
- package/dist/components/rolePicker/index.d.ts.map +1 -1
- package/dist/components/rolePicker/index.js +2 -0
- package/dist/components/rolePicker/index.js.map +1 -1
- package/dist/components/scrollbar/Scrollbar.vue.d.ts +110 -378
- package/dist/components/scrollbar/Scrollbar.vue.d.ts.map +1 -1
- package/dist/components/switch/JaSwitch.vue.d.ts +96 -431
- package/dist/components/switch/JaSwitch.vue.d.ts.map +1 -1
- package/dist/components/upload/JaUploader.vue.d.ts +58 -6
- package/dist/components/upload/JaUploader.vue.d.ts.map +1 -1
- package/dist/components/upload/index.d.ts +88 -9
- package/dist/components/upload/index.d.ts.map +1 -1
- package/dist/components/upload/index.js +1 -0
- package/dist/components/upload/index.js.map +1 -1
- package/dist/components/upload/types.d.ts +3 -0
- package/dist/components/upload/types.d.ts.map +1 -0
- package/dist/components/upload/types.js +2 -0
- package/dist/components/upload/types.js.map +1 -0
- package/dist/components/upload/uploader.vue.d.ts +31 -3
- package/dist/components/upload/uploader.vue.d.ts.map +1 -1
- package/dist/components/upload/uploader.vue.js +42 -15
- package/dist/components/upload/uploader.vue.js.map +1 -1
- package/dist/components/userGroupTree/src/userGroupTree.vue.d.ts +1808 -0
- package/dist/components/userGroupTree/src/userGroupTree.vue.d.ts.map +1 -0
- package/dist/components/userGroupTree/src/userGroupTree.vue.js +23 -14
- package/dist/components/userGroupTree/src/userGroupTree.vue.js.map +1 -1
- package/dist/components/userPicker/src/JaUserList.vue.d.ts +4 -0
- package/dist/components/userPicker/src/JaUserList.vue.d.ts.map +1 -1
- package/dist/components/userPicker/src/JaUserList.vue.js +9 -1
- package/dist/components/userPicker/src/JaUserList.vue.js.map +1 -1
- package/dist/components/userPicker/src/UserPicker.vue.d.ts +10 -0
- package/dist/components/userPicker/src/UserPicker.vue.d.ts.map +1 -1
- package/dist/components/userPicker/src/UserPicker.vue.js +46 -5
- package/dist/components/userPicker/src/UserPicker.vue.js.map +1 -1
- package/dist/components/userSelectDialog/src/userSelectDialog.vue.d.ts +19 -2
- package/dist/components/userSelectDialog/src/userSelectDialog.vue.d.ts.map +1 -1
- package/dist/components/userSelectDialog/src/userSelectDialog.vue.js +60 -12
- package/dist/components/userSelectDialog/src/userSelectDialog.vue.js.map +1 -1
- package/dist/hooks/useAppInstances.d.ts +17 -4
- package/dist/hooks/useAppInstances.d.ts.map +1 -1
- package/dist/hooks/useAppInstances.js +109 -24
- package/dist/hooks/useAppInstances.js.map +1 -1
- package/dist/hooks/useClassificationLevels.d.ts.map +1 -1
- package/dist/hooks/useClassificationLevels.js +30 -7
- package/dist/hooks/useClassificationLevels.js.map +1 -1
- package/dist/hooks/useConstraintProviders.d.ts +5 -0
- package/dist/hooks/useConstraintProviders.d.ts.map +1 -0
- package/dist/hooks/useConstraintProviders.js +31 -0
- package/dist/hooks/useConstraintProviders.js.map +1 -0
- package/dist/hooks/useEntities.d.ts +9 -0
- package/dist/hooks/useEntities.d.ts.map +1 -0
- package/dist/hooks/useEntities.js +40 -0
- package/dist/hooks/useEntities.js.map +1 -0
- package/dist/hooks/useEntityPropDataTypes.d.ts +5 -0
- package/dist/hooks/useEntityPropDataTypes.d.ts.map +1 -0
- package/dist/hooks/useEntityPropDataTypes.js +31 -0
- package/dist/hooks/useEntityPropDataTypes.js.map +1 -0
- package/dist/hooks/useFileConfigurations.d.ts +6 -0
- package/dist/hooks/useFileConfigurations.d.ts.map +1 -0
- package/dist/hooks/useFileConfigurations.js +37 -0
- package/dist/hooks/useFileConfigurations.js.map +1 -0
- package/dist/hooks/useGroups.d.ts +7 -0
- package/dist/hooks/useGroups.d.ts.map +1 -0
- package/dist/hooks/useGroups.js +75 -0
- package/dist/hooks/useGroups.js.map +1 -0
- package/dist/hooks/useNumberTemplates.d.ts +6 -0
- package/dist/hooks/useNumberTemplates.d.ts.map +1 -0
- package/dist/hooks/useNumberTemplates.js +37 -0
- package/dist/hooks/useNumberTemplates.js.map +1 -0
- package/dist/hooks/useProperties.d.ts +9 -0
- package/dist/hooks/useProperties.d.ts.map +1 -0
- package/dist/hooks/useProperties.js +40 -0
- package/dist/hooks/useProperties.js.map +1 -0
- package/dist/hooks/useRoleCategories.d.ts +6 -0
- package/dist/hooks/useRoleCategories.d.ts.map +1 -0
- package/dist/hooks/useRoleCategories.js +37 -0
- package/dist/hooks/useRoleCategories.js.map +1 -0
- package/dist/hooks/useRoles.d.ts +6 -0
- package/dist/hooks/useRoles.d.ts.map +1 -0
- package/dist/hooks/useRoles.js +38 -0
- package/dist/hooks/useRoles.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -1
- package/lib/index.css +1 -1
- package/lib/index.js +9019 -8458
- package/lib/index.umd.cjs +39 -34
- package/package.json +7 -7
- package/packages/components/input/JaInput.vue +1 -1
- package/packages/components/inputI18n/I18nBundleEditor.vue +2 -2
- package/packages/components/inputI18n/InputI18n.vue +33 -25
- package/packages/components/inputNumber/JaInputNumber.vue +6 -5
- package/packages/components/properyPicker/PropertyPicker.vue +4 -8
- package/packages/components/rolePicker/RoleCategorySelector.vue +154 -0
- package/packages/components/rolePicker/RoleEditor.vue +16 -7
- package/packages/components/rolePicker/baseRolePicker.vue +6 -13
- package/packages/components/rolePicker/index.ts +3 -0
- package/packages/components/upload/index.ts +1 -0
- package/packages/components/upload/types.ts +4 -0
- package/packages/components/upload/uploader.vue +469 -381
- package/packages/components/userGroupTree/src/userGroupTree.vue +54 -17
- package/packages/components/userPicker/src/JaUserList.vue +14 -2
- package/packages/components/userPicker/src/UserPicker.vue +47 -4
- package/packages/components/userSelectDialog/src/userSelectDialog.vue +45 -8
- package/packages/hooks/useAppInstances.ts +121 -25
- package/packages/hooks/useClassificationLevels.ts +31 -7
- package/packages/hooks/useConstraintProviders.ts +36 -0
- package/packages/hooks/useEntities.ts +44 -0
- package/packages/hooks/useEntityPropDataTypes.ts +37 -0
- package/packages/hooks/useFileConfigurations.ts +41 -0
- package/packages/hooks/useGroups.ts +81 -0
- package/packages/hooks/useNumberTemplates.ts +43 -0
- package/packages/hooks/useProperties.ts +44 -0
- package/packages/hooks/useRoleCategories.ts +42 -0
- package/packages/hooks/useRoles.ts +44 -0
- package/packages/index.ts +9 -0
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createAxiosWithoutCache, type ProjectedPropertyDefinition, useEntityApi
|
|
3
|
+
} from "@jari-ace/app-bolts";
|
|
4
|
+
|
|
5
|
+
const cache: Map<string, ProjectedPropertyDefinition[] | undefined> = new Map()
|
|
6
|
+
let loadingPromises: Map<string, Promise<ProjectedPropertyDefinition[]>> = new Map()
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* 属性定义信息加载Hooks
|
|
10
|
+
*/
|
|
11
|
+
export function useProperties() {
|
|
12
|
+
return {
|
|
13
|
+
refreshProperties(entityId: string) {
|
|
14
|
+
cache.delete(entityId)
|
|
15
|
+
},
|
|
16
|
+
async getProperties(entityId: string) {
|
|
17
|
+
let properties = cache.get(entityId);
|
|
18
|
+
if (properties) {
|
|
19
|
+
return properties;
|
|
20
|
+
}
|
|
21
|
+
let loadingPromise = loadingPromises.get(entityId);
|
|
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.getProperties(entityId)
|
|
31
|
+
.then(result => {
|
|
32
|
+
cache.set(entityId, result);
|
|
33
|
+
return result;
|
|
34
|
+
})
|
|
35
|
+
.finally(() => {
|
|
36
|
+
loadingPromises.delete(entityId);
|
|
37
|
+
});
|
|
38
|
+
// 4. 将新创建的 Promise 存入 Map
|
|
39
|
+
loadingPromises.set(entityId, loadingPromise);
|
|
40
|
+
// 5. 等待这个新的 Promise 完成并返回
|
|
41
|
+
return await loadingPromise;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createAxiosWithoutCache, type ProjectedFileConfiguration,
|
|
3
|
+
type RoleCategory, useFileConfigurationApi, useRoleCategoryApi,
|
|
4
|
+
} from "@jari-ace/app-bolts";
|
|
5
|
+
|
|
6
|
+
const cache: Map<string, RoleCategory[] | undefined> = new Map()
|
|
7
|
+
let loadingPromises: Map<string, Promise<RoleCategory[]>> = new Map()
|
|
8
|
+
|
|
9
|
+
export function useRoleCategories() {
|
|
10
|
+
return {
|
|
11
|
+
refreshRoleCategoryCache(appId: string) {
|
|
12
|
+
cache.delete(appId)
|
|
13
|
+
},
|
|
14
|
+
async getRoleCategories(appId: string) {
|
|
15
|
+
let roles = cache.get(appId);
|
|
16
|
+
if (roles) {
|
|
17
|
+
return roles;
|
|
18
|
+
}
|
|
19
|
+
let loadingPromise = loadingPromises.get(appId);
|
|
20
|
+
if (loadingPromise) {
|
|
21
|
+
return await loadingPromise
|
|
22
|
+
}
|
|
23
|
+
// 3. 没有缓存,也没有正在进行的请求,创建新请求
|
|
24
|
+
const axios = createAxiosWithoutCache();
|
|
25
|
+
const api = useRoleCategoryApi(axios);
|
|
26
|
+
|
|
27
|
+
// 创建 Promise
|
|
28
|
+
loadingPromise = api.getAllRole(appId)
|
|
29
|
+
.then(result => {
|
|
30
|
+
cache.set(appId, result);
|
|
31
|
+
return result;
|
|
32
|
+
})
|
|
33
|
+
.finally(() => {
|
|
34
|
+
loadingPromises.delete(appId);
|
|
35
|
+
});
|
|
36
|
+
// 4. 将新创建的 Promise 存入 Map
|
|
37
|
+
loadingPromises.set(appId, loadingPromise);
|
|
38
|
+
// 5. 等待这个新的 Promise 完成并返回
|
|
39
|
+
return await loadingPromise;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createAxiosWithoutCache,
|
|
3
|
+
type ProjectedRole,
|
|
4
|
+
useRoleApi
|
|
5
|
+
} from "@jari-ace/app-bolts";
|
|
6
|
+
|
|
7
|
+
const rolesCache: Map<string, ProjectedRole[] | undefined> = new Map()
|
|
8
|
+
let loadingPromises: Map<string, Promise<ProjectedRole[]>> = new Map()
|
|
9
|
+
|
|
10
|
+
export function useRoles() {
|
|
11
|
+
return {
|
|
12
|
+
refreshRolesCache(appId: string) {
|
|
13
|
+
rolesCache.delete(appId)
|
|
14
|
+
console.log('roles cache cleared for app:', appId, rolesCache.get(appId))
|
|
15
|
+
},
|
|
16
|
+
async getRoles(appId: string) {
|
|
17
|
+
let roles = rolesCache.get(appId);
|
|
18
|
+
if (roles) {
|
|
19
|
+
return roles;
|
|
20
|
+
}
|
|
21
|
+
let loadingPromise = loadingPromises.get(appId);
|
|
22
|
+
if (loadingPromise) {
|
|
23
|
+
return await loadingPromise
|
|
24
|
+
}
|
|
25
|
+
// 3. 没有缓存,也没有正在进行的请求,创建新请求
|
|
26
|
+
const axios = createAxiosWithoutCache();
|
|
27
|
+
const api = useRoleApi(axios);
|
|
28
|
+
|
|
29
|
+
// 创建 Promise
|
|
30
|
+
loadingPromise = api.getAllRole(appId)
|
|
31
|
+
.then(result => {
|
|
32
|
+
rolesCache.set(appId, result);
|
|
33
|
+
return result;
|
|
34
|
+
})
|
|
35
|
+
.finally(() => {
|
|
36
|
+
loadingPromises.delete(appId);
|
|
37
|
+
});
|
|
38
|
+
// 4. 将新创建的 Promise 存入 Map
|
|
39
|
+
loadingPromises.set(appId, loadingPromise);
|
|
40
|
+
// 5. 等待这个新的 Promise 完成并返回
|
|
41
|
+
return await loadingPromise;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
package/packages/index.ts
CHANGED
|
@@ -22,3 +22,12 @@ export * from "./hooks/useBridage"
|
|
|
22
22
|
export * from "./hooks/useRealms"
|
|
23
23
|
export * from "./hooks/useUserRefQuery"
|
|
24
24
|
export * from "./hooks/useClassificationLevels"
|
|
25
|
+
export * from "./hooks/useRoles"
|
|
26
|
+
export * from "./hooks/useEntityPropDataTypes"
|
|
27
|
+
export * from "./hooks/useConstraintProviders"
|
|
28
|
+
export * from "./hooks/useFileConfigurations"
|
|
29
|
+
export * from "./hooks/useNumberTemplates"
|
|
30
|
+
export * from "./hooks/useEntities"
|
|
31
|
+
export * from "./hooks/useGroups"
|
|
32
|
+
export * from "./hooks/useRoleCategories"
|
|
33
|
+
export * from "./hooks/useProperties"
|