1.整合后端,调整目录结构 2.编写README
@@ -0,0 +1,45 @@
|
|||||||
|
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
|
||||||
|
|
||||||
|
# dependencies
|
||||||
|
**/node
|
||||||
|
**/node_modules
|
||||||
|
# roadhog-api-doc ignore
|
||||||
|
/src/utils/request-temp.js
|
||||||
|
_roadhog-api-doc
|
||||||
|
|
||||||
|
# production
|
||||||
|
**/dist
|
||||||
|
|
||||||
|
|
||||||
|
# misc
|
||||||
|
.DS_Store
|
||||||
|
npm-debug.log*
|
||||||
|
yarn-error.log
|
||||||
|
|
||||||
|
/coverage
|
||||||
|
.idea
|
||||||
|
yarn.lock
|
||||||
|
package-lock.json
|
||||||
|
pnpm-lock.yaml
|
||||||
|
*bak
|
||||||
|
|
||||||
|
|
||||||
|
# visual studio code
|
||||||
|
.vscode
|
||||||
|
.history
|
||||||
|
*.log
|
||||||
|
functions/*
|
||||||
|
.temp/**
|
||||||
|
|
||||||
|
# umi
|
||||||
|
.umi
|
||||||
|
.umi-production
|
||||||
|
|
||||||
|
# screenshot
|
||||||
|
screenshot
|
||||||
|
.firebase
|
||||||
|
.eslintcache
|
||||||
|
|
||||||
|
# maven
|
||||||
|
target
|
||||||
|
build
|
||||||
@@ -0,0 +1,76 @@
|
|||||||
|
# Central-Platform UI
|
||||||
|
|
||||||
|
本模块是基于`企业级微服务框架`后端 API 所开发的前端项目。
|
||||||
|
|
||||||
|
采用[Ant Design Pro](https://pro.ant.design/)框架,基于[UmiJS v3.x](https://v3.umijs.org/)和[ProComponents](https://procomponents.ant.design/);
|
||||||
|
图表采用[Ant Design Charts](https://charts.ant.design/)。
|
||||||
|
|
||||||
|
## 1.目录说明
|
||||||
|
考虑到部署方便,集成了SpringBootWeb,目录结构基于Maven规范。
|
||||||
|
```lua
|
||||||
|
zlt-web -- 前端一级工程
|
||||||
|
│ ├─src -- 源码
|
||||||
|
│ │ ├─main --
|
||||||
|
│ │ │ ├─frontend -- 前端源码
|
||||||
|
│ │ │ ├─java -- 后端源码
|
||||||
|
```
|
||||||
|
## 2.后端使用说明
|
||||||
|
模块已集成Maven插件`frontend-maven-plugin`用于编译前端代码
|
||||||
|
>由于需要安装前端环境并编译前端代码,首次运行需要时间较长
|
||||||
|
### 打包运行
|
||||||
|
```bash
|
||||||
|
mvn package
|
||||||
|
```
|
||||||
|
在target目录下生成zlt-web-5.4.0.jar(springboot jar)。
|
||||||
|
```bash
|
||||||
|
java -jar zlt-web-5.4.0.jar
|
||||||
|
```
|
||||||
|
|
||||||
|
### IDE中运行
|
||||||
|
|
||||||
|
如在本地开发,在运行`SpringBootApplication`前必须先执行
|
||||||
|
```bash
|
||||||
|
mvn compile
|
||||||
|
```
|
||||||
|
|
||||||
|
### 配置
|
||||||
|
前缀:`zlt.ui`
|
||||||
|
|
||||||
|
| 配置项 | 类型 | 是否必须 | 默认值 | 说明 |
|
||||||
|
|--------------|--------|------|-----|-------|
|
||||||
|
| path-context | String | 否 | "/" | 上下文路径 |
|
||||||
|
|
||||||
|
## 3.前端使用说明
|
||||||
|
所有前端代码在`frontend`目录下。
|
||||||
|
### 环境准备
|
||||||
|
|
||||||
|
安装 `node_modules`:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm install
|
||||||
|
```
|
||||||
|
|
||||||
|
or
|
||||||
|
|
||||||
|
```bash
|
||||||
|
yarn
|
||||||
|
```
|
||||||
|
|
||||||
|
### 运行项目
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm start
|
||||||
|
```
|
||||||
|
|
||||||
|
### 编译项目
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm run build
|
||||||
|
```
|
||||||
|
### More
|
||||||
|
开发参考
|
||||||
|
* [Ant Design Pro](https://pro.ant.design/) 开箱即用的中台前端/设计解决方案
|
||||||
|
* [UmiJS v3.x](https://v3.umijs.org/) 可扩展的企业级前端应用框架
|
||||||
|
* [Ant Design](https://ant.design/index-cn) 基于 Ant Design 设计体系的 React UI 组件库
|
||||||
|
* [ProComponents](https://procomponents.ant.design/) 基于 Ant Design 设计规范,提供更高程度的抽象,提供更上层的设计规范
|
||||||
|
* [Ant Design Charts](https://charts.ant.design/) 简单好用的 React 图表库
|
||||||
@@ -1,17 +1,122 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>com.zlt</groupId>
|
<groupId>com.zlt</groupId>
|
||||||
<artifactId>central-platform</artifactId>
|
<artifactId>central-platform</artifactId>
|
||||||
<version>5.4.0</version>
|
<version>5.4.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<artifactId>zlt-web</artifactId>
|
<artifactId>zlt-web</artifactId>
|
||||||
<description>前端</description>
|
<description>前端</description>
|
||||||
<packaging>pom</packaging>
|
|
||||||
<modules>
|
<properties>
|
||||||
<module>back-web</module>
|
<node.version>v16.13.2</node.version>
|
||||||
</modules>
|
<yarn.version>v1.22.19</yarn.version>
|
||||||
|
</properties>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-web</artifactId>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>com.github.eirslett</groupId>
|
||||||
|
<artifactId>frontend-maven-plugin</artifactId>
|
||||||
|
<version>1.12.1</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>install node and yarn</id>
|
||||||
|
<goals>
|
||||||
|
<goal>install-node-and-yarn</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<nodeVersion>${node.version}</nodeVersion>
|
||||||
|
<yarnVersion>${yarn.version}</yarnVersion>
|
||||||
|
<installDirectory>src/main/frontend</installDirectory>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
<execution>
|
||||||
|
<id>yarn install</id>
|
||||||
|
<phase>generate-resources</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>yarn</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<arguments>install</arguments>
|
||||||
|
<workingDirectory>src/main/frontend</workingDirectory>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
<execution>
|
||||||
|
<id>yarn run build</id>
|
||||||
|
<phase>compile</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>yarn</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<arguments>run build</arguments>
|
||||||
|
<workingDirectory>src/main/frontend</workingDirectory>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-resources-plugin</artifactId>
|
||||||
|
<version>3.3.0</version>
|
||||||
|
<configuration>
|
||||||
|
<includeEmptyDirs>true</includeEmptyDirs>
|
||||||
|
</configuration>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>copy</id>
|
||||||
|
<phase>compile</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>resources</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<goals>
|
||||||
|
<goal>repackage</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
<resources>
|
||||||
|
<resource>
|
||||||
|
<directory>src/main/resources</directory>
|
||||||
|
</resource>
|
||||||
|
<resource>
|
||||||
|
<directory>src/main/frontend/dist</directory>
|
||||||
|
<targetPath>META-INF/central-platform-ui</targetPath>
|
||||||
|
<filtering>false</filtering>
|
||||||
|
</resource>
|
||||||
|
</resources>
|
||||||
|
</build>
|
||||||
|
<profiles>
|
||||||
|
<profile>
|
||||||
|
<id>noNode</id>
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>com.github.eirslett</groupId>
|
||||||
|
<artifactId>frontend-maven-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<skip>true</skip>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</profile>
|
||||||
|
</profiles>
|
||||||
</project>
|
</project>
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
# http://editorconfig.org
|
||||||
|
root = true
|
||||||
|
|
||||||
|
[*]
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 2
|
||||||
|
end_of_line = lf
|
||||||
|
charset = utf-8
|
||||||
|
trim_trailing_whitespace = true
|
||||||
|
insert_final_newline = true
|
||||||
|
|
||||||
|
[*.md]
|
||||||
|
trim_trailing_whitespace = false
|
||||||
|
|
||||||
|
[Makefile]
|
||||||
|
indent_style = tab
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
/lambda/
|
||||||
|
/scripts
|
||||||
|
/config
|
||||||
|
.history
|
||||||
|
public
|
||||||
|
dist
|
||||||
|
.umi
|
||||||
|
mock
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
module.exports = {
|
||||||
|
extends: [require.resolve('@umijs/fabric/dist/eslint')],
|
||||||
|
globals: {
|
||||||
|
ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION: true,
|
||||||
|
page: true,
|
||||||
|
REACT_APP_ENV: true,
|
||||||
|
},
|
||||||
|
};
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
**/*.svg
|
||||||
|
package.json
|
||||||
|
.umi
|
||||||
|
.umi-production
|
||||||
|
/dist
|
||||||
|
.dockerignore
|
||||||
|
.DS_Store
|
||||||
|
.eslintignore
|
||||||
|
*.png
|
||||||
|
*.toml
|
||||||
|
docker
|
||||||
|
.editorconfig
|
||||||
|
Dockerfile*
|
||||||
|
.gitignore
|
||||||
|
.prettierignore
|
||||||
|
LICENSE
|
||||||
|
.eslintcache
|
||||||
|
*.lock
|
||||||
|
yarn-error.log
|
||||||
|
.history
|
||||||
|
CNAME
|
||||||
|
/build
|
||||||
|
/public
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
const fabric = require('@umijs/fabric');
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
...fabric.prettier,
|
||||||
|
};
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
module.exports = {
|
||||||
|
extends: [require.resolve('@umijs/fabric/dist/stylelint')],
|
||||||
|
};
|
||||||
@@ -0,0 +1,59 @@
|
|||||||
|
# Central-Platform UI
|
||||||
|
|
||||||
|
这个项目是基于`企业级微服务框架`后端 API 所开发的前端代码。
|
||||||
|
|
||||||
|
技术采用
|
||||||
|
|
||||||
|
## Environment Prepare
|
||||||
|
|
||||||
|
Install `node_modules`:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm install
|
||||||
|
```
|
||||||
|
|
||||||
|
or
|
||||||
|
|
||||||
|
```bash
|
||||||
|
yarn
|
||||||
|
```
|
||||||
|
|
||||||
|
## Provided Scripts
|
||||||
|
|
||||||
|
Ant Design Pro provides some useful script to help you quick start and build with web project, code style check and test.
|
||||||
|
|
||||||
|
Scripts provided in `package.json`. It's safe to modify or add additional script:
|
||||||
|
|
||||||
|
### Start project
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm start
|
||||||
|
```
|
||||||
|
|
||||||
|
### Build project
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm run build
|
||||||
|
```
|
||||||
|
|
||||||
|
### Check code style
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm run lint
|
||||||
|
```
|
||||||
|
|
||||||
|
You can also use script to auto fix some lint error:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm run lint:fix
|
||||||
|
```
|
||||||
|
|
||||||
|
### Test code
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm test
|
||||||
|
```
|
||||||
|
|
||||||
|
## More
|
||||||
|
|
||||||
|
You can view full document on our [official website](https://pro.ant.design). And welcome any feedback in our [github](https://github.com/ant-design/ant-design-pro).
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
// https://umijs.org/config/
|
||||||
|
import { defineConfig } from 'umi';
|
||||||
|
|
||||||
|
export default defineConfig({
|
||||||
|
plugins: [
|
||||||
|
// https://github.com/zthxxx/react-dev-inspector
|
||||||
|
'react-dev-inspector/plugins/umi/react-inspector',
|
||||||
|
],
|
||||||
|
// https://github.com/zthxxx/react-dev-inspector#inspector-loader-props
|
||||||
|
inspectorConfig: {
|
||||||
|
exclude: [],
|
||||||
|
babelPlugins: [],
|
||||||
|
babelOptions: {},
|
||||||
|
},
|
||||||
|
});
|
||||||
@@ -0,0 +1,80 @@
|
|||||||
|
// https://umijs.org/config/
|
||||||
|
import { defineConfig } from 'umi';
|
||||||
|
import { join } from 'path';
|
||||||
|
|
||||||
|
import defaultSettings from './defaultSettings';
|
||||||
|
import proxy from './proxy';
|
||||||
|
import routes from './routes';
|
||||||
|
|
||||||
|
const { REACT_APP_ENV } = process.env;
|
||||||
|
|
||||||
|
export default defineConfig({
|
||||||
|
hash: true,
|
||||||
|
publicPath:"./",
|
||||||
|
antd: {},
|
||||||
|
dva: {
|
||||||
|
hmr: true,
|
||||||
|
},
|
||||||
|
layout: {
|
||||||
|
// https://umijs.org/zh-CN/plugins/plugin-layout
|
||||||
|
locale: false,
|
||||||
|
siderWidth: 208,
|
||||||
|
...defaultSettings,
|
||||||
|
},
|
||||||
|
// https://umijs.org/zh-CN/plugins/plugin-locale
|
||||||
|
locale: {
|
||||||
|
// default zh-CN
|
||||||
|
default: 'zh-CN',
|
||||||
|
antd: true,
|
||||||
|
// default true, when it is true, will use `navigator.language` overwrite default
|
||||||
|
baseNavigator: true,
|
||||||
|
},
|
||||||
|
dynamicImport: {
|
||||||
|
loading: '@ant-design/pro-layout/es/PageLoading',
|
||||||
|
},
|
||||||
|
targets: {
|
||||||
|
ie: 11,
|
||||||
|
},
|
||||||
|
// umi routes: https://umijs.org/docs/routing
|
||||||
|
routes,
|
||||||
|
access: {},
|
||||||
|
// Theme for antd: https://ant.design/docs/react/customize-theme-cn
|
||||||
|
theme: {
|
||||||
|
// 如果不想要 configProvide 动态设置主题需要把这个设置为 default
|
||||||
|
// 只有设置为 variable, 才能使用 configProvide 动态设置主色调
|
||||||
|
// https://ant.design/docs/react/customize-theme-variable-cn
|
||||||
|
'root-entry-name': 'variable',
|
||||||
|
},
|
||||||
|
// esbuild is father build tools
|
||||||
|
// https://umijs.org/plugins/plugin-esbuild
|
||||||
|
esbuild: {},
|
||||||
|
title: false,
|
||||||
|
ignoreMomentLocale: true,
|
||||||
|
proxy: proxy[REACT_APP_ENV || 'dev'],
|
||||||
|
manifest: {
|
||||||
|
basePath: '/',
|
||||||
|
},
|
||||||
|
// Fast Refresh 热更新
|
||||||
|
fastRefresh: {},
|
||||||
|
openAPI: [
|
||||||
|
{
|
||||||
|
requestLibPath: "import { request } from 'umi'",
|
||||||
|
// 或者使用在线的版本
|
||||||
|
// schemaPath: "https://gw.alipayobjects.com/os/antfincdn/M%24jrzTTYJN/oneapi.json"
|
||||||
|
schemaPath: join(__dirname, 'oneapi.json'),
|
||||||
|
mock: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
requestLibPath: "import { request } from 'umi'",
|
||||||
|
schemaPath: 'https://gw.alipayobjects.com/os/antfincdn/CA1dOm%2631B/openapi.json',
|
||||||
|
projectName: 'swagger',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
nodeModulesTransform: { type: 'none' },
|
||||||
|
mfsu: {},
|
||||||
|
webpack5: {},
|
||||||
|
exportStatic: {},
|
||||||
|
history: {
|
||||||
|
type: 'hash',
|
||||||
|
},
|
||||||
|
});
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
import { Settings as LayoutSettings } from '@ant-design/pro-components';
|
||||||
|
|
||||||
|
const Settings: LayoutSettings & {
|
||||||
|
pwa?: boolean;
|
||||||
|
logo?: string;
|
||||||
|
} = {
|
||||||
|
navTheme: 'dark',
|
||||||
|
// 拂晓蓝
|
||||||
|
primaryColor: '#1890ff',
|
||||||
|
layout: 'mix',
|
||||||
|
contentWidth: 'Fluid',
|
||||||
|
fixedHeader: false,
|
||||||
|
fixSiderbar: true,
|
||||||
|
colorWeak: false,
|
||||||
|
title: 'Microservices-Platform',
|
||||||
|
pwa: false,
|
||||||
|
logo: './logo.png',
|
||||||
|
iconfontUrl: '',
|
||||||
|
};
|
||||||
|
|
||||||
|
export default Settings;
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
{
|
||||||
|
"openapi": "3.0.1",
|
||||||
|
"info": {
|
||||||
|
"title": "zlt-web",
|
||||||
|
"version": "1.0.0"
|
||||||
|
},
|
||||||
|
"servers": [
|
||||||
|
{
|
||||||
|
"url": "http://localhost:8000/"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "https://localhost:8000/"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"paths": {}
|
||||||
|
}
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
/**
|
||||||
|
* 在生产环境 代理是无法生效的,所以这里没有生产环境的配置
|
||||||
|
* -------------------------------
|
||||||
|
* The agent cannot take effect in the production environment
|
||||||
|
* so there is no configuration of the production environment
|
||||||
|
* For details, please see
|
||||||
|
* https://pro.ant.design/docs/deploy
|
||||||
|
*/
|
||||||
|
export default {
|
||||||
|
dev: {
|
||||||
|
// localhost:8000/api/** -> https://preview.pro.ant.design/api/**
|
||||||
|
'/api/': {
|
||||||
|
// 要代理的地址
|
||||||
|
target: 'https://preview.pro.ant.design',
|
||||||
|
// 配置了这个可以从 http 代理到 https
|
||||||
|
// 依赖 origin 的功能可能需要这个,比如 cookie
|
||||||
|
changeOrigin: true,
|
||||||
|
},
|
||||||
|
'/api-uaa/': {
|
||||||
|
target: 'http://gateway.zlt2000.cn',
|
||||||
|
changeOrigin: true,
|
||||||
|
},
|
||||||
|
'/api-user/': {
|
||||||
|
target: 'http://gateway.zlt2000.cn',
|
||||||
|
changeOrigin: true,
|
||||||
|
},
|
||||||
|
'/api-log/': {
|
||||||
|
target: 'http://gateway.zlt2000.cn',
|
||||||
|
changeOrigin: true,
|
||||||
|
},
|
||||||
|
'/api-search/': {
|
||||||
|
target: 'http://gateway.zlt2000.cn',
|
||||||
|
changeOrigin: true,
|
||||||
|
},
|
||||||
|
'/api-generator/': {
|
||||||
|
target: 'http://gateway.zlt2000.cn',
|
||||||
|
changeOrigin: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
test: {
|
||||||
|
'/api/': {
|
||||||
|
target: 'https://proapi.azurewebsites.net',
|
||||||
|
changeOrigin: true,
|
||||||
|
pathRewrite: { '^': '' },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
pre: {
|
||||||
|
'/api/': {
|
||||||
|
target: 'your pre url',
|
||||||
|
changeOrigin: true,
|
||||||
|
pathRewrite: { '^': '' },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
@@ -0,0 +1,109 @@
|
|||||||
|
export default [
|
||||||
|
{
|
||||||
|
path: '/user',
|
||||||
|
layout: false,
|
||||||
|
routes: [
|
||||||
|
{
|
||||||
|
name: 'login',
|
||||||
|
path: '/user/login',
|
||||||
|
component: './user/Login',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
component: './404',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: '/system',
|
||||||
|
routes: [
|
||||||
|
{
|
||||||
|
path: '/system/user.html',
|
||||||
|
component: './system/User',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: '/system/role.html',
|
||||||
|
component: './system/Role',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: '/system/tokens.html',
|
||||||
|
component: './system/Token',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: '/system/menus.html',
|
||||||
|
component: './system/Menu',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: '/system/myInfo.html',
|
||||||
|
component: './system/UserInfo',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: '/search',
|
||||||
|
routes: [
|
||||||
|
{
|
||||||
|
path: '/search/index_manager.html',
|
||||||
|
component: './search/Index',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: '/search/user_search.html',
|
||||||
|
component: './search/User',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: '/log',
|
||||||
|
routes: [
|
||||||
|
{
|
||||||
|
path: '/log/sysLog.html',
|
||||||
|
component: './log/SysLog',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: '/log/auditLog.html',
|
||||||
|
component: './log/AuditLog',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: '/log/slowQueryLog.html',
|
||||||
|
component: './log/SlowSqlLog',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: '/attestation/app.html',
|
||||||
|
component: './system/App',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: '/generator/list.html',
|
||||||
|
component: './system/Generator',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: '/welcome',
|
||||||
|
name: 'welcome',
|
||||||
|
icon: 'smile',
|
||||||
|
component: './Welcome',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: '/admin',
|
||||||
|
name: 'admin',
|
||||||
|
icon: 'crown',
|
||||||
|
access: 'canAdmin',
|
||||||
|
routes: [
|
||||||
|
{
|
||||||
|
path: '/admin/sub-page',
|
||||||
|
name: 'sub-page',
|
||||||
|
icon: 'smile',
|
||||||
|
component: './Welcome',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
component: './404',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: '/',
|
||||||
|
redirect: '/welcome',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
component: './404',
|
||||||
|
},
|
||||||
|
];
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
module.exports = {
|
||||||
|
testURL: 'http://localhost:8000',
|
||||||
|
verbose: false,
|
||||||
|
extraSetupFiles: ['./tests/setupTests.js'],
|
||||||
|
globals: {
|
||||||
|
ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION: false,
|
||||||
|
localStorage: null,
|
||||||
|
},
|
||||||
|
};
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"jsx": "react-jsx",
|
||||||
|
"emitDecoratorMetadata": true,
|
||||||
|
"experimentalDecorators": true,
|
||||||
|
"baseUrl": ".",
|
||||||
|
"paths": {
|
||||||
|
"@/*": ["./src/*"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,174 @@
|
|||||||
|
import { Request, Response } from 'express';
|
||||||
|
import moment from 'moment';
|
||||||
|
import { parse } from 'url';
|
||||||
|
|
||||||
|
// mock tableListDataSource
|
||||||
|
const genList = (current: number, pageSize: number) => {
|
||||||
|
const tableListDataSource: API.RuleListItem[] = [];
|
||||||
|
|
||||||
|
for (let i = 0; i < pageSize; i += 1) {
|
||||||
|
const index = (current - 1) * 10 + i;
|
||||||
|
tableListDataSource.push({
|
||||||
|
key: index,
|
||||||
|
disabled: i % 6 === 0,
|
||||||
|
href: 'https://ant.design',
|
||||||
|
avatar: [
|
||||||
|
'https://gw.alipayobjects.com/zos/rmsportal/eeHMaZBwmTvLdIwMfBpg.png',
|
||||||
|
'https://gw.alipayobjects.com/zos/rmsportal/udxAbMEhpwthVVcjLXik.png',
|
||||||
|
][i % 2],
|
||||||
|
name: `TradeCode ${index}`,
|
||||||
|
owner: '曲丽丽',
|
||||||
|
desc: '这是一段描述',
|
||||||
|
callNo: Math.floor(Math.random() * 1000),
|
||||||
|
status: Math.floor(Math.random() * 10) % 4,
|
||||||
|
updatedAt: moment().format('YYYY-MM-DD'),
|
||||||
|
createdAt: moment().format('YYYY-MM-DD'),
|
||||||
|
progress: Math.ceil(Math.random() * 100),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
tableListDataSource.reverse();
|
||||||
|
return tableListDataSource;
|
||||||
|
};
|
||||||
|
|
||||||
|
let tableListDataSource = genList(1, 100);
|
||||||
|
|
||||||
|
function getRule(req: Request, res: Response, u: string) {
|
||||||
|
let realUrl = u;
|
||||||
|
if (!realUrl || Object.prototype.toString.call(realUrl) !== '[object String]') {
|
||||||
|
realUrl = req.url;
|
||||||
|
}
|
||||||
|
const { current = 1, pageSize = 10 } = req.query;
|
||||||
|
const params = parse(realUrl, true).query as unknown as API.PageParams &
|
||||||
|
API.RuleListItem & {
|
||||||
|
sorter: any;
|
||||||
|
filter: any;
|
||||||
|
};
|
||||||
|
|
||||||
|
let dataSource = [...tableListDataSource].slice(
|
||||||
|
((current as number) - 1) * (pageSize as number),
|
||||||
|
(current as number) * (pageSize as number),
|
||||||
|
);
|
||||||
|
if (params.sorter) {
|
||||||
|
const sorter = JSON.parse(params.sorter);
|
||||||
|
dataSource = dataSource.sort((prev, next) => {
|
||||||
|
let sortNumber = 0;
|
||||||
|
Object.keys(sorter).forEach((key) => {
|
||||||
|
if (sorter[key] === 'descend') {
|
||||||
|
if (prev[key] - next[key] > 0) {
|
||||||
|
sortNumber += -1;
|
||||||
|
} else {
|
||||||
|
sortNumber += 1;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (prev[key] - next[key] > 0) {
|
||||||
|
sortNumber += 1;
|
||||||
|
} else {
|
||||||
|
sortNumber += -1;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return sortNumber;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (params.filter) {
|
||||||
|
const filter = JSON.parse(params.filter as any) as {
|
||||||
|
[key: string]: string[];
|
||||||
|
};
|
||||||
|
if (Object.keys(filter).length > 0) {
|
||||||
|
dataSource = dataSource.filter((item) => {
|
||||||
|
return Object.keys(filter).some((key) => {
|
||||||
|
if (!filter[key]) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (filter[key].includes(`${item[key]}`)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (params.name) {
|
||||||
|
dataSource = dataSource.filter((data) => data?.name?.includes(params.name || ''));
|
||||||
|
}
|
||||||
|
const result = {
|
||||||
|
data: dataSource,
|
||||||
|
total: tableListDataSource.length,
|
||||||
|
success: true,
|
||||||
|
pageSize,
|
||||||
|
current: parseInt(`${params.current}`, 10) || 1,
|
||||||
|
};
|
||||||
|
|
||||||
|
return res.json(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
function postRule(req: Request, res: Response, u: string, b: Request) {
|
||||||
|
let realUrl = u;
|
||||||
|
if (!realUrl || Object.prototype.toString.call(realUrl) !== '[object String]') {
|
||||||
|
realUrl = req.url;
|
||||||
|
}
|
||||||
|
|
||||||
|
const body = (b && b.body) || req.body;
|
||||||
|
const { method, name, desc, key } = body;
|
||||||
|
|
||||||
|
switch (method) {
|
||||||
|
/* eslint no-case-declarations:0 */
|
||||||
|
case 'delete':
|
||||||
|
tableListDataSource = tableListDataSource.filter((item) => key.indexOf(item.key) === -1);
|
||||||
|
break;
|
||||||
|
case 'post':
|
||||||
|
(() => {
|
||||||
|
const i = Math.ceil(Math.random() * 10000);
|
||||||
|
const newRule: API.RuleListItem = {
|
||||||
|
key: tableListDataSource.length,
|
||||||
|
href: 'https://ant.design',
|
||||||
|
avatar: [
|
||||||
|
'https://gw.alipayobjects.com/zos/rmsportal/eeHMaZBwmTvLdIwMfBpg.png',
|
||||||
|
'https://gw.alipayobjects.com/zos/rmsportal/udxAbMEhpwthVVcjLXik.png',
|
||||||
|
][i % 2],
|
||||||
|
name,
|
||||||
|
owner: '曲丽丽',
|
||||||
|
desc,
|
||||||
|
callNo: Math.floor(Math.random() * 1000),
|
||||||
|
status: Math.floor(Math.random() * 10) % 2,
|
||||||
|
updatedAt: moment().format('YYYY-MM-DD'),
|
||||||
|
createdAt: moment().format('YYYY-MM-DD'),
|
||||||
|
progress: Math.ceil(Math.random() * 100),
|
||||||
|
};
|
||||||
|
tableListDataSource.unshift(newRule);
|
||||||
|
return res.json(newRule);
|
||||||
|
})();
|
||||||
|
return;
|
||||||
|
|
||||||
|
case 'update':
|
||||||
|
(() => {
|
||||||
|
let newRule = {};
|
||||||
|
tableListDataSource = tableListDataSource.map((item) => {
|
||||||
|
if (item.key === key) {
|
||||||
|
newRule = { ...item, desc, name };
|
||||||
|
return { ...item, desc, name };
|
||||||
|
}
|
||||||
|
return item;
|
||||||
|
});
|
||||||
|
return res.json(newRule);
|
||||||
|
})();
|
||||||
|
return;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
const result = {
|
||||||
|
list: tableListDataSource,
|
||||||
|
pagination: {
|
||||||
|
total: tableListDataSource.length,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
res.json(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default {
|
||||||
|
'GET /api/rule': getRule,
|
||||||
|
'POST /api/rule': postRule,
|
||||||
|
};
|
||||||
@@ -0,0 +1,107 @@
|
|||||||
|
import { Request, Response } from 'express';
|
||||||
|
|
||||||
|
const getNotices = (req: Request, res: Response) => {
|
||||||
|
res.json({
|
||||||
|
data: [
|
||||||
|
{
|
||||||
|
id: '000000001',
|
||||||
|
avatar: 'https://gw.alipayobjects.com/zos/rmsportal/ThXAXghbEsBCCSDihZxY.png',
|
||||||
|
title: '你收到了 14 份新周报',
|
||||||
|
datetime: '2017-08-09',
|
||||||
|
type: 'notification',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: '000000002',
|
||||||
|
avatar: 'https://gw.alipayobjects.com/zos/rmsportal/OKJXDXrmkNshAMvwtvhu.png',
|
||||||
|
title: '你推荐的 曲妮妮 已通过第三轮面试',
|
||||||
|
datetime: '2017-08-08',
|
||||||
|
type: 'notification',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: '000000003',
|
||||||
|
avatar: 'https://gw.alipayobjects.com/zos/rmsportal/kISTdvpyTAhtGxpovNWd.png',
|
||||||
|
title: '这种模板可以区分多种通知类型',
|
||||||
|
datetime: '2017-08-07',
|
||||||
|
read: true,
|
||||||
|
type: 'notification',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: '000000004',
|
||||||
|
avatar: 'https://gw.alipayobjects.com/zos/rmsportal/GvqBnKhFgObvnSGkDsje.png',
|
||||||
|
title: '左侧图标用于区分不同的类型',
|
||||||
|
datetime: '2017-08-07',
|
||||||
|
type: 'notification',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: '000000005',
|
||||||
|
avatar: 'https://gw.alipayobjects.com/zos/rmsportal/ThXAXghbEsBCCSDihZxY.png',
|
||||||
|
title: '内容不要超过两行字,超出时自动截断',
|
||||||
|
datetime: '2017-08-07',
|
||||||
|
type: 'notification',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: '000000006',
|
||||||
|
avatar: 'https://gw.alipayobjects.com/zos/rmsportal/fcHMVNCjPOsbUGdEduuv.jpeg',
|
||||||
|
title: '曲丽丽 评论了你',
|
||||||
|
description: '描述信息描述信息描述信息',
|
||||||
|
datetime: '2017-08-07',
|
||||||
|
type: 'message',
|
||||||
|
clickClose: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: '000000007',
|
||||||
|
avatar: 'https://gw.alipayobjects.com/zos/rmsportal/fcHMVNCjPOsbUGdEduuv.jpeg',
|
||||||
|
title: '朱偏右 回复了你',
|
||||||
|
description: '这种模板用于提醒谁与你发生了互动,左侧放『谁』的头像',
|
||||||
|
datetime: '2017-08-07',
|
||||||
|
type: 'message',
|
||||||
|
clickClose: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: '000000008',
|
||||||
|
avatar: 'https://gw.alipayobjects.com/zos/rmsportal/fcHMVNCjPOsbUGdEduuv.jpeg',
|
||||||
|
title: '标题',
|
||||||
|
description: '这种模板用于提醒谁与你发生了互动,左侧放『谁』的头像',
|
||||||
|
datetime: '2017-08-07',
|
||||||
|
type: 'message',
|
||||||
|
clickClose: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: '000000009',
|
||||||
|
title: '任务名称',
|
||||||
|
description: '任务需要在 2017-01-12 20:00 前启动',
|
||||||
|
extra: '未开始',
|
||||||
|
status: 'todo',
|
||||||
|
type: 'event',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: '000000010',
|
||||||
|
title: '第三方紧急代码变更',
|
||||||
|
description: '冠霖提交于 2017-01-06,需在 2017-01-07 前完成代码变更任务',
|
||||||
|
extra: '马上到期',
|
||||||
|
status: 'urgent',
|
||||||
|
type: 'event',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: '000000011',
|
||||||
|
title: '信息安全考试',
|
||||||
|
description: '指派竹尔于 2017-01-09 前完成更新并发布',
|
||||||
|
extra: '已耗时 8 天',
|
||||||
|
status: 'doing',
|
||||||
|
type: 'event',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: '000000012',
|
||||||
|
title: 'ABCD 版本发布',
|
||||||
|
description: '冠霖提交于 2017-01-06,需在 2017-01-07 前完成代码变更任务',
|
||||||
|
extra: '进行中',
|
||||||
|
status: 'processing',
|
||||||
|
type: 'event',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
export default {
|
||||||
|
'GET /api/notices': getNotices,
|
||||||
|
};
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
export default {
|
||||||
|
'/api/auth_routes': {
|
||||||
|
'/form/advanced-form': { authority: ['admin', 'user'] },
|
||||||
|
},
|
||||||
|
};
|
||||||
@@ -0,0 +1,203 @@
|
|||||||
|
import { Request, Response } from 'express';
|
||||||
|
|
||||||
|
const waitTime = (time: number = 100) => {
|
||||||
|
return new Promise((resolve) => {
|
||||||
|
setTimeout(() => {
|
||||||
|
resolve(true);
|
||||||
|
}, time);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
async function getFakeCaptcha(req: Request, res: Response) {
|
||||||
|
await waitTime(2000);
|
||||||
|
return res.json('captcha-xxx');
|
||||||
|
}
|
||||||
|
|
||||||
|
const { ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION } = process.env;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 当前用户的权限,如果为空代表没登录
|
||||||
|
* current user access, if is '', user need login
|
||||||
|
* 如果是 pro 的预览,默认是有权限的
|
||||||
|
*/
|
||||||
|
let access = ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION === 'site' ? 'admin' : '';
|
||||||
|
|
||||||
|
const getAccess = () => {
|
||||||
|
return access;
|
||||||
|
};
|
||||||
|
|
||||||
|
// 代码中会兼容本地 service mock 以及部署站点的静态数据
|
||||||
|
export default {
|
||||||
|
// 支持值为 Object 和 Array
|
||||||
|
'GET /api/currentUser': (req: Request, res: Response) => {
|
||||||
|
if (!getAccess()) {
|
||||||
|
res.status(401).send({
|
||||||
|
data: {
|
||||||
|
isLogin: false,
|
||||||
|
},
|
||||||
|
errorCode: '401',
|
||||||
|
errorMessage: '请先登录!',
|
||||||
|
success: true,
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
res.send({
|
||||||
|
success: true,
|
||||||
|
data: {
|
||||||
|
name: 'Serati Ma',
|
||||||
|
avatar: 'https://gw.alipayobjects.com/zos/antfincdn/XAosXuNZyF/BiazfanxmamNRoxxVxka.png',
|
||||||
|
userid: '00000001',
|
||||||
|
email: 'antdesign@alipay.com',
|
||||||
|
signature: '海纳百川,有容乃大',
|
||||||
|
title: '交互专家',
|
||||||
|
group: '蚂蚁金服-某某某事业群-某某平台部-某某技术部-UED',
|
||||||
|
tags: [
|
||||||
|
{
|
||||||
|
key: '0',
|
||||||
|
label: '很有想法的',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: '1',
|
||||||
|
label: '专注设计',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: '2',
|
||||||
|
label: '辣~',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: '3',
|
||||||
|
label: '大长腿',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: '4',
|
||||||
|
label: '川妹子',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: '5',
|
||||||
|
label: '海纳百川',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
notifyCount: 12,
|
||||||
|
unreadCount: 11,
|
||||||
|
country: 'China',
|
||||||
|
access: getAccess(),
|
||||||
|
geographic: {
|
||||||
|
province: {
|
||||||
|
label: '浙江省',
|
||||||
|
key: '330000',
|
||||||
|
},
|
||||||
|
city: {
|
||||||
|
label: '杭州市',
|
||||||
|
key: '330100',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
address: '西湖区工专路 77 号',
|
||||||
|
phone: '0752-268888888',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
},
|
||||||
|
// GET POST 可省略
|
||||||
|
'GET /api/users': [
|
||||||
|
{
|
||||||
|
key: '1',
|
||||||
|
name: 'John Brown',
|
||||||
|
age: 32,
|
||||||
|
address: 'New York No. 1 Lake Park',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: '2',
|
||||||
|
name: 'Jim Green',
|
||||||
|
age: 42,
|
||||||
|
address: 'London No. 1 Lake Park',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: '3',
|
||||||
|
name: 'Joe Black',
|
||||||
|
age: 32,
|
||||||
|
address: 'Sidney No. 1 Lake Park',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
'POST /api/login/account': async (req: Request, res: Response) => {
|
||||||
|
const { password, username, type } = req.body;
|
||||||
|
await waitTime(2000);
|
||||||
|
if (password === 'ant.design' && username === 'admin') {
|
||||||
|
res.send({
|
||||||
|
status: 'ok',
|
||||||
|
type,
|
||||||
|
currentAuthority: 'admin',
|
||||||
|
});
|
||||||
|
access = 'admin';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (password === 'ant.design' && username === 'user') {
|
||||||
|
res.send({
|
||||||
|
status: 'ok',
|
||||||
|
type,
|
||||||
|
currentAuthority: 'user',
|
||||||
|
});
|
||||||
|
access = 'user';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (type === 'mobile') {
|
||||||
|
res.send({
|
||||||
|
status: 'ok',
|
||||||
|
type,
|
||||||
|
currentAuthority: 'admin',
|
||||||
|
});
|
||||||
|
access = 'admin';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
res.send({
|
||||||
|
status: 'error',
|
||||||
|
type,
|
||||||
|
currentAuthority: 'guest',
|
||||||
|
});
|
||||||
|
access = 'guest';
|
||||||
|
},
|
||||||
|
'POST /api/login/outLogin': (req: Request, res: Response) => {
|
||||||
|
access = '';
|
||||||
|
res.send({ data: {}, success: true });
|
||||||
|
},
|
||||||
|
'POST /api/register': (req: Request, res: Response) => {
|
||||||
|
res.send({ status: 'ok', currentAuthority: 'user', success: true });
|
||||||
|
},
|
||||||
|
'GET /api/500': (req: Request, res: Response) => {
|
||||||
|
res.status(500).send({
|
||||||
|
timestamp: 1513932555104,
|
||||||
|
status: 500,
|
||||||
|
error: 'error',
|
||||||
|
message: 'error',
|
||||||
|
path: '/base/category/list',
|
||||||
|
});
|
||||||
|
},
|
||||||
|
'GET /api/404': (req: Request, res: Response) => {
|
||||||
|
res.status(404).send({
|
||||||
|
timestamp: 1513932643431,
|
||||||
|
status: 404,
|
||||||
|
error: 'Not Found',
|
||||||
|
message: 'No message available',
|
||||||
|
path: '/base/category/list/2121212',
|
||||||
|
});
|
||||||
|
},
|
||||||
|
'GET /api/403': (req: Request, res: Response) => {
|
||||||
|
res.status(403).send({
|
||||||
|
timestamp: 1513932555104,
|
||||||
|
status: 403,
|
||||||
|
error: 'Forbidden',
|
||||||
|
message: 'Forbidden',
|
||||||
|
path: '/base/category/list',
|
||||||
|
});
|
||||||
|
},
|
||||||
|
'GET /api/401': (req: Request, res: Response) => {
|
||||||
|
res.status(401).send({
|
||||||
|
timestamp: 1513932555104,
|
||||||
|
status: 401,
|
||||||
|
error: 'Unauthorized',
|
||||||
|
message: 'Unauthorized',
|
||||||
|
path: '/base/category/list',
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
'GET /api/login/captcha': getFakeCaptcha,
|
||||||
|
};
|
||||||
@@ -0,0 +1,106 @@
|
|||||||
|
{
|
||||||
|
"name": "zlt-web",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"private": true,
|
||||||
|
"scripts": {
|
||||||
|
"analyze": "cross-env ANALYZE=1 umi build",
|
||||||
|
"build": "umi 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": "umi g tmp",
|
||||||
|
"lint": "umi g tmp && npm run lint:js && npm run lint:style && 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 && npm run lint:style",
|
||||||
|
"lint:js": "eslint --cache --ext .js,.jsx,.ts,.tsx --format=pretty ./src",
|
||||||
|
"lint:prettier": "prettier -c --write \"src/**/*\" --end-of-line auto",
|
||||||
|
"lint:style": "stylelint --fix \"src/**/*.less\" --syntax less",
|
||||||
|
"openapi": "umi openapi",
|
||||||
|
"playwright": "playwright install && playwright test",
|
||||||
|
"prettier": "prettier -c --write \"src/**/*\"",
|
||||||
|
"serve": "umi-serve",
|
||||||
|
"start": "cross-env UMI_ENV=dev umi dev",
|
||||||
|
"start:dev": "cross-env REACT_APP_ENV=dev MOCK=none UMI_ENV=dev umi dev",
|
||||||
|
"start:no-mock": "cross-env MOCK=none UMI_ENV=dev umi dev",
|
||||||
|
"start:no-ui": "cross-env UMI_UI=none UMI_ENV=dev umi dev",
|
||||||
|
"start:pre": "cross-env REACT_APP_ENV=pre UMI_ENV=dev umi dev",
|
||||||
|
"start:test": "cross-env REACT_APP_ENV=test MOCK=none UMI_ENV=dev umi dev",
|
||||||
|
"test": "umi test",
|
||||||
|
"test:component": "umi test ./src/components",
|
||||||
|
"test:e2e": "node ./tests/run-tests.js",
|
||||||
|
"tsc": "tsc --noEmit"
|
||||||
|
},
|
||||||
|
"lint-staged": {
|
||||||
|
"**/*.less": "stylelint --syntax less",
|
||||||
|
"**/*.{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/charts": "^1.4.2",
|
||||||
|
"@ant-design/icons": "^4.7.0",
|
||||||
|
"@ant-design/pro-components": "1.1.1",
|
||||||
|
"@umijs/route-utils": "^2.0.0",
|
||||||
|
"antd": "^4.20.0",
|
||||||
|
"classnames": "^2.3.0",
|
||||||
|
"lodash": "^4.17.21",
|
||||||
|
"moment": "^2.29.0",
|
||||||
|
"omit.js": "^2.0.2",
|
||||||
|
"rc-menu": "^9.1.0",
|
||||||
|
"rc-resize-observer": "^1.2.0",
|
||||||
|
"rc-util": "^5.16.0",
|
||||||
|
"react": "^17.0.0",
|
||||||
|
"react-dev-inspector": "^1.7.0",
|
||||||
|
"react-dom": "^17.0.0",
|
||||||
|
"react-helmet-async": "^1.2.0",
|
||||||
|
"react-json-tree": "^0.17.0",
|
||||||
|
"treeify-js": "^1.0.8",
|
||||||
|
"umi": "^3.5.0",
|
||||||
|
"uuid": "^9.0.0"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@ant-design/pro-cli": "^2.1.0",
|
||||||
|
"@playwright/test": "^1.17.0",
|
||||||
|
"@types/classnames": "^2.3.1",
|
||||||
|
"@types/express": "^4.17.0",
|
||||||
|
"@types/history": "^4.7.0",
|
||||||
|
"@types/jest": "^26.0.0",
|
||||||
|
"@types/lodash": "^4.14.0",
|
||||||
|
"@types/react": "^17.0.0",
|
||||||
|
"@types/react-dom": "^17.0.0",
|
||||||
|
"@types/react-helmet": "^6.1.0",
|
||||||
|
"@types/uuid": "^8.3.4",
|
||||||
|
"@umijs/fabric": "^2.11.1",
|
||||||
|
"@umijs/openapi": "^1.6.0",
|
||||||
|
"@umijs/plugin-blocks": "^2.2.0",
|
||||||
|
"@umijs/plugin-esbuild": "^1.4.0",
|
||||||
|
"@umijs/plugin-openapi": "^1.3.3",
|
||||||
|
"@umijs/preset-ant-design-pro": "^1.3.0",
|
||||||
|
"@umijs/preset-dumi": "^1.1.0",
|
||||||
|
"@umijs/preset-react": "^2.1.0",
|
||||||
|
"cross-env": "^7.0.0",
|
||||||
|
"cross-port-killer": "^1.3.0",
|
||||||
|
"detect-installer": "^1.0.0",
|
||||||
|
"eslint": "^7.32.0",
|
||||||
|
"gh-pages": "^3.2.0",
|
||||||
|
"jsdom-global": "^3.0.0",
|
||||||
|
"lint-staged": "^10.0.0",
|
||||||
|
"mockjs": "^1.1.0",
|
||||||
|
"prettier": "^2.5.0",
|
||||||
|
"stylelint": "^13.0.0",
|
||||||
|
"swagger-ui-dist": "^4.12.0",
|
||||||
|
"typescript": "^4.5.0",
|
||||||
|
"umi-serve": "^1.9.10"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=12.0.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
// playwright.config.ts
|
||||||
|
import type { PlaywrightTestConfig } from '@playwright/test';
|
||||||
|
import { devices } from '@playwright/test';
|
||||||
|
|
||||||
|
const config: PlaywrightTestConfig = {
|
||||||
|
forbidOnly: !!process.env.CI,
|
||||||
|
retries: process.env.CI ? 2 : 0,
|
||||||
|
use: {
|
||||||
|
trace: 'on-first-retry',
|
||||||
|
},
|
||||||
|
projects: [
|
||||||
|
{
|
||||||
|
name: 'chromium',
|
||||||
|
use: { ...devices['Desktop Chrome'] },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'firefox',
|
||||||
|
use: { ...devices['Desktop Firefox'] },
|
||||||
|
},
|
||||||
|
],
|
||||||
|
};
|
||||||
|
export default config;
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
preview.pro.ant.design
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1664604355459" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="6163" width="128" height="128" xmlns:xlink="http://www.w3.org/1999/xlink"><path d="M832 64H192c-70.4 0-128 57.6-128 128v640c0 70.4 57.6 128 128 128h640c70.4 0 128-57.6 128-128V192c0-70.4-57.6-128-128-128z m-32 447.8H320v320h-64v-640h544l-161.3 160 161.3 160z" fill="#92d050" p-id="6164"></path></svg>
|
||||||
|
After Width: | Height: | Size: 550 B |
|
After Width: | Height: | Size: 4.2 KiB |
|
After Width: | Height: | Size: 1.9 KiB |
|
After Width: | Height: | Size: 3.1 KiB |
|
After Width: | Height: | Size: 14 KiB |
|
After Width: | Height: | Size: 3.6 KiB |
@@ -0,0 +1 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200" version="1.1" viewBox="0 0 200 200"><title>Group 28 Copy 5</title><desc>Created with Sketch.</desc><defs><linearGradient id="linearGradient-1" x1="62.102%" x2="108.197%" y1="0%" y2="37.864%"><stop offset="0%" stop-color="#4285EB"/><stop offset="100%" stop-color="#2EC7FF"/></linearGradient><linearGradient id="linearGradient-2" x1="69.644%" x2="54.043%" y1="0%" y2="108.457%"><stop offset="0%" stop-color="#29CDFF"/><stop offset="37.86%" stop-color="#148EFF"/><stop offset="100%" stop-color="#0A60FF"/></linearGradient><linearGradient id="linearGradient-3" x1="69.691%" x2="16.723%" y1="-12.974%" y2="117.391%"><stop offset="0%" stop-color="#FA816E"/><stop offset="41.473%" stop-color="#F74A5C"/><stop offset="100%" stop-color="#F51D2C"/></linearGradient><linearGradient id="linearGradient-4" x1="68.128%" x2="30.44%" y1="-35.691%" y2="114.943%"><stop offset="0%" stop-color="#FA8E7D"/><stop offset="51.264%" stop-color="#F74A5C"/><stop offset="100%" stop-color="#F51D2C"/></linearGradient></defs><g id="Page-1" fill="none" fill-rule="evenodd" stroke="none" stroke-width="1"><g id="logo" transform="translate(-20.000000, -20.000000)"><g id="Group-28-Copy-5" transform="translate(20.000000, 20.000000)"><g id="Group-27-Copy-3"><g id="Group-25" fill-rule="nonzero"><g id="2"><path id="Shape" fill="url(#linearGradient-1)" d="M91.5880863,4.17652823 L4.17996544,91.5127728 C-0.519240605,96.2081146 -0.519240605,103.791885 4.17996544,108.487227 L91.5880863,195.823472 C96.2872923,200.518814 103.877304,200.518814 108.57651,195.823472 L145.225487,159.204632 C149.433969,154.999611 149.433969,148.181924 145.225487,143.976903 C141.017005,139.771881 134.193707,139.771881 129.985225,143.976903 L102.20193,171.737352 C101.032305,172.906015 99.2571609,172.906015 98.0875359,171.737352 L28.285908,101.993122 C27.1162831,100.824459 27.1162831,99.050775 28.285908,97.8821118 L98.0875359,28.1378823 C99.2571609,26.9692191 101.032305,26.9692191 102.20193,28.1378823 L129.985225,55.8983314 C134.193707,60.1033528 141.017005,60.1033528 145.225487,55.8983314 C149.433969,51.69331 149.433969,44.8756232 145.225487,40.6706018 L108.58055,4.05574592 C103.862049,-0.537986846 96.2692618,-0.500797906 91.5880863,4.17652823 Z"/><path id="Shape" fill="url(#linearGradient-2)" d="M91.5880863,4.17652823 L4.17996544,91.5127728 C-0.519240605,96.2081146 -0.519240605,103.791885 4.17996544,108.487227 L91.5880863,195.823472 C96.2872923,200.518814 103.877304,200.518814 108.57651,195.823472 L145.225487,159.204632 C149.433969,154.999611 149.433969,148.181924 145.225487,143.976903 C141.017005,139.771881 134.193707,139.771881 129.985225,143.976903 L102.20193,171.737352 C101.032305,172.906015 99.2571609,172.906015 98.0875359,171.737352 L28.285908,101.993122 C27.1162831,100.824459 27.1162831,99.050775 28.285908,97.8821118 L98.0875359,28.1378823 C100.999864,25.6271836 105.751642,20.541824 112.729652,19.3524487 C117.915585,18.4685261 123.585219,20.4140239 129.738554,25.1889424 C125.624663,21.0784292 118.571995,14.0340304 108.58055,4.05574592 C103.862049,-0.537986846 96.2692618,-0.500797906 91.5880863,4.17652823 Z"/></g><path id="Shape" fill="url(#linearGradient-3)" d="M153.685633,135.854579 C157.894115,140.0596 164.717412,140.0596 168.925894,135.854579 L195.959977,108.842726 C200.659183,104.147384 200.659183,96.5636133 195.960527,91.8688194 L168.690777,64.7181159 C164.472332,60.5180858 157.646868,60.5241425 153.435895,64.7316526 C149.227413,68.936674 149.227413,75.7543607 153.435895,79.9593821 L171.854035,98.3623765 C173.02366,99.5310396 173.02366,101.304724 171.854035,102.473387 L153.685633,120.626849 C149.47715,124.83187 149.47715,131.649557 153.685633,135.854579 Z"/></g><ellipse id="Combined-Shape" cx="100.519" cy="100.437" fill="url(#linearGradient-4)" rx="23.6" ry="23.581"/></g></g></g></g></svg>
|
||||||
|
After Width: | Height: | Size: 3.8 KiB |
@@ -0,0 +1,5 @@
|
|||||||
|
<svg width="42" height="42" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<g>
|
||||||
|
<path fill="#070707" d="m6.717392,13.773912l5.6,0c2.8,0 4.7,1.9 4.7,4.7c0,2.8 -2,4.7 -4.9,4.7l-2.5,0l0,4.3l-2.9,0l0,-13.7zm2.9,2.2l0,4.9l1.9,0c1.6,0 2.6,-0.9 2.6,-2.4c0,-1.6 -0.9,-2.4 -2.6,-2.4l-1.9,0l0,-0.1zm8.9,11.5l2.7,0l0,-5.7c0,-1.4 0.8,-2.3 2.2,-2.3c0.4,0 0.8,0.1 1,0.2l0,-2.4c-0.2,-0.1 -0.5,-0.1 -0.8,-0.1c-1.2,0 -2.1,0.7 -2.4,2l-0.1,0l0,-1.9l-2.7,0l0,10.2l0.1,0zm11.7,0.1c-3.1,0 -5,-2 -5,-5.3c0,-3.3 2,-5.3 5,-5.3s5,2 5,5.3c0,3.4 -1.9,5.3 -5,5.3zm0,-2.1c1.4,0 2.2,-1.1 2.2,-3.2c0,-2 -0.8,-3.2 -2.2,-3.2c-1.4,0 -2.2,1.2 -2.2,3.2c0,2.1 0.8,3.2 2.2,3.2z" class="st0" id="Ant-Design-Pro"/>
|
||||||
|
</g>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 677 B |
@@ -0,0 +1,9 @@
|
|||||||
|
/**
|
||||||
|
* @see https://umijs.org/zh-CN/plugins/plugin-access
|
||||||
|
* */
|
||||||
|
export default function access(initialState: { currentUser?: API.CurrentUser } | undefined) {
|
||||||
|
const { currentUser } = initialState ?? {};
|
||||||
|
return {
|
||||||
|
canAdmin: currentUser && currentUser.access === 'admin',
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -0,0 +1,305 @@
|
|||||||
|
import Footer from '@/components/Footer';
|
||||||
|
import RightContent from '@/components/RightContent';
|
||||||
|
import {
|
||||||
|
AppstoreOutlined,
|
||||||
|
MenuOutlined,
|
||||||
|
TeamOutlined,
|
||||||
|
SettingOutlined,
|
||||||
|
UserOutlined,
|
||||||
|
CaretDownFilled,
|
||||||
|
CrownOutlined,
|
||||||
|
} from '@ant-design/icons';
|
||||||
|
import type { MenuDataItem, Settings as LayoutSettings } from '@ant-design/pro-components';
|
||||||
|
import { PageLoading, SettingDrawer } from '@ant-design/pro-components';
|
||||||
|
import { Divider, Dropdown, Menu, Space } from 'antd';
|
||||||
|
import type { RequestConfig, RunTimeLayoutConfig } from 'umi';
|
||||||
|
import { history } from 'umi';
|
||||||
|
import defaultSettings from '../config/defaultSettings';
|
||||||
|
import { currentUser as queryCurrentUser, fetchMenuData } from './services/login/api';
|
||||||
|
|
||||||
|
const isDev = process.env.NODE_ENV === 'development';
|
||||||
|
const loginPath = '/user/login';
|
||||||
|
|
||||||
|
/** 获取用户信息比较慢的时候会展示一个 loading */
|
||||||
|
export const initialStateConfig = {
|
||||||
|
loading: <PageLoading />,
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see https://umijs.org/zh-CN/plugins/plugin-initial-state
|
||||||
|
* */
|
||||||
|
export async function getInitialState(): Promise<{
|
||||||
|
settings?: Partial<LayoutSettings>;
|
||||||
|
currentUser?: API.CurrentUser;
|
||||||
|
loading?: boolean;
|
||||||
|
fetchUserInfo?: () => Promise<API.CurrentUser | undefined>;
|
||||||
|
}> {
|
||||||
|
const fetchUserInfo = async () => {
|
||||||
|
try {
|
||||||
|
const msg = await queryCurrentUser();
|
||||||
|
// TODO
|
||||||
|
return msg.datas;
|
||||||
|
} catch (error) {
|
||||||
|
history.push(loginPath);
|
||||||
|
}
|
||||||
|
return undefined;
|
||||||
|
};
|
||||||
|
// 如果不是登录页面,执行
|
||||||
|
if (history.location.pathname !== loginPath) {
|
||||||
|
const currentUser = await fetchUserInfo();
|
||||||
|
return {
|
||||||
|
fetchUserInfo,
|
||||||
|
currentUser,
|
||||||
|
settings: defaultSettings,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
fetchUserInfo,
|
||||||
|
settings: defaultSettings,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
// ProLayout 支持的api https://procomponents.ant.design/components/layout
|
||||||
|
export const layout: RunTimeLayoutConfig = ({ initialState, setInitialState }) => {
|
||||||
|
return {
|
||||||
|
rightContentRender: () => <RightContent />,
|
||||||
|
disableContentMargin: false,
|
||||||
|
waterMarkProps: {
|
||||||
|
content: initialState?.currentUser?.username,
|
||||||
|
},
|
||||||
|
footerRender: () => <Footer />,
|
||||||
|
onPageChange: () => {
|
||||||
|
const { location } = history;
|
||||||
|
// 如果没有登录,重定向到 login
|
||||||
|
if (!initialState?.currentUser && location.pathname !== loginPath) {
|
||||||
|
history.push(loginPath);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
links: isDev
|
||||||
|
? [
|
||||||
|
// <Link key="openapi" to="/umi/plugin/openapi" target="_blank">
|
||||||
|
// <LinkOutlined />
|
||||||
|
// <span>OpenAPI 文档</span>
|
||||||
|
// </Link>,
|
||||||
|
// <Link to="/~docs" key="docs">
|
||||||
|
// <BookOutlined />
|
||||||
|
// <span>业务组件文档</span>
|
||||||
|
// </Link>,
|
||||||
|
]
|
||||||
|
: [],
|
||||||
|
menuHeaderRender: undefined,
|
||||||
|
|
||||||
|
menu: {
|
||||||
|
// 每当 initialState?.currentUser?.userid 发生修改时重新执行 request
|
||||||
|
params: {
|
||||||
|
userId: initialState?.currentUser?.userId,
|
||||||
|
},
|
||||||
|
request: async () => {
|
||||||
|
// initialState.currentUser 中包含了所有用户信息
|
||||||
|
const menuData = await fetchMenuData();
|
||||||
|
|
||||||
|
const mapIcon = (css: string | undefined) => {
|
||||||
|
switch (css) {
|
||||||
|
case 'layui-icon-set':
|
||||||
|
return <SettingOutlined />;
|
||||||
|
case 'layui-icon-friends':
|
||||||
|
return <UserOutlined />;
|
||||||
|
case 'layui-icon-user':
|
||||||
|
return <TeamOutlined />;
|
||||||
|
case 'layui-icon-menu-fill':
|
||||||
|
return <MenuOutlined />;
|
||||||
|
default:
|
||||||
|
return <AppstoreOutlined />;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const mapMenu = (value: API.Menu[]): MenuDataItem[] => {
|
||||||
|
return value.map((item) => {
|
||||||
|
return {
|
||||||
|
key: item.id + '',
|
||||||
|
name: item.name,
|
||||||
|
locale: false,
|
||||||
|
path:
|
||||||
|
item.path?.endsWith('.html') || item.path?.startsWith('http')
|
||||||
|
? item.path
|
||||||
|
: undefined,
|
||||||
|
icon: mapIcon(item.css),
|
||||||
|
children: item.subMenus && mapMenu(item.subMenus),
|
||||||
|
};
|
||||||
|
});
|
||||||
|
};
|
||||||
|
const menus = mapMenu(menuData);
|
||||||
|
return [
|
||||||
|
{ key: 'welcome', name: ' 首页', path: '/welcome', icon: <CrownOutlined /> },
|
||||||
|
...menus,
|
||||||
|
];
|
||||||
|
},
|
||||||
|
},
|
||||||
|
headerContentRender: () => {
|
||||||
|
return (
|
||||||
|
<Space>
|
||||||
|
<Divider type="vertical" />
|
||||||
|
<Dropdown
|
||||||
|
placement="top"
|
||||||
|
overlay={
|
||||||
|
<Menu
|
||||||
|
items={[
|
||||||
|
{
|
||||||
|
key: '1',
|
||||||
|
label: (
|
||||||
|
<a
|
||||||
|
target="_blank"
|
||||||
|
rel="noopener noreferrer"
|
||||||
|
href="https://www.kancloud.cn/zlt2000/microservices-platform/936235"
|
||||||
|
>
|
||||||
|
项目更新日志
|
||||||
|
</a>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: '2',
|
||||||
|
label: (
|
||||||
|
<a target="_blank" rel="noopener noreferrer" href="https://zlt2000.gitee.io/">
|
||||||
|
个人博客
|
||||||
|
</a>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: '3',
|
||||||
|
label: (
|
||||||
|
<a
|
||||||
|
target="_blank"
|
||||||
|
rel="noopener noreferrer"
|
||||||
|
href="https://gitee.com/zlt2000/"
|
||||||
|
>
|
||||||
|
个人公众号
|
||||||
|
</a>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: '4',
|
||||||
|
label: (
|
||||||
|
<a
|
||||||
|
target="_blank"
|
||||||
|
rel="noopener noreferrer"
|
||||||
|
href="https://gitbook.cn/gitchat/author/5b2362320398d50d7b7ab29e"
|
||||||
|
>
|
||||||
|
GitChat
|
||||||
|
</a>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: '5',
|
||||||
|
label: (
|
||||||
|
<a
|
||||||
|
target="_blank"
|
||||||
|
rel="noopener noreferrer"
|
||||||
|
href="https://www.aliyun.com/minisite/goods?userCode=dickv1kw&share_source=copy_link"
|
||||||
|
>
|
||||||
|
阿里云优惠
|
||||||
|
</a>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: '6',
|
||||||
|
label: (
|
||||||
|
<a
|
||||||
|
target="_blank"
|
||||||
|
rel="noopener noreferrer"
|
||||||
|
href="https://cloud.tencent.com/act/cps/redirect?redirect=1074&cps_key=5516bbd5876cd224d90bd41d53d3f7fe&from=console"
|
||||||
|
>
|
||||||
|
腾讯云优惠
|
||||||
|
</a>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: '7',
|
||||||
|
label: (
|
||||||
|
<a
|
||||||
|
target="_blank"
|
||||||
|
rel="noopener noreferrer"
|
||||||
|
href="https://activity.huaweicloud.com/discount_area_v5/index.html?fromacct=a87e1945-e6c4-4e04-bb43-e0472a54e454&utm_source=V1g3MDY4NTY=&utm_medium=cps&utm_campaign=201905"
|
||||||
|
>
|
||||||
|
华为云优惠
|
||||||
|
</a>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<a onClick={(e) => e.preventDefault()}>
|
||||||
|
<Space size="small">
|
||||||
|
相关链接
|
||||||
|
<CaretDownFilled />
|
||||||
|
</Space>
|
||||||
|
</a>
|
||||||
|
</Dropdown>
|
||||||
|
</Space>
|
||||||
|
);
|
||||||
|
},
|
||||||
|
// 自定义 403 页面
|
||||||
|
// unAccessible: <div>unAccessible</div>,
|
||||||
|
// 增加一个 loading 的状态
|
||||||
|
childrenRender: (children, props) => {
|
||||||
|
if (initialState?.loading) return <PageLoading />;
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
{children}
|
||||||
|
{!props.location?.pathname?.includes('/login') && (
|
||||||
|
<SettingDrawer
|
||||||
|
disableUrlParams
|
||||||
|
enableDarkTheme
|
||||||
|
settings={initialState?.settings}
|
||||||
|
onSettingChange={(settings) => {
|
||||||
|
setInitialState((preInitialState) => ({
|
||||||
|
...preInitialState,
|
||||||
|
settings,
|
||||||
|
}));
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
},
|
||||||
|
...initialState?.settings,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
const authHeaderInterceptor = (url: string, options: RequestConfig) => {
|
||||||
|
const accessToken = sessionStorage.getItem('access_token');
|
||||||
|
const authHeader = {};
|
||||||
|
if (accessToken && !url.includes('/api-uaa/oauth/token')) {
|
||||||
|
authHeader.Authorization = `Bearer ${accessToken}`;
|
||||||
|
}
|
||||||
|
const newHeaders = { ...options.headers, ...authHeader };
|
||||||
|
return {
|
||||||
|
url,
|
||||||
|
options: { ...options, interceptors: true, headers: newHeaders },
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
const unauthorizedInterceptor = (response: Response) => {
|
||||||
|
if (response.status === 401) {
|
||||||
|
const { location } = history;
|
||||||
|
// 如果没有登录,重定向到 login
|
||||||
|
if (location.pathname !== loginPath) {
|
||||||
|
history.push(loginPath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return response;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const request: RequestConfig = {
|
||||||
|
// 新增自动添加AccessToken的请求前拦截器
|
||||||
|
requestInterceptors: [authHeaderInterceptor],
|
||||||
|
responseInterceptors: [unauthorizedInterceptor],
|
||||||
|
errorConfig: {
|
||||||
|
adaptor: (resData) => {
|
||||||
|
return {
|
||||||
|
...resData,
|
||||||
|
errorMessage: '请求错误',
|
||||||
|
};
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
import { GithubOutlined } from '@ant-design/icons';
|
||||||
|
import { DefaultFooter } from '@ant-design/pro-components';
|
||||||
|
import { useIntl } from 'umi';
|
||||||
|
|
||||||
|
const Footer: React.FC = () => {
|
||||||
|
const intl = useIntl();
|
||||||
|
const defaultMessage = intl.formatMessage({
|
||||||
|
id: 'app.copyright.produced',
|
||||||
|
defaultMessage: 'zlt版权所有:https://gitee.com/zlt2000/microservices-platform',
|
||||||
|
});
|
||||||
|
|
||||||
|
// const currentYear = new Date().getFullYear();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<DefaultFooter
|
||||||
|
copyright={`${2018} ${defaultMessage}`}
|
||||||
|
links={[
|
||||||
|
{
|
||||||
|
key: 'github',
|
||||||
|
title: <GithubOutlined />,
|
||||||
|
href: 'https://github.com/zlt2000/microservices-platform',
|
||||||
|
blankTarget: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'beian',
|
||||||
|
title: '粤ICP备19081412号',
|
||||||
|
href: 'https://beian.miit.gov.cn/',
|
||||||
|
blankTarget: true,
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default Footer;
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
@import (reference) '~antd/es/style/themes/index';
|
||||||
|
|
||||||
|
.container > * {
|
||||||
|
background-color: @popover-bg;
|
||||||
|
border-radius: 4px;
|
||||||
|
box-shadow: @shadow-1-down;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media screen and (max-width: @screen-xs) {
|
||||||
|
.container {
|
||||||
|
width: 100% !important;
|
||||||
|
}
|
||||||
|
.container > * {
|
||||||
|
border-radius: 0 !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
import { Dropdown } from 'antd';
|
||||||
|
import type { DropDownProps } from 'antd/es/dropdown';
|
||||||
|
import classNames from 'classnames';
|
||||||
|
import React from 'react';
|
||||||
|
import styles from './index.less';
|
||||||
|
|
||||||
|
export type HeaderDropdownProps = {
|
||||||
|
overlayClassName?: string;
|
||||||
|
overlay: React.ReactNode | (() => React.ReactNode) | any;
|
||||||
|
placement?: 'bottomLeft' | 'bottomRight' | 'topLeft' | 'topCenter' | 'topRight' | 'bottomCenter';
|
||||||
|
} & Omit<DropDownProps, 'overlay'>;
|
||||||
|
|
||||||
|
const HeaderDropdown: React.FC<HeaderDropdownProps> = ({ overlayClassName: cls, ...restProps }) => (
|
||||||
|
<Dropdown overlayClassName={classNames(styles.container, cls)} {...restProps} />
|
||||||
|
);
|
||||||
|
|
||||||
|
export default HeaderDropdown;
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
@import (reference) '~antd/es/style/themes/index';
|
||||||
|
|
||||||
|
.headerSearch {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
.input {
|
||||||
|
width: 0;
|
||||||
|
min-width: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
background: transparent;
|
||||||
|
border-radius: 0;
|
||||||
|
transition: width 0.3s, margin-left 0.3s;
|
||||||
|
:global(.ant-select-selection) {
|
||||||
|
background: transparent;
|
||||||
|
}
|
||||||
|
input {
|
||||||
|
box-shadow: none !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.show {
|
||||||
|
width: 210px;
|
||||||
|
margin-left: 8px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,101 @@
|
|||||||
|
import { SearchOutlined } from '@ant-design/icons';
|
||||||
|
import type { InputRef } from 'antd';
|
||||||
|
import { AutoComplete, Input } from 'antd';
|
||||||
|
import type { AutoCompleteProps } from 'antd/es/auto-complete';
|
||||||
|
import classNames from 'classnames';
|
||||||
|
import useMergedState from 'rc-util/es/hooks/useMergedState';
|
||||||
|
import React, { useRef } from 'react';
|
||||||
|
import styles from './index.less';
|
||||||
|
|
||||||
|
export type HeaderSearchProps = {
|
||||||
|
onSearch?: (value?: string) => void;
|
||||||
|
onChange?: (value?: string) => void;
|
||||||
|
onVisibleChange?: (b: boolean) => void;
|
||||||
|
className?: string;
|
||||||
|
placeholder?: string;
|
||||||
|
options: AutoCompleteProps['options'];
|
||||||
|
defaultVisible?: boolean;
|
||||||
|
visible?: boolean;
|
||||||
|
defaultValue?: string;
|
||||||
|
value?: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
const HeaderSearch: React.FC<HeaderSearchProps> = (props) => {
|
||||||
|
const {
|
||||||
|
className,
|
||||||
|
defaultValue,
|
||||||
|
onVisibleChange,
|
||||||
|
placeholder,
|
||||||
|
visible,
|
||||||
|
defaultVisible,
|
||||||
|
...restProps
|
||||||
|
} = props;
|
||||||
|
|
||||||
|
const inputRef = useRef<InputRef | null>(null);
|
||||||
|
|
||||||
|
const [value, setValue] = useMergedState<string | undefined>(defaultValue, {
|
||||||
|
value: props.value,
|
||||||
|
onChange: props.onChange,
|
||||||
|
});
|
||||||
|
|
||||||
|
const [searchMode, setSearchMode] = useMergedState(defaultVisible ?? false, {
|
||||||
|
value: props.visible,
|
||||||
|
onChange: onVisibleChange,
|
||||||
|
});
|
||||||
|
|
||||||
|
const inputClass = classNames(styles.input, {
|
||||||
|
[styles.show]: searchMode,
|
||||||
|
});
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
className={classNames(className, styles.headerSearch)}
|
||||||
|
onClick={() => {
|
||||||
|
setSearchMode(true);
|
||||||
|
if (searchMode && inputRef.current) {
|
||||||
|
inputRef.current.focus();
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
onTransitionEnd={({ propertyName }) => {
|
||||||
|
if (propertyName === 'width' && !searchMode) {
|
||||||
|
if (onVisibleChange) {
|
||||||
|
onVisibleChange(searchMode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<SearchOutlined
|
||||||
|
key="Icon"
|
||||||
|
style={{
|
||||||
|
cursor: 'pointer',
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<AutoComplete
|
||||||
|
key="AutoComplete"
|
||||||
|
className={inputClass}
|
||||||
|
value={value}
|
||||||
|
options={restProps.options}
|
||||||
|
onChange={(completeValue) => setValue(completeValue)}
|
||||||
|
>
|
||||||
|
<Input
|
||||||
|
size="small"
|
||||||
|
ref={inputRef}
|
||||||
|
defaultValue={defaultValue}
|
||||||
|
aria-label={placeholder}
|
||||||
|
placeholder={placeholder}
|
||||||
|
onKeyDown={(e) => {
|
||||||
|
if (e.key === 'Enter') {
|
||||||
|
if (restProps.onSearch) {
|
||||||
|
restProps.onSearch(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
onBlur={() => {
|
||||||
|
setSearchMode(false);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</AutoComplete>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default HeaderSearch;
|
||||||
@@ -0,0 +1,108 @@
|
|||||||
|
import { outLogin } from '@/services/login/api';
|
||||||
|
import { LogoutOutlined, UserOutlined } from '@ant-design/icons';
|
||||||
|
import { Avatar, Menu, Spin } from 'antd';
|
||||||
|
import type { ItemType } from 'antd/lib/menu/hooks/useItems';
|
||||||
|
import { stringify } from 'querystring';
|
||||||
|
import type { MenuInfo } from 'rc-menu/lib/interface';
|
||||||
|
import React, { useCallback } from 'react';
|
||||||
|
import { history, useModel } from 'umi';
|
||||||
|
import HeaderDropdown from '../HeaderDropdown';
|
||||||
|
import styles from './index.less';
|
||||||
|
|
||||||
|
export type GlobalHeaderRightProps = {
|
||||||
|
menu?: boolean;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 退出登录,并且将当前的 url 保存
|
||||||
|
*/
|
||||||
|
const loginOut = async () => {
|
||||||
|
await outLogin();
|
||||||
|
const { query = {}, search, pathname } = history.location;
|
||||||
|
const { redirect } = query;
|
||||||
|
// Note: There may be security issues, please note
|
||||||
|
if (window.location.pathname !== '/user/login' && !redirect) {
|
||||||
|
history.replace({
|
||||||
|
pathname: '/user/login',
|
||||||
|
search: stringify({
|
||||||
|
redirect: pathname + search,
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const AvatarDropdown: React.FC<GlobalHeaderRightProps> = ({ menu }) => {
|
||||||
|
const { initialState, setInitialState } = useModel('@@initialState');
|
||||||
|
|
||||||
|
const onMenuClick = useCallback(
|
||||||
|
(event: MenuInfo) => {
|
||||||
|
const { key } = event;
|
||||||
|
if (key === 'logout') {
|
||||||
|
setInitialState((s) => ({ ...s, currentUser: undefined }));
|
||||||
|
loginOut();
|
||||||
|
return;
|
||||||
|
} else if (key === 'center') {
|
||||||
|
history.push('/system/myInfo.html');
|
||||||
|
}
|
||||||
|
},
|
||||||
|
[setInitialState],
|
||||||
|
);
|
||||||
|
|
||||||
|
const loading = (
|
||||||
|
<span className={`${styles.action} ${styles.account}`}>
|
||||||
|
<Spin
|
||||||
|
size="small"
|
||||||
|
style={{
|
||||||
|
marginLeft: 8,
|
||||||
|
marginRight: 8,
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</span>
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!initialState) {
|
||||||
|
return loading;
|
||||||
|
}
|
||||||
|
|
||||||
|
const { currentUser } = initialState;
|
||||||
|
|
||||||
|
if (!currentUser || !currentUser.nickname) {
|
||||||
|
return loading;
|
||||||
|
}
|
||||||
|
|
||||||
|
const menuItems: ItemType[] = [
|
||||||
|
...(menu
|
||||||
|
? [
|
||||||
|
{
|
||||||
|
key: 'center',
|
||||||
|
icon: <UserOutlined />,
|
||||||
|
label: '个人中心',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'divider' as const,
|
||||||
|
},
|
||||||
|
]
|
||||||
|
: []),
|
||||||
|
|
||||||
|
{
|
||||||
|
key: 'logout',
|
||||||
|
icon: <LogoutOutlined />,
|
||||||
|
label: '退出登录',
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
const menuHeaderDropdown = (
|
||||||
|
<Menu className={styles.menu} selectedKeys={[]} onClick={onMenuClick} items={menuItems} />
|
||||||
|
);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<HeaderDropdown overlay={menuHeaderDropdown}>
|
||||||
|
<span className={`${styles.action} ${styles.account}`}>
|
||||||
|
<Avatar size="small" className={styles.avatar} src={currentUser.headImgUrl} alt="avatar" />
|
||||||
|
<span className={`${styles.name} anticon`}>{currentUser.nickname}</span>
|
||||||
|
</span>
|
||||||
|
</HeaderDropdown>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default AvatarDropdown;
|
||||||
@@ -0,0 +1,84 @@
|
|||||||
|
@import (reference) '~antd/es/style/themes/index';
|
||||||
|
|
||||||
|
@pro-header-hover-bg: rgba(0, 0, 0, 0.025);
|
||||||
|
|
||||||
|
.menu {
|
||||||
|
:global(.anticon) {
|
||||||
|
margin-right: 8px;
|
||||||
|
}
|
||||||
|
:global(.ant-dropdown-menu-item) {
|
||||||
|
min-width: 160px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.right {
|
||||||
|
display: flex;
|
||||||
|
float: right;
|
||||||
|
height: 48px;
|
||||||
|
margin-left: auto;
|
||||||
|
overflow: hidden;
|
||||||
|
.action {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
height: 48px;
|
||||||
|
padding: 0 12px;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: all 0.3s;
|
||||||
|
> span {
|
||||||
|
vertical-align: middle;
|
||||||
|
}
|
||||||
|
&:hover {
|
||||||
|
background: @pro-header-hover-bg;
|
||||||
|
}
|
||||||
|
&:global(.opened) {
|
||||||
|
background: @pro-header-hover-bg;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.search {
|
||||||
|
padding: 0 12px;
|
||||||
|
&:hover {
|
||||||
|
background: transparent;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.account {
|
||||||
|
.avatar {
|
||||||
|
margin-right: 8px;
|
||||||
|
color: @primary-color;
|
||||||
|
vertical-align: top;
|
||||||
|
background: rgba(255, 255, 255, 0.85);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.dark {
|
||||||
|
.action {
|
||||||
|
&:hover {
|
||||||
|
background: #252a3d;
|
||||||
|
}
|
||||||
|
&:global(.opened) {
|
||||||
|
background: #252a3d;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media only screen and (max-width: @screen-md) {
|
||||||
|
:global(.ant-divider-vertical) {
|
||||||
|
vertical-align: unset;
|
||||||
|
}
|
||||||
|
.name {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
.right {
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
right: 12px;
|
||||||
|
.account {
|
||||||
|
.avatar {
|
||||||
|
margin-right: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.search {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,68 @@
|
|||||||
|
import { GithubOutlined, QuestionCircleOutlined } from '@ant-design/icons';
|
||||||
|
import { Space } from 'antd';
|
||||||
|
import React from 'react';
|
||||||
|
import { useModel } from 'umi';
|
||||||
|
import AvatarDropdown from './AvatarDropdown';
|
||||||
|
import styles from './index.less';
|
||||||
|
|
||||||
|
export type SiderTheme = 'light' | 'dark';
|
||||||
|
|
||||||
|
const GlobalHeaderRight: React.FC = () => {
|
||||||
|
const { initialState } = useModel('@@initialState');
|
||||||
|
|
||||||
|
if (!initialState || !initialState.settings) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
const { navTheme, layout } = initialState.settings;
|
||||||
|
let className = styles.right;
|
||||||
|
|
||||||
|
if ((navTheme === 'dark' && layout === 'top') || layout === 'mix') {
|
||||||
|
className = `${styles.right} ${styles.dark}`;
|
||||||
|
}
|
||||||
|
return (
|
||||||
|
<Space className={className}>
|
||||||
|
{/* <HeaderSearch
|
||||||
|
className={`${styles.action} ${styles.search}`}
|
||||||
|
placeholder="站内搜索"
|
||||||
|
defaultValue="umi ui"
|
||||||
|
options={[
|
||||||
|
{ label: <a href="https://umijs.org/zh/guide/umi-ui.html">umi ui</a>, value: 'umi ui' },
|
||||||
|
{
|
||||||
|
label: <a href="next.ant.design">Ant Design</a>,
|
||||||
|
value: 'Ant Design',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: <a href="https://protable.ant.design/">Pro Table</a>,
|
||||||
|
value: 'Pro Table',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: <a href="https://prolayout.ant.design/">Pro Layout</a>,
|
||||||
|
value: 'Pro Layout',
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
onSearch={value => {
|
||||||
|
console.log('input', value);
|
||||||
|
}}
|
||||||
|
/> */}
|
||||||
|
<span
|
||||||
|
className={styles.action}
|
||||||
|
onClick={() => {
|
||||||
|
window.open('https://www.kancloud.cn/zlt2000/microservices-platform');
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<QuestionCircleOutlined />
|
||||||
|
</span>
|
||||||
|
<span
|
||||||
|
className={styles.action}
|
||||||
|
onClick={() => {
|
||||||
|
window.open('https://github.com/zlt2000/microservices-platform');
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<GithubOutlined />
|
||||||
|
</span>
|
||||||
|
<AvatarDropdown menu />
|
||||||
|
</Space>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
export default GlobalHeaderRight;
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
import type { Page } from '@playwright/test';
|
||||||
|
import { expect, test } from '@playwright/test';
|
||||||
|
const { uniq } = require('lodash');
|
||||||
|
const RouterConfig = require('../../config/routes').default;
|
||||||
|
|
||||||
|
const BASE_URL = `http://localhost:${process.env.PORT || 8001}`;
|
||||||
|
|
||||||
|
function formatter(routes: any, parentPath = ''): string[] {
|
||||||
|
const fixedParentPath = parentPath.replace(/\/{1,}/g, '/');
|
||||||
|
let result: string[] = [];
|
||||||
|
routes.forEach((item: { path: string; routes: string }) => {
|
||||||
|
if (item.path && !item.path.startsWith('/')) {
|
||||||
|
result.push(`${fixedParentPath}/${item.path}`.replace(/\/{1,}/g, '/'));
|
||||||
|
}
|
||||||
|
if (item.path && item.path.startsWith('/')) {
|
||||||
|
result.push(`${item.path}`.replace(/\/{1,}/g, '/'));
|
||||||
|
}
|
||||||
|
if (item.routes) {
|
||||||
|
result = result.concat(
|
||||||
|
formatter(item.routes, item.path ? `${fixedParentPath}/${item.path}` : parentPath),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return uniq(result.filter((item) => !!item));
|
||||||
|
}
|
||||||
|
|
||||||
|
const testPage = (path: string, page: Page) => async () => {
|
||||||
|
await page.evaluate(() => {
|
||||||
|
localStorage.setItem('antd-pro-authority', '["admin"]');
|
||||||
|
});
|
||||||
|
await page.goto(`${BASE_URL}${path}`);
|
||||||
|
await page.waitForSelector('footer', {
|
||||||
|
timeout: 2000,
|
||||||
|
});
|
||||||
|
const haveFooter = await page.evaluate(() => document.getElementsByTagName('footer').length > 0);
|
||||||
|
expect(haveFooter).toBeTruthy();
|
||||||
|
};
|
||||||
|
|
||||||
|
const routers = formatter(RouterConfig);
|
||||||
|
|
||||||
|
routers.forEach((route) => {
|
||||||
|
test(`test route page ${route}`, async ({ page }) => {
|
||||||
|
await testPage(route, page);
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -0,0 +1,72 @@
|
|||||||
|
@import '~antd/es/style/variable.less';
|
||||||
|
|
||||||
|
html,
|
||||||
|
body,
|
||||||
|
#root {
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.colorWeak {
|
||||||
|
filter: invert(80%);
|
||||||
|
}
|
||||||
|
|
||||||
|
.ant-layout {
|
||||||
|
min-height: 100vh;
|
||||||
|
}
|
||||||
|
.ant-pro-sider.ant-layout-sider.ant-pro-sider-fixed {
|
||||||
|
left: unset;
|
||||||
|
}
|
||||||
|
|
||||||
|
canvas {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
body {
|
||||||
|
text-rendering: optimizeLegibility;
|
||||||
|
-webkit-font-smoothing: antialiased;
|
||||||
|
-moz-osx-font-smoothing: grayscale;
|
||||||
|
}
|
||||||
|
|
||||||
|
ul,
|
||||||
|
ol {
|
||||||
|
list-style: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ant-layout-content {
|
||||||
|
.query-filter {
|
||||||
|
margin-bottom: @margin-md;
|
||||||
|
padding: @padding-lg;
|
||||||
|
padding-bottom: 0;
|
||||||
|
background: @component-background;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.audit-log {
|
||||||
|
mark {
|
||||||
|
background-color: @gold-3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: @screen-xs) {
|
||||||
|
.ant-table {
|
||||||
|
width: 100%;
|
||||||
|
overflow-x: auto;
|
||||||
|
&-thead > tr,
|
||||||
|
&-tbody > tr {
|
||||||
|
> th,
|
||||||
|
> td {
|
||||||
|
white-space: pre;
|
||||||
|
> span {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Compatible with IE11
|
||||||
|
@media screen and(-ms-high-contrast: active), (-ms-high-contrast: none) {
|
||||||
|
body .ant-design-pro > .ant-layout {
|
||||||
|
min-height: 100vh;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,91 @@
|
|||||||
|
import { Button, message, notification } from 'antd';
|
||||||
|
import { useIntl } from 'umi';
|
||||||
|
import defaultSettings from '../config/defaultSettings';
|
||||||
|
|
||||||
|
const { pwa } = defaultSettings;
|
||||||
|
const isHttps = document.location.protocol === 'https:';
|
||||||
|
|
||||||
|
const clearCache = () => {
|
||||||
|
// remove all caches
|
||||||
|
if (window.caches) {
|
||||||
|
caches
|
||||||
|
.keys()
|
||||||
|
.then((keys) => {
|
||||||
|
keys.forEach((key) => {
|
||||||
|
caches.delete(key);
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.catch((e) => console.log(e));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// if pwa is true
|
||||||
|
if (pwa) {
|
||||||
|
// Notify user if offline now
|
||||||
|
window.addEventListener('sw.offline', () => {
|
||||||
|
message.warning(useIntl().formatMessage({ id: 'app.pwa.offline' }));
|
||||||
|
});
|
||||||
|
|
||||||
|
// Pop up a prompt on the page asking the user if they want to use the latest version
|
||||||
|
window.addEventListener('sw.updated', (event: Event) => {
|
||||||
|
const e = event as CustomEvent;
|
||||||
|
const reloadSW = async () => {
|
||||||
|
// Check if there is sw whose state is waiting in ServiceWorkerRegistration
|
||||||
|
// https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerRegistration
|
||||||
|
const worker = e.detail && e.detail.waiting;
|
||||||
|
if (!worker) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
// Send skip-waiting event to waiting SW with MessageChannel
|
||||||
|
await new Promise((resolve, reject) => {
|
||||||
|
const channel = new MessageChannel();
|
||||||
|
channel.port1.onmessage = (msgEvent) => {
|
||||||
|
if (msgEvent.data.error) {
|
||||||
|
reject(msgEvent.data.error);
|
||||||
|
} else {
|
||||||
|
resolve(msgEvent.data);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
worker.postMessage({ type: 'skip-waiting' }, [channel.port2]);
|
||||||
|
});
|
||||||
|
|
||||||
|
clearCache();
|
||||||
|
window.location.reload();
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
const key = `open${Date.now()}`;
|
||||||
|
const btn = (
|
||||||
|
<Button
|
||||||
|
type="primary"
|
||||||
|
onClick={() => {
|
||||||
|
notification.close(key);
|
||||||
|
reloadSW();
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{useIntl().formatMessage({ id: 'app.pwa.serviceworker.updated.ok' })}
|
||||||
|
</Button>
|
||||||
|
);
|
||||||
|
notification.open({
|
||||||
|
message: useIntl().formatMessage({ id: 'app.pwa.serviceworker.updated' }),
|
||||||
|
description: useIntl().formatMessage({ id: 'app.pwa.serviceworker.updated.hint' }),
|
||||||
|
btn,
|
||||||
|
key,
|
||||||
|
onClose: async () => null,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
} else if ('serviceWorker' in navigator && isHttps) {
|
||||||
|
// unregister service worker
|
||||||
|
const { serviceWorker } = navigator;
|
||||||
|
if (serviceWorker.getRegistrations) {
|
||||||
|
serviceWorker.getRegistrations().then((sws) => {
|
||||||
|
sws.forEach((sw) => {
|
||||||
|
sw.unregister();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
serviceWorker.getRegistration().then((sw) => {
|
||||||
|
if (sw) sw.unregister();
|
||||||
|
});
|
||||||
|
|
||||||
|
clearCache();
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
import component from './zh-CN/component';
|
||||||
|
import globalHeader from './zh-CN/globalHeader';
|
||||||
|
import menu from './zh-CN/menu';
|
||||||
|
import pages from './zh-CN/pages';
|
||||||
|
import pwa from './zh-CN/pwa';
|
||||||
|
import settingDrawer from './zh-CN/settingDrawer';
|
||||||
|
import settings from './zh-CN/settings';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
'navBar.lang': '语言',
|
||||||
|
'layout.user.link.help': '帮助',
|
||||||
|
'layout.user.link.privacy': '隐私',
|
||||||
|
'layout.user.link.terms': '条款',
|
||||||
|
'app.copyright.produced': 'zlt版权所有:https://gitee.com/zlt2000/microservices-platform',
|
||||||
|
'app.preview.down.block': '下载此页面到本地项目',
|
||||||
|
'app.welcome.link.fetch-blocks': '获取全部区块',
|
||||||
|
'app.welcome.link.block-list': '基于 block 开发,快速构建标准页面',
|
||||||
|
...pages,
|
||||||
|
...globalHeader,
|
||||||
|
...menu,
|
||||||
|
...settingDrawer,
|
||||||
|
...settings,
|
||||||
|
...pwa,
|
||||||
|
...component,
|
||||||
|
};
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
export default {
|
||||||
|
'component.tagSelect.expand': '展开',
|
||||||
|
'component.tagSelect.collapse': '收起',
|
||||||
|
'component.tagSelect.all': '全部',
|
||||||
|
};
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
export default {
|
||||||
|
'component.globalHeader.search': '站内搜索',
|
||||||
|
'component.globalHeader.search.example1': '搜索提示一',
|
||||||
|
'component.globalHeader.search.example2': '搜索提示二',
|
||||||
|
'component.globalHeader.search.example3': '搜索提示三',
|
||||||
|
'component.globalHeader.help': '使用文档',
|
||||||
|
'component.globalHeader.notification': '通知',
|
||||||
|
'component.globalHeader.notification.empty': '你已查看所有通知',
|
||||||
|
'component.globalHeader.message': '消息',
|
||||||
|
'component.globalHeader.message.empty': '您已读完所有消息',
|
||||||
|
'component.globalHeader.event': '待办',
|
||||||
|
'component.globalHeader.event.empty': '你已完成所有待办',
|
||||||
|
'component.noticeIcon.clear': '清空',
|
||||||
|
'component.noticeIcon.cleared': '清空了',
|
||||||
|
'component.noticeIcon.empty': '暂无数据',
|
||||||
|
'component.noticeIcon.view-more': '查看更多',
|
||||||
|
};
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
export default {
|
||||||
|
'menu.welcome': '欢迎',
|
||||||
|
'menu.more-blocks': '更多区块',
|
||||||
|
'menu.home': '首页',
|
||||||
|
'menu.admin': '管理页',
|
||||||
|
'menu.admin.sub-page': '二级管理页',
|
||||||
|
'menu.login': '登录',
|
||||||
|
'menu.register': '注册',
|
||||||
|
'menu.register-result': '注册结果',
|
||||||
|
'menu.dashboard': 'Dashboard',
|
||||||
|
'menu.dashboard.analysis': '分析页',
|
||||||
|
'menu.dashboard.monitor': '监控页',
|
||||||
|
'menu.dashboard.workplace': '工作台',
|
||||||
|
'menu.exception.403': '403',
|
||||||
|
'menu.exception.404': '404',
|
||||||
|
'menu.exception.500': '500',
|
||||||
|
'menu.form': '表单页',
|
||||||
|
'menu.form.basic-form': '基础表单',
|
||||||
|
'menu.form.step-form': '分步表单',
|
||||||
|
'menu.form.step-form.info': '分步表单(填写转账信息)',
|
||||||
|
'menu.form.step-form.confirm': '分步表单(确认转账信息)',
|
||||||
|
'menu.form.step-form.result': '分步表单(完成)',
|
||||||
|
'menu.form.advanced-form': '高级表单',
|
||||||
|
'menu.list': '列表页',
|
||||||
|
'menu.list.table-list': '查询表格',
|
||||||
|
'menu.list.basic-list': '标准列表',
|
||||||
|
'menu.list.card-list': '卡片列表',
|
||||||
|
'menu.list.search-list': '搜索列表',
|
||||||
|
'menu.list.search-list.articles': '搜索列表(文章)',
|
||||||
|
'menu.list.search-list.projects': '搜索列表(项目)',
|
||||||
|
'menu.list.search-list.applications': '搜索列表(应用)',
|
||||||
|
'menu.profile': '详情页',
|
||||||
|
'menu.profile.basic': '基础详情页',
|
||||||
|
'menu.profile.advanced': '高级详情页',
|
||||||
|
'menu.result': '结果页',
|
||||||
|
'menu.result.success': '成功页',
|
||||||
|
'menu.result.fail': '失败页',
|
||||||
|
'menu.exception': '异常页',
|
||||||
|
'menu.exception.not-permission': '403',
|
||||||
|
'menu.exception.not-find': '404',
|
||||||
|
'menu.exception.server-error': '500',
|
||||||
|
'menu.exception.trigger': '触发错误',
|
||||||
|
'menu.account': '个人页',
|
||||||
|
'menu.account.center': '个人中心',
|
||||||
|
'menu.account.settings': '个人设置',
|
||||||
|
'menu.account.trigger': '触发报错',
|
||||||
|
'menu.account.logout': '退出登录',
|
||||||
|
'menu.editor': '图形编辑器',
|
||||||
|
'menu.editor.flow': '流程编辑器',
|
||||||
|
'menu.editor.mind': '脑图编辑器',
|
||||||
|
'menu.editor.koni': '拓扑编辑器',
|
||||||
|
};
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
export default {
|
||||||
|
'pages.layouts.userLayout.title': '前后端分离的企业级微服务架构',
|
||||||
|
'pages.login.accountLogin.tab': '账户密码登录',
|
||||||
|
'pages.login.accountLogin.errorMessage': '错误的账号和密码(admin/ant.design)',
|
||||||
|
'pages.login.failure': '登录失败,请重试!',
|
||||||
|
'pages.login.success': '登录成功!',
|
||||||
|
'pages.login.username.placeholder': '账号',
|
||||||
|
'pages.login.username.required': '账号是必填项!',
|
||||||
|
'pages.login.password.placeholder': '密码',
|
||||||
|
'pages.login.password.required': '密码是必填项!',
|
||||||
|
'pages.login.phoneLogin.tab': '手机号登录',
|
||||||
|
'pages.login.phoneLogin.errorMessage': '验证码错误',
|
||||||
|
'pages.login.phoneNumber.placeholder': '请输入手机号!',
|
||||||
|
'pages.login.phoneNumber.required': '手机号是必填项!',
|
||||||
|
'pages.login.phoneNumber.invalid': '不合法的手机号!',
|
||||||
|
'pages.login.captcha.placeholder': '请输入验证码!',
|
||||||
|
'pages.login.captcha.required': '验证码是必填项!',
|
||||||
|
'pages.login.phoneLogin.getVerificationCode': '获取验证码',
|
||||||
|
'pages.getCaptchaSecondText': '秒后重新获取',
|
||||||
|
'pages.login.rememberMe': '自动登录',
|
||||||
|
'pages.login.forgotPassword': '忘记密码 ?',
|
||||||
|
'pages.login.submit': '登录',
|
||||||
|
'pages.login.loginWith': '其他登录方式 :',
|
||||||
|
'pages.login.registerAccount': '注册账户',
|
||||||
|
'pages.welcome.link': '欢迎使用',
|
||||||
|
'pages.welcome.alertMessage': '更快更强的重型组件,已经发布。',
|
||||||
|
'pages.admin.subPage.title': ' 这个页面只有 admin 权限才能查看',
|
||||||
|
'pages.admin.subPage.alertMessage': 'umi ui 现已发布,欢迎使用 npm run ui 启动体验。',
|
||||||
|
'pages.searchTable.createForm.newRule': '新建规则',
|
||||||
|
'pages.searchTable.updateForm.ruleConfig': '规则配置',
|
||||||
|
'pages.searchTable.updateForm.basicConfig': '基本信息',
|
||||||
|
'pages.searchTable.updateForm.ruleName.nameLabel': '规则名称',
|
||||||
|
'pages.searchTable.updateForm.ruleName.nameRules': '请输入规则名称!',
|
||||||
|
'pages.searchTable.updateForm.ruleDesc.descLabel': '规则描述',
|
||||||
|
'pages.searchTable.updateForm.ruleDesc.descPlaceholder': '请输入至少五个字符',
|
||||||
|
'pages.searchTable.updateForm.ruleDesc.descRules': '请输入至少五个字符的规则描述!',
|
||||||
|
'pages.searchTable.updateForm.ruleProps.title': '配置规则属性',
|
||||||
|
'pages.searchTable.updateForm.object': '监控对象',
|
||||||
|
'pages.searchTable.updateForm.ruleProps.templateLabel': '规则模板',
|
||||||
|
'pages.searchTable.updateForm.ruleProps.typeLabel': '规则类型',
|
||||||
|
'pages.searchTable.updateForm.schedulingPeriod.title': '设定调度周期',
|
||||||
|
'pages.searchTable.updateForm.schedulingPeriod.timeLabel': '开始时间',
|
||||||
|
'pages.searchTable.updateForm.schedulingPeriod.timeRules': '请选择开始时间!',
|
||||||
|
'pages.searchTable.titleDesc': '描述',
|
||||||
|
'pages.searchTable.ruleName': '规则名称为必填项',
|
||||||
|
'pages.searchTable.titleCallNo': '服务调用次数',
|
||||||
|
'pages.searchTable.titleStatus': '状态',
|
||||||
|
'pages.searchTable.nameStatus.default': '关闭',
|
||||||
|
'pages.searchTable.nameStatus.running': '运行中',
|
||||||
|
'pages.searchTable.nameStatus.online': '已上线',
|
||||||
|
'pages.searchTable.nameStatus.abnormal': '异常',
|
||||||
|
'pages.searchTable.titleUpdatedAt': '上次调度时间',
|
||||||
|
'pages.searchTable.exception': '请输入异常原因!',
|
||||||
|
'pages.searchTable.titleOption': '操作',
|
||||||
|
'pages.searchTable.config': '配置',
|
||||||
|
'pages.searchTable.subscribeAlert': '订阅警报',
|
||||||
|
'pages.searchTable.title': '查询表格',
|
||||||
|
'pages.searchTable.new': '新建',
|
||||||
|
'pages.searchTable.chosen': '已选择',
|
||||||
|
'pages.searchTable.item': '项',
|
||||||
|
'pages.searchTable.totalServiceCalls': '服务调用次数总计',
|
||||||
|
'pages.searchTable.tenThousand': '万',
|
||||||
|
'pages.searchTable.batchDeletion': '批量删除',
|
||||||
|
'pages.searchTable.batchApproval': '批量审批',
|
||||||
|
};
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
export default {
|
||||||
|
'app.pwa.offline': '当前处于离线状态',
|
||||||
|
'app.pwa.serviceworker.updated': '有新内容',
|
||||||
|
'app.pwa.serviceworker.updated.hint': '请点击“刷新”按钮或者手动刷新页面',
|
||||||
|
'app.pwa.serviceworker.updated.ok': '刷新',
|
||||||
|
};
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
export default {
|
||||||
|
'app.setting.pagestyle': '整体风格设置',
|
||||||
|
'app.setting.pagestyle.dark': '暗色菜单风格',
|
||||||
|
'app.setting.pagestyle.light': '亮色菜单风格',
|
||||||
|
'app.setting.content-width': '内容区域宽度',
|
||||||
|
'app.setting.content-width.fixed': '定宽',
|
||||||
|
'app.setting.content-width.fluid': '流式',
|
||||||
|
'app.setting.themecolor': '主题色',
|
||||||
|
'app.setting.themecolor.dust': '薄暮',
|
||||||
|
'app.setting.themecolor.volcano': '火山',
|
||||||
|
'app.setting.themecolor.sunset': '日暮',
|
||||||
|
'app.setting.themecolor.cyan': '明青',
|
||||||
|
'app.setting.themecolor.green': '极光绿',
|
||||||
|
'app.setting.themecolor.daybreak': '拂晓蓝(默认)',
|
||||||
|
'app.setting.themecolor.geekblue': '极客蓝',
|
||||||
|
'app.setting.themecolor.purple': '酱紫',
|
||||||
|
'app.setting.navigationmode': '导航模式',
|
||||||
|
'app.setting.sidemenu': '侧边菜单布局',
|
||||||
|
'app.setting.topmenu': '顶部菜单布局',
|
||||||
|
'app.setting.fixedheader': '固定 Header',
|
||||||
|
'app.setting.fixedsidebar': '固定侧边菜单',
|
||||||
|
'app.setting.fixedsidebar.hint': '侧边菜单布局时可配置',
|
||||||
|
'app.setting.hideheader': '下滑时隐藏 Header',
|
||||||
|
'app.setting.hideheader.hint': '固定 Header 时可配置',
|
||||||
|
'app.setting.othersettings': '其他设置',
|
||||||
|
'app.setting.weakmode': '色弱模式',
|
||||||
|
'app.setting.copy': '拷贝设置',
|
||||||
|
'app.setting.copyinfo': '拷贝成功,请到 config/defaultSettings.js 中替换默认配置',
|
||||||
|
'app.setting.production.hint':
|
||||||
|
'配置栏只在开发环境用于预览,生产环境不会展现,请拷贝后手动修改配置文件',
|
||||||
|
};
|
||||||
@@ -0,0 +1,55 @@
|
|||||||
|
export default {
|
||||||
|
'app.settings.menuMap.basic': '基本设置',
|
||||||
|
'app.settings.menuMap.security': '安全设置',
|
||||||
|
'app.settings.menuMap.binding': '账号绑定',
|
||||||
|
'app.settings.menuMap.notification': '新消息通知',
|
||||||
|
'app.settings.basic.avatar': '头像',
|
||||||
|
'app.settings.basic.change-avatar': '更换头像',
|
||||||
|
'app.settings.basic.email': '邮箱',
|
||||||
|
'app.settings.basic.email-message': '请输入您的邮箱!',
|
||||||
|
'app.settings.basic.nickname': '昵称',
|
||||||
|
'app.settings.basic.nickname-message': '请输入您的昵称!',
|
||||||
|
'app.settings.basic.profile': '个人简介',
|
||||||
|
'app.settings.basic.profile-message': '请输入个人简介!',
|
||||||
|
'app.settings.basic.profile-placeholder': '个人简介',
|
||||||
|
'app.settings.basic.country': '国家/地区',
|
||||||
|
'app.settings.basic.country-message': '请输入您的国家或地区!',
|
||||||
|
'app.settings.basic.geographic': '所在省市',
|
||||||
|
'app.settings.basic.geographic-message': '请输入您的所在省市!',
|
||||||
|
'app.settings.basic.address': '街道地址',
|
||||||
|
'app.settings.basic.address-message': '请输入您的街道地址!',
|
||||||
|
'app.settings.basic.phone': '联系电话',
|
||||||
|
'app.settings.basic.phone-message': '请输入您的联系电话!',
|
||||||
|
'app.settings.basic.update': '更新基本信息',
|
||||||
|
'app.settings.security.strong': '强',
|
||||||
|
'app.settings.security.medium': '中',
|
||||||
|
'app.settings.security.weak': '弱',
|
||||||
|
'app.settings.security.password': '账户密码',
|
||||||
|
'app.settings.security.password-description': '当前密码强度',
|
||||||
|
'app.settings.security.phone': '密保手机',
|
||||||
|
'app.settings.security.phone-description': '已绑定手机',
|
||||||
|
'app.settings.security.question': '密保问题',
|
||||||
|
'app.settings.security.question-description': '未设置密保问题,密保问题可有效保护账户安全',
|
||||||
|
'app.settings.security.email': '备用邮箱',
|
||||||
|
'app.settings.security.email-description': '已绑定邮箱',
|
||||||
|
'app.settings.security.mfa': 'MFA 设备',
|
||||||
|
'app.settings.security.mfa-description': '未绑定 MFA 设备,绑定后,可以进行二次确认',
|
||||||
|
'app.settings.security.modify': '修改',
|
||||||
|
'app.settings.security.set': '设置',
|
||||||
|
'app.settings.security.bind': '绑定',
|
||||||
|
'app.settings.binding.taobao': '绑定淘宝',
|
||||||
|
'app.settings.binding.taobao-description': '当前未绑定淘宝账号',
|
||||||
|
'app.settings.binding.alipay': '绑定支付宝',
|
||||||
|
'app.settings.binding.alipay-description': '当前未绑定支付宝账号',
|
||||||
|
'app.settings.binding.dingding': '绑定钉钉',
|
||||||
|
'app.settings.binding.dingding-description': '当前未绑定钉钉账号',
|
||||||
|
'app.settings.binding.bind': '绑定',
|
||||||
|
'app.settings.notification.password': '账户密码',
|
||||||
|
'app.settings.notification.password-description': '其他用户的消息将以站内信的形式通知',
|
||||||
|
'app.settings.notification.messages': '系统消息',
|
||||||
|
'app.settings.notification.messages-description': '系统消息将以站内信的形式通知',
|
||||||
|
'app.settings.notification.todo': '待办任务',
|
||||||
|
'app.settings.notification.todo-description': '待办任务将以站内信的形式通知',
|
||||||
|
'app.settings.open': '开',
|
||||||
|
'app.settings.close': '关',
|
||||||
|
};
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
{
|
||||||
|
"name": "Ant Design Pro",
|
||||||
|
"short_name": "Ant Design Pro",
|
||||||
|
"display": "standalone",
|
||||||
|
"start_url": "./?utm_source=homescreen",
|
||||||
|
"theme_color": "#002140",
|
||||||
|
"background_color": "#001529",
|
||||||
|
"icons": [
|
||||||
|
{
|
||||||
|
"src": "icons/icon-192x192.png",
|
||||||
|
"sizes": "192x192"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"src": "icons/icon-128x128.png",
|
||||||
|
"sizes": "128x128"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"src": "icons/icon-512x512.png",
|
||||||
|
"sizes": "512x512"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
import { Button, Result } from 'antd';
|
||||||
|
import React from 'react';
|
||||||
|
import { history } from 'umi';
|
||||||
|
|
||||||
|
const NoFoundPage: React.FC = () => (
|
||||||
|
<Result
|
||||||
|
status="404"
|
||||||
|
title="404"
|
||||||
|
subTitle="Sorry, the page you visited does not exist."
|
||||||
|
extra={
|
||||||
|
<Button type="primary" onClick={() => history.push('/')}>
|
||||||
|
Back Home
|
||||||
|
</Button>
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
|
||||||
|
export default NoFoundPage;
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
import { HeartTwoTone, SmileTwoTone } from '@ant-design/icons';
|
||||||
|
import { PageHeaderWrapper } from '@ant-design/pro-components';
|
||||||
|
import { Alert, Card, Typography } from 'antd';
|
||||||
|
import React from 'react';
|
||||||
|
import { useIntl } from 'umi';
|
||||||
|
|
||||||
|
const Admin: React.FC = () => {
|
||||||
|
const intl = useIntl();
|
||||||
|
return (
|
||||||
|
<PageHeaderWrapper
|
||||||
|
content={intl.formatMessage({
|
||||||
|
id: 'pages.admin.subPage.title',
|
||||||
|
defaultMessage: 'This page can only be viewed by admin',
|
||||||
|
})}
|
||||||
|
>
|
||||||
|
<Card>
|
||||||
|
<Alert
|
||||||
|
message={intl.formatMessage({
|
||||||
|
id: 'pages.welcome.alertMessage',
|
||||||
|
defaultMessage: 'Faster and stronger heavy-duty components have been released.',
|
||||||
|
})}
|
||||||
|
type="success"
|
||||||
|
showIcon
|
||||||
|
banner
|
||||||
|
style={{
|
||||||
|
margin: -12,
|
||||||
|
marginBottom: 48,
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<Typography.Title level={2} style={{ textAlign: 'center' }}>
|
||||||
|
<SmileTwoTone /> Ant Design Pro <HeartTwoTone twoToneColor="#eb2f96" /> You
|
||||||
|
</Typography.Title>
|
||||||
|
</Card>
|
||||||
|
<p style={{ textAlign: 'center', marginTop: 24 }}>
|
||||||
|
Want to add more pages? Please refer to{' '}
|
||||||
|
<a href="https://pro.ant.design/docs/block-cn" target="_blank" rel="noopener noreferrer">
|
||||||
|
use block
|
||||||
|
</a>
|
||||||
|
。
|
||||||
|
</p>
|
||||||
|
</PageHeaderWrapper>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default Admin;
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
@import (reference) '~antd/es/style/themes/index';
|
||||||
|
|
||||||
|
.stat {
|
||||||
|
margin-top: @margin-md;
|
||||||
|
padding: @padding-md;
|
||||||
|
background-color: @white;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pie {
|
||||||
|
margin-top: @margin-md;
|
||||||
|
}
|
||||||
@@ -0,0 +1,229 @@
|
|||||||
|
import { PageContainer, StatisticCard } from '@ant-design/pro-components';
|
||||||
|
import { Card, Tag, Space, Tabs, Col, Row } from 'antd';
|
||||||
|
import RcResizeObserver from 'rc-resize-observer';
|
||||||
|
import React, { useState, useEffect } from 'react';
|
||||||
|
import { statistic } from '@/services/welcome/api';
|
||||||
|
import { Area, Pie } from '@ant-design/plots';
|
||||||
|
import styles from './Welcome.less';
|
||||||
|
|
||||||
|
const { Divider } = StatisticCard;
|
||||||
|
|
||||||
|
const Welcome: React.FC = () => {
|
||||||
|
const [responsive, setResponsive] = useState<boolean>(false);
|
||||||
|
const [statistics, setStatistics] = useState<WELCOME.Statistic>({});
|
||||||
|
const [weeks, setWeeks] = useState<WELCOME.AreaData[]>([]);
|
||||||
|
const [days, setDays] = useState<WELCOME.AreaData[]>([]);
|
||||||
|
|
||||||
|
const mapWeek = (result: WELCOME.Statistic) => {
|
||||||
|
const { statWeek_items, statWeek_pv, statWeek_uv } = result;
|
||||||
|
if (statWeek_items && statWeek_pv && statWeek_uv) {
|
||||||
|
const weekData = statWeek_pv
|
||||||
|
.map((pv, index) => {
|
||||||
|
return { type: '访问量(PV)', date: statWeek_items[index], value: pv };
|
||||||
|
})
|
||||||
|
.concat(
|
||||||
|
statWeek_uv.map((uv, index) => {
|
||||||
|
return { type: '独立用户(UV)', date: statWeek_items[index], value: uv };
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
setWeeks(weekData);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const mapDay = (result: WELCOME.Statistic) => {
|
||||||
|
const { statDate_items, statDate_pv, statDate_uv } = result;
|
||||||
|
if (statDate_items && statDate_pv && statDate_uv) {
|
||||||
|
const dayData = statDate_pv
|
||||||
|
.map((pv, index) => {
|
||||||
|
return { type: '访问量(PV)', date: statDate_items[index], value: pv };
|
||||||
|
})
|
||||||
|
.concat(
|
||||||
|
statDate_uv.map((uv, index) => {
|
||||||
|
return { type: '独立用户(UV)', date: statDate_items[index], value: uv };
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
setDays(dayData);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
(async () => {
|
||||||
|
const result = await statistic();
|
||||||
|
if (result) {
|
||||||
|
setStatistics(result);
|
||||||
|
mapWeek(result);
|
||||||
|
mapDay(result);
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<PageContainer
|
||||||
|
subTitle="前后端分离的企业级微服务架构"
|
||||||
|
tags={
|
||||||
|
<>
|
||||||
|
<Tag color="blue">简单</Tag>
|
||||||
|
<Tag color="blue">高效</Tag>
|
||||||
|
</>
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<RcResizeObserver
|
||||||
|
key="resize-observer"
|
||||||
|
onResize={(offset) => {
|
||||||
|
setResponsive(offset.width < 596);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<StatisticCard.Group direction={responsive ? 'column' : 'row'}>
|
||||||
|
<StatisticCard
|
||||||
|
statistic={{
|
||||||
|
title: (
|
||||||
|
<Space size="small">
|
||||||
|
在线人数<Tag color="#434343">时</Tag>
|
||||||
|
</Space>
|
||||||
|
),
|
||||||
|
value: statistics.currHour_uv,
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<Divider type={responsive ? 'horizontal' : 'vertical'} />
|
||||||
|
<StatisticCard
|
||||||
|
statistic={{
|
||||||
|
title: (
|
||||||
|
<Space size="small">
|
||||||
|
PV<Tag color="#52c41a">天</Tag>
|
||||||
|
</Space>
|
||||||
|
),
|
||||||
|
value: statistics.currDate_pv,
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<Divider type={responsive ? 'horizontal' : 'vertical'} />
|
||||||
|
<StatisticCard
|
||||||
|
statistic={{
|
||||||
|
title: (
|
||||||
|
<Space size="small">
|
||||||
|
UV<Tag color="#52c41a">天</Tag>
|
||||||
|
</Space>
|
||||||
|
),
|
||||||
|
value: statistics.currDate_uv,
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<Divider type={responsive ? 'horizontal' : 'vertical'} />
|
||||||
|
<StatisticCard
|
||||||
|
statistic={{
|
||||||
|
title: (
|
||||||
|
<Space size="small">
|
||||||
|
周访问量<Tag color="#1890ff">周</Tag>
|
||||||
|
</Space>
|
||||||
|
),
|
||||||
|
value: statistics.currWeek_pv,
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<Divider type={responsive ? 'horizontal' : 'vertical'} />
|
||||||
|
<StatisticCard
|
||||||
|
statistic={{
|
||||||
|
title: (
|
||||||
|
<Space size="small">
|
||||||
|
月访问量<Tag color="#faad14">月</Tag>
|
||||||
|
</Space>
|
||||||
|
),
|
||||||
|
value: statistics.currMonth_pv,
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</StatisticCard.Group>
|
||||||
|
</RcResizeObserver>
|
||||||
|
<Tabs defaultActiveKey="1" className={styles.stat}>
|
||||||
|
<Tabs.TabPane tab="周流量趋势" key="1">
|
||||||
|
<Area
|
||||||
|
data={weeks}
|
||||||
|
xField="date"
|
||||||
|
yField="value"
|
||||||
|
seriesField="type"
|
||||||
|
smooth
|
||||||
|
height={200}
|
||||||
|
legend={{
|
||||||
|
layout: 'horizontal',
|
||||||
|
position: 'top',
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</Tabs.TabPane>
|
||||||
|
<Tabs.TabPane tab="天流量趋势" key="2">
|
||||||
|
<Area
|
||||||
|
data={days}
|
||||||
|
xField="date"
|
||||||
|
yField="value"
|
||||||
|
seriesField="type"
|
||||||
|
smooth
|
||||||
|
height={200}
|
||||||
|
legend={{
|
||||||
|
layout: 'horizontal',
|
||||||
|
position: 'top',
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</Tabs.TabPane>
|
||||||
|
</Tabs>
|
||||||
|
<Row gutter={16} className={styles.pie}>
|
||||||
|
<Col span={12}>
|
||||||
|
<Card
|
||||||
|
title="浏览器分布"
|
||||||
|
bordered={false}
|
||||||
|
size="small"
|
||||||
|
headStyle={{ textAlign: 'center' }}
|
||||||
|
>
|
||||||
|
<Pie
|
||||||
|
height={240}
|
||||||
|
data={statistics.browser_datas ?? []}
|
||||||
|
angleField="value"
|
||||||
|
colorField="name"
|
||||||
|
appendPadding={10}
|
||||||
|
radius={0.75}
|
||||||
|
label={{
|
||||||
|
type: 'spider',
|
||||||
|
labelHeight: 28,
|
||||||
|
content: '{name}\n{percentage}',
|
||||||
|
}}
|
||||||
|
interactions={[
|
||||||
|
{
|
||||||
|
type: 'element-selected',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'element-active',
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
</Card>
|
||||||
|
</Col>
|
||||||
|
<Col span={12}>
|
||||||
|
<Card
|
||||||
|
title="操作系统分布"
|
||||||
|
bordered={false}
|
||||||
|
size="small"
|
||||||
|
headStyle={{ textAlign: 'center' }}
|
||||||
|
>
|
||||||
|
<Pie
|
||||||
|
height={240}
|
||||||
|
data={statistics.operatingSystem_datas ?? []}
|
||||||
|
angleField="value"
|
||||||
|
colorField="name"
|
||||||
|
appendPadding={10}
|
||||||
|
radius={0.75}
|
||||||
|
label={{
|
||||||
|
type: 'spider',
|
||||||
|
labelHeight: 28,
|
||||||
|
content: '{name}\n{percentage}',
|
||||||
|
}}
|
||||||
|
interactions={[
|
||||||
|
{
|
||||||
|
type: 'element-selected',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'element-active',
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
</Card>
|
||||||
|
</Col>
|
||||||
|
</Row>
|
||||||
|
</PageContainer>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default Welcome;
|
||||||
@@ -0,0 +1,226 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8" />
|
||||||
|
<meta name="theme-color" content="#1890ff" />
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||||
|
<meta name="keywords"
|
||||||
|
content="antd,umi,umijs,ant design,Scaffolding, layout, Ant Design, project, Pro, admin, console, homepage, out-of-the-box, middle and back office, solution, component library" />
|
||||||
|
<meta name="description" content="
|
||||||
|
An out-of-box UI solution for enterprise applications as a React boilerplate." />
|
||||||
|
<meta name="description" content="
|
||||||
|
Out-of-the-box mid-stage front-end/design solution." />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" />
|
||||||
|
<title>Microservices-Platform</title>
|
||||||
|
<link rel="icon" href="<%= context.config.publicPath +'favicon.ico'%>" type="image/x-icon" />
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<noscript>
|
||||||
|
<div class="noscript-container">
|
||||||
|
Hi there! Please
|
||||||
|
<div class="noscript-enableJS">
|
||||||
|
<a href="https://www.enablejavascript.io/en" target="_blank" rel="noopener noreferrer">
|
||||||
|
<b>enable Javascript</b>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
in your browser to use Ant Design, Out-of-the-box mid-stage front/design solution!
|
||||||
|
</div>
|
||||||
|
</noscript>
|
||||||
|
<div id="root">
|
||||||
|
<style>
|
||||||
|
html,
|
||||||
|
body,
|
||||||
|
#root {
|
||||||
|
height: 100%;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#root {
|
||||||
|
background-repeat: no-repeat;
|
||||||
|
background-size: 100% auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.noscript-container {
|
||||||
|
display: flex;
|
||||||
|
align-content: center;
|
||||||
|
justify-content: center;
|
||||||
|
margin-top: 90px;
|
||||||
|
font-size: 20px;
|
||||||
|
font-family: 'Lucida Sans', 'Lucida Sans Regular', 'Lucida Grande', 'Lucida Sans Unicode',
|
||||||
|
Geneva, Verdana, sans-serif;
|
||||||
|
}
|
||||||
|
|
||||||
|
.noscript-enableJS {
|
||||||
|
padding-right: 3px;
|
||||||
|
padding-left: 3px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.page-loading-warp {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
padding: 98px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ant-spin {
|
||||||
|
position: absolute;
|
||||||
|
display: none;
|
||||||
|
-webkit-box-sizing: border-box;
|
||||||
|
box-sizing: border-box;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
color: rgba(0, 0, 0, 0.65);
|
||||||
|
color: #1890ff;
|
||||||
|
font-size: 14px;
|
||||||
|
font-variant: tabular-nums;
|
||||||
|
line-height: 1.5;
|
||||||
|
text-align: center;
|
||||||
|
list-style: none;
|
||||||
|
opacity: 0;
|
||||||
|
-webkit-transition: -webkit-transform 0.3s cubic-bezier(0.78, 0.14, 0.15, 0.86);
|
||||||
|
transition: -webkit-transform 0.3s cubic-bezier(0.78, 0.14, 0.15, 0.86);
|
||||||
|
transition: transform 0.3s cubic-bezier(0.78, 0.14, 0.15, 0.86);
|
||||||
|
transition: transform 0.3s cubic-bezier(0.78, 0.14, 0.15, 0.86),
|
||||||
|
-webkit-transform 0.3s cubic-bezier(0.78, 0.14, 0.15, 0.86);
|
||||||
|
-webkit-font-feature-settings: 'tnum';
|
||||||
|
font-feature-settings: 'tnum';
|
||||||
|
}
|
||||||
|
|
||||||
|
.ant-spin-spinning {
|
||||||
|
position: static;
|
||||||
|
display: inline-block;
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ant-spin-dot {
|
||||||
|
position: relative;
|
||||||
|
display: inline-block;
|
||||||
|
width: 20px;
|
||||||
|
height: 20px;
|
||||||
|
font-size: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ant-spin-dot-item {
|
||||||
|
position: absolute;
|
||||||
|
display: block;
|
||||||
|
width: 9px;
|
||||||
|
height: 9px;
|
||||||
|
background-color: #1890ff;
|
||||||
|
border-radius: 100%;
|
||||||
|
-webkit-transform: scale(0.75);
|
||||||
|
-ms-transform: scale(0.75);
|
||||||
|
transform: scale(0.75);
|
||||||
|
-webkit-transform-origin: 50% 50%;
|
||||||
|
-ms-transform-origin: 50% 50%;
|
||||||
|
transform-origin: 50% 50%;
|
||||||
|
opacity: 0.3;
|
||||||
|
-webkit-animation: antspinmove 1s infinite linear alternate;
|
||||||
|
animation: antSpinMove 1s infinite linear alternate;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ant-spin-dot-item:nth-child(1) {
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ant-spin-dot-item:nth-child(2) {
|
||||||
|
top: 0;
|
||||||
|
right: 0;
|
||||||
|
-webkit-animation-delay: 0.4s;
|
||||||
|
animation-delay: 0.4s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ant-spin-dot-item:nth-child(3) {
|
||||||
|
right: 0;
|
||||||
|
bottom: 0;
|
||||||
|
-webkit-animation-delay: 0.8s;
|
||||||
|
animation-delay: 0.8s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ant-spin-dot-item:nth-child(4) {
|
||||||
|
bottom: 0;
|
||||||
|
left: 0;
|
||||||
|
-webkit-animation-delay: 1.2s;
|
||||||
|
animation-delay: 1.2s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ant-spin-dot-spin {
|
||||||
|
-webkit-transform: rotate(45deg);
|
||||||
|
-ms-transform: rotate(45deg);
|
||||||
|
transform: rotate(45deg);
|
||||||
|
-webkit-animation: antrotate 1.2s infinite linear;
|
||||||
|
animation: antRotate 1.2s infinite linear;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ant-spin-lg .ant-spin-dot {
|
||||||
|
width: 32px;
|
||||||
|
height: 32px;
|
||||||
|
font-size: 32px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ant-spin-lg .ant-spin-dot i {
|
||||||
|
width: 14px;
|
||||||
|
height: 14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media all and (-ms-high-contrast: none),
|
||||||
|
(-ms-high-contrast: active) {
|
||||||
|
.ant-spin-blur {
|
||||||
|
background: #fff;
|
||||||
|
opacity: 0.5;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@-webkit-keyframes antSpinMove {
|
||||||
|
to {
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes antSpinMove {
|
||||||
|
to {
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@-webkit-keyframes antRotate {
|
||||||
|
to {
|
||||||
|
-webkit-transform: rotate(405deg);
|
||||||
|
transform: rotate(405deg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes antRotate {
|
||||||
|
to {
|
||||||
|
-webkit-transform: rotate(405deg);
|
||||||
|
transform: rotate(405deg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<div style="
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
height: 100%;
|
||||||
|
min-height: 420px;
|
||||||
|
">
|
||||||
|
<img src="<%= context.config.publicPath +'campaign.svg'%>" alt="logo" width="256" />
|
||||||
|
<div class="page-loading-warp">
|
||||||
|
<div class="ant-spin ant-spin-lg ant-spin-spinning">
|
||||||
|
<span class="ant-spin-dot ant-spin-dot-spin"><i class="ant-spin-dot-item"></i><i
|
||||||
|
class="ant-spin-dot-item"></i><i class="ant-spin-dot-item"></i><i class="ant-spin-dot-item"></i></span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div style="display: flex; align-items: center; justify-content: center">
|
||||||
|
<img src="/logo.png" width="32" style="margin-right: 8px" />
|
||||||
|
microservices-platform
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
@import (reference) '~antd/es/style/themes/index';
|
||||||
@@ -0,0 +1,122 @@
|
|||||||
|
import { auditlog } from '@/services/search/api';
|
||||||
|
import type { ProColumns } from '@ant-design/pro-components';
|
||||||
|
import {
|
||||||
|
PageContainer,
|
||||||
|
ProFormText,
|
||||||
|
ProTable,
|
||||||
|
QueryFilter,
|
||||||
|
ProFormSelect,
|
||||||
|
} from '@ant-design/pro-components';
|
||||||
|
import React, { useState } from 'react';
|
||||||
|
import moment from 'moment';
|
||||||
|
|
||||||
|
const AuditLog: React.FC = () => {
|
||||||
|
const [params, setParams] = useState<Record<string, string | number>>();
|
||||||
|
|
||||||
|
const columns: ProColumns<SEARCH.AuditLog>[] = [
|
||||||
|
{
|
||||||
|
dataIndex: 'index',
|
||||||
|
valueType: 'indexBorder',
|
||||||
|
width: 20,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '日志时间',
|
||||||
|
key: 'timestamp',
|
||||||
|
width: 75,
|
||||||
|
render(_, entity) {
|
||||||
|
return moment(entity.timestamp).format('YYYY-MM-DD HH:mm:SS');
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '用户id',
|
||||||
|
dataIndex: 'userId',
|
||||||
|
width: 30,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '用户名',
|
||||||
|
dataIndex: 'userName',
|
||||||
|
width: 40,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '租户id',
|
||||||
|
dataIndex: 'clientId',
|
||||||
|
width: 50,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '操作信息',
|
||||||
|
dataIndex: 'operation',
|
||||||
|
width: 150,
|
||||||
|
ellipsis: true,
|
||||||
|
render: (_, entity) =>
|
||||||
|
entity.operation && <span dangerouslySetInnerHTML={{ __html: entity.operation }} />,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '应用名',
|
||||||
|
dataIndex: 'appName',
|
||||||
|
width: 50,
|
||||||
|
ellipsis: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '类名',
|
||||||
|
dataIndex: 'className',
|
||||||
|
width: 150,
|
||||||
|
ellipsis: true,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
return (
|
||||||
|
<PageContainer header={{ subTitle: '查看系统日志' }}>
|
||||||
|
<QueryFilter
|
||||||
|
defaultCollapsed
|
||||||
|
split
|
||||||
|
span={8}
|
||||||
|
className="query-filter"
|
||||||
|
onFinish={async (values) => {
|
||||||
|
let queryStr = '';
|
||||||
|
const { searchKey, searchValue } = values;
|
||||||
|
if (searchKey && searchValue) {
|
||||||
|
if (searchKey === 'none') {
|
||||||
|
queryStr = searchValue;
|
||||||
|
} else {
|
||||||
|
queryStr = `${searchKey}:${searchValue}`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
setParams({ ...params, queryStr });
|
||||||
|
}}
|
||||||
|
// onReset={() => setParams({})}
|
||||||
|
>
|
||||||
|
<ProFormSelect
|
||||||
|
name="searchKey"
|
||||||
|
label="搜索"
|
||||||
|
valueEnum={{
|
||||||
|
none: '全文搜索',
|
||||||
|
appName: '应用名',
|
||||||
|
classname: '类别',
|
||||||
|
methodName: '方法名',
|
||||||
|
userId: '用户ID',
|
||||||
|
userName: '用户名',
|
||||||
|
clientId: '租户ID',
|
||||||
|
operation: '操作信息',
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<ProFormText name="searchValue" />
|
||||||
|
</QueryFilter>
|
||||||
|
<ProTable<SEARCH.AuditLog>
|
||||||
|
className="audit-log"
|
||||||
|
rowKey="id"
|
||||||
|
headerTitle="系统日志"
|
||||||
|
request={auditlog}
|
||||||
|
columns={columns}
|
||||||
|
search={false}
|
||||||
|
params={params}
|
||||||
|
size="small"
|
||||||
|
pagination={{
|
||||||
|
showSizeChanger: true,
|
||||||
|
showQuickJumper: true,
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</PageContainer>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default AuditLog;
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
@import (reference) '~antd/es/style/themes/index';
|
||||||
@@ -0,0 +1,109 @@
|
|||||||
|
import { slowQueryLog } from '@/services/search/api';
|
||||||
|
import type { ProColumns } from '@ant-design/pro-components';
|
||||||
|
import {
|
||||||
|
PageContainer,
|
||||||
|
ProFormText,
|
||||||
|
ProTable,
|
||||||
|
QueryFilter,
|
||||||
|
ProFormSelect,
|
||||||
|
} from '@ant-design/pro-components';
|
||||||
|
import React, { useState } from 'react';
|
||||||
|
|
||||||
|
const SlowSqlLog: React.FC = () => {
|
||||||
|
const [params, setParams] = useState<Record<string, string | number>>();
|
||||||
|
|
||||||
|
const columns: ProColumns<SEARCH.AuditLog>[] = [
|
||||||
|
{
|
||||||
|
dataIndex: 'index',
|
||||||
|
valueType: 'indexBorder',
|
||||||
|
width: 20,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '日志时间',
|
||||||
|
key: 'timestamp',
|
||||||
|
width: 75,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '查询语句',
|
||||||
|
dataIndex: 'userId',
|
||||||
|
width: 30,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '查询时间(ms)',
|
||||||
|
dataIndex: 'userName',
|
||||||
|
width: 40,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '锁等待时间(ms)',
|
||||||
|
dataIndex: 'clientId',
|
||||||
|
width: 50,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '返回行数',
|
||||||
|
dataIndex: 'operation',
|
||||||
|
width: 150,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '优化器扫描行数',
|
||||||
|
dataIndex: 'appName',
|
||||||
|
width: 50,
|
||||||
|
ellipsis: true,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
return (
|
||||||
|
<PageContainer header={{ subTitle: '查看慢查询日志' }}>
|
||||||
|
<QueryFilter
|
||||||
|
defaultCollapsed
|
||||||
|
split
|
||||||
|
span={8}
|
||||||
|
className="query-filter"
|
||||||
|
onFinish={async (values) => {
|
||||||
|
let queryStr = '';
|
||||||
|
const { searchKey, searchValue } = values;
|
||||||
|
if (searchKey && searchValue) {
|
||||||
|
if (searchKey === 'none') {
|
||||||
|
queryStr = searchValue;
|
||||||
|
} else {
|
||||||
|
queryStr = `${searchKey}:${searchValue}`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
setParams({ ...params, queryStr });
|
||||||
|
}}
|
||||||
|
// onReset={() => setParams({})}
|
||||||
|
>
|
||||||
|
<ProFormSelect
|
||||||
|
name="searchKey"
|
||||||
|
label="搜索"
|
||||||
|
valueEnum={{
|
||||||
|
none: '全文搜索',
|
||||||
|
appName: '应用名',
|
||||||
|
classname: '类别',
|
||||||
|
methodName: '方法名',
|
||||||
|
userId: '用户ID',
|
||||||
|
userName: '用户名',
|
||||||
|
clientId: '租户ID',
|
||||||
|
operation: '操作信息',
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<ProFormText name="searchValue" />
|
||||||
|
</QueryFilter>
|
||||||
|
<ProTable<SEARCH.AuditLog>
|
||||||
|
className="audit-log"
|
||||||
|
rowKey="id"
|
||||||
|
headerTitle="慢查询日志"
|
||||||
|
request={slowQueryLog}
|
||||||
|
columns={columns}
|
||||||
|
search={false}
|
||||||
|
params={params}
|
||||||
|
size="small"
|
||||||
|
pagination={{
|
||||||
|
showSizeChanger: true,
|
||||||
|
showQuickJumper: true,
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</PageContainer>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default SlowSqlLog;
|
||||||
@@ -0,0 +1,76 @@
|
|||||||
|
import { Button, Modal, Table } from 'antd';
|
||||||
|
import React, { useEffect, useState } from 'react';
|
||||||
|
import { tracelog } from '@/services/search/api';
|
||||||
|
import styles from '../index.less';
|
||||||
|
import type { TableColumnType } from 'antd';
|
||||||
|
import { treeify } from 'treeify-js';
|
||||||
|
import { NodeIndexOutlined } from '@ant-design/icons';
|
||||||
|
|
||||||
|
type IndexViewProps = {
|
||||||
|
traceId?: string;
|
||||||
|
onCancel: () => void;
|
||||||
|
open: boolean;
|
||||||
|
};
|
||||||
|
|
||||||
|
const TraceView: React.FC<IndexViewProps> = (props) => {
|
||||||
|
const [traces, setTraces] = useState<SEARCH.TraceLog[]>();
|
||||||
|
const { traceId } = props;
|
||||||
|
|
||||||
|
const columns: TableColumnType<SEARCH.TraceLog>[] = [
|
||||||
|
{
|
||||||
|
title: '应用名',
|
||||||
|
dataIndex: 'appName',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'spanId',
|
||||||
|
dataIndex: 'spanId',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '服务ip',
|
||||||
|
dataIndex: 'serverIp',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '服务端口',
|
||||||
|
dataIndex: 'serverPort',
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
(async () => {
|
||||||
|
if (traceId) {
|
||||||
|
const data = (await tracelog(traceId)) ?? [];
|
||||||
|
const treeData = treeify(data, { id: 'spanId', root: '-1', multi: true });
|
||||||
|
setTraces(treeData);
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
}, [traceId]);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Modal
|
||||||
|
title={
|
||||||
|
<>
|
||||||
|
<NodeIndexOutlined />
|
||||||
|
日志链路
|
||||||
|
</>
|
||||||
|
}
|
||||||
|
className={styles.viewModal}
|
||||||
|
width={800}
|
||||||
|
open={props.open}
|
||||||
|
onCancel={props.onCancel}
|
||||||
|
footer={
|
||||||
|
<Button type="primary" onClick={props.onCancel}>
|
||||||
|
关闭
|
||||||
|
</Button>
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<Table<SEARCH.TraceLog>
|
||||||
|
columns={columns}
|
||||||
|
dataSource={traces}
|
||||||
|
pagination={false}
|
||||||
|
size="small"
|
||||||
|
/>
|
||||||
|
</Modal>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default TraceView;
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
@import (reference) '~antd/es/style/themes/index';
|
||||||
|
|
||||||
|
.view {
|
||||||
|
height: 400px;
|
||||||
|
overflow-y: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.viewModal {
|
||||||
|
.ant-modal-body {
|
||||||
|
padding: @padding-md;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,158 @@
|
|||||||
|
import { syslog } from '@/services/search/api';
|
||||||
|
import type { ProColumns } from '@ant-design/pro-components';
|
||||||
|
import {
|
||||||
|
PageContainer,
|
||||||
|
ProFormText,
|
||||||
|
ProTable,
|
||||||
|
QueryFilter,
|
||||||
|
ProFormSelect,
|
||||||
|
} from '@ant-design/pro-components';
|
||||||
|
import React, { useState } from 'react';
|
||||||
|
import moment from 'moment';
|
||||||
|
import TraceView from './components/TraceView';
|
||||||
|
import { Typography } from 'antd';
|
||||||
|
|
||||||
|
type TraceViewProps = {
|
||||||
|
traceId?: string;
|
||||||
|
open: boolean;
|
||||||
|
};
|
||||||
|
|
||||||
|
const { Link } = Typography;
|
||||||
|
|
||||||
|
const TableList: React.FC = () => {
|
||||||
|
const [params, setParams] = useState<Record<string, string | number>>({
|
||||||
|
sortCol: 'timestamp',
|
||||||
|
isHighlighter: 'true',
|
||||||
|
});
|
||||||
|
const [traceView, setTraceView] = useState<TraceViewProps>({ open: false });
|
||||||
|
|
||||||
|
const columns: ProColumns<SEARCH.SysLog>[] = [
|
||||||
|
{
|
||||||
|
dataIndex: 'index',
|
||||||
|
valueType: 'indexBorder',
|
||||||
|
width: 20,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '时间',
|
||||||
|
key: 'timestamp',
|
||||||
|
width: 75,
|
||||||
|
render(_, entity) {
|
||||||
|
return moment(entity.timestamp).format('YYYY-MM-DD HH:mm:SS');
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '日志信息',
|
||||||
|
dataIndex: 'message',
|
||||||
|
ellipsis: true,
|
||||||
|
width: 200,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '日志级别',
|
||||||
|
dataIndex: 'logLevel',
|
||||||
|
width: 40,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '应用名',
|
||||||
|
dataIndex: 'appName',
|
||||||
|
width: 50,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '追踪id',
|
||||||
|
key: 'traceId',
|
||||||
|
width: 80,
|
||||||
|
render(_, entity) {
|
||||||
|
return (
|
||||||
|
<Link
|
||||||
|
onClick={() => {
|
||||||
|
setTraceView({ traceId: entity.traceId, open: true });
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{entity.traceId}
|
||||||
|
</Link>
|
||||||
|
);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'spanId',
|
||||||
|
dataIndex: 'spanId',
|
||||||
|
width: 40,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '类名',
|
||||||
|
dataIndex: 'classname',
|
||||||
|
width: 110,
|
||||||
|
ellipsis: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '线程名',
|
||||||
|
dataIndex: 'threadName',
|
||||||
|
width: 50,
|
||||||
|
ellipsis: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '服务ip',
|
||||||
|
dataIndex: 'serverIp',
|
||||||
|
width: 50,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '服务端口',
|
||||||
|
dataIndex: 'serverPort',
|
||||||
|
width: 35,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
return (
|
||||||
|
<PageContainer header={{ subTitle: '查看系统日志' }}>
|
||||||
|
<QueryFilter
|
||||||
|
defaultCollapsed
|
||||||
|
split
|
||||||
|
span={8}
|
||||||
|
className="query-filter"
|
||||||
|
onFinish={async (values) => {
|
||||||
|
let queryStr = '';
|
||||||
|
const { searchKey, searchValue } = values;
|
||||||
|
if (searchKey && searchValue) {
|
||||||
|
if (searchKey === 'none') {
|
||||||
|
queryStr = searchValue;
|
||||||
|
} else {
|
||||||
|
queryStr = `${searchKey}:${searchValue}`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
setParams({ ...params, queryStr });
|
||||||
|
}}
|
||||||
|
// onReset={() => setParams({})}
|
||||||
|
>
|
||||||
|
<ProFormSelect
|
||||||
|
name="searchKey"
|
||||||
|
label="搜索"
|
||||||
|
valueEnum={{
|
||||||
|
none: '全文搜索',
|
||||||
|
message: '日志信息',
|
||||||
|
logLevel: '日志级别',
|
||||||
|
appName: '应用名',
|
||||||
|
classname: '类别',
|
||||||
|
traceId: '链路追踪ID',
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<ProFormText name="searchValue" />
|
||||||
|
</QueryFilter>
|
||||||
|
<ProTable<SEARCH.SysLog>
|
||||||
|
rowKey="id"
|
||||||
|
headerTitle="系统日志"
|
||||||
|
request={syslog}
|
||||||
|
columns={columns}
|
||||||
|
search={false}
|
||||||
|
params={params}
|
||||||
|
size="small"
|
||||||
|
pagination={{
|
||||||
|
showSizeChanger: true,
|
||||||
|
showQuickJumper: true,
|
||||||
|
}}
|
||||||
|
scroll={{ x: 1600 }}
|
||||||
|
/>
|
||||||
|
<TraceView {...traceView} onCancel={() => setTraceView({ open: false })} />
|
||||||
|
</PageContainer>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default TableList;
|
||||||
@@ -0,0 +1,57 @@
|
|||||||
|
import { Button, Modal } from 'antd';
|
||||||
|
import React, { useEffect, useState } from 'react';
|
||||||
|
import { JSONTree } from 'react-json-tree';
|
||||||
|
import { index } from '@/services/search/api';
|
||||||
|
import styles from '../index.less';
|
||||||
|
import { NodeIndexOutlined } from '@ant-design/icons';
|
||||||
|
|
||||||
|
type IndexViewProps = {
|
||||||
|
indexName?: string;
|
||||||
|
onCancel: () => void;
|
||||||
|
open: boolean;
|
||||||
|
};
|
||||||
|
|
||||||
|
const IndexView: React.FC<IndexViewProps> = (props) => {
|
||||||
|
const [json, setJson] = useState<any>({});
|
||||||
|
const { indexName } = props;
|
||||||
|
useEffect(() => {
|
||||||
|
(async () => {
|
||||||
|
if (indexName) {
|
||||||
|
const data = await index(indexName);
|
||||||
|
console.log(data);
|
||||||
|
setJson(data);
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
}, [indexName]);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Modal
|
||||||
|
title={
|
||||||
|
<>
|
||||||
|
<NodeIndexOutlined />
|
||||||
|
查看索引
|
||||||
|
</>
|
||||||
|
}
|
||||||
|
className={styles.viewModal}
|
||||||
|
width={800}
|
||||||
|
open={props.open}
|
||||||
|
onCancel={props.onCancel}
|
||||||
|
footer={
|
||||||
|
<Button type="primary" onClick={props.onCancel}>
|
||||||
|
关闭
|
||||||
|
</Button>
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<div className={styles.view}>
|
||||||
|
<JSONTree
|
||||||
|
data={json}
|
||||||
|
hideRoot
|
||||||
|
shouldExpandNode={(a, b, level) => level < 3}
|
||||||
|
invertTheme={false}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</Modal>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default IndexView;
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
@import (reference) '~antd/es/style/themes/index';
|
||||||
|
|
||||||
|
.view {
|
||||||
|
height: 400px;
|
||||||
|
overflow-y: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.viewModal {
|
||||||
|
.ant-modal-body {
|
||||||
|
padding: @padding-md;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,191 @@
|
|||||||
|
import { indice } from '@/services/search/api';
|
||||||
|
import { PlusOutlined } from '@ant-design/icons';
|
||||||
|
import type { ProColumns } from '@ant-design/pro-components';
|
||||||
|
import {
|
||||||
|
ModalForm,
|
||||||
|
ProForm,
|
||||||
|
ProFormTextArea,
|
||||||
|
PageContainer,
|
||||||
|
ProFormText,
|
||||||
|
ProTable,
|
||||||
|
QueryFilter,
|
||||||
|
} from '@ant-design/pro-components';
|
||||||
|
import { Typography, message, Space, Button } from 'antd';
|
||||||
|
import React, { useState } from 'react';
|
||||||
|
import IndexView from './components/IndexView';
|
||||||
|
|
||||||
|
const { Link } = Typography;
|
||||||
|
|
||||||
|
type IndexViewProps = {
|
||||||
|
indexName?: string;
|
||||||
|
open: boolean;
|
||||||
|
};
|
||||||
|
|
||||||
|
const TableList: React.FC = () => {
|
||||||
|
const [params, setParams] = useState<Record<string, string | number>>();
|
||||||
|
const [createModalVisible, handleModalVisible] = useState<boolean>(false);
|
||||||
|
const [indexView, setIndexView] = useState<IndexViewProps>({ open: false });
|
||||||
|
|
||||||
|
const columns: ProColumns<SEARCH.Indice>[] = [
|
||||||
|
{
|
||||||
|
dataIndex: 'index',
|
||||||
|
valueType: 'indexBorder',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '索引健康',
|
||||||
|
dataIndex: 'health',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '索引状态',
|
||||||
|
dataIndex: 'status',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '索引名',
|
||||||
|
dataIndex: 'index',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '文档数',
|
||||||
|
dataIndex: 'docsCount',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '文档删除数',
|
||||||
|
dataIndex: 'docsDeleted',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '索引大小',
|
||||||
|
dataIndex: 'storeSize',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '操作',
|
||||||
|
key: 'action',
|
||||||
|
render: (_, record) => (
|
||||||
|
<Space>
|
||||||
|
<Link
|
||||||
|
onClick={() => {
|
||||||
|
setIndexView({ indexName: record.index, open: true });
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
查看
|
||||||
|
</Link>
|
||||||
|
<Link onClick={() => message.info('演示环境不支持该功能')}>删除</Link>
|
||||||
|
</Space>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
return (
|
||||||
|
<PageContainer header={{ subTitle: '索引管理' }}>
|
||||||
|
<QueryFilter
|
||||||
|
defaultCollapsed
|
||||||
|
split
|
||||||
|
span={12}
|
||||||
|
className="query-filter"
|
||||||
|
onFinish={async (values) => setParams(values)}
|
||||||
|
// onReset={() => setParams({})}
|
||||||
|
>
|
||||||
|
<ProFormText
|
||||||
|
name="queryStr"
|
||||||
|
label="索引名"
|
||||||
|
placeholder="输入关键字,模糊搜索需要加通配符*"
|
||||||
|
/>
|
||||||
|
</QueryFilter>
|
||||||
|
<ProTable<SEARCH.Indice>
|
||||||
|
rowKey="index"
|
||||||
|
headerTitle="索引管理"
|
||||||
|
request={indice}
|
||||||
|
columns={columns}
|
||||||
|
search={false}
|
||||||
|
params={params}
|
||||||
|
pagination={false}
|
||||||
|
toolBarRender={() => [
|
||||||
|
<>
|
||||||
|
<Button
|
||||||
|
type="primary"
|
||||||
|
onClick={() => {
|
||||||
|
handleModalVisible(true);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<PlusOutlined /> 添加
|
||||||
|
</Button>
|
||||||
|
</>,
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
<ModalForm
|
||||||
|
title="新增索引"
|
||||||
|
// layout="horizontal"
|
||||||
|
width={800}
|
||||||
|
visible={createModalVisible}
|
||||||
|
onVisibleChange={handleModalVisible}
|
||||||
|
onFinish={async () => {
|
||||||
|
message.info('演示环境不支持该功能');
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<ProForm.Group>
|
||||||
|
<ProFormText
|
||||||
|
rules={[
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '索引名不为空',
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
width="md"
|
||||||
|
name="index"
|
||||||
|
label="索引名"
|
||||||
|
placeholder="输入索引名"
|
||||||
|
/>
|
||||||
|
<ProFormText
|
||||||
|
rules={[
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '分片数不为空',
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
width="md"
|
||||||
|
name="numberOfShards"
|
||||||
|
label="分片数"
|
||||||
|
placeholder="输入分片数"
|
||||||
|
/>
|
||||||
|
<ProFormText
|
||||||
|
rules={[
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '副本数不为空',
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
width="md"
|
||||||
|
name="numberOfReplicas"
|
||||||
|
label="副本数"
|
||||||
|
placeholder="输入副本数"
|
||||||
|
/>
|
||||||
|
<ProFormText
|
||||||
|
rules={[
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '类型不为空',
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
width="md"
|
||||||
|
name="type"
|
||||||
|
label="类型"
|
||||||
|
placeholder="输入类型"
|
||||||
|
/>
|
||||||
|
<ProFormTextArea
|
||||||
|
rules={[
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: 'mappings不为空',
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
width="xl"
|
||||||
|
name="mappingsSource"
|
||||||
|
label="mappings"
|
||||||
|
placeholder="输入mappings的JSON内容"
|
||||||
|
/>
|
||||||
|
</ProForm.Group>
|
||||||
|
</ModalForm>
|
||||||
|
<IndexView {...indexView} onCancel={() => setIndexView({ open: false })} />
|
||||||
|
</PageContainer>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default TableList;
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
@import (reference) '~antd/es/style/themes/index';
|
||||||
@@ -0,0 +1,88 @@
|
|||||||
|
import { user } from '@/services/system/api';
|
||||||
|
import type { ProColumns } from '@ant-design/pro-components';
|
||||||
|
import {
|
||||||
|
ProFormSelect,
|
||||||
|
PageContainer,
|
||||||
|
ProFormText,
|
||||||
|
ProTable,
|
||||||
|
QueryFilter,
|
||||||
|
} from '@ant-design/pro-components';
|
||||||
|
import React, { useState } from 'react';
|
||||||
|
|
||||||
|
const TableList: React.FC = () => {
|
||||||
|
const [params, setParams] = useState<Record<string, string | number>>({});
|
||||||
|
|
||||||
|
const columns: ProColumns<SYSTEM.User>[] = [
|
||||||
|
{
|
||||||
|
dataIndex: 'index',
|
||||||
|
valueType: 'indexBorder',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '用户编号',
|
||||||
|
dataIndex: 'id',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '账号',
|
||||||
|
dataIndex: 'username',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '用户名',
|
||||||
|
dataIndex: 'nickname',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '手机号',
|
||||||
|
dataIndex: 'mobile',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '性别',
|
||||||
|
dataIndex: 'sex',
|
||||||
|
render: (value) => (value === 0 ? '男' : '女'),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '类别',
|
||||||
|
dataIndex: 'type',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '创建时间',
|
||||||
|
dataIndex: 'createTime',
|
||||||
|
valueType: 'dateTime',
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
return (
|
||||||
|
<PageContainer header={{ subTitle: '查询系统中的用户账号' }}>
|
||||||
|
<QueryFilter
|
||||||
|
defaultCollapsed
|
||||||
|
split
|
||||||
|
className="query-filter"
|
||||||
|
onFinish={async (values) => setParams(values)}
|
||||||
|
>
|
||||||
|
<ProFormSelect
|
||||||
|
name="searchKey"
|
||||||
|
label="搜索"
|
||||||
|
valueEnum={{
|
||||||
|
user_id: 'ID',
|
||||||
|
username: '账号',
|
||||||
|
nick_name: '用户名',
|
||||||
|
mobile: '手机号',
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<ProFormText name="searchValue" />
|
||||||
|
</QueryFilter>
|
||||||
|
<ProTable<SYSTEM.User>
|
||||||
|
rowKey="id"
|
||||||
|
headerTitle="用户管理"
|
||||||
|
request={user}
|
||||||
|
columns={columns}
|
||||||
|
search={false}
|
||||||
|
params={params}
|
||||||
|
pagination={{
|
||||||
|
showSizeChanger: true,
|
||||||
|
showQuickJumper: true,
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</PageContainer>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default TableList;
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
@import (reference) '~antd/es/style/themes/index';
|
||||||
@@ -0,0 +1,108 @@
|
|||||||
|
import { app } from '@/services/system/api';
|
||||||
|
import type { ProColumns } from '@ant-design/pro-components';
|
||||||
|
import { PageContainer, ProFormText, ProTable, QueryFilter } from '@ant-design/pro-components';
|
||||||
|
import { Typography, message } from 'antd';
|
||||||
|
import React, { useState } from 'react';
|
||||||
|
|
||||||
|
const { Link } = Typography;
|
||||||
|
|
||||||
|
const TableList: React.FC = () => {
|
||||||
|
const [params, setParams] = useState<Record<string, string | number>>();
|
||||||
|
|
||||||
|
const columns: ProColumns<SYSTEM.App>[] = [
|
||||||
|
{
|
||||||
|
dataIndex: 'index',
|
||||||
|
valueType: 'indexBorder',
|
||||||
|
width: 20,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '应用标识',
|
||||||
|
dataIndex: 'clientId',
|
||||||
|
width: 50,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '应用名称',
|
||||||
|
dataIndex: 'clientName',
|
||||||
|
width: 50,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '回调地址',
|
||||||
|
dataIndex: 'webServerRedirectUri',
|
||||||
|
width: 120,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'oauth授权方式',
|
||||||
|
dataIndex: 'authorizedGrantTypes',
|
||||||
|
ellipsis: true,
|
||||||
|
width: 50,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '自动审批',
|
||||||
|
key: 'autoapprove',
|
||||||
|
width: 40,
|
||||||
|
align: 'center',
|
||||||
|
render: (_, record) => (record.autoapprove === 'true' ? '是' : '否'),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '令牌时效',
|
||||||
|
dataIndex: 'accessTokenValiditySeconds',
|
||||||
|
valueType: 'second',
|
||||||
|
width: 40,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '刷新时效',
|
||||||
|
dataIndex: 'refreshTokenValiditySeconds',
|
||||||
|
valueType: 'second',
|
||||||
|
width: 40,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '支持ID令牌',
|
||||||
|
key: 'supportIdToken',
|
||||||
|
width: 40,
|
||||||
|
align: 'center',
|
||||||
|
render: (_, record) => (record.supportIdToken ? '是' : '否'),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'ID时效',
|
||||||
|
dataIndex: 'idTokenValiditySeconds',
|
||||||
|
valueType: 'second',
|
||||||
|
width: 40,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '操作',
|
||||||
|
key: 'action',
|
||||||
|
fixed: 'right',
|
||||||
|
width: 40,
|
||||||
|
render: () => <Link onClick={() => message.info('演示环境不支持该功能')}>删除</Link>,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
return (
|
||||||
|
<PageContainer header={{ subTitle: '管理App' }}>
|
||||||
|
<QueryFilter
|
||||||
|
defaultCollapsed
|
||||||
|
split
|
||||||
|
span={6}
|
||||||
|
className="query-filter"
|
||||||
|
onFinish={async (values) => setParams(values)}
|
||||||
|
// onReset={() => setParams({})}
|
||||||
|
>
|
||||||
|
<ProFormText name="searchKey" label="搜索" />
|
||||||
|
</QueryFilter>
|
||||||
|
<ProTable<SYSTEM.App>
|
||||||
|
rowKey="id"
|
||||||
|
headerTitle="Token管理"
|
||||||
|
request={app}
|
||||||
|
columns={columns}
|
||||||
|
search={false}
|
||||||
|
params={params}
|
||||||
|
scroll={{ x: 1300 }}
|
||||||
|
pagination={{
|
||||||
|
showSizeChanger: true,
|
||||||
|
showQuickJumper: true,
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</PageContainer>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default TableList;
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
@import (reference) '~antd/es/style/themes/index';
|
||||||
@@ -0,0 +1,77 @@
|
|||||||
|
import { exportGenerator, generator } from '@/services/system/api';
|
||||||
|
import type { ProColumns } from '@ant-design/pro-components';
|
||||||
|
import { PageContainer, ProFormText, ProTable, QueryFilter } from '@ant-design/pro-components';
|
||||||
|
import { Typography } from 'antd';
|
||||||
|
import React, { useState } from 'react';
|
||||||
|
|
||||||
|
const { Link } = Typography;
|
||||||
|
|
||||||
|
const Generator: React.FC = () => {
|
||||||
|
const [params, setParams] = useState<Record<string, string | number>>();
|
||||||
|
|
||||||
|
const columns: ProColumns<SYSTEM.Generator>[] = [
|
||||||
|
{
|
||||||
|
dataIndex: 'index',
|
||||||
|
valueType: 'indexBorder',
|
||||||
|
width: 20,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '数据库引擎',
|
||||||
|
dataIndex: 'engine',
|
||||||
|
width: 50,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '表名',
|
||||||
|
dataIndex: 'tableName',
|
||||||
|
width: 50,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '创建时间',
|
||||||
|
dataIndex: 'createTime',
|
||||||
|
valueType: 'dateTime',
|
||||||
|
width: 100,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '操作',
|
||||||
|
key: 'action',
|
||||||
|
fixed: 'right',
|
||||||
|
width: 40,
|
||||||
|
render: (_, entity) => (
|
||||||
|
<Link
|
||||||
|
onClick={() => {
|
||||||
|
if (entity.tableName) exportGenerator(entity.tableName);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
生成
|
||||||
|
</Link>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
];
|
||||||
|
return (
|
||||||
|
<PageContainer header={{ subTitle: '生成代码' }}>
|
||||||
|
<QueryFilter
|
||||||
|
defaultCollapsed
|
||||||
|
split
|
||||||
|
span={6}
|
||||||
|
className="query-filter"
|
||||||
|
onFinish={async (values) => setParams(values)}
|
||||||
|
// onReset={() => setParams({})}
|
||||||
|
>
|
||||||
|
<ProFormText name="tableName" label="搜索" placeholder="输入表名" />
|
||||||
|
</QueryFilter>
|
||||||
|
<ProTable<SYSTEM.Generator>
|
||||||
|
headerTitle="代码生成器"
|
||||||
|
request={generator}
|
||||||
|
columns={columns}
|
||||||
|
search={false}
|
||||||
|
params={params}
|
||||||
|
pagination={{
|
||||||
|
showSizeChanger: true,
|
||||||
|
showQuickJumper: true,
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</PageContainer>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default Generator;
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
@import (reference) '~antd/es/style/themes/index';
|
||||||
@@ -0,0 +1,144 @@
|
|||||||
|
import { menu } from '@/services/system/api';
|
||||||
|
import { treeify } from '@/util/treeify';
|
||||||
|
import { FolderOpenOutlined, MenuOutlined, ProfileOutlined } from '@ant-design/icons';
|
||||||
|
import type { ProColumns } from '@ant-design/pro-components';
|
||||||
|
import { ProFormSelect } from '@ant-design/pro-components';
|
||||||
|
import { PageContainer, ProFormText, ProTable, QueryFilter } from '@ant-design/pro-components';
|
||||||
|
import { Space, Tag, Typography } from 'antd';
|
||||||
|
import React, { useEffect, useState } from 'react';
|
||||||
|
|
||||||
|
const { Link } = Typography;
|
||||||
|
|
||||||
|
const Generator: React.FC = () => {
|
||||||
|
const [data, setData] = useState<SYSTEM.Menu[]>();
|
||||||
|
|
||||||
|
const query = async (params: Record<string, string | number>) => {
|
||||||
|
const menus = (await menu(params)) ?? [];
|
||||||
|
const treeData = treeify(menus, {});
|
||||||
|
menus.forEach((node) => {
|
||||||
|
if (node.children && node.children.length === 0) delete node.children;
|
||||||
|
});
|
||||||
|
// debugger;
|
||||||
|
setData(treeData);
|
||||||
|
};
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
query({ tenantId: 'webApp' });
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const columns: ProColumns<SYSTEM.Menu>[] = [
|
||||||
|
{
|
||||||
|
title: '菜单名称',
|
||||||
|
key: 'name',
|
||||||
|
width: 80,
|
||||||
|
render(dom, entity) {
|
||||||
|
if (entity.type === 1) {
|
||||||
|
if (entity.url?.startsWith('javascript')) {
|
||||||
|
return (
|
||||||
|
<Space size="small">
|
||||||
|
<FolderOpenOutlined />
|
||||||
|
{entity.name}
|
||||||
|
</Space>
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return (
|
||||||
|
<Space size="small">
|
||||||
|
<MenuOutlined />
|
||||||
|
{entity.name}
|
||||||
|
</Space>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return (
|
||||||
|
<Space size="small">
|
||||||
|
<ProfileOutlined />
|
||||||
|
{entity.name}
|
||||||
|
</Space>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '菜单url',
|
||||||
|
dataIndex: 'url',
|
||||||
|
width: 100,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '菜单path',
|
||||||
|
dataIndex: 'path',
|
||||||
|
width: 100,
|
||||||
|
ellipsis: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '样式',
|
||||||
|
dataIndex: 'css',
|
||||||
|
width: 80,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '排序号',
|
||||||
|
dataIndex: 'sort',
|
||||||
|
width: 50,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '类型',
|
||||||
|
key: 'type',
|
||||||
|
width: 50,
|
||||||
|
render(_, entity) {
|
||||||
|
if (entity.type === 1) {
|
||||||
|
if (entity.url?.startsWith('javascript')) {
|
||||||
|
return <Tag color="green">目录</Tag>;
|
||||||
|
} else {
|
||||||
|
return <Tag color="blue">菜单</Tag>;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return <Tag color="cyan">资源</Tag>;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '操作',
|
||||||
|
key: 'action',
|
||||||
|
fixed: 'right',
|
||||||
|
width: 80,
|
||||||
|
render: () => (
|
||||||
|
<Space>
|
||||||
|
<Link onClick={() => {}}>修改</Link>
|
||||||
|
<Link onClick={() => {}}>删除</Link>
|
||||||
|
</Space>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
];
|
||||||
|
return (
|
||||||
|
<PageContainer header={{ subTitle: '生成代码' }}>
|
||||||
|
<QueryFilter
|
||||||
|
defaultCollapsed
|
||||||
|
split
|
||||||
|
span={6}
|
||||||
|
className="query-filter"
|
||||||
|
onFinish={async (values) => query(values)}
|
||||||
|
// onReset={() => setParams({})}
|
||||||
|
>
|
||||||
|
<ProFormSelect
|
||||||
|
name="tenantId"
|
||||||
|
label="所属应用"
|
||||||
|
valueEnum={{
|
||||||
|
webApp: 'pc端',
|
||||||
|
app: '移动端',
|
||||||
|
zlt: '第三方应用',
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<ProFormText name="searchValue" />
|
||||||
|
</QueryFilter>
|
||||||
|
<ProTable<SYSTEM.Menu>
|
||||||
|
rowKey="id"
|
||||||
|
headerTitle="菜单管理"
|
||||||
|
dataSource={data}
|
||||||
|
columns={columns}
|
||||||
|
search={false}
|
||||||
|
pagination={false}
|
||||||
|
/>
|
||||||
|
</PageContainer>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default Generator;
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
import { menuForAuth } from '@/services/system/api';
|
||||||
|
import { treeify } from '@/util/treeify';
|
||||||
|
import type { TreeDataNode } from 'antd';
|
||||||
|
import { Modal, Tree, message } from 'antd';
|
||||||
|
import React, { useEffect, useState } from 'react';
|
||||||
|
|
||||||
|
type AssignAuthProps = {
|
||||||
|
roleId?: number;
|
||||||
|
tenantId?: string;
|
||||||
|
onCancel: () => void;
|
||||||
|
assignModalVisible: boolean;
|
||||||
|
};
|
||||||
|
|
||||||
|
type Key = string | number;
|
||||||
|
|
||||||
|
const AssignAuth: React.FC<AssignAuthProps> = (props) => {
|
||||||
|
const [treeData, setTreeData] = useState<TreeDataNode[]>([]);
|
||||||
|
const [checkedKeys, setCheckedKeys] = useState<Key[]>([]);
|
||||||
|
const { roleId, tenantId } = props;
|
||||||
|
useEffect(() => {
|
||||||
|
(async () => {
|
||||||
|
if (roleId && tenantId) {
|
||||||
|
const menus = await menuForAuth(roleId, tenantId);
|
||||||
|
const arr: (SYSTEM.Menu & TreeDataNode)[] = menus.map((m) => {
|
||||||
|
return { ...m, title: m.name, key: m.id };
|
||||||
|
});
|
||||||
|
// console.log(menus);
|
||||||
|
const tree = treeify(arr, { parentId: 'pId' });
|
||||||
|
const keys = menus.filter((m) => m.checked).map((m) => m.id);
|
||||||
|
setTreeData(tree);
|
||||||
|
setCheckedKeys(keys);
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
}, [roleId, tenantId]);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Modal
|
||||||
|
title="权限分配"
|
||||||
|
// layout="horizontal"
|
||||||
|
open={props.assignModalVisible}
|
||||||
|
// initialValues={formData}
|
||||||
|
onOk={() => {
|
||||||
|
message.info('演示环境不支持该功能');
|
||||||
|
props.onCancel();
|
||||||
|
}}
|
||||||
|
onCancel={() => {
|
||||||
|
setTreeData([]);
|
||||||
|
setCheckedKeys([]);
|
||||||
|
props.onCancel();
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Tree
|
||||||
|
defaultExpandAll
|
||||||
|
checkable
|
||||||
|
treeData={treeData}
|
||||||
|
checkedKeys={checkedKeys}
|
||||||
|
onCheck={(keys) => {
|
||||||
|
setCheckedKeys(Array.isArray(keys) ? keys : keys.checked);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</Modal>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default AssignAuth;
|
||||||
@@ -0,0 +1,67 @@
|
|||||||
|
import {
|
||||||
|
ModalForm,
|
||||||
|
ProForm,
|
||||||
|
ProFormText,
|
||||||
|
} from '@ant-design/pro-components';
|
||||||
|
import { Form } from 'antd';
|
||||||
|
import React, { useEffect } from 'react';
|
||||||
|
|
||||||
|
export type FormValueType = Partial<SYSTEM.Role>;
|
||||||
|
|
||||||
|
export type UpdateFormProps = {
|
||||||
|
onCancel: (flag?: boolean, formVals?: FormValueType) => void;
|
||||||
|
onSubmit: (values: FormValueType) => Promise<void>;
|
||||||
|
updateModalVisible: boolean;
|
||||||
|
values: Partial<SYSTEM.Role>;
|
||||||
|
};
|
||||||
|
|
||||||
|
const UpdateForm: React.FC<UpdateFormProps> = (props) => {
|
||||||
|
const [form] = Form.useForm();
|
||||||
|
const { values } = props;
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
form.setFieldsValue(values);
|
||||||
|
}, [form, values]);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<ModalForm
|
||||||
|
title="修改角色"
|
||||||
|
form={form}
|
||||||
|
width={500}
|
||||||
|
// layout="horizontal"
|
||||||
|
visible={props.updateModalVisible}
|
||||||
|
// initialValues={formData}
|
||||||
|
onFinish={props.onSubmit}
|
||||||
|
onVisibleChange={props.onCancel}
|
||||||
|
>
|
||||||
|
<ProForm.Group>
|
||||||
|
<ProFormText
|
||||||
|
rules={[
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '角色名不为空',
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
width="lg"
|
||||||
|
name="name"
|
||||||
|
label="角色名"
|
||||||
|
placeholder="输入角色名"
|
||||||
|
/>
|
||||||
|
<ProFormText
|
||||||
|
rules={[
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: 'Code不为空',
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
width="lg"
|
||||||
|
name="code"
|
||||||
|
label="Code"
|
||||||
|
placeholder="输入Code"
|
||||||
|
/>
|
||||||
|
</ProForm.Group>
|
||||||
|
</ModalForm>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default UpdateForm;
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
@import (reference) '~antd/es/style/themes/index';
|
||||||
@@ -0,0 +1,191 @@
|
|||||||
|
import { pageRole } from '@/services/system/api';
|
||||||
|
import { PlusOutlined } from '@ant-design/icons';
|
||||||
|
import type { ProColumns } from '@ant-design/pro-components';
|
||||||
|
import {
|
||||||
|
ProFormSelect,
|
||||||
|
ModalForm,
|
||||||
|
PageContainer,
|
||||||
|
ProFormText,
|
||||||
|
ProForm,
|
||||||
|
ProTable,
|
||||||
|
QueryFilter,
|
||||||
|
} from '@ant-design/pro-components';
|
||||||
|
import { Space, Typography } from 'antd';
|
||||||
|
import { Button, message } from 'antd';
|
||||||
|
import React, { useState } from 'react';
|
||||||
|
import AssignAuth from './components/AssignAuth';
|
||||||
|
import UpdateForm from './components/UpdateForm';
|
||||||
|
|
||||||
|
const { Link } = Typography;
|
||||||
|
|
||||||
|
type AssignAuthProps = {
|
||||||
|
roleId?: number;
|
||||||
|
tenantId?: string;
|
||||||
|
assignModalVisible: boolean;
|
||||||
|
};
|
||||||
|
|
||||||
|
const TableList: React.FC = () => {
|
||||||
|
const [params, setParams] = useState<Record<string, string | number>>({});
|
||||||
|
|
||||||
|
const [createModalVisible, handleModalVisible] = useState<boolean>(false);
|
||||||
|
const [updateModalVisible, handleUpdateModalVisible] = useState<boolean>(false);
|
||||||
|
|
||||||
|
const [currentRow, setCurrentRow] = useState<SYSTEM.User>();
|
||||||
|
|
||||||
|
const [assignAuth, setAssignAuth] = useState<AssignAuthProps>({ assignModalVisible: false });
|
||||||
|
|
||||||
|
const columns: ProColumns<SYSTEM.Role>[] = [
|
||||||
|
{
|
||||||
|
dataIndex: 'index',
|
||||||
|
valueType: 'indexBorder',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'ID',
|
||||||
|
dataIndex: 'id',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '角色名',
|
||||||
|
dataIndex: 'name',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'CODE',
|
||||||
|
dataIndex: 'code',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '创建时间',
|
||||||
|
dataIndex: 'createTime',
|
||||||
|
valueType: 'dateTime',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '操作',
|
||||||
|
key: 'action',
|
||||||
|
render: (_, record) => (
|
||||||
|
<Space>
|
||||||
|
<Link
|
||||||
|
onClick={() => {
|
||||||
|
handleUpdateModalVisible(true);
|
||||||
|
setCurrentRow(record);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
修改
|
||||||
|
</Link>
|
||||||
|
<Link onClick={() => message.info('演示环境不支持该功能')}>删除</Link>
|
||||||
|
<Link
|
||||||
|
onClick={() => {
|
||||||
|
setAssignAuth({ roleId: record.id, assignModalVisible: true, tenantId: 'webApp' });
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
权限分配
|
||||||
|
</Link>
|
||||||
|
</Space>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
return (
|
||||||
|
<PageContainer header={{ subTitle: '管理系统中的角色' }}>
|
||||||
|
<QueryFilter
|
||||||
|
defaultCollapsed
|
||||||
|
split
|
||||||
|
span={6}
|
||||||
|
className="query-filter"
|
||||||
|
onFinish={async (values) => setParams(values)}
|
||||||
|
>
|
||||||
|
<ProFormSelect
|
||||||
|
name="tenantId"
|
||||||
|
label="所属应用"
|
||||||
|
valueEnum={{
|
||||||
|
webApp: 'pc端',
|
||||||
|
app: '移动端',
|
||||||
|
zlt: '第三方应用',
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<ProFormSelect
|
||||||
|
name="searchKey"
|
||||||
|
label="搜索"
|
||||||
|
valueEnum={{
|
||||||
|
name: '角色名称',
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<ProFormText name="searchValue" />
|
||||||
|
</QueryFilter>
|
||||||
|
<ProTable<SYSTEM.Role>
|
||||||
|
rowKey="id"
|
||||||
|
headerTitle="角色管理"
|
||||||
|
request={pageRole}
|
||||||
|
columns={columns}
|
||||||
|
search={false}
|
||||||
|
params={params}
|
||||||
|
pagination={{
|
||||||
|
showSizeChanger: true,
|
||||||
|
showQuickJumper: true,
|
||||||
|
}}
|
||||||
|
toolBarRender={() => [
|
||||||
|
<>
|
||||||
|
<Button
|
||||||
|
type="primary"
|
||||||
|
onClick={() => {
|
||||||
|
handleModalVisible(true);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<PlusOutlined /> 添加
|
||||||
|
</Button>
|
||||||
|
</>,
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
<ModalForm
|
||||||
|
title="添加角色"
|
||||||
|
// layout="horizontal"
|
||||||
|
width={500}
|
||||||
|
visible={createModalVisible}
|
||||||
|
onVisibleChange={handleModalVisible}
|
||||||
|
onFinish={async () => {
|
||||||
|
message.info('演示环境不支持该功能');
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<ProForm.Group>
|
||||||
|
<ProFormText
|
||||||
|
rules={[
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '角色名不为空',
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
width="lg"
|
||||||
|
name="name"
|
||||||
|
label="角色名"
|
||||||
|
placeholder="输入角色名"
|
||||||
|
/>
|
||||||
|
<ProFormText
|
||||||
|
rules={[
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: 'Code不为空',
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
width="lg"
|
||||||
|
name="code"
|
||||||
|
label="Code"
|
||||||
|
placeholder="输入Code"
|
||||||
|
/>
|
||||||
|
</ProForm.Group>
|
||||||
|
</ModalForm>
|
||||||
|
<UpdateForm
|
||||||
|
onSubmit={async () => {
|
||||||
|
message.info('演示环境不支持该功能');
|
||||||
|
handleUpdateModalVisible(false);
|
||||||
|
setCurrentRow(undefined);
|
||||||
|
}}
|
||||||
|
onCancel={(flag) => {
|
||||||
|
handleUpdateModalVisible(flag ?? true);
|
||||||
|
setCurrentRow(undefined);
|
||||||
|
}}
|
||||||
|
updateModalVisible={updateModalVisible}
|
||||||
|
values={currentRow || {}}
|
||||||
|
/>
|
||||||
|
<AssignAuth {...assignAuth} onCancel={() => setAssignAuth({ assignModalVisible: false })} />
|
||||||
|
</PageContainer>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default TableList;
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
@import (reference) '~antd/es/style/themes/index';
|
||||||
@@ -0,0 +1,94 @@
|
|||||||
|
import { token } from '@/services/system/api';
|
||||||
|
import type { ProColumns } from '@ant-design/pro-components';
|
||||||
|
import {
|
||||||
|
ProFormSelect,
|
||||||
|
PageContainer,
|
||||||
|
ProFormText,
|
||||||
|
ProTable,
|
||||||
|
QueryFilter,
|
||||||
|
} from '@ant-design/pro-components';
|
||||||
|
import { Typography, message } from 'antd';
|
||||||
|
import React, { useState } from 'react';
|
||||||
|
|
||||||
|
const { Link } = Typography;
|
||||||
|
|
||||||
|
const TableList: React.FC = () => {
|
||||||
|
const [params, setParams] = useState<Record<string, string | number>>({ tenantId: 'webApp' });
|
||||||
|
|
||||||
|
const columns: ProColumns<SYSTEM.Token>[] = [
|
||||||
|
{
|
||||||
|
dataIndex: 'index',
|
||||||
|
valueType: 'indexBorder',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'token',
|
||||||
|
dataIndex: 'tokenValue',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '到期时间',
|
||||||
|
dataIndex: 'expiration',
|
||||||
|
valueType: 'dateTime',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '用户名',
|
||||||
|
dataIndex: 'username',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '授权类型',
|
||||||
|
dataIndex: 'grantType',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '所属应用',
|
||||||
|
dataIndex: 'clientId',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '账号类型',
|
||||||
|
dataIndex: 'accountType',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '操作',
|
||||||
|
key: 'action',
|
||||||
|
render: () => <Link onClick={() => message.info('演示环境不支持该功能')}>删除</Link>,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
return (
|
||||||
|
<PageContainer header={{ subTitle: '管理会话Token' }}>
|
||||||
|
<QueryFilter
|
||||||
|
defaultCollapsed
|
||||||
|
split
|
||||||
|
span={6}
|
||||||
|
className="query-filter"
|
||||||
|
initialValues={params}
|
||||||
|
onFinish={async (values) => setParams(values)}
|
||||||
|
// onReset={() => setParams({})}
|
||||||
|
>
|
||||||
|
<ProFormSelect
|
||||||
|
name="tenantId"
|
||||||
|
label="所属应用"
|
||||||
|
valueEnum={{
|
||||||
|
webApp: 'pc端',
|
||||||
|
app: '移动端',
|
||||||
|
zlt: '第三方应用',
|
||||||
|
}}
|
||||||
|
allowClear={false}
|
||||||
|
/>
|
||||||
|
<ProFormText name="username" label="搜索" placeholder="输入用户名" />
|
||||||
|
</QueryFilter>
|
||||||
|
<ProTable<SYSTEM.Token>
|
||||||
|
rowKey="tokenValue"
|
||||||
|
headerTitle="Token管理"
|
||||||
|
request={token}
|
||||||
|
columns={columns}
|
||||||
|
search={false}
|
||||||
|
params={params}
|
||||||
|
pagination={{
|
||||||
|
showSizeChanger: true,
|
||||||
|
showQuickJumper: true,
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</PageContainer>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default TableList;
|
||||||
@@ -0,0 +1,116 @@
|
|||||||
|
import { role } from '@/services/system/api';
|
||||||
|
import {
|
||||||
|
ModalForm,
|
||||||
|
ProForm,
|
||||||
|
ProFormRadio,
|
||||||
|
ProFormSelect,
|
||||||
|
ProFormText,
|
||||||
|
} from '@ant-design/pro-components';
|
||||||
|
import { Form } from 'antd';
|
||||||
|
import React, { useEffect } from 'react';
|
||||||
|
|
||||||
|
export type FormValueType = {
|
||||||
|
roleCodes?: string[];
|
||||||
|
} & Partial<SYSTEM.User>;
|
||||||
|
|
||||||
|
export type UpdateFormProps = {
|
||||||
|
onCancel: (flag?: boolean, formVals?: FormValueType) => void;
|
||||||
|
onSubmit: (values: FormValueType) => Promise<void>;
|
||||||
|
updateModalVisible: boolean;
|
||||||
|
values: Partial<SYSTEM.User>;
|
||||||
|
};
|
||||||
|
|
||||||
|
const UpdateForm: React.FC<UpdateFormProps> = (props) => {
|
||||||
|
const [form] = Form.useForm();
|
||||||
|
const { values } = props;
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (values.roles) {
|
||||||
|
const roleCodes = values.roles.map((r) => r.code);
|
||||||
|
const formData: FormValueType = { ...values, roleCodes };
|
||||||
|
form.setFieldsValue(formData);
|
||||||
|
}
|
||||||
|
}, [form, values]);
|
||||||
|
return (
|
||||||
|
<ModalForm
|
||||||
|
title="修改用户"
|
||||||
|
form={form}
|
||||||
|
// layout="horizontal"
|
||||||
|
visible={props.updateModalVisible}
|
||||||
|
// initialValues={formData}
|
||||||
|
onFinish={props.onSubmit}
|
||||||
|
onVisibleChange={props.onCancel}
|
||||||
|
>
|
||||||
|
<ProForm.Group>
|
||||||
|
<ProFormText
|
||||||
|
rules={[
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '账号不为空',
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
width="md"
|
||||||
|
name="username"
|
||||||
|
label="账号"
|
||||||
|
placeholder="输入账号"
|
||||||
|
/>
|
||||||
|
<ProFormText
|
||||||
|
rules={[
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '用户名不为空',
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
width="md"
|
||||||
|
name="nickname"
|
||||||
|
label="用户名"
|
||||||
|
placeholder="输入用户名"
|
||||||
|
/>
|
||||||
|
<ProFormText
|
||||||
|
rules={[
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '手机号不为空',
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
width="md"
|
||||||
|
name="mobile"
|
||||||
|
label="手机号"
|
||||||
|
placeholder="输入手机号"
|
||||||
|
/>
|
||||||
|
<ProFormRadio.Group
|
||||||
|
name="sex"
|
||||||
|
label="性别"
|
||||||
|
width="md"
|
||||||
|
options={[
|
||||||
|
{
|
||||||
|
label: '男',
|
||||||
|
value: 0,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '女',
|
||||||
|
value: 1,
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
<ProFormSelect
|
||||||
|
mode="multiple"
|
||||||
|
name="roleCodes"
|
||||||
|
label="角色"
|
||||||
|
width="md"
|
||||||
|
request={async () => {
|
||||||
|
const roles = await role();
|
||||||
|
if (roles)
|
||||||
|
return roles.map((r) => {
|
||||||
|
return { label: r.name, value: r.code };
|
||||||
|
});
|
||||||
|
return [];
|
||||||
|
}}
|
||||||
|
placeholder="选择角色"
|
||||||
|
/>
|
||||||
|
</ProForm.Group>
|
||||||
|
</ModalForm>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default UpdateForm;
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
@import (reference) '~antd/es/style/themes/index';
|
||||||
@@ -0,0 +1,247 @@
|
|||||||
|
import { user, exportUser, role } from '@/services/system/api';
|
||||||
|
import { ExportOutlined, ImportOutlined, PlusOutlined } from '@ant-design/icons';
|
||||||
|
import type { ProColumns } from '@ant-design/pro-components';
|
||||||
|
import {
|
||||||
|
ProFormRadio,
|
||||||
|
ProFormSelect,
|
||||||
|
ModalForm,
|
||||||
|
PageContainer,
|
||||||
|
ProFormText,
|
||||||
|
ProForm,
|
||||||
|
ProTable,
|
||||||
|
QueryFilter,
|
||||||
|
} from '@ant-design/pro-components';
|
||||||
|
import { Space, Typography } from 'antd';
|
||||||
|
import { Button, Switch, message } from 'antd';
|
||||||
|
import React, { useState } from 'react';
|
||||||
|
import UpdateForm from './components/UpdateForm';
|
||||||
|
|
||||||
|
const { Link } = Typography;
|
||||||
|
|
||||||
|
const TableList: React.FC = () => {
|
||||||
|
const [params, setParams] = useState<Record<string, string | number>>({});
|
||||||
|
|
||||||
|
const [createModalVisible, handleModalVisible] = useState<boolean>(false);
|
||||||
|
|
||||||
|
const [updateModalVisible, handleUpdateModalVisible] = useState<boolean>(false);
|
||||||
|
const [currentRow, setCurrentRow] = useState<SYSTEM.User>();
|
||||||
|
|
||||||
|
const columns: ProColumns<SYSTEM.User>[] = [
|
||||||
|
{
|
||||||
|
dataIndex: 'index',
|
||||||
|
valueType: 'indexBorder',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '用户编号',
|
||||||
|
dataIndex: 'id',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '账号',
|
||||||
|
dataIndex: 'username',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '用户名',
|
||||||
|
dataIndex: 'nickname',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '手机号',
|
||||||
|
dataIndex: 'mobile',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '性别',
|
||||||
|
dataIndex: 'sex',
|
||||||
|
render: (value) => (value === 0 ? '男' : '女'),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '创建时间',
|
||||||
|
dataIndex: 'createTime',
|
||||||
|
valueType: 'dateTime',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '状态',
|
||||||
|
dataIndex: 'enabled',
|
||||||
|
render: (_dom, entity) => (
|
||||||
|
<Switch
|
||||||
|
checkedChildren="正常"
|
||||||
|
unCheckedChildren="锁定"
|
||||||
|
checked={entity.enabled}
|
||||||
|
onClick={() => message.info('演示环境不支持该功能')}
|
||||||
|
/>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '操作',
|
||||||
|
key: 'action',
|
||||||
|
render: (_, record) => (
|
||||||
|
<Space>
|
||||||
|
<Link
|
||||||
|
onClick={() => {
|
||||||
|
handleUpdateModalVisible(true);
|
||||||
|
setCurrentRow(record);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
修改
|
||||||
|
</Link>
|
||||||
|
<Link onClick={() => message.info('演示环境不支持该功能')}>重置密码</Link>
|
||||||
|
<Link onClick={() => message.info('演示环境不支持该功能')}>删除</Link>
|
||||||
|
</Space>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
return (
|
||||||
|
<PageContainer header={{ subTitle: '管理系统中的用户账号' }}>
|
||||||
|
<QueryFilter
|
||||||
|
defaultCollapsed
|
||||||
|
split
|
||||||
|
className="query-filter"
|
||||||
|
onFinish={async (values) => setParams(values)}
|
||||||
|
>
|
||||||
|
<ProFormSelect
|
||||||
|
name="searchKey"
|
||||||
|
label="搜索"
|
||||||
|
valueEnum={{
|
||||||
|
user_id: 'ID',
|
||||||
|
username: '账号',
|
||||||
|
nick_name: '用户名',
|
||||||
|
mobile: '手机号',
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<ProFormText name="searchValue" />
|
||||||
|
</QueryFilter>
|
||||||
|
<ProTable<SYSTEM.User>
|
||||||
|
rowKey="id"
|
||||||
|
headerTitle="用户管理"
|
||||||
|
request={user}
|
||||||
|
columns={columns}
|
||||||
|
search={false}
|
||||||
|
params={params}
|
||||||
|
pagination={{
|
||||||
|
showSizeChanger: true,
|
||||||
|
showQuickJumper: true,
|
||||||
|
}}
|
||||||
|
toolBarRender={() => [
|
||||||
|
<>
|
||||||
|
<Button
|
||||||
|
onClick={() => {
|
||||||
|
exportUser();
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<ExportOutlined /> 导出
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
onClick={() => {
|
||||||
|
message.info('演示环境不支持该功能');
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<ImportOutlined /> 导入
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
type="primary"
|
||||||
|
onClick={() => {
|
||||||
|
handleModalVisible(true);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<PlusOutlined /> 添加
|
||||||
|
</Button>
|
||||||
|
</>,
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
<ModalForm
|
||||||
|
title="添加用户"
|
||||||
|
// layout="horizontal"
|
||||||
|
visible={createModalVisible}
|
||||||
|
onVisibleChange={handleModalVisible}
|
||||||
|
initialValues={{ sex: 0 }}
|
||||||
|
onFinish={async (values) => {
|
||||||
|
console.log(values);
|
||||||
|
message.info('演示环境不支持该功能');
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<ProForm.Group>
|
||||||
|
<ProFormText
|
||||||
|
rules={[
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '账号不为空',
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
width="md"
|
||||||
|
name="username"
|
||||||
|
label="账号"
|
||||||
|
placeholder="输入账号"
|
||||||
|
/>
|
||||||
|
<ProFormText
|
||||||
|
rules={[
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '用户名不为空',
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
width="md"
|
||||||
|
name="nickname"
|
||||||
|
label="用户名"
|
||||||
|
placeholder="输入用户名"
|
||||||
|
/>
|
||||||
|
<ProFormText
|
||||||
|
rules={[
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '手机号不为空',
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
width="md"
|
||||||
|
name="mobile"
|
||||||
|
label="手机号"
|
||||||
|
placeholder="输入手机号"
|
||||||
|
/>
|
||||||
|
<ProFormRadio.Group
|
||||||
|
name="sex"
|
||||||
|
label="性别"
|
||||||
|
width="md"
|
||||||
|
options={[
|
||||||
|
{
|
||||||
|
label: '男',
|
||||||
|
value: 0,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '女',
|
||||||
|
value: 1,
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
<ProFormSelect
|
||||||
|
mode="multiple"
|
||||||
|
name="roleCodes"
|
||||||
|
label="角色"
|
||||||
|
width="md"
|
||||||
|
request={async () => {
|
||||||
|
const roles = await role();
|
||||||
|
if (roles)
|
||||||
|
return roles.map((r) => {
|
||||||
|
return { label: r.name, value: r.code };
|
||||||
|
});
|
||||||
|
return [];
|
||||||
|
}}
|
||||||
|
placeholder="选择角色"
|
||||||
|
/>
|
||||||
|
</ProForm.Group>
|
||||||
|
</ModalForm>
|
||||||
|
<UpdateForm
|
||||||
|
onSubmit={async () => {
|
||||||
|
message.info('演示环境不支持该功能');
|
||||||
|
handleUpdateModalVisible(false);
|
||||||
|
setCurrentRow(undefined);
|
||||||
|
}}
|
||||||
|
onCancel={(flag) => {
|
||||||
|
handleUpdateModalVisible(flag ?? true);
|
||||||
|
setCurrentRow(undefined);
|
||||||
|
}}
|
||||||
|
updateModalVisible={updateModalVisible}
|
||||||
|
values={currentRow || {}}
|
||||||
|
/>
|
||||||
|
</PageContainer>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default TableList;
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
@import (reference) '~antd/es/style/themes/index';
|
||||||
|
|
||||||
|
.baseView {
|
||||||
|
display: flex;
|
||||||
|
padding: @padding-lg;
|
||||||
|
background: @component-background;
|
||||||
|
|
||||||
|
:global {
|
||||||
|
.ant-legacy-form-item .ant-legacy-form-item-control-wrapper {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.left {
|
||||||
|
min-width: 224px;
|
||||||
|
max-width: 448px;
|
||||||
|
}
|
||||||
|
.right {
|
||||||
|
flex: 1;
|
||||||
|
padding-left: 104px;
|
||||||
|
.avatar_title {
|
||||||
|
height: 22px;
|
||||||
|
margin-bottom: 8px;
|
||||||
|
color: @heading-color;
|
||||||
|
font-size: @font-size-base;
|
||||||
|
line-height: 22px;
|
||||||
|
}
|
||||||
|
.avatar {
|
||||||
|
width: 144px;
|
||||||
|
height: 144px;
|
||||||
|
margin-bottom: 12px;
|
||||||
|
overflow: hidden;
|
||||||
|
img {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.button_view {
|
||||||
|
width: 144px;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,93 @@
|
|||||||
|
import { currentUser2 } from '@/services/login/api';
|
||||||
|
import { UploadOutlined } from '@ant-design/icons';
|
||||||
|
import type { ProFormInstance } from '@ant-design/pro-components';
|
||||||
|
import { PageContainer, ProFormText, ProForm, ProFormRadio } from '@ant-design/pro-components';
|
||||||
|
import { Button, Upload } from 'antd';
|
||||||
|
import React, { useRef } from 'react';
|
||||||
|
import { useModel } from 'umi';
|
||||||
|
import styles from './index.less';
|
||||||
|
|
||||||
|
const AvatarView = ({ avatar }: { avatar: string }) => (
|
||||||
|
<>
|
||||||
|
<div className={styles.avatar_title}>头像</div>
|
||||||
|
<div className={styles.avatar}>
|
||||||
|
<img src={avatar} alt="avatar" />
|
||||||
|
</div>
|
||||||
|
<Upload showUploadList={false}>
|
||||||
|
<div className={styles.button_view}>
|
||||||
|
<Button>
|
||||||
|
<UploadOutlined />
|
||||||
|
更换头像
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</Upload>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
|
||||||
|
const UserInfo: React.FC = () => {
|
||||||
|
const formRef = useRef<ProFormInstance<API.CurrentUser>>();
|
||||||
|
const { initialState } = useModel('@@initialState');
|
||||||
|
const { currentUser } = initialState;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<PageContainer header={{ subTitle: '更新个人信息' }}>
|
||||||
|
<div className={styles.baseView}>
|
||||||
|
<div className={styles.left}>
|
||||||
|
<ProForm<API.CurrentUser>
|
||||||
|
formRef={formRef}
|
||||||
|
//layout="horizontal"
|
||||||
|
request={currentUser2}
|
||||||
|
// labelCol={{ span: 8 }}
|
||||||
|
// wrapperCol={{ span: 16 }}
|
||||||
|
>
|
||||||
|
<ProFormText name="username" label="账号" readonly />
|
||||||
|
<ProFormText
|
||||||
|
rules={[
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '用户名不为空',
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
width="md"
|
||||||
|
name="nickname"
|
||||||
|
label="用户名"
|
||||||
|
placeholder="输入用户名"
|
||||||
|
/>
|
||||||
|
<ProFormText
|
||||||
|
rules={[
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '手机号不为空',
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
width="md"
|
||||||
|
name="mobile"
|
||||||
|
label="手机号"
|
||||||
|
placeholder="输入手机号"
|
||||||
|
/>
|
||||||
|
<ProFormRadio.Group
|
||||||
|
name="sex"
|
||||||
|
label="性别"
|
||||||
|
width="md"
|
||||||
|
options={[
|
||||||
|
{
|
||||||
|
label: '男',
|
||||||
|
value: 0,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '女',
|
||||||
|
value: 1,
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
</ProForm>
|
||||||
|
</div>
|
||||||
|
<div className={styles.right}>
|
||||||
|
<AvatarView avatar={currentUser.headImgUrl} />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</PageContainer>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default UserInfo;
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
@import (reference) '~antd/es/style/themes/index';
|
||||||
|
|
||||||
|
.container {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
height: 100vh;
|
||||||
|
overflow: auto;
|
||||||
|
background: @layout-body-background;
|
||||||
|
}
|
||||||
|
|
||||||
|
.lang {
|
||||||
|
width: 100%;
|
||||||
|
height: 40px;
|
||||||
|
line-height: 44px;
|
||||||
|
text-align: right;
|
||||||
|
:global(.ant-dropdown-trigger) {
|
||||||
|
margin-right: 24px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.content {
|
||||||
|
flex: 1;
|
||||||
|
padding: 32px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (min-width: @screen-md-min) {
|
||||||
|
.container {
|
||||||
|
background-image: url('https://gw.alipayobjects.com/zos/rmsportal/TVYTbAXWheQpRcWDaDMu.svg');
|
||||||
|
background-repeat: no-repeat;
|
||||||
|
background-position: center 110px;
|
||||||
|
background-size: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.content {
|
||||||
|
padding: 32px 0 24px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.icon {
|
||||||
|
margin-left: 8px;
|
||||||
|
color: rgba(0, 0, 0, 0.2);
|
||||||
|
font-size: 24px;
|
||||||
|
vertical-align: middle;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: color 0.3s;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
color: @primary-color;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,156 @@
|
|||||||
|
import Footer from '@/components/Footer';
|
||||||
|
import { login } from '@/services/login/api';
|
||||||
|
import { InfoCircleOutlined, LockOutlined, UserOutlined } from '@ant-design/icons';
|
||||||
|
import { LoginForm, ProFormCaptcha, ProFormText } from '@ant-design/pro-components';
|
||||||
|
import { message, Tooltip } from 'antd';
|
||||||
|
import React, { useState } from 'react';
|
||||||
|
import { FormattedMessage, history, useIntl, useModel } from 'umi';
|
||||||
|
import { v4 as uuidv4 } from 'uuid';
|
||||||
|
import styles from './index.less';
|
||||||
|
|
||||||
|
const Login: React.FC = () => {
|
||||||
|
const [uuid, setUuid] = useState<string>(uuidv4());
|
||||||
|
const { initialState, setInitialState } = useModel('@@initialState');
|
||||||
|
|
||||||
|
const intl = useIntl();
|
||||||
|
|
||||||
|
const fetchUserInfo = async () => {
|
||||||
|
const userInfo = await initialState?.fetchUserInfo?.();
|
||||||
|
if (userInfo) {
|
||||||
|
await setInitialState((s) => ({
|
||||||
|
...s,
|
||||||
|
currentUser: userInfo,
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleSubmit = async (values: API.LoginParams) => {
|
||||||
|
try {
|
||||||
|
// 登录
|
||||||
|
const msg = await login({ ...values });
|
||||||
|
if (msg.resp_code === 0) {
|
||||||
|
const defaultLoginSuccessMessage = intl.formatMessage({
|
||||||
|
id: 'pages.login.success',
|
||||||
|
defaultMessage: '登录成功!',
|
||||||
|
});
|
||||||
|
const loginResult = msg.datas;
|
||||||
|
if (loginResult && loginResult.access_token)
|
||||||
|
sessionStorage.setItem('access_token', loginResult.access_token);
|
||||||
|
message.success(defaultLoginSuccessMessage);
|
||||||
|
await fetchUserInfo();
|
||||||
|
/** 此方法会跳转到 redirect 参数所在的位置 */
|
||||||
|
if (!history) return;
|
||||||
|
const { query } = history.location;
|
||||||
|
const { redirect } = query as { redirect: string };
|
||||||
|
history.push(redirect || '/');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 如果失败去设置用户错误信息
|
||||||
|
} catch (error) {
|
||||||
|
const defaultLoginFailureMessage = intl.formatMessage({
|
||||||
|
id: 'pages.login.failure',
|
||||||
|
defaultMessage: '登录失败,请重试!',
|
||||||
|
});
|
||||||
|
message.error(defaultLoginFailureMessage);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const captchaUrl = `/api-uaa/validata/code/${uuid}`;
|
||||||
|
return (
|
||||||
|
<div className={styles.container}>
|
||||||
|
<div className={styles.content}>
|
||||||
|
<LoginForm
|
||||||
|
logo={<img alt="logo" src="./logo.png" />}
|
||||||
|
title="microservices-platform"
|
||||||
|
subTitle={intl.formatMessage({ id: 'pages.layouts.userLayout.title' })}
|
||||||
|
initialValues={{
|
||||||
|
autoLogin: true,
|
||||||
|
}}
|
||||||
|
onFinish={async (values) => {
|
||||||
|
await handleSubmit({ ...values, deviceId: uuid } as API.LoginParams);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<>
|
||||||
|
<ProFormText
|
||||||
|
name="username"
|
||||||
|
fieldProps={{
|
||||||
|
size: 'large',
|
||||||
|
prefix: <UserOutlined className={styles.prefixIcon} />,
|
||||||
|
}}
|
||||||
|
placeholder={intl.formatMessage({
|
||||||
|
id: 'pages.login.username.placeholder',
|
||||||
|
defaultMessage: '账号',
|
||||||
|
})}
|
||||||
|
rules={[
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: (
|
||||||
|
<FormattedMessage
|
||||||
|
id="pages.login.username.required"
|
||||||
|
defaultMessage="请输入账号!"
|
||||||
|
/>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
<ProFormText.Password
|
||||||
|
name="password"
|
||||||
|
fieldProps={{
|
||||||
|
size: 'large',
|
||||||
|
prefix: <LockOutlined className={styles.prefixIcon} />,
|
||||||
|
}}
|
||||||
|
placeholder={intl.formatMessage({
|
||||||
|
id: 'pages.login.password.placeholder',
|
||||||
|
defaultMessage: '密码',
|
||||||
|
})}
|
||||||
|
rules={[
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: (
|
||||||
|
<FormattedMessage
|
||||||
|
id="pages.login.password.required"
|
||||||
|
defaultMessage="请输入密码!"
|
||||||
|
/>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
<ProFormCaptcha
|
||||||
|
name="validCode"
|
||||||
|
fieldProps={{
|
||||||
|
size: 'large',
|
||||||
|
prefix: <LockOutlined className={'prefixIcon'} />,
|
||||||
|
suffix: (
|
||||||
|
<Tooltip title="不区分大小写">
|
||||||
|
<InfoCircleOutlined style={{ color: 'rgba(0,0,0,.45)' }} />
|
||||||
|
</Tooltip>
|
||||||
|
),
|
||||||
|
}}
|
||||||
|
captchaProps={{
|
||||||
|
size: 'large',
|
||||||
|
style: { padding: '0 2px' },
|
||||||
|
}}
|
||||||
|
placeholder={'验证码'}
|
||||||
|
captchaTextRender={() => (
|
||||||
|
<span onClick={() => setUuid(uuidv4())}>
|
||||||
|
<img src={captchaUrl} alt="验证码" />
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
rules={[
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请输入验证码!',
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
onGetCaptcha={async () => {}}
|
||||||
|
/>
|
||||||
|
</>
|
||||||
|
</LoginForm>
|
||||||
|
</div>
|
||||||
|
<Footer />
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default Login;
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
/* eslint-disable no-restricted-globals */
|
||||||
|
/* eslint-disable no-underscore-dangle */
|
||||||
|
/* globals workbox */
|
||||||
|
workbox.core.setCacheNameDetails({
|
||||||
|
prefix: 'antd-pro',
|
||||||
|
suffix: 'v5',
|
||||||
|
});
|
||||||
|
// Control all opened tabs ASAP
|
||||||
|
workbox.clientsClaim();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Use precaching list generated by workbox in build process.
|
||||||
|
* https://developers.google.com/web/tools/workbox/reference-docs/latest/workbox.precaching
|
||||||
|
*/
|
||||||
|
workbox.precaching.precacheAndRoute(self.__precacheManifest || []);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register a navigation route.
|
||||||
|
* https://developers.google.com/web/tools/workbox/modules/workbox-routing#how_to_register_a_navigation_route
|
||||||
|
*/
|
||||||
|
workbox.routing.registerNavigationRoute('/index.html');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Use runtime cache:
|
||||||
|
* https://developers.google.com/web/tools/workbox/reference-docs/latest/workbox.routing#.registerRoute
|
||||||
|
*
|
||||||
|
* Workbox provides all common caching strategies including CacheFirst, NetworkFirst etc.
|
||||||
|
* https://developers.google.com/web/tools/workbox/reference-docs/latest/workbox.strategies
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** Handle API requests */
|
||||||
|
workbox.routing.registerRoute(/\/api\//, workbox.strategies.networkFirst());
|
||||||
|
|
||||||
|
/** Handle third party requests */
|
||||||
|
workbox.routing.registerRoute(
|
||||||
|
/^https:\/\/gw\.alipayobjects\.com\//,
|
||||||
|
workbox.strategies.networkFirst(),
|
||||||
|
);
|
||||||
|
workbox.routing.registerRoute(
|
||||||
|
/^https:\/\/cdnjs\.cloudflare\.com\//,
|
||||||
|
workbox.strategies.networkFirst(),
|
||||||
|
);
|
||||||
|
workbox.routing.registerRoute(/\/color.less/, workbox.strategies.networkFirst());
|
||||||
|
|
||||||
|
/** Response to client after skipping waiting with MessageChannel */
|
||||||
|
addEventListener('message', (event) => {
|
||||||
|
const replyPort = event.ports[0];
|
||||||
|
const message = event.data;
|
||||||
|
if (replyPort && message && message.type === 'skip-waiting') {
|
||||||
|
event.waitUntil(
|
||||||
|
self.skipWaiting().then(
|
||||||
|
() => {
|
||||||
|
replyPort.postMessage({
|
||||||
|
error: null,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
(error) => {
|
||||||
|
replyPort.postMessage({
|
||||||
|
error,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
// @ts-ignore
|
||||||
|
/* eslint-disable */
|
||||||
|
import { request } from 'umi';
|
||||||
|
|
||||||
|
export async function currentUser(options?: { [key: string]: any }) {
|
||||||
|
return request<API.OptionalResult<API.CurrentUser>>('/api-user/users/current', {
|
||||||
|
method: 'GET',
|
||||||
|
...(options || {}),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function currentUser2(options?: { [key: string]: any }) {
|
||||||
|
const result = await request<API.OptionalResult<API.CurrentUser>>('/api-user/users/current', {
|
||||||
|
method: 'GET',
|
||||||
|
...(options || {}),
|
||||||
|
});
|
||||||
|
return result.datas ?? {};
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function fetchMenuData(options?: { [key: string]: any }) {
|
||||||
|
return request<API.Menu[]>('/api-user/menus/current', {
|
||||||
|
method: 'GET',
|
||||||
|
...(options || {}),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 退出登录接口 POST /api/login/outLogin */
|
||||||
|
export async function outLogin(options?: { [key: string]: any }) {
|
||||||
|
return request<Record<string, any>>('/api/login/outLogin', {
|
||||||
|
method: 'POST',
|
||||||
|
...(options || {}),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function login(body: API.LoginParams, options?: { [key: string]: any }) {
|
||||||
|
return request<API.OptionalResult<API.LoginResult>>('/api-uaa/oauth/token', {
|
||||||
|
method: 'POST',
|
||||||
|
requestType: 'form',
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/x-www-form-urlencoded',
|
||||||
|
Authorization: 'Basic d2ViQXBwOndlYkFwcA==',
|
||||||
|
},
|
||||||
|
data: { ...body, grant_type: 'password_code' },
|
||||||
|
...(options || {}),
|
||||||
|
});
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
// @ts-ignore
|
||||||
|
/* eslint-disable */
|
||||||
|
// API 更新时间:
|
||||||
|
// API 唯一标识:
|
||||||
|
import * as api from './api';
|
||||||
|
export default {
|
||||||
|
api,
|
||||||
|
};
|
||||||
@@ -0,0 +1,59 @@
|
|||||||
|
// @ts-ignore
|
||||||
|
/* eslint-disable */
|
||||||
|
|
||||||
|
declare namespace API {
|
||||||
|
type Result<T> = {
|
||||||
|
resp_code?: number;
|
||||||
|
resp_msg?: number;
|
||||||
|
datas?: T[];
|
||||||
|
};
|
||||||
|
|
||||||
|
type OptionalResult<T> = {
|
||||||
|
resp_code?: number;
|
||||||
|
resp_msg?: number;
|
||||||
|
datas?: T;
|
||||||
|
};
|
||||||
|
|
||||||
|
type CurrentUser = {
|
||||||
|
userId?: string;
|
||||||
|
username?: string;
|
||||||
|
nickname?: string;
|
||||||
|
headImgUrl?: string;
|
||||||
|
sex?: number;
|
||||||
|
type?: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
type Menu = {
|
||||||
|
id?: number;
|
||||||
|
name?: string;
|
||||||
|
path?: string;
|
||||||
|
url?: string;
|
||||||
|
css?: string;
|
||||||
|
subMenus?: Menu[];
|
||||||
|
};
|
||||||
|
|
||||||
|
type LoginResult = {
|
||||||
|
access_token?: string;
|
||||||
|
token_type?: string;
|
||||||
|
refresh_token?: string;
|
||||||
|
expires_in?: number;
|
||||||
|
scope?: string;
|
||||||
|
account_type?: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
type LoginParams = {
|
||||||
|
username?: string;
|
||||||
|
password?: string;
|
||||||
|
validCode?: string;
|
||||||
|
deviceId?: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
type ErrorResponse = {
|
||||||
|
/** 业务约定的错误码 */
|
||||||
|
errorCode: string;
|
||||||
|
/** 业务上的错误信息 */
|
||||||
|
errorMessage?: string;
|
||||||
|
/** 业务上的请求是否成功 */
|
||||||
|
success?: boolean;
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -0,0 +1,56 @@
|
|||||||
|
// @ts-ignore
|
||||||
|
/* eslint-disable */
|
||||||
|
import { request } from 'umi';
|
||||||
|
|
||||||
|
export async function indice(params?: { [key: string]: string | number }) {
|
||||||
|
const { current, pageSize, ...rest } = params ?? {};
|
||||||
|
const result = await request<SYSTEM.Page<SEARCH.Indice>>('/api-search/admin/indices', {
|
||||||
|
method: 'GET',
|
||||||
|
params: { page: current, limit: pageSize, ...rest },
|
||||||
|
});
|
||||||
|
return { data: result.data };
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function index(indexName: string) {
|
||||||
|
const result = await request<API.OptionalResult<any>>('/api-search/admin/index', {
|
||||||
|
method: 'GET',
|
||||||
|
params: { indexName },
|
||||||
|
});
|
||||||
|
return result.datas;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function syslog(params?: { [key: string]: string | number }) {
|
||||||
|
const { current, pageSize, ...rest } = params ?? {};
|
||||||
|
const result = await request<SYSTEM.Page<SEARCH.SysLog>>('/api-log/sysLog', {
|
||||||
|
method: 'GET',
|
||||||
|
params: { page: current, limit: pageSize, ...rest },
|
||||||
|
});
|
||||||
|
return { data: result.data, total: result.count };
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function tracelog(traceId: string) {
|
||||||
|
const params = { queryStr: `traceId:${traceId}`, sortCol: 'timestamp', sortOrder: 'ASC' };
|
||||||
|
const result = await request<SYSTEM.Page<SEARCH.TraceLog>>('/api-log/traceLog', {
|
||||||
|
method: 'GET',
|
||||||
|
params,
|
||||||
|
});
|
||||||
|
return result.data;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function auditlog(params?: { [key: string]: string | number }) {
|
||||||
|
const { current, pageSize, ...rest } = params ?? {};
|
||||||
|
const result = await request<SYSTEM.Page<SEARCH.TraceLog>>('/api-log/auditLog', {
|
||||||
|
method: 'GET',
|
||||||
|
params: { page: current, limit: pageSize, ...rest },
|
||||||
|
});
|
||||||
|
return { data: result.data, total: result.count };
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function slowQueryLog(params?: { [key: string]: string | number }) {
|
||||||
|
const { current, pageSize, ...rest } = params ?? {};
|
||||||
|
const result = await request<SYSTEM.Page<SEARCH.TraceLog>>('/api-log/slowQueryLog', {
|
||||||
|
method: 'GET',
|
||||||
|
params: { page: current, limit: pageSize, ...rest },
|
||||||
|
});
|
||||||
|
return { data: result.data, total: result.count };
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
// @ts-ignore
|
||||||
|
/* eslint-disable */
|
||||||
|
// API 更新时间:
|
||||||
|
// API 唯一标识:
|
||||||
|
import * as api from './api';
|
||||||
|
export default {
|
||||||
|
api,
|
||||||
|
};
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
// @ts-ignore
|
||||||
|
/* eslint-disable */
|
||||||
|
|
||||||
|
declare namespace SEARCH {
|
||||||
|
type Indice = {
|
||||||
|
docsCount?: string;
|
||||||
|
docsDeleted?: string;
|
||||||
|
health?: string;
|
||||||
|
index?: string;
|
||||||
|
status?: string;
|
||||||
|
storeSize?: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
type SysLog = {
|
||||||
|
id?: string;
|
||||||
|
'@timestamp'?: Date;
|
||||||
|
agent?: { name?: string; type?: string; id?: string; version?: string };
|
||||||
|
appName?: string;
|
||||||
|
classname?: string;
|
||||||
|
id?: string;
|
||||||
|
logLevel?: string;
|
||||||
|
serverIp?: string;
|
||||||
|
serverPort?: string;
|
||||||
|
timestamp?: string;
|
||||||
|
message?: string;
|
||||||
|
traceId?: string;
|
||||||
|
spanId?: string;
|
||||||
|
threadName?: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
type TraceLog = {
|
||||||
|
appName?: string;
|
||||||
|
parentId?: string;
|
||||||
|
serverIp?: string;
|
||||||
|
serverPort?: string;
|
||||||
|
spanId?: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
type AuditLog = {
|
||||||
|
id?: string;
|
||||||
|
appName?: string;
|
||||||
|
className?: string;
|
||||||
|
clientId?: string;
|
||||||
|
methodName?: string;
|
||||||
|
operation?: string;
|
||||||
|
timestamp?: string;
|
||||||
|
userId?: string;
|
||||||
|
userName?: string;
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -0,0 +1,100 @@
|
|||||||
|
// @ts-ignore
|
||||||
|
/* eslint-disable */
|
||||||
|
import { download } from '@/util/download';
|
||||||
|
import { request } from 'umi';
|
||||||
|
|
||||||
|
export async function user(params?: { [key: string]: string | number }) {
|
||||||
|
const { current, pageSize, ...rest } = params ?? {};
|
||||||
|
const result = await request<SYSTEM.Page<SYSTEM.User>>('/api-user/users', {
|
||||||
|
method: 'GET',
|
||||||
|
params: { page: current, limit: pageSize, ...rest },
|
||||||
|
});
|
||||||
|
return { data: result.data, total: result.count };
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function role() {
|
||||||
|
const result = await request<SYSTEM.Page<SYSTEM.Role>>('/api-user/roles', {
|
||||||
|
method: 'GET',
|
||||||
|
});
|
||||||
|
return result.data;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function pageRole(params?: { [key: string]: string | number }) {
|
||||||
|
const { current, pageSize, ...rest } = params ?? {};
|
||||||
|
const result = await request<SYSTEM.Page<SYSTEM.Role>>('/api-user/roles', {
|
||||||
|
method: 'GET',
|
||||||
|
params: { page: current, limit: pageSize, ...rest },
|
||||||
|
});
|
||||||
|
return { data: result.data, total: result.count };
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function menuForAuth(roleId: number, tenantId: string) {
|
||||||
|
const url = `/api-user/menus/${roleId}/menus`;
|
||||||
|
const result = await request<SYSTEM.Menu[]>(url, {
|
||||||
|
method: 'GET',
|
||||||
|
params: { tenantId },
|
||||||
|
});
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function exportUser(params?: { [key: string]: string | number }) {
|
||||||
|
return request('/api-user/users/export', {
|
||||||
|
method: 'POST',
|
||||||
|
params,
|
||||||
|
responseType: 'blob',
|
||||||
|
}).then((res) => {
|
||||||
|
const blob = new Blob([res]);
|
||||||
|
const objectURL = URL.createObjectURL(blob);
|
||||||
|
let btn = document.createElement('a');
|
||||||
|
btn.download = 'user.xls';
|
||||||
|
btn.href = objectURL;
|
||||||
|
btn.click();
|
||||||
|
URL.revokeObjectURL(objectURL);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function token(params?: { [key: string]: string | number }) {
|
||||||
|
const { current, pageSize, ...rest } = params ?? {};
|
||||||
|
const result = await request<SYSTEM.Page<SYSTEM.Token>>('/api-uaa/tokens', {
|
||||||
|
method: 'GET',
|
||||||
|
params: { page: current, limit: pageSize, ...rest },
|
||||||
|
});
|
||||||
|
return { data: result.data, total: result.count };
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function app(params?: { [key: string]: string | number }) {
|
||||||
|
const { current, pageSize, ...rest } = params ?? {};
|
||||||
|
const result = await request<SYSTEM.Page<SYSTEM.App>>('/api-uaa/clients/list', {
|
||||||
|
method: 'GET',
|
||||||
|
params: { page: current, limit: pageSize, ...rest },
|
||||||
|
});
|
||||||
|
return { data: result.data, total: result.count };
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function generator(params?: { [key: string]: string | number }) {
|
||||||
|
const { current, pageSize, ...rest } = params ?? {};
|
||||||
|
const result = await request<SYSTEM.Page<SYSTEM.Generator>>('/api-generator/generator/list', {
|
||||||
|
method: 'GET',
|
||||||
|
params: { page: current, limit: pageSize, ...rest },
|
||||||
|
});
|
||||||
|
return { data: result.data, total: result.count };
|
||||||
|
}
|
||||||
|
|
||||||
|
export function exportGenerator(tables: string) {
|
||||||
|
return request('/api-generator/generator/code', {
|
||||||
|
method: 'GET',
|
||||||
|
params: { tables },
|
||||||
|
responseType: 'blob',
|
||||||
|
getResponse: true,
|
||||||
|
}).then((res) => {
|
||||||
|
download(res);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function menu(params: { [key: string]: string | number }) {
|
||||||
|
const result = await request<SYSTEM.Page<SYSTEM.Menu>>('/api-user/menus/findAlls', {
|
||||||
|
method: 'GET',
|
||||||
|
params,
|
||||||
|
});
|
||||||
|
return result.data;
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
// @ts-ignore
|
||||||
|
/* eslint-disable */
|
||||||
|
// API 更新时间:
|
||||||
|
// API 唯一标识:
|
||||||
|
import * as api from './api';
|
||||||
|
export default {
|
||||||
|
api,
|
||||||
|
};
|
||||||