feat(topology): add square light canvas
Co-Authored-By: OpenAI Codex <codex@openai.com>
This commit is contained in:
@@ -3,41 +3,44 @@
|
||||
import json
|
||||
from topology_api.db import write_cursor
|
||||
|
||||
THEME_KEY = "guanghan_dark_engineering_v1"
|
||||
THEME_KEY = "guanghan_light_engineering_v1"
|
||||
CANVAS_WIDTH = 1900
|
||||
CANVAS_HEIGHT = 1900
|
||||
CONTENT_X_OFFSET = 200
|
||||
|
||||
THEME_TOKENS = {
|
||||
"textColor": "#eaf2ff",
|
||||
"mutedTextColor": "#91a3bd",
|
||||
"metaColor": "#a6b5c9",
|
||||
"hintColor": "#71849e",
|
||||
"textColor": "#152033",
|
||||
"mutedTextColor": "#5e6f85",
|
||||
"metaColor": "#435a72",
|
||||
"hintColor": "#6f8296",
|
||||
}
|
||||
|
||||
NODE_STYLES = [
|
||||
("node-card", "普通舱段", "#10263a", "#52baff", 3, 16),
|
||||
("core-card", "核心舱", "#3b250d", "#ffad42", 5, 16),
|
||||
("power-card", "电力模块分支", "#2a2810", "#d5b642", 3, 16),
|
||||
("power-node-card", "电力模块中心", "#393412", "#d5b642", 5, 16),
|
||||
("vehicle-card", "车辆", "#291c34", "#c28cdf", 3, 16),
|
||||
("node-card", "普通舱段", "#edf7ff", "#1677b8", 3, 16),
|
||||
("core-card", "核心舱", "#fff3e2", "#c76b00", 5, 16),
|
||||
("power-card", "电力模块分支", "#fff9d9", "#9b7900", 3, 16),
|
||||
("power-node-card", "电力模块中心", "#fff2b8", "#9b7900", 5, 16),
|
||||
("vehicle-card", "车辆", "#f7effb", "#8755a4", 3, 16),
|
||||
]
|
||||
|
||||
EDGE_STYLES = [
|
||||
("structural_mount", "结构直连", "#8fa1b8", 6, None, "square", "structural", 10),
|
||||
("pressurized_passage", "加压走道", "#51e89c", 9, None, "square", "pressurized", 20),
|
||||
("fuel", "燃料 / 供电", "#b178e6", 4, "13 10", "square", "utility", 30),
|
||||
("power", "燃料 / 供电", "#b178e6", 4, "13 10", "square", "utility", 30),
|
||||
("cooling", "冷却", "#78d6e6", 4, "10 8", "square", "cooling", 40),
|
||||
("docking", "对接口", "#c28cdf", 4, "10 8", "square", "docking", 50),
|
||||
("structural_mount", "结构直连", "#66788e", 6, None, "square", "structural", 10),
|
||||
("pressurized_passage", "加压走道", "#168a55", 9, None, "square", "pressurized", 20),
|
||||
("fuel", "燃料 / 供电", "#7a4fb3", 4, "13 10", "square", "utility", 30),
|
||||
("power", "燃料 / 供电", "#7a4fb3", 4, "13 10", "square", "utility", 30),
|
||||
("cooling", "冷却", "#27809a", 4, "10 8", "square", "cooling", 40),
|
||||
("docking", "对接口", "#8755a4", 4, "10 8", "square", "docking", 50),
|
||||
]
|
||||
|
||||
DECORATION_STYLES = [
|
||||
(
|
||||
"radiator",
|
||||
"大型折叠散热面板",
|
||||
"#6b5814",
|
||||
"#f0d869",
|
||||
"#fff0a8",
|
||||
"#9b7900",
|
||||
2,
|
||||
"散热器",
|
||||
"#f4df7b",
|
||||
"#6d5500",
|
||||
{
|
||||
"widthRatio": 0.55,
|
||||
"maxWidth": 130,
|
||||
@@ -64,6 +67,11 @@ def seed():
|
||||
cur.execute("SELECT id FROM bases WHERE code = 'guanghan'")
|
||||
base_id = cur.fetchone()["id"]
|
||||
|
||||
cur.execute(
|
||||
"UPDATE diagram_themes SET is_default = false WHERE base_id = %(base)s",
|
||||
{"base": base_id},
|
||||
)
|
||||
|
||||
cur.execute("""
|
||||
INSERT INTO diagram_themes
|
||||
(id, base_id, theme_key, name, description, tokens, is_default)
|
||||
@@ -71,8 +79,8 @@ def seed():
|
||||
gen_random_uuid(),
|
||||
%(base)s,
|
||||
%(theme_key)s,
|
||||
'广寒深色工程图',
|
||||
'广寒基地工程总图默认表现层主题',
|
||||
'广寒浅色工程图',
|
||||
'适配 Wiki.js 与 Dark Reader 的浅色工程总图主题',
|
||||
%(tokens)s,
|
||||
true
|
||||
)
|
||||
@@ -96,13 +104,20 @@ def seed():
|
||||
INSERT INTO diagram_layouts (id, base_id, layout_key, name,
|
||||
canvas_width, canvas_height, is_default, theme_id)
|
||||
VALUES (gen_random_uuid(), %(base)s, 'engineering_overview_v1',
|
||||
'工程总图 v1', 1500, 1900, true, %(theme)s)
|
||||
'工程总图 v1', %(canvas_width)s, %(canvas_height)s, true, %(theme)s)
|
||||
ON CONFLICT (base_id, layout_key) DO UPDATE
|
||||
SET name = EXCLUDED.name,
|
||||
canvas_width = EXCLUDED.canvas_width,
|
||||
canvas_height = EXCLUDED.canvas_height,
|
||||
is_default = true,
|
||||
theme_id = EXCLUDED.theme_id
|
||||
RETURNING id
|
||||
""", {"base": base_id, "theme": theme_id})
|
||||
""", {
|
||||
"base": base_id,
|
||||
"canvas_width": CANVAS_WIDTH,
|
||||
"canvas_height": CANVAS_HEIGHT,
|
||||
"theme": theme_id,
|
||||
})
|
||||
layout_id = cur.fetchone()["id"]
|
||||
print(f"Layout: {layout_id}")
|
||||
|
||||
@@ -278,7 +293,7 @@ def seed():
|
||||
""", {
|
||||
"lid": layout_id, "cid": primary_component_id,
|
||||
"nkey": node_key,
|
||||
"x": x, "y": y, "w": w, "h": h,
|
||||
"x": x + CONTENT_X_OFFSET, "y": y, "w": w, "h": h,
|
||||
"style": style, "label": label, "z": z,
|
||||
"meta": display_meta, "hint": display_hint,
|
||||
"decorations": json.dumps(decorations),
|
||||
|
||||
Reference in New Issue
Block a user