refactor: format code with prettier and fix quotation marks
This commit is contained in:
@@ -112,7 +112,7 @@ export const LayoutViewer = forwardRef<DialogRef>((props, ref) => {
|
||||
}));
|
||||
|
||||
const handleConfigChange = (patch: Partial<IVergeConfig>) => {
|
||||
setLocalConfig(prev => ({ ...prev, ...patch }));
|
||||
setLocalConfig((prev) => ({ ...prev, ...patch }));
|
||||
};
|
||||
|
||||
const handleIconChange = useLockFn(
|
||||
@@ -133,7 +133,8 @@ export const LayoutViewer = forwardRef<DialogRef>((props, ref) => {
|
||||
handleConfigChange({ [key]: true });
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
);
|
||||
|
||||
const handleSave = useLockFn(async () => {
|
||||
setLoading(true);
|
||||
@@ -149,75 +150,112 @@ export const LayoutViewer = forwardRef<DialogRef>((props, ref) => {
|
||||
});
|
||||
|
||||
return (
|
||||
<Dialog open={open} onOpenChange={setOpen}>
|
||||
<DialogContent className="sm:max-w-md">
|
||||
<DialogHeader>
|
||||
<DialogTitle>{t("Layout Setting")}</DialogTitle>
|
||||
</DialogHeader>
|
||||
<Dialog open={open} onOpenChange={setOpen}>
|
||||
<DialogContent className="sm:max-w-md">
|
||||
<DialogHeader>
|
||||
<DialogTitle>{t("Layout Setting")}</DialogTitle>
|
||||
</DialogHeader>
|
||||
|
||||
<div className="py-4 space-y-1">
|
||||
{OS === "macos" && (
|
||||
<>
|
||||
<SettingRow label={t("Tray Icon")}>
|
||||
<Select
|
||||
onValueChange={(value) => handleConfigChange({ tray_icon: value as any })}
|
||||
value={localConfig.tray_icon ?? "monochrome"}
|
||||
>
|
||||
<SelectTrigger className="w-40 h-8"><SelectValue /></SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="monochrome">{t("Monochrome")}</SelectItem>
|
||||
<SelectItem value="colorful">{t("Colorful")}</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</SettingRow>
|
||||
<div className="py-4 space-y-1">
|
||||
{OS === "macos" && (
|
||||
<>
|
||||
<SettingRow label={t("Tray Icon")}>
|
||||
<Select
|
||||
onValueChange={(value) =>
|
||||
handleConfigChange({ tray_icon: value as any })
|
||||
}
|
||||
value={localConfig.tray_icon ?? "monochrome"}
|
||||
>
|
||||
<SelectTrigger className="w-40 h-8">
|
||||
<SelectValue />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="monochrome">
|
||||
{t("Monochrome")}
|
||||
</SelectItem>
|
||||
<SelectItem value="colorful">{t("Colorful")}</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</SettingRow>
|
||||
|
||||
<SettingRow label={t("Enable Tray Icon")}>
|
||||
<Switch
|
||||
checked={localConfig.enable_tray_icon ?? true}
|
||||
onCheckedChange={(checked) => handleConfigChange({ enable_tray_icon: checked })}
|
||||
/>
|
||||
</SettingRow>
|
||||
</>
|
||||
)}
|
||||
<SettingRow label={t("Enable Tray Icon")}>
|
||||
<Switch
|
||||
checked={localConfig.enable_tray_icon ?? true}
|
||||
onCheckedChange={(checked) =>
|
||||
handleConfigChange({ enable_tray_icon: checked })
|
||||
}
|
||||
/>
|
||||
</SettingRow>
|
||||
</>
|
||||
)}
|
||||
|
||||
<SettingRow label={t("Common Tray Icon")}>
|
||||
<Button variant="outline" size="sm" className="h-8" onClick={() => handleIconChange("common")}>
|
||||
{localConfig.common_tray_icon && commonIcon && (
|
||||
<img src={convertFileSrc(commonIcon)} className="h-5 mr-2" alt="common tray icon" />
|
||||
)}
|
||||
{localConfig.common_tray_icon ? t("Clear") : t("Browse")}
|
||||
</Button>
|
||||
</SettingRow>
|
||||
|
||||
<SettingRow label={t("System Proxy Tray Icon")}>
|
||||
<Button variant="outline" size="sm" className="h-8" onClick={() => handleIconChange("sysproxy")}>
|
||||
{localConfig.sysproxy_tray_icon && sysproxyIcon && (
|
||||
<img src={convertFileSrc(sysproxyIcon)} className="h-5 mr-2" alt="system proxy tray icon" />
|
||||
)}
|
||||
{localConfig.sysproxy_tray_icon ? t("Clear") : t("Browse")}
|
||||
</Button>
|
||||
</SettingRow>
|
||||
|
||||
<SettingRow label={t("Tun Tray Icon")}>
|
||||
<Button variant="outline" size="sm" className="h-8" onClick={() => handleIconChange("tun")}>
|
||||
{localConfig.tun_tray_icon && tunIcon && (
|
||||
<img src={convertFileSrc(tunIcon)} className="h-5 mr-2" alt="tun mode tray icon" />
|
||||
)}
|
||||
{localConfig.tun_tray_icon ? t("Clear") : t("Browse")}
|
||||
</Button>
|
||||
</SettingRow>
|
||||
</div>
|
||||
|
||||
<DialogFooter>
|
||||
<DialogClose asChild>
|
||||
<Button type="button" variant="outline">{t("Cancel")}</Button>
|
||||
</DialogClose>
|
||||
<Button type="button" onClick={handleSave} disabled={loading}>
|
||||
{loading && <Loader2 className="mr-2 h-4 w-4 animate-spin" />}
|
||||
{t("Save")}
|
||||
<SettingRow label={t("Common Tray Icon")}>
|
||||
<Button
|
||||
variant="outline"
|
||||
size="sm"
|
||||
className="h-8"
|
||||
onClick={() => handleIconChange("common")}
|
||||
>
|
||||
{localConfig.common_tray_icon && commonIcon && (
|
||||
<img
|
||||
src={convertFileSrc(commonIcon)}
|
||||
className="h-5 mr-2"
|
||||
alt="common tray icon"
|
||||
/>
|
||||
)}
|
||||
{localConfig.common_tray_icon ? t("Clear") : t("Browse")}
|
||||
</Button>
|
||||
</DialogFooter>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
</SettingRow>
|
||||
|
||||
<SettingRow label={t("System Proxy Tray Icon")}>
|
||||
<Button
|
||||
variant="outline"
|
||||
size="sm"
|
||||
className="h-8"
|
||||
onClick={() => handleIconChange("sysproxy")}
|
||||
>
|
||||
{localConfig.sysproxy_tray_icon && sysproxyIcon && (
|
||||
<img
|
||||
src={convertFileSrc(sysproxyIcon)}
|
||||
className="h-5 mr-2"
|
||||
alt="system proxy tray icon"
|
||||
/>
|
||||
)}
|
||||
{localConfig.sysproxy_tray_icon ? t("Clear") : t("Browse")}
|
||||
</Button>
|
||||
</SettingRow>
|
||||
|
||||
<SettingRow label={t("Tun Tray Icon")}>
|
||||
<Button
|
||||
variant="outline"
|
||||
size="sm"
|
||||
className="h-8"
|
||||
onClick={() => handleIconChange("tun")}
|
||||
>
|
||||
{localConfig.tun_tray_icon && tunIcon && (
|
||||
<img
|
||||
src={convertFileSrc(tunIcon)}
|
||||
className="h-5 mr-2"
|
||||
alt="tun mode tray icon"
|
||||
/>
|
||||
)}
|
||||
{localConfig.tun_tray_icon ? t("Clear") : t("Browse")}
|
||||
</Button>
|
||||
</SettingRow>
|
||||
</div>
|
||||
|
||||
<DialogFooter>
|
||||
<DialogClose asChild>
|
||||
<Button type="button" variant="outline">
|
||||
{t("Cancel")}
|
||||
</Button>
|
||||
</DialogClose>
|
||||
<Button type="button" onClick={handleSave} disabled={loading}>
|
||||
{loading && <Loader2 className="mr-2 h-4 w-4 animate-spin" />}
|
||||
{t("Save")}
|
||||
</Button>
|
||||
</DialogFooter>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user