From a99886eb9c73018235e2c373f3d82a2b0b2311d5 Mon Sep 17 00:00:00 2001
From: zhangchen <1652267879@qq.com>
Date: 星期二, 16 九月 2025 13:36:40 +0800
Subject: [PATCH] Merge branch 'ID1766-添加推送登录功能' into test
---
src/views/mobile/bedsideAuxiliaryScreen/components/Header.vue | 34 +++++++++++++++++++++++++++++++++-
1 files changed, 33 insertions(+), 1 deletions(-)
diff --git a/src/views/mobile/bedsideAuxiliaryScreen/components/Header.vue b/src/views/mobile/bedsideAuxiliaryScreen/components/Header.vue
index cb20147..2807483 100644
--- a/src/views/mobile/bedsideAuxiliaryScreen/components/Header.vue
+++ b/src/views/mobile/bedsideAuxiliaryScreen/components/Header.vue
@@ -65,7 +65,8 @@
alt=""
@click="openSettingDeviceDialog"
/>
- <img :src="userImg" class="btn-img" alt="" @click="openLoginDialog" />
+ <img v-if="userInfo?.code" :src="userInfo?.userAvatar" class="btn-img" alt="" @click="openLoginDialog" />
+ <img v-else :src="userImg" class="btn-img" alt="" @click="openLoginDialog" />
</div>
</div>
<!-- 设置设备编号组件 -->
@@ -164,6 +165,14 @@
}
});
+
+const userInfo = computed(() => {
+ if (!bedsideAuxiliaryScreenStore.userInfo) return null
+ return Object.assign({}, bedsideAuxiliaryScreenStore.userInfo, {
+ userAvatar: bedsideAuxiliaryScreenStore.userInfo?.userAvatar ? bedsideAuxiliaryScreenStore.userInfo?.userAvatar : generateCircularAvatar(bedsideAuxiliaryScreenStore.userInfo?.userName)
+ });
+});
+
watch(
() => bedsideAuxiliaryScreenStore.taskData?.[0]?.countdown,
(val) => {
@@ -246,6 +255,29 @@
loginDialogRef.value.openDialog();
};
+function generateCircularAvatar(name: string, size = 100): string {
+ console.log('name: ', name)
+ const canvas = document.createElement('canvas');
+ canvas.width = size;
+ canvas.height = size;
+ const ctx = canvas.getContext('2d')!;
+
+ // 绘制圆形背景
+ ctx.fillStyle = '#dae5ec';
+ ctx.beginPath();
+ ctx.arc(size / 2, size / 2, size / 2, 0, Math.PI * 2);
+ ctx.fill();
+
+ // 绘制文字(第一个字)
+ ctx.fillStyle = '#70a3dd'; // 字体颜色
+ ctx.font = `${size * 0.5}px sans-serif`; // 字体大小为头像大小的一半
+ ctx.textAlign = 'center';
+ ctx.textBaseline = 'middle';
+ ctx.fillText(name.charAt(0), size / 2, size / 2);
+
+ return canvas.toDataURL('image/png'); // 返回 Base64 图片
+}
+
onUnmounted(() => {
clearTimer();
});
--
Gitblit v1.8.0