App({
  globalData: {
    // 真机调试时请改为电脑局域网 IP，例如 http://192.168.1.10:5000/api
    baseURL: 'http://127.0.0.1:5000/api',
    token: wx.getStorageSync('token') || '',
    user: wx.getStorageSync('user') || null
  },

  setAuth(token, user) {
    this.globalData.token = token
    this.globalData.user = user
    wx.setStorageSync('token', token)
    wx.setStorageSync('user', user)
  },

  clearAuth() {
    this.globalData.token = ''
    this.globalData.user = null
    wx.removeStorageSync('token')
    wx.removeStorageSync('user')
  }
})
