修改页面结构

This commit is contained in:
2026-02-02 20:07:37 +08:00
parent 3de5e9ebe9
commit 21f4a0fa96
209 changed files with 41824 additions and 2730 deletions

View File

@@ -0,0 +1,185 @@
/**
* 文章管理服务层
* 提供文章列表、详情、保存、删除等接口
*/
// 文章列表项数据结构
export interface ArticleItem {
id: number
title: string
category_id: number
category_name: string
image: string
description: string
status: number // 0: 未发布, 1: 已发布
views: number
created_at: string
updated_at: string
}
// 文章详情数据结构
export interface ArticleDetail {
id: number
title: string
category_id: number
image: string
description: string
content: string
status: number
created_at: string
updated_at: string
}
// 文章创建/编辑参数
export interface ArticlePayload {
title: string
category_id: number
image: string
description: string
content: string
status: number
}
/**
* 获取文章列表
* @param params 查询参数 { page, limit, keyword, status, category_id }
* @returns Promise<{ items: ArticleItem[], total: number }>
*/
export function getArticleList(params: any = {}): Promise<any> {
// TODO: 替换为实际 API 调用
// return uni.$http.get('/article/list', { params })
return new Promise((resolve) => {
setTimeout(() => {
resolve({
items: [
{
id: 1,
title: '如何选择合适的商品分类',
category_id: 1,
category_name: '运营指南',
image: '/static/article-1.png',
description: '商品分类是电商平台的重要组成部分...',
status: 1,
views: 128,
created_at: '2026-01-28 10:30:00',
updated_at: '2026-01-28 10:30:00'
},
{
id: 2,
title: '商城营销活动最佳实践',
category_id: 2,
category_name: '营销技巧',
image: '/static/article-2.png',
description: '分享最新的营销活动策略和案例...',
status: 1,
views: 256,
created_at: '2026-01-27 15:20:00',
updated_at: '2026-01-27 15:20:00'
},
{
id: 3,
title: '用户评价管理指南',
category_id: 1,
category_name: '运营指南',
image: '/static/article-3.png',
description: '如何有效管理用户的评价和反馈...',
status: 0,
views: 64,
created_at: '2026-01-26 09:15:00',
updated_at: '2026-01-26 09:15:00'
}
],
total: 3
})
}, 300)
})
}
/**
* 获取文章详情
* @param id 文章ID
* @returns Promise<ArticleDetail>
*/
export function getArticleDetail(id: number): Promise<ArticleDetail> {
// TODO: 替换为实际 API 调用
// return uni.$http.get(`/article/${id}`)
return new Promise((resolve) => {
setTimeout(() => {
resolve({
id,
title: '如何选择合适的商品分类',
category_id: 1,
image: '/static/article-1.png',
description: '商品分类是电商平台的重要组成部分...',
content: '<h2>标题</h2><p>详细内容...</p>',
status: 1,
created_at: '2026-01-28 10:30:00',
updated_at: '2026-01-28 10:30:00'
})
}, 300)
})
}
/**
* 保存文章(新建或编辑)
* @param data 文章数据
* @param id 文章ID编辑时传入
* @returns Promise<{ success: boolean, message: string, id?: number }>
*/
export function saveArticle(data: ArticlePayload, id?: number): Promise<any> {
// TODO: 替换为实际 API 调用
// const method = id ? 'PUT' : 'POST'
// const url = id ? `/article/${id}` : '/article'
// return uni.$http[method === 'PUT' ? 'put' : 'post'](url, data)
return new Promise((resolve) => {
setTimeout(() => {
resolve({
success: true,
message: id ? '编辑成功' : '新建成功',
id: id || Math.floor(Math.random() * 10000)
})
}, 500)
})
}
/**
* 删除文章
* @param id 文章ID
* @returns Promise<{ success: boolean, message: string }>
*/
export function deleteArticle(id: number): Promise<any> {
// TODO: 替换为实际 API 调用
// return uni.$http.delete(`/article/${id}`)
return new Promise((resolve) => {
setTimeout(() => {
resolve({
success: true,
message: '删除成功'
})
}, 300)
})
}
/**
* 发布/取消发布文章
* @param id 文章ID
* @param status 状态 (0: 取消发布, 1: 发布)
* @returns Promise<{ success: boolean, message: string }>
*/
export function publishArticle(id: number, status: number): Promise<any> {
// TODO: 替换为实际 API 调用
// return uni.$http.put(`/article/${id}/publish`, { status })
return new Promise((resolve) => {
setTimeout(() => {
resolve({
success: true,
message: status === 1 ? '发布成功' : '取消发布成功'
})
}, 300)
})
}

View File

@@ -0,0 +1,178 @@
/**
* 文章分类管理服务层
* 提供分类列表、保存、删除等接口
*/
// 分类数据结构
export interface CategoryItem {
id: number
name: string
description: string
image: string
article_count: number
sort: number
status: number // 0: 禁用, 1: 启用
created_at: string
updated_at: string
}
// 分类创建/编辑参数
export interface CategoryPayload {
name: string
description: string
image: string
sort: number
status: number
}
/**
* 获取分类列表
* @param params 查询参数 { page, limit, keyword, status }
* @returns Promise<{ items: CategoryItem[], total: number }>
*/
export function getCategoryList(params: any = {}): Promise<any> {
// TODO: 替换为实际 API 调用
// return uni.$http.get('/article/category/list', { params })
return new Promise((resolve) => {
setTimeout(() => {
resolve({
items: [
{
id: 1,
name: '运营指南',
description: '关于商城运营的各类指南和教程',
image: '/static/category-1.png',
article_count: 12,
sort: 1,
status: 1,
created_at: '2026-01-15 10:00:00',
updated_at: '2026-01-20 15:30:00'
},
{
id: 2,
name: '营销技巧',
description: '营销活动策略和最佳实践',
image: '/static/category-2.png',
article_count: 8,
sort: 2,
status: 1,
created_at: '2026-01-15 11:00:00',
updated_at: '2026-01-19 14:20:00'
},
{
id: 3,
name: '常见问题',
description: '常见问题解答和故障排除',
image: '/static/category-3.png',
article_count: 5,
sort: 3,
status: 1,
created_at: '2026-01-15 12:00:00',
updated_at: '2026-01-18 09:45:00'
},
{
id: 4,
name: '产品更新',
description: '产品更新日志和新功能介绍',
image: '/static/category-4.png',
article_count: 3,
sort: 4,
status: 0,
created_at: '2026-01-16 10:00:00',
updated_at: '2026-01-17 16:00:00'
}
],
total: 4
})
}, 300)
})
}
/**
* 获取分类详情
* @param id 分类ID
* @returns Promise<CategoryItem>
*/
export function getCategoryDetail(id: number): Promise<CategoryItem> {
// TODO: 替换为实际 API 调用
// return uni.$http.get(`/article/category/${id}`)
return new Promise((resolve) => {
setTimeout(() => {
resolve({
id,
name: '运营指南',
description: '关于商城运营的各类指南和教程',
image: '/static/category-1.png',
article_count: 12,
sort: 1,
status: 1,
created_at: '2026-01-15 10:00:00',
updated_at: '2026-01-20 15:30:00'
})
}, 300)
})
}
/**
* 保存分类(新建或编辑)
* @param data 分类数据
* @param id 分类ID编辑时传入
* @returns Promise<{ success: boolean, message: string, id?: number }>
*/
export function saveCategory(data: CategoryPayload, id?: number): Promise<any> {
// TODO: 替换为实际 API 调用
// const method = id ? 'PUT' : 'POST'
// const url = id ? `/article/category/${id}` : '/article/category'
// return uni.$http[method === 'PUT' ? 'put' : 'post'](url, data)
return new Promise((resolve) => {
setTimeout(() => {
resolve({
success: true,
message: id ? '编辑成功' : '新建成功',
id: id || Math.floor(Math.random() * 10000)
})
}, 500)
})
}
/**
* 删除分类
* @param id 分类ID
* @returns Promise<{ success: boolean, message: string }>
*/
export function deleteCategory(id: number): Promise<any> {
// TODO: 替换为实际 API 调用
// return uni.$http.delete(`/article/category/${id}`)
return new Promise((resolve) => {
setTimeout(() => {
resolve({
success: true,
message: '删除成功'
})
}, 300)
})
}
/**
* 启用/禁用分类
* @param id 分类ID
* @param status 状态 (0: 禁用, 1: 启用)
* @returns Promise<{ success: boolean, message: string }>
*/
export function toggleCategoryStatus(id: number, status: number): Promise<any> {
// TODO: 替换为实际 API 调用
// return uni.$http.put(`/article/category/${id}/status`, { status })
return new Promise((resolve) => {
setTimeout(() => {
resolve({
success: true,
message: status === 1 ? '启用成功' : '禁用成功'
})
}, 300)
})
}

View File

@@ -0,0 +1,25 @@
<template>
<AdminLayout :currentPage="currentPage">
<view class="page">
<view class="header">
<text class="title">{{ title }}</text>
<text class="sub-title">页面已修复 (UTF-8)</text>
</view>
</view>
</AdminLayout>
</template>
<script setup lang="uts">
import { ref } from 'vue'
import AdminLayout from '@/layouts/admin/AdminLayout.uvue'
const currentPage = ref<string>('category')
const title = ref<string>('category')
</script>
<style scoped lang="scss">
@import '@/uni.scss';
.page { padding: $space-lg; }
.header { padding: $space-lg; border-radius: $radius; background: $background-primary; box-shadow: $shadow-xs; }
.title { font-size: $font-size-lg; font-weight: $font-weight-bold; color: $text-primary; }
.sub-title { margin-top: $space-xs; font-size: $font-size-md; color: $text-secondary; }
</style>

View File

@@ -0,0 +1,25 @@
<template>
<AdminLayout :currentPage="currentPage">
<view class="page">
<view class="header">
<text class="title">{{ title }}</text>
<text class="sub-title">页面已修复 (UTF-8)</text>
</view>
</view>
</AdminLayout>
</template>
<script setup lang="uts">
import { ref } from 'vue'
import AdminLayout from '@/layouts/admin/AdminLayout.uvue'
const currentPage = ref<string>('create')
const title = ref<string>('create')
</script>
<style scoped lang="scss">
@import '@/uni.scss';
.page { padding: $space-lg; }
.header { padding: $space-lg; border-radius: $radius; background: $background-primary; box-shadow: $shadow-xs; }
.title { font-size: $font-size-lg; font-weight: $font-weight-bold; color: $text-primary; }
.sub-title { margin-top: $space-xs; font-size: $font-size-md; color: $text-secondary; }
</style>

View File

@@ -0,0 +1,25 @@
<template>
<AdminLayout :currentPage="currentPage">
<view class="page">
<view class="header">
<text class="title">{{ title }}</text>
<text class="sub-title">页面已修复 (UTF-8)</text>
</view>
</view>
</AdminLayout>
</template>
<script setup lang="uts">
import { ref } from 'vue'
import AdminLayout from '@/layouts/admin/AdminLayout.uvue'
const currentPage = ref<string>('edit')
const title = ref<string>('edit')
</script>
<style scoped lang="scss">
@import '@/uni.scss';
.page { padding: $space-lg; }
.header { padding: $space-lg; border-radius: $radius; background: $background-primary; box-shadow: $shadow-xs; }
.title { font-size: $font-size-lg; font-weight: $font-weight-bold; color: $text-primary; }
.sub-title { margin-top: $space-xs; font-size: $font-size-md; color: $text-secondary; }
</style>

View File

@@ -0,0 +1,25 @@
<template>
<AdminLayout :currentPage="currentPage">
<view class="page">
<view class="header">
<text class="title">{{ title }}</text>
<text class="sub-title">页面已修复 (UTF-8)</text>
</view>
</view>
</AdminLayout>
</template>
<script setup lang="uts">
import { ref } from 'vue'
import AdminLayout from '@/layouts/admin/AdminLayout.uvue'
const currentPage = ref<string>('article-index')
const title = ref<string>('文章管理')
</script>
<style scoped lang="scss">
@import '@/uni.scss';
.page { padding: $space-lg; }
.header { padding: $space-lg; border-radius: $radius; background: $background-primary; box-shadow: $shadow-xs; }
.title { font-size: $font-size-lg; font-weight: $font-weight-bold; color: $text-primary; }
.sub-title { margin-top: $space-xs; font-size: $font-size-md; color: $text-secondary; }
</style>