import { createContext, useContext, type ReactNode } from "react";
import { useAppStore } from "../../store/appStore";
import controls from "../ui/Controls.module.scss";
import styles from "./CursorSettings.module.scss";
const CaReady = createContext(false);
const ModelsReady = createContext(false);
export function CursorCaProvider({ children }: { children: ReactNode }) {
const { cursorHarness } = useAppStore();
return {children};
}
export function CursorCaGate({ busy, waitingForRefresh, onInitialize, onRefresh, children }: { busy: boolean; waitingForRefresh: boolean; onInitialize: () => void; onRefresh: () => void; children: ReactNode }) {
const ready = useContext(CaReady);
const { cursorHarness } = useAppStore();
if (ready) return children;
const unsupported = cursorHarness?.ca === "unsupported";
const installedLocally = cursorHarness?.ca === "untrusted";
return
{unsupported ? t("当前系统暂不支持安装 CA") : installedLocally ? t("需要在系统中信任本地 CA") : t("需要先初始化本地 CA")}
{unsupported ? t("请使用 macOS 或 Windows。") : installedLocally ? t("请在终端中粘贴授权命令并输入密码,完成后点击下方按钮") : t("CA 仅保存在本机,用于安全解析 Cursor 的 HTTPS 请求。")}
{!unsupported && }
;
}
export function CursorModelProvider({ children }: { children: ReactNode }) {
const { models } = useAppStore();
return 0}>{children};
}
export function CursorModelGate({ onAdd, children }: { onAdd: () => void; children: ReactNode }) {
const ready = useContext(ModelsReady);
if (ready) return children;
return
{t("还没有可供 Cursor 使用的模型")}
{t("Cursor 接管已生效;添加上游及其模型配置后即可使用 BYOK 模型。")}
;
}