1818
1919 <div class =" container" :class =" { 'has-warning': showSecurityWarning }" >
2020 <!-- 修改法律免责说明 -->
21- <div class =" legal-disclaimer"
21+ <div class =" legal-disclaimer"
2222 v-if =" showSecurityWarning"
2323 :class =" { 'hidden': !showSecurityWarning }" >
2424 <div class =" disclaimer-content" >
3535 </div >
3636 <EditorControls
3737 v-if =" isDrawStampUtilsReady"
38- ref =" editorControls "
38+ ref =" editorControlsRef "
3939 :drawStampUtils =" drawStampUtils"
4040 @updateDrawStamp =" updateDrawStamp"
4141 />
5959 <span class =" button-icon" >🔍</span >
6060 {{ t('stamp.extract.tool') }}
6161 </button >
62-
62+
6363 <!-- 添加拖动开关 -->
6464 <div class =" drag-switch-container" >
6565 <span class =" drag-label" >{{ t('stamp.drag.label') }}</span >
7272 </div >
7373 <!-- 右侧工具栏 -->
7474 <div class =" right-toolbar" >
75-
75+
7676 </div >
7777 <!-- 使用模板弹窗组件 -->
7878 <TemplateDialog
@@ -101,7 +101,7 @@ const { t } = useI18n()
101101// 添加一个标志来控制 EditorControls 的加载
102102const isDrawStampUtilsReady = ref (false )
103103
104- const editorControls = ref <InstanceType <typeof EditorControls > | null >(null )
104+ const editorControlsRef = ref <InstanceType <typeof EditorControls > | null >(null )
105105const stampCanvas = ref <any | null >(null )
106106const MM_PER_PIXEL = 10 // 毫米换算像素
107107
@@ -127,10 +127,10 @@ const initDrawStampUtils = () => {
127127const drawStamp = (refreshSecurityPattern : boolean = false , refreshOld : boolean = false , refreshRoughEdge : boolean = false ) => {
128128 // 使用drawstamputils进行绘制
129129 drawStampUtils .refreshStamp (refreshSecurityPattern , refreshOld , refreshRoughEdge )
130-
130+
131131 // 确保拖动设置与当前状态一致
132132 drawStampUtils .setDraggable (isDraggable .value )
133-
133+
134134 // 更新文字路径
135135 companyTextPaths = drawStampUtils .drawCompanyUtils .getTextPaths ()
136136 codeTextPaths = drawStampUtils .drawCodeUtils .getTextPaths ()
@@ -168,13 +168,13 @@ const loadSystemFonts = async () => {
168168onMounted (async () => {
169169 initDrawStampUtils ()
170170 await loadSystemFonts ()
171-
171+
172172 // 设置初始拖动状态
173173 drawStampUtils .setDraggable (isDraggable .value )
174174 if (stampCanvas .value ) {
175175 stampCanvas .value .style .cursor = isDraggable .value ? ' move' : ' default'
176176 }
177-
177+
178178 drawStamp ()
179179 // 加载模板列表,这里是预览的模板列表
180180 loadTemplatesFromStorage ()
@@ -327,11 +327,11 @@ const saveCurrentAsTemplate = async () => {
327327 localStorage .setItem (' stampTemplates' , JSON .stringify (templateList .value ))
328328}
329329
330- // 加载模板
330+ // 加载模板,从模板弹窗选中模板,需要将模板的值设置到左边设置里面
331331const loadSelectedTemplate = (template : Template ) => {
332332 try {
333333 isDrawStampUtilsReady .value = false
334-
334+ // 绘制印章
335335 drawStampUtils = new DrawStampUtils (stampCanvas .value , MM_PER_PIXEL )
336336 drawStamp ()
337337 // 初始化所有字体选择器的预览
@@ -344,7 +344,7 @@ const loadSelectedTemplate = (template: Template) => {
344344 window .addEventListener (' mousemove' , handleMouseMove )
345345 drawStampUtils ?.canvas ?.addEventListener (' click' , handleCanvasClick )
346346
347-
347+ // 将选中的config进行设置
348348 const newConfig = JSON .parse (JSON .stringify (template .config )) as IDrawStampConfig
349349 newConfig .ruler .showRuler = true
350350 newConfig .ruler .showFullRuler = true
@@ -360,8 +360,10 @@ const loadSelectedTemplate = (template: Template) => {
360360 // drawStampUtils.refreshStamp()
361361 setTimeout (() => {
362362 isDrawStampUtilsReady .value = true
363+ console .log (" refresh editor controls" )
364+ editorControlsRef .value .restoreDrawConfigs ()
363365 }, 100 )
364-
366+
365367 // 更新当前选中的模板索引(使用负数表示默认模板)
366368 currentTemplateIndex .value = - 1 - defaultTemplates .findIndex (t => t === template )
367369 } catch (error ) {
@@ -413,7 +415,7 @@ const loadTemplatesFromStorage = () => {
413415 // 设置模板配置
414416 tempDrawStampUtils .setDrawConfigs (template .config )
415417 tempDrawStampUtils .refreshStamp ()
416-
418+
417419 // 生成预览图
418420 template .preview = tempCanvas .toDataURL (' image/png' )
419421 })
@@ -437,11 +439,11 @@ const handleMouseMove = (event: MouseEvent) => {
437439 // 检查是否悬停在文字上
438440 let isOverText = false
439441 for (const textPath of allTextPaths ) {
440- if (x >= textPath .bounds .x &&
442+ if (x >= textPath .bounds .x &&
441443 x <= textPath .bounds .x + textPath .bounds .width &&
442- y >= textPath .bounds .y &&
444+ y >= textPath .bounds .y &&
443445 y <= textPath .bounds .y + textPath .bounds .height ) {
444-
446+
445447 isOverText = true
446448 showTooltip .value = true
447449 tooltipStyle .value = {
@@ -454,7 +456,7 @@ const handleMouseMove = (event: MouseEvent) => {
454456 return
455457 }
456458 }
457-
459+
458460 if (! isOverText ) {
459461 showTooltip .value = false
460462 drawStampUtils .canvas .style .cursor = ' default'
@@ -468,14 +470,14 @@ const handleCanvasClick = (event: MouseEvent) => {
468470 const rect = drawStampUtils .canvas .getBoundingClientRect ()
469471 const x = event .clientX - rect .left
470472 const y = event .clientY - rect .top
471-
473+
472474 // 检查点击的文字
473475 for (const textPath of allTextPaths ) {
474- if (x >= textPath .bounds .x &&
476+ if (x >= textPath .bounds .x &&
475477 x <= textPath .bounds .x + textPath .bounds .width &&
476- y >= textPath .bounds .y &&
478+ y >= textPath .bounds .y &&
477479 y <= textPath .bounds .y + textPath .bounds .height ) {
478-
480+
479481 // 打印文字信息
480482 console .log (' 点击的文字:' , textPath .text )
481483 console .log (' 文字路径:' , textPath .path )
@@ -486,29 +488,29 @@ const handleCanvasClick = (event: MouseEvent) => {
486488 if (textPath .type === ' company' ) {
487489 const companyIndex = findCompanyIndexByText (textPath .text )
488490 if (companyIndex !== - 1 ) {
489- const editorControlsRef = editorControls .value
491+ const editorControlsRef = editorControlsRef .value
490492 if (editorControlsRef ) {
491493 editorControlsRef .scrollToCompanyText (companyIndex )
492494 }
493495 }
494496 } else if (textPath .type === ' code' ) {
495497 // 点击编码文字时,展开编码设置组
496- const editorControlsRef = editorControls .value
498+ const editorControlsRef = editorControlsRef .value
497499 if (editorControlsRef ) {
498500 editorControlsRef .scrollToCode ()
499501 }
500502 } else if (textPath .type === ' stampType' ) {
501503 // 点击印章类型文字时,展开印章类型设置组
502504 const stampTypeIndex = findStampTypeIndexByText (textPath .text )
503505 if (stampTypeIndex !== - 1 ) {
504- const editorControlsRef = editorControls .value
506+ const editorControlsRef = editorControlsRef .value
505507 if (editorControlsRef ) {
506508 editorControlsRef .scrollToStampType (stampTypeIndex )
507509 }
508510 }
509511 } else if (textPath .type === ' taxNumber' ) {
510512 // 点击税号文字时,展开税号设置组
511- const editorControlsRef = editorControls .value
513+ const editorControlsRef = editorControlsRef .value
512514 if (editorControlsRef ) {
513515 editorControlsRef .scrollToTaxNumber ()
514516 }
@@ -537,7 +539,7 @@ watch(isDraggable, (newValue) => {
537539 if (drawStampUtils ) {
538540 // 更新 drawStampUtils 中的拖动状态
539541 drawStampUtils .setDraggable (newValue )
540-
542+
541543 // 更新鼠标样式
542544 if (stampCanvas .value ) {
543545 stampCanvas .value .style .cursor = newValue ? ' move' : ' default'
0 commit comments