feat:优化 debug 页

This commit is contained in:
2025-07-16 18:31:55 +08:00
parent 72be2372ee
commit 3ce3d3cac4
15 changed files with 177 additions and 60 deletions
+2 -1
View File
@@ -10,6 +10,7 @@
"van-radio-group": "@vant/weapp/radio-group/index",
"van-cell": "@vant/weapp/cell/index",
"van-cell-group": "@vant/weapp/cell-group/index",
"van-switch": "@vant/weapp/switch/index"
"van-switch": "@vant/weapp/switch/index",
"van-field": "@vant/weapp/field/index"
}
}
+17 -6
View File
@@ -1,27 +1,38 @@
Page({
data: {
header: 'wechat',
printConfig: {
header: 'wechat',
appName: '涂鸦丫小程序'
},
enableDebug: false
},
onLoad() {
const header = getApp().getPrintHeader() || 'wechat';
const printConfig = getApp().getPrintConfig() || {
header: 'wechat',
appName: '涂鸦丫小程序'
};
const enableDebug = wx.getStorageSync('enableDebug') || false;
this.setData({ header, enableDebug });
this.setData({ printConfig, enableDebug });
},
onChangeHeader(e: WechatMiniprogram.CustomEvent) {
const header = e.detail.value as PrintHeader;
this.setData({ header });
this.setData({ printConfig: { ...this.data.printConfig, header } });
},
onClickHeaderSetting(e: WechatMiniprogram.CustomEvent) {
const header = e.currentTarget.dataset.name as PrintHeader;
this.setData({ header });
this.setData({ printConfig: { ...this.data.printConfig, header } });
},
onAppNameChange(e: WechatMiniprogram.CustomEvent) {
const appName = e.detail + '';
this.setData({ printConfig: { ...this.data.printConfig, appName } });
},
onConfirm() {
getApp().setPrintHeader(this.data.header);
getApp().setPrintConfig(this.data.printConfig);
const enableDebug = this.data.enableDebug;
wx.setStorageSync('enableDebug', enableDebug);
wx.setEnableDebug({ enableDebug });
+9 -2
View File
@@ -1,10 +1,12 @@
<view class="debug-page">
<van-cell-group custom-class="debug-wrapper">
<van-cell
title="打印图片Header设置"
title="打印图片Header设置111"
size="large"
custom-class="centered-title" />
<van-radio-group value="{{header}}" bind:change="onChangeHeader">
<van-radio-group
value="{{printConfig.header}}"
bind:change="onChangeHeader">
<van-cell
title="微信小程序头(wechat)(默认)"
clickable
@@ -35,6 +37,11 @@
<van-radio slot="right-icon" name="minimal" />
</van-cell>
</van-radio-group>
<van-field
label="appName"
value=""
placeholder="{{printConfig.appName}}"
bind:change="onAppNameChange" />
</van-cell-group>
<van-cell-group custom-class="debug-wrapper">