34 lines
857 B
TypeScript
34 lines
857 B
TypeScript
// app.ts
|
|
App<IAppOption>({
|
|
globalData: {
|
|
env: 'release'
|
|
},
|
|
onLaunch() {
|
|
const accountInfo = wx.getAccountInfoSync();
|
|
const env = accountInfo.miniProgram.envVersion || 'release';
|
|
this.globalData.env = env;
|
|
if (env !== 'release') {
|
|
const printHeader = wx.getStorageSync('printHeader') || 'wechat';
|
|
this.globalData.printHeader = printHeader;
|
|
}
|
|
},
|
|
|
|
onShow() {
|
|
// 小程序显示时的生命周期
|
|
},
|
|
|
|
onHide() {
|
|
// 小程序隐藏时的生命周期
|
|
},
|
|
|
|
getPrintHeader(): PrintHeader {
|
|
return this.globalData.printHeader || 'wechat';
|
|
},
|
|
|
|
setPrintHeader(header: PrintHeader) {
|
|
header = header || 'wechat';
|
|
this.globalData.printHeader = header;
|
|
wx.setStorageSync('printHeader', header);
|
|
}
|
|
});
|