boke-devops 0.0.30
Sign up to get free protection for your applications and to get access to all the features.
- package/.vscode/settings.json +2 -0
- package/lerna.json +4 -0
- package/package.json +43 -0
- package/packages/boke-devops-vue/.eslintrc.cjs +22 -0
- package/packages/boke-devops-vue/README.md +45 -0
- package/packages/boke-devops-vue/demo/App.vue +62 -0
- package/packages/boke-devops-vue/demo/main.ts +7 -0
- package/packages/boke-devops-vue/package-lock.json +13513 -0
- package/packages/boke-devops-vue/package.json +59 -0
- package/packages/boke-devops-vue/pnpm-lock.yaml +6063 -0
- package/packages/boke-devops-vue/src/AegisUser/__tests__/Avatar.test.js +18 -0
- package/packages/boke-devops-vue/src/AegisUser/__tests__/__snapshots__/Avatar.test.js.snap +60 -0
- package/packages/boke-devops-vue/src/AegisUser/multiple-user-select.vue +190 -0
- package/packages/boke-devops-vue/src/AegisUser/store.ts +23 -0
- package/packages/boke-devops-vue/src/AegisUser/user-avatar-group.vue +76 -0
- package/packages/boke-devops-vue/src/AegisUser/user-avatar.vue +347 -0
- package/packages/boke-devops-vue/src/Microapp/MicroAppProvider.vue +50 -0
- package/packages/boke-devops-vue/src/Provider/Provider.vue +22 -0
- package/packages/boke-devops-vue/src/Provider/store.ts +23 -0
- package/packages/boke-devops-vue/src/global.d.ts +43 -0
- package/packages/boke-devops-vue/src/index.ts +39 -0
- package/packages/boke-devops-vue/src/style/variables.less +79 -0
- package/packages/boke-devops-vue/tsconfig.json +34 -0
- package/packages/boke-devops-vue/tsconfig.web.json +20 -0
- package/packages/boke-devops-vue/types/AegisUser/multiple-user-select.vue.d.ts +97 -0
- package/packages/boke-devops-vue/types/AegisUser/store.d.ts +7 -0
- package/packages/boke-devops-vue/types/AegisUser/user-avatar-group.vue.d.ts +44 -0
- package/packages/boke-devops-vue/types/AegisUser/user-avatar.vue.d.ts +217 -0
- package/packages/boke-devops-vue/types/Microapp/MicroAppProvider.vue.d.ts +39 -0
- package/packages/boke-devops-vue/types/Provider/Provider.vue.d.ts +63 -0
- package/packages/boke-devops-vue/types/Provider/store.d.ts +15 -0
- package/packages/boke-devops-vue/types/index.d.ts +13 -0
- package/packages/boke-devops-vue/types/store.d.ts +12 -0
- package/packages/boke-devops-vue/vite.config.ts +90 -0
- package/packages/boke-docs/.dumirc.ts +64 -0
- package/packages/boke-docs/.eslintrc.js +14 -0
- package/packages/boke-docs/.fatherrc.ts +7 -0
- package/packages/boke-docs/README.md +1 -0
- package/packages/boke-docs/docs/components/Avatar/demo/normal.vue +25 -0
- package/packages/boke-docs/docs/components/Avatar/demo/with_provider.vue +38 -0
- package/packages/boke-docs/docs/components/Avatar/index.md +10 -0
- package/packages/boke-docs/docs/components/UserSelect/demo/normal.vue +34 -0
- package/packages/boke-docs/docs/components/UserSelect/demo/with_provider.vue +40 -0
- package/packages/boke-docs/docs/components/UserSelect/index.md +12 -0
- package/packages/boke-docs/docs/components/index.md +126 -0
- package/packages/boke-docs/docs/framework-test/external/App.vue +303 -0
- package/packages/boke-docs/docs/framework-test/index.md +96 -0
- package/packages/boke-docs/docs/index.md +50 -0
- package/packages/boke-docs/node_modules/.bin/acorn +17 -0
- package/packages/boke-docs/node_modules/.bin/acorn.CMD +12 -0
- package/packages/boke-docs/node_modules/.bin/acorn.ps1 +41 -0
- package/packages/boke-docs/node_modules/.bin/browserslist +17 -0
- package/packages/boke-docs/node_modules/.bin/browserslist.CMD +12 -0
- package/packages/boke-docs/node_modules/.bin/browserslist.ps1 +41 -0
- package/packages/boke-docs/node_modules/.bin/dumi +17 -0
- package/packages/boke-docs/node_modules/.bin/dumi.CMD +12 -0
- package/packages/boke-docs/node_modules/.bin/dumi.ps1 +41 -0
- package/packages/boke-docs/node_modules/.bin/eslint +17 -0
- package/packages/boke-docs/node_modules/.bin/eslint.CMD +12 -0
- package/packages/boke-docs/node_modules/.bin/eslint.ps1 +41 -0
- package/packages/boke-docs/node_modules/.bin/prettier +17 -0
- package/packages/boke-docs/node_modules/.bin/prettier.CMD +12 -0
- package/packages/boke-docs/node_modules/.bin/prettier.ps1 +41 -0
- package/packages/boke-docs/node_modules/.bin/stylelint +17 -0
- package/packages/boke-docs/node_modules/.bin/stylelint.CMD +12 -0
- package/packages/boke-docs/node_modules/.bin/stylelint.ps1 +41 -0
- package/packages/boke-docs/node_modules/.bin/tsc +17 -0
- package/packages/boke-docs/node_modules/.bin/tsc.CMD +12 -0
- package/packages/boke-docs/node_modules/.bin/tsc.ps1 +41 -0
- package/packages/boke-docs/node_modules/.bin/tsserver +17 -0
- package/packages/boke-docs/node_modules/.bin/tsserver.CMD +12 -0
- package/packages/boke-docs/node_modules/.bin/tsserver.ps1 +41 -0
- package/packages/boke-docs/node_modules/.bin/vite +17 -0
- package/packages/boke-docs/node_modules/.bin/vite.CMD +12 -0
- package/packages/boke-docs/node_modules/.bin/vite.ps1 +41 -0
- package/packages/boke-docs/node_modules/.bin/webpack +17 -0
- package/packages/boke-docs/node_modules/.bin/webpack.CMD +12 -0
- package/packages/boke-docs/node_modules/.bin/webpack.ps1 +41 -0
- package/packages/boke-docs/package.json +38 -0
- package/packages/boke-docs/pnpm-lock.yaml +11506 -0
- package/packages/boke-docs/tsconfig.json +14 -0
- package/packages/boke-docs/tsconfig.vue.json +10 -0
- package/packages/boke-js-bridge/es/child.d.ts +27 -0
- package/packages/boke-js-bridge/es/child.js +144 -0
- package/packages/boke-js-bridge/es/index.d.ts +3 -0
- package/packages/boke-js-bridge/es/index.js +3 -0
- package/packages/boke-js-bridge/es/parent.d.ts +24 -0
- package/packages/boke-js-bridge/es/parent.js +71 -0
- package/packages/boke-js-bridge/es/utils.d.ts +2 -0
- package/packages/boke-js-bridge/es/utils.js +6 -0
- package/packages/boke-js-bridge/package-lock.json +2028 -0
- package/packages/boke-js-bridge/package.json +35 -0
- package/packages/boke-js-bridge/readme.md +11 -0
- package/packages/boke-js-bridge/src/child.ts +174 -0
- package/packages/boke-js-bridge/src/index.ts +3 -0
- package/packages/boke-js-bridge/src/parent.ts +92 -0
- package/packages/boke-js-bridge/src/utils.ts +15 -0
- package/packages/boke-js-bridge/tsconfig.json +26 -0
- package/packages/boke-js-bridge/typings.d.ts +4 -0
- package/packages/boke-js-bridge/umd/child.js +156 -0
- package/packages/boke-js-bridge/umd/index.js +18 -0
- package/packages/boke-js-bridge/umd/parent.js +84 -0
- package/packages/boke-js-bridge/umd/utils.js +18 -0
- package/packages/test/Provider-test.vue +85 -0
- package/pnpm-workspace.yaml +2 -0
- package/scripts/configs.mjs +52 -0
- package/scripts/index.mjs +43 -0
- package/scripts/release.mjs +16 -0
- package/test-setup.js +24 -0
- package/vite.config.ts +21 -0
- package/vitest.config.js +22 -0
@@ -0,0 +1,18 @@
|
|
1
|
+
import Avatar from '../user-avatar.vue'
|
2
|
+
import { mount, VueWrapper } from '@vue/test-utils';
|
3
|
+
import { describe, expect, it, vi, test, } from 'vitest';
|
4
|
+
|
5
|
+
test('Link changes the state when hovered', async () => {
|
6
|
+
const wrapper = mount(Avatar, {
|
7
|
+
props: {
|
8
|
+
data: { name: 'Julone', dept_name: '运维部', avatar: 'https://s1-imfile.fewebp' }
|
9
|
+
},
|
10
|
+
slots: {
|
11
|
+
default : 'sdafasd'
|
12
|
+
},
|
13
|
+
},
|
14
|
+
);
|
15
|
+
expect(wrapper.element).toMatchSnapshot() // 匹配快照
|
16
|
+
const actions = wrapper.find('.boke-useravator-wrapper');
|
17
|
+
expect(actions.exists()).toBeTruthy(); // 查找是否有类名
|
18
|
+
})
|
@@ -0,0 +1,60 @@
|
|
1
|
+
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
2
|
+
|
3
|
+
exports[`Link changes the state when hovered 1`] = `
|
4
|
+
<div
|
5
|
+
data-v-6fc62be8=""
|
6
|
+
style="display: inline-flex;"
|
7
|
+
>
|
8
|
+
<span
|
9
|
+
class="ant-tag css-dev-only-do-not-override-16pw25h ant-tag-default boke-useravator-wrapper"
|
10
|
+
data-v-6fc62be8=""
|
11
|
+
style="padding: 2px 12px 2px 2px; border-radius: 50px;"
|
12
|
+
>
|
13
|
+
|
14
|
+
<div
|
15
|
+
class="left-icon"
|
16
|
+
data-v-6fc62be8=""
|
17
|
+
>
|
18
|
+
<span
|
19
|
+
class="avator-icon ant-avatar ant-avatar-circle ant-avatar-image css-dev-only-do-not-override-16pw25h"
|
20
|
+
data-v-6fc62be8=""
|
21
|
+
style="width: 28px; height: 28px; line-height: 28px; font-size: 18px;"
|
22
|
+
>
|
23
|
+
<img
|
24
|
+
src="https://s1-imfile.fewebp"
|
25
|
+
/>
|
26
|
+
</span>
|
27
|
+
</div>
|
28
|
+
|
29
|
+
|
30
|
+
<div
|
31
|
+
class="label"
|
32
|
+
data-v-6fc62be8=""
|
33
|
+
>
|
34
|
+
<span
|
35
|
+
class="realname"
|
36
|
+
data-v-6fc62be8=""
|
37
|
+
>
|
38
|
+
Julone
|
39
|
+
</span>
|
40
|
+
<span
|
41
|
+
class="id"
|
42
|
+
data-v-6fc62be8=""
|
43
|
+
>
|
44
|
+
<span
|
45
|
+
data-v-6fc62be8=""
|
46
|
+
>
|
47
|
+
运维部
|
48
|
+
</span>
|
49
|
+
</span>
|
50
|
+
</div>
|
51
|
+
<!--v-if-->
|
52
|
+
<!--v-if-->
|
53
|
+
|
54
|
+
sdafasd
|
55
|
+
|
56
|
+
|
57
|
+
<!---->
|
58
|
+
</span>
|
59
|
+
</div>
|
60
|
+
`;
|
@@ -0,0 +1,190 @@
|
|
1
|
+
<template>
|
2
|
+
<ASelect
|
3
|
+
v-model:value="innerdata"
|
4
|
+
class="wiki-user-caseder"
|
5
|
+
v-if="options"
|
6
|
+
@change="onNodeClick($event)"
|
7
|
+
style="flex: 1"
|
8
|
+
:dropdownStyle="{ zIndex: 100000 }"
|
9
|
+
allowClear
|
10
|
+
:virtual="true"
|
11
|
+
:options="options"
|
12
|
+
mode="multiple"
|
13
|
+
:fieldNames="{ children: 'children', label: 'label', value: 'value' }"
|
14
|
+
:disabled="props.disabled || false"
|
15
|
+
show-search
|
16
|
+
:dropdownMatchSelectWidth="240"
|
17
|
+
:max-tag-count="props.maxTagCount || 100"
|
18
|
+
:filter-option="onFilterOption"
|
19
|
+
v-bind="$attrs"
|
20
|
+
>
|
21
|
+
<template #tagRender="{ label, closable, onClose, option }">
|
22
|
+
<userAvatar
|
23
|
+
v-if="option?.data"
|
24
|
+
:data="option?.data"
|
25
|
+
:size="18"
|
26
|
+
:hidePopover="true"
|
27
|
+
:noID="true"
|
28
|
+
style="width: fit-content"
|
29
|
+
:noDialogDetail="true"
|
30
|
+
:tag="true"
|
31
|
+
:closable="closable"
|
32
|
+
@close="onClose"
|
33
|
+
:customProps="$attrs.customProps"
|
34
|
+
>
|
35
|
+
</userAvatar>
|
36
|
+
</template>
|
37
|
+
<template #placeholder>
|
38
|
+
<div
|
39
|
+
style="display: flex; align-items: center; line-height: 12px; gap: 8px"
|
40
|
+
>
|
41
|
+
<UserOutlined />
|
42
|
+
{{ props.placeholder || "未选择用户" }}
|
43
|
+
</div>
|
44
|
+
</template>
|
45
|
+
<template #option="item">
|
46
|
+
<div style="display: flex; align-items: center; height: 100%">
|
47
|
+
<div
|
48
|
+
style="
|
49
|
+
display: flex;
|
50
|
+
align-items: center;
|
51
|
+
justify-content: space-between;
|
52
|
+
width: 100%;
|
53
|
+
pointer-events: none;
|
54
|
+
"
|
55
|
+
>
|
56
|
+
<div class="user-select-user-label">
|
57
|
+
<a-avatar
|
58
|
+
:src="item?.data?.[AVATAR_KEY]"
|
59
|
+
:class="'user-select-avatar-icon'"
|
60
|
+
:size="18"
|
61
|
+
>
|
62
|
+
<div style="display: flex;width: 18px;height: 18px"></div>
|
63
|
+
</a-avatar>
|
64
|
+
<span>
|
65
|
+
{{ item.data?.[NAME_KEY] }}
|
66
|
+
</span>
|
67
|
+
</div>
|
68
|
+
<small style="margin: 0 8px; zoom: 0.8">{{
|
69
|
+
item.data?.[DEPT_KEY]
|
70
|
+
}}</small>
|
71
|
+
</div>
|
72
|
+
</div>
|
73
|
+
</template>
|
74
|
+
</ASelect>
|
75
|
+
</template>
|
76
|
+
|
77
|
+
<script setup lang="tsx">
|
78
|
+
import {
|
79
|
+
defineProps,
|
80
|
+
ref,
|
81
|
+
computed,
|
82
|
+
nextTick,
|
83
|
+
watch,
|
84
|
+
onUpdated,
|
85
|
+
} from "vue";
|
86
|
+
|
87
|
+
import {find as _find} from "lodash-es";
|
88
|
+
import { Select as ASelect, Avatar as AAvatar} from "ant-design-vue/es";
|
89
|
+
import userAvatar from "./user-avatar.vue";
|
90
|
+
import { UserOutlined } from "@ant-design/icons-vue";
|
91
|
+
|
92
|
+
import {useCustomProps} from "./store"
|
93
|
+
import { onErrorCaptured } from "vue";
|
94
|
+
|
95
|
+
const props = defineProps([
|
96
|
+
"modelValue",
|
97
|
+
"options",
|
98
|
+
"disabled",
|
99
|
+
"userSource",
|
100
|
+
"optionDisabledProp",
|
101
|
+
"hideValues",
|
102
|
+
"placeholder",
|
103
|
+
"maxTagCount",
|
104
|
+
]);
|
105
|
+
|
106
|
+
const {NAME_KEY, AVATAR_KEY, DEPT_KEY,USERID_KEY } =useCustomProps()
|
107
|
+
|
108
|
+
const emits = defineEmits(["update:modelValue", "blur", "focus", "change"]);
|
109
|
+
// userSelectOptionsAll
|
110
|
+
const projUserTreeOptions = computed(
|
111
|
+
() => null
|
112
|
+
);
|
113
|
+
const innerdata = ref(null);
|
114
|
+
const options = computed(() => {
|
115
|
+
const target = props.options || projUserTreeOptions.value;
|
116
|
+
return target
|
117
|
+
?.map((item) => {
|
118
|
+
item.disabled = props.optionDisabledProp
|
119
|
+
? item[props.optionDisabledProp]
|
120
|
+
: item.disabled;
|
121
|
+
return item;
|
122
|
+
})
|
123
|
+
.filter((user) => {
|
124
|
+
return !props.hideValues?.includes(user.value);
|
125
|
+
});
|
126
|
+
});
|
127
|
+
const onNodeClick = (e) => {
|
128
|
+
const target = _find(projUserTreeOptions.value, (item: any) => item.value == e);
|
129
|
+
emits("change", target);
|
130
|
+
emits("update:modelValue", e);
|
131
|
+
nextTick(() => {
|
132
|
+
innerdata.value = e;
|
133
|
+
});
|
134
|
+
};
|
135
|
+
const onFocus = () => {
|
136
|
+
// userCenter.refreshUserCenter()
|
137
|
+
};
|
138
|
+
|
139
|
+
const onFilterOption = (inputValue, option) => {
|
140
|
+
const description = option.label
|
141
|
+
.toLowerCase()
|
142
|
+
.includes(inputValue.toLowerCase());
|
143
|
+
return option.label.toLowerCase().includes(inputValue.toLowerCase());
|
144
|
+
};
|
145
|
+
|
146
|
+
watch(
|
147
|
+
props.userSource,
|
148
|
+
(val) => {
|
149
|
+
innerdata.value = props.modelValue;
|
150
|
+
},
|
151
|
+
{ immediate: true }
|
152
|
+
);
|
153
|
+
onUpdated(() => {
|
154
|
+
innerdata.value = props.modelValue;
|
155
|
+
});
|
156
|
+
|
157
|
+
onErrorCaptured(()=> {
|
158
|
+
return false
|
159
|
+
})
|
160
|
+
</script>
|
161
|
+
<style lang="less" scoped>
|
162
|
+
.wiki-user-caseder {
|
163
|
+
/deep/ .ant-select-selection-item {
|
164
|
+
align-items: center;
|
165
|
+
}
|
166
|
+
|
167
|
+
&.ant-select-disabled {
|
168
|
+
/deep/.ant-select-selector {
|
169
|
+
// border: none !important;
|
170
|
+
background: transparent !important;
|
171
|
+
|
172
|
+
.ant-select-selection-item {
|
173
|
+
color: var(--boke-text-color-regular) !important;
|
174
|
+
}
|
175
|
+
}
|
176
|
+
}
|
177
|
+
}
|
178
|
+
|
179
|
+
.user-select-user-label {
|
180
|
+
font-size: 12px;
|
181
|
+
white-space: nowrap;
|
182
|
+
display: flex;
|
183
|
+
max-width: 80px;
|
184
|
+
margin-left: 4px;
|
185
|
+
gap: 12px;
|
186
|
+
/deep/ .user-select-avatar-icon {
|
187
|
+
flex: none;
|
188
|
+
}
|
189
|
+
}
|
190
|
+
</style>
|
@@ -0,0 +1,23 @@
|
|
1
|
+
import { computed, toRef, getCurrentInstance, inject } from "vue"
|
2
|
+
import { globalConfig, globalState } from "../Provider/store"
|
3
|
+
import { mergeWith } from "lodash-es"
|
4
|
+
|
5
|
+
export const useCustomProps = () => {
|
6
|
+
const props = getCurrentInstance()?.attrs as any;
|
7
|
+
const injectGlobalConfig = inject("globalConfig") as any
|
8
|
+
const injectGlobalState = inject("globalState") as any
|
9
|
+
const mergedProps = mergeWith({}, globalConfig.avatar, injectGlobalConfig?.avatar, props?.customProps || {});
|
10
|
+
|
11
|
+
let NAME_KEY = toRef(mergedProps, 'user_name')
|
12
|
+
let AVATAR_KEY = toRef(mergedProps, 'user_avatar')
|
13
|
+
let DEPT_KEY = toRef(mergedProps, 'dept_name')
|
14
|
+
let USERID_KEY = toRef(mergedProps, 'user_id')
|
15
|
+
const global_always_avatar_is_hihglight = injectGlobalState?.global_always_avatar_is_hihglight || globalState?.global_always_avatar_is_hihglight
|
16
|
+
return {
|
17
|
+
NAME_KEY,
|
18
|
+
AVATAR_KEY,
|
19
|
+
DEPT_KEY,
|
20
|
+
USERID_KEY,
|
21
|
+
global_always_avatar_is_hihglight
|
22
|
+
}
|
23
|
+
}
|
@@ -0,0 +1,76 @@
|
|
1
|
+
<template>
|
2
|
+
<a-typography-text v-if="!data || data.length === 0" type="info">{{props.placeholder}}</a-typography-text>
|
3
|
+
<rmp-user-avatar v-else-if="data.length == 1" :data="data[0]" :key="data[0]?.[AVATAR_KEY]" :size="size" :hide-popover="false"
|
4
|
+
:show-text="props.showText" :is_highlight="() => props.is_highlight(data[0])" :tag="props.tag"></rmp-user-avatar>
|
5
|
+
<a-popover v-else show-arrow placement="bottom" destroy-on-close>
|
6
|
+
<div>
|
7
|
+
<a-avatar-group>
|
8
|
+
<template v-for="(el, index) in data">
|
9
|
+
<a-avatar :src="el?.[AVATAR_KEY]" :key="el?.[AVATAR_KEY]" v-if="index < props.max" :size="$props.size" :class="{ is_highlight: isH(el) }"></a-avatar>
|
10
|
+
</template>
|
11
|
+
<a-avatar v-if="props.max < data.length" shape="circle" style="background: rgb(103 103 103)" :size="$props.size"> 共{{ data.length }}人</a-avatar>
|
12
|
+
</a-avatar-group>
|
13
|
+
</div>
|
14
|
+
<!-- <div slot="content">触发元素是指触发浮层内容显示的元素</div> -->
|
15
|
+
<template #content>
|
16
|
+
<div style="padding: 8px; max-width: 320px; gap: 16px; display: flex; flex-wrap: wrap">
|
17
|
+
<rmp-user-avatar v-for="(el, index) in data" :key="el?.[AVATAR_KEY]" :data="el" :size="'small'" :show-text="true"
|
18
|
+
style="display: inline-flex" :is_highlight="() => props.is_highlight(el)" :tag="props.tag" ></rmp-user-avatar>
|
19
|
+
</div>
|
20
|
+
</template>
|
21
|
+
</a-popover>
|
22
|
+
</template>
|
23
|
+
|
24
|
+
<script setup lang="jsx">
|
25
|
+
import { useAttrs } from "vue"
|
26
|
+
import RmpUserAvatar from './user-avatar.vue';
|
27
|
+
import { Popover as APopover, AvatarGroup as AAvatarGroup, Avatar as AAvatar, TypographyText as ATypographyText} from "ant-design-vue"
|
28
|
+
import { useCustomProps } from "./store"
|
29
|
+
import {isFunction} from "lodash-es"
|
30
|
+
|
31
|
+
const props = defineProps({
|
32
|
+
data: {
|
33
|
+
type: Array,
|
34
|
+
default: () => [],
|
35
|
+
},
|
36
|
+
size: {
|
37
|
+
type: String,
|
38
|
+
default: '27px',
|
39
|
+
},
|
40
|
+
showText: {
|
41
|
+
type: Boolean,
|
42
|
+
default: false,
|
43
|
+
},
|
44
|
+
placeholder: {
|
45
|
+
type: String,
|
46
|
+
default: "暂无人员"
|
47
|
+
},
|
48
|
+
max: {
|
49
|
+
type: Number,
|
50
|
+
default: 3,
|
51
|
+
},
|
52
|
+
is_highlight: {
|
53
|
+
type: Function,
|
54
|
+
default: (v) => {
|
55
|
+
return false
|
56
|
+
}
|
57
|
+
},
|
58
|
+
tag: {
|
59
|
+
type: Boolean,
|
60
|
+
}
|
61
|
+
});
|
62
|
+
|
63
|
+
const attrs = useAttrs ()
|
64
|
+
const { AVATAR_KEY, global_always_avatar_is_hihglight, NAME_KEY, DEPT_KEY } = useCustomProps()
|
65
|
+
const isH = (item) => {
|
66
|
+
if(global_always_avatar_is_hihglight) {
|
67
|
+
return isFunction(global_always_avatar_is_hihglight)? global_always_avatar_is_hihglight(item): global_always_avatar_is_hihglight
|
68
|
+
}
|
69
|
+
return (isFunction(props.is_highlight)? props?.is_highlight(item): props.is_highlight)
|
70
|
+
}
|
71
|
+
</script>
|
72
|
+
<style lang="less" scoped>
|
73
|
+
.is_highlight{
|
74
|
+
box-shadow: 0 0px 0px 1.5px var(--boke-color-primary);
|
75
|
+
}
|
76
|
+
</style>
|
@@ -0,0 +1,347 @@
|
|
1
|
+
<template>
|
2
|
+
<div style="display:inline-flex">
|
3
|
+
<ATag class="boke-useravator-wrapper" :class="{
|
4
|
+
'wrapper-only-name': props.onlyName,
|
5
|
+
is_tag: props.tag && !props.color,
|
6
|
+
is_highlight: isHigh(),
|
7
|
+
disabled: props.disabled,
|
8
|
+
'only-icon-style': props.onlyIcon
|
9
|
+
}" v-bind="attrs" :style="{ padding: '2px', paddingRight: '12px', borderRadius: '50px' }" v-if="data"
|
10
|
+
:color="props.color || 'default'" :title="data?.[DEPT_KEY]">
|
11
|
+
<div class="left-icon" ref="targetRef" @mouseenter="onShowPopover()" @mousemove="onShowPopover()"
|
12
|
+
@mouseleave="onClosePopover()">
|
13
|
+
<AAvatar v-if="!props.onlyName" :src="user_icon" :class="'avator-icon'" :size="props.size">
|
14
|
+
</AAvatar>
|
15
|
+
<span v-else>
|
16
|
+
<span v-if="props.linkType == 'text'">
|
17
|
+
{{ user_name }}
|
18
|
+
</span>
|
19
|
+
<el-link v-else :type="props.linkType" :underline="false">
|
20
|
+
{{ user_name }}
|
21
|
+
</el-link>
|
22
|
+
</span>
|
23
|
+
</div>
|
24
|
+
<slot name="prefix"></slot>
|
25
|
+
<div class="label" v-if="!props.onlyIcon && !props.onlyName">
|
26
|
+
<span class="realname">
|
27
|
+
{{
|
28
|
+
isLoading
|
29
|
+
? "加载中..."
|
30
|
+
: user_name
|
31
|
+
}}
|
32
|
+
</span>
|
33
|
+
<span class="id" v-if="!props.noID">
|
34
|
+
<span>{{ dept_name }}</span>
|
35
|
+
</span>
|
36
|
+
</div>
|
37
|
+
<div v-if="props.suffix">{{ props.suffix }}</div>
|
38
|
+
<AButton size="small" v-if="props.closable" @click.stop.prevent="onClose" :color="props.color" type="text"
|
39
|
+
shape="circle" style="margin-left: 3px; transform: translateY(0) scale(0.6); opacity: 0.8">
|
40
|
+
<template #icon>
|
41
|
+
<CloseOutlined />
|
42
|
+
</template>
|
43
|
+
</AButton>
|
44
|
+
<slot name="default" :scoped="data"></slot>
|
45
|
+
</ATag>
|
46
|
+
</div>
|
47
|
+
</template>
|
48
|
+
|
49
|
+
<script lang="jsx">
|
50
|
+
import { defineComponent } from "vue"
|
51
|
+
import {
|
52
|
+
ref,
|
53
|
+
defineEmits,
|
54
|
+
computed,
|
55
|
+
} from "vue";
|
56
|
+
import { Avatar as AAvatar, Button as AButton, Tag as ATag } from "ant-design-vue/es"
|
57
|
+
import { useCustomProps } from "./store"
|
58
|
+
import { isFunction } from "lodash-es"
|
59
|
+
import {CloseOutlined} from "@ant-design/icons-vue"
|
60
|
+
|
61
|
+
export default defineComponent({
|
62
|
+
inheritAttrs: false,
|
63
|
+
name: "BokeUserAvator", // 切记:defineOptions() vue3.3才有,请使用defineComponent
|
64
|
+
components: {
|
65
|
+
'AAvatar': AAvatar,
|
66
|
+
"AButton": AButton,
|
67
|
+
"ATag": ATag,
|
68
|
+
CloseOutlined
|
69
|
+
},
|
70
|
+
props: {
|
71
|
+
size: {
|
72
|
+
type: [Number, String],
|
73
|
+
required: false,
|
74
|
+
default: 28
|
75
|
+
},
|
76
|
+
hidePopover: {
|
77
|
+
type: Boolean,
|
78
|
+
required: false,
|
79
|
+
default: false
|
80
|
+
},
|
81
|
+
onlyIcon: {
|
82
|
+
type: Boolean,
|
83
|
+
required: false,
|
84
|
+
default: false
|
85
|
+
},
|
86
|
+
onlyName: {
|
87
|
+
type: Boolean,
|
88
|
+
required: false,
|
89
|
+
default: false
|
90
|
+
},
|
91
|
+
linkType: {
|
92
|
+
type: null,
|
93
|
+
required: false,
|
94
|
+
default: "primary"
|
95
|
+
},
|
96
|
+
data: {
|
97
|
+
type: null,
|
98
|
+
required: false,
|
99
|
+
default: null
|
100
|
+
},
|
101
|
+
shape: {
|
102
|
+
type: String,
|
103
|
+
required: false,
|
104
|
+
default: "circle"
|
105
|
+
},
|
106
|
+
insidePopover: {
|
107
|
+
type: Boolean,
|
108
|
+
required: false,
|
109
|
+
default: false
|
110
|
+
},
|
111
|
+
noID: {
|
112
|
+
type: Boolean,
|
113
|
+
required: false,
|
114
|
+
default: false
|
115
|
+
},
|
116
|
+
noDialogDetail: {
|
117
|
+
type: Boolean,
|
118
|
+
required: false,
|
119
|
+
default: false
|
120
|
+
},
|
121
|
+
tag: {
|
122
|
+
type: Boolean,
|
123
|
+
required: false,
|
124
|
+
default: false
|
125
|
+
},
|
126
|
+
closable: {
|
127
|
+
type: Boolean,
|
128
|
+
required: false,
|
129
|
+
default: false
|
130
|
+
},
|
131
|
+
color: {
|
132
|
+
type: String,
|
133
|
+
required: false,
|
134
|
+
default: ""
|
135
|
+
},
|
136
|
+
disabled: {
|
137
|
+
type: Boolean,
|
138
|
+
required: false,
|
139
|
+
default: false
|
140
|
+
},
|
141
|
+
suffix: {
|
142
|
+
type: String,
|
143
|
+
required: false,
|
144
|
+
default: ""
|
145
|
+
},
|
146
|
+
is_highlight: {
|
147
|
+
type: Function,
|
148
|
+
required: false,
|
149
|
+
default: () => false
|
150
|
+
}
|
151
|
+
},
|
152
|
+
emits: ['close'],
|
153
|
+
setup(props, { attrs, emit }) {
|
154
|
+
const { NAME_KEY, AVATAR_KEY, DEPT_KEY, USERID_KEY, global_always_avatar_is_hihglight } = useCustomProps()
|
155
|
+
const appVersion = "1.0.0";
|
156
|
+
console.log(emit,"emits")
|
157
|
+
const targetRef = ref();
|
158
|
+
const onShowPopover = () => { };
|
159
|
+
const showViewer = ref(false);
|
160
|
+
|
161
|
+
const onClosePopover = () => { };
|
162
|
+
const isMyself = ref(false);
|
163
|
+
|
164
|
+
const user_name = computed(() => {
|
165
|
+
return props.data[NAME_KEY.value] || "未知用户";
|
166
|
+
});
|
167
|
+
|
168
|
+
const dept_name = computed(() => {
|
169
|
+
return props.data[DEPT_KEY.value] || "未知部门";
|
170
|
+
});
|
171
|
+
|
172
|
+
const user_id = computed(() => {
|
173
|
+
return props.data[USERID_KEY.value] || "未知用户";
|
174
|
+
});
|
175
|
+
const data = ref<any>(props.data);
|
176
|
+
const user_icon = ref(props.data[AVATAR_KEY.value]);
|
177
|
+
const isLoading = ref(false);
|
178
|
+
|
179
|
+
const isHigh = () => {
|
180
|
+
if (global_always_avatar_is_hihglight) {
|
181
|
+
return isFunction(global_always_avatar_is_hihglight) ? global_always_avatar_is_hihglight(data.value) : global_always_avatar_is_hihglight
|
182
|
+
}
|
183
|
+
return isFunction(props.is_highlight) ? props?.is_highlight(data.value) : props.is_highlight
|
184
|
+
}
|
185
|
+
|
186
|
+
const onClose= ()=> {
|
187
|
+
emit("close")
|
188
|
+
}
|
189
|
+
return {
|
190
|
+
user_name,
|
191
|
+
dept_name,
|
192
|
+
user_id,
|
193
|
+
data,
|
194
|
+
user_icon,
|
195
|
+
isLoading,
|
196
|
+
isHigh,
|
197
|
+
props,
|
198
|
+
onShowPopover,
|
199
|
+
onClosePopover,
|
200
|
+
attrs,
|
201
|
+
emit,
|
202
|
+
onClose
|
203
|
+
}
|
204
|
+
}
|
205
|
+
})
|
206
|
+
</script>
|
207
|
+
<style lang="less" scoped>
|
208
|
+
.boke-useravator-wrapper {
|
209
|
+
display: inline-flex;
|
210
|
+
position: relative;
|
211
|
+
align-items: center;
|
212
|
+
overflow: hidden;
|
213
|
+
margin-left: 4px;
|
214
|
+
border: none;
|
215
|
+
|
216
|
+
&.ant-tag-default {
|
217
|
+
cursor: default;
|
218
|
+
background-color: transparent;
|
219
|
+
|
220
|
+
&:hover {
|
221
|
+
filter: brightness(0.8)
|
222
|
+
}
|
223
|
+
}
|
224
|
+
|
225
|
+
&.is_tag {
|
226
|
+
background-color: var(--boke-fill-color-light);
|
227
|
+
border-radius: 118px;
|
228
|
+
}
|
229
|
+
|
230
|
+
&.is_highlight {
|
231
|
+
border-radius: 118px;
|
232
|
+
background-color: var(--boke-color-primary);
|
233
|
+
color: white;
|
234
|
+
}
|
235
|
+
|
236
|
+
&.disabled {
|
237
|
+
pointer-events: none;
|
238
|
+
}
|
239
|
+
|
240
|
+
.left-icon {
|
241
|
+
display: inline-flex;
|
242
|
+
padding: 0 4px 0 2px;
|
243
|
+
position: relative;
|
244
|
+
}
|
245
|
+
|
246
|
+
&.wrapper-only-name {
|
247
|
+
margin-left: 0px;
|
248
|
+
|
249
|
+
.left-icon {
|
250
|
+
padding: 0 0px;
|
251
|
+
}
|
252
|
+
}
|
253
|
+
|
254
|
+
.label {
|
255
|
+
font-size: 12px;
|
256
|
+
white-space: nowrap;
|
257
|
+
display: flex;
|
258
|
+
flex-direction: column;
|
259
|
+
max-width: 80px;
|
260
|
+
margin-left: 4px;
|
261
|
+
|
262
|
+
span {
|
263
|
+
text-overflow: ellipsis;
|
264
|
+
overflow: hidden;
|
265
|
+
line-height: 14px;
|
266
|
+
|
267
|
+
&.realname {
|
268
|
+
margin-bottom: 0;
|
269
|
+
|
270
|
+
&.lineThrough {
|
271
|
+
// text-decoration: line-through;
|
272
|
+
color: #75757599;
|
273
|
+
}
|
274
|
+
}
|
275
|
+
|
276
|
+
&.id {
|
277
|
+
opacity: 0.7;
|
278
|
+
zoom: 0.8;
|
279
|
+
}
|
280
|
+
}
|
281
|
+
}
|
282
|
+
|
283
|
+
&.isByeBye {
|
284
|
+
opacity: 0.5;
|
285
|
+
|
286
|
+
.avator-icon {
|
287
|
+
position: relative;
|
288
|
+
|
289
|
+
&::after {
|
290
|
+
content: "";
|
291
|
+
width: inherit;
|
292
|
+
height: 100%;
|
293
|
+
position: absolute;
|
294
|
+
top: 0px;
|
295
|
+
left: 0px;
|
296
|
+
z-index: 100;
|
297
|
+
display: block;
|
298
|
+
border: 2px solid var(--boke-color-danger);
|
299
|
+
border-radius: inherit;
|
300
|
+
box-sizing: border-box;
|
301
|
+
pointer-events: none;
|
302
|
+
}
|
303
|
+
}
|
304
|
+
}
|
305
|
+
|
306
|
+
.left-icon {
|
307
|
+
:deep(.el-avatar) {
|
308
|
+
&::before {
|
309
|
+
content: "";
|
310
|
+
width: inherit;
|
311
|
+
height: 100%;
|
312
|
+
position: absolute;
|
313
|
+
top: 0px;
|
314
|
+
left: 4px;
|
315
|
+
z-index: 100;
|
316
|
+
display: block;
|
317
|
+
border: 1px solid var(--boke-border-color-extra-light);
|
318
|
+
border-radius: inherit;
|
319
|
+
box-sizing: border-box;
|
320
|
+
pointer-events: none;
|
321
|
+
mix-blend-mode: darken;
|
322
|
+
}
|
323
|
+
}
|
324
|
+
}
|
325
|
+
|
326
|
+
:deep(.el-avatar) {
|
327
|
+
img {
|
328
|
+
width: 100%;
|
329
|
+
cursor: pointer;
|
330
|
+
}
|
331
|
+
}
|
332
|
+
}
|
333
|
+
|
334
|
+
.demo-rich-conent {
|
335
|
+
:deep(.el-avatar) {
|
336
|
+
img {
|
337
|
+
width: 100%;
|
338
|
+
cursor: pointer;
|
339
|
+
}
|
340
|
+
}
|
341
|
+
}
|
342
|
+
|
343
|
+
.only-icon-style {
|
344
|
+
padding: 0;
|
345
|
+
margin: 0;
|
346
|
+
}
|
347
|
+
</style>
|