feat(api,userbot,frontend): add accounts from the web ui and isolate per-account settings

This commit is contained in:
hh
2026-08-05 23:49:52 +02:00
parent 92fd20137e
commit 9c265af3d3
19 changed files with 917 additions and 268 deletions
@@ -1,5 +1,4 @@
<script lang="ts">
import { onMount } from "svelte";
import {
createPolicy,
deletePolicy,
@@ -16,6 +15,7 @@
import CaptureToggleList from "$lib/components/policy/CaptureToggleList.svelte";
import Icon from "$lib/components/ui/Icon.svelte";
import Spinner from "$lib/components/ui/Spinner.svelte";
import { accounts } from "$lib/stores/accounts.svelte";
import { chats } from "$lib/stores/chats.svelte";
import { toasts } from "$lib/stores/toasts.svelte";
@@ -110,7 +110,8 @@
p.id === record.id ? { ...p, [key]: value } : p
);
try {
await updatePolicy(record.id, next);
const saved = await updatePolicy(record.id, next);
policies = policies.map((p) => (p.id === record.id ? saved : p));
} catch {
toasts.error("Не удалось сохранить политику");
await reload();
@@ -143,7 +144,8 @@
}
}
onMount(async () => {
async function load(_account: number | null) {
loading = true;
chats.load();
try {
await reload();
@@ -152,6 +154,10 @@
} finally {
loading = false;
}
}
$effect(() => {
load(accounts.selectedId);
});
</script>
@@ -159,7 +165,10 @@
<div class="card">
<div class="card-head">
<span class="card-title">{title}</span>
{#if onremove}
{#if record.account_id === null}
<span class="shared">для всех аккаунтов</span>
{/if}
{#if onremove && record.account_id !== null}
<button
type="button"
class="remove"
@@ -303,6 +312,11 @@
font-weight: var(--font-weight-medium);
}
.shared {
font-size: 0.75rem;
color: var(--color-text-secondary);
}
.remove {
cursor: pointer;
display: flex;