mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-01-29 08:45:41 +08:00
feat: support new profile
This commit is contained in:
@@ -6,6 +6,7 @@ import {
|
||||
selectProfile,
|
||||
patchProfile,
|
||||
importProfile,
|
||||
newProfile,
|
||||
} from "../services/cmds";
|
||||
import { getProxies, updateProxy } from "../services/api";
|
||||
import noop from "../utils/noop";
|
||||
@@ -94,6 +95,21 @@ const ProfilePage = () => {
|
||||
}
|
||||
};
|
||||
|
||||
const lockNewRef = useRef(false);
|
||||
const onNew = async () => {
|
||||
if (lockNewRef.current) return;
|
||||
lockNewRef.current = true;
|
||||
|
||||
try {
|
||||
await newProfile("New Profile", "no desc");
|
||||
mutate("getProfiles");
|
||||
} catch (err: any) {
|
||||
err && Notice.error(err.toString());
|
||||
} finally {
|
||||
lockNewRef.current = false;
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<BasePage title="Profiles">
|
||||
<Box sx={{ display: "flex", mb: 3 }}>
|
||||
@@ -105,15 +121,19 @@ const ProfilePage = () => {
|
||||
fullWidth
|
||||
value={url}
|
||||
onChange={(e) => setUrl(e.target.value)}
|
||||
sx={{ mr: 2 }}
|
||||
sx={{ mr: 1 }}
|
||||
/>
|
||||
<Button
|
||||
disabled={!url || disabled}
|
||||
variant="contained"
|
||||
onClick={onImport}
|
||||
sx={{ mr: 1 }}
|
||||
>
|
||||
Import
|
||||
</Button>
|
||||
<Button variant="contained" onClick={onNew}>
|
||||
New
|
||||
</Button>
|
||||
</Box>
|
||||
|
||||
<Grid container spacing={3}>
|
||||
|
||||
@@ -9,6 +9,10 @@ export async function syncProfiles() {
|
||||
return invoke<void>("sync_profiles");
|
||||
}
|
||||
|
||||
export async function newProfile(name: string, desc: string) {
|
||||
return invoke<void>("new_profile", { name, desc });
|
||||
}
|
||||
|
||||
export async function viewProfile(index: number) {
|
||||
return invoke<void>("view_profile", { index });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user