103 lines
3.0 KiB
Markdown
103 lines
3.0 KiB
Markdown
# cooperation
|
||
|
||
协作工具, 把事情变简单
|
||
|
||
```bash
|
||
# 下载到本地(使用 git)
|
||
git clone git@git.satori.love:LaniakeaSupercluster/cooperation.git
|
||
cd cooperation
|
||
|
||
# 安装依赖(使用镜像站)
|
||
npm i --registry=https://registry.npmmirror.com
|
||
|
||
# 运行开发环境
|
||
npm run dev
|
||
|
||
# 编译发布
|
||
npm run build
|
||
|
||
# 生产环境运行
|
||
npm run start
|
||
```
|
||
|
||
编辑器
|
||
- [x] 虚拟光标
|
||
- [ ] 实时转换
|
||
- [ ] 括号补全
|
||
- [ ] 自动缩进
|
||
- [ ] 列表延伸
|
||
- [ ] 快捷缩进
|
||
- [ ] 拖动排序
|
||
- [ ] 多选交互
|
||
- [ ] 图像加入
|
||
- [ ] 指令预测
|
||
|
||
|
||
协作同步
|
||
- [ ] 日志流
|
||
- [ ] 推转@(将任务推到下一个工序)
|
||
- [ ] 推转等待(下一个工序处理后仍要回执的, 等待过长会造成效率低下)
|
||
- [ ] 创建项目
|
||
- [ ] 发布任务
|
||
|
||
|
||
```sql
|
||
-- 用户表
|
||
CREATE TABLE users (
|
||
id INTEGER PRIMARY KEY,
|
||
name TEXT NOT NULL,
|
||
avatar TEXT, -- 存储头像的 URL 或路径
|
||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, -- 自动设置创建时间
|
||
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, -- 自动设置更新时间
|
||
CHECK (created_at <= updated_at) -- 确保更新时间不早于创建时间
|
||
);
|
||
|
||
-- 项目表
|
||
CREATE TABLE projects (
|
||
id INTEGER PRIMARY KEY,
|
||
user_id INTEGER NOT NULL,
|
||
name TEXT NOT NULL,
|
||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, -- 自动设置创建时间
|
||
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, -- 自动设置更新时间
|
||
FOREIGN KEY (user_id) REFERENCES users (id) ON DELETE CASCADE,
|
||
CHECK (created_at <= updated_at) -- 确保更新时间不早于创建时间
|
||
);
|
||
|
||
-- 任务表
|
||
CREATE TABLE tasks (
|
||
id INTEGER PRIMARY KEY,
|
||
project_id INTEGER NOT NULL,
|
||
name TEXT NOT NULL,
|
||
status TEXT NOT NULL DEFAULT '未开始', -- 任务状态默认未开始
|
||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, -- 自动设置创建时间
|
||
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, -- 自动设置更新时间
|
||
FOREIGN KEY (project_id) REFERENCES projects (id) ON DELETE CASCADE,
|
||
CHECK (created_at <= updated_at), -- 确保更新时间不早于创建时间
|
||
CHECK (status IN ('未开始', '进行中', '已完成')) -- 限制任务状态为预定义值
|
||
);
|
||
|
||
|
||
-- 问题发现 > 分析原因 > 处理方案 > 处理结果
|
||
-- 功能新增 > 分析需求 > 规划方案 > 实施结果
|
||
|
||
|
||
-- 触发器(自动设置更新时间)
|
||
CREATE TRIGGER update_users AFTER UPDATE ON users FOR EACH ROW BEGIN
|
||
UPDATE users SET updated_at = CURRENT_TIMESTAMP WHERE id = OLD.id;
|
||
END;
|
||
|
||
CREATE TRIGGER update_projects AFTER UPDATE ON projects FOR EACH ROW BEGIN
|
||
UPDATE projects SET updated_at = CURRENT_TIMESTAMP WHERE id = OLD.id;
|
||
END;
|
||
|
||
CREATE TRIGGER update_tasks AFTER UPDATE ON tasks FOR EACH ROW BEGIN
|
||
UPDATE tasks SET updated_at = CURRENT_TIMESTAMP WHERE id = OLD.id;
|
||
END;
|
||
|
||
```
|
||
|
||
默认情况下,SQLite 的外键约束是关闭的,需要在每次连接数据库时显式启用外键支持。否则,外键约束将不会生效。
|
||
```sql
|
||
PRAGMA foreign_keys = ON;
|
||
```
|