pokalasruthi-26/pyroshield-emergency-incident-management
GitHub: pokalasruthi-26/pyroshield-emergency-incident-management
PyroShield 是一款实时火灾事件报告和应急响应管理平台。
Stars: 0 | Forks: 0
# 火灾报告应用
## 本地运行
1. 安装依赖:
- `npm install`
2. 启动应用:
- `npm run dev`
## Supabase 设置(修复图片上传错误)
如果图片上传失败,出现类似“找不到存储桶”、“新行违反行级安全”或“403”的消息,请在 Supabase SQL 编辑器中完成此设置。
快速选项:在 [supabase/fix_storage_and_rls.sql](supabase/fix_storage_and_rls.sql) 中运行脚本。
### 1. 必需的表
```
create table if not exists public.profiles (
id uuid primary key,
name text,
email text,
role text default 'public',
trust_score int default 80,
created_at timestamptz default now()
);
create table if not exists public.incidents (
id uuid primary key default gen_random_uuid(),
description text not null,
latitude double precision not null,
longitude double precision not null,
address text,
image_url text,
priority text default 'low',
status text default 'active',
reporter_id uuid,
reporter_name text,
created_at timestamptz default now()
);
create table if not exists public.status_logs (
id uuid primary key default gen_random_uuid(),
incident_id uuid references public.incidents(id) on delete cascade,
status text not null,
message text not null,
updated_at timestamptz default now()
);
```
### 2. 为图片创建存储桶
```
insert into storage.buckets (id, name, public)
values ('incident-images', 'incident-images', true)
on conflict (id) do nothing;
```
### 3. 上传和读取的存储策略
```
create policy "Public read incident images"
on storage.objects
for select
to public
using (bucket_id = 'incident-images');
create policy "Authenticated upload incident images"
on storage.objects
for insert
to authenticated
with check (bucket_id = 'incident-images');
```
### 4. 表 RLS 策略
```
alter table public.incidents enable row level security;
alter table public.status_logs enable row level security;
alter table public.profiles enable row level security;
create policy "Read incidents"
on public.incidents
for select
to authenticated
using (true);
create policy "Insert incidents"
on public.incidents
for insert
to authenticated
with check (true);
create policy "Read status logs"
on public.status_logs
for select
to authenticated
using (true);
create policy "Insert status logs"
on public.status_logs
for insert
to authenticated
with check (true);
```
## 注意事项
- 报告表单在图片上传下方有专门的提交按钮。
- 用户报告写入 `incidents` 和 `status_logs`,并在管理员仪表板上可见。
- 如果存储上传失败,应用仍然会使用内联压缩图片数据提交报告,以便管理员可以立即分析。
标签:GPS定位, SQL编辑, Supabase, 事件生命周期管理, 代码部署, 图像存储, 多线程, 存储桶配置, 存储策略, 安全策略, 库, 应急响应, 提示词设计, 数据上传, 数据库管理, 本地运行, 火灾报警, 用户角色管理, 紧急警报, 自定义脚本, 行级安全, 表单创建, 逆向工具