overwrite subscribe rules

This commit is contained in:
Gabe Yuan
2023-09-01 22:27:25 +08:00
parent 5ba061deda
commit 5c8e216169
8 changed files with 278 additions and 27 deletions

View File

@@ -1,4 +1,4 @@
import { DEFAULT_SUBRULES_LIST } from "../config";
import { DEFAULT_SUBRULES_LIST, DEFAULT_OW_RULE } from "../config";
import { useSetting } from "./Setting";
import { useCallback, useEffect, useMemo, useState } from "react";
import { loadOrFetchSubRules } from "../libs/subRules";
@@ -79,3 +79,21 @@ export function useSubRules() {
loading,
};
}
/**
* 覆写订阅规则
* @returns
*/
export function useOwSubRule() {
const { setting, updateSetting } = useSetting();
const { owSubrule = DEFAULT_OW_RULE } = setting;
const updateOwSubrule = useCallback(
async (obj) => {
await updateSetting({ owSubrule: { ...owSubrule, ...obj } });
},
[owSubrule, updateSetting]
);
return { owSubrule, updateOwSubrule };
}