Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
W
web-lib
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
郑磊
web-lib
Commits
741b3fe6
Commit
741b3fe6
authored
Mar 29, 2024
by
郑磊
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
更新app内的状态
parent
93caf4dd
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
5 deletions
+43
-5
app.ts
src/app.ts
+39
-2
token.ts
src/token.ts
+4
-3
No files found.
src/app.ts
View file @
741b3fe6
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'
)
??
''
,
}
}
src/token.ts
View file @
741b3fe6
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
app
Token
=
Cookies
.
get
(
'app_token'
)
if
(
app
T
oken
)
{
const
app
Status
=
getAppStatus
(
)
if
(
app
Status
&&
appStatus
.
app_t
oken
)
{
return
{
token
:
app
T
oken
,
token
:
app
Status
.
app_t
oken
,
source
:
'cookie_app'
,
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment