import Taro from '@tarojs/taro'
import { ServerBaseUrl } from '@/config/app'
import type { User } from '@/api/system/user/model'

export const SERVER_API_URL = ServerBaseUrl

export function saveStorageByLoginUser(token: string, user: User) {
  Taro.setStorageSync('TenantId', user.tenantId)
  Taro.setStorageSync('access_token', token)
  Taro.setStorageSync('UserId', user.userId)
  Taro.setStorageSync('Phone', user.phone)
  Taro.setStorageSync('WxNickName', user.nickname)
  Taro.setStorageSync('User', user)
}

export function clearStorageByLoginUser() {
  Taro.removeStorageSync('TenantId')
  Taro.removeStorageSync('access_token')
  Taro.removeStorageSync('UserId')
  Taro.removeStorageSync('Phone')
  Taro.removeStorageSync('WxNickName')
  Taro.removeStorageSync('User')
}
