From 078fc54886ff8ff307dccda0cfb60afef83c3294 Mon Sep 17 00:00:00 2001 From: yaling888 <73897884+yaling888@users.noreply.github.com> Date: Fri, 6 May 2022 06:03:30 +0800 Subject: feat: add reload config-file & flush fake-ip pool to config page --- src/store/configs.ts | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) (limited to 'src/store') diff --git a/src/store/configs.ts b/src/store/configs.ts index c533508..b0ae2a7 100644 --- a/src/store/configs.ts +++ b/src/store/configs.ts @@ -89,6 +89,52 @@ export function updateConfigs( }; } +export function reloadConfigs(apiConfig: ClashAPIConfig) { + return async (dispatch: DispatchFn) => { + configsAPI + .reloadConfigs(apiConfig) + .then( + (res) => { + if (res.ok === false) { + // eslint-disable-next-line no-console + console.log('Error update configs', res.statusText); + } + }, + (err) => { + // eslint-disable-next-line no-console + console.log('Error update configs', err); + throw err; + } + ) + .then(() => { + dispatch(fetchConfigs(apiConfig)); + }); + }; +} + +export function flushFakeIPPool(apiConfig: ClashAPIConfig) { + return async (dispatch: DispatchFn) => { + configsAPI + .flushFakeIPPool(apiConfig) + .then( + (res) => { + if (res.ok === false) { + // eslint-disable-next-line no-console + console.log('Error update configs', res.statusText); + } + }, + (err) => { + // eslint-disable-next-line no-console + console.log('Error update configs', err); + throw err; + } + ) + .then(() => { + dispatch(fetchConfigs(apiConfig)); + }); + }; +} + export const initialState: StateConfigs = { configs: { port: 7890, -- cgit v1.3.1