!153 feat(utils): 添加文本宽度测量工具函数

* feat(utils): 添加文本宽度测量工具函数
This commit is contained in:
binny1024
2025-06-15 07:45:51 +00:00
committed by 芋道源码
parent 032c32b337
commit 6c6f8c84aa
2 changed files with 37 additions and 2 deletions
@@ -1,10 +1,11 @@
import sheep from '@/sheep';
import { formatImageUrlProtocol, getWxaQrcode } from './index';
import { measureTextWidth } from '@/utils/textUtils'; // 引入新封装的方法
const user = async (poster) => {
const width = poster.width;
const userInfo = sheep.$store('user').userInfo;
const wxa_qrcode = await getWxaQrcode(poster.shareInfo.path, poster.shareInfo.query);
const widthNickName = measureTextWidth(userInfo.nickname, 14); // 使用新方法
return [
{
type: 'image',
@@ -28,7 +29,7 @@ const user = async (poster) => {
fontFamily: 'sans-serif',
position: 'fixed',
top: width * 0.4,
left: width / 2,
left: (width-widthNickName) / 2,
},
},
{