💰

记账本

个人财务管家

⚙️ 配置 Supabase

记账本

🔔 你的账号尚未同步到云端,点击此处注册云端账号 启用云同步备份
本月收入 ¥0.00
本月支出 ¥0.00
本月结余 ¥0.00

最近交易

分类支出

预算进度

📝

还没有交易记录

我的银行卡

收支趋势

分类占比

分类明细

预算管理

账户信息

U
用户
已登录

数据管理

云端同步

关于

记账本 v1.0
数据存储于本地浏览器

记一笔

添加卡片

添加预算

Supabase 配置

Supabase 快速上手:
1. 访问 supabase.com 注册并创建项目
2. SQL Editor 中执行以下建表 SQL
3. 在 Settings → API 获取 URL 和 anon key
4. 重要:Authentication → URL Configuration 中添加 Site URL(如 http://localhost:8080)
5. 重要:Authentication → Providers → Email 确认已启用
6. 填入下方保存即可启用云端同步
🔧 常见问题排查:
• 报错「无法连接」→ 检查 URL/Key 是否正确,网络是否通畅
• 报错「AuthRetryableFetchError」→ 检查项目是否被暂停,URL Configuration 是否正确
• 注册失败 → 确认 Email Provider 已启用,密码至少 8 位含大小写和数字
• 点击「诊断」按钮可一键检测所有配置
建表 SQL:
-- 启用 RLS
alter database postgres set "Timezone" to 'UTC';

create table if not exists profiles (
  id uuid references auth.users primary key,
  username text unique,
  created_at timestamptz default now()
);

create table if not exists transactions (
  id text primary key,
  user_id uuid references auth.users(id),
  type text check (type in ('income','expense')),
  amount numeric,
  category text,
  date text,
  merchant text,
  note text,
  created_at timestamptz default now()
);

create table if not exists cards (
  id text primary key,
  user_id uuid references auth.users(id),
  name text, type text, number text, bank text,
  color text, balance numeric, credit_limit numeric,
  arrears numeric, due_date int, statement_date int,
  created_at timestamptz default now()
);

create table if not exists budgets (
  id text primary key,
  user_id uuid references auth.users(id),
  name text, category text, amount numeric,
  created_at timestamptz default now()
);

create table if not exists categories (
  id text primary key,
  user_id uuid references auth.users(id),
  type text, name text, icon text, color text,
  is_default boolean default false,
  created_at timestamptz default now()
);

-- RLS
alter table transactions enable row level security;
alter table cards enable row level security;
alter table budgets enable row level security;
alter table categories enable row level security;

create policy "own_transactions" on transactions for all using (auth.uid() = user_id);
create policy "own_cards" on cards for all using (auth.uid() = user_id);
create policy "own_budgets" on budgets for all using (auth.uid() = user_id);
create policy "own_categories" on categories for all using (auth.uid() = user_id);
create policy "own_profiles" on profiles for all using (auth.uid() = id);

-- 自动创建 profile
create or replace function handle_new_user() returns trigger as $$
  begin
    insert into profiles (id, username)
    values (new.id, new.raw_user_meta_data->>'username');
    return new;
  end;
$$ language plpgsql;

create trigger on_auth_user_created
  after insert on auth.users
  for each row execute procedure handle_new_user();