健身饮食记录
自律给我自由 · 登录开始记录
还没有账号?
⚙️ 首次使用配置说明(点击展开)

1. 去 supabase.com 注册并创建项目

2. 项目设置 → API,复制 URL 和 anon key,替换文件开头 JS 里的 SUPABASE_URL 和 SUPABASE_ANON_KEY

3. 进入 SQL Editor,执行以下建表SQL:

create table diet_records (
  id uuid primary key default gen_random_uuid(),
  user_id uuid references auth.users not null,
  date date not null,
  carb_type text,
  weight text, waist text,
  breakfast text, lunch text, dinner text,
  anaerobic text, aerobic text,
  is_public boolean default false,
  username text default '匿名用户',
  created_at timestamptz default now()
);
alter table diet_records enable row level security;
create policy "用户可查看自己的记录" on diet_records for select using (auth.uid() = user_id);
create policy "所有人可查看公开记录" on diet_records for select using (is_public = true);
create policy "用户可新增自己的记录" on diet_records for insert with check (auth.uid() = user_id);
create policy "用户可修改自己的记录" on diet_records for update using (auth.uid() = user_id);
create policy "用户可删除自己的记录" on diet_records for delete using (auth.uid() = user_id);

-- 用户资料表(用户名/隐私设置)
create table if not exists user_profiles (
  user_id uuid primary key references auth.users,
  username text,
  is_private boolean default true,
  created_at timestamptz default now()
);
alter table user_profiles enable row level security;
create policy "用户可查看自己的资料" on user_profiles for select using (auth.uid() = user_id);
create policy "用户可修改自己的资料" on user_profiles for update using (auth.uid() = user_id);
create policy "用户可新增自己的资料" on user_profiles for insert with check (auth.uid() = user_id);

-- 注册后自动创建profile的触发器(可选)
create or replace function public.handle_new_user()
returns trigger as $$
begin
  insert into public.user_profiles (user_id, username, is_private)
  values (new.id, split_part(new.email, '@', 1), true);
  return new;
end;
$$ language plpgsql security definer;
drop trigger if exists on_auth_user_created on auth.users;
create trigger on_auth_user_created
  after insert on auth.users
  for each row execute function public.handle_new_user();

健身饮食记录

时间范围

暂无记录,点击下方按钮添加

记录对比

横向滑动查看更多 →
日期 类型 早餐 午餐 晚餐 身体数据 运动
体重 腰围 无氧 有氧

所选日期范围内暂无记录

全览广场

横向滑动查看更多 →

展示所有用户公开的记录

日期 用户 类型 早餐 午餐 晚餐 身体数据 运动
体重 腰围 无氧 有氧

暂无公开记录,快去设置里把数据公开吧~

加载中...

日
一
二
三
四
五
六
低碳日
高碳日
无记录

添加记录

设置

我的用户名
在全览视图中展示给其他人
数据仅自己可见
开启后,你的记录不会出现在全览广场;关闭后所有人都能看到你的记录