Parcourir la source

chore(core): 修改打包

wjx il y a 1 an
Parent
commit
8810a32ed0

+ 4 - 1
config/config.ts

@@ -8,6 +8,9 @@ import routes from './routes';
 const { REACT_APP_ENV = 'dev' } = process.env;
 
 export default defineConfig({
+  history: {
+    type: 'hash',
+  },
   /**
    * @name 开启 hash 模式
    * @description 让 build 之后的产物包含 hash 后缀。通常用于增量发布和避免浏览器加载缓存。
@@ -76,7 +79,7 @@ export default defineConfig({
    * @name layout 插件
    * @doc https://umijs.org/docs/max/layout-menu
    */
-  title: 'Ant Design Pro',
+  title: '趣程素材库',
   layout: {
     locale: true,
     ...defaultSettings,

+ 70 - 70
config/routes.ts

@@ -1,70 +1,70 @@
-/**
- * @name umi 的路由配置
- * @description 只支持 path,component,routes,redirect,wrappers,name,icon 的配置
- * @param path  path 只支持两种占位符配置,第一种是动态参数 :id 的形式,第二种是 * 通配符,通配符只能出现路由字符串的最后。
- * @param component 配置 location 和 path 匹配后用于渲染的 React 组件路径。可以是绝对路径,也可以是相对路径,如果是相对路径,会从 src/pages 开始找起。
- * @param routes 配置子路由,通常在需要为多个路径增加 layout 组件时使用。
- * @param redirect 配置路由跳转
- * @param wrappers 配置路由组件的包装组件,通过包装组件可以为当前的路由组件组合进更多的功能。 比如,可以用于路由级别的权限校验
- * @param name 配置路由的标题,默认读取国际化文件 menu.ts 中 menu.xxxx 的值,如配置 name 为 login,则读取 menu.ts 中 menu.login 的取值作为标题
- * @param icon 配置路由的图标,取值参考 https://ant.design/components/icon-cn, 注意去除风格后缀和大小写,如想要配置图标为 <StepBackwardOutlined /> 则取值应为 stepBackward 或 StepBackward,如想要配置图标为 <UserOutlined /> 则取值应为 user 或者 User
- * @doc https://umijs.org/docs/guides/routes
- */
-export default [
-  {
-    path: '/user',
-    layout: false,
-    routes: [
-      {
-        name: 'login',
-        path: '/user/login',
-        component: './User/Login',
-      },
-    ],
-  },
-  {
-    path: '/home',
-    name: 'home',
-    icon: 'home',
-    component: './Home',
-  },
-  {
-    path: '/task',
-    name: 'task',
-    icon: 'crown',
-    component: './Task',
-  },
-  {
-    path: '/myTask',
-    name: 'my-task',
-    icon: 'fileText',
-    component: './MyTask',
-  },
-  {
-    path: '/opus',
-    name: 'opus',
-    icon: 'snippets',
-    component: './Opus',
-  },
-  {
-    path: '/income',
-    name: 'income',
-    icon: 'accountBook',
-    component: './Income',
-  },
-  {
-    path: '/download',
-    name: 'download',
-    icon: 'download',
-    component: './Download',
-  },
-  {
-    path: '/',
-    redirect: '/Home',
-  },
-  {
-    path: '*',
-    layout: false,
-    component: './404',
-  },
-];
+/**
+ * @name umi 的路由配置
+ * @description 只支持 path,component,routes,redirect,wrappers,name,icon 的配置
+ * @param path  path 只支持两种占位符配置,第一种是动态参数 :id 的形式,第二种是 * 通配符,通配符只能出现路由字符串的最后。
+ * @param component 配置 location 和 path 匹配后用于渲染的 React 组件路径。可以是绝对路径,也可以是相对路径,如果是相对路径,会从 src/pages 开始找起。
+ * @param routes 配置子路由,通常在需要为多个路径增加 layout 组件时使用。
+ * @param redirect 配置路由跳转
+ * @param wrappers 配置路由组件的包装组件,通过包装组件可以为当前的路由组件组合进更多的功能。 比如,可以用于路由级别的权限校验
+ * @param name 配置路由的标题,默认读取国际化文件 menu.ts 中 menu.xxxx 的值,如配置 name 为 login,则读取 menu.ts 中 menu.login 的取值作为标题
+ * @param icon 配置路由的图标,取值参考 https://ant.design/components/icon-cn, 注意去除风格后缀和大小写,如想要配置图标为 <StepBackwardOutlined /> 则取值应为 stepBackward 或 StepBackward,如想要配置图标为 <UserOutlined /> 则取值应为 user 或者 User
+ * @doc https://umijs.org/docs/guides/routes
+ */
+export default [
+  {
+    path: '/user',
+    layout: false,
+    routes: [
+      {
+        name: 'login',
+        path: '/user/login',
+        component: './User/Login',
+      },
+    ],
+  },
+  // {
+  //   path: '/home',
+  //   name: 'home',
+  //   icon: 'home',
+  //   component: './Home',
+  // },
+  {
+    path: '/task',
+    name: 'task',
+    icon: 'crown',
+    component: './Task',
+  },
+  {
+    path: '/myTask',
+    name: 'my-task',
+    icon: 'fileText',
+    component: './MyTask',
+  },
+  {
+    path: '/opus',
+    name: 'opus',
+    icon: 'snippets',
+    component: './Opus',
+  },
+  {
+    path: '/income',
+    name: 'income',
+    icon: 'accountBook',
+    component: './Income',
+  },
+  {
+    path: '/download',
+    name: 'download',
+    icon: 'download',
+    component: './Download',
+  },
+  {
+    path: '/',
+    redirect: '/Task',
+  },
+  {
+    path: '*',
+    layout: false,
+    component: './404',
+  },
+];

+ 103 - 101
package.json

@@ -1,101 +1,103 @@
-{
-  "name": "qc-sourcematerial",
-  "version": "6.0.0",
-  "private": true,
-  "description": "An out-of-box UI solution for enterprise applications",
-  "scripts": {
-    "analyze": "cross-env ANALYZE=1 max build",
-    "build": "max build",
-    "deploy": "npm run build && npm run gh-pages",
-    "dev": "npm run start:dev",
-    "gh-pages": "gh-pages -d dist",
-    "i18n-remove": "pro i18n-remove --locale=zh-CN --write",
-    "postinstall": "max setup",
-    "jest": "jest",
-    "lint": "npm run lint:js && npm run lint:prettier && npm run tsc",
-    "lint-staged": "lint-staged",
-    "lint-staged:js": "eslint --ext .js,.jsx,.ts,.tsx ",
-    "lint:fix": "eslint --fix --cache --ext .js,.jsx,.ts,.tsx --format=pretty ./src ",
-    "lint:js": "eslint --cache --ext .js,.jsx,.ts,.tsx --format=pretty ./src",
-    "lint:prettier": "prettier -c --write \"**/**.{js,jsx,tsx,ts,less,md,json}\" --end-of-line auto",
-    "openapi": "max openapi",
-    "prepare": "husky install",
-    "prettier": "prettier -c --write \"**/**.{js,jsx,tsx,ts,less,md,json}\"",
-    "preview": "npm run build && max preview --port 8000",
-    "record": "cross-env NODE_ENV=development REACT_APP_ENV=test max record --scene=login",
-    "serve": "umi-serve",
-    "start": "cross-env UMI_ENV=dev max dev",
-    "start:dev": "cross-env REACT_APP_ENV=dev MOCK=none UMI_ENV=dev max dev",
-    "start:no-mock": "cross-env MOCK=none UMI_ENV=dev max dev",
-    "start:pre": "cross-env REACT_APP_ENV=pre UMI_ENV=dev max dev",
-    "start:test": "cross-env REACT_APP_ENV=test MOCK=none UMI_ENV=dev max dev",
-    "test": "jest",
-    "test:coverage": "npm run jest -- --coverage",
-    "test:update": "npm run jest -- -u",
-    "tsc": "tsc --noEmit"
-  },
-  "lint-staged": {
-    "**/*.{js,jsx,ts,tsx}": "npm run lint-staged:js",
-    "**/*.{js,jsx,tsx,ts,less,md,json}": [
-      "prettier --write"
-    ]
-  },
-  "browserslist": [
-    "> 1%",
-    "last 2 versions",
-    "not ie <= 10"
-  ],
-  "dependencies": {
-    "@ant-design/icons": "^4.8.0",
-    "@ant-design/pro-components": "^2.6.31",
-    "@ant-design/use-emotion-css": "1.0.4",
-    "@types/spark-md5": "^3.0.3",
-    "@umijs/route-utils": "^2.2.2",
-    "ahooks": "^3.7.8",
-    "antd": "^5.2.2",
-    "classnames": "^2.3.2",
-    "lodash": "^4.17.21",
-    "moment": "^2.29.4",
-    "omit.js": "^2.0.2",
-    "rc-menu": "^9.8.2",
-    "rc-util": "^5.27.2",
-    "react": "^18.2.0",
-    "react-dev-inspector": "^1.8.4",
-    "react-dom": "^18.2.0",
-    "react-helmet-async": "^1.3.0",
-    "react-infinite-scroll-component": "^6.1.0",
-    "spark-md5": "^3.0.2"
-  },
-  "devDependencies": {
-    "@ant-design/pro-cli": "^2.1.5",
-    "@testing-library/react": "^13.4.0",
-    "@types/classnames": "^2.3.1",
-    "@types/express": "^4.17.17",
-    "@types/history": "^4.7.11",
-    "@types/jest": "^29.4.0",
-    "@types/lodash": "^4.14.191",
-    "@types/react": "^18.0.28",
-    "@types/react-dom": "^18.0.11",
-    "@types/react-helmet": "^6.1.6",
-    "@umijs/fabric": "^2.14.1",
-    "@umijs/lint": "^4.0.52",
-    "@umijs/max": "^4.0.52",
-    "cross-env": "^7.0.3",
-    "eslint": "^8.34.0",
-    "express": "^4.18.2",
-    "gh-pages": "^3.2.3",
-    "husky": "^7.0.4",
-    "jest": "^29.4.3",
-    "jest-environment-jsdom": "^29.4.3",
-    "lint-staged": "^10.5.4",
-    "mockjs": "^1.1.0",
-    "prettier": "^2.8.4",
-    "swagger-ui-dist": "^4.15.5",
-    "ts-node": "^10.9.1",
-    "typescript": "^4.9.5",
-    "umi-presets-pro": "^2.0.2"
-  },
-  "engines": {
-    "node": ">=12.0.0"
-  }
-}
+{
+  "name": "qc-sourcematerial",
+  "version": "6.0.0",
+  "private": true,
+  "description": "An out-of-box UI solution for enterprise applications",
+  "scripts": {
+    "analyze": "cross-env ANALYZE=1 max build",
+    "build": "max build",
+    "build:dev": "max build REACT_APP_ENV=dev",
+    "build:pre": "max build REACT_APP_ENV=pre",
+    "deploy": "npm run build && npm run gh-pages",
+    "dev": "npm run start:dev",
+    "gh-pages": "gh-pages -d dist",
+    "i18n-remove": "pro i18n-remove --locale=zh-CN --write",
+    "postinstall": "max setup",
+    "jest": "jest",
+    "lint": "npm run lint:js && npm run lint:prettier && npm run tsc",
+    "lint-staged": "lint-staged",
+    "lint-staged:js": "eslint --ext .js,.jsx,.ts,.tsx ",
+    "lint:fix": "eslint --fix --cache --ext .js,.jsx,.ts,.tsx --format=pretty ./src ",
+    "lint:js": "eslint --cache --ext .js,.jsx,.ts,.tsx --format=pretty ./src",
+    "lint:prettier": "prettier -c --write \"**/**.{js,jsx,tsx,ts,less,md,json}\" --end-of-line auto",
+    "openapi": "max openapi",
+    "prepare": "husky install",
+    "prettier": "prettier -c --write \"**/**.{js,jsx,tsx,ts,less,md,json}\"",
+    "preview": "npm run build && max preview --port 8000",
+    "record": "cross-env NODE_ENV=development REACT_APP_ENV=test max record --scene=login",
+    "serve": "umi-serve",
+    "start": "cross-env UMI_ENV=dev max dev",
+    "start:dev": "cross-env REACT_APP_ENV=dev MOCK=none UMI_ENV=dev max dev",
+    "start:no-mock": "cross-env MOCK=none UMI_ENV=dev max dev",
+    "start:pre": "cross-env REACT_APP_ENV=pre UMI_ENV=dev max dev",
+    "start:test": "cross-env REACT_APP_ENV=test MOCK=none UMI_ENV=dev max dev",
+    "test": "jest",
+    "test:coverage": "npm run jest -- --coverage",
+    "test:update": "npm run jest -- -u",
+    "tsc": "tsc --noEmit"
+  },
+  "lint-staged": {
+    "**/*.{js,jsx,ts,tsx}": "npm run lint-staged:js",
+    "**/*.{js,jsx,tsx,ts,less,md,json}": [
+      "prettier --write"
+    ]
+  },
+  "browserslist": [
+    "> 1%",
+    "last 2 versions",
+    "not ie <= 10"
+  ],
+  "dependencies": {
+    "@ant-design/icons": "^4.8.0",
+    "@ant-design/pro-components": "^2.6.31",
+    "@ant-design/use-emotion-css": "1.0.4",
+    "@types/spark-md5": "^3.0.3",
+    "@umijs/route-utils": "^2.2.2",
+    "ahooks": "^3.7.8",
+    "antd": "^5.2.2",
+    "classnames": "^2.3.2",
+    "lodash": "^4.17.21",
+    "moment": "^2.29.4",
+    "omit.js": "^2.0.2",
+    "rc-menu": "^9.8.2",
+    "rc-util": "^5.27.2",
+    "react": "^18.2.0",
+    "react-dev-inspector": "^1.8.4",
+    "react-dom": "^18.2.0",
+    "react-helmet-async": "^1.3.0",
+    "react-infinite-scroll-component": "^6.1.0",
+    "spark-md5": "^3.0.2"
+  },
+  "devDependencies": {
+    "@ant-design/pro-cli": "^2.1.5",
+    "@testing-library/react": "^13.4.0",
+    "@types/classnames": "^2.3.1",
+    "@types/express": "^4.17.17",
+    "@types/history": "^4.7.11",
+    "@types/jest": "^29.4.0",
+    "@types/lodash": "^4.14.191",
+    "@types/react": "^18.0.28",
+    "@types/react-dom": "^18.0.11",
+    "@types/react-helmet": "^6.1.6",
+    "@umijs/fabric": "^2.14.1",
+    "@umijs/lint": "^4.0.52",
+    "@umijs/max": "^4.0.52",
+    "cross-env": "^7.0.3",
+    "eslint": "^8.34.0",
+    "express": "^4.18.2",
+    "gh-pages": "^3.2.3",
+    "husky": "^7.0.4",
+    "jest": "^29.4.3",
+    "jest-environment-jsdom": "^29.4.3",
+    "lint-staged": "^10.5.4",
+    "mockjs": "^1.1.0",
+    "prettier": "^2.8.4",
+    "swagger-ui-dist": "^4.15.5",
+    "ts-node": "^10.9.1",
+    "typescript": "^4.9.5",
+    "umi-presets-pro": "^2.0.2"
+  },
+  "engines": {
+    "node": ">=12.0.0"
+  }
+}

+ 1 - 1
src/pages/Opus/opusRoll.tsx

@@ -135,7 +135,7 @@ const OpusRoll: React.FC<Props> = ({
                       <Button
                         type="link"
                         style={{ padding: 0 }}
-                        onClick={() => download(list.link, 1)}
+                        onClick={() => download(list.link, list.id)}
                       >
                         下载
                       </Button>

+ 142 - 141
src/requestErrorConfig.ts

@@ -1,141 +1,142 @@
-import type { RequestOptions } from '@@/plugin-request/request';
-import type { RequestConfig } from '@umijs/max';
-import { message, notification } from 'antd';
-import { history } from '@umijs/max';
-
-// 与后端约定的响应数据格式
-interface ResponseStructure {
-  success: boolean;
-  data: any;
-  code: number;
-  msg: string;
-  fail: boolean
-}
-
-const codeMessage: any = {
-  200: '服务器成功返回请求的数据。',
-  201: '新建或修改数据成功。',
-  202: '一个请求已经进入后台排队(异步任务)。',
-  204: '删除数据成功。',
-  400: '发出的请求有错误,服务器没有进行新建或修改数据的操作。',
-  401: '用户没有权限(令牌、用户名、密码错误)。',
-  403: '用户得到授权,但是访问是被禁止的。',
-  404: '发出的请求针对的是不存在的记录,服务器没有进行操作。',
-  405: '请求方法不被允许。',
-  406: '请求的格式不可得。',
-  410: '请求的资源被永久删除,且不会再得到的。',
-  422: '当创建一个对象时,发生一个验证错误。',
-  500: '服务器发生错误,请检查服务器。',
-  502: '网关错误。',
-  503: '服务不可用,服务器暂时过载或维护。',
-  504: '网关超时。',
-};
-
-/**
- * @name 错误处理
- * pro 自带的错误处理, 可以在这里做自己的改动
- * @doc https://umijs.org/docs/max/request#配置
- */
-export const errorConfig: RequestConfig = {
-  // 错误处理: umi@3 的错误处理方案。
-  errorConfig: {
-    // 错误抛出
-    // errorThrower: (res) => {
-    //   const { success, data, code, msg, fail } = res as unknown as ResponseStructure;
-    //   if (!success) {
-    //     let error: any = new Error(msg);
-    //     error.name = 'BizError';
-    //     error.info = { code, msg, fail, data };
-    //     throw error; // 抛出自制的错误
-    //   }
-    // },
-    // // 错误接收及处理
-    errorHandler: (error: any, opts: any) => {
-      const { response } = error;
-      if (response && response.status) {
-        const errorText = codeMessage[(response as any).status] || response.statusText;
-        const { status, path } = response;
-        notification.error({
-          message: `请求错误 ${status}: ${path}`,
-          description: errorText,
-        });
-      }
-
-      if (!response) {
-        notification.error({
-          description: '您的网络发生异常,无法连接服务器',
-          message: '网络异常',
-        });
-      }
-      throw error;
-    },
-  },
-
-  // 请求拦截器
-  requestInterceptors: [
-    (config: RequestOptions) => {
-      // 拦截请求配置,进行个性化处理。
-      const url = config?.url;
-      if (config?.headers) {
-        config.headers['token'] = localStorage.getItem('Admin-Token') || ''
-      }
-      return { ...config, url };
-    },
-  ],
-
-  // 响应拦截器
-  responseInterceptors: [
-    (response) => {
-      // 拦截响应数据,进行个性化处理
-      const { data } = response as unknown as ResponseStructure;
-      if (data?.success === false) {
-        let msg: any
-        switch (data?.code) {
-          case 500:
-            msg = sessionStorage.getItem('msg')
-            if (data.msg === '令牌验证失败') {//
-              localStorage.removeItem('Admin-Token')
-              if (!msg) {
-                sessionStorage.setItem('msg', 'true')
-                message.error({
-                  content: data?.msg,
-                  onClose: () => {
-                    localStorage.removeItem('Admin-Token')
-                    history.push('/user/login')
-                    sessionStorage.removeItem('msg')
-                  }
-                });
-              }
-            }
-            if (!msg) {
-              sessionStorage.setItem('msg', 'true')
-              message.error({
-                content: data.msg,
-                onClose: () => {
-                  sessionStorage.removeItem('msg')
-                }
-              });
-            }
-            break
-          case 310:
-            msg = sessionStorage.getItem('msg')
-            localStorage.removeItem('Admin-Token')
-            history.push('/user/login')
-            if (!msg) {
-              sessionStorage.setItem('msg', 'true')
-              notification.error({
-                message: data?.msg,
-                onClose: () => {
-                  sessionStorage.removeItem('msg')
-                }
-              });
-            }
-            break
-          default:
-            message.error(data?.msg || '请求失败!');
-        }
-      }
-      return response;
-    },
-  ],
-};
+import type { RequestOptions } from '@@/plugin-request/request';
+import type { RequestConfig } from '@umijs/max';
+import { history } from '@umijs/max';
+import { message, notification } from 'antd';
+
+// 与后端约定的响应数据格式
+interface ResponseStructure {
+  success: boolean;
+  data: any;
+  code: number;
+  msg: string;
+  fail: boolean;
+}
+
+const codeMessage: any = {
+  200: '服务器成功返回请求的数据。',
+  201: '新建或修改数据成功。',
+  202: '一个请求已经进入后台排队(异步任务)。',
+  204: '删除数据成功。',
+  400: '发出的请求有错误,服务器没有进行新建或修改数据的操作。',
+  401: '用户没有权限(令牌、用户名、密码错误)。',
+  403: '用户得到授权,但是访问是被禁止的。',
+  404: '发出的请求针对的是不存在的记录,服务器没有进行操作。',
+  405: '请求方法不被允许。',
+  406: '请求的格式不可得。',
+  410: '请求的资源被永久删除,且不会再得到的。',
+  422: '当创建一个对象时,发生一个验证错误。',
+  500: '服务器发生错误,请检查服务器。',
+  502: '网关错误。',
+  503: '服务不可用,服务器暂时过载或维护。',
+  504: '网关超时。',
+};
+
+/**
+ * @name 错误处理
+ * pro 自带的错误处理, 可以在这里做自己的改动
+ * @doc https://umijs.org/docs/max/request#配置
+ */
+export const errorConfig: RequestConfig = {
+  // 错误处理: umi@3 的错误处理方案。
+  errorConfig: {
+    // 错误抛出
+    // errorThrower: (res) => {
+    //   const { success, data, code, msg, fail } = res as unknown as ResponseStructure;
+    //   if (!success) {
+    //     let error: any = new Error(msg);
+    //     error.name = 'BizError';
+    //     error.info = { code, msg, fail, data };
+    //     throw error; // 抛出自制的错误
+    //   }
+    // },
+    // // 错误接收及处理
+    errorHandler: (error: any, opts: any) => {
+      const { response } = error;
+      if (response && response.status) {
+        const errorText = codeMessage[(response as any).status] || response.statusText;
+        const { status, path } = response;
+        notification.error({
+          message: `请求错误 ${status}: ${path}`,
+          description: errorText,
+        });
+      }
+
+      if (!response) {
+        notification.error({
+          description: '您的网络发生异常,无法连接服务器',
+          message: '网络异常',
+        });
+      }
+      throw error;
+    },
+  },
+
+  // 请求拦截器
+  requestInterceptors: [
+    (config: RequestOptions) => {
+      // 拦截请求配置,进行个性化处理。
+      const url = config?.url;
+      if (config?.headers) {
+        config.headers['token'] = localStorage.getItem('Admin-Token') || '';
+      }
+      return { ...config, url };
+    },
+  ],
+
+  // 响应拦截器
+  responseInterceptors: [
+    (response) => {
+      // 拦截响应数据,进行个性化处理
+      const { data } = response as unknown as ResponseStructure;
+      if (data?.success === false) {
+        let msg: any;
+        switch (data?.code) {
+          case 500:
+            msg = sessionStorage.getItem('msg');
+            if (data.msg === '登录信息已失效, 请重新登录') {
+              //
+              localStorage.removeItem('Admin-Token');
+              if (!msg) {
+                sessionStorage.setItem('msg', 'true');
+                message.error({
+                  content: data?.msg,
+                  onClose: () => {
+                    localStorage.removeItem('Admin-Token');
+                    history.push('/user/login');
+                    sessionStorage.removeItem('msg');
+                  },
+                });
+              }
+            }
+            if (!msg) {
+              sessionStorage.setItem('msg', 'true');
+              message.error({
+                content: data.msg,
+                onClose: () => {
+                  sessionStorage.removeItem('msg');
+                },
+              });
+            }
+            break;
+          case 310:
+            msg = sessionStorage.getItem('msg');
+            localStorage.removeItem('Admin-Token');
+            history.push('/user/login');
+            if (!msg) {
+              sessionStorage.setItem('msg', 'true');
+              notification.error({
+                message: data?.msg,
+                onClose: () => {
+                  sessionStorage.removeItem('msg');
+                },
+              });
+            }
+            break;
+          default:
+            message.error(data?.msg || '请求失败!');
+        }
+      }
+      return response;
+    },
+  ],
+};

+ 15 - 12
src/services/ant-design-pro/api.ts

@@ -1,10 +1,11 @@
 // @ts-ignore
 /* eslint-disable */
 import { request } from '@umijs/max';
+import config from '../config';
 
 /** 获取当前的用户 GET /api/currentUser */
 export async function currentUser(options?: { [key: string]: any }) {
-  return request<{ data: API.CurrentUser; }>('/api/login/user', {
+  return request<{ data: API.CurrentUser }>(config.API_BASE_URL + '/api/login/user', {
     method: 'GET',
     ...(options || {}),
   });
@@ -12,7 +13,7 @@ export async function currentUser(options?: { [key: string]: any }) {
 
 /** 退出登录接口 POST /api/login/outLogin */
 export async function outLogin(options?: { [key: string]: any }) {
-  return request<Record<string, any>>('/api/login/outLogin', {
+  return request<Record<string, any>>(config.API_BASE_URL + '/api/login/outLogin', {
     method: 'POST',
     ...(options || {}),
   });
@@ -20,7 +21,7 @@ export async function outLogin(options?: { [key: string]: any }) {
 
 /** 登录接口 POST /api/login/account */
 export async function login(body: API.LoginParams, options?: { [key: string]: any }) {
-  return request<API.Result>('/api/login/mobile', {
+  return request<API.Result>(config.API_BASE_URL + '/api/login/mobile', {
     method: 'POST',
     headers: {
       'Content-Type': 'application/json',
@@ -32,7 +33,7 @@ export async function login(body: API.LoginParams, options?: { [key: string]: an
 
 /** 此处后端没有提供注释 GET /api/notices */
 export async function getNotices(options?: { [key: string]: any }) {
-  return request<API.NoticeIconList>('/api/notices', {
+  return request<API.NoticeIconList>(config.API_BASE_URL + '/api/notices', {
     method: 'GET',
     ...(options || {}),
   });
@@ -49,7 +50,7 @@ export async function rule(
   },
   options?: { [key: string]: any },
 ) {
-  return request<API.RuleList>('/api/rule', {
+  return request<API.RuleList>(config.API_BASE_URL + '/api/rule', {
     method: 'GET',
     params: {
       ...params,
@@ -60,7 +61,7 @@ export async function rule(
 
 /** 新建规则 PUT /api/rule */
 export async function updateRule(options?: { [key: string]: any }) {
-  return request<API.RuleListItem>('/api/rule', {
+  return request<API.RuleListItem>(config.API_BASE_URL + '/api/rule', {
     method: 'PUT',
     ...(options || {}),
   });
@@ -68,7 +69,7 @@ export async function updateRule(options?: { [key: string]: any }) {
 
 /** 新建规则 POST /api/rule */
 export async function addRule(options?: { [key: string]: any }) {
-  return request<API.RuleListItem>('/api/rule', {
+  return request<API.RuleListItem>(config.API_BASE_URL + '/api/rule', {
     method: 'POST',
     ...(options || {}),
   });
@@ -76,18 +77,20 @@ export async function addRule(options?: { [key: string]: any }) {
 
 /** 删除规则 DELETE /api/rule */
 export async function removeRule(options?: { [key: string]: any }) {
-  return request<Record<string, any>>('/api/rule', {
+  return request<Record<string, any>>(config.API_BASE_URL + '/api/rule', {
     method: 'DELETE',
     ...(options || {}),
   });
 }
 
-
 /** 获取oss GET /api/notices */
-export async function getOssInfo(params: { fileType: string, type: string }, options?: { [key: string]: any }) {
-  return request<API.Result>('/api/oss/form/upload', {
+export async function getOssInfo(
+  params: { fileType: string; type: string },
+  options?: { [key: string]: any },
+) {
+  return request<API.Result>(config.API_BASE_URL + '/api/oss/form/upload', {
     method: 'GET',
     params,
     ...(options || {}),
   });
-}
+}

+ 3 - 2
src/services/ant-design-pro/login.ts

@@ -1,16 +1,17 @@
 // @ts-ignore
 /* eslint-disable */
 import { request } from '@umijs/max';
+import config from '../config';
 
 /** 发送验证码 POST /api/login/captcha */
 export async function getFakeCaptcha(
   data: {
     mobile: string;
-    smsType: 'SMS_REG_LOGIN' | 'SMS_MODIFY' | 'SMS_FIND_PWD'
+    smsType: 'SMS_REG_LOGIN' | 'SMS_MODIFY' | 'SMS_FIND_PWD';
   },
   options?: { [key: string]: any },
 ) {
-  return request<API.FakeCaptcha>('/api/sms/send/msg', {
+  return request<API.FakeCaptcha>(config.API_BASE_URL + '/api/sms/send/msg', {
     method: 'POST',
     data,
     ...(options || {}),

+ 7 - 0
src/services/config.ts

@@ -0,0 +1,7 @@
+const isProduction = process.env.NODE_ENV === 'production';
+
+const API_BASE_URL = isProduction ? 'http://47.97.38.17:9988' : 'http://47.97.38.17:9988';
+
+export default {
+  API_BASE_URL,
+};

+ 15 - 15
src/services/task-api/center.ts

@@ -1,15 +1,15 @@
-import { request } from "@umijs/max";
-
-
-/**
- * 个人中心获取用户信息
- * @param data 
- * @param options 
- * @returns 
- */
-export async function getCenterUserInfoApi(options?: { [key: string]: any }) {
-    return request<API.Result>('/api/login/user/info', {
-        method: 'GET',
-        ...(options || {}),
-    });
-}
+import { request } from '@umijs/max';
+import config from '../config';
+
+/**
+ * 个人中心获取用户信息
+ * @param data
+ * @param options
+ * @returns
+ */
+export async function getCenterUserInfoApi(options?: { [key: string]: any }) {
+  return request<API.Result>(config.API_BASE_URL + '/api/login/user/info', {
+    method: 'GET',
+    ...(options || {}),
+  });
+}

+ 36 - 30
src/services/task-api/download.ts

@@ -1,30 +1,36 @@
-import { request } from "@umijs/max";
-
-
-/**
- * 下载任务列表
- * @param data 
- * @param options 
- * @returns 
- */
-export async function getDownloadListApi(data: TASKAPI.DownloadList, options?: { [key: string]: any }) {
-    return request<API.Result>('/api/download/log/pageList', {
-        method: 'POST',
-        data,
-        ...(options || {}),
-    });
-}
-
-/**
- * 下载上报
- * @param data 
- * @param options 
- * @returns 
- */
-export async function downloadEscalationApi(data: TASKAPI.DownloadEscalation, options?: { [key: string]: any }) {
-    return request<API.Result>('/api/download/log/add', {
-        method: 'POST',
-        data,
-        ...(options || {}),
-    });
-}
+import { request } from '@umijs/max';
+import config from '../config';
+
+/**
+ * 下载任务列表
+ * @param data
+ * @param options
+ * @returns
+ */
+export async function getDownloadListApi(
+  data: TASKAPI.DownloadList,
+  options?: { [key: string]: any },
+) {
+  return request<API.Result>(config.API_BASE_URL + '/api/download/log/pageList', {
+    method: 'POST',
+    data,
+    ...(options || {}),
+  });
+}
+
+/**
+ * 下载上报
+ * @param data
+ * @param options
+ * @returns
+ */
+export async function downloadEscalationApi(
+  data: TASKAPI.DownloadEscalation,
+  options?: { [key: string]: any },
+) {
+  return request<API.Result>(config.API_BASE_URL + '/api/download/log/add', {
+    method: 'POST',
+    data,
+    ...(options || {}),
+  });
+}

+ 16 - 16
src/services/task-api/income.ts

@@ -1,16 +1,16 @@
-import { request } from "@umijs/max";
-
-
-/**
- * 收益列表
- * @param data 
- * @param options 
- * @returns 
- */
-export async function getIncomeListApi(data: TASKAPI.IncomeList, options?: { [key: string]: any }) {
-    return request<API.Result>('/api/material/income/list', {
-        method: 'POST',
-        data,
-        ...(options || {}),
-    });
-}
+import { request } from '@umijs/max';
+import config from '../config';
+
+/**
+ * 收益列表
+ * @param data
+ * @param options
+ * @returns
+ */
+export async function getIncomeListApi(data: TASKAPI.IncomeList, options?: { [key: string]: any }) {
+  return request<API.Result>(config.API_BASE_URL + '/api/material/income/list', {
+    method: 'POST',
+    data,
+    ...(options || {}),
+  });
+}

+ 46 - 45
src/services/task-api/myTask.ts

@@ -1,45 +1,46 @@
-// @ts-ignore
-/* eslint-disable */
-import { request } from '@umijs/max';
-
-/**
- * 任务发布
- * @param data 
- * @param options 
- * @returns 
- */
-export async function addTaskApi(data: TASKAPI.AddTask, options?: { [key: string]: any }) {
-    return request<API.Result>('/api/task/add', {
-        method: 'POST',
-        data,
-        ...(options || {}),
-    });
-}
-
-/**
- * 任务修改
- * @param data 
- * @param options 
- * @returns 
- */
-export async function modifyTaskApi(data: TASKAPI.ModifyTask, options?: { [key: string]: any }) {
-    return request<API.Result>('/api/task/modify', {
-        method: 'POST',
-        data,
-        ...(options || {}),
-    });
-}
-
-/**
- * 我的任务列表
- * @param data 
- * @param options 
- * @returns 
- */
-export async function getTaskListApi(data: TASKAPI.TaskList, options?: { [key: string]: any }) {
-    return request<API.Result>('/api/task/manage/list', {
-        method: 'POST',
-        data,
-        ...(options || {}),
-    });
-}
+// @ts-ignore
+/* eslint-disable */
+import { request } from '@umijs/max';
+import config from '../config';
+
+/**
+ * 任务发布
+ * @param data
+ * @param options
+ * @returns
+ */
+export async function addTaskApi(data: TASKAPI.AddTask, options?: { [key: string]: any }) {
+  return request<API.Result>(config.API_BASE_URL + '/api/task/add', {
+    method: 'POST',
+    data,
+    ...(options || {}),
+  });
+}
+
+/**
+ * 任务修改
+ * @param data
+ * @param options
+ * @returns
+ */
+export async function modifyTaskApi(data: TASKAPI.ModifyTask, options?: { [key: string]: any }) {
+  return request<API.Result>(config.API_BASE_URL + '/api/task/modify', {
+    method: 'POST',
+    data,
+    ...(options || {}),
+  });
+}
+
+/**
+ * 我的任务列表
+ * @param data
+ * @param options
+ * @returns
+ */
+export async function getTaskListApi(data: TASKAPI.TaskList, options?: { [key: string]: any }) {
+  return request<API.Result>(config.API_BASE_URL + '/api/task/manage/list', {
+    method: 'POST',
+    data,
+    ...(options || {}),
+  });
+}

+ 16 - 16
src/services/task-api/opus.ts

@@ -1,16 +1,16 @@
-import { request } from "@umijs/max";
-
-
-/**
- * 任务列表
- * @param data 
- * @param options 
- * @returns 
- */
-export async function getOpusListApi(data: TASKAPI.OpusList, options?: { [key: string]: any }) {
-    return request<API.Result>('/api/material/list', {
-        method: 'POST',
-        data,
-        ...(options || {}),
-    });
-}
+import { request } from '@umijs/max';
+import config from '../config';
+
+/**
+ * 任务列表
+ * @param data
+ * @param options
+ * @returns
+ */
+export async function getOpusListApi(data: TASKAPI.OpusList, options?: { [key: string]: any }) {
+  return request<API.Result>(config.API_BASE_URL + '/api/material/list', {
+    method: 'POST',
+    data,
+    ...(options || {}),
+  });
+}

+ 33 - 30
src/services/task-api/task.ts

@@ -1,30 +1,33 @@
-import { request } from "@umijs/max";
-
-
-/**
- * 任务列表
- * @param data 
- * @param options 
- * @returns 
- */
-export async function getTaskMemberListApi(data: TASKAPI.TaskMemberList, options?: { [key: string]: any }) {
-    return request<API.Result>('/api/task/member/list', {
-        method: 'POST',
-        data,
-        ...(options || {}),
-    });
-}
-
-/**
- * 提交素材
- * @param data 
- * @param options 
- * @returns 
- */
-export async function addMaterialApi(data: TASKAPI.AddMaterial, options?: { [key: string]: any }) {
-    return request<API.Result>('/api/material/add', {
-        method: 'POST',
-        data,
-        ...(options || {}),
-    });
-}
+import { request } from '@umijs/max';
+import config from '../config';
+
+/**
+ * 任务列表
+ * @param data
+ * @param options
+ * @returns
+ */
+export async function getTaskMemberListApi(
+  data: TASKAPI.TaskMemberList,
+  options?: { [key: string]: any },
+) {
+  return request<API.Result>(config.API_BASE_URL + '/api/task/member/list', {
+    method: 'POST',
+    data,
+    ...(options || {}),
+  });
+}
+
+/**
+ * 提交素材
+ * @param data
+ * @param options
+ * @returns
+ */
+export async function addMaterialApi(data: TASKAPI.AddMaterial, options?: { [key: string]: any }) {
+  return request<API.Result>(config.API_BASE_URL + '/api/material/add', {
+    method: 'POST',
+    data,
+    ...(options || {}),
+  });
+}