Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions apps/server/src/db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ export interface TaskRow {
screenshot: number;
created_at: number;
finished_at: number | null;
style_hint: string | null;
}

export interface SessionRow {
Expand All @@ -101,6 +102,7 @@ export const tasks = {
email: string;
domain: string;
isPublic: boolean;
styleHint: string | null;
}) {
db.insert(tasksTable)
.values({
Expand All @@ -113,6 +115,7 @@ export const tasks = {
email: p.email,
domain: p.domain,
is_public: p.isPublic ? 1 : 0,
style_hint: p.styleHint,
created_at: Date.now(),
})
.run();
Expand Down Expand Up @@ -152,20 +155,22 @@ export const tasks = {
id: string;
code: string | null;
domain: string | null;
prompt: string;
publish_url: string | null;
prompt: string;
screenshot: number;
created_at: number;
style_hint: string | null;
}> {
return db
.select({
id: tasksTable.id,
code: tasksTable.code,
domain: tasksTable.domain,
prompt: tasksTable.prompt,
publish_url: tasksTable.publish_url,
prompt: tasksTable.prompt,
screenshot: tasksTable.screenshot,
created_at: tasksTable.created_at,
style_hint: tasksTable.style_hint,
})
.from(tasksTable)
.where(
Expand Down
3 changes: 3 additions & 0 deletions apps/server/src/routes/tasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { queue } from "../services/queue.js";
import { publish } from "../services/publisher.js";
import { sendCompletionMail } from "../services/mailer.js";
import { captureScreenshot, shotPath } from "../services/screenshot.js";
import { pickStyle } from "../services/styleHint.js";
import { newTaskId, newCertCode, isValidDeviceId } from "../util/ids.js";

export const tasksRouter = Router();
Expand Down Expand Up @@ -79,6 +80,7 @@ tasksRouter.post("/", (req: Request, res: Response) => {
email: mail,
domain,
isPublic: isPublic !== false,
styleHint: pickStyle(trimmed),
});
queue.enqueueGen(id);
res.json({ taskId: id, queuePosition: queue.positionOf(id), domain });
Expand Down Expand Up @@ -123,6 +125,7 @@ screenRouter.get("/all", (_req: Request, res: Response) => {
prompt: t.prompt,
hasScreenshot: !!t.screenshot,
createdAt: t.created_at,
styleHint: t.style_hint,
})),
);
});
Expand Down
10 changes: 10 additions & 0 deletions apps/server/src/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,16 @@ export const tasksTable = sqliteTable(
screenshot: integer("screenshot").default(0),
created_at: integer("created_at"),
finished_at: integer("finished_at"),
/**
* 大屏卡片外壳(七式之一:archive/fullscreen/spine/bigno/collage/bubble/classic)。
* 创建任务时由主题关键词分类器一次性算出并写入;前台只读不判。
*
* 注意:这里**不要**加 .default()。drizzle-kit 对 SQLite 只在「新增可空无默认列」
* 时才生成 ALTER TABLE ADD COLUMN;一旦带 DEFAULT 就退化为整表重建,
* 而重建序列里的 `INSERT ... SELECT "style_hint" FROM tasks` 会引用尚不存在的新列
* 直接报错(旧库上服务起不来)。历史行的 NULL 由前端兜底成默认外壳。
*/
style_hint: text("style_hint"),
},
(t) => [
index("idx_tasks_status").on(t.status),
Expand Down
Loading
Loading