diff --git a/backend/src/components/CommonAside.vue b/backend/src/components/CommonAside.vue index ddb0574..b895a77 100644 --- a/backend/src/components/CommonAside.vue +++ b/backend/src/components/CommonAside.vue @@ -296,6 +296,14 @@ const fixedCmsMenu = { icon: "Document", order: -200, children: [ + { + id: -2001, + path: "/apps/cms/analytics/content", + title: "内容统计", + icon: "DataAnalysis", + order: 0, + children: [] + }, { id: -201, path: "/apps/cms/article", diff --git a/backend/src/router/dynamicRoutes.js b/backend/src/router/dynamicRoutes.js index d1fb33c..24c0c48 100644 --- a/backend/src/router/dynamicRoutes.js +++ b/backend/src/router/dynamicRoutes.js @@ -160,11 +160,13 @@ export function convertMenusToRoutes(menus, parentPath = '') { } else if (hasChildren) { route.component = () => import('@/views/layouts/EmptyLayout.vue'); route.children = convertMenusToRoutes(menu.children, fullPath); - const firstChild = menu.children[0]; - if (firstChild && firstChild.path) { - const childFullPath = firstChild.path.startsWith('/') - ? firstChild.path - : `${fullPath}/${firstChild.path}`; + const defaultChild = menu.children.find((child) => + child.path === '/apps/cms/analytics/content' || child.path === 'analytics/content' + ) || menu.children[0]; + if (defaultChild && defaultChild.path) { + const childFullPath = defaultChild.path.startsWith('/') + ? defaultChild.path + : `${fullPath}/${defaultChild.path}`; route.redirect = childFullPath; } } else { diff --git a/backend/src/router/index.js b/backend/src/router/index.js index 113f0ed..1e23ac2 100644 --- a/backend/src/router/index.js +++ b/backend/src/router/index.js @@ -12,6 +12,12 @@ const staticMainChildren = [ }, // CMS 文章/产品/解决方案是系统内置功能,不依赖数据库菜单配置。 // 统一结构:index 为列表页,type 为分类页。 + { + path: "/apps/cms/analytics/content", + name: "CmsContentAnalytics", + component: () => import("@/views/apps/cms/analytics/content/index.vue"), + meta: { requiresAuth: true, title: "内容统计", modulePath: "/apps/cms" } + }, { path: "/apps/cms/article", name: "CmsArticles", diff --git a/backend/src/views/apps/cms/article/index/components/preview.vue b/backend/src/views/apps/cms/article/index/components/preview.vue index 7747110..ef5977a 100644 --- a/backend/src/views/apps/cms/article/index/components/preview.vue +++ b/backend/src/views/apps/cms/article/index/components/preview.vue @@ -98,6 +98,20 @@ const getCategoryName = (cate) => { return category?.name || "无分类"; }; +// 格式化日期 +const formatDate = (date: string | number | Date) => { + if (!date) return "-"; + const d = new Date(date); + if (isNaN(d.getTime())) return String(date); + const year = d.getFullYear(); + const month = String(d.getMonth() + 1).padStart(2, "0"); + const day = String(d.getDate()).padStart(2, "0"); + const hours = String(d.getHours()).padStart(2, "0"); + const minutes = String(d.getMinutes()).padStart(2, "0"); + const seconds = String(d.getSeconds()).padStart(2, "0"); + return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`; +}; + const emit = defineEmits(["update:modelValue"]); const visible = ref(false); diff --git a/backend/src/views/apps/cms/article/index/index.vue b/backend/src/views/apps/cms/article/index/index.vue index d99c0ff..20665aa 100644 --- a/backend/src/views/apps/cms/article/index/index.vue +++ b/backend/src/views/apps/cms/article/index/index.vue @@ -213,8 +213,8 @@ import { ref, onMounted } from "vue"; import { ElMessage, ElMessageBox } from "element-plus"; import { Search } from "@element-plus/icons-vue"; -import Edit from "./index/components/edit.vue"; -import Preview from "./index/components/preview.vue"; +import Edit from "./components/edit.vue"; +import Preview from "./components/preview.vue"; import { useAuthStore } from "@/stores/auth"; import { listArticles, diff --git a/backend/src/views/apps/cms/product/index/components/edit.vue b/backend/src/views/apps/cms/product/index/components/edit.vue index 17ea62d..7e33b81 100644 --- a/backend/src/views/apps/cms/product/index/components/edit.vue +++ b/backend/src/views/apps/cms/product/index/components/edit.vue @@ -1,8 +1,9 @@ - + diff --git a/backend/src/views/home/index.vue b/backend/src/views/home/index.vue index 32fe264..25100e0 100644 --- a/backend/src/views/home/index.vue +++ b/backend/src/views/home/index.vue @@ -63,7 +63,7 @@ v-for="module in basicModules" :key="module.path" class="module-card" - @click="handleNavigate(module.path)" + @click="handleNavigate(module)" >
{{ module.name }} @@ -85,7 +85,7 @@ v-for="module in systemModules" :key="module.path" class="module-card" - @click="handleNavigate(module.path)" + @click="handleNavigate(module)" >
{{ module.name }} @@ -107,7 +107,7 @@ v-for="module in uncategorizedModules" :key="module.path" class="module-card" - @click="handleNavigate(module.path)" + @click="handleNavigate(module)" >
{{ module.name }} @@ -222,8 +222,13 @@ const userName = computed( const userAvatar = computed(() => authStore.user?.avatar || ""); // 处理导航跳转 -function handleNavigate(path: string) { - if (path) router.push(path); +function handleNavigate(module: ModuleItem) { + const isWebsiteManagement = module.name === "网站管理" || module.path.startsWith("/apps/cms"); + const targetPath = isWebsiteManagement + ? "/apps/cms/analytics/content" + : module.path; + + if (targetPath) router.push(targetPath); } // 刷新菜单 diff --git a/go/controllers/backend_solution.go b/go/controllers/backend_solution.go index cda1597..fb764e2 100644 --- a/go/controllers/backend_solution.go +++ b/go/controllers/backend_solution.go @@ -60,6 +60,7 @@ func cmsSolutionToMap(row models.CmsSolution) map[string]interface{} { "title": row.Title, "thumb": row.Thumb, "desc": row.Desc, + "content": row.Content, "url": row.URL, "sort": row.Sort, "status": row.Status, @@ -141,12 +142,13 @@ func (c *BackendSolutionController) List() { } type cmsSolutionPayload struct { - Title string `json:"title"` - Thumb string `json:"thumb"` - Desc string `json:"desc"` - URL string `json:"url"` - Sort int `json:"sort"` - Status int8 `json:"status"` + Title string `json:"title"` + Thumb string `json:"thumb"` + Desc string `json:"desc"` + Content string `json:"content"` + URL string `json:"url"` + Sort int `json:"sort"` + Status int8 `json:"status"` } // Create POST /backend/addServices @@ -187,6 +189,7 @@ func (c *BackendSolutionController) Create() { Title: title, Thumb: strings.TrimSpace(p.Thumb), Desc: strings.TrimSpace(p.Desc), + Content: p.Content, URL: strings.TrimSpace(p.URL), Sort: p.Sort, Status: p.Status, @@ -245,6 +248,7 @@ func (c *BackendSolutionController) Update() { "title": title, "thumb": strings.TrimSpace(p.Thumb), "desc": strings.TrimSpace(p.Desc), + "content": p.Content, "url": strings.TrimSpace(p.URL), "sort": p.Sort, "status": p.Status, diff --git a/go/models/backend_menu_front.go b/go/models/backend_menu_front.go index 3208a51..49d7f2f 100644 --- a/go/models/backend_menu_front.go +++ b/go/models/backend_menu_front.go @@ -2,8 +2,6 @@ package models import ( "time" - - "github.com/beego/beego/v2/client/orm" ) type BackendMenuFront struct { @@ -27,7 +25,3 @@ type BackendMenuFront struct { func (m *BackendMenuFront) TableName() string { return "yz_backend_menu_front" } - -func init() { - orm.RegisterModel(new(BackendMenuFront)) -} diff --git a/go/models/cms_solution.go b/go/models/cms_solution.go index 9dfb4df..7984197 100644 --- a/go/models/cms_solution.go +++ b/go/models/cms_solution.go @@ -12,6 +12,7 @@ type CmsSolution struct { Title string `orm:"column(title);size(100)" json:"title"` Thumb string `orm:"column(thumb);size(500);default()" json:"thumb"` Desc string `orm:"column(desc);size(500);default()" json:"desc"` + Content string `orm:"column(content);type(mediumtext);null" json:"content"` URL string `orm:"column(url);size(500);default()" json:"url"` Sort int `orm:"column(sort);default(0)" json:"sort"` Status int8 `orm:"column(status);default(1)" json:"status"` @@ -55,6 +56,7 @@ CREATE TABLE IF NOT EXISTS yz_cms_solution ( title varchar(100) NOT NULL DEFAULT '', thumb varchar(500) NOT NULL DEFAULT '', ` + "`desc`" + ` varchar(500) NOT NULL DEFAULT '', + content mediumtext, url varchar(500) NOT NULL DEFAULT '', sort int NOT NULL DEFAULT 0, status tinyint NOT NULL DEFAULT 1, @@ -67,6 +69,8 @@ CREATE TABLE IF NOT EXISTS yz_cms_solution ( if err != nil { return } + // 确保已有表补齐 content 字段 + _, _ = Orm.Raw("ALTER TABLE yz_cms_solution ADD COLUMN content mediumtext").Exec() _, err = Orm.Raw(` CREATE TABLE IF NOT EXISTS yz_cms_solution_category ( id bigint unsigned NOT NULL AUTO_INCREMENT, diff --git a/go/models/init.go b/go/models/init.go index 77ab1aa..3efd2b0 100644 --- a/go/models/init.go +++ b/go/models/init.go @@ -69,11 +69,16 @@ func Init(_ string) { new(CmsArticleCategory), new(CmsArticle), + new(CmsProductCategory), + new(CmsProduct), + new(CmsSolutionCategory), + new(CmsSolution), new(CmsFrontendTemplate), new(CmsFrontendBanner), new(CmsFrontendFriendlink), new(CmsFrontendOnepage), + new(BackendMenuFront), new(SystemReminderList),