From d472b8410ede81df5b478847c34c391611d5e807 Mon Sep 17 00:00:00 2001 From: Cheng Zhou Date: Mon, 8 Jun 2026 13:38:09 +0800 Subject: [PATCH] fix(faq): repair category schema and icons --- .../20260608_01_add_faq_category_icon.py | 36 ++++++++++++ database/init.sql | 1 + frontend/index.html | 3 +- frontend/src/components/FaqCategoryForm.vue | 3 +- .../src/components/FaqCategoryManager.vue | 16 ++--- frontend/src/components/FaqCategoryPanel.vue | 20 ++----- frontend/src/components/FaqIcon.vue | 58 +++++++++++++++++++ frontend/src/views/Faq.vue | 4 +- 8 files changed, 115 insertions(+), 26 deletions(-) create mode 100644 backend/alembic/versions/20260608_01_add_faq_category_icon.py create mode 100644 frontend/src/components/FaqIcon.vue diff --git a/backend/alembic/versions/20260608_01_add_faq_category_icon.py b/backend/alembic/versions/20260608_01_add_faq_category_icon.py new file mode 100644 index 00000000..b1f372c8 --- /dev/null +++ b/backend/alembic/versions/20260608_01_add_faq_category_icon.py @@ -0,0 +1,36 @@ +"""add faq category icon column + +Revision ID: 20260608_01 +Revises: 20260529_04 +Create Date: 2026-06-08 14:30:00.000000 + +""" + +from typing import Sequence, Union + +from alembic import op +import sqlalchemy as sa + + +revision: str = "20260608_01" +down_revision: Union[str, None] = "20260529_04" +branch_labels: Union[str, Sequence[str], None] = None +depends_on: Union[str, Sequence[str], None] = None + + +def _column_exists(inspector: sa.Inspector, table_name: str, column_name: str) -> bool: + return any(column["name"] == column_name for column in inspector.get_columns(table_name)) + + +def upgrade() -> None: + bind = op.get_bind() + inspector = sa.inspect(bind) + if "faq_categories" in inspector.get_table_names() and not _column_exists(inspector, "faq_categories", "icon"): + op.add_column("faq_categories", sa.Column("icon", sa.String(length=30), nullable=True)) + + +def downgrade() -> None: + bind = op.get_bind() + inspector = sa.inspect(bind) + if "faq_categories" in inspector.get_table_names() and _column_exists(inspector, "faq_categories", "icon"): + op.drop_column("faq_categories", "icon") diff --git a/database/init.sql b/database/init.sql index 764874de..e8ba0149 100644 --- a/database/init.sql +++ b/database/init.sql @@ -376,6 +376,7 @@ CREATE TABLE IF NOT EXISTS public.faq_categories ( name character varying(100) NOT NULL, description text, sort_order integer NOT NULL DEFAULT 0, + icon character varying(30), is_active boolean NOT NULL DEFAULT true, created_at timestamp with time zone NOT NULL DEFAULT now(), updated_at timestamp with time zone NOT NULL DEFAULT now(), diff --git a/frontend/index.html b/frontend/index.html index b6573b8e..fbb2a5bf 100644 --- a/frontend/index.html +++ b/frontend/index.html @@ -5,7 +5,6 @@ - CTMS @@ -14,4 +13,4 @@ - \ No newline at end of file + diff --git a/frontend/src/components/FaqCategoryForm.vue b/frontend/src/components/FaqCategoryForm.vue index dcb01735..57424a68 100644 --- a/frontend/src/components/FaqCategoryForm.vue +++ b/frontend/src/components/FaqCategoryForm.vue @@ -41,7 +41,7 @@ 'icon-option--used': isIconUsedByOther(icon.cls), }]" @click="selectIcon(icon.cls)" - > + > @@ -62,6 +62,7 @@ diff --git a/frontend/src/views/Faq.vue b/frontend/src/views/Faq.vue index b553eb92..04fc932a 100644 --- a/frontend/src/views/Faq.vue +++ b/frontend/src/views/Faq.vue @@ -2,7 +2,7 @@
-

项目知识库

+

项目知识库

import { computed, onMounted, ref, watch } from "vue"; import { ElMessage } from "element-plus"; -import { Plus, Search } from "@element-plus/icons-vue"; +import { Collection, Plus, Search } from "@element-plus/icons-vue"; import { fetchFaqCategories, fetchFaqItems } from "../api/faqs"; import FaqCategoryPanel from "../components/FaqCategoryPanel.vue"; import FaqList from "../components/FaqList.vue";