mirror of
https://github.com/suyiiyii/nonebot-bison.git
synced 2025-07-14 20:23:01 +08:00
29 lines
929 B
TypeScript
29 lines
929 B
TypeScript
import { createApi } from '@reduxjs/toolkit/query/react';
|
|
import { PlatformWeightConfigResp, StatusResp } from '../../utils/type';
|
|
import baseQueryWithAuth from '../auth/authQuery';
|
|
|
|
export const weightApi = createApi({
|
|
reducerPath: 'weight',
|
|
baseQuery: baseQueryWithAuth,
|
|
tagTypes: ['Weight'],
|
|
endpoints: (builder) => ({
|
|
getWeight: builder.query<PlatformWeightConfigResp, void>({
|
|
query: () => '/weight',
|
|
providesTags: ['Weight'],
|
|
}),
|
|
updateWeight: builder.mutation<StatusResp,
|
|
Pick<PlatformWeightConfigResp, 'platform_name' | 'target' | 'weight' >>({
|
|
query: ({ platform_name: platformName, target, weight }) => ({
|
|
method: 'PUT',
|
|
url: `/weight?platform_name=${platformName}&target=${target}`,
|
|
body: weight,
|
|
}),
|
|
invalidatesTags: ['Weight'],
|
|
}),
|
|
}),
|
|
});
|
|
|
|
export const {
|
|
useGetWeightQuery, useUpdateWeightMutation,
|
|
} = weightApi;
|