Files
Pet3/miniprogram/app.js
2026-06-25 18:24:29 +08:00

31 lines
737 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// app.js
App({
globalData: {
env: 'cloud1-d0gmb6bjde8af3266', // TODO: 替换为你的云开发环境 ID
userInfo: null,
dogs: [],
currentDogId: null,
walkSession: null,
},
onLaunch() {
if (!wx.cloud) {
console.error('请使用 2.2.3 或以上的基础库以使用云能力');
return;
}
const { platform } = wx.getDeviceInfo();
const isDevtools = platform === 'devtools';
wx.cloud.init({
env: this.globalData.env,
traceUser: !isDevtools,
});
// 恢复未结束的遛狗会话(切后台/重启不丢,见 docs/01 §4
const session = wx.getStorageSync('walkSession');
if (session) {
this.globalData.walkSession = session;
}
},
});