mirror of
https://github.com/suyiiyii/nonebot-bison.git
synced 2026-06-27 00:34:50 +08:00
update
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
import { RootState, store } from '../../app/store';
|
||||
import { baseUrl } from '../../utils/urls';
|
||||
|
||||
export default async function getTargetName(platformName: string, target: string) {
|
||||
const url = `${baseUrl}target_name?platformName=${platformName}&target=${target}`;
|
||||
const state = store.getState() as RootState;
|
||||
const authToken = state.auth.token;
|
||||
const res = await fetch(url, {
|
||||
headers: {
|
||||
Authorization: `Bearer ${authToken}`,
|
||||
},
|
||||
});
|
||||
const resObj = await res.json();
|
||||
return resObj.targetName as string;
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
import { createApi } from '@reduxjs/toolkit/query/react';
|
||||
import baseQueryWithAuth from '../auth/authQuery';
|
||||
|
||||
export const targetNameApi = createApi({
|
||||
reducerPath: 'targetName',
|
||||
baseQuery: baseQueryWithAuth,
|
||||
endpoints: (builder) => ({
|
||||
getTargetName: builder.query<{targetName: string}, {target: string; platformName: string}>({
|
||||
query: () => '/target_name',
|
||||
}),
|
||||
}),
|
||||
});
|
||||
|
||||
export const { useGetTargetNameQuery } = targetNameApi;
|
||||
Reference in New Issue
Block a user