From c2fa484010aa0fd3e513783078870a591f23c96e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E5=BF=A0=E6=9E=97?= <170083662@qq.com> Date: Sun, 6 Jul 2025 09:58:35 +0800 Subject: [PATCH] =?UTF-8?q?next=E7=89=88=E6=9C=AC=E7=9A=84pc=E7=AB=AF?= =?UTF-8?q?=E7=A8=8B=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- next.config.ts | 2 +- src/api/bszx/bszxBranch/index.ts | 3 +- src/api/examples/tenant-api-usage.ts | 145 -------- src/api/index.ts | 12 +- src/api/layout/index.ts | 19 +- src/api/modules/article.ts | 390 -------------------- src/api/modules/auth.ts | 246 ------------ src/api/modules/user.ts | 284 -------------- src/api/passport/login/index.ts | 34 +- src/api/system/company/index.ts | 1 - src/app/api-example/page.tsx | 288 --------------- src/app/articles/[id]/page.tsx | 358 ------------------ src/app/articles/page.tsx | 380 ------------------- src/app/globals.css | 4 +- src/app/layout.tsx | 3 - src/app/page.tsx | 21 +- src/components/layout/Footer.tsx | 145 +------- src/components/layout/Header.tsx | 120 +----- src/components/sections/PartnersSection.tsx | 94 ++--- src/config/setting.ts | 5 + src/utils/request.ts | 11 +- 21 files changed, 118 insertions(+), 2447 deletions(-) delete mode 100644 src/api/examples/tenant-api-usage.ts delete mode 100644 src/api/modules/article.ts delete mode 100644 src/api/modules/auth.ts delete mode 100644 src/api/modules/user.ts delete mode 100644 src/app/api-example/page.tsx delete mode 100644 src/app/articles/[id]/page.tsx delete mode 100644 src/app/articles/page.tsx diff --git a/next.config.ts b/next.config.ts index 1617a52..6faa225 100644 --- a/next.config.ts +++ b/next.config.ts @@ -62,7 +62,7 @@ const nextConfig: NextConfig = { pathname: '/**', }, ], - }, + } }; export default nextConfig; diff --git a/src/api/bszx/bszxBranch/index.ts b/src/api/bszx/bszxBranch/index.ts index 0f7955b..2c14319 100644 --- a/src/api/bszx/bszxBranch/index.ts +++ b/src/api/bszx/bszxBranch/index.ts @@ -79,8 +79,9 @@ export async function removeBszxBranch(id?: number) { /** * 批量删除百色中学-分部 */ + export async function removeBatchBszxBranch(data: (number | undefined)[]) { - const res = await request.delete>( + const res = await request.delete>( MODULES_API_URL + '/bszx/bszx-branch/batch', { data diff --git a/src/api/examples/tenant-api-usage.ts b/src/api/examples/tenant-api-usage.ts deleted file mode 100644 index f7f3a67..0000000 --- a/src/api/examples/tenant-api-usage.ts +++ /dev/null @@ -1,145 +0,0 @@ -/** - * 租户 API 使用示例 - * 展示如何使用带租户 ID 的 API 请求 - */ - -import { request } from '@/api'; -import type { ApiResult, PageResult, PageParam } from '@/api'; - -// ==================== 示例数据类型 ==================== - -interface User { - id: number; - name: string; - email: string; - tenantId: string; - createTime: string; -} - -interface CreateUserData { - name: string; - email: string; - password: string; -} - -interface UpdateUserData { - name?: string; - email?: string; -} - -// ==================== API 使用示例 ==================== - -/** - * 获取用户列表 - GET 请求示例 - * 租户 ID 会自动添加到查询参数中 - */ -export const getUserList = async (params?: PageParam): Promise>> => { - return request.get>('/users', params); -}; - -/** - * 获取用户详情 - GET 请求示例 - * 租户 ID 会自动添加到查询参数中 - */ -export const getUserById = async (id: number): Promise> => { - return request.get(`/users/${id}`); -}; - -/** - * 创建用户 - POST 请求示例 - * 租户 ID 会自动添加到请求体中 - */ -export const createUser = async (data: CreateUserData): Promise> => { - return request.post('/users', data); -}; - -/** - * 更新用户 - PUT 请求示例 - * 租户 ID 会自动添加到请求体中 - */ -export const updateUser = async (id: number, data: UpdateUserData): Promise> => { - return request.put(`/users/${id}`, data); -}; - -/** - * 部分更新用户 - PATCH 请求示例 - * 租户 ID 会自动添加到请求体中 - */ -export const patchUser = async (id: number, data: Partial): Promise> => { - return request.patch(`/users/${id}`, data); -}; - -/** - * 删除用户 - DELETE 请求示例 - * 租户 ID 会自动添加到请求头中 - */ -export const deleteUser = async (id: number): Promise> => { - return request.delete(`/users/${id}`); -}; - -// ==================== 使用示例 ==================== - -/** - * 组件中使用示例 - */ -export const exampleUsage = async () => { - try { - // 获取用户列表 - const userListResult = await getUserList({ - page: 1, - limit: 10, - keywords: '张三' - }); - - if (userListResult.code === 0) { - console.log('用户列表:', userListResult.data?.list); - } - - // 创建用户 - const createResult = await createUser({ - name: '新用户', - email: 'newuser@example.com', - password: '123456' - }); - - if (createResult.code === 0) { - console.log('创建成功:', createResult.data); - } - - // 更新用户 - if (createResult.data?.id) { - const updateResult = await updateUser(createResult.data.id, { - name: '更新后的用户名' - }); - - if (updateResult.code === 0) { - console.log('更新成功:', updateResult.data); - } - } - - } catch (error) { - console.error('API 请求失败:', error); - } -}; - -// ==================== 注意事项 ==================== - -/** - * 租户 ID 自动添加说明: - * - * 1. GET 请求:租户 ID 会自动添加到查询参数中 - * 例如:/users?page=1&limit=10&tenantId=1001 - * - * 2. POST/PUT/PATCH 请求:租户 ID 会自动添加到请求体中 - * 例如:{ name: '用户名', email: 'email@example.com', tenantId: '10001' } - * - * 3. 所有请求:租户 ID 会自动添加到请求头中 - * 例如:TenantId: 1001 - * - * 4. 租户 ID 从配置文件中读取: - * - 环境变量:NEXT_PUBLIC_TENANT_ID - * - 配置文件:APP_CONFIG.TENANT_ID - * - 默认值:'10001' - * - * 5. 如果需要覆盖租户 ID,可以在请求参数或数据中显式指定 - */ diff --git a/src/api/index.ts b/src/api/index.ts index 85c01ed..6595e8b 100644 --- a/src/api/index.ts +++ b/src/api/index.ts @@ -267,7 +267,7 @@ export class ApiClient { (requestConfig.headers as Record)['TenantId'] = APP_CONFIG.TENANT_ID; // 添加请求体 - if (data && ['POST', 'PUT', 'PATCH'].includes(method)) { + if (data && ['POST', 'PUT', 'PATCH', 'DELETE'].includes(method)) { if (data instanceof FormData) { // FormData 不需要设置 Content-Type delete (requestConfig.headers as Record)['Content-Type']; @@ -368,8 +368,10 @@ export class ApiClient { /** * DELETE 请求 */ - async delete(url: string, config?: RequestConfig): Promise> { - return this.request(url, 'DELETE', undefined, config); + async delete(url: string, data?: unknown, config?: RequestConfig): Promise> { + // 为对象数据添加租户ID + const mergedData = this.addTenantIdToData(data); + return this.request(url, 'DELETE', mergedData, config); } /** @@ -402,8 +404,8 @@ export const request = { put: (url: string, data?: unknown, config?: RequestConfig) => apiClient.put(url, data, config), - delete: (url: string, config?: RequestConfig) => - apiClient.delete(url, config), + delete: (url: string, data?: unknown, config?: RequestConfig) => + apiClient.delete(url, data, config), patch: (url: string, data?: unknown, config?: RequestConfig) => apiClient.patch(url, data, config), diff --git a/src/api/layout/index.ts b/src/api/layout/index.ts index 8d105ed..591b046 100644 --- a/src/api/layout/index.ts +++ b/src/api/layout/index.ts @@ -16,7 +16,7 @@ export async function getTenantInfo(): Promise { SERVER_API_URL + '/auth/tenant' ); if (res.data.code === 0 && res.data.data) { - return res.data.data; + return res.data.data as Company; } return Promise.reject(new Error(res.data.message)); } @@ -34,7 +34,7 @@ export async function getSiteInfo(): Promise { } ); if (res.data.code === 0 && res.data.data) { - return res.data.data; + return res.data.data as unknown as CmsWebsite; } return Promise.reject(new Error(res.data.message)); } @@ -45,7 +45,7 @@ export async function getSiteInfo(): Promise { export async function getUserInfo(): Promise { const res = await request.get>(SERVER_API_URL + '/auth/user'); if (res.data.code === 0 && res.data.data) { - return res.data.data; + return res.data.data as unknown as User; } return Promise.reject(new Error(res.data.message)); } @@ -68,12 +68,12 @@ export async function updateLoginUser(data: User) { * 获取服务器时间(实时) * @return */ -export async function getServerTime() { - const res = await request.get>( +export async function getServerTime(): Promise { + const res = await request.get>( MODULES_API_URL + '/cms/website/getServerTime' ); if (res.data.code === 0 && res.data.data) { - return res.data.data; + return res.data.data as unknown as string; } return Promise.reject(new Error(res.data.message)); } @@ -82,13 +82,12 @@ export async function getServerTime() { * 获取未来7天的日期 * @return */ -export async function getNext7day() { - const res = await request.get>( +export async function getNext7day(): Promise { + const res = await request.get>( MODULES_API_URL + '/cms/website/getNext7day' ); - console.log('res.data.code: ', res.data.code); if (res.data.code === 0 && res.data.data) { - return res.data.data; + return res.data.data as unknown as string[]; } return Promise.reject(new Error(res.data.message)); } diff --git a/src/api/modules/article.ts b/src/api/modules/article.ts deleted file mode 100644 index cacca28..0000000 --- a/src/api/modules/article.ts +++ /dev/null @@ -1,390 +0,0 @@ -/** - * 文章相关 API - */ - -import { request, type ApiResult, type PageResult, type PageParam } from '@/api'; - -// ==================== 类型定义 ==================== - -/** - * 文章信息 - */ -export interface Article { - id: number; - title: string; - content: string; - excerpt?: string; - thumbnail?: string; - author: string; - authorId: number; - categoryId?: number; - categoryName?: string; - tags?: string[]; - status: 'draft' | 'published' | 'archived'; - viewCount: number; - likeCount: number; - commentCount: number; - isTop: boolean; - isRecommend: boolean; - publishTime?: string; - createTime: string; - updateTime: string; - seoTitle?: string; - seoKeywords?: string; - seoDescription?: string; -} - -/** - * 文章分类 - */ -export interface ArticleCategory { - id: number; - name: string; - slug: string; - description?: string; - parentId?: number; - sortOrder: number; - articleCount: number; - status: number; - createTime: string; - children?: ArticleCategory[]; -} - -/** - * 文章标签 - */ -export interface ArticleTag { - id: number; - name: string; - slug: string; - color?: string; - articleCount: number; - createTime: string; -} - -/** - * 文章查询参数 - */ -export interface ArticleSearchParams extends PageParam { - title?: string; - categoryId?: number; - authorId?: number; - status?: 'draft' | 'published' | 'archived'; - isTop?: boolean; - isRecommend?: boolean; - tags?: string[]; - startTime?: string; - endTime?: string; -} - -/** - * 文章创建参数 - */ -export interface CreateArticleParams { - title: string; - content: string; - excerpt?: string; - thumbnail?: string; - categoryId?: number; - tags?: string[]; - status?: 'draft' | 'published'; - isTop?: boolean; - isRecommend?: boolean; - publishTime?: string; - seoTitle?: string; - seoKeywords?: string; - seoDescription?: string; -} - -/** - * 文章更新参数 - */ -export interface UpdateArticleParams extends CreateArticleParams { - id: number; -} - -// ==================== API 方法 ==================== - -/** - * 文章 API 类 - */ -export class ArticleApi { - /** - * 分页查询文章列表 - */ - static async getArticles(params?: ArticleSearchParams): Promise>> { - return request.get>('/cms/cms-article/page', params); - } - - /** - * 获取推荐文章列表 - */ - static async getRecommendArticles(limit = 6): Promise> { - return request.get('/cms/cms-article/recommend', { limit }); - } - - /** - * 获取热门文章列表 - */ - static async getHotArticles(limit = 10): Promise> { - return request.get('/cms/cms-article/hot', { limit }); - } - - /** - * 获取最新文章列表 - */ - static async getLatestArticles(limit = 10): Promise> { - return request.get('/cms/cms-article', { limit }); - } - - /** - * 根据 ID 获取文章详情 - */ - static async getArticleById(id: number): Promise> { - return request.get
(`/cms/cms-article/${id}`); - } - - /** - * 根据分类获取文章列表 - */ - static async getArticlesByCategory( - categoryId: number, - params?: Omit - ): Promise>> { - return request.get>('/cms/cms-article/page', { - ...params, - categoryId, - }); - } - - /** - * 根据标签获取文章列表 - */ - static async getArticlesByTag( - tag: string, - params?: Omit - ): Promise>> { - return request.get>('/cms/cms-article/page', { - ...params, - tags: [tag], - }); - } - - /** - * 搜索文章 - */ - static async searchArticles( - keyword: string, - params?: ArticleSearchParams - ): Promise>> { - return request.get>('/cms/cms-article/search', { - ...params, - keywords: keyword, - }); - } - - /** - * 获取相关文章 - */ - static async getRelatedArticles(id: number, limit = 5): Promise> { - return request.get(`/cms/cms-article/${id}/related`, { limit }); - } - - /** - * 增加文章浏览量 - */ - static async increaseViewCount(id: number): Promise> { - return request.post(`/cms/cms-article/${id}/view`); - } - - /** - * 点赞文章 - */ - static async likeArticle(id: number): Promise> { - return request.post(`/cms/cms-article/${id}/like`); - } - - /** - * 取消点赞文章 - */ - static async unlikeArticle(id: number): Promise> { - return request.delete(`/cms/cms-article/${id}/like`); - } - - /** - * 创建文章(管理员功能) - */ - static async createArticle(params: CreateArticleParams): Promise> { - return request.post('/cms/cms-article', params); - } - - /** - * 更新文章(管理员功能) - */ - static async updateArticle(params: UpdateArticleParams): Promise> { - return request.put('/cms/cms-article', params); - } - - /** - * 删除文章(管理员功能) - */ - static async deleteArticle(id: number): Promise> { - return request.delete(`/cms/cms-article/${id}`); - } - - /** - * 批量删除文章(管理员功能) - */ - static async batchDeleteArticles(ids: number[]): Promise> { - return request.post('/cms/cms-article/batch-delete', ids); - } - - /** - * 发布文章(管理员功能) - */ - static async publishArticle(id: number): Promise> { - return request.post(`/cms/cms-article/${id}/publish`); - } - - /** - * 取消发布文章(管理员功能) - */ - static async unpublishArticle(id: number): Promise> { - return request.post(`/cms/cms-article/${id}/unpublish`); - } -} - -/** - * 文章分类 API 类 - */ -export class ArticleCategoryApi { - /** - * 获取所有分类列表 - */ - static async getCategories(): Promise> { - return request.get('/cms/cms-article-category'); - } - - /** - * 获取分类树 - */ - static async getCategoryTree(): Promise> { - return request.get('/cms/cms-article-category/tree'); - } - - /** - * 根据 ID 获取分类详情 - */ - static async getCategoryById(id: number): Promise> { - return request.get(`/cms/cms-article-category/${id}`); - } - - /** - * 创建分类(管理员功能) - */ - static async createCategory(params: { - name: string; - slug?: string; - description?: string; - parentId?: number; - sortOrder?: number; - }): Promise> { - return request.post('/cms/cms-article-category', params); - } - - /** - * 更新分类(管理员功能) - */ - static async updateCategory(params: { - id: number; - name?: string; - slug?: string; - description?: string; - parentId?: number; - sortOrder?: number; - }): Promise> { - return request.put('/cms/cms-article-category', params); - } - - /** - * 删除分类(管理员功能) - */ - static async deleteCategory(id: number): Promise> { - return request.delete(`/cms/cms-article-category/${id}`); - } -} - -/** - * 文章标签 API 类 - */ -export class ArticleTagApi { - /** - * 获取所有标签列表 - */ - static async getTags(): Promise> { - return request.get('/cms/cms-article-tag'); - } - - /** - * 获取热门标签 - */ - static async getHotTags(limit = 20): Promise> { - return request.get('/cms/cms-article-tag/hot', { limit }); - } - - /** - * 根据 ID 获取标签详情 - */ - static async getTagById(id: number): Promise> { - return request.get(`/cms/cms-article-tag/${id}`); - } - - /** - * 搜索标签 - */ - static async searchTags(keyword: string): Promise> { - return request.get('/cms/cms-article-tag/search', { keyword }); - } -} - -// ==================== 便捷方法导出 ==================== - -export const { - getArticles, - getRecommendArticles, - getHotArticles, - getLatestArticles, - getArticleById, - getArticlesByCategory, - getArticlesByTag, - searchArticles, - getRelatedArticles, - increaseViewCount, - likeArticle, - unlikeArticle, - createArticle, - updateArticle, - deleteArticle, - batchDeleteArticles, - publishArticle, - unpublishArticle, -} = ArticleApi; - -export const { - getCategories, - getCategoryTree, - getCategoryById, - createCategory, - updateCategory, - deleteCategory, -} = ArticleCategoryApi; - -export const { - getTags, - getHotTags, - getTagById, - searchTags, -} = ArticleTagApi; - -// 默认导出 -export default ArticleApi; diff --git a/src/api/modules/auth.ts b/src/api/modules/auth.ts deleted file mode 100644 index d03faad..0000000 --- a/src/api/modules/auth.ts +++ /dev/null @@ -1,246 +0,0 @@ -/** - * 认证相关 API - 现代化封装示例 - */ - -import { request, type ApiResult, type PageResult } from '@/api'; - -// ==================== 类型定义 ==================== - -/** - * 登录参数 - */ -export interface LoginParams { - username: string; - password: string; - tenantId?: number; - remember?: boolean; - phone?: string; - code?: string; -} - -/** - * 登录结果 - */ -export interface LoginResult { - access_token: string; - refresh_token?: string; - user: User; - expiresIn?: number; -} - -/** - * 用户信息 - */ -export interface User { - userId: number; - username: string; - email?: string; - phone?: string; - avatar?: string; - nickname?: string; - realName?: string; - status: number; - tenantId: number; - companyId?: number; - merchantId?: number; - merchantName?: string; - roles?: Role[]; - permissions?: string[]; - createTime?: string; - updateTime?: string; -} - -/** - * 角色信息 - */ -export interface Role { - roleId: number; - roleName: string; - roleCode: string; - description?: string; - status: number; -} - -/** - * 验证码结果 - */ -export interface CaptchaResult { - base64: string; - text: string; -} - -// ==================== API 方法 ==================== - -/** - * 认证 API 类 - */ -export class AuthApi { - /** - * 用户登录 - */ - static async login(params: LoginParams): Promise> { - return request.post('/loginByUserId', params); - } - - /** - * 短信登录 - */ - static async loginBySms(params: LoginParams): Promise> { - return request.post('/loginBySms', params); - } - - /** - * 用户注册 - */ - static async register(params: Partial): Promise> { - return request.post('/register', params); - } - - /** - * 用户登出 - */ - static async logout(): Promise> { - return request.post('/logout'); - } - - /** - * 获取验证码 - */ - static async getCaptcha(): Promise> { - return request.get('/captcha'); - } - - /** - * 发送短信验证码 - */ - static async sendSmsCaptcha(params: { phone: string }): Promise> { - return request.post('/sendSmsCaptcha', params); - } - - /** - * 获取当前用户信息 - */ - static async getCurrentUser(): Promise> { - return request.get('/auth/user'); - } - - /** - * 更新用户信息 - */ - static async updateProfile(params: Partial): Promise> { - return request.put('/auth/user', params); - } - - /** - * 修改密码 - */ - static async changePassword(params: { - oldPassword: string; - newPassword: string; - confirmPassword: string; - }): Promise> { - return request.post('/auth/change-password', params); - } - - /** - * 忘记密码 - */ - static async forgotPassword(params: { email: string }): Promise> { - return request.post('/auth/forgot-password', params); - } - - /** - * 重置密码 - */ - static async resetPassword(params: { - token: string; - password: string; - confirmPassword: string; - }): Promise> { - return request.post('/auth/reset-password', params); - } - - /** - * 刷新 token - */ - static async refreshToken(refreshToken: string): Promise> { - return request.post('/auth/refresh', { refreshToken }); - } - - /** - * 获取用户菜单 - */ - static async getUserMenus(): Promise> { - return request.get('/auth/menus'); - } - - /** - * 获取用户权限 - */ - static async getUserPermissions(): Promise> { - return request.get('/auth/permissions'); - } - - /** - * 检查用户名是否可用 - */ - static async checkUsername(username: string): Promise> { - return request.get('/auth/check-username', { username }); - } - - /** - * 检查邮箱是否可用 - */ - static async checkEmail(email: string): Promise> { - return request.get('/auth/check-email', { email }); - } - - /** - * 检查手机号是否可用 - */ - static async checkPhone(phone: string): Promise> { - return request.get('/auth/check-phone', { phone }); - } -} - -/** - * 菜单信息 - */ -export interface Menu { - menuId: number; - menuName: string; - menuCode: string; - parentId?: number; - path?: string; - component?: string; - icon?: string; - sortNumber: number; - menuType: number; - status: number; - children?: Menu[]; -} - -// ==================== 便捷方法导出 ==================== - -export const { - login, - loginBySms, - register, - logout, - getCaptcha, - sendSmsCaptcha, - getCurrentUser, - updateProfile, - changePassword, - forgotPassword, - resetPassword, - refreshToken, - getUserMenus, - getUserPermissions, - checkUsername, - checkEmail, - checkPhone, -} = AuthApi; - -// 默认导出 -export default AuthApi; diff --git a/src/api/modules/user.ts b/src/api/modules/user.ts deleted file mode 100644 index 4f4f353..0000000 --- a/src/api/modules/user.ts +++ /dev/null @@ -1,284 +0,0 @@ -/** - * 用户管理相关 API - 现代化封装示例 - */ - -import { request, type ApiResult, type PageResult, type PageParam } from '@/api'; -import type { User } from './auth'; - -// ==================== 类型定义 ==================== - -/** - * 用户查询参数 - */ -export interface UserSearchParams extends PageParam { - username?: string; - email?: string; - phone?: string; - status?: number; - roleId?: number; - departmentId?: number; - createTimeStart?: string; - createTimeEnd?: string; -} - -/** - * 用户创建参数 - */ -export interface CreateUserParams { - username: string; - password: string; - email?: string; - phone?: string; - nickname?: string; - realName?: string; - avatar?: string; - status?: number; - roleIds?: number[]; - departmentId?: number; - remark?: string; -} - -/** - * 用户更新参数 - */ -export interface UpdateUserParams { - userId: number; - username?: string; - email?: string; - phone?: string; - nickname?: string; - realName?: string; - avatar?: string; - status?: number; - roleIds?: number[]; - departmentId?: number; - remark?: string; -} - -/** - * 用户统计信息 - */ -export interface UserStats { - total: number; - active: number; - inactive: number; - newToday: number; - newThisWeek: number; - newThisMonth: number; -} - -/** - * 用户余额信息 - */ -export interface UserBalance { - userId: number; - balance: number; - frozenBalance: number; - totalRecharge: number; - totalConsume: number; -} - -// ==================== API 方法 ==================== - -/** - * 用户管理 API 类 - */ -export class UserApi { - /** - * 分页查询用户列表 - */ - static async getUsers(params?: UserSearchParams): Promise>> { - return request.get>('/system/user/page', params); - } - - /** - * 获取所有用户列表(不分页) - */ - static async getAllUsers(params?: Omit): Promise> { - return request.get('/system/user', params); - } - - /** - * 根据 ID 获取用户详情 - */ - static async getUserById(userId: number): Promise> { - return request.get(`/system/user/${userId}`); - } - - /** - * 创建用户 - */ - static async createUser(params: CreateUserParams): Promise> { - return request.post('/system/user', params); - } - - /** - * 更新用户信息 - */ - static async updateUser(params: UpdateUserParams): Promise> { - return request.put('/system/user', params); - } - - /** - * 删除用户 - */ - static async deleteUser(userId: number): Promise> { - return request.delete(`/system/user/${userId}`); - } - - /** - * 批量删除用户 - */ - static async batchDeleteUsers(userIds: number[]): Promise> { - return request.delete('/system/user/batch', { data: userIds }); - } - - /** - * 更新用户状态 - */ - static async updateUserStatus(userId: number, status: number): Promise> { - return request.put('/system/user/status', { userId, status }); - } - - /** - * 重置用户密码 - */ - static async resetUserPassword(userId: number, password = '123456'): Promise> { - return request.put('/system/user/password', { userId, password }); - } - - /** - * 导入用户 - */ - static async importUsers(file: File): Promise> { - const formData = new FormData(); - formData.append('file', file); - return request.post('/system/user/import', formData); - } - - /** - * 导出用户 - */ - static async exportUsers(params?: UserSearchParams): Promise> { - return request.post<{ downloadUrl: string }>('/system/user/export', params); - } - - /** - * 检查用户是否存在 - */ - static async checkUserExists(field: string, value: string, userId?: number): Promise> { - return request.get('/system/user/existence', { field, value, id: userId }); - } - - /** - * 获取用户统计信息 - */ - static async getUserStats(): Promise> { - return request.get('/system/user/stats'); - } - - /** - * 统计用户余额 - */ - static async getUserBalance(params?: UserSearchParams): Promise> { - return request.get('/system/user/countUserBalance', params); - } - - /** - * 获取员工列表 - */ - static async getStaffs(params?: UserSearchParams): Promise> { - return request.get('/system/user/staffs', params); - } - - /** - * 获取管理员列表 - */ - static async getAdmins(params?: UserSearchParams): Promise> { - return request.get('/system/user/listAdminsByPhoneAll', params); - } - - /** - * 更新用户推荐状态 - */ - static async updateUserRecommend(params: { - userId: number; - isRecommend: boolean; - }): Promise> { - return request.put('/system/user/recommend', params); - } - - /** - * 获取用户登录日志 - */ - static async getUserLoginLogs(params: { - userId?: number; - page?: number; - limit?: number; - startTime?: string; - endTime?: string; - }): Promise>> { - return request.get('/system/user/login-logs', params); - } - - /** - * 获取用户操作日志 - */ - static async getUserOperationLogs(params: { - userId?: number; - page?: number; - limit?: number; - startTime?: string; - endTime?: string; - }): Promise>> { - return request.get('/system/user/operation-logs', params); - } -} - -// ==================== 便捷方法导出 ==================== - -export const { - getUsers, - getAllUsers, - getUserById, - createUser, - updateUser, - deleteUser, - batchDeleteUsers, - updateUserStatus, - resetUserPassword, - importUsers, - exportUsers, - checkUserExists, - getUserStats, - getUserBalance, - getStaffs, - getAdmins, - updateUserRecommend, - getUserLoginLogs, - getUserOperationLogs, -} = UserApi; - -// 默认导出 -export default UserApi; diff --git a/src/api/passport/login/index.ts b/src/api/passport/login/index.ts index e50c206..fae0b1d 100644 --- a/src/api/passport/login/index.ts +++ b/src/api/passport/login/index.ts @@ -18,10 +18,15 @@ export async function login(data: LoginParam) { SERVER_API_URL + '/loginByUserId', data ); - if (res.data.code === 0) { - setToken(res.data.data?.access_token, data.remember); - if (res.data.data?.user) { - const user = res.data.data?.user; + if (res.data.code === 0 && res.data.data) { + // 确保 access_token 存在且为字符串类型 + const loginResult = res.data.data as LoginResult; + if (loginResult.access_token) { + setToken(loginResult.access_token, data.remember); + } + + if (loginResult.user) { + const user = loginResult.user; localStorage.setItem('TenantId', String(user.tenantId)); localStorage.setItem('UserId', String(user.userId)); } @@ -49,10 +54,14 @@ export async function loginBySms(data: LoginParam) { SERVER_API_URL + '/loginBySms', data ); - if (res.data.code === 0) { - setToken(res.data.data?.access_token, data.remember); - if (res.data.data?.user) { - const user = res.data.data?.user; + if (res.data.code === 0 && res.data.data) { + const loginResult = res.data.data as LoginResult; + if (loginResult.access_token) { + setToken(loginResult.access_token, data.remember); + } + + if (loginResult.user) { + const user = loginResult.user; localStorage.setItem('TenantId', String(user.tenantId)); localStorage.setItem('Phone', String(user.phone)); localStorage.setItem('UserId', String(user.userId)); @@ -87,8 +96,11 @@ export async function remoteLogin(data: LoginParam) { 'https://open.gxwebsoft.com/api/login', data ); - if (res.data.code === 0) { - setToken(res.data.data?.access_token, data.remember); + if (res.data.code === 0 && res.data.data) { + const loginResult = res.data.data as LoginResult; + if (loginResult.access_token) { + setToken(loginResult.access_token, data.remember); + } return res.data.message; } return Promise.reject(new Error(res.data.message)); @@ -97,7 +109,7 @@ export async function remoteLogin(data: LoginParam) { /** * 获取企业微信登录链接 */ -export async function getWxWorkQrConnect(data) { +export async function getWxWorkQrConnect(data: unknown) { const res = await request.post>( SERVER_API_URL + '/wx-work', data diff --git a/src/api/system/company/index.ts b/src/api/system/company/index.ts index f1d021e..d6249a5 100644 --- a/src/api/system/company/index.ts +++ b/src/api/system/company/index.ts @@ -28,7 +28,6 @@ export async function getCompanyAll(companyId: number) { SERVER_API_URL + '/system/company/profileAll/' + companyId ); if (res.data.code === 0 && res.data) { - console.log(res.data); return res.data.data; } return Promise.reject(new Error(res.data.message)); diff --git a/src/app/api-example/page.tsx b/src/app/api-example/page.tsx deleted file mode 100644 index e0412d5..0000000 --- a/src/app/api-example/page.tsx +++ /dev/null @@ -1,288 +0,0 @@ -'use client'; - -import { useState } from 'react'; -import { AuthApi } from '@/api/modules/auth'; -import { UserApi } from '@/api/modules/user'; -import { request } from '@/api'; -import type { User, LoginResult } from '@/api/modules/auth'; - -export default function ApiExamplePage() { - const [loading, setLoading] = useState(false); - const [result, setResult] = useState(''); - const [users, setUsers] = useState([]); - const [loginResult, setLoginResult] = useState(null); - - // 测试登录 - const testLogin = async () => { - setLoading(true); - setResult(''); - try { - const response = await AuthApi.login({ - username: 'demo', - password: 'demo123', - }); - - setLoginResult(response.data || null); - setResult(`登录成功: ${JSON.stringify(response, null, 2)}`); - } catch (error: any) { - setResult(`登录失败: ${error.message}`); - } finally { - setLoading(false); - } - }; - - // 测试获取用户列表 - const testGetUsers = async () => { - setLoading(true); - setResult(''); - try { - const response = await UserApi.getUsers({ - page: 1, - limit: 10, - }); - - setUsers(response.data?.list || []); - setResult(`获取用户列表成功: ${JSON.stringify(response, null, 2)}`); - } catch (error: any) { - setResult(`获取用户列表失败: ${error.message}`); - } finally { - setLoading(false); - } - }; - - // 测试原始请求方法 - const testRawRequest = async () => { - setLoading(true); - setResult(''); - try { - const response = await request.get('/system/user/page', { - page: 1, - limit: 5, - }); - - setResult(`原始请求成功: ${JSON.stringify(response, null, 2)}`); - } catch (error: any) { - setResult(`原始请求失败: ${error.message}`); - } finally { - setLoading(false); - } - }; - - // 测试获取验证码 - const testGetCaptcha = async () => { - setLoading(true); - setResult(''); - try { - const response = await AuthApi.getCaptcha(); - setResult(`获取验证码成功: ${JSON.stringify(response, null, 2)}`); - } catch (error: any) { - setResult(`获取验证码失败: ${error.message}`); - } finally { - setLoading(false); - } - }; - - // 测试检查用户名 - const testCheckUsername = async () => { - setLoading(true); - setResult(''); - try { - const response = await AuthApi.checkUsername('admin'); - setResult(`检查用户名成功: ${JSON.stringify(response, null, 2)}`); - } catch (error: any) { - setResult(`检查用户名失败: ${error.message}`); - } finally { - setLoading(false); - } - }; - - return ( -
-

API 封装系统示例

- - {/* 功能按钮 */} -
- - - - - - - - - -
- - {/* 加载状态 */} - {loading && ( -
- 正在请求中... -
- )} - - {/* 登录结果显示 */} - {loginResult && ( -
-

登录信息:

-

用户名: {loginResult.user?.username}

-

用户ID: {loginResult.user?.userId}

-

Token: {loginResult.access_token?.substring(0, 50)}...

-
- )} - - {/* 用户列表显示 */} - {users.length > 0 && ( -
-

用户列表:

-
- {users.map((user) => ( -
-

ID: {user.userId}

-

用户名: {user.username}

-

邮箱: {user.email || '未设置'}

-

状态: {user.status === 1 ? '正常' : '禁用'}

-
- ))} -
-
- )} - - {/* 结果显示 */} - {result && ( -
-

请求结果:

-
{result}
-
- )} - - {/* API 使用说明 */} -
-

API 使用说明

- -
-
-

1. 现代化 API 模块

-
-{`import { AuthApi, UserApi } from '@/api/modules/auth';
-
-// 用户登录
-const result = await AuthApi.login({
-  username: 'admin',
-  password: '123456'
-});
-
-// 获取用户列表
-const users = await UserApi.getUsers({
-  page: 1,
-  limit: 10
-});`}
-            
-
- -
-

2. 原始请求方法

-
-{`import { request } from '@/api';
-
-// GET 请求
-const response = await request.get('/api/data', { page: 1 });
-
-// POST 请求
-const response = await request.post('/api/data', { name: 'test' });`}
-            
-
- -
-

3. 兼容现有代码

-
-{`import request from '@/utils/request';
-
-const res = await request.get('/api/data', { params: { page: 1 } });
-if (res.data.code === 0) {
-  console.log(res.data.data);
-}`}
-            
-
- -
-

4. Token 管理

-
-{`import { setToken, getToken, clearToken } from '@/api';
-
-// 设置 token
-setToken('your-access-token', true);
-
-// 获取 token
-const token = getToken();
-
-// 清除 token
-clearToken();`}
-            
-
-
-
- - {/* 特性说明 */} -
-

系统特性

-
-
-

✅ 已实现的特性

-
    -
  • • TypeScript 类型安全
  • -
  • • 自动 Token 管理
  • -
  • • 统一错误处理
  • -
  • • 请求/响应拦截
  • -
  • • 兼容现有代码
  • -
  • • Next.js SSR 支持
  • -
  • • 文件上传支持
  • -
  • • 自动认证失效处理
  • -
-
- -
-

🚀 API 端点

-
    -
  • • 认证相关: 登录、注册、登出
  • -
  • • 用户管理: CRUD、状态管理
  • -
  • • 文件上传: 图片、文档上传
  • -
  • • 系统管理: 配置、日志
  • -
  • • 内容管理: 文章、分类
  • -
  • • 权限管理: 角色、菜单
  • -
-
-
-
-
- ); -} diff --git a/src/app/articles/[id]/page.tsx b/src/app/articles/[id]/page.tsx deleted file mode 100644 index ac74cad..0000000 --- a/src/app/articles/[id]/page.tsx +++ /dev/null @@ -1,358 +0,0 @@ -'use client'; - -import { useState, useEffect } from 'react'; -import { useParams } from 'next/navigation'; -import Link from 'next/link'; -import Image from 'next/image'; -import { ArticleApi, type Article } from '@/api/modules/article'; - -const ArticleDetailPage = () => { - const params = useParams(); - const articleId = parseInt(params.id as string); - - const [article, setArticle] = useState
(null); - const [relatedArticles, setRelatedArticles] = useState([]); - const [loading, setLoading] = useState(true); - const [error, setError] = useState(null); - const [liked, setLiked] = useState(false); - - useEffect(() => { - if (articleId) { - fetchArticle(); - fetchRelatedArticles(); - } - }, [articleId]); - - const fetchArticle = async () => { - try { - setLoading(true); - setError(null); - - // 增加浏览量 - await ArticleApi.increaseViewCount(articleId); - - // 获取文章详情 - const response = await ArticleApi.getArticleById(articleId); - - if (response.code === 0 && response.data) { - setArticle(response.data); - } else { - setError(response.message || '文章不存在'); - } - } catch (error) { - console.error('获取文章失败:', error); - setError('网络错误,请稍后重试'); - - // 设置模拟文章数据 - setArticle({ - id: articleId, - title: '企业数字化转型的关键要素与实施策略', - content: ` -

引言

-

在当今快速发展的数字化时代,企业数字化转型已经不再是一个选择题,而是一个必答题。随着云计算、大数据、人工智能、物联网等新兴技术的快速发展,传统企业面临着前所未有的挑战和机遇。

- -

数字化转型的核心要素

-

1. 战略规划

-

数字化转型首先需要明确的战略规划。企业需要从顶层设计出发,制定符合自身发展阶段和行业特点的数字化转型战略。这包括:

-
    -
  • 明确转型目标和愿景
  • -
  • 制定分阶段实施计划
  • -
  • 建立评估和监控机制
  • -
  • 确保资源投入和组织保障
  • -
- -

2. 技术基础设施

-

强大的技术基础设施是数字化转型的基石。企业需要构建灵活、可扩展、安全的IT架构,包括:

-
    -
  • 云计算平台建设
  • -
  • 数据中心现代化
  • -
  • 网络安全体系完善
  • -
  • 移动办公环境搭建
  • -
- -

3. 数据治理

-

数据是数字化转型的核心资产。企业需要建立完善的数据治理体系:

-
    -
  • 数据标准化和规范化
  • -
  • 数据质量管理
  • -
  • 数据安全和隐私保护
  • -
  • 数据分析和应用
  • -
- -

实施策略

-

分步骤实施

-

数字化转型是一个长期的过程,需要分步骤、有计划地推进。建议采用以下策略:

-
    -
  1. 评估现状:全面评估企业当前的数字化水平
  2. -
  3. 制定规划:基于评估结果制定详细的转型规划
  4. -
  5. 试点先行:选择关键业务领域进行试点
  6. -
  7. 逐步推广:在试点成功的基础上逐步推广
  8. -
  9. 持续优化:根据实施效果持续优化和改进
  10. -
- -

成功案例分析

-

许多企业在数字化转型方面取得了显著成效。例如,某制造企业通过实施智能制造系统,生产效率提升了30%,产品质量得到显著改善。某零售企业通过数字化营销平台,客户转化率提升了50%。

- -

结论

-

数字化转型是企业适应数字时代、保持竞争优势的必由之路。成功的数字化转型需要企业在战略、技术、人才、文化等多个维度进行系统性变革。只有坚持以客户为中心,以数据为驱动,以技术为支撑,企业才能在数字化转型的道路上取得成功。

- `, - excerpt: '在数字化时代,企业需要从战略、技术、人才等多个维度进行全面转型,以适应快速变化的市场环境。本文深入分析了企业数字化转型的关键要素和实施策略。', - thumbnail: '/article-detail.jpg', - author: '张三', - authorId: 1, - categoryId: 1, - categoryName: '行业洞察', - tags: ['数字化转型', '企业管理', '技术创新'], - status: 'published', - viewCount: 1250, - likeCount: 89, - commentCount: 23, - isTop: false, - isRecommend: true, - publishTime: '2024-01-15T10:30:00Z', - createTime: '2024-01-15T10:30:00Z', - updateTime: '2024-01-15T10:30:00Z', - seoTitle: '企业数字化转型的关键要素与实施策略 - 专业指南', - seoKeywords: '数字化转型,企业管理,技术创新,战略规划', - seoDescription: '深入解析企业数字化转型的核心要素,提供实用的实施策略和成功案例分析,助力企业在数字时代取得成功。' - }); - } finally { - setLoading(false); - } - }; - - const fetchRelatedArticles = async () => { - try { - const response = await ArticleApi.getRelatedArticles(articleId, 4); - if (response.code === 0 && response.data) { - setRelatedArticles(response.data); - } - } catch (error) { - console.error('获取相关文章失败:', error); - // 设置模拟相关文章数据 - setRelatedArticles([]); - } - }; - - const handleLike = async () => { - try { - if (liked) { - await ArticleApi.unlikeArticle(articleId); - setLiked(false); - if (article) { - setArticle({ ...article, likeCount: article.likeCount - 1 }); - } - } else { - await ArticleApi.likeArticle(articleId); - setLiked(true); - if (article) { - setArticle({ ...article, likeCount: article.likeCount + 1 }); - } - } - } catch (error) { - console.error('点赞操作失败:', error); - } - }; - - const formatDate = (dateString: string) => { - const date = new Date(dateString); - return date.toLocaleDateString('zh-CN', { - year: 'numeric', - month: 'long', - day: 'numeric', - hour: '2-digit', - minute: '2-digit' - }); - }; - - const formatNumber = (num: number) => { - if (num >= 1000) { - return (num / 1000).toFixed(1) + 'k'; - } - return num.toString(); - }; - - if (loading) { - return ( -
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- ); - } - - if (error || !article) { - return ( -
-
-
404
-

文章不存在

-

{error || '您访问的文章可能已被删除或不存在'}

- - 返回文章列表 - -
-
- ); - } - - return ( -
- {/* 面包屑导航 */} -
-
- -
-
- -
-
- {/* 文章头部 */} -
- {/* 分类标签 */} - {article.categoryName && ( -
- - {article.categoryName} - -
- )} - - {/* 文章标题 */} -

- {article.title} -

- - {/* 文章元信息 */} -
-
- - - - - {article.author} - - - - - - {formatDate(article.createTime)} - -
- -
- - - - - - {formatNumber(article.viewCount)} - - -
-
- - {/* 文章摘要 */} - {article.excerpt && ( -
-

{article.excerpt}

-
- )} - - {/* 标签 */} - {article.tags && article.tags.length > 0 && ( -
- {article.tags.map((tag, index) => ( - - #{tag} - - ))} -
- )} -
- - {/* 文章内容 */} -
-
-
- - {/* 相关文章 */} - {relatedArticles.length > 0 && ( -
-

相关文章

-
- {relatedArticles.map((relatedArticle) => ( - - {relatedArticle.title} { - const target = e.target as HTMLImageElement; - target.src = 'data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTIwIiBoZWlnaHQ9IjgwIiB2aWV3Qm94PSIwIDAgMTIwIDgwIiBmaWxsPSJub25lIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPgo8cmVjdCB3aWR0aD0iMTIwIiBoZWlnaHQ9IjgwIiBmaWxsPSIjRjNGNEY2Ii8+CjxwYXRoIGQ9Ik01MCAzMEg3MFY1MEg1MFYzMFoiIGZpbGw9IiM5Q0EzQUYiLz4KPHA+CjxwYXRoIGQ9Ik00MCA0MEg4MFY0MEg0MFoiIGZpbGw9IiM5Q0EzQUYiLz4KPC9zdmc+Cg=='; - }} - /> -
-

- {relatedArticle.title} -

-

- {relatedArticle.excerpt} -

-
- {relatedArticle.categoryName} - {formatDate(relatedArticle.createTime)} -
-
- - ))} -
-
- )} -
-
-
- ); -}; - -export default ArticleDetailPage; diff --git a/src/app/articles/page.tsx b/src/app/articles/page.tsx deleted file mode 100644 index f648760..0000000 --- a/src/app/articles/page.tsx +++ /dev/null @@ -1,380 +0,0 @@ -'use client'; - -import { useState, useEffect } from 'react'; -import Link from 'next/link'; -import Image from 'next/image'; -import { ArticleApi, ArticleCategoryApi, type Article, type ArticleCategory } from '@/api/modules/article'; - -const ArticlesPage = () => { - const [articles, setArticles] = useState([]); - const [categories, setCategories] = useState([]); - const [loading, setLoading] = useState(true); - const [error, setError] = useState(null); - const [currentPage, setCurrentPage] = useState(1); - const [totalPages, setTotalPages] = useState(1); - const [selectedCategory, setSelectedCategory] = useState(null); - const [searchKeyword, setSearchKeyword] = useState(''); - - const pageSize = 12; - - useEffect(() => { - fetchCategories(); - }, []); - - useEffect(() => { - fetchArticles(); - }, [currentPage, selectedCategory, searchKeyword]); - - const fetchCategories = async () => { - try { - const response = await ArticleCategoryApi.getCategories(); - if (response.code === 0 && response.data) { - setCategories(response.data); - } - } catch (error) { - console.error('获取分类失败:', error); - // 设置模拟分类数据 - setCategories([ - { id: 1, name: '行业洞察', slug: 'industry', description: '', parentId: 0, sortOrder: 1, articleCount: 15, status: 1, createTime: '2024-01-01T00:00:00Z' }, - { id: 2, name: '技术分享', slug: 'tech', description: '', parentId: 0, sortOrder: 2, articleCount: 23, status: 1, createTime: '2024-01-01T00:00:00Z' }, - { id: 3, name: '前沿科技', slug: 'innovation', description: '', parentId: 0, sortOrder: 3, articleCount: 18, status: 1, createTime: '2024-01-01T00:00:00Z' }, - { id: 4, name: '企业动态', slug: 'news', description: '', parentId: 0, sortOrder: 4, articleCount: 12, status: 1, createTime: '2024-01-01T00:00:00Z' }, - ]); - } - }; - - const fetchArticles = async () => { - try { - setLoading(true); - setError(null); - - let response; - if (searchKeyword) { - response = await ArticleApi.searchArticles(searchKeyword, { - page: currentPage, - limit: pageSize, - categoryId: selectedCategory || undefined, - status: 'published', - }); - } else { - response = await ArticleApi.getArticles(); - } - - if (response.code === 0 && response.data) { - setArticles(response.data.list); - setTotalPages(Math.ceil(response.data.count / pageSize)); - } else { - setError(response.message || '获取文章失败'); - } - } catch (error) { - console.error('获取文章失败:', error); - setError('网络错误,请稍后重试'); - - // 设置模拟文章数据 - const mockArticles: Article[] = Array.from({ length: pageSize }, (_, index) => ({ - id: (currentPage - 1) * pageSize + index + 1, - title: `文章标题 ${(currentPage - 1) * pageSize + index + 1}`, - content: '这是文章的详细内容...', - excerpt: '这是文章的摘要内容,介绍了文章的主要观点和核心内容...', - thumbnail: `/article-${(index % 3) + 1}.jpg`, - author: ['张三', '李四', '王五'][index % 3], - authorId: (index % 3) + 1, - categoryId: selectedCategory || ((index % 4) + 1), - categoryName: categories.find(c => c.id === (selectedCategory || ((index % 4) + 1)))?.name || '默认分类', - tags: ['标签1', '标签2'], - status: 'published', - viewCount: Math.floor(Math.random() * 2000) + 100, - likeCount: Math.floor(Math.random() * 200) + 10, - commentCount: Math.floor(Math.random() * 50) + 1, - isTop: index === 0, - isRecommend: index < 3, - createTime: new Date(Date.now() - Math.random() * 30 * 24 * 60 * 60 * 1000).toISOString(), - updateTime: new Date().toISOString(), - })); - - setArticles(mockArticles); - setTotalPages(5); // 模拟总页数 - } finally { - setLoading(false); - } - }; - - const handleSearch = (e: React.FormEvent) => { - e.preventDefault(); - setCurrentPage(1); - fetchArticles(); - }; - - const handleCategoryChange = (categoryId: number | null) => { - setSelectedCategory(categoryId); - setCurrentPage(1); - }; - - const formatDate = (dateString: string) => { - const date = new Date(dateString); - return date.toLocaleDateString('zh-CN', { - year: 'numeric', - month: 'long', - day: 'numeric' - }); - }; - - const formatNumber = (num: number) => { - if (num >= 1000) { - return (num / 1000).toFixed(1) + 'k'; - } - return num.toString(); - }; - - return ( -
- {/* 页面头部 */} -
-
-
-

新闻资讯

-

- 了解行业动态,掌握前沿技术,获取专业见解 -

-
-
-
- -
-
- {/* 侧边栏 */} -
- {/* 搜索框 */} -
-

搜索文章

-
-
- setSearchKeyword(e.target.value)} - placeholder="输入关键词..." - className="flex-1 px-4 py-2 border border-gray-300 rounded-l-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent" - /> - -
-
-
- - {/* 分类筛选 */} -
-

文章分类

-
    -
  • - -
  • - {categories.map((category) => ( -
  • - -
  • - ))} -
-
-
- - {/* 主内容区 */} -
- {/* 筛选信息 */} -
-
- {selectedCategory && ( - - 分类: - {categories.find(c => c.id === selectedCategory)?.name} - - - )} - {searchKeyword && ( - - 搜索:"{searchKeyword}" - - )} -
-
- 共 {articles.length} 篇文章 -
-
- - {/* 错误提示 */} - {error && ( -
-

{error}

-

以下为示例内容

-
- )} - - {/* 文章列表 */} - {loading ? ( -
- {[1, 2, 3, 4, 5, 6].map((i) => ( -
-
-
-
-
-
-
-
-
- ))} -
- ) : ( - <> -
- {articles.map((article, index) => ( -
- {/* 文章图片 */} -
- {article.title} { - const target = e.target as HTMLImageElement; - target.src = 'data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNDAwIiBoZWlnaHQ9IjIwMCIgdmlld0JveD0iMCAwIDQwMCAyMDAiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CjxyZWN0IHdpZHRoPSI0MDAiIGhlaWdodD0iMjAwIiBmaWxsPSIjRjNGNEY2Ii8+CjxwYXRoIGQ9Ik0xNzUgNzVIMjI1VjEyNUgxNzVWNzVaIiBmaWxsPSIjOUNBM0FGIi8+CjxwYXRoIGQ9Ik0xNTAgMTAwSDI1MFYxMDBIMTUwWiIgZmlsbD0iIzlDQTNBRiIvPgo8L3N2Zz4K'; - }} - /> - - {/* 置顶标签 */} - {article.isTop && ( -
- 置顶 -
- )} - - {/* 推荐标签 */} - {article.isRecommend && ( -
- 推荐 -
- )} -
- - {/* 文章内容 */} -
- {/* 分类标签 */} - {article.categoryName && ( - - {article.categoryName} - - )} - - {/* 文章标题 */} -

- - {article.title} - -

- - {/* 文章摘要 */} -

- {article.excerpt || article.content?.substring(0, 100) + '...'} -

- - {/* 文章元信息 */} -
-
- - - - - - {formatNumber(article.viewCount)} - - - - - - {formatNumber(article.likeCount)} - -
- {formatDate(article.createTime)} -
-
-
- ))} -
- - {/* 分页 */} - {totalPages > 1 && ( -
- -
- )} - - )} -
-
-
-
- ); -}; - -export default ArticlesPage; diff --git a/src/app/globals.css b/src/app/globals.css index 4565f14..b419e55 100644 --- a/src/app/globals.css +++ b/src/app/globals.css @@ -1,6 +1,4 @@ -@tailwind base; -@tailwind components; -@tailwind utilities; +@import "tailwindcss"; /* 现代Web应用全局样式 */ :root { diff --git a/src/app/layout.tsx b/src/app/layout.tsx index a194e20..2cc53ce 100644 --- a/src/app/layout.tsx +++ b/src/app/layout.tsx @@ -22,10 +22,7 @@ export async function generateMetadata(): Promise { }; try { - console.log('Attempting to fetch site info for metadata...'); const siteInfo = await getSiteInfo(); - console.log('Site info fetched successfully:', siteInfo); - const title = siteInfo.websiteName || defaultMetadata.title as string; const description = siteInfo.comments || defaultMetadata.description as string; const keywords = siteInfo.keywords || defaultMetadata.keywords as string; diff --git a/src/app/page.tsx b/src/app/page.tsx index 98d1113..8d9bade 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -1,26 +1,27 @@ -import HeroSection from '@/components/sections/HeroSection'; -import FeaturesSection from '@/components/sections/FeaturesSection'; -import CasesSection from '@/components/sections/CasesSection'; -import PartnersSection from '@/components/sections/PartnersSection'; -import ContactSection from '@/components/sections/ContactSection'; +// import HeroSection from '@/components/sections/HeroSection'; +// import FeaturesSection from '@/components/sections/FeaturesSection'; +// import CasesSection from '@/components/sections/CasesSection'; +// import PartnersSection from '@/components/sections/PartnersSection'; +// import ContactSection from '@/components/sections/ContactSection'; export default function Home() { return (
+
Main
{/* 英雄区域 */} - + {/**/} {/* 产品服务 */} - + {/**/} {/* 客户案例 */} - + {/**/} {/* 合作伙伴 */} - + {/**/} {/* 联系我们 */} - + {/**/}
); } diff --git a/src/components/layout/Footer.tsx b/src/components/layout/Footer.tsx index 300fad0..89e8661 100644 --- a/src/components/layout/Footer.tsx +++ b/src/components/layout/Footer.tsx @@ -33,150 +33,7 @@ const Footer = () => { return (
-
-
- {/* 公司信息 */} -
-
-

WEBSOFT

-

- 专业的Web应用开发服务商,致力于为企业提供高质量的数字化解决方案。 - 我们拥有丰富的行业经验和专业的技术团队。 -

-
-
- - - - 福建省福州市鼓楼区软件园 -
-
- - - - 0591-88888888 -
-
- - - - - info@websoft.top -
-
-
-
- - {/* 产品链接 */} -
-

产品

-
    - {footerLinks.products.map((link) => ( -
  • - - {link.name} - -
  • - ))} -
-
- - {/* 解决方案链接 */} -
-

解决方案

-
    - {footerLinks.solutions.map((link) => ( -
  • - - {link.name} - -
  • - ))} -
-
- - {/* 技术支持链接 */} -
-

技术支持

-
    - {footerLinks.support.map((link) => ( -
  • - - {link.name} - -
  • - ))} -
-
- - {/* 公司链接和二维码 */} -
-

公司

-
    - {footerLinks.company.map((link) => ( -
  • - - {link.name} - -
  • - ))} -
- {/* 二维码 */} -
-
-
- - - -
-
-

微信公众号

-
-
-
- - {/* 底部版权信息 */} -
-
-
- © {currentYear} 企业官网. 保留所有权利. -
-
- - 隐私政策 - - - 服务条款 - - - 网站地图 - -
-
-
- - {/* 社交媒体链接 */} - -
+ Footer
); }; diff --git a/src/components/layout/Header.tsx b/src/components/layout/Header.tsx index e37f380..94850b7 100644 --- a/src/components/layout/Header.tsx +++ b/src/components/layout/Header.tsx @@ -29,7 +29,6 @@ const Header = () => { const reload = () => { getSiteInfo().then(data => { - console.log(data,'data') if(data){ setConfig(data); } @@ -41,123 +40,8 @@ const Header = () => { }, []); return ( -
-
-
- {/* Logo */} -
- - = {config?.websiteName} = - -
- - {/* Desktop Navigation */} - - - {/* Language Switch & CTA */} -
-
- 中文 - | - EN -
- - 免费咨询 - -
- - {/* Mobile menu button */} -
- -
-
- - {/* Mobile Navigation */} - {isMenuOpen && ( -
-
- {navigation.map((item) => ( - setIsMenuOpen(false)} - > - {item.name} - - ))} -
- setIsMenuOpen(false)} - > - 免费咨询 - -
-
-
- )} -
+
+ Top
); }; diff --git a/src/components/sections/PartnersSection.tsx b/src/components/sections/PartnersSection.tsx index 5e95819..c896b08 100644 --- a/src/components/sections/PartnersSection.tsx +++ b/src/components/sections/PartnersSection.tsx @@ -1,35 +1,35 @@ 'use client'; -import Image from 'next/image'; +// import Image from 'next/image'; const PartnersSection = () => { - const partners = [ - { - name: '阿里云', - logo: '/partners/aliyun.png', - description: '云计算服务合作伙伴' - }, - { - name: '腾讯云', - logo: '/partners/tencent.png', - description: '云服务技术合作' - }, - { - name: '华为', - logo: '/partners/huawei.png', - description: '企业级解决方案合作' - }, - { - name: '百度', - logo: '/partners/baidu.png', - description: 'AI技术合作伙伴' - }, - { - name: '字节跳动', - logo: '/partners/bytedance.png', - description: '前端技术合作' - } - ]; + // const partners = [ + // { + // name: '阿里云', + // logo: '/partners/aliyun.png', + // description: '云计算服务合作伙伴' + // }, + // { + // name: '腾讯云', + // logo: '/partners/tencent.png', + // description: '云服务技术合作' + // }, + // { + // name: '华为', + // logo: '/partners/huawei.png', + // description: '企业级解决方案合作' + // }, + // { + // name: '百度', + // logo: '/partners/baidu.png', + // description: 'AI技术合作伙伴' + // }, + // { + // name: '字节跳动', + // logo: '/partners/bytedance.png', + // description: '前端技术合作' + // } + // ]; return (
@@ -42,25 +42,25 @@ const PartnersSection = () => {
- {partners.map((partner, index) => ( -
-
- {partner.name} { - const target = e.target as HTMLImageElement; - target.src = 'data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iODAiIGhlaWdodD0iODAiIHZpZXdCb3g9IjAgMCA4MCA4MCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHJlY3Qgd2lkdGg9IjgwIiBoZWlnaHQ9IjgwIiBmaWxsPSIjRjNGNEY2Ii8+CjxwYXRoIGQ9Ik0zNSAzMEg0NVY1MEgzNVYzMFoiIGZpbGw9IiM5Q0EzQUYiLz4KPHBhdGggZD0iTTMwIDQwSDUwVjQwSDMwWiIgZmlsbD0iIzlDQTNBRiIvPgo8L3N2Zz4K'; - }} - /> -
-

{partner.name}

-

{partner.description}

-
- ))} + {/*{partners.map((partner, index) => (*/} + {/*
*/} + {/*
*/} + {/* {*/} + {/* const target = e.target as HTMLImageElement;*/} + {/* target.src = 'data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iODAiIGhlaWdodD0iODAiIHZpZXdCb3g9IjAgMCA4MCA4MCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHJlY3Qgd2lkdGg9IjgwIiBoZWlnaHQ9IjgwIiBmaWxsPSIjRjNGNEY2Ii8+CjxwYXRoIGQ9Ik0zNSAzMEg0NVY1MEgzNVYzMFoiIGZpbGw9IiM5Q0EzQUYiLz4KPHBhdGggZD0iTTMwIDQwSDUwVjQwSDMwWiIgZmlsbD0iIzlDQTNBRiIvPgo8L3N2Zz4K';*/} + {/* }}*/} + {/* />*/} + {/*
*/} + {/*

{partner.name}

*/} + {/*

{partner.description}

*/} + {/*
*/} + {/*))}*/}
{/* 合作统计 */} diff --git a/src/config/setting.ts b/src/config/setting.ts index 0d8c2e8..4ae77fd 100644 --- a/src/config/setting.ts +++ b/src/config/setting.ts @@ -20,6 +20,11 @@ export const MODULES_API_URL = 'https://cms-api.websoft.top/api'; */ export const UPLOAD_API_URL = 'https://cms-api.websoft.top/api/upload'; +/** + * 模板ID + */ +export const TEMPLATE_ID = '10258'; + // ==================== 环境配置 ==================== /** diff --git a/src/utils/request.ts b/src/utils/request.ts index fef1b86..5cc9187 100644 --- a/src/utils/request.ts +++ b/src/utils/request.ts @@ -33,8 +33,15 @@ const request = { /** * DELETE 请求 */ - delete: (url: string, config?: RequestConfig): Promise<{ data: ApiResult }> => { - return apiRequest.delete(url, config).then(data => ({ data })); + delete: (url: string, configOrData?: RequestConfig | { data?: unknown }): Promise<{ data: ApiResult }> => { + // 检查第二个参数是否包含 data 属性 + if (configOrData && 'data' in configOrData) { + const { data, ...config } = configOrData as { data?: unknown } & RequestConfig; + return apiRequest.delete(url, data, config).then(data => ({ data })); + } else { + // 兼容原有的只传 config 的方式 + return apiRequest.delete(url, undefined, configOrData as RequestConfig).then(data => ({ data })); + } }, /**