Commit 741b3fe6 authored by 郑磊's avatar 郑磊

更新app内的状态

parent 93caf4dd
export interface AppStatus {}
import Cookies from 'js-cookie'
/**
* 通过app获取到的状态
*/
export interface AppStatus {
/**
* 包名
*/
source: string
/**
* 是否在直播间中
*/
isOnLiveRoom: number
/**
* 当前直播间的房间号
*/
roomIdentifier: number
/**
* 当前用户的token
*/
app_token: string
/**
* 加密后的用户id
*/
userid: string
}
/**
* 读取当前APP的状态
*/
export function getAppStatus(): AppStatus | undefined {
//先判断是否在app内
return
const platform = Cookies.get('platform')
const source = Cookies.get('source')
if (platform !== 'app' || !source) return
return {
source,
app_token: Cookies.get('app_token') ?? '',
isOnLiveRoom: parseInt(Cookies.get('isOnLiveRoom') ?? '0'),
roomIdentifier: parseInt(Cookies.get('roomIdentifier') || '0'),
userid: Cookies.get('userid') ?? '',
}
}
import CryptoJS from 'crypto-js'
import Cookies from 'js-cookie'
import { getAppStatus } from './app'
/**
* token数据
......@@ -81,10 +82,10 @@ export function parseToken(): TokenData | undefined {
}
//接着尝试从cookie中获取app_token
const appToken = Cookies.get('app_token')
if (appToken) {
const appStatus = getAppStatus()
if (appStatus && appStatus.app_token) {
return {
token: appToken,
token: appStatus.app_token,
source: 'cookie_app',
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment