diff options
| author | yaling888 <[email protected]> | 2022-05-06 06:03:30 +0800 |
|---|---|---|
| committer | yaling888 <[email protected]> | 2022-05-06 06:03:30 +0800 |
| commit | 078fc54886ff8ff307dccda0cfb60afef83c3294 (patch) | |
| tree | c3f3839be7f8aa0b90289be12f38f618eb67ed9e /src/store | |
| parent | dafd4486f17fcd72ac86578854886a807b0c4748 (diff) | |
feat: add reload config-file & flush fake-ip pool to config page
Diffstat (limited to 'src/store')
| -rw-r--r-- | src/store/configs.ts | 46 |
1 files changed, 46 insertions, 0 deletions
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, |
