summaryrefslogtreecommitdiff
path: root/src/store
diff options
context:
space:
mode:
authoryaling888 <[email protected]>2022-05-16 03:14:22 +0800
committeryaling888 <[email protected]>2022-05-16 03:14:22 +0800
commitc0ff201efb58765bc108b3c97efdc8d635f26921 (patch)
treec0d76e5e09122b1cbd1d302acd61a1924935deaa /src/store
parentf3d984984124c947322024c3f8b9a8e8ae8b728f (diff)
feat: add "update geo databases" & "tls sniffing switch" to config page
Diffstat (limited to 'src/store')
-rw-r--r--src/store/configs.ts39
-rw-r--r--src/store/types.ts1
2 files changed, 30 insertions, 10 deletions
diff --git a/src/store/configs.ts b/src/store/configs.ts
index c4b95de..2a5c21a 100644
--- a/src/store/configs.ts
+++ b/src/store/configs.ts
@@ -87,12 +87,7 @@ export function updateConfigs(
});
dispatch('storeConfigsOptimisticUpdateConfigs', (s) => {
- if (partialConfg.tun != null) {
- s.configs.configs.tun = { ...s.configs.configs.tun, ...partialConfg.tun };
- } else {
- const config: generalConfig = {...s.configs.configs, ...partialConfg};
- s.configs.configs = config
- }
+ s.configs.configs = { ...s.configs.configs, ...partialConfg } as generalConfig;
});
};
}
@@ -105,12 +100,35 @@ export function reloadConfigFile(apiConfig: ClashAPIConfig) {
(res) => {
if (res.ok === false) {
// eslint-disable-next-line no-console
- console.log('Error update configs', res.statusText);
+ console.log('Error reload config file', res.statusText);
}
},
(err) => {
// eslint-disable-next-line no-console
- console.log('Error update configs', err);
+ console.log('Error reload config file', err);
+ throw err;
+ }
+ )
+ .then(() => {
+ dispatch(fetchConfigs(apiConfig));
+ });
+ };
+}
+
+export function updateGeoDatabasesFile(apiConfig: ClashAPIConfig) {
+ return async (dispatch: DispatchFn) => {
+ configsAPI
+ .updateGeoDatabasesFile(apiConfig)
+ .then(
+ (res) => {
+ if (res.ok === false) {
+ // eslint-disable-next-line no-console
+ console.log('Error update geo databases file', res.statusText);
+ }
+ },
+ (err) => {
+ // eslint-disable-next-line no-console
+ console.log('Error update geo databases file', err);
throw err;
}
)
@@ -128,12 +146,12 @@ export function flushFakeIPPool(apiConfig: ClashAPIConfig) {
(res) => {
if (res.ok === false) {
// eslint-disable-next-line no-console
- console.log('Error update configs', res.statusText);
+ console.log('Error flush FakeIP pool', res.statusText);
}
},
(err) => {
// eslint-disable-next-line no-console
- console.log('Error update configs', err);
+ console.log('Error flush FakeIP pool', err);
throw err;
}
)
@@ -154,6 +172,7 @@ export const initialState: StateConfigs = {
'allow-lan': false,
mode: 'rule',
'log-level': 'uninit',
+ sniffing: false,
tun: {
enable: false,
device: '',
diff --git a/src/store/types.ts b/src/store/types.ts
index 5ce542f..3a3e412 100644
--- a/src/store/types.ts
+++ b/src/store/types.ts
@@ -34,6 +34,7 @@ export type ClashGeneralConfig = {
'allow-lan': boolean;
mode: string;
'log-level': string;
+ sniffing?: boolean;
tun?: ClashTunConfig;
};