Bladeren bron

fix: 修复构建报错

周玉环 2 weken geleden
bovenliggende
commit
5298a0e6bd

+ 3 - 0
.env.development

@@ -8,3 +8,6 @@ VITE_APP_TITLE=Content Management System (Dev)
 
 # 是否启用 Mock 数据
 VITE_USE_MOCK=false
+
+# jeecg跳转路由
+VITE_JEECG_DOAMAIN=/admin

+ 4 - 2
src/components/SearchModal/index.tsx

@@ -1,4 +1,4 @@
-import { Modal, Badge } from "@contentful/f36-components";
+import { Modal } from "@contentful/f36-components";
 import { useState } from "react";
 import styles from "./index.module.css";
 
@@ -21,7 +21,9 @@ export default function SearchModal({ isOpen, onClose }: SearchModalProps) {
       onClose={handleClose}
       className={styles.modal}
     >
-      <div className={styles.search_wrap}></div>
+      <div className={styles.search_wrap}>
+        {searchQuery}
+      </div>
     </Modal>
   );
 }

+ 1 - 1
src/http/Axios.ts

@@ -7,7 +7,7 @@ import type { AxiosRequestConfig, AxiosInstance, AxiosResponse, AxiosError } fro
 import axios from "axios";
 import type { RequestOptions, Result } from "@/types/axios";
 import type { CreateAxiosOptions } from "./axiosTransform";
-import { AxiosTransform } from "./axiosTransform";
+// import { AxiosTransform } from "./axiosTransform";
 
 export class VAxios {
   private axiosInstance: AxiosInstance;

+ 1 - 1
src/http/helper.ts

@@ -2,7 +2,7 @@
  * 辅助函数
  */
 
-const DATE_TIME_FORMAT = "YYYY-MM-DD HH:mm:ss";
+// const DATE_TIME_FORMAT = "YYYY-MM-DD HH:mm:ss";
 
 export function joinTimestamp<T extends boolean>(join: boolean, restful: T): T extends true ? string : object;
 

+ 1 - 1
src/http/index.ts

@@ -155,7 +155,7 @@ const transform: AxiosTransform = {
   /**
    * 请求拦截器处理
    */
-  requestInterceptors: (config, options) => {
+  requestInterceptors: (config) => {
     const token = getToken();
     const tenantId = getTenantId();
 

+ 0 - 103
src/services/BaseService.ts

@@ -1,103 +0,0 @@
-/**
- * 基础服务类
- * 提供通用的 CRUD 操作,参考 JeecgBoot 的 CommonAPI
- */
-
-import { defHttp as http } from "@/http";
-
-export interface PageParams {
-  pageNo: number;
-  pageSize: number;
-  column?: string; // 排序字段
-  order?: "asc" | "desc"; // 排序方式
-  [key: string]: any; // 其他查询参数
-}
-
-export interface PageResult<T> {
-  records: T[];
-  total: number;
-  size: number;
-  current: number;
-  pages: number;
-}
-
-export class BaseService<T = any> {
-  protected baseUrl: string;
-
-  constructor(baseUrl: string) {
-    // 直接使用传入的路径,前缀由 http 工具自动添加
-    this.baseUrl = baseUrl;
-  }
-
-  /**
-   * 分页查询列表
-   */
-  list(params: Partial<PageParams>) {
-    return http.get<PageResult<T>>({ url: `${this.baseUrl}/list`, params });
-  }
-
-  /**
-   * 查询所有数据(不分页)
-   */
-  queryAll(params?: Record<string, any>) {
-    return http.get<T[]>({ url: `${this.baseUrl}/queryAll`, params });
-  }
-
-  /**
-   * 根据ID查询
-   */
-  getById(id: string) {
-    return http.get<T>({ url: `${this.baseUrl}/queryById`, params: { id } });
-  }
-
-  /**
-   * 新增
-   */
-  add(data: Partial<T>) {
-    return http.post({ url: `${this.baseUrl}/add`, data });
-  }
-
-  /**
-   * 编辑
-   */
-  edit(data: Partial<T>) {
-    return http.put({ url: `${this.baseUrl}/edit`, data });
-  }
-
-  /**
-   * 删除
-   */
-  delete(id: string) {
-    return http.delete({ url: `${this.baseUrl}/delete`, params: { id } });
-  }
-
-  /**
-   * 批量删除
-   */
-  deleteBatch(ids: string[]) {
-    return http.delete({ url: `${this.baseUrl}/deleteBatch`, params: { ids: ids.join(",") } });
-  }
-
-  /**
-   * 导出Excel
-   */
-  exportXls(params?: Record<string, any>, filename = "导出数据.xls") {
-    return http.download(`${this.baseUrl}/exportXls`, filename, params);
-  }
-
-  /**
-   * 导入Excel
-   */
-  importExcel(file: File) {
-    const formData = new FormData();
-    formData.append("file", file);
-    return http.upload(`${this.baseUrl}/importExcel`, formData);
-  }
-}
-
-/**
- * 创建服务实例的工厂函数
- */
-export function createService<T = any>(baseUrl: string) {
-  return new BaseService<T>(baseUrl);
-}

+ 1 - 8
src/services/index.ts

@@ -3,7 +3,6 @@
  */
 
 export * from "./api";
-export * from "./BaseService";
 
 // 系统管理模块
 export {
@@ -12,10 +11,4 @@ export {
   dictApi,
   uploadApi,
   sysApi,
-} from "./modules/system";
-
-// 业务模块服务
-export { default as userService } from "./modules/user";
-
-// 导出类型
-export type { User } from "./modules/user";
+} from "./modules/system";

+ 0 - 78
src/services/modules/user.ts

@@ -1,78 +0,0 @@
-/**
- * 用户管理服务
- */
-
-import { BaseService } from "@/services/BaseService";
-import { defHttp as http } from "@/http";
-
-export interface User {
-  id: string;
-  username: string;
-  realname: string;
-  avatar?: string;
-  birthday?: string;
-  sex?: number;
-  email?: string;
-  phone?: string;
-  orgCode?: string;
-  status?: number;
-  delFlag?: number;
-  workNo?: string;
-  post?: string;
-  telephone?: string;
-  createBy?: string;
-  createTime?: string;
-  updateBy?: string;
-  updateTime?: string;
-}
-
-class UserService extends BaseService<User> {
-  constructor() {
-    super("/sys/user");
-  }
-
-  /**
-   * 冻结/解冻用户
-   */
-  frozenBatch(ids: string[], status: 1 | 2) {
-    return http.put({ url: "/sys/user/frozenBatch", data: { ids: ids.join(","), status } });
-  }
-
-  /**
-   * 修改密码
-   */
-  changePassword(userId: string, password: string) {
-    return http.put({ url: "/sys/user/changePassword", data: { userId, password } });
-  }
-
-  /**
-   * 查询用户角色
-   */
-  getUserRoles(userId: string) {
-    return http.get<string[]>({ url: "/sys/user/queryUserRole", params: { userid: userId } });
-  }
-
-  /**
-   * 根据部门查询用户
-   */
-  queryByDepId(depId: string) {
-    return http.get<User[]>({ url: "/sys/user/queryByDepId", params: { depId } });
-  }
-
-  /**
-   * 用户注册
-   */
-  register(data: Partial<User> & { password: string }) {
-    return http.post({ url: "/sys/user/register", data });
-  }
-
-  /**
-   * 校验用户是否存在
-   */
-  checkOnlyUser(username: string, id?: string) {
-    return http.get<boolean>({ url: "/sys/user/checkOnlyUser", params: { username, id } });
-  }
-}
-
-export const userService = new UserService();
-export default userService;

+ 76 - 78
src/utils/jeecgNavigation.ts

@@ -1,3 +1,7 @@
+// import { generatePersistentKey } from "@/config/project";
+
+// const PERSISTENT_KEY = generatePersistentKey();
+
 /**
  * JeecgBoot 页面跳转工具
  * 利用共享的 localStorage 实现免登录跳转
@@ -22,40 +26,40 @@ export interface JeecgPageConfig {
  */
 export const systemPages: JeecgPageConfig[] = [
   {
-    key: 'user',
-    title: '用户管理',
-    path: '/system/user',
-    description: '管理系统用户',
+    key: "user",
+    title: "用户管理",
+    path: "/system/user",
+    description: "管理系统用户",
   },
   {
-    key: 'role',
-    title: '角色管理',
-    path: '/system/role',
-    description: '管理用户角色和权限',
+    key: "role",
+    title: "角色管理",
+    path: "/system/role",
+    description: "管理用户角色和权限",
   },
   {
-    key: 'menu',
-    title: '菜单管理',
-    path: '/system/menu',
-    description: '管理系统菜单和权限',
+    key: "menu",
+    title: "菜单管理",
+    path: "/system/menu",
+    description: "管理系统菜单和权限",
   },
   {
-    key: 'depart',
-    title: '部门管理',
-    path: '/system/depart',
-    description: '管理组织架构',
+    key: "depart",
+    title: "部门管理",
+    path: "/system/depart",
+    description: "管理组织架构",
   },
   {
-    key: 'dict',
-    title: '字典管理',
-    path: '/system/dict',
-    description: '管理数据字典',
+    key: "dict",
+    title: "字典管理",
+    path: "/system/dict",
+    description: "管理数据字典",
   },
   {
-    key: 'log',
-    title: '日志管理',
-    path: '/system/log',
-    description: '查看系统日志',
+    key: "log",
+    title: "日志管理",
+    path: "/system/log",
+    description: "查看系统日志",
   },
 ];
 
@@ -64,45 +68,51 @@ export const systemPages: JeecgPageConfig[] = [
  * @param path JeecgBoot 页面路径
  * @param newTab 是否在新标签页打开
  */
-export function navigateToJeecg(path: string, newTab: boolean = false): void {
-  // 确保路径以 / 开头
-  const normalizedPath = path.startsWith('/') ? path : `/${path}`;
-  
-  // 生产环境:同域名,直接跳转
-  // 开发环境:不同端口,localStorage 不共享,需要通过 URL 参数传递 token
-  if (import.meta.env.PROD) {
-    // 生产环境:直接跳转
-    const url = normalizedPath;
-    if (newTab) {
-      window.open(url, '_blank');
-    } else {
-      window.location.href = url;
-    }
-  } else {
-    // 开发环境:通过 URL 参数传递认证信息
-    const token = localStorage.getItem('内容中心管理系统__PRODUCTION__1.0.0__COMMON__LOCAL__KEY__');
-    const url = `http://localhost:3100${normalizedPath}`;
-    
-    if (token) {
-      // 将 token 通过 URL 参数传递(仅用于开发环境测试)
-      const urlWithToken = `${url}?_dev_token=${encodeURIComponent(token)}`;
-      
-      if (newTab) {
-        window.open(urlWithToken, '_blank');
-      } else {
-        window.location.href = urlWithToken;
-      }
-      
-      console.warn('[Dev Only] Token passed via URL parameter for local testing');
-    } else {
-      // 没有 token,直接跳转
-      if (newTab) {
-        window.open(url, '_blank');
-      } else {
-        window.location.href = url;
-      }
-    }
-  }
+export function navigateToJeecg(path: string): void {
+  const jeecgDomain = import.meta.env.VITE_JEECG_DOAMAIN;
+  window.open(jeecgDomain.replace(/\/$/, "") + path, "_blank");
+  return;
+
+  // // 确保路径以 / 开头
+  // const normalizedPath = path.startsWith("/") ? path : `/${path}`;
+
+  // // 生产环境:同域名,直接跳转
+  // // 开发环境:不同端口,localStorage 不共享,需要通过 URL 参数传递 token
+  // if (import.meta.env.PROD) {
+  //   // 生产环境:直接跳转
+  //   const url = normalizedPath;
+  //   if (newTab) {
+  //     window.open(url, "_blank");
+  //   } else {
+  //     window.location.href = url;
+  //   }
+  // } else {
+  //   // 开发环境:通过 URL 参数传递认证信息
+  //   const token = localStorage.getItem(PERSISTENT_KEY);
+  //   const url = `http://localhost:3100${normalizedPath}`;
+
+  //   if (token) {
+  //     // 将 token 通过 URL 参数传递(仅用于开发环境测试)
+  //     const urlWithToken = `${url}?_dev_token=${encodeURIComponent(token)}`;
+
+  //     if (newTab) {
+  //       window.open(urlWithToken, "_blank");
+  //     } else {
+  //       window.location.href = urlWithToken;
+  //     }
+
+  //     console.warn(
+  //       "[Dev Only] Token passed via URL parameter for local testing"
+  //     );
+  //   } else {
+  //     // 没有 token,直接跳转
+  //     if (newTab) {
+  //       window.open(url, "_blank");
+  //     } else {
+  //       window.location.href = url;
+  //     }
+  //   }
+  // }
 }
 
 /**
@@ -110,23 +120,11 @@ export function navigateToJeecg(path: string, newTab: boolean = false): void {
  * @param key 页面标识
  * @param newTab 是否在新标签页打开
  */
-export function navigateToJeecgByKey(key: string, newTab: boolean = false): void {
-  const page = systemPages.find(p => p.key === key);
+export function navigateToJeecgByKey(key: string): void {
+  const page = systemPages.find((p) => p.key === key);
   if (page) {
-    navigateToJeecg(page.path, newTab);
+    navigateToJeecg(page.path);
   } else {
     console.error(`[JeecgNavigation] Page not found: ${key}`);
   }
 }
-
-/**
- * 获取 JeecgBoot 页面完整 URL
- * @param path JeecgBoot 页面路径
- */
-export function getJeecgUrl(path: string): string {
-  const normalizedPath = path.startsWith('/') ? path : `/${path}`;
-  
-  return import.meta.env.PROD 
-    ? `${window.location.origin}${normalizedPath}`
-    : `http://localhost:3100${normalizedPath}`;
-}