39 lines
997 B
TypeScript
39 lines
997 B
TypeScript
import config from './config/config';
|
|
|
|
const defaultPrintConfig: PrintConfig = config.printHeader as PrintConfig;
|
|
|
|
|
|
// app.ts
|
|
App<IAppOption>({
|
|
globalData: {
|
|
env: 'release',
|
|
printConfig: defaultPrintConfig
|
|
},
|
|
onLaunch() {
|
|
const accountInfo = wx.getAccountInfoSync();
|
|
const env = accountInfo.miniProgram.envVersion || 'release';
|
|
this.globalData.env = env;
|
|
if (env !== 'release') {
|
|
const printConfig = wx.getStorageSync('printConfig') || defaultPrintConfig;
|
|
this.globalData.printConfig = printConfig;
|
|
}
|
|
},
|
|
|
|
onShow() {
|
|
// 小程序显示时的生命周期
|
|
},
|
|
|
|
onHide() {
|
|
// 小程序隐藏时的生命周期
|
|
},
|
|
|
|
getPrintConfig(): PrintConfig {
|
|
return this.globalData.printConfig || defaultPrintConfig;
|
|
},
|
|
|
|
setPrintConfig(config: PrintConfig) {
|
|
this.globalData.printConfig = config;
|
|
wx.setStorageSync('printConfig', config);
|
|
}
|
|
});
|