fix(image-tools): 文字模板区改为常驻侧栏顶部(用户找不到模板入口)

- 模板区显示条件从「文字工具或选中文字层」改为「图片已加载即显示」,
  并移到侧栏第一位(✨ 文字模板 → 图层 → 属性 → 历史)
- 点击模板在任意工具下都直接插入画布;若当前非文字/移动工具则自动
  切到移动工具,插入后立即可拖动旋转
- 实测:默认打开图片编辑(移动工具激活)模板区即可见(14款),
  点「黄字紫描边」直接插入(历史「套用模板」),截图验收无布局问题
This commit is contained in:
personal82555 committed 2026-10-21 23:06:57 +08:00
1 parent 263d52475f
commit e65eb89fa9
1 file changed
+20 -17
+20 -17
View File
@@ -718,6 +718,9 @@ function applyTpl(t: TextTpl): void {
const m = textMetrics(tl);
tl.x = Math.round((docW.value - m.w) / 2);
tl.y = Math.round(Math.max(8, docH.value * 0.1));
if (tool.value !== 'text' && tool.value !== 'move') {
tool.value = 'move'; // 插入后直接可拖动/旋转
}
commit(`套用模板「${t.name}」`);
composite();
scheduleRender();
@@ -1920,6 +1923,23 @@ onBeforeUnmount(() => {
<canvas ref="viewCanvas" :style="{ cursor: cursorCss }" />
</div>
<div class="psx-side">
<div v-if="docW" class="psx-sec psx-tpl-sec">
<div class="psx-sec-t">
✨ 文字模板
<span class="psx-tip">点击即插入套用</span>
</div>
<div class="psx-tpl-grid">
<button
v-for="t in TEXT_TPLS"
:key="t.id"
class="psx-tpl"
:title="`${t.name} — ${activeLayer?.type === 'text' ? '应用到当前文字' : '插入并应用'}`"
@click="applyTpl(t)"
>
<span :style="tplStyle(t)">文字</span>
</button>
</div>
</div>
<div class="psx-sec">
<div class="psx-sec-t">
图层
@@ -1949,23 +1969,6 @@ onBeforeUnmount(() => {
</div>
</div>
</div>
<div v-if="tool === 'text' || activeLayer?.type === 'text'" class="psx-sec">
<div class="psx-sec-t">
文字模板
<span class="psx-tip">点击套用</span>
</div>
<div class="psx-tpl-grid">
<button
v-for="t in TEXT_TPLS"
:key="t.id"
class="psx-tpl"
:title="`${t.name} — ${activeLayer?.type === 'text' ? '应用到当前文字' : '插入并应用'}`"
@click="applyTpl(t)"
>
<span :style="tplStyle(t)">文字</span>
</button>
</div>
</div>
<div v-if="activeLayer && activeLayer.type !== 'image'" class="psx-sec">
<div class="psx-sec-t">属性</div>
<div class="psx-prop">