修复若干bug

This commit is contained in:
2026-04-03 22:48:27 +08:00
parent 10843a5bc5
commit 17655f2dba
16 changed files with 108 additions and 2 deletions
Binary file not shown.
Binary file not shown.
+15
View File
@@ -228,3 +228,18 @@ def reorder_items(group_id, id_list):
conn.execute("UPDATE items SET position=? WHERE id=?", (pos, iid))
conn.commit()
conn.close()
def reset_groups_and_items(recreate_default_group: bool = True):
"""
清空所有分组与程序(items)。
- 为避免外键级联受 SQLite 外键开关影响,这里显式先删 items 再删 groups。
- 可选地重新创建默认分组「常用程序」,保证界面至少有一个组可操作。
"""
conn = get_conn()
conn.execute("DELETE FROM items")
conn.execute("DELETE FROM groups")
if recreate_default_group:
conn.execute("INSERT INTO groups (name, position) VALUES ('常用程序', 0)")
conn.commit()
conn.close()