适配
This commit is contained in:
18
src/App.tsx
18
src/App.tsx
@@ -290,7 +290,7 @@ export default function App() {
|
||||
const handleExportTemplate = (tmpl: LabelTemplate) => {
|
||||
const dataStr = JSON.stringify(normalizeTemplate(tmpl), null, 2);
|
||||
const dataUri = 'data:application/json;charset=utf-8,' + encodeURIComponent(dataStr);
|
||||
const exportFileDefaultName = `模板_${tmpl.name?.replace(/\s+/g, '_') || tmpl.id}.json`;
|
||||
const exportFileDefaultName = `模板_${tmpl.name?.replace(/\s+/g, '_') || tmpl.id}.lad`;
|
||||
|
||||
const linkElement = document.createElement('a');
|
||||
linkElement.setAttribute('href', dataUri);
|
||||
@@ -325,12 +325,12 @@ export default function App() {
|
||||
handleSelectTemplate(newId);
|
||||
await showAlert('模板读取解析成功,已追加至库中。', { variant: 'success' });
|
||||
} else {
|
||||
await showAlert('JSON格式错误:外部模板必须至少包含 width, height, 以及 elements 分组', {
|
||||
await showAlert('模板格式错误:外部模板必须至少包含 width, height, 以及 elements 分组', {
|
||||
variant: 'error',
|
||||
});
|
||||
}
|
||||
} catch (err) {
|
||||
await showAlert('文件解码失败,请确保您上传的是合法的 json 模板结构文件。', {
|
||||
await showAlert('文件解码失败,请确保您上传的是合法的模板文件。', {
|
||||
variant: 'error',
|
||||
});
|
||||
}
|
||||
@@ -648,10 +648,10 @@ export default function App() {
|
||||
</button>
|
||||
<label className="inline-flex items-center gap-1.5 px-4 py-2 bg-white/10 hover:bg-white/15 border border-slate-700 text-slate-100 rounded-xl text-xs font-semibold whitespace-nowrap transition shadow-sm cursor-pointer">
|
||||
<Upload className="w-4 h-4 shrink-0" />
|
||||
导入 JSON 模板
|
||||
导入模板
|
||||
<input
|
||||
type="file"
|
||||
accept=".json"
|
||||
accept=".lad"
|
||||
onChange={handleImportTemplate}
|
||||
className="hidden"
|
||||
/>
|
||||
@@ -692,7 +692,7 @@ export default function App() {
|
||||
<p className="text-sm text-gray-500 mt-2 max-w-md leading-relaxed">
|
||||
{isMobile
|
||||
? '导入已有模板,或在电脑端设计标签模板'
|
||||
: '创建模板开始可视化设计,或导入已有的 JSON 模板文件。'}
|
||||
: '创建模板开始可视化设计,或导入已有的模板文件。'}
|
||||
</p>
|
||||
<div className="flex flex-col sm:flex-row items-center justify-center gap-3 mt-3">
|
||||
{!isMobile && (
|
||||
@@ -707,10 +707,10 @@ export default function App() {
|
||||
)}
|
||||
<label className="inline-flex items-center justify-center gap-2 px-5 py-2.5 bg-white border border-gray-200 hover:border-indigo-300 text-gray-700 rounded-xl text-sm font-semibold transition shadow-sm cursor-pointer shrink-0">
|
||||
<Upload className="w-4 h-4 shrink-0" />
|
||||
导入 JSON 模板
|
||||
导入模板
|
||||
<input
|
||||
type="file"
|
||||
accept=".json"
|
||||
accept=".lad"
|
||||
onChange={handleImportTemplate}
|
||||
className="hidden"
|
||||
/>
|
||||
@@ -814,7 +814,7 @@ export default function App() {
|
||||
handleExportTemplate(tmpl);
|
||||
}}
|
||||
className="shrink-0 p-1.5 bg-gray-50 text-gray-500 hover:bg-gray-100 border border-gray-100 hover:border-gray-300 rounded-lg inline-flex items-center justify-center transition cursor-pointer"
|
||||
title="导出 JSON"
|
||||
title="导出"
|
||||
>
|
||||
<Download className="w-3.5 h-3.5" />
|
||||
</button>
|
||||
|
||||
Reference in New Issue
Block a user