refactor: add typescript support to project
This commit is contained in:
@@ -48,6 +48,13 @@ export const authApi = createApi({
|
||||
}
|
||||
}
|
||||
}),
|
||||
register: builder.mutation({
|
||||
query: (data) => ({
|
||||
url: `user/register`,
|
||||
method: "POST",
|
||||
body: data
|
||||
})
|
||||
}),
|
||||
// 更新token
|
||||
renew: builder.mutation({
|
||||
query: ({ token, refreshToken }) => ({
|
||||
@@ -90,9 +97,9 @@ export const authApi = createApi({
|
||||
})
|
||||
}),
|
||||
|
||||
checkInviteTokenValid: builder.mutation({
|
||||
checkMagicTokenValid: builder.mutation({
|
||||
query: (token) => ({
|
||||
url: "user/check_invite_magic_token",
|
||||
url: "user/check_magic_token",
|
||||
method: "POST",
|
||||
body: { magic_token: token }
|
||||
})
|
||||
@@ -104,11 +111,23 @@ export const authApi = createApi({
|
||||
body: { old_password, new_password }
|
||||
})
|
||||
}),
|
||||
sendMagicLink: builder.mutation({
|
||||
sendLoginMagicLink: builder.mutation({
|
||||
query: (email) => ({
|
||||
url: "token/send_magic_link",
|
||||
headers: {
|
||||
// "content-type": "text/plain",
|
||||
accept: "text/plain"
|
||||
},
|
||||
url: `user/send_login_magic_link?email=${encodeURIComponent(email)}`,
|
||||
method: "POST",
|
||||
body: { email }
|
||||
responseHandler: (response) => response.text()
|
||||
// body: { email }
|
||||
})
|
||||
}),
|
||||
sendRegMagicLink: builder.mutation({
|
||||
query: (data) => ({
|
||||
url: `user/send_reg_magic_link`,
|
||||
method: "POST",
|
||||
body: data
|
||||
})
|
||||
}),
|
||||
getMetamaskNonce: builder.query({
|
||||
@@ -146,7 +165,8 @@ export const authApi = createApi({
|
||||
|
||||
export const {
|
||||
useGetInitializedQuery,
|
||||
useSendMagicLinkMutation,
|
||||
useSendLoginMagicLinkMutation,
|
||||
useSendRegMagicLinkMutation,
|
||||
useGetCredentialsQuery,
|
||||
useUpdateDeviceTokenMutation,
|
||||
useGetOpenidMutation,
|
||||
@@ -154,6 +174,7 @@ export const {
|
||||
useLazyGetMetamaskNonceQuery,
|
||||
useLoginMutation,
|
||||
useLazyLogoutQuery,
|
||||
useCheckInviteTokenValidMutation,
|
||||
useUpdatePasswordMutation
|
||||
useCheckMagicTokenValidMutation,
|
||||
useUpdatePasswordMutation,
|
||||
useRegisterMutation
|
||||
} = authApi;
|
||||
|
||||
@@ -7,8 +7,9 @@ import BASE_URL, { tokenHeader } from "../config";
|
||||
const whiteList = [
|
||||
"login",
|
||||
"register",
|
||||
"sendMagicLink",
|
||||
"checkInviteTokenValid",
|
||||
"sendLoginMagicLink",
|
||||
"sendRegMagicLink",
|
||||
"checkMagicTokenValid",
|
||||
"getGoogleAuthConfig",
|
||||
"getGithubAuthConfig",
|
||||
"getSMTPStatus",
|
||||
|
||||
@@ -72,12 +72,14 @@ export const channelApi = createApi({
|
||||
}
|
||||
}),
|
||||
createInviteLink: builder.query({
|
||||
query: (gid) => ({
|
||||
query: (gid = "") => ({
|
||||
headers: {
|
||||
"content-type": "text/plain",
|
||||
accept: "text/plain"
|
||||
},
|
||||
url: `/group/${gid}/create_invite_link`,
|
||||
url: gid
|
||||
? `/group/create_reg_magic_link?expired_in=3600&max_times=1&gid=${gid}`
|
||||
: `/group/create_reg_magic_link?expired_in=3600&max_times=1`,
|
||||
responseHandler: (response) => response.text()
|
||||
}),
|
||||
transformResponse: (link) => {
|
||||
|
||||
@@ -89,13 +89,7 @@ export const contactApi = createApi({
|
||||
body: data
|
||||
})
|
||||
}),
|
||||
register: builder.mutation({
|
||||
query: (data) => ({
|
||||
url: `user/register`,
|
||||
method: "POST",
|
||||
body: data
|
||||
})
|
||||
}),
|
||||
|
||||
sendMsg: builder.mutation({
|
||||
query: ({ id, content, type = "text", properties = "" }) => ({
|
||||
headers: {
|
||||
@@ -139,6 +133,5 @@ export const {
|
||||
useUpdateAvatarMutation,
|
||||
useGetContactsQuery,
|
||||
useLazyGetContactsQuery,
|
||||
useSendMsgMutation,
|
||||
useRegisterMutation
|
||||
useSendMsgMutation
|
||||
} = contactApi;
|
||||
|
||||
Reference in New Issue
Block a user