比较提交
没有共同的提交。06316a324055f6b17458f5819de7d7049af095db 和 779ffc3d5540f9d5370902c04ec957950563ae0a 的历史完全不同。
06316a3240
...
779ffc3d55
共有 5 个文件被更改,包括 639 次插入 和 810 次删除
|
|
@ -36,14 +36,6 @@ The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
- Adding a connection now asks for four things — server address, adapter id, API key, and slot —
|
|
||||||
with the rest behind a collapsed advanced section. The SSE URL and certificate fingerprint fields
|
|
||||||
were removed because nothing reads them, and the role field was removed because it follows the
|
|
||||||
chosen slot. The display name is derived from the identity and host unless set explicitly, and the
|
|
||||||
insecure-HTTP approval appears only for an `http://` address, where it is required.
|
|
||||||
- Choosing a slot in the connection form now assigns the slot and points startup auto-connect at it,
|
|
||||||
replacing a separate slot card interaction and a separate dropdown that could disagree.
|
|
||||||
- The API key is enrolled as part of saving a new connection instead of as a second step.
|
|
||||||
- Synchronized the 13-item roadmap status with the actual P02 implementation state.
|
- Synchronized the 13-item roadmap status with the actual P02 implementation state.
|
||||||
- Documented external prerequisites for HTTPS certificate pinning, signed updates, and dual-server soak testing.
|
- Documented external prerequisites for HTTPS certificate pinning, signed updates, and dual-server soak testing.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -650,51 +650,3 @@ Rust 107 passed / 2 ignored. Frontend 24 passed / 5 files. Playwright 5 passed.
|
||||||
|
|
||||||
Next: capture the frames, then batch R3.6 (message identity, pulling F-34 forward) and R3.7
|
Next: capture the frames, then batch R3.6 (message identity, pulling F-34 forward) and R3.7
|
||||||
(attachment chain, pulling F-33 forward).
|
(attachment chain, pulling F-33 forward).
|
||||||
|
|
||||||
## 2026-07-27: window controls and connection form
|
|
||||||
|
|
||||||
### Window controls (P0)
|
|
||||||
|
|
||||||
The minimize, maximize and close buttons did nothing. The handlers were correct; the ACL rejected
|
|
||||||
them. `core:default` resolves to `core:window:default`, which grants only read-only queries —
|
|
||||||
`allow-is-maximized` is in it, which is why the maximize icon tracked state, but `allow-minimize`,
|
|
||||||
`allow-toggle-maximize`, `allow-close` and `allow-start-dragging` are not. Both windows are
|
|
||||||
`decorations: false`, so with close denied the main window could not be closed except through the
|
|
||||||
tray.
|
|
||||||
|
|
||||||
Added `main-window-controls` and `pet-window-drag` capabilities rather than widening the shared one,
|
|
||||||
so the pet gains dragging alone. Routed the calls through a helper that reports failures in the
|
|
||||||
shell error banner; they were bare `void` expressions, which is why the rejection was
|
|
||||||
indistinguishable from an unwired button.
|
|
||||||
|
|
||||||
This is the second time a missing capability surfaced as a silent no-op, after the pet window
|
|
||||||
(F-03). `src-tauri/tests/capabilities.rs` now reads the shipped capability files and asserts each
|
|
||||||
permission the UI calls is granted to the window that calls it.
|
|
||||||
|
|
||||||
### Connection form
|
|
||||||
|
|
||||||
Adding a connection asked for eleven fields. Three reached nothing: the SSE URL has no consumer in
|
|
||||||
`networking/`, the certificate fingerprint is stored but TLS pinning is unimplemented, and the role
|
|
||||||
only chose a word in the profile list. The form is now server address, adapter id, API key and slot,
|
|
||||||
with the rest behind a collapsed advanced section.
|
|
||||||
|
|
||||||
The adapter id is the remote username, previously entered twice — once in the profile form, once in
|
|
||||||
the credential card. Display name, role, and the insecure-HTTP approval are now derived rather than
|
|
||||||
asked for; the approval appears only for an `http://` address and is required there, since
|
|
||||||
`normalize_url` rejects such an address without it.
|
|
||||||
|
|
||||||
Choosing a slot assigns the slot and points auto-connect at it, replacing two controls that could
|
|
||||||
disagree. The API key is enrolled in the same submit; both follow-up steps need the profile to
|
|
||||||
exist, so they report their own failures rather than failing the save.
|
|
||||||
|
|
||||||
`ProfileManager.tsx` was normalized to LF in a separate commit first. It held 603 CRLF and 85 LF
|
|
||||||
lines against an `.editorconfig` that pins LF, which is why the fix queue carried a standing warning
|
|
||||||
about editing it.
|
|
||||||
|
|
||||||
### Test status
|
|
||||||
|
|
||||||
Rust 112 passed / 2 ignored. Frontend 29 passed / 6 files. Playwright 5 passed. Build passes.
|
|
||||||
|
|
||||||
Verified in a browser against the real stylesheet rather than by inspection: four visible fields
|
|
||||||
plus a collapsed advanced section, the insecure checkbox appearing only for `http://` and carrying
|
|
||||||
`required`, and the display name resolving to identity@host.
|
|
||||||
|
|
|
||||||
|
|
@ -227,16 +227,15 @@ describe("App", () => {
|
||||||
await openConnectionsPage();
|
await openConnectionsPage();
|
||||||
expect(await screen.findByText("尚未保存 Profile。")).toBeInTheDocument();
|
expect(await screen.findByText("尚未保存 Profile。")).toBeInTheDocument();
|
||||||
|
|
||||||
fireEvent.change(screen.getByLabelText("服务器地址"), {
|
|
||||||
target: { value: "https://ops.example.test" },
|
|
||||||
});
|
|
||||||
fireEvent.change(screen.getByLabelText("适配器 ID"), {
|
|
||||||
target: { value: "opsbot" },
|
|
||||||
});
|
|
||||||
// Lives under 高级设置; the disclosure only hides it visually.
|
|
||||||
fireEvent.change(screen.getByLabelText("显示名称"), {
|
fireEvent.change(screen.getByLabelText("显示名称"), {
|
||||||
target: { value: "家庭运维" },
|
target: { value: "家庭运维" },
|
||||||
});
|
});
|
||||||
|
fireEvent.change(screen.getByLabelText("角色"), {
|
||||||
|
target: { value: "operations" },
|
||||||
|
});
|
||||||
|
fireEvent.change(screen.getByLabelText("REST 基础 URL"), {
|
||||||
|
target: { value: "https://ops.example.test" },
|
||||||
|
});
|
||||||
fireEvent.click(screen.getByRole("button", { name: "保存 Profile" }));
|
fireEvent.click(screen.getByRole("button", { name: "保存 Profile" }));
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
|
|
@ -355,24 +354,13 @@ describe("App", () => {
|
||||||
const created: ConnectionProfile = {
|
const created: ConnectionProfile = {
|
||||||
id: "2bdedc10-d804-4da5-8e92-39dd7f175d7a",
|
id: "2bdedc10-d804-4da5-8e92-39dd7f175d7a",
|
||||||
...request,
|
...request,
|
||||||
transportKind: request.transportKind ?? "astr-bot-open-api",
|
transportKind: "desktop-v1",
|
||||||
createdAt: "2026-07-19T03:00:00Z",
|
createdAt: "2026-07-19T03:00:00Z",
|
||||||
updatedAt: "2026-07-19T03:00:00Z",
|
updatedAt: "2026-07-19T03:00:00Z",
|
||||||
};
|
};
|
||||||
profiles = [created];
|
profiles = [created];
|
||||||
return created;
|
return created;
|
||||||
}
|
}
|
||||||
if (command === "assign_connection_slot") {
|
|
||||||
const { request } = args as {
|
|
||||||
request: { slot: ActiveSlotKind; profileId: string };
|
|
||||||
};
|
|
||||||
return {
|
|
||||||
slot: request.slot,
|
|
||||||
profileId: request.profileId,
|
|
||||||
state: "disconnected",
|
|
||||||
unreadCount: 0,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
throw new Error(`Unexpected command: ${command}`);
|
throw new Error(`Unexpected command: ${command}`);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -380,18 +368,19 @@ describe("App", () => {
|
||||||
await openConnectionsPage();
|
await openConnectionsPage();
|
||||||
expect(await screen.findByText("尚未保存 Profile。")).toBeInTheDocument();
|
expect(await screen.findByText("尚未保存 Profile。")).toBeInTheDocument();
|
||||||
|
|
||||||
fireEvent.change(screen.getByLabelText("服务器地址"), {
|
|
||||||
target: { value: "https://companion.example.test" },
|
|
||||||
});
|
|
||||||
fireEvent.change(screen.getByLabelText("适配器 ID"), {
|
|
||||||
target: { value: "companionbot" },
|
|
||||||
});
|
|
||||||
fireEvent.change(screen.getByLabelText("显示名称"), {
|
fireEvent.change(screen.getByLabelText("显示名称"), {
|
||||||
target: { value: "自动陪伴" },
|
target: { value: "自动陪伴" },
|
||||||
});
|
});
|
||||||
// Choosing a slot is now the single control: it assigns the slot, sets the
|
fireEvent.change(screen.getByLabelText("角色"), {
|
||||||
// role, and points startup auto-connect at it.
|
target: { value: "companion" },
|
||||||
fireEvent.change(screen.getByLabelText("槽位"), {
|
});
|
||||||
|
fireEvent.change(screen.getByLabelText("REST 基础 URL"), {
|
||||||
|
target: { value: "https://companion.example.test" },
|
||||||
|
});
|
||||||
|
fireEvent.click(
|
||||||
|
screen.getByLabelText("启动时自动连接(不会在本阶段真正建立网络会话)"),
|
||||||
|
);
|
||||||
|
fireEvent.change(screen.getByLabelText("自动连接槽位"), {
|
||||||
target: { value: "companion" },
|
target: { value: "companion" },
|
||||||
});
|
});
|
||||||
fireEvent.click(screen.getByRole("button", { name: "保存 Profile" }));
|
fireEvent.click(screen.getByRole("button", { name: "保存 Profile" }));
|
||||||
|
|
@ -399,25 +388,19 @@ describe("App", () => {
|
||||||
expect(
|
expect(
|
||||||
await screen.findByText("已创建 Profile:自动陪伴"),
|
await screen.findByText("已创建 Profile:自动陪伴"),
|
||||||
).toBeInTheDocument();
|
).toBeInTheDocument();
|
||||||
|
expect(screen.getByText("自动连接:陪伴")).toBeInTheDocument();
|
||||||
expect(invoke).toHaveBeenCalledWith("create_connection_profile", {
|
expect(invoke).toHaveBeenCalledWith("create_connection_profile", {
|
||||||
request: {
|
request: {
|
||||||
displayName: "自动陪伴",
|
displayName: "自动陪伴",
|
||||||
role: "companion",
|
role: "companion",
|
||||||
baseUrl: "https://companion.example.test",
|
baseUrl: "https://companion.example.test",
|
||||||
authenticationType: "api-key",
|
authenticationType: "device-token",
|
||||||
transportKind: "astr-bot-open-api",
|
transportKind: "desktop-v1",
|
||||||
remoteUsername: "companionbot",
|
|
||||||
allowInsecureHttp: false,
|
allowInsecureHttp: false,
|
||||||
autoConnect: true,
|
autoConnect: true,
|
||||||
autoConnectSlot: "companion",
|
autoConnectSlot: "companion",
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
expect(invoke).toHaveBeenCalledWith("assign_connection_slot", {
|
|
||||||
request: {
|
|
||||||
slot: "companion",
|
|
||||||
profileId: "2bdedc10-d804-4da5-8e92-39dd7f175d7a",
|
|
||||||
},
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("shows duplicate server-instance warnings and locks the operations slot", async () => {
|
it("shows duplicate server-instance warnings and locks the operations slot", async () => {
|
||||||
|
|
|
||||||
|
|
@ -25,68 +25,35 @@ import { errorMessage } from "../../lib/errorMessage";
|
||||||
import { CredentialEnrollmentCard } from "./CredentialEnrollmentCard";
|
import { CredentialEnrollmentCard } from "./CredentialEnrollmentCard";
|
||||||
|
|
||||||
interface ProfileFormState {
|
interface ProfileFormState {
|
||||||
baseUrl: string;
|
|
||||||
apiKey: string;
|
|
||||||
remoteUsername: string;
|
|
||||||
slot: "" | ActiveSlotKind;
|
|
||||||
displayName: string;
|
displayName: string;
|
||||||
remoteDisplayName: string;
|
role: ProfileRole;
|
||||||
|
baseUrl: string;
|
||||||
|
eventStreamUrl: string;
|
||||||
authenticationType: AuthenticationType;
|
authenticationType: AuthenticationType;
|
||||||
transportKind: TransportKind;
|
transportKind: TransportKind;
|
||||||
|
remoteUsername: string;
|
||||||
|
remoteDisplayName: string;
|
||||||
allowInsecureHttp: boolean;
|
allowInsecureHttp: boolean;
|
||||||
|
pinnedCertificateFingerprint: string;
|
||||||
autoConnect: boolean;
|
autoConnect: boolean;
|
||||||
|
autoConnectSlot: "" | ActiveSlotKind;
|
||||||
}
|
}
|
||||||
|
|
||||||
const emptyForm: ProfileFormState = {
|
const emptyForm: ProfileFormState = {
|
||||||
baseUrl: "http://",
|
|
||||||
apiKey: "",
|
|
||||||
remoteUsername: "",
|
|
||||||
slot: "",
|
|
||||||
displayName: "",
|
displayName: "",
|
||||||
|
role: "general",
|
||||||
|
baseUrl: "https://",
|
||||||
|
eventStreamUrl: "",
|
||||||
|
authenticationType: "device-token",
|
||||||
|
transportKind: "desktop-v1",
|
||||||
|
remoteUsername: "",
|
||||||
remoteDisplayName: "",
|
remoteDisplayName: "",
|
||||||
authenticationType: "api-key",
|
|
||||||
transportKind: "astr-bot-open-api",
|
|
||||||
allowInsecureHttp: false,
|
allowInsecureHttp: false,
|
||||||
autoConnect: true,
|
pinnedCertificateFingerprint: "",
|
||||||
|
autoConnect: false,
|
||||||
|
autoConnectSlot: "",
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Names the connection after the server and identity when the user did not.
|
|
||||||
///
|
|
||||||
/// The display name is `NOT NULL` in the database and is what the profile list
|
|
||||||
/// and the slot cards show, but asking for it adds a field that carries no
|
|
||||||
/// information the other three do not already provide.
|
|
||||||
function derivedDisplayName(form: ProfileFormState): string {
|
|
||||||
const explicit = form.displayName.trim();
|
|
||||||
if (explicit) return explicit;
|
|
||||||
const username = form.remoteUsername.trim();
|
|
||||||
const host = hostOf(form.baseUrl);
|
|
||||||
if (host && username) return `${username}@${host}`;
|
|
||||||
return username || host || "AstrBot 连接";
|
|
||||||
}
|
|
||||||
|
|
||||||
function hostOf(value: string): string {
|
|
||||||
try {
|
|
||||||
return new URL(value.trim()).host;
|
|
||||||
} catch {
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// The slot a profile serves is the only meaningful reading of its role.
|
|
||||||
function roleForSlot(slot: "" | ActiveSlotKind): ProfileRole {
|
|
||||||
return slot === "" ? "general" : slot;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// True when the address needs the explicit insecure-transport approval.
|
|
||||||
///
|
|
||||||
/// `normalize_url` in `profiles.rs` rejects an `http://` base URL unless the
|
|
||||||
/// profile carries that approval, so the checkbox has to appear before the user
|
|
||||||
/// can save a LAN address — but showing it unconditionally invites turning it on
|
|
||||||
/// for an `https://` endpoint that never needed it.
|
|
||||||
function needsInsecureApproval(baseUrl: string): boolean {
|
|
||||||
return baseUrl.trim().toLowerCase().startsWith("http://");
|
|
||||||
}
|
|
||||||
|
|
||||||
const emptyPolicy: ConnectionPolicyStatus = {
|
const emptyPolicy: ConnectionPolicyStatus = {
|
||||||
operationsSwitchLocked: false,
|
operationsSwitchLocked: false,
|
||||||
activeOperationsTaskCount: 0,
|
activeOperationsTaskCount: 0,
|
||||||
|
|
@ -136,10 +103,7 @@ export function ProfileManager() {
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
void loadProfiles();
|
void loadProfiles();
|
||||||
const refreshTimer = window.setInterval(
|
const refreshTimer = window.setInterval(() => void refreshRuntimeStatus(), 2000);
|
||||||
() => void refreshRuntimeStatus(),
|
|
||||||
2000,
|
|
||||||
);
|
|
||||||
return () => window.clearInterval(refreshTimer);
|
return () => window.clearInterval(refreshTimer);
|
||||||
}, [loadProfiles, refreshRuntimeStatus]);
|
}, [loadProfiles, refreshRuntimeStatus]);
|
||||||
|
|
||||||
|
|
@ -168,65 +132,15 @@ export function ProfileManager() {
|
||||||
saved,
|
saved,
|
||||||
]),
|
]),
|
||||||
);
|
);
|
||||||
|
|
||||||
// The remaining steps each need the profile to exist, so they cannot be
|
|
||||||
// folded into the create call. A failure in either leaves a usable
|
|
||||||
// profile, so report it rather than treating the save as failed.
|
|
||||||
const followUp: string[] = [];
|
|
||||||
|
|
||||||
if (form.slot) {
|
|
||||||
try {
|
|
||||||
const assigned = connectionSlotSchema.parse(
|
|
||||||
await invoke<unknown>("assign_connection_slot", {
|
|
||||||
request: {
|
|
||||||
slot: form.slot,
|
|
||||||
profileId: saved.id,
|
|
||||||
} satisfies AssignConnectionSlotRequest,
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
setSlots((current) =>
|
|
||||||
current.map((item) =>
|
|
||||||
item.slot === assigned.slot ? assigned : item,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
} catch (reason) {
|
|
||||||
followUp.push(`槽位指派失败:${errorMessage(reason)}`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const secret = form.apiKey.trim();
|
|
||||||
if (secret) {
|
|
||||||
try {
|
|
||||||
await invoke("enroll_profile_credential", {
|
|
||||||
request: {
|
|
||||||
profileId: saved.id,
|
|
||||||
authenticationType: saved.authenticationType,
|
|
||||||
secret,
|
|
||||||
username: saved.remoteUsername ?? undefined,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
} catch (reason) {
|
|
||||||
followUp.push(
|
|
||||||
`凭据登记失败:${errorMessage(reason)}。Profile 已保存,可在下方凭据卡片重试。`,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
await loadProfiles();
|
|
||||||
await refreshPolicy();
|
await refreshPolicy();
|
||||||
if (followUp.length > 0) {
|
setNotice(
|
||||||
setError(followUp.join(" "));
|
editingId
|
||||||
setNotice(`已保存 Profile:${saved.displayName}`);
|
? `已更新 Profile:${saved.displayName}`
|
||||||
} else {
|
: `已创建 Profile:${saved.displayName}`,
|
||||||
setNotice(
|
);
|
||||||
editingId
|
|
||||||
? `已更新 Profile:${saved.displayName}`
|
|
||||||
: `已创建 Profile:${saved.displayName}`,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
resetForm();
|
resetForm();
|
||||||
} catch (reason) {
|
} catch (reason) {
|
||||||
setError(`Profile 保存失败:${errorMessage(reason)}`);
|
setError(`Profile save failed: ${errorMessage(reason)}`);
|
||||||
} finally {
|
} finally {
|
||||||
setBusy(false);
|
setBusy(false);
|
||||||
}
|
}
|
||||||
|
|
@ -234,25 +148,19 @@ export function ProfileManager() {
|
||||||
|
|
||||||
function editProfile(profile: ConnectionProfile) {
|
function editProfile(profile: ConnectionProfile) {
|
||||||
setEditingId(profile.id);
|
setEditingId(profile.id);
|
||||||
// The persisted slot assignment is authoritative for which slot a profile
|
|
||||||
// serves; `autoConnectSlot` only says where startup connection should go.
|
|
||||||
const assignedSlot = slots.find(
|
|
||||||
(slot) => slot.profileId === profile.id,
|
|
||||||
)?.slot;
|
|
||||||
setForm({
|
setForm({
|
||||||
baseUrl: profile.baseUrl,
|
|
||||||
// Never populated from a stored profile: the secret lives in Windows
|
|
||||||
// Credential Manager and never crosses IPC. Rotation goes through the
|
|
||||||
// credential card.
|
|
||||||
apiKey: "",
|
|
||||||
remoteUsername: profile.remoteUsername ?? "",
|
|
||||||
slot: assignedSlot ?? profile.autoConnectSlot ?? "",
|
|
||||||
displayName: profile.displayName,
|
displayName: profile.displayName,
|
||||||
remoteDisplayName: profile.remoteDisplayName ?? "",
|
role: profile.role,
|
||||||
|
baseUrl: profile.baseUrl,
|
||||||
|
eventStreamUrl: profile.eventStreamUrl ?? "",
|
||||||
authenticationType: profile.authenticationType,
|
authenticationType: profile.authenticationType,
|
||||||
transportKind: profile.transportKind ?? "astr-bot-open-api",
|
transportKind: profile.transportKind ?? "desktop-v1",
|
||||||
|
remoteUsername: profile.remoteUsername ?? "",
|
||||||
|
remoteDisplayName: profile.remoteDisplayName ?? "",
|
||||||
allowInsecureHttp: profile.allowInsecureHttp,
|
allowInsecureHttp: profile.allowInsecureHttp,
|
||||||
|
pinnedCertificateFingerprint: profile.pinnedCertificateFingerprint ?? "",
|
||||||
autoConnect: profile.autoConnect,
|
autoConnect: profile.autoConnect,
|
||||||
|
autoConnectSlot: profile.autoConnectSlot ?? "",
|
||||||
});
|
});
|
||||||
setError(null);
|
setError(null);
|
||||||
setNotice(null);
|
setNotice(null);
|
||||||
|
|
@ -427,12 +335,45 @@ export function ProfileManager() {
|
||||||
<h3>{editingId ? "编辑 Profile" : "新建 Profile"}</h3>
|
<h3>{editingId ? "编辑 Profile" : "新建 Profile"}</h3>
|
||||||
|
|
||||||
<label>
|
<label>
|
||||||
<span>服务器地址</span>
|
<span>显示名称</span>
|
||||||
|
<input
|
||||||
|
name="displayName"
|
||||||
|
required
|
||||||
|
maxLength={80}
|
||||||
|
value={form.displayName}
|
||||||
|
onChange={(event) =>
|
||||||
|
setForm((current) => ({
|
||||||
|
...current,
|
||||||
|
displayName: event.target.value,
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
</label>
|
||||||
|
|
||||||
|
<label>
|
||||||
|
<span>角色</span>
|
||||||
|
<select
|
||||||
|
name="role"
|
||||||
|
value={form.role}
|
||||||
|
onChange={(event) =>
|
||||||
|
setForm((current) => ({
|
||||||
|
...current,
|
||||||
|
role: event.target.value as ProfileRole,
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<option value="general">通用</option>
|
||||||
|
<option value="companion">陪伴</option>
|
||||||
|
<option value="operations">运维</option>
|
||||||
|
</select>
|
||||||
|
</label>
|
||||||
|
|
||||||
|
<label>
|
||||||
|
<span>REST 基础 URL</span>
|
||||||
<input
|
<input
|
||||||
name="baseUrl"
|
name="baseUrl"
|
||||||
type="url"
|
type="url"
|
||||||
required
|
required
|
||||||
placeholder="http://192.168.1.10:6185"
|
|
||||||
value={form.baseUrl}
|
value={form.baseUrl}
|
||||||
onChange={(event) =>
|
onChange={(event) =>
|
||||||
setForm((current) => ({
|
setForm((current) => ({
|
||||||
|
|
@ -444,12 +385,90 @@ export function ProfileManager() {
|
||||||
</label>
|
</label>
|
||||||
|
|
||||||
<label>
|
<label>
|
||||||
<span>适配器 ID</span>
|
<span>SSE URL(可选)</span>
|
||||||
|
<input
|
||||||
|
name="eventStreamUrl"
|
||||||
|
type="url"
|
||||||
|
value={form.eventStreamUrl}
|
||||||
|
onChange={(event) =>
|
||||||
|
setForm((current) => ({
|
||||||
|
...current,
|
||||||
|
eventStreamUrl: event.target.value,
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
</label>
|
||||||
|
|
||||||
|
<label>
|
||||||
|
<span>认证类型</span>
|
||||||
|
<select
|
||||||
|
name="authenticationType"
|
||||||
|
value={form.authenticationType}
|
||||||
|
onChange={(event) =>
|
||||||
|
setForm((current) => ({
|
||||||
|
...current,
|
||||||
|
authenticationType: event.target.value as AuthenticationType,
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<option value="device-token">设备 Token</option>
|
||||||
|
<option value="api-key">API Key</option>
|
||||||
|
<option value="jwt">AstrBot JWT</option>
|
||||||
|
</select>
|
||||||
|
</label>
|
||||||
|
|
||||||
|
<label>
|
||||||
|
<span>证书 SHA-256 指纹(可选)</span>
|
||||||
|
<input
|
||||||
|
name="pinnedCertificateFingerprint"
|
||||||
|
inputMode="text"
|
||||||
|
placeholder="64 位十六进制"
|
||||||
|
value={form.pinnedCertificateFingerprint}
|
||||||
|
onChange={(event) =>
|
||||||
|
setForm((current) => ({
|
||||||
|
...current,
|
||||||
|
pinnedCertificateFingerprint: event.target.value,
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
</label>
|
||||||
|
|
||||||
|
<label className="checkbox-field">
|
||||||
|
<input
|
||||||
|
name="allowInsecureHttp"
|
||||||
|
type="checkbox"
|
||||||
|
checked={form.allowInsecureHttp}
|
||||||
|
onChange={(event) =>
|
||||||
|
setForm((current) => ({
|
||||||
|
...current,
|
||||||
|
allowInsecureHttp: event.target.checked,
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
<span>明确允许不安全 HTTP(仅限受信任网络)</span>
|
||||||
|
</label>
|
||||||
|
|
||||||
|
|
||||||
|
<label>
|
||||||
|
传输协议
|
||||||
|
<select
|
||||||
|
value={form.transportKind}
|
||||||
|
onChange={(event) =>
|
||||||
|
setForm((current) => ({
|
||||||
|
...current,
|
||||||
|
transportKind: event.target.value as TransportKind,
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<option value="desktop-v1">Desktop Mock/Gateway</option>
|
||||||
|
<option value="astr-bot-open-api">AstrBot OpenAPI</option>
|
||||||
|
</select>
|
||||||
|
</label>
|
||||||
|
{form.transportKind === "astr-bot-open-api" ? (
|
||||||
|
<>
|
||||||
|
<label>
|
||||||
|
AstrBot 用户名
|
||||||
<input
|
<input
|
||||||
name="remoteUsername"
|
|
||||||
required={form.transportKind === "astr-bot-open-api"}
|
|
||||||
pattern="[A-Za-z0-9]{3,32}"
|
|
||||||
placeholder="yoki"
|
|
||||||
value={form.remoteUsername}
|
value={form.remoteUsername}
|
||||||
onChange={(event) =>
|
onChange={(event) =>
|
||||||
setForm((current) => ({
|
setForm((current) => ({
|
||||||
|
|
@ -457,159 +476,67 @@ export function ProfileManager() {
|
||||||
remoteUsername: event.target.value,
|
remoteUsername: event.target.value,
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
placeholder="desktop-companion"
|
||||||
/>
|
/>
|
||||||
</label>
|
</label>
|
||||||
<p className="form-note">
|
|
||||||
AstrBot 的会话身份,3–32 位英文或数字。两个槽位必须使用不同的
|
|
||||||
ID,否则会共用同一段对话。
|
|
||||||
</p>
|
|
||||||
|
|
||||||
{editingId ? null : (
|
|
||||||
<>
|
|
||||||
<label>
|
|
||||||
<span>API Key</span>
|
|
||||||
<input
|
|
||||||
name="apiKey"
|
|
||||||
type="password"
|
|
||||||
autoComplete="off"
|
|
||||||
value={form.apiKey}
|
|
||||||
onChange={(event) =>
|
|
||||||
setForm((current) => ({
|
|
||||||
...current,
|
|
||||||
apiKey: event.target.value,
|
|
||||||
}))
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
</label>
|
|
||||||
<p className="form-note">
|
|
||||||
保存时一次性写入 Windows
|
|
||||||
凭据管理器,不会进入本地数据库或前端状态。
|
|
||||||
</p>
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
|
|
||||||
<label>
|
<label>
|
||||||
<span>槽位</span>
|
BOT 称呼昵称
|
||||||
<select
|
<input
|
||||||
name="slot"
|
value={form.remoteDisplayName}
|
||||||
value={form.slot}
|
maxLength={80}
|
||||||
onChange={(event) =>
|
onChange={(event) =>
|
||||||
setForm((current) => ({
|
setForm((current) => ({
|
||||||
...current,
|
...current,
|
||||||
slot: event.target.value as "" | ActiveSlotKind,
|
remoteDisplayName: event.target.value,
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
placeholder="小明"
|
||||||
|
/>
|
||||||
|
</label>
|
||||||
|
</>
|
||||||
|
) : null}
|
||||||
|
<label className="checkbox-field">
|
||||||
|
<input
|
||||||
|
name="autoConnect"
|
||||||
|
type="checkbox"
|
||||||
|
checked={form.autoConnect}
|
||||||
|
onChange={(event) =>
|
||||||
|
setForm((current) => ({
|
||||||
|
...current,
|
||||||
|
autoConnect: event.target.checked,
|
||||||
|
autoConnectSlot: event.target.checked
|
||||||
|
? current.autoConnectSlot || "companion"
|
||||||
|
: "",
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
<span>启动时自动连接(不会在本阶段真正建立网络会话)</span>
|
||||||
|
</label>
|
||||||
|
|
||||||
|
<label>
|
||||||
|
<span>自动连接槽位</span>
|
||||||
|
<select
|
||||||
|
name="autoConnectSlot"
|
||||||
|
aria-label="自动连接槽位"
|
||||||
|
disabled={!form.autoConnect}
|
||||||
|
value={form.autoConnectSlot}
|
||||||
|
onChange={(event) =>
|
||||||
|
setForm((current) => ({
|
||||||
|
...current,
|
||||||
|
autoConnectSlot: event.target.value as "" | ActiveSlotKind,
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<option value="">暂不指派</option>
|
<option value="">不自动连接</option>
|
||||||
<option value="companion">陪伴</option>
|
<option value="companion">陪伴槽位</option>
|
||||||
<option value="operations">运维</option>
|
<option value="operations">运维槽位</option>
|
||||||
</select>
|
</select>
|
||||||
</label>
|
</label>
|
||||||
|
|
||||||
{needsInsecureApproval(form.baseUrl) ? (
|
<p className="form-note">
|
||||||
<label className="checkbox-field">
|
自动连接配置最多两个 Profile,且槽位不可重复;真正的 REST/SSE
|
||||||
<input
|
激活仍需等待协议与凭据边界确认。
|
||||||
name="allowInsecureHttp"
|
</p>
|
||||||
type="checkbox"
|
|
||||||
required
|
|
||||||
checked={form.allowInsecureHttp}
|
|
||||||
onChange={(event) =>
|
|
||||||
setForm((current) => ({
|
|
||||||
...current,
|
|
||||||
allowInsecureHttp: event.target.checked,
|
|
||||||
}))
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
<span>这是明文 HTTP 地址,确认仅在受信任的局域网内使用</span>
|
|
||||||
</label>
|
|
||||||
) : null}
|
|
||||||
|
|
||||||
<details className="profile-advanced">
|
|
||||||
<summary>高级设置</summary>
|
|
||||||
|
|
||||||
<label>
|
|
||||||
<span>显示名称</span>
|
|
||||||
<input
|
|
||||||
name="displayName"
|
|
||||||
maxLength={80}
|
|
||||||
placeholder={derivedDisplayName(form)}
|
|
||||||
value={form.displayName}
|
|
||||||
onChange={(event) =>
|
|
||||||
setForm((current) => ({
|
|
||||||
...current,
|
|
||||||
displayName: event.target.value,
|
|
||||||
}))
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
</label>
|
|
||||||
|
|
||||||
<label>
|
|
||||||
<span>传输协议</span>
|
|
||||||
<select
|
|
||||||
name="transportKind"
|
|
||||||
value={form.transportKind}
|
|
||||||
onChange={(event) =>
|
|
||||||
setForm((current) => ({
|
|
||||||
...current,
|
|
||||||
transportKind: event.target.value as TransportKind,
|
|
||||||
}))
|
|
||||||
}
|
|
||||||
>
|
|
||||||
<option value="astr-bot-open-api">AstrBot OpenAPI</option>
|
|
||||||
<option value="desktop-v1">Desktop Mock/Gateway</option>
|
|
||||||
</select>
|
|
||||||
</label>
|
|
||||||
|
|
||||||
<label>
|
|
||||||
<span>认证类型</span>
|
|
||||||
<select
|
|
||||||
name="authenticationType"
|
|
||||||
value={form.authenticationType}
|
|
||||||
onChange={(event) =>
|
|
||||||
setForm((current) => ({
|
|
||||||
...current,
|
|
||||||
authenticationType: event.target
|
|
||||||
.value as AuthenticationType,
|
|
||||||
}))
|
|
||||||
}
|
|
||||||
>
|
|
||||||
<option value="api-key">API Key</option>
|
|
||||||
<option value="jwt">AstrBot JWT</option>
|
|
||||||
<option value="device-token">设备 Token</option>
|
|
||||||
</select>
|
|
||||||
</label>
|
|
||||||
|
|
||||||
<label>
|
|
||||||
<span>BOT 称呼昵称</span>
|
|
||||||
<input
|
|
||||||
name="remoteDisplayName"
|
|
||||||
maxLength={80}
|
|
||||||
placeholder="小明"
|
|
||||||
value={form.remoteDisplayName}
|
|
||||||
onChange={(event) =>
|
|
||||||
setForm((current) => ({
|
|
||||||
...current,
|
|
||||||
remoteDisplayName: event.target.value,
|
|
||||||
}))
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
</label>
|
|
||||||
|
|
||||||
<label className="checkbox-field">
|
|
||||||
<input
|
|
||||||
name="autoConnect"
|
|
||||||
type="checkbox"
|
|
||||||
checked={form.autoConnect}
|
|
||||||
onChange={(event) =>
|
|
||||||
setForm((current) => ({
|
|
||||||
...current,
|
|
||||||
autoConnect: event.target.checked,
|
|
||||||
}))
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
<span>启动时自动连接所选槽位</span>
|
|
||||||
</label>
|
|
||||||
</details>
|
|
||||||
|
|
||||||
<div className="button-row">
|
<div className="button-row">
|
||||||
<button type="submit" disabled={busy}>
|
<button type="submit" disabled={busy}>
|
||||||
|
|
@ -680,7 +607,7 @@ export function ProfileManager() {
|
||||||
profile={profile}
|
profile={profile}
|
||||||
onChanged={loadProfiles}
|
onChanged={loadProfiles}
|
||||||
/>
|
/>
|
||||||
</article>
|
</article>
|
||||||
))
|
))
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -701,22 +628,23 @@ export function ProfileManager() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function toProfileInput(form: ProfileFormState): ConnectionProfileInput {
|
function toProfileInput(form: ProfileFormState): ConnectionProfileInput {
|
||||||
const slot = form.slot || undefined;
|
const eventStreamUrl = form.eventStreamUrl.trim();
|
||||||
|
const fingerprint = form.pinnedCertificateFingerprint.trim();
|
||||||
return {
|
return {
|
||||||
displayName: derivedDisplayName(form),
|
displayName: form.displayName.trim(),
|
||||||
role: roleForSlot(form.slot),
|
role: form.role,
|
||||||
baseUrl: form.baseUrl.trim(),
|
baseUrl: form.baseUrl.trim(),
|
||||||
|
eventStreamUrl: eventStreamUrl || undefined,
|
||||||
authenticationType: form.authenticationType,
|
authenticationType: form.authenticationType,
|
||||||
transportKind: form.transportKind,
|
transportKind: form.transportKind,
|
||||||
remoteUsername: form.remoteUsername.trim() || undefined,
|
remoteUsername: form.remoteUsername.trim() || undefined,
|
||||||
remoteDisplayName: form.remoteDisplayName.trim() || undefined,
|
remoteDisplayName: form.remoteDisplayName.trim() || undefined,
|
||||||
// `normalize_url` only consults this for an `http://` address, and leaving a
|
allowInsecureHttp: form.allowInsecureHttp,
|
||||||
// stale approval on an `https://` profile would silently permit a later
|
pinnedCertificateFingerprint: fingerprint || undefined,
|
||||||
// downgrade of that address.
|
autoConnect: form.autoConnect,
|
||||||
allowInsecureHttp:
|
autoConnectSlot: form.autoConnect
|
||||||
needsInsecureApproval(form.baseUrl) && form.allowInsecureHttp,
|
? form.autoConnectSlot || undefined
|
||||||
autoConnect: form.autoConnect && Boolean(slot),
|
: undefined,
|
||||||
autoConnectSlot: form.autoConnect ? slot : undefined,
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -265,32 +265,6 @@ select:focus {
|
||||||
font-size: 0.9rem;
|
font-size: 0.9rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Everything the AstrBot connection does not need in order to work. Collapsed
|
|
||||||
by default so the common path is four fields. */
|
|
||||||
.profile-advanced {
|
|
||||||
padding: 0.75rem 0.9rem;
|
|
||||||
border: 1px solid var(--ui-line, rgb(137 175 232 / 26%));
|
|
||||||
border-radius: 0.65rem;
|
|
||||||
background: var(--ui-surface-soft, rgb(11 27 49 / 45%));
|
|
||||||
}
|
|
||||||
|
|
||||||
.profile-advanced > summary {
|
|
||||||
color: var(--ui-subtle, #9fb4d4);
|
|
||||||
font-size: 0.9rem;
|
|
||||||
font-weight: 650;
|
|
||||||
cursor: pointer;
|
|
||||||
list-style-position: inside;
|
|
||||||
}
|
|
||||||
|
|
||||||
.profile-advanced[open] > summary {
|
|
||||||
margin-bottom: 0.9rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.profile-advanced > label:not(:last-child),
|
|
||||||
.profile-advanced > .checkbox-field:not(:last-child) {
|
|
||||||
margin-bottom: 0.9rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.button-row {
|
.button-row {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
|
|
|
||||||
正在加载…
添加表格
在新工单中引用