diff --git a/.DS_Store b/.DS_Store deleted file mode 100644 index f611cef9..00000000 Binary files a/.DS_Store and /dev/null differ diff --git a/.gitignore b/.gitignore index 0a0f4f76..0b2f4240 100644 --- a/.gitignore +++ b/.gitignore @@ -50,4 +50,7 @@ docs/.docusaurus ### Docker ### docker/conf -docker/target \ No newline at end of file +docker/target + +### OS ### +.DS_Store \ No newline at end of file diff --git a/docs/i18n/zh/code.json b/docs/i18n/zh/code.json index 8dec86f4..5e96ee21 100644 --- a/docs/i18n/zh/code.json +++ b/docs/i18n/zh/code.json @@ -271,7 +271,7 @@ }, "homepage.secondTitle": { "message": "Hippo4j能做什么?", - "description": "a title for introduciton part" + "description": "The title for the introduction part" }, "homepage.introduction.fristPartTitle": { "message": "动态变更", @@ -312,5 +312,49 @@ "companyPage.linkText": { "message": "点击进行登记", "description": "the text for the company page link" + }, + "homepage.introduction.fristPartDesc1": { + "message": "应用程序运行时动态更改线程池参数。", + "description": "The first desc for fristPart " + }, + "homepage.introduction.fristPartDesc2": { + "message": "包括但不限于核心大小、最大线程数、阻塞队列大小和拒绝策略。", + "description": "The second desc for fristPart " + }, + "homepage.introduction.fristPartDesc3": { + "message": "支持应用集群中不同节点的差异化线程池配置。", + "description": "The third desc for fristPart " + }, + "homepage.introduction.secondPartDesc1": { + "message": "应用程序线程池运行时点,提供四个告警维度。", + "description": "The first desc for secondPart " + }, + "homepage.introduction.secondPartDesc2": { + "message": "线程池超载,阻塞队列容量,运行时间过长以及拒绝策略警报。", + "description": "The second desc for secondPart " + }, + "homepage.introduction.secondPartDesc3": { + "message": "它还支持在自定义时间段内的非重复闹钟。", + "description": "The third desc for secondPart " + }, + "homepage.introduction.thirdPartDesc1": { + "message": "支持为数据收集和存储设置自定义持续时间的线程池。", + "description": "The first desc for thirdPart " + }, + "homepage.introduction.thirdPartDesc2": { + "message": "同时还支持Prometheus、InfluxDB和其他监控系统。", + "description": "The second desc for thirdPart " + }, + "homepage.introduction.thirdPartDesc3": { + "message": "通过Grafana或内置的监控页面提供可视化仪表盘监控指标。", + "description": "The third desc for thirdPart " + }, + "homepage.secondTitleDesc1": { + "message": "Hippo4j是一个Java线程池框架。", + "description": "The p1 for the secondTitle part" + }, + "homepage.secondTitleDesc2": { + "message": "提供了线程池动态调整、自定义警报和操作监控等功能,以帮助提高业务系统的运营支持能力。", + "description": "The p2 for the secondTitle part" } } diff --git a/docs/src/components/LandingPage/Hero.jsx b/docs/src/components/LandingPage/Hero.jsx index 9b0ffa50..3be732c6 100644 --- a/docs/src/components/LandingPage/Hero.jsx +++ b/docs/src/components/LandingPage/Hero.jsx @@ -6,19 +6,24 @@ import Translate, { translate } from "@docusaurus/Translate"; import Link from "@docusaurus/Link"; const Hero = () => { + const bgUrl = useBaseUrl("/img/bg.jpg"); + return ( -
-
-
+
+
+
{/* */} -
+
{/* title and desc */}
-

+

Hippo4j

-

+

{ Thread Pool Framework For Java

-

+

{

{/* */} -
+
Hippo4j System
diff --git a/docs/src/components/LandingPage/Introduction.jsx b/docs/src/components/LandingPage/Introduction.jsx index e67ba148..41a78df5 100644 --- a/docs/src/components/LandingPage/Introduction.jsx +++ b/docs/src/components/LandingPage/Introduction.jsx @@ -3,101 +3,205 @@ import useBaseUrl from "@docusaurus/useBaseUrl"; import Translate from "@docusaurus/Translate"; const Introduction = () => { return ( -
-
-

- {/* Hippo4j能做什么 */} - - What can Hippo4j do? - -

-
-
-
- -
-
-

- {/* 动态变更 */} - - Dynamic Change - -

-

- {/* 应用运行时动态变更线程池参数,包括不限于核心、最大线程、阻塞队列大小和拒绝策略等,支持应用集群下不同节点线程池配置差异化 */} - - Application runtime dynamically changes thread pool parameters, - including but not limited to core size, maximum threads, - blocking queue size, and rejection policy. It supports - differentiated thread pool configurations for different nodes in - the application cluster. - -
-
-

+
+
+
+
+ Hippo4j System
-
-

- {/* 自定义报警 */} +
+

- Custom Alarm + What can Hippo4j do? -

-

- {/* 应用线程池运行时埋点,提供四种报警维度,线程池过载、阻塞队列容量、运行超长以及拒绝策略报警,并支持自定义时间内不重复报警 */} +

+

- Application thread pool runtime point, providing four alarm - dimensions: thread pool overload, blocking queue capacity, - running for too long, and rejection strategy alarm. It also - supports non-repetitive alarms within a custom time period. + Hippo4j is a Java thread pool framework. -
-

-
-
-

- {/* 运行监控 */} +

- Operation Monitoring + Provided functions such as dynamic adjustment of thread pool, + custom alerts, and operation monitoring to help improve the + operational support capabilities of business systems. -

-

- {/* 支持自定义时长线程池运行数据采集存储,同时也支持 - Prometheus、InfluxDB 等采集监控,通过 Grafana - 或内置监控页面提供可视化大屏监控运行指标 */} - - Supports custom duration thread pool for data collection and - storage, while also supporting Prometheus, InfluxDB, and other - monitoring systems. Provides visualized dashboard monitoring - metrics through Grafana or built-in monitoring pages. - -
-

+ +
+
+
+

+ + Dynamic Change + +

+
+

+ + Application runtime dynamically changes thread pool + parameters. + {" "} +

+

+ + Including but not limited to core size, maximum threads, + blocking queue size, and rejection policy. + +

+

+ + It supports differentiated thread pool configurations for + different nodes in the application cluster. + +

+
+
+
+ {/* */} + Hippo4j System +
+
+
+
+ Hippo4j System +
+
+
+

+ + Custom Alarm + +

+
+

+ + Application thread pool runtime point, providing four + alarm dimensions. + +

+

+ + Thread pool overload, blocking queue capacity, running for + too long, and rejection strategy alarm. + {" "} +

+

+ + It also supports non-repetitive alarms within a custom + time period. + +

+
+
+
+
+
+
+

+ + Operation Monitoring + +

+
+

+ + Supports custom duration thread pool for data collection and + storage. + +

+

+ + while also supporting Prometheus, InfluxDB, and other + monitoring systems. + +

+

+ + Provides visualized dashboard monitoring metrics through + Grafana or built-in monitoring pages. + +

+
+
+
+ {/* */} + Hippo4j System +
+
+
); diff --git a/docs/src/css/custom.css b/docs/src/css/custom.css index db4d0be4..8701dc1b 100644 --- a/docs/src/css/custom.css +++ b/docs/src/css/custom.css @@ -219,3 +219,31 @@ div[class^="announcementBar_"] { height: 100%; } } + +/* Custom by youbo */ +.bg-cousom { + background-position: 50% 65%; +} + +.bg-svg { + background-color: #ffffff; + background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='192' height='192' viewBox='0 0 192 192'%3E%3Cpath fill='%23c2b9cf' fill-opacity='0.31' d='M192 15v2a11 11 0 0 0-11 11c0 1.94 1.16 4.75 2.53 6.11l2.36 2.36a6.93 6.93 0 0 1 1.22 7.56l-.43.84a8.08 8.08 0 0 1-6.66 4.13H145v35.02a6.1 6.1 0 0 0 3.03 4.87l.84.43c1.58.79 4 .4 5.24-.85l2.36-2.36a12.04 12.04 0 0 1 7.51-3.11 13 13 0 1 1 .02 26 12 12 0 0 1-7.53-3.11l-2.36-2.36a4.93 4.93 0 0 0-5.24-.85l-.84.43a6.1 6.1 0 0 0-3.03 4.87V143h35.02a8.08 8.08 0 0 1 6.66 4.13l.43.84a6.91 6.91 0 0 1-1.22 7.56l-2.36 2.36A10.06 10.06 0 0 0 181 164a11 11 0 0 0 11 11v2a13 13 0 0 1-13-13 12 12 0 0 1 3.11-7.53l2.36-2.36a4.93 4.93 0 0 0 .85-5.24l-.43-.84a6.1 6.1 0 0 0-4.87-3.03H145v35.02a8.08 8.08 0 0 1-4.13 6.66l-.84.43a6.91 6.91 0 0 1-7.56-1.22l-2.36-2.36A10.06 10.06 0 0 0 124 181a11 11 0 0 0-11 11h-2a13 13 0 0 1 13-13c2.47 0 5.79 1.37 7.53 3.11l2.36 2.36a4.94 4.94 0 0 0 5.24.85l.84-.43a6.1 6.1 0 0 0 3.03-4.87V145h-35.02a8.08 8.08 0 0 1-6.66-4.13l-.43-.84a6.91 6.91 0 0 1 1.22-7.56l2.36-2.36A10.06 10.06 0 0 0 107 124a11 11 0 0 0-22 0c0 1.94 1.16 4.75 2.53 6.11l2.36 2.36a6.93 6.93 0 0 1 1.22 7.56l-.43.84a8.08 8.08 0 0 1-6.66 4.13H49v35.02a6.1 6.1 0 0 0 3.03 4.87l.84.43c1.58.79 4 .4 5.24-.85l2.36-2.36a12.04 12.04 0 0 1 7.51-3.11A13 13 0 0 1 81 192h-2a11 11 0 0 0-11-11c-1.94 0-4.75 1.16-6.11 2.53l-2.36 2.36a6.93 6.93 0 0 1-7.56 1.22l-.84-.43a8.08 8.08 0 0 1-4.13-6.66V145H11.98a6.1 6.1 0 0 0-4.87 3.03l-.43.84c-.79 1.58-.4 4 .85 5.24l2.36 2.36a12.04 12.04 0 0 1 3.11 7.51A13 13 0 0 1 0 177v-2a11 11 0 0 0 11-11c0-1.94-1.16-4.75-2.53-6.11l-2.36-2.36a6.93 6.93 0 0 1-1.22-7.56l.43-.84a8.08 8.08 0 0 1 6.66-4.13H47v-35.02a6.1 6.1 0 0 0-3.03-4.87l-.84-.43c-1.59-.8-4-.4-5.24.85l-2.36 2.36A12 12 0 0 1 28 109a13 13 0 1 1 0-26c2.47 0 5.79 1.37 7.53 3.11l2.36 2.36a4.94 4.94 0 0 0 5.24.85l.84-.43A6.1 6.1 0 0 0 47 84.02V49H11.98a8.08 8.08 0 0 1-6.66-4.13l-.43-.84a6.91 6.91 0 0 1 1.22-7.56l2.36-2.36A10.06 10.06 0 0 0 11 28 11 11 0 0 0 0 17v-2a13 13 0 0 1 13 13c0 2.47-1.37 5.79-3.11 7.53l-2.36 2.36a4.94 4.94 0 0 0-.85 5.24l.43.84A6.1 6.1 0 0 0 11.98 47H47V11.98a8.08 8.08 0 0 1 4.13-6.66l.84-.43a6.91 6.91 0 0 1 7.56 1.22l2.36 2.36A10.06 10.06 0 0 0 68 11 11 11 0 0 0 79 0h2a13 13 0 0 1-13 13 12 12 0 0 1-7.53-3.11l-2.36-2.36a4.93 4.93 0 0 0-5.24-.85l-.84.43A6.1 6.1 0 0 0 49 11.98V47h35.02a8.08 8.08 0 0 1 6.66 4.13l.43.84a6.91 6.91 0 0 1-1.22 7.56l-2.36 2.36A10.06 10.06 0 0 0 85 68a11 11 0 0 0 22 0c0-1.94-1.16-4.75-2.53-6.11l-2.36-2.36a6.93 6.93 0 0 1-1.22-7.56l.43-.84a8.08 8.08 0 0 1 6.66-4.13H143V11.98a6.1 6.1 0 0 0-3.03-4.87l-.84-.43c-1.59-.8-4-.4-5.24.85l-2.36 2.36A12 12 0 0 1 124 13a13 13 0 0 1-13-13h2a11 11 0 0 0 11 11c1.94 0 4.75-1.16 6.11-2.53l2.36-2.36a6.93 6.93 0 0 1 7.56-1.22l.84.43a8.08 8.08 0 0 1 4.13 6.66V47h35.02a6.1 6.1 0 0 0 4.87-3.03l.43-.84c.8-1.59.4-4-.85-5.24l-2.36-2.36A12 12 0 0 1 179 28a13 13 0 0 1 13-13zM84.02 143a6.1 6.1 0 0 0 4.87-3.03l.43-.84c.8-1.59.4-4-.85-5.24l-2.36-2.36A12 12 0 0 1 83 124a13 13 0 1 1 26 0c0 2.47-1.37 5.79-3.11 7.53l-2.36 2.36a4.94 4.94 0 0 0-.85 5.24l.43.84a6.1 6.1 0 0 0 4.87 3.03H143v-35.02a8.08 8.08 0 0 1 4.13-6.66l.84-.43a6.91 6.91 0 0 1 7.56 1.22l2.36 2.36A10.06 10.06 0 0 0 164 107a11 11 0 0 0 0-22c-1.94 0-4.75 1.16-6.11 2.53l-2.36 2.36a6.93 6.93 0 0 1-7.56 1.22l-.84-.43a8.08 8.08 0 0 1-4.13-6.66V49h-35.02a6.1 6.1 0 0 0-4.87 3.03l-.43.84c-.79 1.58-.4 4 .85 5.24l2.36 2.36a12.04 12.04 0 0 1 3.11 7.51A13 13 0 1 1 83 68a12 12 0 0 1 3.11-7.53l2.36-2.36a4.93 4.93 0 0 0 .85-5.24l-.43-.84A6.1 6.1 0 0 0 84.02 49H49v35.02a8.08 8.08 0 0 1-4.13 6.66l-.84.43a6.91 6.91 0 0 1-7.56-1.22l-2.36-2.36A10.06 10.06 0 0 0 28 85a11 11 0 0 0 0 22c1.94 0 4.75-1.16 6.11-2.53l2.36-2.36a6.93 6.93 0 0 1 7.56-1.22l.84.43a8.08 8.08 0 0 1 4.13 6.66V143h35.02z'%3E%3C/path%3E%3C/svg%3E"); +} + +:root[data-theme="light"] { + --hero-image-url: url("../../static/img/hero/hero-removebg.png"); + --hero-bg-url: url("../../static/img/hero/bg.jpg"); +} + +:root[data-theme="dark"] { + --hero-image-url: url("../../static/img/hero/hero.jpg"); + /* --hero-bg-url:url("../../static/img/bg.jpg"); */ +} + +.hero-img { + content: var(--hero-image-url); +} + +.hero-bg-img { + background-image: var(--hero-bg-url); +} diff --git a/docs/static/img/hero/bg.jpg b/docs/static/img/hero/bg.jpg new file mode 100644 index 00000000..d091d3ff Binary files /dev/null and b/docs/static/img/hero/bg.jpg differ diff --git a/docs/static/img/hero/bg2.jpg b/docs/static/img/hero/bg2.jpg new file mode 100644 index 00000000..00fff65e Binary files /dev/null and b/docs/static/img/hero/bg2.jpg differ diff --git a/docs/static/img/hero/hero-removebg.png b/docs/static/img/hero/hero-removebg.png new file mode 100644 index 00000000..d402847d Binary files /dev/null and b/docs/static/img/hero/hero-removebg.png differ diff --git a/docs/static/img/hero/hero.jpg b/docs/static/img/hero/hero.jpg new file mode 100644 index 00000000..84fabc9b Binary files /dev/null and b/docs/static/img/hero/hero.jpg differ diff --git a/docs/static/img/introduction/p1.svg b/docs/static/img/introduction/p1.svg new file mode 100644 index 00000000..b8036b71 --- /dev/null +++ b/docs/static/img/introduction/p1.svg @@ -0,0 +1 @@ + diff --git a/docs/static/img/introduction/p2.svg b/docs/static/img/introduction/p2.svg new file mode 100644 index 00000000..f28d4722 --- /dev/null +++ b/docs/static/img/introduction/p2.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/docs/static/img/introduction/p3.svg b/docs/static/img/introduction/p3.svg new file mode 100644 index 00000000..b5c179e2 --- /dev/null +++ b/docs/static/img/introduction/p3.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/docs/static/img/introduction/title-image.svg b/docs/static/img/introduction/title-image.svg new file mode 100644 index 00000000..d7078a32 --- /dev/null +++ b/docs/static/img/introduction/title-image.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/threadpool/.DS_Store b/threadpool/.DS_Store deleted file mode 100644 index f70d1c0d..00000000 Binary files a/threadpool/.DS_Store and /dev/null differ diff --git a/threadpool/console-new/.eslintrc.js b/threadpool/console-new/.eslintrc.js index 99e7f2d6..38eb2edf 100644 --- a/threadpool/console-new/.eslintrc.js +++ b/threadpool/console-new/.eslintrc.js @@ -1,5 +1,3 @@ -const { off } = require("process"); - module.exports = { env: { browser: true, diff --git a/threadpool/console-new/craco.config.js b/threadpool/console-new/craco.config.js index c2beac22..88250a4c 100644 --- a/threadpool/console-new/craco.config.js +++ b/threadpool/console-new/craco.config.js @@ -20,7 +20,7 @@ module.exports = { // A callback function that receives two arguments: the webpack rule, // and the context. You must return an updated rule object. - modifyLessRule: (lessRule, context) => { + modifyLessRule: lessRule => { lessRule.test = lessModuleRegex; lessRule.exclude = /node_modules|antd\.css/; return lessRule; @@ -36,6 +36,7 @@ module.exports = { webpack: { alias: { '@': resolve('src'), + '@i18': resolve('public/locales'), }, }, devServer: { diff --git a/threadpool/console-new/package.json b/threadpool/console-new/package.json index 03c31fb3..dc6357f2 100644 --- a/threadpool/console-new/package.json +++ b/threadpool/console-new/package.json @@ -8,8 +8,11 @@ "@testing-library/user-event": "^13.5.0", "ahooks": "^3.7.8", "antd": "^5.4.7", + "i18next": "^23.5.1", + "qs": "^6.11.2", "react": "^18.2.0", "react-dom": "^18.2.0", + "react-i18next": "^13.2.2", "react-router-dom": "^6.11.1", "react-scripts": "5.0.1", "web-vitals": "^2.1.4" diff --git a/threadpool/console-new/public/locales/en.json b/threadpool/console-new/public/locales/en.json new file mode 100644 index 00000000..e69de29b diff --git a/threadpool/console-new/public/locales/zh.json b/threadpool/console-new/public/locales/zh.json new file mode 100644 index 00000000..e69de29b diff --git a/threadpool/console-new/src/App.tsx b/threadpool/console-new/src/App.tsx index 835cc1b5..709464e4 100644 --- a/threadpool/console-new/src/App.tsx +++ b/threadpool/console-new/src/App.tsx @@ -1,6 +1,7 @@ import LayoutCom from './components/layout-com'; import { Routes, Route } from 'react-router-dom'; import routeList from './route'; +import Login from '@/page/login'; import { AppstoreOutlined, MailOutlined } from '@ant-design/icons'; const sideMenuList = [ @@ -20,6 +21,7 @@ const App = () => { return ( + {routeList.map(item => ( ))} diff --git a/threadpool/console-new/src/components/layout-com/index.module.less b/threadpool/console-new/src/components/layout-com/index.module.less index 4fed70ff..6731ddf2 100644 --- a/threadpool/console-new/src/components/layout-com/index.module.less +++ b/threadpool/console-new/src/components/layout-com/index.module.less @@ -14,5 +14,6 @@ border-radius: 12px 12px 0 0; min-height: 100%; flex: 1; + padding: 10px 12px; } } diff --git a/threadpool/console-new/src/components/layout-com/index.tsx b/threadpool/console-new/src/components/layout-com/index.tsx index 18ed958e..b4450c47 100644 --- a/threadpool/console-new/src/components/layout-com/index.tsx +++ b/threadpool/console-new/src/components/layout-com/index.tsx @@ -22,7 +22,7 @@ const LayoutCom = (props: ILayoutCom) => { const [setIsDark] = useThemeMode(); return (
-
+
diff --git a/threadpool/console-new/src/context/index.tsx b/threadpool/console-new/src/context/index.tsx new file mode 100644 index 00000000..4a06a7fa --- /dev/null +++ b/threadpool/console-new/src/context/index.tsx @@ -0,0 +1,18 @@ +import React, { createContext, useState, ReactNode } from 'react'; + +export enum THEME_NAME { + DEFAULT = 'default', + DARK = 'dark', +} + +export const StoreContext = createContext<{ + themeName: string; + setThemeName: (name: THEME_NAME) => void; +} | null>(null); + +export const Store: React.FC<{ + children: ReactNode; +}> = ({ children }) => { + const [themeName, setThemeName] = useState(THEME_NAME.DEFAULT); + return {children}; +}; diff --git a/threadpool/console-new/src/page/home/components/detail/index.tsx b/threadpool/console-new/src/page/home/components/detail/index.tsx new file mode 100644 index 00000000..2d4cd32b --- /dev/null +++ b/threadpool/console-new/src/page/home/components/detail/index.tsx @@ -0,0 +1,6 @@ +import React from 'react'; + +const HomeDetail = () => { + return <>; +}; +export default HomeDetail; diff --git a/threadpool/console-new/src/page/home/constans.ts b/threadpool/console-new/src/page/home/constans.ts new file mode 100644 index 00000000..9f36b36d --- /dev/null +++ b/threadpool/console-new/src/page/home/constans.ts @@ -0,0 +1 @@ +export const Map = {}; diff --git a/threadpool/console-new/src/page/home/index.tsx b/threadpool/console-new/src/page/home/index.tsx index d1d425d7..527ec194 100644 --- a/threadpool/console-new/src/page/home/index.tsx +++ b/threadpool/console-new/src/page/home/index.tsx @@ -1,9 +1,17 @@ -import { Button, Card } from 'antd'; +import { Button } from 'antd'; +import request from '@/utils'; + const Home = () => { + const fetchdata = (body: { duid: string }) => { + return request<{ phone: string }>('https://mock.xiaojukeji.com/mock/16635/am/marketing/mis/member/archive/phone', { + method: 'post', + body, + }); + }; + return (
- - +
); }; diff --git a/threadpool/console-new/src/page/home/service.ts b/threadpool/console-new/src/page/home/service.ts new file mode 100644 index 00000000..a8d772dd --- /dev/null +++ b/threadpool/console-new/src/page/home/service.ts @@ -0,0 +1,9 @@ +const fetchData = async () => { + await new Promise(resolve => { + resolve(100); + }); +}; + +const service = { fetchData }; + +export default service; diff --git a/threadpool/console-new/src/page/home/type.ts b/threadpool/console-new/src/page/home/type.ts new file mode 100644 index 00000000..c4dbf016 --- /dev/null +++ b/threadpool/console-new/src/page/home/type.ts @@ -0,0 +1,3 @@ +export enum CON { + NAME = '1', +} diff --git a/threadpool/console-new/src/page/login/index.tsx b/threadpool/console-new/src/page/login/index.tsx index f4652837..99427fb0 100644 --- a/threadpool/console-new/src/page/login/index.tsx +++ b/threadpool/console-new/src/page/login/index.tsx @@ -1,74 +1,6 @@ -import { Form, Input, Button } from 'antd'; +import React from 'react'; const Login = () => { - const [form] = Form.useForm(); - const data = { - passwordType: 'password', - capsTooltip: false, - loading: false, - showDialog: false, - redirect: undefined, - otherQuery: {}, - loginForm: { - username: '', - password: '', - }, - loginRules: { - // username: [{ required: true, trigger: 'blur', validator: validateUsername }], - // password: [{ required: true, trigger: 'blur', validator: this.validatePassword }], - }, - }; - - const validatePassword = (rule: any, value: string | any[], callback: (arg0: Error | undefined) => void) => { - if (value.length < 6) { - callback(new Error('The password can not be less than 6 digits')); - } else if (value.length > 72) { - callback(new Error('The password can not be greater than 72 digits')); - } else { - // callback(); - } - }; - - const onFinish = () => { - let loginParams = { - username: form.getFieldValue('username'), - password: form.getFieldValue('password'), - rememberMe: 1, - }; - data.loginForm.username = form.getFieldValue('username'); - console.log('hhhhhh', loginParams); - }; - const showPwd = () => { - if (data.passwordType === 'password') { - data.passwordType = ''; - } else { - data.passwordType = 'password'; - } - // $nextTick(() => { - // $refs.password.focus(); - // }); - }; - return ( -
-
-
-

你好呀

- {/*

{{ $t('system.login') }}

*/} -
- - - - - - - - - -
-
- ); + return <>; }; - export default Login; diff --git a/threadpool/console-new/src/theme/dark-algorithm.ts b/threadpool/console-new/src/theme/dark-algorithm.ts index 8603aeb0..8ed1fa92 100644 --- a/threadpool/console-new/src/theme/dark-algorithm.ts +++ b/threadpool/console-new/src/theme/dark-algorithm.ts @@ -7,6 +7,10 @@ export const darkAlgorithm = { fontSize: 14, }, components: { + Layout: { + bodyBg: darkDefaultTheme.backgroundColor.bg1, + headerBg: darkDefaultTheme.backgroundColor.bgHeader, + }, Button: { fontSize: 14, }, diff --git a/threadpool/console-new/src/theme/default-algnorithm.ts b/threadpool/console-new/src/theme/default-algnorithm.ts index eda9622b..20f7cc6a 100644 --- a/threadpool/console-new/src/theme/default-algnorithm.ts +++ b/threadpool/console-new/src/theme/default-algnorithm.ts @@ -8,6 +8,10 @@ export const defaultAlgorithm = { // colorBgBase: lightDefaultTheme.backgroundColor.bg1, }, components: { + Layout: { + bodyBg: lightDefaultTheme.backgroundColor.bg1, + headerBg: lightDefaultTheme.backgroundColor.bgHeader, + }, Button: { fontSize: 14, }, diff --git a/threadpool/console-new/src/theme/default-theme.d.ts b/threadpool/console-new/src/theme/default-theme.d.ts index 6afe0865..5c137cf6 100644 --- a/threadpool/console-new/src/theme/default-theme.d.ts +++ b/threadpool/console-new/src/theme/default-theme.d.ts @@ -29,6 +29,8 @@ declare module 'styled-components' { }; // 背景色 backgroundColor: { + bgHeader: string; + bgContent: string; bg1: string; bg2: string; bg3: string; diff --git a/threadpool/console-new/src/theme/index.ts b/threadpool/console-new/src/theme/index.ts index 1ebe38f3..c1c656b4 100644 --- a/threadpool/console-new/src/theme/index.ts +++ b/threadpool/console-new/src/theme/index.ts @@ -24,6 +24,8 @@ export const lightDefaultTheme: DefaultTheme = { bl3: '#B5BDCE', }, backgroundColor: { + bgHeader: '#fff', + bgContent: '#fff', // main bgc bg1: '#ebebf2', // app or head bgc @@ -65,6 +67,8 @@ export const darkDefaultTheme: DefaultTheme = { bl3: '#424242', }, backgroundColor: { + bgHeader: '#141414', + bgContent: '#141414', // 大面积色 bg1: '#141414', // tab顶部颜色 diff --git a/threadpool/console-new/src/utils/common/index.ts b/threadpool/console-new/src/utils/common/index.ts new file mode 100644 index 00000000..8085a28c --- /dev/null +++ b/threadpool/console-new/src/utils/common/index.ts @@ -0,0 +1,11 @@ +// is plain object +const isPlainObject = (obj: { [key: string]: any }): boolean => { + let proto, Ctor; + if (!obj || typeof obj !== 'object') return false; + proto = Object.getPrototypeOf(obj); + if (!proto) return true; + Ctor = Object.prototype.hasOwnProperty.call(proto, 'constructor') && proto.constructor; + return typeof Ctor === 'function' && Ctor === Object; // insure is new by Object or {} +}; + +export { isPlainObject }; diff --git a/threadpool/console-new/src/utils/index.ts b/threadpool/console-new/src/utils/index.ts new file mode 100644 index 00000000..15fcf852 --- /dev/null +++ b/threadpool/console-new/src/utils/index.ts @@ -0,0 +1,3 @@ +import request from './request'; +export * from './common'; +export default request; diff --git a/threadpool/console-new/src/utils/request/index.ts b/threadpool/console-new/src/utils/request/index.ts new file mode 100644 index 00000000..89516eb9 --- /dev/null +++ b/threadpool/console-new/src/utils/request/index.ts @@ -0,0 +1,159 @@ +import { isPlainObject } from '../common'; +import { notification, message } from 'antd'; +import Qs from 'qs'; + +type HttpMethods = 'POST' | 'post' | 'GET' | 'get' | 'DELETE' | 'delete' | 'PUT' | 'put'; + +interface HeaderConfig extends Record { + Accept?: string; + 'Content-Type'?: string; +} + +interface RequestOptions { + headers?: HeaderConfig; + method?: HttpMethods; + params?: { [key: string]: string } | null; + body?: { [key: string]: string } | null; + timeout?: number; + credentials?: boolean; + moda?: 'cors' | 'same-origin'; + cache?: 'no-cache' | 'default' | 'force-cache'; + customize?: boolean; + responseType?: 'TEXT' | 'JSON' | 'BLOB' | 'ARRAYBUFFER'; +} + +type Response = { + success: boolean; + data?: T; + module?: T; + msg?: string; + status?: number; + message?: string; + code?: string | number; +}; + +let baseURL = 'http://127.0.0.1:9999'; + +const inital: RequestOptions = { + method: 'GET', + params: null, + body: null, + headers: { + 'Content-Type': 'application/json', + }, + credentials: true, + responseType: 'JSON', + cache: 'no-cache', +}; +const env = process.env.NODE_ENV || 'development'; + +enum IENV_ENUM { + DEVELOPMENT = 'development', + TEST = 'test', + PRODUCTION = 'production', +} + +switch (env) { + case IENV_ENUM.DEVELOPMENT: + baseURL = ''; + break; + case IENV_ENUM.TEST: + baseURL = ''; + break; + case IENV_ENUM.PRODUCTION: + baseURL = ''; + break; +} + +const codeMessage: { [key: string]: string } = { + '200': '请求已成功被服务器处理,并返回了请求的内容。', + '201': '请求已成功,并且服务器创建了一个新的资源作为响应。', + '202': '一个请求已进入后台排队', + '204': '请求已成功处理,但响应中没有返回任何内容。', + '400': '客户端发送的请求有错误,服务器无法处理。', + '401': '客户端需要提供有效的身份验证信息,以便访问受保护的资源。', + '403': '服务器理解了请求,但拒绝执行该请求。', + '404': '服务器未找到请求的资源。', + '500': '服务器在处理请求时发生了未知的错误。', +}; + +function request(url: string, config: RequestOptions): Promise> { + if (config === null || typeof config !== 'object') { + config = {}; + } + if (config.headers && isPlainObject(config.headers)) { + config.headers = Object.assign({}, inital.headers, config.headers); + } + let { method, params, body, headers, credentials, responseType } = Object.assign({}, inital, config) as any; + if (typeof url !== 'string') throw new TypeError('url is not an string'); + if (!/^http(s?):\/\//i.test(url)) url = baseURL + url; + if (params !== null) { + if (isPlainObject(params)) { + params = Qs.stringify(params); + } + url += `${url.includes('?') ? '&' : '?'}${params}`; + } + if (body !== null) { + if (isPlainObject(body)) { + let contentType = headers['Content-Type'] || 'application/json'; + if (contentType.includes('urlencoded')) body = Qs.stringify(body); + if (contentType.includes('json')) body = JSON.stringify(body); + } + } + credentials = credentials ? 'include' : 'same-origin'; + method = method.toUpperCase(); + responseType = responseType.toUpperCase(); + config = { + method, + credentials, + responseType, + }; + if (/^(POST|PUT|PATCH)$/i.test(method)) { + config.body = body; + } else { + config.body = null; + } + return fetch(url, config as any).then(function onfulfilled(response) { + let { status, statusText } = response; + if (status >= 200 && status < 400) { + let result; + switch (responseType) { + case 'TEXT': + result = response.text(); + break; + case 'JSON': + result = response.json(); + break; + case 'BLOB': + result = response.blob(); + break; + case 'ARRAYBUFFER': + result = response.arrayBuffer(); + break; + } + // business code + result?.then(res => { + if (res?.code === 200) { + // console.log(':::'); + } + }); + return result; + } + let tip = codeMessage[String(status)]; + notification.error({ + message: tip, + }); + return Promise.reject({ + code: 'STATUS ERROR', + status, + statusText, + }).catch(function onrejected(reason) { + if (!navigator.onLine) { + message.error('好像断网了'); + } + return Promise.reject(reason); + }); + }); +} + +export default request; diff --git a/threadpool/console-new/yarn.lock b/threadpool/console-new/yarn.lock index a4c3863b..4924e267 100644 --- a/threadpool/console-new/yarn.lock +++ b/threadpool/console-new/yarn.lock @@ -1733,7 +1733,7 @@ "@jridgewell/trace-mapping@0.3.9": version "0.3.9" - resolved "https://registry.npmmirror.com/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz#6534fd5933a53ba7cbf3a17615e273a0d1273ff9" + resolved "https://registry.npmmirror.com/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz" integrity sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ== dependencies: "@jridgewell/resolve-uri" "^3.0.3" @@ -2840,7 +2840,7 @@ ajv@^6.12.2, ajv@^6.12.4, ajv@^6.12.5: ajv@^8.0.0, ajv@^8.6.0, ajv@^8.9.0: version "8.12.0" - resolved "https://registry.npmmirror.com/ajv/-/ajv-8.12.0.tgz#d1a0527323e22f53562c567c00991577dfbe19d1" + resolved "https://registry.npmmirror.com/ajv/-/ajv-8.12.0.tgz" integrity sha512-sRu1kpcO9yLtYxBKvqfTeh9KzZEwO3STyX1HT+4CaDzC6HpTGYhIhPIzj9XuKU7KYDwnaeh5hcOwjy1QuJzBPA== dependencies: fast-deep-equal "^3.1.1" @@ -2993,7 +2993,7 @@ argparse@^2.0.1: aria-query@5.1.3: version "5.1.3" - resolved "https://registry.npmmirror.com/aria-query/-/aria-query-5.1.3.tgz#19db27cd101152773631396f7a95a3b58c22c35e" + resolved "https://registry.npmmirror.com/aria-query/-/aria-query-5.1.3.tgz" integrity sha512-R5iJ5lkuHybztUfuOAznmboyjWq8O6sqNqtK7CLOqdydi54VNbORp49mb14KbWgG1QD3JFO9hJdZ+y4KutfdOQ== dependencies: deep-equal "^2.0.5" @@ -3527,7 +3527,7 @@ case-sensitive-paths-webpack-plugin@^2.4.0: chalk@5.3.0: version "5.3.0" - resolved "https://registry.npmmirror.com/chalk/-/chalk-5.3.0.tgz#67c20a7ebef70e7f3970a01f90fa210cb6860385" + resolved "https://registry.npmmirror.com/chalk/-/chalk-5.3.0.tgz" integrity sha512-dLitG79d+GV1Nb/VYcCDFivJeK1hiukt9QjRNVOsUtTy1rR1YJsmpGGTZ3qJos+uw7WmWF4wUwBd9jxjocFC2w== chalk@^2.4.1, chalk@^2.4.2: @@ -4016,7 +4016,7 @@ css-to-react-native@^3.2.0: css-tree@1.0.0-alpha.37: version "1.0.0-alpha.37" - resolved "https://registry.npmmirror.com/css-tree/-/css-tree-1.0.0-alpha.37.tgz#98bebd62c4c1d9f960ec340cf9f7522e30709a22" + resolved "https://registry.npmmirror.com/css-tree/-/css-tree-1.0.0-alpha.37.tgz" integrity sha512-DMxWJg0rnz7UgxKT0Q1HU/L9BeJI0M6ksor0OgqOnF+aRCDWg/N2641HmVyU9KVIu0OVVWOb2IpC9A+BJRnejg== dependencies: mdn-data "2.0.4" @@ -4161,14 +4161,14 @@ debug@2.6.9, debug@^2.6.0: debug@4, debug@4.3.4, debug@^4.1.0, debug@^4.1.1, debug@^4.3.2, debug@^4.3.4: version "4.3.4" - resolved "https://registry.npmmirror.com/debug/-/debug-4.3.4.tgz#1319f6579357f2338d3337d2cdd4914bb5dcc865" + resolved "https://registry.npmmirror.com/debug/-/debug-4.3.4.tgz" integrity sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ== dependencies: ms "2.1.2" debug@^3.2.6, debug@^3.2.7: version "3.2.7" - resolved "https://registry.npmmirror.com/debug/-/debug-3.2.7.tgz#72580b7e9145fb39b6676f9c5e5fb100b934179a" + resolved "https://registry.npmmirror.com/debug/-/debug-3.2.7.tgz" integrity sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ== dependencies: ms "^2.1.1" @@ -5219,7 +5219,7 @@ find-up@^3.0.0: find-up@^4.0.0, find-up@^4.1.0: version "4.1.0" - resolved "https://registry.npmmirror.com/find-up/-/find-up-4.1.0.tgz#97afe7d6cdc0bc5928584b7c8d7b16e8a9aa5d19" + resolved "https://registry.npmmirror.com/find-up/-/find-up-4.1.0.tgz" integrity sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw== dependencies: locate-path "^5.0.0" @@ -5406,7 +5406,7 @@ get-symbol-description@^1.0.0: glob-parent@^5.1.2, glob-parent@~5.1.2: version "5.1.2" - resolved "https://registry.npmmirror.com/glob-parent/-/glob-parent-5.1.2.tgz#869832c58034fe68a4093c17dc15e8340d8401c4" + resolved "https://registry.npmmirror.com/glob-parent/-/glob-parent-5.1.2.tgz" integrity sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow== dependencies: is-glob "^4.0.1" @@ -5425,7 +5425,7 @@ glob-to-regexp@^0.4.1: glob@7.1.6: version "7.1.6" - resolved "https://registry.npmmirror.com/glob/-/glob-7.1.6.tgz#141f33b81a7c2492e125594307480c46679278a6" + resolved "https://registry.npmmirror.com/glob/-/glob-7.1.6.tgz" integrity sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA== dependencies: fs.realpath "^1.0.0" @@ -5624,6 +5624,13 @@ html-minifier-terser@^6.0.2: relateurl "^0.2.7" terser "^5.10.0" +html-parse-stringify@^3.0.1: + version "3.0.1" + resolved "https://registry.npmmirror.com/html-parse-stringify/-/html-parse-stringify-3.0.1.tgz#dfc1017347ce9f77c8141a507f233040c59c55d2" + integrity sha512-KknJ50kTInJ7qIScF3jeaFRpMpE8/lfiTdzf/twXyPBLAGrLRTmkz3AdTnKeh40X8k9L2fdYwEp/42WGXIRGcg== + dependencies: + void-elements "3.1.0" + html-webpack-plugin@^5.5.0: version "5.5.3" resolved "https://registry.npmmirror.com/html-webpack-plugin/-/html-webpack-plugin-5.5.3.tgz#72270f4a78e222b5825b296e5e3e1328ad525a3e" @@ -5728,9 +5735,16 @@ husky@^8.0.0: resolved "https://registry.npmmirror.com/husky/-/husky-8.0.3.tgz#4936d7212e46d1dea28fef29bb3a108872cd9184" integrity sha512-+dQSyqPh4x1hlO1swXBiNb2HzTDN1I2IGLQx1GrBuiqFJfoMrnZWwVmatvSiO+Iz8fBUnf+lekwNo4c2LlXItg== +i18next@^23.5.1: + version "23.5.1" + resolved "https://registry.npmmirror.com/i18next/-/i18next-23.5.1.tgz#7f7c35ffaa907618d9489f106d5006b09fbca3d3" + integrity sha512-JelYzcaCoFDaa+Ysbfz2JsGAKkrHiMG6S61+HLBUEIPaF40WMwW9hCPymlQGrP+wWawKxKPuSuD71WZscCsWHg== + dependencies: + "@babel/runtime" "^7.22.5" + iconv-lite@0.4.24: version "0.4.24" - resolved "https://registry.npmmirror.com/iconv-lite/-/iconv-lite-0.4.24.tgz#2022b4b25fbddc21d2f524974a474aafe733908b" + resolved "https://registry.npmmirror.com/iconv-lite/-/iconv-lite-0.4.24.tgz" integrity sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA== dependencies: safer-buffer ">= 2.1.2 < 3" @@ -7150,7 +7164,7 @@ make-dir@^2.1.0: make-dir@^3.0.2, make-dir@^3.1.0: version "3.1.0" - resolved "https://registry.npmmirror.com/make-dir/-/make-dir-3.1.0.tgz#415e967046b3a7f1d185277d84aa58203726a13f" + resolved "https://registry.npmmirror.com/make-dir/-/make-dir-3.1.0.tgz" integrity sha512-g3FeP20LNwhALb/6Cz6Dd4F2ngze0jz7tbzrD2wAV+o9FeNHe4rL+yK2md0J/fiSf1sa1ADhXqi5+oVwOM/eGw== dependencies: semver "^6.0.0" @@ -7551,7 +7565,7 @@ once@^1.3.0: onetime@^5.1.0, onetime@^5.1.2: version "5.1.2" - resolved "https://registry.npmmirror.com/onetime/-/onetime-5.1.2.tgz#d0e96ebb56b07476df1dd9c4806e5237985ca45e" + resolved "https://registry.npmmirror.com/onetime/-/onetime-5.1.2.tgz" integrity sha512-kbpaSSGJTWdAY5KPVeMOKXSrPtr8C8C7wodJbcsd51jRnmD+GZu8Y0VoU6Dm5Z4vWr0Ig/1NKuWRKf7j5aaYSg== dependencies: mimic-fn "^2.1.0" @@ -8477,6 +8491,13 @@ qs@6.11.0: dependencies: side-channel "^1.0.4" +qs@^6.11.2: + version "6.11.2" + resolved "https://registry.npmmirror.com/qs/-/qs-6.11.2.tgz#64bea51f12c1f5da1bc01496f48ffcff7c69d7d9" + integrity sha512-tDNIz22aBzCDxLtVH++VnTfzxlfeK5CbqohpSqpJgj1Wg/cQbStNAz3NuqCs5vV+pjBsK4x4pN9HlVh7rcYRiA== + dependencies: + side-channel "^1.0.4" + querystringify@^2.1.1: version "2.2.0" resolved "https://registry.npmmirror.com/querystringify/-/querystringify-2.2.0.tgz#3345941b4153cb9d082d8eee4cda2016a9aef7f6" @@ -8931,6 +8952,14 @@ react-error-overlay@^6.0.11: resolved "https://registry.npmmirror.com/react-error-overlay/-/react-error-overlay-6.0.11.tgz#92835de5841c5cf08ba00ddd2d677b6d17ff9adb" integrity sha512-/6UZ2qgEyH2aqzYZgQPxEnz33NJ2gNsnHA2o5+o4wW9bLM/JYQitNP9xPhsXwC08hMMovfGe/8retsdDsczPRg== +react-i18next@^13.2.2: + version "13.2.2" + resolved "https://registry.npmmirror.com/react-i18next/-/react-i18next-13.2.2.tgz#b1e78ed66a54f4bc819616f68b98221e1b1a1936" + integrity sha512-+nFUkbRByFwnrfDcYqvzBuaeZb+nACHx+fAWN/pZMddWOCJH5hoc21+Sa/N/Lqi6ne6/9wC/qRGOoQhJa6IkEQ== + dependencies: + "@babel/runtime" "^7.22.5" + html-parse-stringify "^3.0.1" + react-is@^16.12.0, react-is@^16.13.1: version "16.13.1" resolved "https://registry.npmmirror.com/react-is/-/react-is-16.13.1.tgz#789729a4dc36de2999dc156dd6c1d9c18cea56a4" @@ -9372,7 +9401,7 @@ scheduler@^0.23.0: schema-utils@2.7.0: version "2.7.0" - resolved "https://registry.npmmirror.com/schema-utils/-/schema-utils-2.7.0.tgz#17151f76d8eae67fbbf77960c33c676ad9f4efc7" + resolved "https://registry.npmmirror.com/schema-utils/-/schema-utils-2.7.0.tgz" integrity sha512-0ilKFI6QQF5nxDZLFn2dMjvc4hjg/Wkg7rHd3jK6/A4a1Hl9VFdQWvgB1UMGoU94pad1P/8N7fMcEnLnSiju8A== dependencies: "@types/json-schema" "^7.0.4" @@ -9438,7 +9467,7 @@ semver@^5.6.0: semver@^6.0.0, semver@^6.3.0, semver@^6.3.1: version "6.3.1" - resolved "https://registry.npmmirror.com/semver/-/semver-6.3.1.tgz#556d2ef8689146e46dcea4bfdd095f3434dffcb4" + resolved "https://registry.npmmirror.com/semver/-/semver-6.3.1.tgz" integrity sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA== semver@^7.3.2, semver@^7.3.5, semver@^7.3.7, semver@^7.3.8, semver@^7.5.3: @@ -10480,6 +10509,11 @@ vary@~1.1.2: resolved "https://registry.npmmirror.com/vary/-/vary-1.1.2.tgz#2299f02c6ded30d4a5961b0b9f74524a18f634fc" integrity sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg== +void-elements@3.1.0: + version "3.1.0" + resolved "https://registry.npmmirror.com/void-elements/-/void-elements-3.1.0.tgz#614f7fbf8d801f0bb5f0661f5b2f5785750e4f09" + integrity sha512-Dhxzh5HZuiHQhbvTW9AMetFfBHDMYpo23Uo9btPXgdYP+3T5S+p+jgNy7spra+veYhBP2dCSgxR/i2Y02h5/6w== + w3c-hr-time@^1.0.2: version "1.0.2" resolved "https://registry.npmmirror.com/w3c-hr-time/-/w3c-hr-time-1.0.2.tgz#0a89cdf5cc15822df9c360543676963e0cc308cd"