feat: 优化字帖功能
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
import WordDrawService from '../../service/wordDrawService';
|
||||
import { checkAndSaveImage } from '../../utils/saveImage';
|
||||
import { shouldShowShareGuide } from '../../utils/shareGuide';
|
||||
import { downloadPrint } from '../../utils/downloadPrint';
|
||||
import { PAPER_SIZE } from '../../constants/colors';
|
||||
import { getWordsSvgData } from '../../utils/getWordsSvgJson';
|
||||
import { WORDS } from '../../constants/words';
|
||||
@@ -108,6 +107,7 @@ Page({
|
||||
{
|
||||
inputWords: [],
|
||||
words: updatedWords,
|
||||
inputValue: '', // 同步清空输入框值
|
||||
},
|
||||
() => {
|
||||
this.renderPracticeContent().catch(console.error);
|
||||
@@ -143,11 +143,12 @@ Page({
|
||||
// 3. 替换输入汉字(不是追加),合并已选择的汉字
|
||||
const updatedWords = [...newInputChars, ...selectedWords];
|
||||
|
||||
// 4. 更新数据并提示
|
||||
// 4. 更新数据并提示(同步更新 inputValue 保持一致)
|
||||
this.setData(
|
||||
{
|
||||
inputWords: newInputChars,
|
||||
words: updatedWords,
|
||||
inputValue: text, // 同步输入框值
|
||||
},
|
||||
() => {
|
||||
this.renderPracticeContent().catch(console.error);
|
||||
@@ -436,32 +437,12 @@ Page({
|
||||
return characterData;
|
||||
},
|
||||
|
||||
/** 记录待下载状态(当需要分享引导时) */
|
||||
pendingDownload: false,
|
||||
|
||||
// 下载打印练字贴
|
||||
exportToPrint() {
|
||||
if (!this.canvas) {
|
||||
wx.showToast({ title: '请先生成练字贴', icon: 'none' });
|
||||
return;
|
||||
}
|
||||
|
||||
// 检查是否需要显示分享引导
|
||||
if (shouldShowShareGuide()) {
|
||||
this.setData({ showShareDialog: true });
|
||||
return;
|
||||
}
|
||||
|
||||
// 上报下载埋点
|
||||
tracker.reportDownload('练字贴');
|
||||
|
||||
// 直接下载
|
||||
checkAndSaveImage(this.canvas);
|
||||
},
|
||||
|
||||
/** 关闭分享引导弹窗 */
|
||||
onCloseShareDialog() {
|
||||
this.setData({ showShareDialog: false });
|
||||
async exportToPrint() {
|
||||
await downloadPrint(this.canvas, {
|
||||
errorToast: '请先生成练字贴',
|
||||
trackerName: '练字贴',
|
||||
});
|
||||
},
|
||||
|
||||
// 分享功能
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<view class="wrapper">
|
||||
<text class="wrapper-title">自定义练字贴</text>
|
||||
<view class="word-input-box">
|
||||
<word-input bind:onConfirm="onConfirmInput" style="width: 100%;"/>
|
||||
<word-input value="{{inputValue}}" bind:onConfirm="onConfirmInput" style="width: 100%;"/>
|
||||
</view>
|
||||
|
||||
<view class="action-buttons-box">
|
||||
|
||||
Reference in New Issue
Block a user