Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
B
bigwood
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
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
罗超
bigwood
Commits
debf67cd
Commit
debf67cd
authored
Nov 17, 2022
by
youjie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
no message
parent
06615da2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
3 deletions
+24
-3
axios.ts
src/api/axios.ts
+12
-2
request.ts
src/api/request.ts
+12
-1
No files found.
src/api/axios.ts
View file @
debf67cd
import
{
Data
}
from
'./../../node_modules/_vite@2.9.15@vite/dist/node/index.d'
;
import
Axios
,
{
AxiosResponse
,
AxiosRequestConfig
,
AxiosError
}
from
'axios'
import
message
from
'../utils/message'
...
...
@@ -6,7 +7,10 @@ import router from '../router'
// import { message } from 'ant-design-vue'
// import Store from '../store'
// import { Notify } from 'quasar'
let
{
t
}
=
i18n
.
global
import
*
as
OpenCC
from
'opencc-js'
let
{
locale
,
t
}
=
i18n
.
global
let
converterTW
=
OpenCC
.
Converter
({
from
:
'cn'
,
to
:
'tw'
})
//转繁
let
datas
:
AxiosResponse
// 接收需要转繁数据
/**
...
...
@@ -118,7 +122,13 @@ service.interceptors.response.use(
/** 请求有响应 */
async
(
response
:
AxiosResponse
)
=>
{
if
(
response
.
status
===
200
)
{
return
Promise
.
resolve
(
response
)
if
(
locale
.
value
==
'zhTW'
){
let
stringifyData
=
converterTW
(
JSON
.
stringify
(
response
))
datas
=
JSON
.
parse
(
stringifyData
)
}
else
{
datas
=
response
}
return
Promise
.
resolve
(
datas
)
}
else
{
const
__text
=
getErrorCode2text
(
response
)
return
Promise
.
reject
(
new
Error
(
__text
))
...
...
src/api/request.ts
View file @
debf67cd
...
...
@@ -2,8 +2,19 @@ import service from "./axios";
import
Store
from
'../store'
import
md5
from
"md5-ts"
;
import
{
HttpResponse
}
from
"@/@types"
;
import
*
as
OpenCC
from
'opencc-js'
import
{
i18n
}
from
'../boot/i18n'
let
{
locale
}
=
i18n
.
global
let
converterSW
=
OpenCC
.
Converter
({
from
:
'tw'
,
to
:
'cn'
})
//转简
let
datas
:
any
// 接收需要转简数据
const
request
=
(
cmd
:
string
,
msg
:
any
):
Promise
<
HttpResponse
>=>
{
msg
=
msg
??{}
if
(
locale
.
value
==
'zhTW'
){
let
stringifyData
=
converterSW
(
JSON
.
stringify
(
msg
))
datas
=
JSON
.
parse
(
stringifyData
)
}
else
{
datas
=
msg
}
msg
=
datas
??{}
let
token
=
""
;
let
key
=
""
;
let
timestamp
=
(
new
Date
()).
valueOf
();
...
...
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