update at 2026-02-14 16:38:52

This commit is contained in:
douboer
2026-02-14 16:38:52 +08:00
parent 1fb3b51beb
commit b7dac22327
6 changed files with 17 additions and 9 deletions

View File

@@ -1 +1 @@
import{_ as v}from"./index-BOK_W8r_.js";function p(t,e,n="text/plain"){const o=new Blob([t],{type:n});s(o,e)}function s(t,e){const n=URL.createObjectURL(t),o=document.createElement("a");o.href=n,o.download=e,document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(n)}function P(t,e){p(t,e,"image/svg+xml")}async function F(t,e="font2svg-export.zip"){const n=(await v(async()=>{const{default:r}=await import("./jszip.min-D7KnG0-e.js").then(i=>i.j);return{default:r}},[])).default,o=new n;for(const r of t)o.file(r.name,r.content);const a=await o.generateAsync({type:"blob"});s(a,e)}function d(t){if(!t)return null;const e=t.match(/-?\d+(\.\d+)?/);if(!e)return null;const n=Number(e[0]);return Number.isFinite(n)?n:null}function x(t){const n=new DOMParser().parseFromString(t,"image/svg+xml").documentElement,o=d(n.getAttribute("width")),a=d(n.getAttribute("height"));if(o&&a)return{width:o,height:a};const r=n.getAttribute("viewBox");if(r){const i=r.trim().split(/[\s,]+/).map(Number);if(i.length===4&&Number.isFinite(i[2])&&Number.isFinite(i[3]))return{width:Math.max(1,i[2]),height:Math.max(1,i[3])}}return{width:1024,height:1024}}async function _(t,e){const n=x(t),o=e?.scale??1,a=Math.max(1,Math.round((e?.width??n.width)*o)),r=Math.max(1,Math.round((e?.height??n.height)*o)),i=document.createElement("canvas");i.width=a,i.height=r;const l=i.getContext("2d");if(!l)throw new Error("无法创建 PNG 画布");e?.backgroundColor?(l.fillStyle=e.backgroundColor,l.fillRect(0,0,a,r)):l.clearRect(0,0,a,r);const f=new Blob([t],{type:"image/svg+xml;charset=utf-8"}),u=URL.createObjectURL(f);try{const c=new Image;await new Promise((w,b)=>{c.onload=()=>w(),c.onerror=()=>b(new Error("SVG 转 PNG 失败")),c.src=u}),l.drawImage(c,0,0,a,r)}finally{URL.revokeObjectURL(u)}const g=await new Promise(c=>{i.toBlob(c,"image/png")});if(!g)throw new Error("PNG 编码失败");return g}async function R(t,e,n){const o=await _(t,n);s(o,e)}function m(t){return t.replace(/[<>:"/\\|?*\x00-\x1F]/g,"_").replace(/\s+/g,"_").substring(0,200)}function h(t,e){const n=m(Array.from(t).slice(0,8).join(""));return`${m(e.substring(0,20))}_${n}`}function B(t,e){return`${h(t,e)}.svg`}function L(t,e){return`${h(t,e)}.png`}export{_ as convertSvgToPngBlob,s as downloadBlob,F as downloadMultipleFiles,R as downloadPngFromSvg,P as downloadSvg,p as downloadText,L as generatePngFilename,B as generateSvgFilename,m as sanitizeFilename}; import{_ as v}from"./index-RDAzKva3.js";function p(t,e,n="text/plain"){const o=new Blob([t],{type:n});s(o,e)}function s(t,e){const n=URL.createObjectURL(t),o=document.createElement("a");o.href=n,o.download=e,document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(n)}function P(t,e){p(t,e,"image/svg+xml")}async function F(t,e="font2svg-export.zip"){const n=(await v(async()=>{const{default:r}=await import("./jszip.min-D7KnG0-e.js").then(i=>i.j);return{default:r}},[])).default,o=new n;for(const r of t)o.file(r.name,r.content);const a=await o.generateAsync({type:"blob"});s(a,e)}function d(t){if(!t)return null;const e=t.match(/-?\d+(\.\d+)?/);if(!e)return null;const n=Number(e[0]);return Number.isFinite(n)?n:null}function x(t){const n=new DOMParser().parseFromString(t,"image/svg+xml").documentElement,o=d(n.getAttribute("width")),a=d(n.getAttribute("height"));if(o&&a)return{width:o,height:a};const r=n.getAttribute("viewBox");if(r){const i=r.trim().split(/[\s,]+/).map(Number);if(i.length===4&&Number.isFinite(i[2])&&Number.isFinite(i[3]))return{width:Math.max(1,i[2]),height:Math.max(1,i[3])}}return{width:1024,height:1024}}async function _(t,e){const n=x(t),o=e?.scale??1,a=Math.max(1,Math.round((e?.width??n.width)*o)),r=Math.max(1,Math.round((e?.height??n.height)*o)),i=document.createElement("canvas");i.width=a,i.height=r;const l=i.getContext("2d");if(!l)throw new Error("无法创建 PNG 画布");e?.backgroundColor?(l.fillStyle=e.backgroundColor,l.fillRect(0,0,a,r)):l.clearRect(0,0,a,r);const f=new Blob([t],{type:"image/svg+xml;charset=utf-8"}),u=URL.createObjectURL(f);try{const c=new Image;await new Promise((w,b)=>{c.onload=()=>w(),c.onerror=()=>b(new Error("SVG 转 PNG 失败")),c.src=u}),l.drawImage(c,0,0,a,r)}finally{URL.revokeObjectURL(u)}const g=await new Promise(c=>{i.toBlob(c,"image/png")});if(!g)throw new Error("PNG 编码失败");return g}async function R(t,e,n){const o=await _(t,n);s(o,e)}function m(t){return t.replace(/[<>:"/\\|?*\x00-\x1F]/g,"_").replace(/\s+/g,"_").substring(0,200)}function h(t,e){const n=m(Array.from(t).slice(0,8).join(""));return`${m(e.substring(0,20))}_${n}`}function B(t,e){return`${h(t,e)}.svg`}function L(t,e){return`${h(t,e)}.png`}export{_ as convertSvgToPngBlob,s as downloadBlob,F as downloadMultipleFiles,R as downloadPngFromSvg,P as downloadSvg,p as downloadText,L as generatePngFilename,B as generateSvgFilename,m as sanitizeFilename};

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -8,8 +8,8 @@
<link rel="apple-touch-icon" href="/favicon_new.png" /> <link rel="apple-touch-icon" href="/favicon_new.png" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Font2SVG - 字体转SVG工具</title> <title>Font2SVG - 字体转SVG工具</title>
<script type="module" crossorigin src="/assets/index-BOK_W8r_.js"></script> <script type="module" crossorigin src="/assets/index-RDAzKva3.js"></script>
<link rel="stylesheet" crossorigin href="/assets/index-BgOAveGB.css"> <link rel="stylesheet" crossorigin href="/assets/index-9cGmT6aX.css">
</head> </head>
<body> <body>
<div id="app"></div> <div id="app"></div>

View File

@@ -429,7 +429,7 @@ console.log('App.vue: script setup completed')
</div> </div>
<!-- 底部版权 --> <!-- 底部版权 -->
<div class="copyright-footer text-[#86909c] text-xs text-center shrink-0 h-6 pt-4 flex items-center justify-center px-2"> <div class="copyright-footer text-[#86909c] text-xs text-center shrink-0 flex items-center justify-center px-2">
@版权说明所有字体来源互联网分享仅供效果预览不做下载传播如有侵权请告知douboer@gmail.com @版权说明所有字体来源互联网分享仅供效果预览不做下载传播如有侵权请告知douboer@gmail.com
</div> </div>
</div> </div>
@@ -476,6 +476,7 @@ console.log('App.vue: script setup completed')
@media (max-width: 768px) { @media (max-width: 768px) {
.app-container { .app-container {
padding: 4px; padding: 4px;
overflow: hidden;
} }
/* 顶部工具栏 - 压缩 */ /* 顶部工具栏 - 压缩 */
@@ -550,8 +551,9 @@ console.log('App.vue: script setup completed')
/* 主内容区 - 改为垂直布局 */ /* 主内容区 - 改为垂直布局 */
.main-content { .main-content {
flex-direction: column; flex-direction: column;
gap: 8px; gap: 4px;
padding: 0 4px; padding: 0 4px;
overflow: hidden;
} }
/* 隐藏桌面端左侧栏 */ /* 隐藏桌面端左侧栏 */
@@ -573,7 +575,7 @@ console.log('App.vue: script setup completed')
/* 显示移动端底部区域 */ /* 显示移动端底部区域 */
.bottom-section-mobile { .bottom-section-mobile {
display: flex !important; display: flex !important;
flex-direction: column; flex-direction: row;
gap: 8px; gap: 8px;
flex: 1; flex: 1;
min-height: 0; min-height: 0;
@@ -604,8 +606,9 @@ console.log('App.vue: script setup completed')
/* 版权信息缩小 */ /* 版权信息缩小 */
.copyright-footer { .copyright-footer {
font-size: 10px; font-size: 10px;
padding: 8px 0; padding: 4px 0;
height: auto; height: auto;
flex-shrink: 0;
} }
} }
@@ -640,5 +643,10 @@ console.log('App.vue: script setup completed')
width: 32px !important; width: 32px !important;
height: 24px !important; height: 24px !important;
} }
/* 手机端底部区域垂直布局 */
.bottom-section-mobile {
flex-direction: column;
}
} }
</style> </style>