├── .editorconfig ├── .env ├── .eslintignore ├── .eslintrc.js ├── .gitignore ├── .prettierignore ├── .prettierrc.js ├── LICENSE ├── README.md ├── config ├── config.ts ├── defaultSettings.ts ├── oneapi.json ├── proxy.ts └── routes.ts ├── docs ├── account.png ├── account_add.png ├── account_info.png ├── login.png ├── task.png └── welcome.png ├── jest.config.ts ├── jsconfig.json ├── mock ├── listTableList.ts ├── notices.ts ├── requestRecord.mock.js ├── route.ts └── user.ts ├── package.json ├── pnpm-lock.yaml ├── public ├── CNAME ├── favicon.ico ├── icons │ ├── icon-128x128.png │ ├── icon-192x192.png │ └── icon-512x512.png ├── logo.svg ├── pro_icon.svg └── scripts │ └── loading.js ├── src ├── access.ts ├── app.tsx ├── components │ ├── Footer │ │ └── index.tsx │ ├── HeaderDropdown │ │ └── index.tsx │ └── RightContent │ │ ├── AvatarDropdown.tsx │ │ └── index.tsx ├── global.less ├── global.tsx ├── locales │ ├── en-US.ts │ ├── en-US │ │ ├── component.ts │ │ ├── globalHeader.ts │ │ ├── menu.ts │ │ ├── pages.ts │ │ ├── pwa.ts │ │ ├── settingDrawer.ts │ │ └── settings.ts │ ├── zh-CN.ts │ └── zh-CN │ │ ├── component.ts │ │ ├── globalHeader.ts │ │ ├── menu.ts │ │ ├── pages.ts │ │ ├── pwa.ts │ │ ├── settingDrawer.ts │ │ └── settings.ts ├── manifest.json ├── pages │ ├── 404.tsx │ ├── AccountList │ │ ├── components │ │ │ ├── ColumnBuilder.tsx │ │ │ ├── Modal.tsx │ │ │ ├── button │ │ │ │ ├── DelButton.tsx │ │ │ │ └── SyncButton.tsx │ │ │ └── contents │ │ │ │ ├── AddContent .tsx │ │ │ │ ├── EditContent .tsx │ │ │ │ └── MoreContent .tsx │ │ ├── index.less │ │ └── index.tsx │ ├── Task │ │ └── List │ │ │ ├── index.less │ │ │ └── index.tsx │ ├── User │ │ └── Login │ │ │ ├── __snapshots__ │ │ │ └── login.test.tsx.snap │ │ │ ├── index.tsx │ │ │ └── login.test.tsx │ └── Welcome.tsx ├── requestErrorConfig.ts ├── service-worker.js ├── services │ ├── ant-design-pro │ │ ├── api.ts │ │ ├── index.ts │ │ ├── login.ts │ │ └── typings.d.ts │ └── swagger │ │ ├── index.ts │ │ ├── pet.ts │ │ ├── store.ts │ │ ├── typings.d.ts │ │ └── user.ts └── typings.d.ts ├── tests └── setupTests.jsx ├── tsconfig.json └── types ├── cache ├── cache.json ├── login.cache.json └── mock │ ├── login.mock.cache.js │ └── mock.cache.js └── index.d.ts /.editorconfig: -------------------------------------------------------------------------------- 1 | # http://editorconfig.org 2 | root = true 3 | 4 | [*] 5 | indent_style = space 6 | indent_size = 2 7 | end_of_line = lf 8 | charset = utf-8 9 | trim_trailing_whitespace = true 10 | insert_final_newline = true 11 | 12 | [*.md] 13 | trim_trailing_whitespace = false 14 | 15 | [Makefile] 16 | indent_style = tab 17 | -------------------------------------------------------------------------------- /.env: -------------------------------------------------------------------------------- 1 | # 账户名 2 | ADMIN_NAME=admin 3 | # 密码 4 | PASS_WORD=123456 5 | # MJ-SERVER 6 | MJ_SERVER=http://127.0.0.1:8080 7 | # mj.api-secret 8 | UMI_APP_MJ_API_SECRET=homoloadmin -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | /lambda/ 2 | /scripts 3 | /config 4 | .history 5 | public 6 | dist 7 | .umi 8 | mock -------------------------------------------------------------------------------- /.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | extends: [require.resolve('@umijs/lint/dist/config/eslint')], 3 | globals: { 4 | page: true, 5 | REACT_APP_ENV: true, 6 | }, 7 | }; 8 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | **/node_modules 5 | # roadhog-api-doc ignore 6 | /src/utils/request-temp.js 7 | _roadhog-api-doc 8 | 9 | # production 10 | /dist 11 | 12 | # misc 13 | .DS_Store 14 | npm-debug.log* 15 | yarn-error.log 16 | 17 | /coverage 18 | .idea 19 | yarn.lock 20 | package-lock.json 21 | *bak 22 | .vscode 23 | 24 | 25 | # visual studio code 26 | .history 27 | *.log 28 | functions/* 29 | .temp/** 30 | 31 | # umi 32 | .umi 33 | .umi-production 34 | .umi-test 35 | 36 | # screenshot 37 | screenshot 38 | .firebase 39 | .eslintcache 40 | 41 | build 42 | -------------------------------------------------------------------------------- /.prettierignore: -------------------------------------------------------------------------------- 1 | **/*.svg 2 | .umi 3 | .umi-production 4 | /dist 5 | .dockerignore 6 | .DS_Store 7 | .eslintignore 8 | *.png 9 | *.toml 10 | docker 11 | .editorconfig 12 | Dockerfile* 13 | .gitignore 14 | .prettierignore 15 | LICENSE 16 | .eslintcache 17 | *.lock 18 | yarn-error.log 19 | .history 20 | CNAME 21 | /build 22 | /public 23 | -------------------------------------------------------------------------------- /.prettierrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | singleQuote: true, 3 | trailingComma: 'all', 4 | printWidth: 100, 5 | proseWrap: 'never', 6 | endOfLine: 'lf', 7 | overrides: [ 8 | { 9 | files: '.prettierrc', 10 | options: { 11 | parser: 'json', 12 | }, 13 | }, 14 | { 15 | files: 'document.ejs', 16 | options: { 17 | parser: 'html', 18 | }, 19 | }, 20 | ], 21 | }; 22 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # midjourney-proxy-admin 2 | [midjourney-proxy-plus](https://github.com/litter-coder/midjourney-proxy-plus) 的管理后台 3 | 4 | # 主要功能 5 | 6 | - [x] 支持MJ账户的增删改查功能 7 | - [x] 支持MJ账户的详细信息查询和账户同步操作 8 | - [x] 支持MJ账户的并发队列设置 9 | - [x] 支持MJ的任务查询 10 | 11 | # 后续计划 12 | 13 | - [ ] 任务查询功能优化 14 | - [ ] 支持MJ的账户settings修改 15 | - [ ] 支持MJ的队列内容查询 16 | - [ ] ... 17 | 18 | # 使用示例 19 | 20 | ①登录页 21 | 22 | 登录页 23 | 24 | ②欢迎页 25 | 26 | 欢迎页 27 | 28 | ③账户管理 29 | 30 | 账户管理 31 | 32 | ④添加账户 33 | 34 | 添加账户 35 | 36 | ⑤账户详情 37 | 38 | 账户详情 39 | 40 | ⑥任务列表 41 | 42 | 任务列表 43 | 44 | # 部署方式 45 | 46 | ## 1.运行环境 47 | 48 | 支持 Linux、MacOS、Windows 系统(可在Linux服务器上长期运行),同时需安装 `node18`。 49 | 50 | **(1) 克隆项目代码:** 51 | 52 | ```bash 53 | git clone https://github.com/litter-coder/midjourney-proxy-admin 54 | cd midjourney-proxy-admin/ 55 | ``` 56 | 57 | **(2) 安装依赖 :** 58 | 59 | ```bash 60 | npm install 61 | ``` 62 | 63 | ## 2.配置 64 | 65 | 配置文件在根目录的`.env`中: 66 | 67 | ```shell 68 | # 账户名 69 | ADMIN_NAME=admin 70 | # 密码 71 | PASS_WORD=123456 72 | # MJ-SERVER 73 | MJ_SERVER=http://127.0.0.1:8080 74 | # mj.api-secret 75 | UMI_APP_MJ_API_SECRET=123456 76 | ``` 77 | 78 | ## 3.运行 79 | 80 | 使用nohup命令在后台运行程序: 81 | 82 | ``` 83 | nohup npm run start > out.log 2>&1 & disown 84 | # 在后台运行程序 85 | ``` 86 | 87 | ## 4.其他 88 | 89 | ### 1.查看进程 90 | 91 | ```shell 92 | ps -ef | grep npm 93 | ``` 94 | 95 | ### 2.结束进程 96 | 97 | ```sh 98 | kill -9 [进程id] 99 | ``` 100 | 101 | # 联系我们 102 | 103 | 问题咨询和商务合作可联系 104 | 105 | 微信二维码 106 | 107 | -------------------------------------------------------------------------------- /config/config.ts: -------------------------------------------------------------------------------- 1 | // https://umijs.org/config/ 2 | import { defineConfig } from '@umijs/max'; 3 | import { join } from 'path'; 4 | import defaultSettings from './defaultSettings'; 5 | import proxy from './proxy'; 6 | import routes from './routes'; 7 | 8 | const { REACT_APP_ENV = 'dev' } = process.env; 9 | 10 | export default defineConfig({ 11 | /** 12 | * @name 开启 hash 模式 13 | * @description 让 build 之后的产物包含 hash 后缀。通常用于增量发布和避免浏览器加载缓存。 14 | * @doc https://umijs.org/docs/api/config#hash 15 | */ 16 | hash: true, 17 | 18 | /** 19 | * @name 兼容性设置 20 | * @description 设置 ie11 不一定完美兼容,需要检查自己使用的所有依赖 21 | * @doc https://umijs.org/docs/api/config#targets 22 | */ 23 | // targets: { 24 | // ie: 11, 25 | // }, 26 | /** 27 | * @name 路由的配置,不在路由中引入的文件不会编译 28 | * @description 只支持 path,component,routes,redirect,wrappers,title 的配置 29 | * @doc https://umijs.org/docs/guides/routes 30 | */ 31 | // umi routes: https://umijs.org/docs/routing 32 | routes, 33 | /** 34 | * @name 主题的配置 35 | * @description 虽然叫主题,但是其实只是 less 的变量设置 36 | * @doc antd的主题设置 https://ant.design/docs/react/customize-theme-cn 37 | * @doc umi 的theme 配置 https://umijs.org/docs/api/config#theme 38 | */ 39 | theme: { 40 | // 如果不想要 configProvide 动态设置主题需要把这个设置为 default 41 | // 只有设置为 variable, 才能使用 configProvide 动态设置主色调 42 | 'root-entry-name': 'variable', 43 | }, 44 | /** 45 | * @name moment 的国际化配置 46 | * @description 如果对国际化没有要求,打开之后能减少js的包大小 47 | * @doc https://umijs.org/docs/api/config#ignoremomentlocale 48 | */ 49 | ignoreMomentLocale: true, 50 | /** 51 | * @name 代理配置 52 | * @description 可以让你的本地服务器代理到你的服务器上,这样你就可以访问服务器的数据了 53 | * @see 要注意以下 代理只能在本地开发时使用,build 之后就无法使用了。 54 | * @doc 代理介绍 https://umijs.org/docs/guides/proxy 55 | * @doc 代理配置 https://umijs.org/docs/api/config#proxy 56 | */ 57 | proxy: proxy[REACT_APP_ENV as keyof typeof proxy], 58 | /** 59 | * @name 快速热更新配置 60 | * @description 一个不错的热更新组件,更新时可以保留 state 61 | */ 62 | fastRefresh: true, 63 | //============== 以下都是max的插件配置 =============== 64 | /** 65 | * @name 数据流插件 66 | * @@doc https://umijs.org/docs/max/data-flow 67 | */ 68 | model: {}, 69 | /** 70 | * 一个全局的初始数据流,可以用它在插件之间共享数据 71 | * @description 可以用来存放一些全局的数据,比如用户信息,或者一些全局的状态,全局初始状态在整个 Umi 项目的最开始创建。 72 | * @doc https://umijs.org/docs/max/data-flow#%E5%85%A8%E5%B1%80%E5%88%9D%E5%A7%8B%E7%8A%B6%E6%80%81 73 | */ 74 | initialState: {}, 75 | /** 76 | * @name layout 插件 77 | * @doc https://umijs.org/docs/max/layout-menu 78 | */ 79 | title: 'Ant Design Pro', 80 | layout: { 81 | locale: true, 82 | ...defaultSettings, 83 | }, 84 | /** 85 | * @name moment2dayjs 插件 86 | * @description 将项目中的 moment 替换为 dayjs 87 | * @doc https://umijs.org/docs/max/moment2dayjs 88 | */ 89 | moment2dayjs: { 90 | preset: 'antd', 91 | plugins: ['duration'], 92 | }, 93 | /** 94 | * @name 国际化插件 95 | * @doc https://umijs.org/docs/max/i18n 96 | */ 97 | locale: { 98 | // default zh-CN 99 | default: 'zh-CN', 100 | antd: true, 101 | // default true, when it is true, will use `navigator.language` overwrite default 102 | baseNavigator: true, 103 | }, 104 | /** 105 | * @name antd 插件 106 | * @description 内置了 babel import 插件 107 | * @doc https://umijs.org/docs/max/antd#antd 108 | */ 109 | antd: {}, 110 | /** 111 | * @name 网络请求配置 112 | * @description 它基于 axios 和 ahooks 的 useRequest 提供了一套统一的网络请求和错误处理方案。 113 | * @doc https://umijs.org/docs/max/request 114 | */ 115 | request: {}, 116 | /** 117 | * @name 权限插件 118 | * @description 基于 initialState 的权限插件,必须先打开 initialState 119 | * @doc https://umijs.org/docs/max/access 120 | */ 121 | access: {}, 122 | /** 123 | * @name 中额外的 script 124 | * @description 配置 中额外的 script 125 | */ 126 | headScripts: [ 127 | // 解决首次加载时白屏的问题 128 | { src: '/scripts/loading.js', async: true }, 129 | ], 130 | //================ pro 插件配置 ================= 131 | presets: ['umi-presets-pro'], 132 | /** 133 | * @name openAPI 插件的配置 134 | * @description 基于 openapi 的规范生成serve 和mock,能减少很多样板代码 135 | * @doc https://pro.ant.design/zh-cn/docs/openapi/ 136 | */ 137 | openAPI: [ 138 | { 139 | requestLibPath: "import { request } from '@umijs/max'", 140 | // 或者使用在线的版本 141 | // schemaPath: "https://gw.alipayobjects.com/os/antfincdn/M%24jrzTTYJN/oneapi.json" 142 | schemaPath: join(__dirname, 'oneapi.json'), 143 | mock: false, 144 | }, 145 | { 146 | requestLibPath: "import { request } from '@umijs/max'", 147 | schemaPath: 'https://gw.alipayobjects.com/os/antfincdn/CA1dOm%2631B/openapi.json', 148 | projectName: 'swagger', 149 | }, 150 | ], 151 | mfsu: { 152 | strategy: 'normal', 153 | }, 154 | requestRecord: {}, 155 | }); 156 | -------------------------------------------------------------------------------- /config/defaultSettings.ts: -------------------------------------------------------------------------------- 1 | import { ProLayoutProps } from '@ant-design/pro-components'; 2 | 3 | /** 4 | * @name 5 | */ 6 | const Settings: ProLayoutProps & { 7 | pwa?: boolean; 8 | logo?: string; 9 | } = { 10 | navTheme: 'light', 11 | // 拂晓蓝 12 | colorPrimary: '#1890ff', 13 | layout: 'mix', 14 | contentWidth: 'Fluid', 15 | fixedHeader: false, 16 | fixSiderbar: true, 17 | colorWeak: false, 18 | title: 'Midjourney Proxy Admin', 19 | pwa: true, 20 | logo: 'https://gw.alipayobjects.com/zos/rmsportal/KDpgvguMpGfqaHPjicRK.svg', 21 | iconfontUrl: '', 22 | token: { 23 | // 参见ts声明,demo 见文档,通过token 修改样式 24 | //https://procomponents.ant.design/components/layout#%E9%80%9A%E8%BF%87-token-%E4%BF%AE%E6%94%B9%E6%A0%B7%E5%BC%8F 25 | }, 26 | }; 27 | 28 | export default Settings; 29 | -------------------------------------------------------------------------------- /config/oneapi.json: -------------------------------------------------------------------------------- 1 | { 2 | "openapi": "3.0.1", 3 | "info": { 4 | "title": "Ant Design Pro", 5 | "version": "1.0.0" 6 | }, 7 | "servers": [ 8 | { 9 | "url": "http://localhost:8000/" 10 | }, 11 | { 12 | "url": "https://localhost:8000/" 13 | } 14 | ], 15 | "paths": { 16 | "/api/currentUser": { 17 | "get": { 18 | "tags": ["api"], 19 | "description": "获取当前的用户", 20 | "operationId": "currentUser", 21 | "responses": { 22 | "200": { 23 | "description": "Success", 24 | "content": { 25 | "application/json": { 26 | "schema": { 27 | "$ref": "#/components/schemas/CurrentUser" 28 | } 29 | } 30 | } 31 | }, 32 | "401": { 33 | "description": "Error", 34 | "content": { 35 | "application/json": { 36 | "schema": { 37 | "$ref": "#/components/schemas/ErrorResponse" 38 | } 39 | } 40 | } 41 | } 42 | } 43 | }, 44 | "x-swagger-router-controller": "api" 45 | }, 46 | "/api/login/captcha": { 47 | "post": { 48 | "description": "发送验证码", 49 | "operationId": "getFakeCaptcha", 50 | "tags": ["login"], 51 | "parameters": [ 52 | { 53 | "name": "phone", 54 | "in": "query", 55 | "description": "手机号", 56 | "schema": { 57 | "type": "string" 58 | } 59 | } 60 | ], 61 | "responses": { 62 | "200": { 63 | "description": "Success", 64 | "content": { 65 | "application/json": { 66 | "schema": { 67 | "$ref": "#/components/schemas/FakeCaptcha" 68 | } 69 | } 70 | } 71 | } 72 | } 73 | } 74 | }, 75 | "/api/login/outLogin": { 76 | "post": { 77 | "description": "登录接口", 78 | "operationId": "outLogin", 79 | "tags": ["login"], 80 | "responses": { 81 | "200": { 82 | "description": "Success", 83 | "content": { 84 | "application/json": { 85 | "schema": { 86 | "type": "object" 87 | } 88 | } 89 | } 90 | }, 91 | "401": { 92 | "description": "Error", 93 | "content": { 94 | "application/json": { 95 | "schema": { 96 | "$ref": "#/components/schemas/ErrorResponse" 97 | } 98 | } 99 | } 100 | } 101 | } 102 | }, 103 | "x-swagger-router-controller": "api" 104 | }, 105 | "/api/login/account": { 106 | "post": { 107 | "tags": ["login"], 108 | "description": "登录接口", 109 | "operationId": "login", 110 | "requestBody": { 111 | "description": "登录系统", 112 | "content": { 113 | "application/json": { 114 | "schema": { 115 | "$ref": "#/components/schemas/LoginParams" 116 | } 117 | } 118 | }, 119 | "required": true 120 | }, 121 | "responses": { 122 | "200": { 123 | "description": "Success", 124 | "content": { 125 | "application/json": { 126 | "schema": { 127 | "$ref": "#/components/schemas/LoginResult" 128 | } 129 | } 130 | } 131 | }, 132 | "401": { 133 | "description": "Error", 134 | "content": { 135 | "application/json": { 136 | "schema": { 137 | "$ref": "#/components/schemas/ErrorResponse" 138 | } 139 | } 140 | } 141 | } 142 | }, 143 | "x-codegen-request-body-name": "body" 144 | }, 145 | "x-swagger-router-controller": "api" 146 | }, 147 | "/api/notices": { 148 | "summary": "getNotices", 149 | "description": "NoticeIconItem", 150 | "get": { 151 | "tags": ["api"], 152 | "operationId": "getNotices", 153 | "responses": { 154 | "200": { 155 | "description": "Success", 156 | "content": { 157 | "application/json": { 158 | "schema": { 159 | "$ref": "#/components/schemas/NoticeIconList" 160 | } 161 | } 162 | } 163 | } 164 | } 165 | } 166 | }, 167 | "/api/rule": { 168 | "get": { 169 | "tags": ["rule"], 170 | "description": "获取规则列表", 171 | "operationId": "rule", 172 | "parameters": [ 173 | { 174 | "name": "current", 175 | "in": "query", 176 | "description": "当前的页码", 177 | "schema": { 178 | "type": "number" 179 | } 180 | }, 181 | { 182 | "name": "pageSize", 183 | "in": "query", 184 | "description": "页面的容量", 185 | "schema": { 186 | "type": "number" 187 | } 188 | } 189 | ], 190 | "responses": { 191 | "200": { 192 | "description": "Success", 193 | "content": { 194 | "application/json": { 195 | "schema": { 196 | "$ref": "#/components/schemas/RuleList" 197 | } 198 | } 199 | } 200 | }, 201 | "401": { 202 | "description": "Error", 203 | "content": { 204 | "application/json": { 205 | "schema": { 206 | "$ref": "#/components/schemas/ErrorResponse" 207 | } 208 | } 209 | } 210 | } 211 | } 212 | }, 213 | "post": { 214 | "tags": ["rule"], 215 | "description": "新建规则", 216 | "operationId": "addRule", 217 | "responses": { 218 | "200": { 219 | "description": "Success", 220 | "content": { 221 | "application/json": { 222 | "schema": { 223 | "$ref": "#/components/schemas/RuleListItem" 224 | } 225 | } 226 | } 227 | }, 228 | "401": { 229 | "description": "Error", 230 | "content": { 231 | "application/json": { 232 | "schema": { 233 | "$ref": "#/components/schemas/ErrorResponse" 234 | } 235 | } 236 | } 237 | } 238 | } 239 | }, 240 | "put": { 241 | "tags": ["rule"], 242 | "description": "新建规则", 243 | "operationId": "updateRule", 244 | "responses": { 245 | "200": { 246 | "description": "Success", 247 | "content": { 248 | "application/json": { 249 | "schema": { 250 | "$ref": "#/components/schemas/RuleListItem" 251 | } 252 | } 253 | } 254 | }, 255 | "401": { 256 | "description": "Error", 257 | "content": { 258 | "application/json": { 259 | "schema": { 260 | "$ref": "#/components/schemas/ErrorResponse" 261 | } 262 | } 263 | } 264 | } 265 | } 266 | }, 267 | "delete": { 268 | "tags": ["rule"], 269 | "description": "删除规则", 270 | "operationId": "removeRule", 271 | "responses": { 272 | "200": { 273 | "description": "Success", 274 | "content": { 275 | "application/json": { 276 | "schema": { 277 | "type": "object" 278 | } 279 | } 280 | } 281 | }, 282 | "401": { 283 | "description": "Error", 284 | "content": { 285 | "application/json": { 286 | "schema": { 287 | "$ref": "#/components/schemas/ErrorResponse" 288 | } 289 | } 290 | } 291 | } 292 | } 293 | }, 294 | "x-swagger-router-controller": "api" 295 | }, 296 | "/swagger": { 297 | "x-swagger-pipe": "swagger_raw" 298 | } 299 | }, 300 | "components": { 301 | "schemas": { 302 | "CurrentUser": { 303 | "type": "object", 304 | "properties": { 305 | "name": { 306 | "type": "string" 307 | }, 308 | "avatar": { 309 | "type": "string" 310 | }, 311 | "userid": { 312 | "type": "string" 313 | }, 314 | "email": { 315 | "type": "string" 316 | }, 317 | "signature": { 318 | "type": "string" 319 | }, 320 | "title": { 321 | "type": "string" 322 | }, 323 | "group": { 324 | "type": "string" 325 | }, 326 | "tags": { 327 | "type": "array", 328 | "items": { 329 | "type": "object", 330 | "properties": { 331 | "key": { 332 | "type": "string" 333 | }, 334 | "label": { 335 | "type": "string" 336 | } 337 | } 338 | } 339 | }, 340 | "notifyCount": { 341 | "type": "integer", 342 | "format": "int32" 343 | }, 344 | "unreadCount": { 345 | "type": "integer", 346 | "format": "int32" 347 | }, 348 | "country": { 349 | "type": "string" 350 | }, 351 | "access": { 352 | "type": "string" 353 | }, 354 | "geographic": { 355 | "type": "object", 356 | "properties": { 357 | "province": { 358 | "type": "object", 359 | "properties": { 360 | "label": { 361 | "type": "string" 362 | }, 363 | "key": { 364 | "type": "string" 365 | } 366 | } 367 | }, 368 | "city": { 369 | "type": "object", 370 | "properties": { 371 | "label": { 372 | "type": "string" 373 | }, 374 | "key": { 375 | "type": "string" 376 | } 377 | } 378 | } 379 | } 380 | }, 381 | "address": { 382 | "type": "string" 383 | }, 384 | "phone": { 385 | "type": "string" 386 | } 387 | } 388 | }, 389 | "LoginResult": { 390 | "type": "object", 391 | "properties": { 392 | "status": { 393 | "type": "string" 394 | }, 395 | "type": { 396 | "type": "string" 397 | }, 398 | "currentAuthority": { 399 | "type": "string" 400 | } 401 | } 402 | }, 403 | "PageParams": { 404 | "type": "object", 405 | "properties": { 406 | "current": { 407 | "type": "number" 408 | }, 409 | "pageSize": { 410 | "type": "number" 411 | } 412 | } 413 | }, 414 | "RuleListItem": { 415 | "type": "object", 416 | "properties": { 417 | "key": { 418 | "type": "integer", 419 | "format": "int32" 420 | }, 421 | "disabled": { 422 | "type": "boolean" 423 | }, 424 | "href": { 425 | "type": "string" 426 | }, 427 | "avatar": { 428 | "type": "string" 429 | }, 430 | "name": { 431 | "type": "string" 432 | }, 433 | "owner": { 434 | "type": "string" 435 | }, 436 | "desc": { 437 | "type": "string" 438 | }, 439 | "callNo": { 440 | "type": "integer", 441 | "format": "int32" 442 | }, 443 | "status": { 444 | "type": "integer", 445 | "format": "int32" 446 | }, 447 | "updatedAt": { 448 | "type": "string", 449 | "format": "datetime" 450 | }, 451 | "createdAt": { 452 | "type": "string", 453 | "format": "datetime" 454 | }, 455 | "progress": { 456 | "type": "integer", 457 | "format": "int32" 458 | } 459 | } 460 | }, 461 | "RuleList": { 462 | "type": "object", 463 | "properties": { 464 | "data": { 465 | "type": "array", 466 | "items": { 467 | "$ref": "#/components/schemas/RuleListItem" 468 | } 469 | }, 470 | "total": { 471 | "type": "integer", 472 | "description": "列表的内容总数", 473 | "format": "int32" 474 | }, 475 | "success": { 476 | "type": "boolean" 477 | } 478 | } 479 | }, 480 | "FakeCaptcha": { 481 | "type": "object", 482 | "properties": { 483 | "code": { 484 | "type": "integer", 485 | "format": "int32" 486 | }, 487 | "status": { 488 | "type": "string" 489 | } 490 | } 491 | }, 492 | "LoginParams": { 493 | "type": "object", 494 | "properties": { 495 | "username": { 496 | "type": "string" 497 | }, 498 | "password": { 499 | "type": "string" 500 | }, 501 | "autoLogin": { 502 | "type": "boolean" 503 | }, 504 | "type": { 505 | "type": "string" 506 | } 507 | } 508 | }, 509 | "ErrorResponse": { 510 | "required": ["errorCode"], 511 | "type": "object", 512 | "properties": { 513 | "errorCode": { 514 | "type": "string", 515 | "description": "业务约定的错误码" 516 | }, 517 | "errorMessage": { 518 | "type": "string", 519 | "description": "业务上的错误信息" 520 | }, 521 | "success": { 522 | "type": "boolean", 523 | "description": "业务上的请求是否成功" 524 | } 525 | } 526 | }, 527 | "NoticeIconList": { 528 | "type": "object", 529 | "properties": { 530 | "data": { 531 | "type": "array", 532 | "items": { 533 | "$ref": "#/components/schemas/NoticeIconItem" 534 | } 535 | }, 536 | "total": { 537 | "type": "integer", 538 | "description": "列表的内容总数", 539 | "format": "int32" 540 | }, 541 | "success": { 542 | "type": "boolean" 543 | } 544 | } 545 | }, 546 | "NoticeIconItemType": { 547 | "title": "NoticeIconItemType", 548 | "description": "已读未读列表的枚举", 549 | "type": "string", 550 | "properties": {}, 551 | "enum": ["notification", "message", "event"] 552 | }, 553 | "NoticeIconItem": { 554 | "type": "object", 555 | "properties": { 556 | "id": { 557 | "type": "string" 558 | }, 559 | "extra": { 560 | "type": "string", 561 | "format": "any" 562 | }, 563 | "key": { "type": "string" }, 564 | "read": { 565 | "type": "boolean" 566 | }, 567 | "avatar": { 568 | "type": "string" 569 | }, 570 | "title": { 571 | "type": "string" 572 | }, 573 | "status": { 574 | "type": "string" 575 | }, 576 | "datetime": { 577 | "type": "string", 578 | "format": "date" 579 | }, 580 | "description": { 581 | "type": "string" 582 | }, 583 | "type": { 584 | "extensions": { 585 | "x-is-enum": true 586 | }, 587 | "$ref": "#/components/schemas/NoticeIconItemType" 588 | } 589 | } 590 | } 591 | } 592 | } 593 | } 594 | -------------------------------------------------------------------------------- /config/proxy.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @name 代理的配置 3 | * @see 在生产环境 代理是无法生效的,所以这里没有生产环境的配置 4 | * ------------------------------- 5 | * The agent cannot take effect in the production environment 6 | * so there is no configuration of the production environment 7 | * For details, please see 8 | * https://pro.ant.design/docs/deploy 9 | * 10 | * @doc https://umijs.org/docs/guides/proxy 11 | */ 12 | 13 | const MJ_SERVER = process.env.MJ_SERVER; 14 | 15 | export default { 16 | // 如果需要自定义本地开发服务器 请取消注释按需调整 17 | dev: { 18 | // localhost:8000/api/** -> https://preview.pro.ant.design/api/** 19 | '/mj/': { 20 | // 要代理的地址 21 | target: MJ_SERVER, 22 | // 配置了这个可以从 http 代理到 https 23 | // 依赖 origin 的功能可能需要这个,比如 cookie 24 | changeOrigin: true, 25 | }, 26 | }, 27 | 28 | /** 29 | * @name 详细的代理配置 30 | * @doc https://github.com/chimurai/http-proxy-middleware 31 | */ 32 | test: { 33 | // localhost:8000/api/** -> https://preview.pro.ant.design/api/** 34 | '/api/': { 35 | target: 'https://proapi.azurewebsites.net', 36 | changeOrigin: true, 37 | pathRewrite: { '^': '' }, 38 | }, 39 | }, 40 | pre: { 41 | '/api/': { 42 | target: 'your pre url', 43 | changeOrigin: true, 44 | pathRewrite: { '^': '' }, 45 | }, 46 | }, 47 | }; 48 | -------------------------------------------------------------------------------- /config/routes.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @name umi 的路由配置 3 | * @description 只支持 path,component,routes,redirect,wrappers,name,icon 的配置 4 | * @param path path 只支持两种占位符配置,第一种是动态参数 :id 的形式,第二种是 * 通配符,通配符只能出现路由字符串的最后。 5 | * @param component 配置 location 和 path 匹配后用于渲染的 React 组件路径。可以是绝对路径,也可以是相对路径,如果是相对路径,会从 src/pages 开始找起。 6 | * @param routes 配置子路由,通常在需要为多个路径增加 layout 组件时使用。 7 | * @param redirect 配置路由跳转 8 | * @param wrappers 配置路由组件的包装组件,通过包装组件可以为当前的路由组件组合进更多的功能。 比如,可以用于路由级别的权限校验 9 | * @param name 配置路由的标题,默认读取国际化文件 menu.ts 中 menu.xxxx 的值,如配置 name 为 login,则读取 menu.ts 中 menu.login 的取值作为标题 10 | * @param icon 配置路由的图标,取值参考 https://ant.design/components/icon-cn, 注意去除风格后缀和大小写,如想要配置图标为 则取值应为 stepBackward 或 StepBackward,如想要配置图标为 则取值应为 user 或者 User 11 | * @doc https://umijs.org/docs/guides/routes 12 | */ 13 | export default [ 14 | { 15 | path: '/user', 16 | layout: false, 17 | routes: [ 18 | { 19 | name: 'login', 20 | path: '/user/login', 21 | component: './User/Login', 22 | }, 23 | ], 24 | }, 25 | { 26 | path: '/welcome', 27 | name: 'welcome', 28 | icon: 'smile', 29 | component: './Welcome', 30 | }, 31 | { 32 | name: 'list.account-list', 33 | icon: 'crown', 34 | path: '/account', 35 | component: './AccountList', 36 | }, 37 | { 38 | name: 'task-list', 39 | icon: 'bars', 40 | path: '/task/list', 41 | component: './Task/List', 42 | }, 43 | { 44 | path: '/', 45 | redirect: '/welcome', 46 | }, 47 | { 48 | path: '*', 49 | layout: false, 50 | component: './404', 51 | }, 52 | ]; 53 | -------------------------------------------------------------------------------- /docs/account.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rancytech/mj-proxy-admin/969850bfbc599cefbf51ee9d701cca3cb38e66e7/docs/account.png -------------------------------------------------------------------------------- /docs/account_add.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rancytech/mj-proxy-admin/969850bfbc599cefbf51ee9d701cca3cb38e66e7/docs/account_add.png -------------------------------------------------------------------------------- /docs/account_info.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rancytech/mj-proxy-admin/969850bfbc599cefbf51ee9d701cca3cb38e66e7/docs/account_info.png -------------------------------------------------------------------------------- /docs/login.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rancytech/mj-proxy-admin/969850bfbc599cefbf51ee9d701cca3cb38e66e7/docs/login.png -------------------------------------------------------------------------------- /docs/task.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rancytech/mj-proxy-admin/969850bfbc599cefbf51ee9d701cca3cb38e66e7/docs/task.png -------------------------------------------------------------------------------- /docs/welcome.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rancytech/mj-proxy-admin/969850bfbc599cefbf51ee9d701cca3cb38e66e7/docs/welcome.png -------------------------------------------------------------------------------- /jest.config.ts: -------------------------------------------------------------------------------- 1 | import { configUmiAlias, createConfig } from '@umijs/max/test'; 2 | 3 | export default async () => { 4 | const config = await configUmiAlias({ 5 | ...createConfig({ 6 | target: 'browser', 7 | }), 8 | }); 9 | 10 | console.log(); 11 | return { 12 | ...config, 13 | testEnvironmentOptions: { 14 | ...(config?.testEnvironmentOptions || {}), 15 | url: 'http://localhost:8000', 16 | }, 17 | setupFiles: [...(config.setupFiles || []), './tests/setupTests.jsx'], 18 | globals: { 19 | ...config.globals, 20 | localStorage: null, 21 | }, 22 | }; 23 | }; 24 | -------------------------------------------------------------------------------- /jsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "jsx": "react-jsx", 4 | "emitDecoratorMetadata": true, 5 | "experimentalDecorators": true, 6 | "baseUrl": ".", 7 | "paths": { 8 | "@/*": ["./src/*"] 9 | } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /mock/listTableList.ts: -------------------------------------------------------------------------------- 1 | import { Request, Response } from 'express'; 2 | import moment from 'moment'; 3 | import { parse } from 'url'; 4 | 5 | // mock tableListDataSource 6 | const genList = (current: number, pageSize: number) => { 7 | const tableListDataSource: API.RuleListItem[] = []; 8 | 9 | for (let i = 0; i < pageSize; i += 1) { 10 | const index = (current - 1) * 10 + i; 11 | tableListDataSource.push({ 12 | key: index, 13 | disabled: i % 6 === 0, 14 | href: 'https://ant.design', 15 | avatar: [ 16 | 'https://gw.alipayobjects.com/zos/rmsportal/eeHMaZBwmTvLdIwMfBpg.png', 17 | 'https://gw.alipayobjects.com/zos/rmsportal/udxAbMEhpwthVVcjLXik.png', 18 | ][i % 2], 19 | name: `TradeCode ${index}`, 20 | owner: '曲丽丽', 21 | desc: '这是一段描述', 22 | callNo: Math.floor(Math.random() * 1000), 23 | status: Math.floor(Math.random() * 10) % 4, 24 | updatedAt: moment().format('YYYY-MM-DD'), 25 | createdAt: moment().format('YYYY-MM-DD'), 26 | progress: Math.ceil(Math.random() * 100), 27 | }); 28 | } 29 | tableListDataSource.reverse(); 30 | return tableListDataSource; 31 | }; 32 | 33 | let tableListDataSource = genList(1, 100); 34 | 35 | function getRule(req: Request, res: Response, u: string) { 36 | let realUrl = u; 37 | if (!realUrl || Object.prototype.toString.call(realUrl) !== '[object String]') { 38 | realUrl = req.url; 39 | } 40 | const { current = 1, pageSize = 10 } = req.query; 41 | const params = parse(realUrl, true).query as unknown as API.PageParams & 42 | API.RuleListItem & { 43 | sorter: any; 44 | filter: any; 45 | }; 46 | 47 | let dataSource = [...tableListDataSource].slice( 48 | ((current as number) - 1) * (pageSize as number), 49 | (current as number) * (pageSize as number), 50 | ); 51 | if (params.sorter) { 52 | const sorter = JSON.parse(params.sorter); 53 | dataSource = dataSource.sort((prev, next) => { 54 | let sortNumber = 0; 55 | (Object.keys(sorter) as Array).forEach((key) => { 56 | let nextSort = next?.[key] as number; 57 | let preSort = prev?.[key] as number; 58 | if (sorter[key] === 'descend') { 59 | if (preSort - nextSort > 0) { 60 | sortNumber += -1; 61 | } else { 62 | sortNumber += 1; 63 | } 64 | return; 65 | } 66 | if (preSort - nextSort > 0) { 67 | sortNumber += 1; 68 | } else { 69 | sortNumber += -1; 70 | } 71 | }); 72 | return sortNumber; 73 | }); 74 | } 75 | if (params.filter) { 76 | const filter = JSON.parse(params.filter as any) as { 77 | [key: string]: string[]; 78 | }; 79 | if (Object.keys(filter).length > 0) { 80 | dataSource = dataSource.filter((item) => { 81 | return (Object.keys(filter) as Array).some((key) => { 82 | if (!filter[key]) { 83 | return true; 84 | } 85 | if (filter[key].includes(`${item[key]}`)) { 86 | return true; 87 | } 88 | return false; 89 | }); 90 | }); 91 | } 92 | } 93 | 94 | if (params.name) { 95 | dataSource = dataSource.filter((data) => data?.name?.includes(params.name || '')); 96 | } 97 | const result = { 98 | data: dataSource, 99 | total: tableListDataSource.length, 100 | success: true, 101 | pageSize, 102 | current: parseInt(`${params.current}`, 10) || 1, 103 | }; 104 | 105 | return res.json(result); 106 | } 107 | 108 | function postRule(req: Request, res: Response, u: string, b: Request) { 109 | let realUrl = u; 110 | if (!realUrl || Object.prototype.toString.call(realUrl) !== '[object String]') { 111 | realUrl = req.url; 112 | } 113 | 114 | const body = (b && b.body) || req.body; 115 | const { method, name, desc, key } = body; 116 | 117 | switch (method) { 118 | /* eslint no-case-declarations:0 */ 119 | case 'delete': 120 | tableListDataSource = tableListDataSource.filter((item) => key.indexOf(item.key) === -1); 121 | break; 122 | case 'post': 123 | (() => { 124 | const i = Math.ceil(Math.random() * 10000); 125 | const newRule: API.RuleListItem = { 126 | key: tableListDataSource.length, 127 | href: 'https://ant.design', 128 | avatar: [ 129 | 'https://gw.alipayobjects.com/zos/rmsportal/eeHMaZBwmTvLdIwMfBpg.png', 130 | 'https://gw.alipayobjects.com/zos/rmsportal/udxAbMEhpwthVVcjLXik.png', 131 | ][i % 2], 132 | name, 133 | owner: '曲丽丽', 134 | desc, 135 | callNo: Math.floor(Math.random() * 1000), 136 | status: Math.floor(Math.random() * 10) % 2, 137 | updatedAt: moment().format('YYYY-MM-DD'), 138 | createdAt: moment().format('YYYY-MM-DD'), 139 | progress: Math.ceil(Math.random() * 100), 140 | }; 141 | tableListDataSource.unshift(newRule); 142 | return res.json(newRule); 143 | })(); 144 | return; 145 | 146 | case 'update': 147 | (() => { 148 | let newRule = {}; 149 | tableListDataSource = tableListDataSource.map((item) => { 150 | if (item.key === key) { 151 | newRule = { ...item, desc, name }; 152 | return { ...item, desc, name }; 153 | } 154 | return item; 155 | }); 156 | return res.json(newRule); 157 | })(); 158 | return; 159 | default: 160 | break; 161 | } 162 | 163 | const result = { 164 | list: tableListDataSource, 165 | pagination: { 166 | total: tableListDataSource.length, 167 | }, 168 | }; 169 | 170 | res.json(result); 171 | } 172 | 173 | export default { 174 | 'GET /api/rule': getRule, 175 | 'POST /api/rule': postRule, 176 | }; 177 | -------------------------------------------------------------------------------- /mock/notices.ts: -------------------------------------------------------------------------------- 1 | import { Request, Response } from 'express'; 2 | 3 | const getNotices = (req: Request, res: Response) => { 4 | res.json({ 5 | data: [ 6 | { 7 | id: '000000001', 8 | avatar: 9 | 'https://mdn.alipayobjects.com/yuyan_qk0oxh/afts/img/MSbDR4FR2MUAAAAAAAAAAAAAFl94AQBr', 10 | title: '你收到了 14 份新周报', 11 | datetime: '2017-08-09', 12 | type: 'notification', 13 | }, 14 | { 15 | id: '000000002', 16 | avatar: 17 | 'https://mdn.alipayobjects.com/yuyan_qk0oxh/afts/img/hX-PTavYIq4AAAAAAAAAAAAAFl94AQBr', 18 | title: '你推荐的 曲妮妮 已通过第三轮面试', 19 | datetime: '2017-08-08', 20 | type: 'notification', 21 | }, 22 | { 23 | id: '000000003', 24 | avatar: 25 | 'https://mdn.alipayobjects.com/yuyan_qk0oxh/afts/img/jHX5R5l3QjQAAAAAAAAAAAAAFl94AQBr', 26 | title: '这种模板可以区分多种通知类型', 27 | datetime: '2017-08-07', 28 | read: true, 29 | type: 'notification', 30 | }, 31 | { 32 | id: '000000004', 33 | avatar: 34 | 'https://mdn.alipayobjects.com/yuyan_qk0oxh/afts/img/Wr4mQqx6jfwAAAAAAAAAAAAAFl94AQBr', 35 | title: '左侧图标用于区分不同的类型', 36 | datetime: '2017-08-07', 37 | type: 'notification', 38 | }, 39 | { 40 | id: '000000005', 41 | avatar: 42 | 'https://mdn.alipayobjects.com/yuyan_qk0oxh/afts/img/Mzj_TbcWUj4AAAAAAAAAAAAAFl94AQBr', 43 | title: '内容不要超过两行字,超出时自动截断', 44 | datetime: '2017-08-07', 45 | type: 'notification', 46 | }, 47 | { 48 | id: '000000006', 49 | avatar: 50 | 'https://mdn.alipayobjects.com/yuyan_qk0oxh/afts/img/eXLzRbPqQE4AAAAAAAAAAAAAFl94AQBr', 51 | title: '曲丽丽 评论了你', 52 | description: '描述信息描述信息描述信息', 53 | datetime: '2017-08-07', 54 | type: 'message', 55 | clickClose: true, 56 | }, 57 | { 58 | id: '000000007', 59 | avatar: 60 | 'https://mdn.alipayobjects.com/yuyan_qk0oxh/afts/img/w5mRQY2AmEEAAAAAAAAAAAAAFl94AQBr', 61 | title: '朱偏右 回复了你', 62 | description: '这种模板用于提醒谁与你发生了互动,左侧放『谁』的头像', 63 | datetime: '2017-08-07', 64 | type: 'message', 65 | clickClose: true, 66 | }, 67 | { 68 | id: '000000008', 69 | avatar: 70 | 'https://mdn.alipayobjects.com/yuyan_qk0oxh/afts/img/wPadR5M9918AAAAAAAAAAAAAFl94AQBr', 71 | title: '标题', 72 | description: '这种模板用于提醒谁与你发生了互动,左侧放『谁』的头像', 73 | datetime: '2017-08-07', 74 | type: 'message', 75 | clickClose: true, 76 | }, 77 | { 78 | id: '000000009', 79 | title: '任务名称', 80 | description: '任务需要在 2017-01-12 20:00 前启动', 81 | extra: '未开始', 82 | status: 'todo', 83 | type: 'event', 84 | }, 85 | { 86 | id: '000000010', 87 | title: '第三方紧急代码变更', 88 | description: '冠霖提交于 2017-01-06,需在 2017-01-07 前完成代码变更任务', 89 | extra: '马上到期', 90 | status: 'urgent', 91 | type: 'event', 92 | }, 93 | { 94 | id: '000000011', 95 | title: '信息安全考试', 96 | description: '指派竹尔于 2017-01-09 前完成更新并发布', 97 | extra: '已耗时 8 天', 98 | status: 'doing', 99 | type: 'event', 100 | }, 101 | { 102 | id: '000000012', 103 | title: 'ABCD 版本发布', 104 | description: '冠霖提交于 2017-01-06,需在 2017-01-07 前完成代码变更任务', 105 | extra: '进行中', 106 | status: 'processing', 107 | type: 'event', 108 | }, 109 | ], 110 | }); 111 | }; 112 | 113 | export default { 114 | 'GET /api/notices': getNotices, 115 | }; 116 | -------------------------------------------------------------------------------- /mock/requestRecord.mock.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | 'GET /api/currentUser': { 3 | data: { 4 | name: 'Serati Ma', 5 | avatar: 'https://gw.alipayobjects.com/zos/rmsportal/BiazfanxmamNRoxxVxka.png', 6 | userid: '00000001', 7 | email: 'antdesign@alipay.com', 8 | signature: '海纳百川,有容乃大', 9 | title: '交互专家', 10 | group: '蚂蚁金服-某某某事业群-某某平台部-某某技术部-UED', 11 | tags: [ 12 | { key: '0', label: '很有想法的' }, 13 | { key: '1', label: '专注设计' }, 14 | { key: '2', label: '辣~' }, 15 | { key: '3', label: '大长腿' }, 16 | { key: '4', label: '川妹子' }, 17 | { key: '5', label: '海纳百川' }, 18 | ], 19 | notifyCount: 12, 20 | unreadCount: 11, 21 | country: 'China', 22 | geographic: { 23 | province: { label: '浙江省', key: '330000' }, 24 | city: { label: '杭州市', key: '330100' }, 25 | }, 26 | address: '西湖区工专路 77 号', 27 | phone: '0752-268888888', 28 | }, 29 | }, 30 | 'GET /api/rule': { 31 | data: [ 32 | { 33 | key: 99, 34 | disabled: false, 35 | href: 'https://ant.design', 36 | avatar: 'https://gw.alipayobjects.com/zos/rmsportal/udxAbMEhpwthVVcjLXik.png', 37 | name: 'TradeCode 99', 38 | owner: '曲丽丽', 39 | desc: '这是一段描述', 40 | callNo: 503, 41 | status: '0', 42 | updatedAt: '2022-12-06T05:00:57.040Z', 43 | createdAt: '2022-12-06T05:00:57.040Z', 44 | progress: 81, 45 | }, 46 | { 47 | key: 98, 48 | disabled: false, 49 | href: 'https://ant.design', 50 | avatar: 'https://gw.alipayobjects.com/zos/rmsportal/eeHMaZBwmTvLdIwMfBpg.png', 51 | name: 'TradeCode 98', 52 | owner: '曲丽丽', 53 | desc: '这是一段描述', 54 | callNo: 164, 55 | status: '0', 56 | updatedAt: '2022-12-06T05:00:57.040Z', 57 | createdAt: '2022-12-06T05:00:57.040Z', 58 | progress: 12, 59 | }, 60 | { 61 | key: 97, 62 | disabled: false, 63 | href: 'https://ant.design', 64 | avatar: 'https://gw.alipayobjects.com/zos/rmsportal/udxAbMEhpwthVVcjLXik.png', 65 | name: 'TradeCode 97', 66 | owner: '曲丽丽', 67 | desc: '这是一段描述', 68 | callNo: 174, 69 | status: '1', 70 | updatedAt: '2022-12-06T05:00:57.040Z', 71 | createdAt: '2022-12-06T05:00:57.040Z', 72 | progress: 81, 73 | }, 74 | { 75 | key: 96, 76 | disabled: true, 77 | href: 'https://ant.design', 78 | avatar: 'https://gw.alipayobjects.com/zos/rmsportal/eeHMaZBwmTvLdIwMfBpg.png', 79 | name: 'TradeCode 96', 80 | owner: '曲丽丽', 81 | desc: '这是一段描述', 82 | callNo: 914, 83 | status: '0', 84 | updatedAt: '2022-12-06T05:00:57.040Z', 85 | createdAt: '2022-12-06T05:00:57.040Z', 86 | progress: 7, 87 | }, 88 | { 89 | key: 95, 90 | disabled: false, 91 | href: 'https://ant.design', 92 | avatar: 'https://gw.alipayobjects.com/zos/rmsportal/udxAbMEhpwthVVcjLXik.png', 93 | name: 'TradeCode 95', 94 | owner: '曲丽丽', 95 | desc: '这是一段描述', 96 | callNo: 698, 97 | status: '2', 98 | updatedAt: '2022-12-06T05:00:57.040Z', 99 | createdAt: '2022-12-06T05:00:57.040Z', 100 | progress: 82, 101 | }, 102 | { 103 | key: 94, 104 | disabled: false, 105 | href: 'https://ant.design', 106 | avatar: 'https://gw.alipayobjects.com/zos/rmsportal/eeHMaZBwmTvLdIwMfBpg.png', 107 | name: 'TradeCode 94', 108 | owner: '曲丽丽', 109 | desc: '这是一段描述', 110 | callNo: 488, 111 | status: '1', 112 | updatedAt: '2022-12-06T05:00:57.040Z', 113 | createdAt: '2022-12-06T05:00:57.040Z', 114 | progress: 14, 115 | }, 116 | { 117 | key: 93, 118 | disabled: false, 119 | href: 'https://ant.design', 120 | avatar: 'https://gw.alipayobjects.com/zos/rmsportal/udxAbMEhpwthVVcjLXik.png', 121 | name: 'TradeCode 93', 122 | owner: '曲丽丽', 123 | desc: '这是一段描述', 124 | callNo: 580, 125 | status: '2', 126 | updatedAt: '2022-12-06T05:00:57.040Z', 127 | createdAt: '2022-12-06T05:00:57.040Z', 128 | progress: 77, 129 | }, 130 | { 131 | key: 92, 132 | disabled: false, 133 | href: 'https://ant.design', 134 | avatar: 'https://gw.alipayobjects.com/zos/rmsportal/eeHMaZBwmTvLdIwMfBpg.png', 135 | name: 'TradeCode 92', 136 | owner: '曲丽丽', 137 | desc: '这是一段描述', 138 | callNo: 244, 139 | status: '3', 140 | updatedAt: '2022-12-06T05:00:57.040Z', 141 | createdAt: '2022-12-06T05:00:57.040Z', 142 | progress: 58, 143 | }, 144 | { 145 | key: 91, 146 | disabled: false, 147 | href: 'https://ant.design', 148 | avatar: 'https://gw.alipayobjects.com/zos/rmsportal/udxAbMEhpwthVVcjLXik.png', 149 | name: 'TradeCode 91', 150 | owner: '曲丽丽', 151 | desc: '这是一段描述', 152 | callNo: 959, 153 | status: '0', 154 | updatedAt: '2022-12-06T05:00:57.040Z', 155 | createdAt: '2022-12-06T05:00:57.040Z', 156 | progress: 66, 157 | }, 158 | { 159 | key: 90, 160 | disabled: true, 161 | href: 'https://ant.design', 162 | avatar: 'https://gw.alipayobjects.com/zos/rmsportal/eeHMaZBwmTvLdIwMfBpg.png', 163 | name: 'TradeCode 90', 164 | owner: '曲丽丽', 165 | desc: '这是一段描述', 166 | callNo: 958, 167 | status: '0', 168 | updatedAt: '2022-12-06T05:00:57.040Z', 169 | createdAt: '2022-12-06T05:00:57.040Z', 170 | progress: 72, 171 | }, 172 | { 173 | key: 89, 174 | disabled: false, 175 | href: 'https://ant.design', 176 | avatar: 'https://gw.alipayobjects.com/zos/rmsportal/udxAbMEhpwthVVcjLXik.png', 177 | name: 'TradeCode 89', 178 | owner: '曲丽丽', 179 | desc: '这是一段描述', 180 | callNo: 301, 181 | status: '2', 182 | updatedAt: '2022-12-06T05:00:57.040Z', 183 | createdAt: '2022-12-06T05:00:57.040Z', 184 | progress: 2, 185 | }, 186 | { 187 | key: 88, 188 | disabled: false, 189 | href: 'https://ant.design', 190 | avatar: 'https://gw.alipayobjects.com/zos/rmsportal/eeHMaZBwmTvLdIwMfBpg.png', 191 | name: 'TradeCode 88', 192 | owner: '曲丽丽', 193 | desc: '这是一段描述', 194 | callNo: 277, 195 | status: '1', 196 | updatedAt: '2022-12-06T05:00:57.040Z', 197 | createdAt: '2022-12-06T05:00:57.040Z', 198 | progress: 12, 199 | }, 200 | { 201 | key: 87, 202 | disabled: false, 203 | href: 'https://ant.design', 204 | avatar: 'https://gw.alipayobjects.com/zos/rmsportal/udxAbMEhpwthVVcjLXik.png', 205 | name: 'TradeCode 87', 206 | owner: '曲丽丽', 207 | desc: '这是一段描述', 208 | callNo: 810, 209 | status: '1', 210 | updatedAt: '2022-12-06T05:00:57.040Z', 211 | createdAt: '2022-12-06T05:00:57.040Z', 212 | progress: 82, 213 | }, 214 | { 215 | key: 86, 216 | disabled: false, 217 | href: 'https://ant.design', 218 | avatar: 'https://gw.alipayobjects.com/zos/rmsportal/eeHMaZBwmTvLdIwMfBpg.png', 219 | name: 'TradeCode 86', 220 | owner: '曲丽丽', 221 | desc: '这是一段描述', 222 | callNo: 780, 223 | status: '3', 224 | updatedAt: '2022-12-06T05:00:57.040Z', 225 | createdAt: '2022-12-06T05:00:57.040Z', 226 | progress: 22, 227 | }, 228 | { 229 | key: 85, 230 | disabled: false, 231 | href: 'https://ant.design', 232 | avatar: 'https://gw.alipayobjects.com/zos/rmsportal/udxAbMEhpwthVVcjLXik.png', 233 | name: 'TradeCode 85', 234 | owner: '曲丽丽', 235 | desc: '这是一段描述', 236 | callNo: 705, 237 | status: '3', 238 | updatedAt: '2022-12-06T05:00:57.040Z', 239 | createdAt: '2022-12-06T05:00:57.040Z', 240 | progress: 12, 241 | }, 242 | { 243 | key: 84, 244 | disabled: true, 245 | href: 'https://ant.design', 246 | avatar: 'https://gw.alipayobjects.com/zos/rmsportal/eeHMaZBwmTvLdIwMfBpg.png', 247 | name: 'TradeCode 84', 248 | owner: '曲丽丽', 249 | desc: '这是一段描述', 250 | callNo: 203, 251 | status: '0', 252 | updatedAt: '2022-12-06T05:00:57.040Z', 253 | createdAt: '2022-12-06T05:00:57.040Z', 254 | progress: 79, 255 | }, 256 | { 257 | key: 83, 258 | disabled: false, 259 | href: 'https://ant.design', 260 | avatar: 'https://gw.alipayobjects.com/zos/rmsportal/udxAbMEhpwthVVcjLXik.png', 261 | name: 'TradeCode 83', 262 | owner: '曲丽丽', 263 | desc: '这是一段描述', 264 | callNo: 491, 265 | status: '2', 266 | updatedAt: '2022-12-06T05:00:57.040Z', 267 | createdAt: '2022-12-06T05:00:57.040Z', 268 | progress: 59, 269 | }, 270 | { 271 | key: 82, 272 | disabled: false, 273 | href: 'https://ant.design', 274 | avatar: 'https://gw.alipayobjects.com/zos/rmsportal/eeHMaZBwmTvLdIwMfBpg.png', 275 | name: 'TradeCode 82', 276 | owner: '曲丽丽', 277 | desc: '这是一段描述', 278 | callNo: 73, 279 | status: '0', 280 | updatedAt: '2022-12-06T05:00:57.040Z', 281 | createdAt: '2022-12-06T05:00:57.040Z', 282 | progress: 100, 283 | }, 284 | { 285 | key: 81, 286 | disabled: false, 287 | href: 'https://ant.design', 288 | avatar: 'https://gw.alipayobjects.com/zos/rmsportal/udxAbMEhpwthVVcjLXik.png', 289 | name: 'TradeCode 81', 290 | owner: '曲丽丽', 291 | desc: '这是一段描述', 292 | callNo: 406, 293 | status: '3', 294 | updatedAt: '2022-12-06T05:00:57.040Z', 295 | createdAt: '2022-12-06T05:00:57.040Z', 296 | progress: 61, 297 | }, 298 | { 299 | key: 80, 300 | disabled: false, 301 | href: 'https://ant.design', 302 | avatar: 'https://gw.alipayobjects.com/zos/rmsportal/eeHMaZBwmTvLdIwMfBpg.png', 303 | name: 'TradeCode 80', 304 | owner: '曲丽丽', 305 | desc: '这是一段描述', 306 | callNo: 112, 307 | status: '2', 308 | updatedAt: '2022-12-06T05:00:57.040Z', 309 | createdAt: '2022-12-06T05:00:57.040Z', 310 | progress: 20, 311 | }, 312 | ], 313 | total: 100, 314 | success: true, 315 | pageSize: 20, 316 | current: 1, 317 | }, 318 | 'POST /api/login/outLogin': { data: {}, success: true }, 319 | 'POST /api/login/account': { 320 | status: 'ok', 321 | type: 'account', 322 | currentAuthority: 'admin', 323 | }, 324 | }; 325 | -------------------------------------------------------------------------------- /mock/route.ts: -------------------------------------------------------------------------------- 1 | export default { 2 | '/api/auth_routes': { 3 | '/form/advanced-form': { authority: ['admin', 'user'] }, 4 | }, 5 | }; 6 | -------------------------------------------------------------------------------- /mock/user.ts: -------------------------------------------------------------------------------- 1 | import { Request, Response } from 'express'; 2 | 3 | const adminName = process.env.ADMIN_NAME; 4 | const passWord = process.env.PASS_WORD; 5 | 6 | const waitTime = (time: number = 100) => { 7 | return new Promise((resolve) => { 8 | setTimeout(() => { 9 | resolve(true); 10 | }, time); 11 | }); 12 | }; 13 | 14 | async function getFakeCaptcha(req: Request, res: Response) { 15 | await waitTime(2000); 16 | return res.json('captcha-xxx'); 17 | } 18 | 19 | const { ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION } = process.env; 20 | 21 | /** 22 | * 当前用户的权限,如果为空代表没登录 23 | * current user access, if is '', user need login 24 | * 如果是 pro 的预览,默认是有权限的 25 | */ 26 | let access = ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION === 'site' ? 'admin' : ''; 27 | 28 | const getAccess = () => { 29 | return access; 30 | }; 31 | 32 | // 代码中会兼容本地 service mock 以及部署站点的静态数据 33 | export default { 34 | // 支持值为 Object 和 Array 35 | 'GET /api/currentUser': (req: Request, res: Response) => { 36 | if (!getAccess()) { 37 | res.status(401).send({ 38 | data: { 39 | isLogin: false, 40 | }, 41 | errorCode: '401', 42 | errorMessage: '请先登录!', 43 | success: true, 44 | }); 45 | return; 46 | } 47 | res.send({ 48 | success: true, 49 | data: { 50 | name: adminName, 51 | avatar: 'https://gw.alipayobjects.com/zos/antfincdn/XAosXuNZyF/BiazfanxmamNRoxxVxka.png', 52 | userid: '00000001', 53 | email: 'antdesign@alipay.com', 54 | signature: '海纳百川,有容乃大', 55 | title: '交互专家', 56 | group: '蚂蚁金服-某某某事业群-某某平台部-某某技术部-UED', 57 | tags: [ 58 | { 59 | key: '0', 60 | label: '很有想法的', 61 | }, 62 | { 63 | key: '1', 64 | label: '专注设计', 65 | }, 66 | { 67 | key: '2', 68 | label: '辣~', 69 | }, 70 | { 71 | key: '3', 72 | label: '大长腿', 73 | }, 74 | { 75 | key: '4', 76 | label: '川妹子', 77 | }, 78 | { 79 | key: '5', 80 | label: '海纳百川', 81 | }, 82 | ], 83 | notifyCount: 12, 84 | unreadCount: 11, 85 | country: 'China', 86 | access: getAccess(), 87 | geographic: { 88 | province: { 89 | label: '浙江省', 90 | key: '330000', 91 | }, 92 | city: { 93 | label: '杭州市', 94 | key: '330100', 95 | }, 96 | }, 97 | address: '西湖区工专路 77 号', 98 | phone: '0752-268888888', 99 | }, 100 | }); 101 | }, 102 | // GET POST 可省略 103 | 'GET /api/users': [ 104 | { 105 | key: '1', 106 | name: 'John Brown', 107 | age: 32, 108 | address: 'New York No. 1 Lake Park', 109 | }, 110 | { 111 | key: '2', 112 | name: 'Jim Green', 113 | age: 42, 114 | address: 'London No. 1 Lake Park', 115 | }, 116 | { 117 | key: '3', 118 | name: 'Joe Black', 119 | age: 32, 120 | address: 'Sidney No. 1 Lake Park', 121 | }, 122 | ], 123 | 'POST /api/login/account': async (req: Request, res: Response) => { 124 | const { password, username, type } = req.body; 125 | await waitTime(2000); 126 | if (password === password && username === adminName) { 127 | res.send({ 128 | status: 'ok', 129 | type, 130 | currentAuthority: 'admin', 131 | }); 132 | access = 'admin'; 133 | return; 134 | } 135 | res.send({ 136 | status: 'error', 137 | type, 138 | currentAuthority: 'guest', 139 | }); 140 | access = 'guest'; 141 | }, 142 | 'POST /api/login/outLogin': (req: Request, res: Response) => { 143 | access = ''; 144 | res.send({ data: {}, success: true }); 145 | }, 146 | 'POST /api/register': (req: Request, res: Response) => { 147 | res.send({ status: 'ok', currentAuthority: 'user', success: true }); 148 | }, 149 | 'GET /api/500': (req: Request, res: Response) => { 150 | res.status(500).send({ 151 | timestamp: 1513932555104, 152 | status: 500, 153 | error: 'error', 154 | message: 'error', 155 | path: '/base/category/list', 156 | }); 157 | }, 158 | 'GET /api/404': (req: Request, res: Response) => { 159 | res.status(404).send({ 160 | timestamp: 1513932643431, 161 | status: 404, 162 | error: 'Not Found', 163 | message: 'No message available', 164 | path: '/base/category/list/2121212', 165 | }); 166 | }, 167 | 'GET /api/403': (req: Request, res: Response) => { 168 | res.status(403).send({ 169 | timestamp: 1513932555104, 170 | status: 403, 171 | error: 'Forbidden', 172 | message: 'Forbidden', 173 | path: '/base/category/list', 174 | }); 175 | }, 176 | 'GET /api/401': (req: Request, res: Response) => { 177 | res.status(401).send({ 178 | timestamp: 1513932555104, 179 | status: 401, 180 | error: 'Unauthorized', 181 | message: 'Unauthorized', 182 | path: '/base/category/list', 183 | }); 184 | }, 185 | 186 | 'GET /api/login/captcha': getFakeCaptcha, 187 | }; 188 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "midjourney-proxy-admin", 3 | "version": "1.0", 4 | "private": true, 5 | "description": "An out-of-box UI solution for enterprise applications", 6 | "scripts": { 7 | "analyze": "cross-env ANALYZE=1 max build", 8 | "build": "max build", 9 | "deploy": "npm run build && npm run gh-pages", 10 | "dev": "npm run start:dev", 11 | "gh-pages": "gh-pages -d dist", 12 | "i18n-remove": "pro i18n-remove --locale=zh-CN --write", 13 | "postinstall": "max setup", 14 | "jest": "jest", 15 | "lint": "npm run lint:js && npm run lint:prettier && npm run tsc", 16 | "lint-staged": "lint-staged", 17 | "lint-staged:js": "eslint --ext .js,.jsx,.ts,.tsx ", 18 | "lint:fix": "eslint --fix --cache --ext .js,.jsx,.ts,.tsx --format=pretty ./src ", 19 | "lint:js": "eslint --cache --ext .js,.jsx,.ts,.tsx --format=pretty ./src", 20 | "lint:prettier": "prettier -c --write \"**/**.{js,jsx,tsx,ts,less,md,json}\" --end-of-line auto", 21 | "openapi": "max openapi", 22 | "prettier": "prettier -c --write \"**/**.{js,jsx,tsx,ts,less,md,json}\"", 23 | "preview": "npm run build && max preview --port 8000", 24 | "record": "cross-env NODE_ENV=development REACT_APP_ENV=test max record --scene=login", 25 | "serve": "umi-serve", 26 | "start": "cross-env UMI_ENV=dev max dev", 27 | "start:dev": "cross-env REACT_APP_ENV=dev MOCK=none UMI_ENV=dev max dev", 28 | "start:no-mock": "cross-env MOCK=none UMI_ENV=dev max dev", 29 | "start:pre": "cross-env REACT_APP_ENV=pre UMI_ENV=dev max dev", 30 | "start:test": "cross-env REACT_APP_ENV=test MOCK=none UMI_ENV=dev max dev", 31 | "test": "jest", 32 | "test:coverage": "npm run jest -- --coverage", 33 | "test:update": "npm run jest -- -u", 34 | "tsc": "tsc --noEmit" 35 | }, 36 | "lint-staged": { 37 | "**/*.{js,jsx,ts,tsx}": "npm run lint-staged:js", 38 | "**/*.{js,jsx,tsx,ts,less,md,json}": [ 39 | "prettier --write" 40 | ] 41 | }, 42 | "browserslist": [ 43 | "> 1%", 44 | "last 2 versions", 45 | "not ie <= 10" 46 | ], 47 | "dependencies": { 48 | "@ant-design/icons": "^4.8.0", 49 | "@ant-design/pro-components": "^2.3.57", 50 | "@ant-design/use-emotion-css": "1.0.4", 51 | "@umijs/route-utils": "^2.2.2", 52 | "antd": "^5.2.2", 53 | "classnames": "^2.3.2", 54 | "lodash": "^4.17.21", 55 | "moment": "^2.29.4", 56 | "omit.js": "^2.0.2", 57 | "rc-menu": "^9.8.2", 58 | "rc-util": "^5.27.2", 59 | "react": "^18.2.0", 60 | "react-dev-inspector": "^1.8.4", 61 | "react-dom": "^18.2.0", 62 | "react-helmet-async": "^1.3.0" 63 | }, 64 | "devDependencies": { 65 | "@ant-design/pro-cli": "^2.1.5", 66 | "@testing-library/react": "^13.4.0", 67 | "@types/classnames": "^2.3.1", 68 | "@types/express": "^4.17.17", 69 | "@types/history": "^4.7.11", 70 | "@types/jest": "^29.4.0", 71 | "@types/lodash": "^4.14.191", 72 | "@types/react": "^18.0.28", 73 | "@types/react-dom": "^18.0.11", 74 | "@types/react-helmet": "^6.1.6", 75 | "@umijs/fabric": "^2.14.1", 76 | "@umijs/lint": "^4.0.52", 77 | "@umijs/max": "^4.0.52", 78 | "cross-env": "^7.0.3", 79 | "eslint": "^8.34.0", 80 | "express": "^4.18.2", 81 | "gh-pages": "^3.2.3", 82 | "husky": "^7.0.4", 83 | "jest": "^29.4.3", 84 | "jest-environment-jsdom": "^29.4.3", 85 | "lint-staged": "^10.5.4", 86 | "mockjs": "^1.1.0", 87 | "prettier": "^2.8.4", 88 | "swagger-ui-dist": "^4.15.5", 89 | "ts-node": "^10.9.1", 90 | "typescript": "^4.9.5", 91 | "umi-presets-pro": "^2.0.2" 92 | }, 93 | "engines": { 94 | "node": ">=12.0.0" 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /public/CNAME: -------------------------------------------------------------------------------- 1 | preview.pro.ant.design -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rancytech/mj-proxy-admin/969850bfbc599cefbf51ee9d701cca3cb38e66e7/public/favicon.ico -------------------------------------------------------------------------------- /public/icons/icon-128x128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rancytech/mj-proxy-admin/969850bfbc599cefbf51ee9d701cca3cb38e66e7/public/icons/icon-128x128.png -------------------------------------------------------------------------------- /public/icons/icon-192x192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rancytech/mj-proxy-admin/969850bfbc599cefbf51ee9d701cca3cb38e66e7/public/icons/icon-192x192.png -------------------------------------------------------------------------------- /public/icons/icon-512x512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rancytech/mj-proxy-admin/969850bfbc599cefbf51ee9d701cca3cb38e66e7/public/icons/icon-512x512.png -------------------------------------------------------------------------------- /public/logo.svg: -------------------------------------------------------------------------------- 1 | Group 28 Copy 5Created with Sketch. -------------------------------------------------------------------------------- /public/pro_icon.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /public/scripts/loading.js: -------------------------------------------------------------------------------- 1 | /** 2 | * loading 占位 3 | * 解决首次加载时白屏的问题 4 | */ 5 | (function () { 6 | const _root = document.querySelector('#root'); 7 | if (_root && _root.innerHTML === '') { 8 | _root.innerHTML = ` 9 | 174 | 175 |
183 |
184 |
185 | 186 | 187 | 188 | 189 | 190 | 191 |
192 |
193 |
194 | 正在加载资源 195 |
196 |
197 | 初次加载资源可能需要较多时间 请耐心等待 198 |
199 |
200 | `; 201 | } 202 | })(); 203 | -------------------------------------------------------------------------------- /src/access.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @see https://umijs.org/zh-CN/plugins/plugin-access 3 | * */ 4 | export default function access(initialState: { currentUser?: API.CurrentUser } | undefined) { 5 | const { currentUser } = initialState ?? {}; 6 | return { 7 | canAdmin: currentUser && currentUser.access === 'admin', 8 | }; 9 | } 10 | -------------------------------------------------------------------------------- /src/app.tsx: -------------------------------------------------------------------------------- 1 | import Footer from '@/components/Footer'; 2 | import { SelectLang } from '@/components/RightContent'; 3 | import type { Settings as LayoutSettings } from '@ant-design/pro-components'; 4 | import { SettingDrawer } from '@ant-design/pro-components'; 5 | import type { RunTimeLayoutConfig } from '@umijs/max'; 6 | import { history } from '@umijs/max'; 7 | import defaultSettings from '../config/defaultSettings'; 8 | import { AvatarDropdown, AvatarName } from './components/RightContent/AvatarDropdown'; 9 | import { errorConfig } from './requestErrorConfig'; 10 | import { currentUser as queryCurrentUser } from './services/ant-design-pro/api'; 11 | const isDev = process.env.NODE_ENV === 'development'; 12 | const loginPath = '/user/login'; 13 | 14 | /** 15 | * @see https://umijs.org/zh-CN/plugins/plugin-initial-state 16 | * */ 17 | export async function getInitialState(): Promise<{ 18 | settings?: Partial; 19 | currentUser?: API.CurrentUser; 20 | loading?: boolean; 21 | fetchUserInfo?: () => Promise; 22 | }> { 23 | const fetchUserInfo = async () => { 24 | try { 25 | const msg = await queryCurrentUser({ 26 | skipErrorHandler: true, 27 | }); 28 | return msg.data; 29 | } catch (error) { 30 | history.push(loginPath); 31 | } 32 | return undefined; 33 | }; 34 | // 如果不是登录页面,执行 35 | const { location } = history; 36 | if (location.pathname !== loginPath) { 37 | const currentUser = await fetchUserInfo(); 38 | return { 39 | fetchUserInfo, 40 | currentUser, 41 | settings: defaultSettings as Partial, 42 | }; 43 | } 44 | return { 45 | fetchUserInfo, 46 | settings: defaultSettings as Partial, 47 | }; 48 | } 49 | 50 | // ProLayout 支持的api https://procomponents.ant.design/components/layout 51 | export const layout: RunTimeLayoutConfig = ({ initialState, setInitialState }) => { 52 | return { 53 | actionsRender: () => [], 54 | avatarProps: { 55 | src: initialState?.currentUser?.avatar, 56 | title: , 57 | render: (_, avatarChildren) => { 58 | return {avatarChildren}; 59 | }, 60 | }, 61 | waterMarkProps: { 62 | content: initialState?.currentUser?.name, 63 | }, 64 | footerRender: () =>