修复若干bug
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user