feat: 分类管理页开发
This commit is contained in:
@@ -1,43 +1,44 @@
|
||||
import { defaultPrintConfig } from '../../config/config';
|
||||
type DebugEntry = {
|
||||
id: string;
|
||||
title: string;
|
||||
subtitle: string;
|
||||
icon: string;
|
||||
path: string;
|
||||
};
|
||||
|
||||
const DEBUG_ENTRIES: DebugEntry[] = [
|
||||
{
|
||||
id: 'category-manage',
|
||||
title: '分类管理',
|
||||
subtitle: '对比本地与云端分类数据,执行新增或更新。',
|
||||
icon: '🗂️',
|
||||
path: '/supportPages/categoryManage/categoryManage',
|
||||
},
|
||||
];
|
||||
|
||||
Page({
|
||||
data: {
|
||||
printConfig: defaultPrintConfig,
|
||||
enableDebug: false,
|
||||
entries: DEBUG_ENTRIES,
|
||||
isDevEnv: true,
|
||||
},
|
||||
|
||||
onLoad() {
|
||||
const printConfig = getApp().getPrintConfig() || defaultPrintConfig;
|
||||
const enableDebug = wx.getStorageSync('enableDebug') || false;
|
||||
this.setData({ printConfig, enableDebug });
|
||||
const envVersion = wx.getAccountInfoSync().miniProgram.envVersion;
|
||||
const isDevEnv = envVersion === 'develop';
|
||||
this.setData({ isDevEnv });
|
||||
|
||||
if (!isDevEnv) {
|
||||
wx.showToast({
|
||||
title: '仅开发版可用',
|
||||
icon: 'none',
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
onChangeHeader(e: WechatMiniprogram.CustomEvent) {
|
||||
const header = e.detail.value as PrintHeader;
|
||||
this.setData({ printConfig: { ...this.data.printConfig, header } });
|
||||
},
|
||||
|
||||
onClickHeaderSetting(e: WechatMiniprogram.CustomEvent) {
|
||||
const header = e.currentTarget.dataset.name as PrintHeader;
|
||||
this.setData({ printConfig: { ...this.data.printConfig, header } });
|
||||
},
|
||||
|
||||
onAppNameChange(e: WechatMiniprogram.CustomEvent) {
|
||||
const appName = e.detail + '';
|
||||
this.setData({ printConfig: { ...this.data.printConfig, appName } });
|
||||
},
|
||||
|
||||
onConfirm() {
|
||||
getApp().setPrintConfig(this.data.printConfig);
|
||||
const enableDebug = this.data.enableDebug;
|
||||
wx.setStorageSync('enableDebug', enableDebug);
|
||||
wx.setEnableDebug({ enableDebug });
|
||||
wx.navigateBack();
|
||||
},
|
||||
|
||||
/** 真机调试线上包 */
|
||||
toggleDebug() {
|
||||
const enableDebug = !this.data.enableDebug;
|
||||
this.setData({ enableDebug });
|
||||
onTapEntry(e: WechatMiniprogram.TouchEvent) {
|
||||
if (!this.data.isDevEnv) return;
|
||||
const path = e.currentTarget.dataset.path as string;
|
||||
if (!path) return;
|
||||
wx.navigateTo({ url: path });
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user