@jari-ace/element-plus-component 0.2.2 → 0.3.0

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 (171) hide show
  1. package/README.md +1 -1
  2. package/dist/components/autoComplete/JaAutoComplete.vue.d.ts +18 -18
  3. package/dist/components/button/JaButton.vue.d.ts +24 -24
  4. package/dist/components/customGroupTree/src/customGroupTree.vue.d.ts +1 -1
  5. package/dist/components/departmentPicker/src/DepartmentPicker.vue.d.ts +2 -2
  6. package/dist/components/departmentTree/src/departmentTree.vue.d.ts +1 -1
  7. package/dist/components/dropdownButton/JaDropdownButton.vue.d.ts +55 -55
  8. package/dist/components/enumList/EnumListInput.vue.d.ts +2 -2
  9. package/dist/components/enumPicker/src/EnumPicker.vue.d.ts +1 -1
  10. package/dist/components/form/JaForm.vue.d.ts +1 -1
  11. package/dist/components/formItem/JaFormItem.vue.d.ts +12 -12
  12. package/dist/components/input/JaInput.vue.d.ts +18 -18
  13. package/dist/components/inputI18n/I18nBundleEditor.vue.d.ts +1 -1
  14. package/dist/components/inputI18n/InputI18n.vue.d.ts +2 -2
  15. package/dist/components/inputI18n/JaInputI18n.vue.d.ts +70 -70
  16. package/dist/components/inputNumber/JaInputNumber.vue.d.ts +12 -12
  17. package/dist/components/mapItemList/MapItemListInput.vue.d.ts +2 -2
  18. package/dist/components/numberList/NumberListInput.vue.d.ts +2 -2
  19. package/dist/components/rolePicker/RoleEditor.vue.d.ts +1 -1
  20. package/dist/components/rolePicker/baseRolePicker.vue.d.ts +1 -1
  21. package/dist/components/rolePicker/baseRolePicker.vue.d.ts.map +1 -1
  22. package/dist/components/rolePicker/baseRolePicker.vue.js +4 -2
  23. package/dist/components/rolePicker/baseRolePicker.vue.js.map +1 -1
  24. package/dist/components/scrollbar/Scrollbar.vue.d.ts +8 -8
  25. package/dist/components/select/JaSelect.vue.d.ts +70 -70
  26. package/dist/components/stringList/StringListInput.vue.d.ts +2 -2
  27. package/dist/components/tip/index.d.ts +6 -6
  28. package/dist/components/tip/src/AceTip.vue.d.ts +1 -1
  29. package/dist/components/upload/index.d.ts +23 -4
  30. package/dist/components/upload/index.d.ts.map +1 -1
  31. package/dist/components/upload/index.js +1 -3
  32. package/dist/components/upload/index.js.map +1 -1
  33. package/dist/components/upload/pdf-viewer/PdfViewerModal.vue.d.ts +27 -0
  34. package/dist/components/upload/pdf-viewer/PdfViewerModal.vue.d.ts.map +1 -0
  35. package/dist/components/upload/pdf-viewer/PdfViewerModal.vue.js +94 -0
  36. package/dist/components/upload/pdf-viewer/PdfViewerModal.vue.js.map +1 -0
  37. package/dist/components/upload/uploader-locale-zh-cn.d.ts +223 -0
  38. package/dist/components/upload/uploader-locale-zh-cn.d.ts.map +1 -0
  39. package/dist/components/upload/uploader-locale-zh-cn.js +224 -0
  40. package/dist/components/upload/uploader-locale-zh-cn.js.map +1 -0
  41. package/dist/components/upload/uploader.vue.d.ts +42 -0
  42. package/dist/components/upload/uploader.vue.d.ts.map +1 -0
  43. package/dist/components/upload/uploader.vue.js +713 -0
  44. package/dist/components/upload/uploader.vue.js.map +1 -0
  45. package/dist/components/userGroupPicker/src/UserGroupPicker.vue.d.ts +2 -2
  46. package/dist/components/userPicker/src/UserPicker.vue.d.ts +3 -3
  47. package/dist/components/userSelectDialog/src/userSelectDialog.vue.d.ts +1 -1
  48. package/dist/components/userTag/UserInfoTag.vue.d.ts +2 -2
  49. package/lib/index.css +9 -1
  50. package/lib/index.js +37354 -2740
  51. package/lib/index.umd.cjs +407 -2
  52. package/package.json +70 -61
  53. package/packages/components/autoComplete/JaAutoComplete.vue +47 -47
  54. package/packages/components/autoComplete/index.ts +5 -5
  55. package/packages/components/avatar/JaAvatar.vue +126 -126
  56. package/packages/components/avatar/avatarToken.ts +11 -11
  57. package/packages/components/avatar/defaultImg.ts +14 -14
  58. package/packages/components/avatar/index.ts +7 -7
  59. package/packages/components/button/JaButton.vue +51 -51
  60. package/packages/components/button/index.ts +4 -4
  61. package/packages/components/channelPicker/index.ts +7 -7
  62. package/packages/components/channelPicker/src/ChannelPicker.vue +43 -43
  63. package/packages/components/channelPicker/src/JaChannelPicker.vue +42 -42
  64. package/packages/components/checkbox/JaCheckbox.vue +73 -73
  65. package/packages/components/checkbox/index.ts +4 -4
  66. package/packages/components/checkboxGroup/JaCheckboxGroup.vue +45 -45
  67. package/packages/components/checkboxGroup/index.ts +4 -4
  68. package/packages/components/customGroupTree/index.ts +10 -10
  69. package/packages/components/customGroupTree/src/customGroupTree.vue +91 -91
  70. package/packages/components/datePicker/JaDatePicker.vue +52 -52
  71. package/packages/components/datePicker/index.ts +4 -4
  72. package/packages/components/departmentPicker/index.ts +4 -4
  73. package/packages/components/departmentPicker/src/DepartmentPicker.vue +107 -107
  74. package/packages/components/departmentPicker/src/consts.ts +2 -2
  75. package/packages/components/departmentTree/index.ts +10 -10
  76. package/packages/components/departmentTree/src/departmentTree.vue +135 -135
  77. package/packages/components/dropdownButton/JaDropdownButton.vue +59 -59
  78. package/packages/components/dropdownButton/index.ts +4 -4
  79. package/packages/components/enumList/EnumListInput.vue +107 -107
  80. package/packages/components/enumList/JaEnumList.vue +39 -39
  81. package/packages/components/enumList/index.ts +7 -7
  82. package/packages/components/enumPicker/index.ts +5 -5
  83. package/packages/components/enumPicker/src/EnumPicker.vue +103 -103
  84. package/packages/components/form/JaForm.vue +146 -146
  85. package/packages/components/form/index.ts +5 -5
  86. package/packages/components/form/types.ts +4 -4
  87. package/packages/components/formItem/JaFormItem.vue +87 -87
  88. package/packages/components/formItem/index.ts +4 -4
  89. package/packages/components/index.ts +34 -34
  90. package/packages/components/input/JaInput.vue +143 -143
  91. package/packages/components/input/index.ts +4 -4
  92. package/packages/components/inputI18n/I18nBundleEditor.vue +76 -76
  93. package/packages/components/inputI18n/InputI18n.vue +146 -146
  94. package/packages/components/inputI18n/JaInputI18n.vue +50 -50
  95. package/packages/components/inputI18n/index.ts +8 -8
  96. package/packages/components/inputNumber/JaInputNumber.vue +98 -98
  97. package/packages/components/inputNumber/index.ts +4 -4
  98. package/packages/components/mapItemList/JaMapItemList.vue +35 -35
  99. package/packages/components/mapItemList/MapItemListInput.vue +191 -191
  100. package/packages/components/mapItemList/index.ts +7 -7
  101. package/packages/components/numberList/JaNumberList.vue +36 -36
  102. package/packages/components/numberList/NumberListInput.vue +111 -111
  103. package/packages/components/numberList/index.ts +7 -7
  104. package/packages/components/properyPicker/JaPropertyPicker.vue +38 -38
  105. package/packages/components/properyPicker/PropertyPicker.vue +314 -314
  106. package/packages/components/properyPicker/index.ts +7 -7
  107. package/packages/components/radioGroup/JaRadioGroup.vue +50 -50
  108. package/packages/components/radioGroup/index.ts +4 -4
  109. package/packages/components/rolePicker/RoleEditor.vue +129 -129
  110. package/packages/components/rolePicker/RolePicker.vue +44 -44
  111. package/packages/components/rolePicker/RolePickerRaw.vue +56 -56
  112. package/packages/components/rolePicker/baseRolePicker.vue +91 -87
  113. package/packages/components/rolePicker/index.ts +10 -10
  114. package/packages/components/scrollbar/Scrollbar.vue +89 -89
  115. package/packages/components/scrollbar/index.ts +5 -5
  116. package/packages/components/scrollbar/utils.ts +17 -17
  117. package/packages/components/select/JaSelect.vue +48 -48
  118. package/packages/components/select/index.ts +4 -4
  119. package/packages/components/stringList/JaStringList.vue +36 -36
  120. package/packages/components/stringList/StringListInput.vue +96 -96
  121. package/packages/components/stringList/index.ts +7 -7
  122. package/packages/components/switch/JaSwitch.vue +50 -50
  123. package/packages/components/switch/index.ts +4 -4
  124. package/packages/components/timePicker/JaTimePicker.vue +52 -52
  125. package/packages/components/timePicker/index.ts +5 -5
  126. package/packages/components/tip/index.ts +4 -4
  127. package/packages/components/tip/src/AceTip.vue +43 -43
  128. package/packages/components/upload/index.ts +4 -6
  129. package/packages/components/upload/pdf-viewer/PdfViewerModal.vue +32 -0
  130. package/packages/components/upload/uploader-locale-zh-cn.ts +223 -0
  131. package/packages/components/upload/uploader.vue +513 -0
  132. package/packages/components/userGroupPicker/index.ts +4 -4
  133. package/packages/components/userGroupPicker/src/UserGroupPicker.vue +94 -94
  134. package/packages/components/userGroupTree/index.ts +10 -10
  135. package/packages/components/userGroupTree/src/userGroupTree.vue +149 -149
  136. package/packages/components/userPicker/index.ts +10 -10
  137. package/packages/components/userPicker/src/CustomGroupManager.vue +189 -189
  138. package/packages/components/userPicker/src/JaUserList.vue +317 -317
  139. package/packages/components/userPicker/src/JaUserPicker.vue +40 -40
  140. package/packages/components/userPicker/src/UserPicker.vue +472 -472
  141. package/packages/components/userSelectDialog/index.ts +6 -6
  142. package/packages/components/userSelectDialog/src/userSelectDialog.vue +462 -462
  143. package/packages/components/userTag/UserInfoTag.vue +397 -397
  144. package/packages/components/userTag/index.ts +6 -6
  145. package/packages/components/userTag/sharedAxios.ts +8 -8
  146. package/packages/directives/auth/index.ts +41 -41
  147. package/packages/directives/autofocus/index.ts +29 -29
  148. package/packages/directives/index.ts +10 -10
  149. package/packages/directives/shortcut/index.ts +192 -192
  150. package/packages/hooks/useAppInstances.ts +34 -34
  151. package/packages/hooks/useBackendValidations.ts +81 -81
  152. package/packages/hooks/useBridage.ts +157 -157
  153. package/packages/hooks/useClassificationLevels.ts +62 -62
  154. package/packages/hooks/useDateTimeShortCuts.ts +65 -65
  155. package/packages/hooks/useRealms.ts +28 -28
  156. package/packages/hooks/useTreeData.ts +45 -45
  157. package/packages/hooks/useUserRefQuery.ts +232 -232
  158. package/packages/index.ts +24 -24
  159. package/packages/list.json +7 -7
  160. package/packages/types/custom.d.ts +13 -13
  161. package/packages/types/window.d.ts +16 -16
  162. package/packages/utils/install.ts +43 -43
  163. package/packages/utils/objectUtils.ts +31 -31
  164. package/theme-style/fonts/iconfont.json +5196 -5196
  165. package/theme-style/index.scss +10 -10
  166. package/theme-style/styles/element-plus-var.scss +1419 -1419
  167. package/theme-style/styles/iconfont.css +2979 -2979
  168. package/theme-style/styles/theme-var.scss +72 -72
  169. package/theme-style/styles/transition.scss +122 -122
  170. package/packages/components/upload/src/Upload.vue +0 -25
  171. package/packages/components/upload/src/type.ts +0 -3
package/package.json CHANGED
@@ -1,61 +1,70 @@
1
- {
2
- "name": "@jari-ace/element-plus-component",
3
- "private": false,
4
- "version": "0.2.2",
5
- "main": "lib/index.umd.cjs",
6
- "module": "lib/index.js",
7
- "types": "dist/index.d.ts",
8
- "type": "module",
9
- "files": [
10
- "lib",
11
- "dist",
12
- "theme-style",
13
- "packages"
14
- ],
15
- "scripts": {
16
- "dev": "vite --port 3400",
17
- "build": "run-p type-check && vite build",
18
- "preview": "vite preview",
19
- "dts": "vue-tsc --declaration --emitDeclarationOnly ",
20
- "type-check": "vue-tsc --build --force"
21
- },
22
- "dependencies": {
23
- "@element-plus/icons-vue": "^2.3.1",
24
- "animate.css": "^4.1.1"
25
- },
26
- "devDependencies": {
27
- "@jari-ace/app-bolts": "0.3.6",
28
- "@types/lodash-es": "^4.17.12",
29
- "@vitejs/plugin-vue": "^5.2.1",
30
- "@vitejs/plugin-vue-jsx": "^4.1.1",
31
- "@vue/tsconfig": "^0.5.1",
32
- "@vueuse/core": "^11.1.0",
33
- "element-plus": "2.10.3",
34
- "gulp": "^4.0.2",
35
- "gulp-autoprefixer": "^8.0.0",
36
- "gulp-clean-css": "^4.3.0",
37
- "gulp-concat-css": "^3.1.0",
38
- "gulp-dart-sass": "^1.0.2",
39
- "gulp-rename": "^2.0.0",
40
- "gulp-replace": "^1.1.4",
41
- "lodash-es": "^4.17.21",
42
- "npm-run-all2": "^6.2.0",
43
- "sass": "^1.77.6",
44
- "typescript": "~5.4.5",
45
- "vite": "^6.3.5",
46
- "vue": "^3.5.13",
47
- "vue-i18n": "^9.13.1",
48
- "vue-tsc": "^2.0.21"
49
- },
50
- "publishConfig": {
51
- "access": "public"
52
- },
53
- "peerDependencies": {
54
- "@jari-ace/app-bolts": "workspace:*",
55
- "@vueuse/core": "^11.1.0",
56
- "element-plus": "^2.8.4",
57
- "lodash-es": "^4.17.21",
58
- "vue": "^3.5.11",
59
- "vue-i18n": "^9.13.1"
60
- }
61
- }
1
+ {
2
+ "name": "@jari-ace/element-plus-component",
3
+ "private": false,
4
+ "version": "0.3.0",
5
+ "main": "lib/index.umd.cjs",
6
+ "module": "lib/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "type": "module",
9
+ "files": [
10
+ "lib",
11
+ "dist",
12
+ "theme-style",
13
+ "packages"
14
+ ],
15
+ "dependencies": {
16
+ "@element-plus/icons-vue": "^2.3.1",
17
+ "@uppy/audio": "^3.0.1",
18
+ "@uppy/core": "^5.1.1",
19
+ "@uppy/dashboard": "^5.0.3",
20
+ "@uppy/image-editor": "^4.0.2",
21
+ "@uppy/screen-capture": "^5.0.1",
22
+ "@uppy/tus": "^5.0.2",
23
+ "@uppy/vue": "^3.1.0",
24
+ "@uppy/webcam": "^5.0.2",
25
+ "animate.css": "^4.1.1",
26
+ "pretty-bytes": "^7.1.0",
27
+ "vue-pdf-embed": "^2.1.3",
28
+ "@jari-ace/app-bolts": "0.5.10"
29
+ },
30
+ "devDependencies": {
31
+ "@types/lodash-es": "^4.17.12",
32
+ "@vitejs/plugin-vue": "^5.2.1",
33
+ "@vitejs/plugin-vue-jsx": "^4.1.1",
34
+ "@vue/tsconfig": "^0.5.1",
35
+ "@vueuse/core": "^11.1.0",
36
+ "element-plus": "2.10.3",
37
+ "gulp": "^4.0.2",
38
+ "gulp-autoprefixer": "^8.0.0",
39
+ "gulp-clean-css": "^4.3.0",
40
+ "gulp-concat-css": "^3.1.0",
41
+ "gulp-dart-sass": "^1.0.2",
42
+ "gulp-rename": "^2.0.0",
43
+ "gulp-replace": "^1.1.4",
44
+ "lodash-es": "^4.17.21",
45
+ "npm-run-all2": "^6.2.0",
46
+ "sass": "^1.77.6",
47
+ "typescript": "~5.4.5",
48
+ "vite": "^6.3.5",
49
+ "vue": "^3.5.13",
50
+ "vue-i18n": "^9.13.1",
51
+ "vue-tsc": "^2.0.21"
52
+ },
53
+ "publishConfig": {
54
+ "access": "public"
55
+ },
56
+ "peerDependencies": {
57
+ "@vueuse/core": "^11.1.0",
58
+ "element-plus": "^2.8.4",
59
+ "lodash-es": "^4.17.21",
60
+ "vue": "^3.5.11",
61
+ "vue-i18n": "^9.13.1"
62
+ },
63
+ "scripts": {
64
+ "dev": "vite --port 3400",
65
+ "build": "run-p type-check && vite build",
66
+ "preview": "vite preview",
67
+ "dts": "vue-tsc --declaration --emitDeclarationOnly ",
68
+ "type-check": "vue-tsc --build --force"
69
+ }
70
+ }
@@ -1,47 +1,47 @@
1
- <script setup lang="ts">
2
- import {ElAutocomplete} from "element-plus";
3
- import {inject, ref, watch} from "vue";
4
- import type {ValidationInstance} from "../../hooks/useBackendValidations";
5
- import type {EpPropMergeType} from "element-plus/es/utils";
6
- import {getValue, setValue} from "../../utils/objectUtils";
7
-
8
- const input = ref<typeof ElAutocomplete>()
9
- const model = inject('aceFormModel') as Record<string, any>
10
- const prop = inject('aceFormItemProp') as string
11
- const validator = inject('aceFormValidator') as ValidationInstance
12
- const emit = defineEmits<{
13
- change: [value: string]
14
- }>()
15
-
16
- function onChange(value: string) {
17
- validator.removeFieldError(prop)
18
- setValue(model.formData, prop, mv.value);
19
- emit('change', value)
20
- }
21
-
22
- type modelType =
23
- EpPropMergeType<readonly [StringConstructor, NumberConstructor], unknown, unknown> | undefined;
24
-
25
- const mv = ref(getValue(model.formData, prop) as modelType);
26
- watch(() => model.formData, () => {
27
- mv.value = getValue(model.formData, prop) as modelType
28
- }, {
29
- deep: true
30
- })
31
- defineExpose({
32
- elAutocomplete: input
33
- })
34
-
35
- </script>
36
-
37
- <template>
38
- <el-autocomplete
39
- ref="input"
40
- v-model="mv"
41
- @change="onChange"
42
- v-bind="$attrs">
43
- <template v-for="(_, name) in $slots" v-slot:[name]>
44
- <slot :name="name"></slot>
45
- </template>
46
- </el-autocomplete>
47
- </template>
1
+ <script setup lang="ts">
2
+ import {ElAutocomplete} from "element-plus";
3
+ import {inject, ref, watch} from "vue";
4
+ import type {ValidationInstance} from "../../hooks/useBackendValidations";
5
+ import type {EpPropMergeType} from "element-plus/es/utils";
6
+ import {getValue, setValue} from "../../utils/objectUtils";
7
+
8
+ const input = ref<typeof ElAutocomplete>()
9
+ const model = inject('aceFormModel') as Record<string, any>
10
+ const prop = inject('aceFormItemProp') as string
11
+ const validator = inject('aceFormValidator') as ValidationInstance
12
+ const emit = defineEmits<{
13
+ change: [value: string]
14
+ }>()
15
+
16
+ function onChange(value: string) {
17
+ validator.removeFieldError(prop)
18
+ setValue(model.formData, prop, mv.value);
19
+ emit('change', value)
20
+ }
21
+
22
+ type modelType =
23
+ EpPropMergeType<readonly [StringConstructor, NumberConstructor], unknown, unknown> | undefined;
24
+
25
+ const mv = ref(getValue(model.formData, prop) as modelType);
26
+ watch(() => model.formData, () => {
27
+ mv.value = getValue(model.formData, prop) as modelType
28
+ }, {
29
+ deep: true
30
+ })
31
+ defineExpose({
32
+ elAutocomplete: input
33
+ })
34
+
35
+ </script>
36
+
37
+ <template>
38
+ <el-autocomplete
39
+ ref="input"
40
+ v-model="mv"
41
+ @change="onChange"
42
+ v-bind="$attrs">
43
+ <template v-for="(_, name) in $slots" v-slot:[name]>
44
+ <slot :name="name"></slot>
45
+ </template>
46
+ </el-autocomplete>
47
+ </template>
@@ -1,5 +1,5 @@
1
- import {type SFCWithInstall, withInstall} from "../../utils/install";
2
- import Autocomplete from "./JaAutoComplete.vue";
3
-
4
- export const JaAutocomplete: SFCWithInstall<typeof Autocomplete> = withInstall(Autocomplete);
5
- // export default JaButton;
1
+ import {type SFCWithInstall, withInstall} from "../../utils/install";
2
+ import Autocomplete from "./JaAutoComplete.vue";
3
+
4
+ export const JaAutocomplete: SFCWithInstall<typeof Autocomplete> = withInstall(Autocomplete);
5
+ // export default JaButton;
@@ -1,126 +1,126 @@
1
- <script setup lang="ts">
2
- import {getAvatarToken} from "./avatarToken";
3
- import {ElAvatar, ElImage} from "element-plus";
4
- import {
5
- computed,
6
- defineProps,
7
- nextTick,
8
- onMounted, onUnmounted,
9
- ref,
10
- watch,
11
- withDefaults
12
- } from "vue";
13
- import {defaultImg} from "./defaultImg";
14
-
15
- const props = withDefaults(defineProps<{
16
- /**
17
- * 用户id
18
- */
19
- userId?: string,
20
- /**
21
- * 用户名
22
- */
23
- username?: string,
24
- /**
25
- * 用户域
26
- */
27
- realm?: string,
28
- /**
29
- * 是否在tag上显示用户头像
30
- */
31
- doNotLoadAvatar?: boolean,
32
- /**
33
- * 用户是否设置了头像
34
- */
35
- hasAvatar?: boolean,
36
-
37
- firstName?: string
38
- }>(), {
39
- doNotLoadAvatar: false
40
- })
41
-
42
- const token = getAvatarToken();
43
- const inView = ref(false);
44
- const avatar = ref<InstanceType<typeof ElAvatar>>()
45
- const usernameSpan = ref<HTMLElement>();
46
- const scrollbarWrappedItems = undefined; //inject(SCROLL_BAR_WRAPPED_INJECT_KEY) as Ref<ScrollbarWrapped[] | undefined>
47
- if (!scrollbarWrappedItems) {
48
- inView.value = true;
49
- }
50
-
51
- onMounted(async () => {
52
- await nextTick();
53
- if (scrollbarWrappedItems) {
54
- scrollbarWrappedItems.value?.push({
55
- childElement: avatar.value?.$el,
56
- onInView(isInView: boolean) {
57
- if (isInView && !inView.value) inView.value = true;
58
- }
59
- });
60
- }
61
- })
62
-
63
- const lazyUrl = computed(() => {
64
- if (!(
65
- inView.value && props.hasAvatar && !props.doNotLoadAvatar
66
- )) {
67
- return props.firstName ? "" : defaultImg;
68
- }
69
- if (props.userId && props.userId.length > 0) {
70
- const path = '/ace-app-service/avatar/' + props.userId
71
- return window.appDescriptor.env.isDevMode()
72
- ? new URL("/ace" + path, location.origin).toString() + "?t=" + token.value.toString() //开发模式下使用vite代理,添加ace前缀,由vite代理修改路由
73
- : new URL(path, location.origin).toString() + "?t=" + token.value.toString()
74
- }
75
- if (props.realm && props.realm.length > 0 && props.username && props.username.length > 0) {
76
- const path = '/ace-app-service/avatar/' + props.realm + '/' + props.username
77
- return window.appDescriptor.env.isDevMode()
78
- ? new URL("/ace" + path, location.origin).toString() + "?t=" + token.value.toString() //开发模式下使用vite代理,添加ace前缀,由vite代理修改路由
79
- : new URL(path, location.origin).toString() + "?t=" + token.value.toString()
80
- }
81
- return props.firstName ? "" : defaultImg;
82
- }
83
- )
84
-
85
- function adjustFontSize(element?: HTMLElement) {
86
- if (!element) return;
87
- let parentWidth = avatar.value?.$el.clientWidth;
88
- let fontSize = parentWidth / 2.8;
89
- element.style.fontSize = fontSize + 'px';
90
- }
91
-
92
- onUnmounted(() => {
93
- if (scrollbarWrappedItems) {
94
- scrollbarWrappedItems.value = undefined;
95
- }
96
- })
97
-
98
- watch(usernameSpan, () => adjustFontSize(usernameSpan.value))
99
- </script>
100
-
101
- <template>
102
- <el-avatar :src="lazyUrl" v-bind="$attrs" ref="avatar" class="ja-avatar">
103
- <span v-if="props.firstName && props.firstName.length > 0" class="user-name-avatar"
104
- ref="usernameSpan">
105
- {{ firstName }}
106
- </span>
107
- <el-image style="height:100%" v-else
108
- :src="defaultImg"
109
- alt="用户头像"/>
110
- </el-avatar>
111
- </template>
112
-
113
- <style scoped lang="scss">
114
- .ja-avatar {
115
- --el-avatar-bg-color: #C1CCD7 !important;
116
- transition: background-color 0.3s ease;
117
-
118
- &:hover {
119
- --el-avatar-bg-color: #9BA4AF !important;
120
- }
121
- }
122
-
123
- .user-name-avatar {
124
- }
125
-
126
- </style>
1
+ <script setup lang="ts">
2
+ import {getAvatarToken} from "./avatarToken";
3
+ import {ElAvatar, ElImage} from "element-plus";
4
+ import {
5
+ computed,
6
+ defineProps,
7
+ nextTick,
8
+ onMounted, onUnmounted,
9
+ ref,
10
+ watch,
11
+ withDefaults
12
+ } from "vue";
13
+ import {defaultImg} from "./defaultImg";
14
+
15
+ const props = withDefaults(defineProps<{
16
+ /**
17
+ * 用户id
18
+ */
19
+ userId?: string,
20
+ /**
21
+ * 用户名
22
+ */
23
+ username?: string,
24
+ /**
25
+ * 用户域
26
+ */
27
+ realm?: string,
28
+ /**
29
+ * 是否在tag上显示用户头像
30
+ */
31
+ doNotLoadAvatar?: boolean,
32
+ /**
33
+ * 用户是否设置了头像
34
+ */
35
+ hasAvatar?: boolean,
36
+
37
+ firstName?: string
38
+ }>(), {
39
+ doNotLoadAvatar: false
40
+ })
41
+
42
+ const token = getAvatarToken();
43
+ const inView = ref(false);
44
+ const avatar = ref<InstanceType<typeof ElAvatar>>()
45
+ const usernameSpan = ref<HTMLElement>();
46
+ const scrollbarWrappedItems = undefined; //inject(SCROLL_BAR_WRAPPED_INJECT_KEY) as Ref<ScrollbarWrapped[] | undefined>
47
+ if (!scrollbarWrappedItems) {
48
+ inView.value = true;
49
+ }
50
+
51
+ onMounted(async () => {
52
+ await nextTick();
53
+ if (scrollbarWrappedItems) {
54
+ scrollbarWrappedItems.value?.push({
55
+ childElement: avatar.value?.$el,
56
+ onInView(isInView: boolean) {
57
+ if (isInView && !inView.value) inView.value = true;
58
+ }
59
+ });
60
+ }
61
+ })
62
+
63
+ const lazyUrl = computed(() => {
64
+ if (!(
65
+ inView.value && props.hasAvatar && !props.doNotLoadAvatar
66
+ )) {
67
+ return props.firstName ? "" : defaultImg;
68
+ }
69
+ if (props.userId && props.userId.length > 0) {
70
+ const path = '/ace-app-service/avatar/' + props.userId
71
+ return window.appDescriptor.env.isDevMode()
72
+ ? new URL("/ace" + path, location.origin).toString() + "?t=" + token.value.toString() //开发模式下使用vite代理,添加ace前缀,由vite代理修改路由
73
+ : new URL(path, location.origin).toString() + "?t=" + token.value.toString()
74
+ }
75
+ if (props.realm && props.realm.length > 0 && props.username && props.username.length > 0) {
76
+ const path = '/ace-app-service/avatar/' + props.realm + '/' + props.username
77
+ return window.appDescriptor.env.isDevMode()
78
+ ? new URL("/ace" + path, location.origin).toString() + "?t=" + token.value.toString() //开发模式下使用vite代理,添加ace前缀,由vite代理修改路由
79
+ : new URL(path, location.origin).toString() + "?t=" + token.value.toString()
80
+ }
81
+ return props.firstName ? "" : defaultImg;
82
+ }
83
+ )
84
+
85
+ function adjustFontSize(element?: HTMLElement) {
86
+ if (!element) return;
87
+ let parentWidth = avatar.value?.$el.clientWidth;
88
+ let fontSize = parentWidth / 2.8;
89
+ element.style.fontSize = fontSize + 'px';
90
+ }
91
+
92
+ onUnmounted(() => {
93
+ if (scrollbarWrappedItems) {
94
+ scrollbarWrappedItems.value = undefined;
95
+ }
96
+ })
97
+
98
+ watch(usernameSpan, () => adjustFontSize(usernameSpan.value))
99
+ </script>
100
+
101
+ <template>
102
+ <el-avatar :src="lazyUrl" v-bind="$attrs" ref="avatar" class="ja-avatar">
103
+ <span v-if="props.firstName && props.firstName.length > 0" class="user-name-avatar"
104
+ ref="usernameSpan">
105
+ {{ firstName }}
106
+ </span>
107
+ <el-image style="height:100%" v-else
108
+ :src="defaultImg"
109
+ alt="用户头像"/>
110
+ </el-avatar>
111
+ </template>
112
+
113
+ <style scoped lang="scss">
114
+ .ja-avatar {
115
+ --el-avatar-bg-color: #C1CCD7 !important;
116
+ transition: background-color 0.3s ease;
117
+
118
+ &:hover {
119
+ --el-avatar-bg-color: #9BA4AF !important;
120
+ }
121
+ }
122
+
123
+ .user-name-avatar {
124
+ }
125
+
126
+ </style>
@@ -1,11 +1,11 @@
1
- import {ref} from "vue"
2
-
3
- const token = ref(Date.now());
4
-
5
- export function updateAvatarToken() {
6
- token.value = Date.now();
7
- }
8
-
9
- export function getAvatarToken() {
10
- return token;
11
- }
1
+ import {ref} from "vue"
2
+
3
+ const token = ref(Date.now());
4
+
5
+ export function updateAvatarToken() {
6
+ token.value = Date.now();
7
+ }
8
+
9
+ export function getAvatarToken() {
10
+ return token;
11
+ }
@@ -1,14 +1,14 @@
1
- export const defaultImg = "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='1280.000000pt' height='1248.000000pt' viewBox='-384 -374 2048 2048' preserveAspectRatio='xMidYMid meet'%3E%3Cg transform='translate(0.000000,1248.000000) scale(0.100000,-0.100000)'\n" +
2
- "fill='%23fff' stroke='none'%3E%3Cpath d='M6005 12474 c-22 -2 -89 -9 -149 -14 -542 -53 -1087 -253 -1556 -571\n" +
3
- "-1089 -738 -1659 -2029 -1470 -3331 117 -802 507 -1518 1129 -2075 454 -406\n" +
4
- "1057 -697 1666 -802 220 -39 317 -46 595 -46 278 0 375 7 595 46 1218 211\n" +
5
- "2250 1096 2647 2269 353 1043 189 2180 -442 3075 -568 804 -1437 1318 -2425\n" +
6
- "1435 -92 11 -518 21 -590 14z'/%3E%3Cpath d='M8585 5886 c-478 -363 -1085 -626 -1687 -730 -247 -43 -348 -51 -678\n" +
7
- "-51 -319 0 -364 3 -612 41 -586 88 -1171 326 -1668 676 l-114 81 -106 -17\n" +
8
- "c-58 -10 -181 -38 -275 -61 -807 -204 -1528 -616 -2120 -1210 -726 -728 -1170\n" +
9
- "-1655 -1297 -2704 -29 -238 -32 -741 -5 -930 53 -378 142 -589 320 -758 171\n" +
10
- "-163 421 -234 772 -220 269 11 533 55 1230 208 817 179 1195 244 1690 291 205\n" +
11
- "19 4525 19 4730 0 495 -47 873 -112 1690 -291 697 -153 961 -197 1230 -208\n" +
12
- "254 -10 438 21 605 103 172 84 315 254 390 463 74 203 108 420 117 736 34\n" +
13
- "1230 -451 2439 -1332 3320 -707 707 -1608 1156 -2597 1294 -206 29 -201 30\n" +
14
- "-283 -33z'/%3E%3C/g%3E%3C/svg%3E";
1
+ export const defaultImg = "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='1280.000000pt' height='1248.000000pt' viewBox='-384 -374 2048 2048' preserveAspectRatio='xMidYMid meet'%3E%3Cg transform='translate(0.000000,1248.000000) scale(0.100000,-0.100000)'\n" +
2
+ "fill='%23fff' stroke='none'%3E%3Cpath d='M6005 12474 c-22 -2 -89 -9 -149 -14 -542 -53 -1087 -253 -1556 -571\n" +
3
+ "-1089 -738 -1659 -2029 -1470 -3331 117 -802 507 -1518 1129 -2075 454 -406\n" +
4
+ "1057 -697 1666 -802 220 -39 317 -46 595 -46 278 0 375 7 595 46 1218 211\n" +
5
+ "2250 1096 2647 2269 353 1043 189 2180 -442 3075 -568 804 -1437 1318 -2425\n" +
6
+ "1435 -92 11 -518 21 -590 14z'/%3E%3Cpath d='M8585 5886 c-478 -363 -1085 -626 -1687 -730 -247 -43 -348 -51 -678\n" +
7
+ "-51 -319 0 -364 3 -612 41 -586 88 -1171 326 -1668 676 l-114 81 -106 -17\n" +
8
+ "c-58 -10 -181 -38 -275 -61 -807 -204 -1528 -616 -2120 -1210 -726 -728 -1170\n" +
9
+ "-1655 -1297 -2704 -29 -238 -32 -741 -5 -930 53 -378 142 -589 320 -758 171\n" +
10
+ "-163 421 -234 772 -220 269 11 533 55 1230 208 817 179 1195 244 1690 291 205\n" +
11
+ "19 4525 19 4730 0 495 -47 873 -112 1690 -291 697 -153 961 -197 1230 -208\n" +
12
+ "254 -10 438 21 605 103 172 84 315 254 390 463 74 203 108 420 117 736 34\n" +
13
+ "1230 -451 2439 -1332 3320 -707 707 -1608 1156 -2597 1294 -206 29 -201 30\n" +
14
+ "-283 -33z'/%3E%3C/g%3E%3C/svg%3E";
@@ -1,7 +1,7 @@
1
- import {type SFCWithInstall, withInstall} from "../../utils/install";
2
- import Avatar from "./JaAvatar.vue";
3
-
4
- export const JaAvatar: SFCWithInstall<typeof Avatar> = withInstall(Avatar);
5
-
6
- export * from "./avatarToken";
7
-
1
+ import {type SFCWithInstall, withInstall} from "../../utils/install";
2
+ import Avatar from "./JaAvatar.vue";
3
+
4
+ export const JaAvatar: SFCWithInstall<typeof Avatar> = withInstall(Avatar);
5
+
6
+ export * from "./avatarToken";
7
+