feat:更新iconfont

This commit is contained in:
2025-06-11 11:24:01 +08:00
34 changed files with 639 additions and 5726 deletions
+22 -43
View File
@@ -34,37 +34,6 @@ Page({
.exec();
},
// renderCanvas() {
// // wx.nextTick(() => {
// // this.setCanvasBoxSize();
// // });
// console.log('this.boxWidth:', this.boxWidth);
// console.log('this.boxHeight:', this.boxHeight);
// if (this.boxWidth && this.boxHeight) {
// this.initCanvas(this.boxWidth, this.boxHeight);
// }
// },
// setCanvasBoxSize() {
// const { windowWidth } = wx.getWindowInfo();
// console.log('windowWidth---:', windowWidth);
// const query = wx.createSelectorQuery();
// query
// .select('#canvasWrapper')
// .boundingClientRect((rect) => {
// if (rect) {
// const boxWidth = rect.width;
// const boxHeight = boxWidth / (width / height);
// console.log('boxWidth----:', boxWidth);
// console.log('boxHeight----:', boxHeight);
// this.initCanvas(boxHeight, boxWidth);
// }
// })
// .exec();
// },
initCanvas(boxWidth: number, boxHeight: number) {
wx.createSelectorQuery()
.select('#canvasContent')
@@ -79,8 +48,7 @@ Page({
if (ctx) {
this.canvas = canvas;
this.ctx = ctx;
const rect = res[0];
console.log('rect-----:', rect);
// const rect = res[0];
this.textDrawService = new TextDrawService(canvas, ctx);
// textDrawService.draw();
this.setData({ boxWidth, boxHeight });
@@ -89,6 +57,16 @@ Page({
});
},
/** 变更cardList 并更新canvas */
drawCanvas(
updatedCardList: Array<{ color: string; word: string }>,
callback: () => void = () => {},
) {
console.log('drawCanvas called updatedCardList:', updatedCardList);
this.setData({ cardList: updatedCardList }, callback);
this.textDrawService?.draw(updatedCardList);
},
tapCard(e: WechatMiniprogram.TouchEvent) {
const { url } = e.currentTarget.dataset;
console.log('navigateTo url:', url);
@@ -107,9 +85,10 @@ Page({
word: char,
}));
console.log('updatedCardList', updatedCardList);
this.setData({ cardList: updatedCardList });
// this.renderCanvas();
this.textDrawService?.draw(updatedCardList);
this.drawCanvas(updatedCardList);
// this.setData({ cardList: updatedCardList });
// // this.renderCanvas();
// this.textDrawService?.draw(updatedCardList);
},
deleteWordCard(e: WechatMiniprogram.CustomEvent) {
@@ -117,14 +96,14 @@ Page({
console.log('deleteWordCard key:', key, 'word:', word);
const { cardList } = this.data;
const updatedCardList = cardList.filter((_, index) => index !== key);
this.setData({ cardList: updatedCardList });
wx.showToast({
title: `已删除 "${word}"`,
icon: 'none',
duration: 2000,
this.drawCanvas(updatedCardList, () => {
wx.showToast({
title: `已删除 "${word}"`,
icon: 'none',
duration: 2000,
});
});
// this.renderCanvas();
this.textDrawService?.draw(updatedCardList);
},
/** 下载打印 */