feat:架构代码优化
This commit is contained in:
+13
-3
@@ -1,17 +1,27 @@
|
||||
import config from './config/config';
|
||||
|
||||
const defaultPrintConfig: PrintConfig = config.printHeader as PrintConfig;
|
||||
import { defaultPrintConfig } from './config/config';
|
||||
import { generateUUID, getAppUUID, setAppUUID } from './utils/uuid';
|
||||
|
||||
// app.ts
|
||||
App<IAppOption>({
|
||||
globalData: {
|
||||
env: 'release',
|
||||
uuid: '',
|
||||
printConfig: defaultPrintConfig,
|
||||
},
|
||||
onLaunch() {
|
||||
const accountInfo = wx.getAccountInfoSync();
|
||||
const env = accountInfo.miniProgram.envVersion || 'release';
|
||||
this.globalData.env = env;
|
||||
|
||||
// 从 localStorage 读取 UUID,如果没有则生成并存储
|
||||
let uuid = getAppUUID();
|
||||
if (!uuid) {
|
||||
uuid = generateUUID();
|
||||
setAppUUID(uuid);
|
||||
console.log('生成并存储 UUID', uuid);
|
||||
}
|
||||
this.globalData.uuid = uuid;
|
||||
|
||||
if (env !== 'release') {
|
||||
const printConfig =
|
||||
wx.getStorageSync('printConfig') || defaultPrintConfig;
|
||||
|
||||
Reference in New Issue
Block a user