UNPKG

mine-h5-ui

Version:

一款轻量级、模块化基于 Vue3.x 的 H5 前端 UI 组件库 👍

22 lines (21 loc) 803 B
import { computed as a } from "vue"; import { mergeDefaultWithProps as l, viewBoxSize as r } from "./config.js"; /*! * mine-h5-ui v2.15.0 * Copyright (c) 2025 biaov * @license MIT */ const g = (o) => { const c = document.createElement("canvas").getContext("2d"), i = ({ text: t, size: e, family: m }) => { c.font = `${e}px ${m}`; const n = c.measureText(t), u = n.width + 10, f = n.fontBoundingBoxAscent + n.fontBoundingBoxDescent; return { width: u, height: f }; }, s = a(() => { const t = l(o), e = i({ text: t.text, size: t.size, family: t.family }); return { ...t, ...e, viewBoxSize: `${r}px` }; }), x = a(() => i({ text: o.text, size: r, family: s.value.family })); return { rect: s, viewBox: x }; }; export { g as useHandle };