diff --git a/im-uniapp/components/head-image/head-image.vue b/im-uniapp/components/head-image/head-image.vue
index 3e4210a..1f1251e 100644
--- a/im-uniapp/components/head-image/head-image.vue
+++ b/im-uniapp/components/head-image/head-image.vue
@@ -71,11 +71,15 @@ export default {
avatarTextStyle() {
return `width: ${this._size}rpx;
height:${this._size}rpx;
- background-color:${this.name ? this.textColor : '#fff'};
- font-size:${this._size * 0.5}rpx;
+ background: linear-gradient(145deg,#ffffff20 25%,#00000060),${this.textColor};
+ font-size:${this._size * 0.45}rpx;
+ border-radius: ${this.radius};
`
},
textColor() {
+ if(!this.name){
+ return '#fff';
+ }
let hash = 0;
for (var i = 0; i < this.name.length; i++) {
hash += this.name.charCodeAt(i);
diff --git a/im-web/src/components/common/HeadImage.vue b/im-web/src/components/common/HeadImage.vue
index ed0008f..40fa044 100644
--- a/im-web/src/components/common/HeadImage.vue
+++ b/im-web/src/components/common/HeadImage.vue
@@ -2,7 +2,7 @@
- {{ name?.substring(0, 2).toUpperCase() }}
+ {{ avaterText }}
@@ -66,6 +66,9 @@ export default {
this.$eventBus.$emit("openUserInfo", user, pos);
})
}
+ },
+ isChinese(charCode) {
+ return charCode >= 0x4e00 && charCode <= 0x9fa5;
}
},
computed: {
@@ -78,14 +81,21 @@ export default {
avatarTextStyle() {
let w = this.width ? this.width : this.size;
let h = this.height ? this.height : this.size;
- return `
- width: ${w}px;height:${h}px;
- background-color: ${this.name ? this.textColor : '#fff'};
- font-size:${w * 0.35}px;
- border-radius: ${this.radius};
- `
+ return `width: ${w}px;height:${h}px;
+ background: linear-gradient(145deg,#ffffff20 25%,#00000060),${this.textColor};
+ font-size:${w * 0.4}px;
+ border-radius: ${this.radius};`
+ },
+ avaterText() {
+ if (!this.name) return '';
+ if (this.isChinese(this.name.charCodeAt(0))) {
+ return this.name.charAt(0)
+ } else {
+ return this.name.charAt(0).toUpperCase() + this.name.charAt(1)
+ }
},
textColor() {
+ if (!this.name) return 'fff';
let hash = 0;
for (var i = 0; i < this.name.length; i++) {
hash += this.name.charCodeAt(i);