mx-ui-template 0.1.5 → 0.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,44 +1,45 @@
1
- function i(t, e, o) {
2
- const n = document.createElement("canvas");
3
- n.width = e, n.height = e;
4
- const r = n.getContext("2d");
5
- return r.beginPath(), r.arc(e / 2, e / 2, e / 2, 0, Math.PI * 2), r.fillStyle = a(t), r.fill(), r.font = `bold ${e / o}rem Arial`, r.textAlign = "center", r.textBaseline = "middle", r.fillStyle = "#fff", r.fillText(
1
+ function c(t, n, i) {
2
+ const r = document.createElement("canvas");
3
+ let { size: e, baseFontSize: a } = i || {};
4
+ e = e || 128, n ? a = a || 20 * 3.5 : a = a || 20 * 1.5, r.width = e, r.height = e;
5
+ const o = r.getContext("2d");
6
+ return o.beginPath(), o.arc(e / 2, e / 2, e / 2, 0, Math.PI * 2), o.fillStyle = l(t), o.fill(), o.font = `bold ${e / a}rem Arial`, o.textAlign = "center", o.textBaseline = "middle", o.fillStyle = "#fff", o.fillText(
6
7
  t.charAt(0).toUpperCase() + t.charAt(1).toUpperCase(),
7
8
  e / 2,
8
9
  e / 2
9
- ), n.toDataURL("image/png");
10
+ ), r.toDataURL("image/png");
10
11
  }
11
- function a(t) {
12
- let e = 0;
13
- for (let n = 0; n < t.length; n++)
14
- e = t.charCodeAt(n) + ((e << 5) - e);
15
- return "#" + (e & 16777215).toString(16).padStart(6, "0");
12
+ function l(t) {
13
+ let n = 0;
14
+ for (let r = 0; r < t.length; r++)
15
+ n = t.charCodeAt(r) + ((n << 5) - n);
16
+ return "#" + (n & 16777215).toString(16).padStart(6, "0");
16
17
  }
17
- function c(t, e) {
18
+ function f(t, n) {
18
19
  if (!t) return "";
19
- const o = t instanceof Date ? t : new Date(t);
20
- if (Number.isNaN(o.getTime())) return "";
21
- const n = e?.locale ?? void 0, r = e?.options ?? {
20
+ const i = t instanceof Date ? t : new Date(t);
21
+ if (Number.isNaN(i.getTime())) return "";
22
+ const r = n?.locale ?? void 0, e = n?.options ?? {
22
23
  year: "numeric",
23
24
  month: "2-digit",
24
25
  day: "2-digit"
25
26
  };
26
- return new Intl.DateTimeFormat(n, r).format(o);
27
+ return new Intl.DateTimeFormat(r, e).format(i);
27
28
  }
28
- function l(t) {
29
+ function s(t) {
29
30
  return t == null ? !0 : typeof t == "string" ? t.trim() === "" : Array.isArray(t) ? t.length === 0 : typeof t == "object" ? Object.keys(t).length === 0 : !1;
30
31
  }
31
- const f = {
32
- formatDate: c,
33
- isEmpty: l,
34
- generateTextAvatar: i,
35
- generateColor: a
32
+ const g = {
33
+ formatDate: f,
34
+ isEmpty: s,
35
+ generateTextAvatar: c,
36
+ generateColor: l
36
37
  };
37
38
  export {
38
- f as default,
39
- c as formatDate,
40
- a as generateColor,
41
- i as generateTextAvatar,
42
- l as isEmpty,
43
- f as utils
39
+ g as default,
40
+ f as formatDate,
41
+ l as generateColor,
42
+ c as generateTextAvatar,
43
+ s as isEmpty,
44
+ g as utils
44
45
  };
@@ -1 +1 @@
1
- (function(n,i){typeof exports=="object"&&typeof module<"u"?i(exports):typeof define=="function"&&define.amd?define(["exports"],i):(n=typeof globalThis<"u"?globalThis:n||self,i(n.MxUIUtils={}))})(this,(function(n){"use strict";function i(t,e,a){const o=document.createElement("canvas");o.width=e,o.height=e;const r=o.getContext("2d");return r.beginPath(),r.arc(e/2,e/2,e/2,0,Math.PI*2),r.fillStyle=f(t),r.fill(),r.font=`bold ${e/a}rem Arial`,r.textAlign="center",r.textBaseline="middle",r.fillStyle="#fff",r.fillText(t.charAt(0).toUpperCase()+t.charAt(1).toUpperCase(),e/2,e/2),o.toDataURL("image/png")}function f(t){let e=0;for(let o=0;o<t.length;o++)e=t.charCodeAt(o)+((e<<5)-e);return"#"+(e&16777215).toString(16).padStart(6,"0")}function l(t,e){if(!t)return"";const a=t instanceof Date?t:new Date(t);if(Number.isNaN(a.getTime()))return"";const o=e?.locale??void 0,r=e?.options??{year:"numeric",month:"2-digit",day:"2-digit"};return new Intl.DateTimeFormat(o,r).format(a)}function c(t){return t==null?!0:typeof t=="string"?t.trim()==="":Array.isArray(t)?t.length===0:typeof t=="object"?Object.keys(t).length===0:!1}const d={formatDate:l,isEmpty:c,generateTextAvatar:i,generateColor:f};n.default=d,n.formatDate=l,n.generateColor=f,n.generateTextAvatar=i,n.isEmpty=c,n.utils=d,Object.defineProperties(n,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
1
+ (function(n,a){typeof exports=="object"&&typeof module<"u"?a(exports):typeof define=="function"&&define.amd?define(["exports"],a):(n=typeof globalThis<"u"?globalThis:n||self,a(n.MxUIUtils={}))})(this,(function(n){"use strict";function a(t,r,f){const i=document.createElement("canvas");let{size:e,baseFontSize:l}=f||{};e=e||128,r?l=l||20*3.5:l=l||20*1.5,i.width=e,i.height=e;const o=i.getContext("2d");return o.beginPath(),o.arc(e/2,e/2,e/2,0,Math.PI*2),o.fillStyle=c(t),o.fill(),o.font=`bold ${e/l}rem Arial`,o.textAlign="center",o.textBaseline="middle",o.fillStyle="#fff",o.fillText(t.charAt(0).toUpperCase()+t.charAt(1).toUpperCase(),e/2,e/2),i.toDataURL("image/png")}function c(t){let r=0;for(let i=0;i<t.length;i++)r=t.charCodeAt(i)+((r<<5)-r);return"#"+(r&16777215).toString(16).padStart(6,"0")}function s(t,r){if(!t)return"";const f=t instanceof Date?t:new Date(t);if(Number.isNaN(f.getTime()))return"";const i=r?.locale??void 0,e=r?.options??{year:"numeric",month:"2-digit",day:"2-digit"};return new Intl.DateTimeFormat(i,e).format(f)}function d(t){return t==null?!0:typeof t=="string"?t.trim()==="":Array.isArray(t)?t.length===0:typeof t=="object"?Object.keys(t).length===0:!1}const u={formatDate:s,isEmpty:d,generateTextAvatar:a,generateColor:c};n.default=u,n.formatDate=s,n.generateColor=c,n.generateTextAvatar=a,n.isEmpty=d,n.utils=u,Object.defineProperties(n,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
package/package.json CHANGED
@@ -1,7 +1,8 @@
1
1
  {
2
2
  "name": "mx-ui-template",
3
3
  "private": false,
4
- "version": "0.1.5",
4
+ "version": "0.1.7",
5
+ "description": "修改头像生成逻辑,简约参数传递",
5
6
  "type": "module",
6
7
  "main": "./dist/mx-ui-template.umd.cjs",
7
8
  "module": "./dist/mx-ui-template.js",