@mingfuyun/star-allinone 0.1.6 → 0.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +111 -1
- package/dist/components/BaseModal/index.d.ts +6 -6
- package/dist/components/BaseModal/index.d.ts.map +1 -1
- package/dist/components/CustomDrawer/index.d.ts +5 -5
- package/dist/components/CustomDrawer/index.d.ts.map +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.js +1 -1
- package/package.json +9 -2
- package/scripts/cli.js +179 -0
- package/skills/README.md +297 -0
- package/skills/shared/ai-review/SKILL.md +29 -0
- package/skills/shared/api-mock/SKILL.md +23 -0
- package/skills/shared/api-mock/references/mock-conventions.md +90 -0
- package/skills/shared/api-to-service/SKILL.md +51 -0
- package/skills/shared/api-to-service/references/api-artifact-generation.md +70 -0
- package/skills/shared/api-to-service/references/service-conventions.md +89 -0
- package/skills/shared/commit-current-changes/SKILL.md +63 -0
- package/skills/shared/design-to-page/SKILL.md +48 -0
- package/skills/shared/design-to-page/references/overlays.md +73 -0
- package/skills/shared/design-to-page/references/page-conventions.md +85 -0
- package/skills/shared/impact-analysis/SKILL.md +30 -0
- package/skills/shared/project-conventions/SKILL.md +30 -0
- package/skills/shared/project-conventions/references/architecture.md +43 -0
- package/skills/shared/project-conventions/references/quality-checklist.md +19 -0
- package/skills/shared/project-conventions/references/review-checklist.md +42 -0
- package/skills/shared/publish-test/SKILL.md +46 -0
- package/skills/shared/publish-test/scripts/publish-current-branch.sh +174 -0
- package/skills/shared/review-and-submit/SKILL.md +75 -0
- package/skills/shared/verify/SKILL.md +44 -0
package/README.md
CHANGED
|
@@ -12,6 +12,117 @@ yarn add @mingfuyun/star-allinone
|
|
|
12
12
|
pnpm add @mingfuyun/star-allinone
|
|
13
13
|
```
|
|
14
14
|
|
|
15
|
+
## Skill 如何使用
|
|
16
|
+
|
|
17
|
+
公共 skill 由本仓库维护,随 `@mingfuyun/star-allinone` 发布。业务项目用 CLI 同步到自己的 `.agents/skills/shared-*` 并提交。Codex / Cursor 直接从业务仓库发现 skill,不写入 `~/.codex/skills`,团队成员也不需要本仓库源码。
|
|
18
|
+
|
|
19
|
+
```text
|
|
20
|
+
.agents/skills/
|
|
21
|
+
├── shared-* ← npm 包同步,不能在业务项目直接改
|
|
22
|
+
└── custom-* ← 业务项目自己维护
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
完整约定见 [skills/README.md](skills/README.md)。
|
|
26
|
+
|
|
27
|
+
### 命令
|
|
28
|
+
|
|
29
|
+
全部在**业务项目根目录**执行:
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
pnpm exec star-allinone skills list
|
|
33
|
+
pnpm exec star-allinone skills sync --dry-run
|
|
34
|
+
pnpm exec star-allinone skills sync
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
`list` 查看包内公共 skill。`sync` 把它们写入当前项目的 `.agents/skills/shared-*`,会整体替换过期的 `shared-*`,但不会改 `custom-*`。
|
|
38
|
+
|
|
39
|
+
### 维护者:改公共 skill
|
|
40
|
+
|
|
41
|
+
1. 修改 `skills/shared/<name>/SKILL.md`,例如 `skills/shared/api-to-service/SKILL.md`
|
|
42
|
+
2. 发布新版本 `@mingfuyun/star-allinone`
|
|
43
|
+
3. 业务项目升级依赖并重新同步(见下方)
|
|
44
|
+
|
|
45
|
+
不要把流水线 ID 或 OpenAPI 快照写进 `skills/shared`。流水线 ID 放在业务项目 `.star-allinone.json` 的 `publishPipelineId`。审查、提交、发布、Mock 和 Service 生成都是公共 skill。
|
|
46
|
+
|
|
47
|
+
### 业务项目:首次接入
|
|
48
|
+
|
|
49
|
+
1. 安装依赖:
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
pnpm add @mingfuyun/star-allinone
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
2. 在项目根目录添加 `.star-allinone.json`:
|
|
56
|
+
|
|
57
|
+
```json
|
|
58
|
+
{
|
|
59
|
+
"project": "starscope-frontend",
|
|
60
|
+
"publicSkillPrefix": "shared-",
|
|
61
|
+
"serviceDir": "src/services",
|
|
62
|
+
"openapi": ".agents/project/openapi.json",
|
|
63
|
+
"publishPipelineId": "5108336"
|
|
64
|
+
}
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
StarLink 示例见 `examples/projects/`。
|
|
68
|
+
|
|
69
|
+
3. 同步公共 skill:
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
pnpm exec star-allinone skills sync
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
4. 把真正的业务特例放到 `.agents/skills/custom-*`。审查、提交、发布、Mock 和 Service 生成不要做成 `custom-*`。
|
|
76
|
+
|
|
77
|
+
5. 提交配置和 skill:
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
git add .star-allinone.json .agents/skills
|
|
81
|
+
git commit -m "chore(skill): 接入公共 skill"
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### 业务项目:日常调用
|
|
85
|
+
|
|
86
|
+
在 Codex / Cursor 对话里用 `$skill-name` 显式调用,例如:
|
|
87
|
+
|
|
88
|
+
```text
|
|
89
|
+
使用 $shared-api-to-service,为 GET /api/v1/devices/ 生成类型、Service 和 JSON Mock。
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
```text
|
|
93
|
+
使用 $shared-design-to-page,根据我上传的设计稿生成页面。
|
|
94
|
+
缺少的 Service、类型和 Mock 一并生成。
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
```text
|
|
98
|
+
使用 $shared-review-and-submit,对当前变更执行提交前审查。
|
|
99
|
+
等我确认后再提交。
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
```text
|
|
103
|
+
使用 $shared-publish-test,把当前分支发布到测试环境。
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
公共流程用 `shared-*`,项目专属规则用 `custom-*`。业务定制 skill 需要复用公共流程时,在 `custom-*` 的 `SKILL.md` 里写明先读取对应的 `.agents/skills/shared-*/SKILL.md`。
|
|
107
|
+
|
|
108
|
+
### 业务项目:更新公共 skill
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
pnpm update @mingfuyun/star-allinone
|
|
112
|
+
pnpm exec star-allinone skills sync
|
|
113
|
+
git add package.json pnpm-lock.yaml .agents/skills/shared-*
|
|
114
|
+
git commit -m "chore(skill): 更新公共 skill"
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
其他成员只需:
|
|
118
|
+
|
|
119
|
+
```bash
|
|
120
|
+
git pull
|
|
121
|
+
pnpm install
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
不要手动修改 `shared-*`。下次 `skills sync` 会覆盖这些目录。
|
|
125
|
+
|
|
15
126
|
### 在 Umi 项目中使用
|
|
16
127
|
|
|
17
128
|
如果您的项目使用 **Umi** 框架,组件库会自动从您的项目中获取 `@umijs/max` 的能力(如 `useAccess`)。
|
|
@@ -593,4 +704,3 @@ MIT License
|
|
|
593
704
|
---
|
|
594
705
|
|
|
595
706
|
Made with ❤️ by 星系运维团队
|
|
596
|
-
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
2
|
import "./index.less";
|
|
3
3
|
interface IBaseModal {
|
|
4
|
-
title?: string |
|
|
4
|
+
title?: string | ReactNode;
|
|
5
5
|
visible?: boolean;
|
|
6
6
|
onOk?: () => void;
|
|
7
7
|
onCancel?: () => void;
|
|
8
|
-
children:
|
|
8
|
+
children: ReactNode;
|
|
9
9
|
width?: number;
|
|
10
10
|
afterClose?: () => void;
|
|
11
11
|
okText?: string;
|
|
12
12
|
cancelText?: string;
|
|
13
13
|
confirmLoading?: boolean;
|
|
14
|
-
footer?:
|
|
14
|
+
footer?: ReactNode | null;
|
|
15
15
|
wrapClassName?: string;
|
|
16
16
|
className?: string;
|
|
17
17
|
keyboard?: boolean;
|
|
@@ -20,8 +20,8 @@ interface IBaseModal {
|
|
|
20
20
|
getContainer?: () => HTMLElement;
|
|
21
21
|
closable?: boolean;
|
|
22
22
|
destroyOnClose?: boolean;
|
|
23
|
-
closeIcon?:
|
|
23
|
+
closeIcon?: ReactNode;
|
|
24
24
|
}
|
|
25
|
-
declare const _default:
|
|
25
|
+
declare const _default: import("react").NamedExoticComponent<IBaseModal>;
|
|
26
26
|
export default _default;
|
|
27
27
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../components/BaseModal/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../components/BaseModal/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAM,SAAS,EAAE,MAAM,OAAO,CAAC;AAC3C,OAAO,cAAc,CAAC;AAEtB,UAAU,UAAU;IAClB,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,IAAI,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;IACtB,QAAQ,EAAE,SAAS,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,IAAI,CAAC;IACxB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,MAAM,CAAC,EAAE,SAAS,GAAG,IAAI,CAAC;IAC1B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,YAAY,CAAC,EAAE,MAAM,WAAW,CAAC;IACjC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,SAAS,CAAC,EAAE,SAAS,CAAC;CACvB;;AAmDD,wBAA+B"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import type { FC, ReactNode } from "react";
|
|
2
2
|
import "./index.less";
|
|
3
3
|
interface CustomDrawerProps {
|
|
4
4
|
title: string;
|
|
@@ -8,13 +8,13 @@ interface CustomDrawerProps {
|
|
|
8
8
|
onClose: () => void;
|
|
9
9
|
onConfirm?: () => void;
|
|
10
10
|
cancelText?: string;
|
|
11
|
-
children?:
|
|
11
|
+
children?: ReactNode;
|
|
12
12
|
okText?: string;
|
|
13
13
|
className?: string;
|
|
14
|
-
footer?:
|
|
15
|
-
extra?:
|
|
14
|
+
footer?: ReactNode;
|
|
15
|
+
extra?: ReactNode;
|
|
16
16
|
loading?: boolean;
|
|
17
17
|
}
|
|
18
|
-
declare const CustomDrawer:
|
|
18
|
+
declare const CustomDrawer: FC<CustomDrawerProps>;
|
|
19
19
|
export default CustomDrawer;
|
|
20
20
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../components/CustomDrawer/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../components/CustomDrawer/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAC3C,OAAO,cAAc,CAAC;AAEtB,UAAU,iBAAiB;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,OAAO,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACxB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;IACvB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,QAAA,MAAM,YAAY,EAAE,EAAE,CAAC,iBAAiB,CA0CvC,CAAC;AAEF,eAAe,YAAY,CAAC"}
|
package/dist/index.esm.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import*as e from"react/jsx-runtime";import*as n from"antd";import*as r from"react";var t=[,(e,n,r)=>{r.r(n),r.d(n,{default:()=>d});var t=r(2),a=r(3),o=r(4),l=r(5),i=r(6),u=function(){return u=Object.assign||function(e){for(var n,r=1,t=arguments.length;r<t;r++)for(var a in n=arguments[r])Object.prototype.hasOwnProperty.call(n,a)&&(e[a]=n[a]);return e},u.apply(this,arguments)},s=["minute","hour","day","month","week"],c={display:"block",lineHeight:2};const d=(0,l.forwardRef)(function(e,n){var r=e.cronExpression,d=(0,l.useState)(""),m=d[0],h=d[1],f=(0,l.useState)({minute:1,hour:1,day:1,month:1,week:1}),p=f[0],x=f[1],v=(0,l.useState)({minute:{min:1,max:2},hour:{min:0,max:1},day:{min:1,max:2},month:{min:1,max:2},week:{min:2,max:3}}),y=v[0],j=v[1],w=(0,l.useState)({minute:{start:0,end:1},hour:{start:0,end:1},day:{start:1,end:1},month:{start:1,end:1},week:{start:1,end:1}}),C=w[0],b=w[1],g=(0,l.useState)({minute:[],hour:[],day:[],month:[],week:[]}),k=g[0],O=g[1],N=(0,l.useRef)(null),R=(0,l.useState)(void 0),S=R[0],I=R[1],E=function(e,n){switch(e){case"minute":return{minute:n};case"hour":return{hour:n};case"day":return{day:n};case"month":return{month:n};case"week":return{week:n};default:return{}}},T=function(){return m},z=function(){x({minute:1,hour:1,day:1,month:1,week:1}),j({minute:{min:1,max:2},hour:{min:0,max:1},day:{min:1,max:2},month:{min:1,max:2},week:{min:2,max:3}}),b({minute:{start:0,end:1},hour:{start:0,end:1},day:{start:1,end:1},month:{start:1,end:1},week:{start:1,end:1}}),O({minute:[],hour:[],day:[],month:[],week:[]}),h("")},P=function(e,n){for(var r=[],t=e;t<=n;t++)r.push({label:t,value:t});return r},B=function(e){for(var n=[],r=["","一","二","三","四","五","六","日"],t=1;t<=e;t++)n.push({label:"星期".concat(r[t]),value:t+1===8?7:t});return n},M=function(e,n){switch(n){case"week":x(u(u(u({},p),{day:2}),E(n,e.target.value)));break;case"day":x(u(u(u({},p),{week:2}),E(n,e.target.value)));break;default:x(u(u({},p),E(n,e.target.value)))}},D=function(e,n,r){var t,a;r(u(u({},k),((t={})[n]=e,t))),x(u(u({},p),((a={})[n]="point",a)))},F=function(e,n,r){var t=y;t[n]="max"===r?{max:e,min:t[n].min}:{max:t[n].max,min:e},j(u(u({},y),E(n,t[n])))},L=function(e,n,r){var t=C;t[n]="start"===r?{start:e,end:t[n].end}:{start:t[n].start,end:e},b(u(u({},C),E(n,t[n])))};return(0,l.useEffect)(function(){r?function(e){h(e);var n=e.split(" "),r={},t={},a={},o={};n.forEach(function(e,n){if(-1!==e.indexOf("/")&&-1!==e.indexOf("-")){r[s[n]]="loop";var l=e.split("/")[0],i=l.split("-")[0];a[s[n]]={start:"*"===l?0:Number(i),end:Number(e.split("/")[1])}}else-1!==e.indexOf("*")?r[s[n]]="*":-1!==e.indexOf("-")?(r[s[n]]="period",t[s[n]]={min:Number(e.split("-")[0]),max:Number(e.split("-")[1])}):(r[s[n]]="point",o[s[n]]=e.split(",").map(function(e){return Number(e)}))}),j(u(u({},y),t)),b(u(u({},C),a)),O(u(u({},k),o)),x(u(u({},p),r))}(r):z()},[r]),(0,l.useEffect)(function(){!function(){var e={};s.forEach(function(n){return e=u(u({},e),function(e){var n=p[e],r=y[e],t=C[e],a=k[e],o="";switch(n){case"*":default:o="*";break;case"point":for(var l=0,i=a;l<i.length;l++)o=o+i[l]+",";o=o.substring(0,o.length-1);break;case"period":o=r.min+"-"+r.max;break;case"loop":o=t.start+"-"+{minute:59,hour:23,day:31,month:12,week:7}[e]+"/"+t.end}return E(e,o)}(n))});var n=e.minute,r=e.hour,t=e.day,a=e.month,o=e.week;h(n+" "+r+" "+t+" "+a+" "+o)}()},[p,y,C]),(0,l.useImperativeHandle)(n,function(){return{refGetCron:T,resetCronState:z,getValidateStatus:function(){return S}}}),(0,l.useEffect)(function(){var e;!function(e){(0,o.isValidCron)(e)?null==I||I("success"):null==I||I("error")}(m),null===(e=N.current)||void 0===e||e.setFieldsValue({cronText:m})},[m]),(0,t.jsxs)("div",{className:i.default.Cron,children:[(0,t.jsx)(a.Tabs,{type:"card",items:[{label:"分",key:"minute",children:(0,t.jsx)(a.Card,{children:(0,t.jsxs)(a.Radio.Group,{value:p.minute,onChange:function(e){return M(e,"minute")},children:[(0,t.jsx)(a.Radio,{style:c,value:"*",children:"每分执行"}),(0,t.jsxs)(a.Radio,{style:c,value:"period",children:["周期从",(0,t.jsx)(a.InputNumber,{size:"small",min:0,max:58,value:y.minute.min,onChange:function(e){return F(e,"minute","min")}}),"-",(0,t.jsx)(a.InputNumber,{size:"small",min:2,max:59,value:y.minute.max,onChange:function(e){return F(e,"minute","max")}}),"分"]}),(0,t.jsxs)(a.Radio,{style:c,value:"loop",children:["从",(0,t.jsx)(a.InputNumber,{size:"small",min:0,max:58,value:C.minute.start,onChange:function(e){return L(e,"minute","start")}}),"分开始,每",(0,t.jsx)(a.InputNumber,{size:"small",min:1,max:58,value:C.minute.end,onChange:function(e){return L(e,"minute","end")}}),"分执行一次"]}),(0,t.jsxs)(a.Row,{children:[(0,t.jsx)(a.Radio,{style:c,value:"point",children:"指定"}),(0,t.jsx)(a.Col,{span:18,children:(0,t.jsx)(a.Select,{value:k.minute,style:{width:"80%",marginTop:7},mode:"multiple",allowClear:!0,placeholder:"请选择分钟",onChange:function(e){return D(e,"minute",O)},options:P(0,59)})})]})]})})},{label:"时",key:"hour",children:(0,t.jsx)(a.Card,{children:(0,t.jsxs)(a.Radio.Group,{onChange:function(e){return M(e,"hour")},value:p.hour,children:[(0,t.jsx)(a.Radio,{style:c,value:"*",children:"每小时执行"}),(0,t.jsxs)(a.Radio,{style:c,value:"period",children:["周期从",(0,t.jsx)(a.InputNumber,{size:"small",min:0,max:22,value:y.hour.min,onChange:function(e){return F(e,"hour","min")}}),"-",(0,t.jsx)(a.InputNumber,{size:"small",min:1,max:23,value:y.hour.max,onChange:function(e){return F(e,"hour","max")}}),"时"]}),(0,t.jsxs)(a.Radio,{style:c,value:"loop",children:["从",(0,t.jsx)(a.InputNumber,{size:"small",min:0,max:22,value:C.hour.start,onChange:function(e){return L(e,"hour","start")}}),"时开始,每",(0,t.jsx)(a.InputNumber,{size:"small",min:1,max:22,value:C.hour.end,onChange:function(e){return L(e,"hour","end")}}),"时执行一次"]}),(0,t.jsxs)(a.Row,{children:[(0,t.jsx)(a.Radio,{style:c,value:"point",children:"指定"}),(0,t.jsx)(a.Col,{span:18,children:(0,t.jsx)(a.Select,{value:k.hour,style:{width:"80%",marginTop:7},mode:"multiple",allowClear:!0,placeholder:"请选择小时",onChange:function(e){return D(e,"hour",O)},options:P(0,23)})})]})]})})},{label:"日",key:"day",children:(0,t.jsx)(a.Card,{children:(0,t.jsxs)(a.Radio.Group,{onChange:function(e){return M(e,"day")},value:p.day,children:[(0,t.jsx)(a.Radio,{style:c,value:"*",children:"每日执行"}),(0,t.jsxs)(a.Radio,{style:c,value:"period",children:["周期从",(0,t.jsx)(a.InputNumber,{size:"small",min:1,max:30,value:y.day.min,onChange:function(e){return F(e,"day","min")}}),"-",(0,t.jsx)(a.InputNumber,{size:"small",min:2,max:31,value:y.day.max,onChange:function(e){return F(e,"day","max")}}),"日"]}),(0,t.jsxs)(a.Radio,{style:c,value:"loop",children:["从",(0,t.jsx)(a.InputNumber,{size:"small",min:1,max:31,value:C.day.start,onChange:function(e){return L(e,"day","start")}}),"日开始,每",(0,t.jsx)(a.InputNumber,{size:"small",min:1,max:31,value:C.day.end,onChange:function(e){return L(e,"day","end")}}),"日执行一次"]}),(0,t.jsxs)(a.Row,{children:[(0,t.jsx)(a.Radio,{style:c,value:"point",children:"指定"}),(0,t.jsx)(a.Col,{span:18,children:(0,t.jsx)(a.Select,{value:k.day,style:{width:"80%",marginTop:7},mode:"multiple",allowClear:!0,placeholder:"请选择日期",onChange:function(e){return D(e,"day",O)},options:P(1,31)})})]})]})})},{label:"月",key:"month",children:(0,t.jsx)(a.Card,{children:(0,t.jsxs)(a.Radio.Group,{onChange:function(e){return M(e,"month")},value:p.month,children:[(0,t.jsx)(a.Radio,{style:c,value:"*",children:"每月执行"}),(0,t.jsxs)(a.Radio,{style:c,value:"period",children:["周期从",(0,t.jsx)(a.InputNumber,{size:"small",min:1,max:11,value:y.month.min,onChange:function(e){return F(e,"month","min")}}),"-",(0,t.jsx)(a.InputNumber,{size:"small",min:2,max:12,value:y.month.max,onChange:function(e){return F(e,"month","max")}}),"月"]}),(0,t.jsxs)(a.Radio,{style:c,value:"loop",children:["从",(0,t.jsx)(a.InputNumber,{size:"small",min:1,max:12,value:C.month.start,onChange:function(e){return L(e,"month","start")}}),"月开始,每",(0,t.jsx)(a.InputNumber,{size:"small",min:1,max:12,value:C.month.end,onChange:function(e){return L(e,"month","end")}}),"月执行一次"]}),(0,t.jsxs)(a.Row,{children:[(0,t.jsx)(a.Radio,{style:c,value:"point",children:"指定"}),(0,t.jsx)(a.Col,{span:18,children:(0,t.jsx)(a.Select,{value:k.month,style:{width:"80%",marginTop:7},mode:"multiple",allowClear:!0,placeholder:"请选择月份",onChange:function(e){return D(e,"month",O)},options:P(1,12)})})]})]})})},{label:"周",key:"week",children:(0,t.jsx)(a.Card,{children:(0,t.jsxs)(a.Radio.Group,{onChange:function(e){return M(e,"week")},value:p.week,children:[(0,t.jsx)(a.Radio,{style:c,value:"*",children:"每周执行"}),(0,t.jsxs)(a.Row,{children:[(0,t.jsx)(a.Col,{children:(0,t.jsx)(a.Radio,{style:c,value:"period",children:"周期从 周"})}),(0,t.jsx)(a.Col,{children:(0,t.jsx)(a.Select,{style:{marginTop:7},allowClear:!0,value:y.week.min,placeholder:"请选择周",onChange:function(e){return F(e,"week","min")},options:B(7)})}),(0,t.jsx)(a.Col,{className:i.default.CronWeekFont,children:"- 周"}),(0,t.jsx)(a.Col,{children:(0,t.jsx)(a.Select,{style:{marginTop:7},allowClear:!0,value:y.week.max,placeholder:"请选择周",onChange:function(e){return F(e,"week","max")},options:B(7)})})]}),(0,t.jsxs)(a.Row,{children:[(0,t.jsx)(a.Radio,{style:c,value:"point",children:"指定"}),(0,t.jsx)(a.Col,{span:18,children:(0,t.jsx)(a.Select,{value:k.week,style:{width:"80%",marginTop:7},mode:"multiple",allowClear:!0,placeholder:"请选择周",onChange:function(e){return D(e,"week",O)},options:B(7)})})]})]})})}]}),(0,t.jsx)(a.Form,{className:i.default.CronPreview,ref:N,children:(0,t.jsx)(a.Form.Item,{label:"预览",name:"cronText",className:i.default.CronPreviewItem,hasFeedback:!0,validateStatus:S,children:(0,t.jsx)(a.Input,{readOnly:!0,style:{width:150}})})})]})})},n=>{n.exports=e},e=>{e.exports=n},function(e,n){var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var n,r=1,t=arguments.length;r<t;r++)for(var a in n=arguments[r])Object.prototype.hasOwnProperty.call(n,a)&&(e[a]=n[a]);return e},r.apply(this,arguments)};Object.defineProperty(n,"__esModule",{value:!0}),n.isValidCron=void 0;var t=function(e){return/^\d+$/.test(e)?Number(e):NaN},a=function(e){return"?"===e},o=function(e,n,r){return e>=n&&e<=r},l=function(e,n,r){return-1===e.search(/[^\d-,\/*]/)&&e.split(",").every(function(e){var a=e.split("/");if(e.trim().endsWith("/"))return!1;if(a.length>2)return!1;var l=a[0],i=a[1];return function(e,n,r){var a=e.split("-");switch(a.length){case 1:return function(e){return"*"===e}(e)||o(t(e),n,r);case 2:var l=a.map(function(e){return t(e)}),i=l[0],u=l[1];return i<=u&&o(i,n,r)&&o(u,n,r);default:return!1}}(l,n,r)&&function(e){return void 0===e||-1===e.search(/[^\d]/)&&t(e)>0}(i)})},i={jan:"1",feb:"2",mar:"3",apr:"4",may:"5",jun:"6",jul:"7",aug:"8",sep:"9",oct:"10",nov:"11",dec:"12"},u={sun:"0",mon:"1",tue:"2",wed:"3",thu:"4",fri:"5",sat:"6"},s={alias:!1,seconds:!1,allowBlankDay:!1,allowSevenAsSunday:!1,allowNthWeekdayOfMonth:!1};n.isValidCron=function(e,n){var c=r(r({},s),n),d=function(e){return e.trim().split(/\s+/)}(e);if(d.length>(c.seconds?6:5)||d.length<5)return!1;var m=[];if(6===d.length){var h=d.shift();h&&m.push(function(e){return l(e,0,59)}(h))}var f=d[0],p=d[1],x=d[2],v=d[3],y=d[4];return m.push(function(e){return l(e,0,59)}(f)),m.push(function(e){return l(e,0,23)}(p)),m.push(function(e,n){return n&&a(e)||l(e,1,31)}(x,c.allowBlankDay)),m.push(function(e,n){if(-1!==e.search(/\/[a-zA-Z]/))return!1;if(n){var r=e.toLowerCase().replace(/[a-z]{3}/g,function(e){return void 0===i[e]?e:i[e]});return l(r,1,12)}return l(e,1,12)}(v,c.alias)),m.push(function(e,n){var r=n.allowBlankDay,i=n.alias,s=n.allowSevenAsSunday,c=n.allowNthWeekdayOfMonth;if(r&&a(e))return!0;if(!r&&a(e))return!1;if(-1!==e.search(/\/[a-zA-Z]/))return!1;var d=i?e.toLowerCase().replace(/[a-z]{3}/g,function(e){return void 0===u[e]?e:u[e]}):e,m=s?7:6,h=d.split("#");if(c&&h.length>=2){var f=h[0],p=h[1];return 0===h.slice(2).length&&o(t(p),1,5)&&o(t(f),0,m)}return l(d,0,m)}(y,c)),m.push(function(e,n,r){return!(r&&a(e)&&a(n))}(x,y,c.allowBlankDay)),m.every(Boolean)}},e=>{e.exports=r},(e,n,r)=>{r.r(n),r.d(n,{default:()=>t});const t={Cron:"vBb5040F",CronWeekFont:"O5XKllcf",CronPreview:"Ci4nV30W",CronPreviewItem:"y5qUyBlE"}},(e,n,r)=>{r.r(n),r.d(n,{default:()=>l});var t=r(2),a=r(5),o=function(){return o=Object.assign||function(e){for(var n,r=1,t=arguments.length;r<t;r++)for(var a in n=arguments[r])Object.prototype.hasOwnProperty.call(n,a)&&(e[a]=n[a]);return e},o.apply(this,arguments)};function l(e){return(0,a.forwardRef)(function(n,r){var l=(0,a.useState)(!1),i=l[0],u=l[1],s=(0,a.useRef)(null);(0,a.useImperativeHandle)(r,function(){return{show:function(e){s.current=e,u(!0)},hide:function(){u(!1)}}});var c=function(){u(!1)},d=(0,a.useMemo)(function(){return(0,t.jsx)(e,o({},n,{visible:i,handleCancel:c},s.current))},[i]);return(0,t.jsx)(t.Fragment,{children:i?d:null})})}},(e,n,r)=>{r.r(n),r.d(n,{default:()=>o});var t=r(2),a=r(3);r(9);const o=function(e){var n=e.title,r=e.open,o=e.onClose,l=e.onConfirm,i=e.children,u=e.width,s=e.closable,c=e.cancelText,d=e.okText,m=e.footer,h=e.className,f=e.extra,p=void 0===f?null:f,x=e.loading,v=void 0!==x&&x;return(0,t.jsx)(a.Drawer,{title:(0,t.jsx)("div",{style:{float:"left"},children:n}),placement:"right",className:h,closable:s,onClose:o,width:u,open:r,footer:m||(0,t.jsx)("div",{className:"custom-footer",children:(0,t.jsxs)(a.Space,{children:[(0,t.jsx)(a.Button,{onClick:o,children:c||"取消"}),(0,t.jsx)(a.Button,{type:"primary",onClick:l,children:d||"确定"})]})}),extra:p,loading:v,children:i})}},(e,n,r)=>{r.r(n)},(e,n,r)=>{r.r(n),r.d(n,{default:()=>l});var t=r(2),a=r(3),o=r(5);function l(e){var n=e.children,r=e.onError,l=(0,o.useState)({hasError:!1}),i=l[0],u=l[1],s=(0,o.useCallback)(function(e,n){u({hasError:!0,error:e,errorInfo:n}),r&&r(e,n),console.error("Error caught by boundary:",e,n)},[r]);return(0,o.useEffect)(function(){var e=function(e){s(e,{isAsync:!0,timestamp:(new Date).toISOString()})},n=function(n){n.preventDefault(),e(n.reason)},r=function(n){n.preventDefault(),e(n.error)};return window.addEventListener("unhandledrejection",n),window.addEventListener("error",r),function(){window.removeEventListener("unhandledrejection",n),window.removeEventListener("error",r)}},[s]),i.hasError&&i.error?(0,t.jsx)(t.Fragment,{children:(0,t.jsx)(a.Result,{status:"error",title:"System Failed",subTitle:"Please check and modify the following information before resubmitting.",extra:[(0,t.jsx)(a.Button,{type:"primary",onClick:function(){return window.location.reload()},children:"刷新页面"},"console")]})}):(0,t.jsx)(t.Fragment,{children:n})}},(e,n,r)=>{r.r(n),r.d(n,{default:()=>i});var t=r(2),a=r(3),o=r(5),l=(r(12),function(){return l=Object.assign||function(e){for(var n,r=1,t=arguments.length;r<t;r++)for(var a in n=arguments[r])Object.prototype.hasOwnProperty.call(n,a)&&(e[a]=n[a]);return e},l.apply(this,arguments)});const i=o.default.memo(function(e){var n=e.title,r=e.visible,o=e.onOk,i=e.onCancel,u=e.children,s=e.width,c=e.afterClose,d=e.okText,m=e.confirmLoading,h=void 0!==m&&m,f=e.footer,p=void 0===f?void 0:f,x=e.wrapClassName,v=void 0===x?"":x,y=e.cancelText,j=e.className,w=void 0===j?"":j,C=e.keyboard,b=void 0===C||C,g=e.maskClosable,k=void 0===g||g,O=e.mask,N=void 0===O||O,R=e.getContainer,S=e.closable,I=void 0===S||S,E=function(e,n){var r={};for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&n.indexOf(t)<0&&(r[t]=e[t]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var a=0;for(t=Object.getOwnPropertySymbols(e);a<t.length;a++)n.indexOf(t[a])<0&&Object.prototype.propertyIsEnumerable.call(e,t[a])&&(r[t[a]]=e[t[a]])}return r}(e,["title","visible","onOk","onCancel","children","width","afterClose","okText","confirmLoading","footer","wrapClassName","cancelText","className","keyboard","maskClosable","mask","getContainer","closable"]);return(0,t.jsx)(a.Modal,l({mask:N,width:s||320,title:n,open:r,onOk:o,onCancel:i,wrapClassName:"".concat(v," base-modal"),centered:!0,afterClose:c,okText:d||"确定",cancelText:y||"取消",confirmLoading:h,footer:p,destroyOnClose:!0,className:w,keyboard:b,maskClosable:k,getContainer:R,closable:I},E,{children:u}))})},(e,n,r)=>{r.r(n)}],a={};function o(e){var n=a[e];if(void 0!==n)return n.exports;var r=a[e]={exports:{}};return t[e].call(r.exports,r,r.exports,o),r.exports}o.n=e=>{var n=e&&e.__esModule?()=>e.default:()=>e;return o.d(n,{a:n}),n},o.d=(e,n)=>{for(var r in n)o.o(n,r)&&!o.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:n[r]})},o.o=(e,n)=>Object.prototype.hasOwnProperty.call(e,n),o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var l={};(()=>{o.r(l),o.d(l,{BaseModal:()=>a.default,Cron:()=>e.default,CustomDrawer:()=>r.default,ErrorBoundary:()=>t.default,HocModal:()=>n.default});var e=o(1),n=o(7),r=o(8),t=o(10),a=o(11)})();const i=l.BaseModal,u=l.Cron,s=l.CustomDrawer,c=l.ErrorBoundary,d=l.HocModal;export{i as BaseModal,u as Cron,s as CustomDrawer,c as ErrorBoundary,d as HocModal};
|
|
1
|
+
import*as e from"react/jsx-runtime";import*as n from"antd";import*as r from"react";var t=[,(e,n,r)=>{r.r(n),r.d(n,{default:()=>d});var t=r(2),a=r(3),o=r(4),l=r(5),i=r(6),u=function(){return u=Object.assign||function(e){for(var n,r=1,t=arguments.length;r<t;r++)for(var a in n=arguments[r])Object.prototype.hasOwnProperty.call(n,a)&&(e[a]=n[a]);return e},u.apply(this,arguments)},s=["minute","hour","day","month","week"],c={display:"block",lineHeight:2};const d=(0,l.forwardRef)(function(e,n){var r=e.cronExpression,d=(0,l.useState)(""),m=d[0],h=d[1],f=(0,l.useState)({minute:1,hour:1,day:1,month:1,week:1}),p=f[0],x=f[1],v=(0,l.useState)({minute:{min:1,max:2},hour:{min:0,max:1},day:{min:1,max:2},month:{min:1,max:2},week:{min:2,max:3}}),y=v[0],j=v[1],w=(0,l.useState)({minute:{start:0,end:1},hour:{start:0,end:1},day:{start:1,end:1},month:{start:1,end:1},week:{start:1,end:1}}),C=w[0],b=w[1],g=(0,l.useState)({minute:[],hour:[],day:[],month:[],week:[]}),k=g[0],O=g[1],N=(0,l.useRef)(null),R=(0,l.useState)(void 0),S=R[0],I=R[1],E=function(e,n){switch(e){case"minute":return{minute:n};case"hour":return{hour:n};case"day":return{day:n};case"month":return{month:n};case"week":return{week:n};default:return{}}},T=function(){return m},z=function(){x({minute:1,hour:1,day:1,month:1,week:1}),j({minute:{min:1,max:2},hour:{min:0,max:1},day:{min:1,max:2},month:{min:1,max:2},week:{min:2,max:3}}),b({minute:{start:0,end:1},hour:{start:0,end:1},day:{start:1,end:1},month:{start:1,end:1},week:{start:1,end:1}}),O({minute:[],hour:[],day:[],month:[],week:[]}),h("")},P=function(e,n){for(var r=[],t=e;t<=n;t++)r.push({label:t,value:t});return r},B=function(e){for(var n=[],r=["","一","二","三","四","五","六","日"],t=1;t<=e;t++)n.push({label:"星期".concat(r[t]),value:t+1===8?7:t});return n},M=function(e,n){switch(n){case"week":x(u(u(u({},p),{day:2}),E(n,e.target.value)));break;case"day":x(u(u(u({},p),{week:2}),E(n,e.target.value)));break;default:x(u(u({},p),E(n,e.target.value)))}},D=function(e,n,r){var t,a;r(u(u({},k),((t={})[n]=e,t))),x(u(u({},p),((a={})[n]="point",a)))},F=function(e,n,r){var t=y;t[n]="max"===r?{max:e,min:t[n].min}:{max:t[n].max,min:e},j(u(u({},y),E(n,t[n])))},L=function(e,n,r){var t=C;t[n]="start"===r?{start:e,end:t[n].end}:{start:t[n].start,end:e},b(u(u({},C),E(n,t[n])))};return(0,l.useEffect)(function(){r?function(e){h(e);var n=e.split(" "),r={},t={},a={},o={};n.forEach(function(e,n){if(-1!==e.indexOf("/")&&-1!==e.indexOf("-")){r[s[n]]="loop";var l=e.split("/")[0],i=l.split("-")[0];a[s[n]]={start:"*"===l?0:Number(i),end:Number(e.split("/")[1])}}else-1!==e.indexOf("*")?r[s[n]]="*":-1!==e.indexOf("-")?(r[s[n]]="period",t[s[n]]={min:Number(e.split("-")[0]),max:Number(e.split("-")[1])}):(r[s[n]]="point",o[s[n]]=e.split(",").map(function(e){return Number(e)}))}),j(u(u({},y),t)),b(u(u({},C),a)),O(u(u({},k),o)),x(u(u({},p),r))}(r):z()},[r]),(0,l.useEffect)(function(){!function(){var e={};s.forEach(function(n){return e=u(u({},e),function(e){var n=p[e],r=y[e],t=C[e],a=k[e],o="";switch(n){case"*":default:o="*";break;case"point":for(var l=0,i=a;l<i.length;l++)o=o+i[l]+",";o=o.substring(0,o.length-1);break;case"period":o=r.min+"-"+r.max;break;case"loop":o=t.start+"-"+{minute:59,hour:23,day:31,month:12,week:7}[e]+"/"+t.end}return E(e,o)}(n))});var n=e.minute,r=e.hour,t=e.day,a=e.month,o=e.week;h(n+" "+r+" "+t+" "+a+" "+o)}()},[p,y,C]),(0,l.useImperativeHandle)(n,function(){return{refGetCron:T,resetCronState:z,getValidateStatus:function(){return S}}}),(0,l.useEffect)(function(){var e;!function(e){(0,o.isValidCron)(e)?null==I||I("success"):null==I||I("error")}(m),null===(e=N.current)||void 0===e||e.setFieldsValue({cronText:m})},[m]),(0,t.jsxs)("div",{className:i.default.Cron,children:[(0,t.jsx)(a.Tabs,{type:"card",items:[{label:"分",key:"minute",children:(0,t.jsx)(a.Card,{children:(0,t.jsxs)(a.Radio.Group,{value:p.minute,onChange:function(e){return M(e,"minute")},children:[(0,t.jsx)(a.Radio,{style:c,value:"*",children:"每分执行"}),(0,t.jsxs)(a.Radio,{style:c,value:"period",children:["周期从",(0,t.jsx)(a.InputNumber,{size:"small",min:0,max:58,value:y.minute.min,onChange:function(e){return F(e,"minute","min")}}),"-",(0,t.jsx)(a.InputNumber,{size:"small",min:2,max:59,value:y.minute.max,onChange:function(e){return F(e,"minute","max")}}),"分"]}),(0,t.jsxs)(a.Radio,{style:c,value:"loop",children:["从",(0,t.jsx)(a.InputNumber,{size:"small",min:0,max:58,value:C.minute.start,onChange:function(e){return L(e,"minute","start")}}),"分开始,每",(0,t.jsx)(a.InputNumber,{size:"small",min:1,max:58,value:C.minute.end,onChange:function(e){return L(e,"minute","end")}}),"分执行一次"]}),(0,t.jsxs)(a.Row,{children:[(0,t.jsx)(a.Radio,{style:c,value:"point",children:"指定"}),(0,t.jsx)(a.Col,{span:18,children:(0,t.jsx)(a.Select,{value:k.minute,style:{width:"80%",marginTop:7},mode:"multiple",allowClear:!0,placeholder:"请选择分钟",onChange:function(e){return D(e,"minute",O)},options:P(0,59)})})]})]})})},{label:"时",key:"hour",children:(0,t.jsx)(a.Card,{children:(0,t.jsxs)(a.Radio.Group,{onChange:function(e){return M(e,"hour")},value:p.hour,children:[(0,t.jsx)(a.Radio,{style:c,value:"*",children:"每小时执行"}),(0,t.jsxs)(a.Radio,{style:c,value:"period",children:["周期从",(0,t.jsx)(a.InputNumber,{size:"small",min:0,max:22,value:y.hour.min,onChange:function(e){return F(e,"hour","min")}}),"-",(0,t.jsx)(a.InputNumber,{size:"small",min:1,max:23,value:y.hour.max,onChange:function(e){return F(e,"hour","max")}}),"时"]}),(0,t.jsxs)(a.Radio,{style:c,value:"loop",children:["从",(0,t.jsx)(a.InputNumber,{size:"small",min:0,max:22,value:C.hour.start,onChange:function(e){return L(e,"hour","start")}}),"时开始,每",(0,t.jsx)(a.InputNumber,{size:"small",min:1,max:22,value:C.hour.end,onChange:function(e){return L(e,"hour","end")}}),"时执行一次"]}),(0,t.jsxs)(a.Row,{children:[(0,t.jsx)(a.Radio,{style:c,value:"point",children:"指定"}),(0,t.jsx)(a.Col,{span:18,children:(0,t.jsx)(a.Select,{value:k.hour,style:{width:"80%",marginTop:7},mode:"multiple",allowClear:!0,placeholder:"请选择小时",onChange:function(e){return D(e,"hour",O)},options:P(0,23)})})]})]})})},{label:"日",key:"day",children:(0,t.jsx)(a.Card,{children:(0,t.jsxs)(a.Radio.Group,{onChange:function(e){return M(e,"day")},value:p.day,children:[(0,t.jsx)(a.Radio,{style:c,value:"*",children:"每日执行"}),(0,t.jsxs)(a.Radio,{style:c,value:"period",children:["周期从",(0,t.jsx)(a.InputNumber,{size:"small",min:1,max:30,value:y.day.min,onChange:function(e){return F(e,"day","min")}}),"-",(0,t.jsx)(a.InputNumber,{size:"small",min:2,max:31,value:y.day.max,onChange:function(e){return F(e,"day","max")}}),"日"]}),(0,t.jsxs)(a.Radio,{style:c,value:"loop",children:["从",(0,t.jsx)(a.InputNumber,{size:"small",min:1,max:31,value:C.day.start,onChange:function(e){return L(e,"day","start")}}),"日开始,每",(0,t.jsx)(a.InputNumber,{size:"small",min:1,max:31,value:C.day.end,onChange:function(e){return L(e,"day","end")}}),"日执行一次"]}),(0,t.jsxs)(a.Row,{children:[(0,t.jsx)(a.Radio,{style:c,value:"point",children:"指定"}),(0,t.jsx)(a.Col,{span:18,children:(0,t.jsx)(a.Select,{value:k.day,style:{width:"80%",marginTop:7},mode:"multiple",allowClear:!0,placeholder:"请选择日期",onChange:function(e){return D(e,"day",O)},options:P(1,31)})})]})]})})},{label:"月",key:"month",children:(0,t.jsx)(a.Card,{children:(0,t.jsxs)(a.Radio.Group,{onChange:function(e){return M(e,"month")},value:p.month,children:[(0,t.jsx)(a.Radio,{style:c,value:"*",children:"每月执行"}),(0,t.jsxs)(a.Radio,{style:c,value:"period",children:["周期从",(0,t.jsx)(a.InputNumber,{size:"small",min:1,max:11,value:y.month.min,onChange:function(e){return F(e,"month","min")}}),"-",(0,t.jsx)(a.InputNumber,{size:"small",min:2,max:12,value:y.month.max,onChange:function(e){return F(e,"month","max")}}),"月"]}),(0,t.jsxs)(a.Radio,{style:c,value:"loop",children:["从",(0,t.jsx)(a.InputNumber,{size:"small",min:1,max:12,value:C.month.start,onChange:function(e){return L(e,"month","start")}}),"月开始,每",(0,t.jsx)(a.InputNumber,{size:"small",min:1,max:12,value:C.month.end,onChange:function(e){return L(e,"month","end")}}),"月执行一次"]}),(0,t.jsxs)(a.Row,{children:[(0,t.jsx)(a.Radio,{style:c,value:"point",children:"指定"}),(0,t.jsx)(a.Col,{span:18,children:(0,t.jsx)(a.Select,{value:k.month,style:{width:"80%",marginTop:7},mode:"multiple",allowClear:!0,placeholder:"请选择月份",onChange:function(e){return D(e,"month",O)},options:P(1,12)})})]})]})})},{label:"周",key:"week",children:(0,t.jsx)(a.Card,{children:(0,t.jsxs)(a.Radio.Group,{onChange:function(e){return M(e,"week")},value:p.week,children:[(0,t.jsx)(a.Radio,{style:c,value:"*",children:"每周执行"}),(0,t.jsxs)(a.Row,{children:[(0,t.jsx)(a.Col,{children:(0,t.jsx)(a.Radio,{style:c,value:"period",children:"周期从 周"})}),(0,t.jsx)(a.Col,{children:(0,t.jsx)(a.Select,{style:{marginTop:7},allowClear:!0,value:y.week.min,placeholder:"请选择周",onChange:function(e){return F(e,"week","min")},options:B(7)})}),(0,t.jsx)(a.Col,{className:i.default.CronWeekFont,children:"- 周"}),(0,t.jsx)(a.Col,{children:(0,t.jsx)(a.Select,{style:{marginTop:7},allowClear:!0,value:y.week.max,placeholder:"请选择周",onChange:function(e){return F(e,"week","max")},options:B(7)})})]}),(0,t.jsxs)(a.Row,{children:[(0,t.jsx)(a.Radio,{style:c,value:"point",children:"指定"}),(0,t.jsx)(a.Col,{span:18,children:(0,t.jsx)(a.Select,{value:k.week,style:{width:"80%",marginTop:7},mode:"multiple",allowClear:!0,placeholder:"请选择周",onChange:function(e){return D(e,"week",O)},options:B(7)})})]})]})})}]}),(0,t.jsx)(a.Form,{className:i.default.CronPreview,ref:N,children:(0,t.jsx)(a.Form.Item,{label:"预览",name:"cronText",className:i.default.CronPreviewItem,hasFeedback:!0,validateStatus:S,children:(0,t.jsx)(a.Input,{readOnly:!0,style:{width:150}})})})]})})},n=>{n.exports=e},e=>{e.exports=n},function(e,n){var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var n,r=1,t=arguments.length;r<t;r++)for(var a in n=arguments[r])Object.prototype.hasOwnProperty.call(n,a)&&(e[a]=n[a]);return e},r.apply(this,arguments)};Object.defineProperty(n,"__esModule",{value:!0}),n.isValidCron=void 0;var t=function(e){return/^\d+$/.test(e)?Number(e):NaN},a=function(e){return"?"===e},o=function(e,n,r){return e>=n&&e<=r},l=function(e,n,r){return-1===e.search(/[^\d-,\/*]/)&&e.split(",").every(function(e){var a=e.split("/");if(e.trim().endsWith("/"))return!1;if(a.length>2)return!1;var l=a[0],i=a[1];return function(e,n,r){var a=e.split("-");switch(a.length){case 1:return function(e){return"*"===e}(e)||o(t(e),n,r);case 2:var l=a.map(function(e){return t(e)}),i=l[0],u=l[1];return i<=u&&o(i,n,r)&&o(u,n,r);default:return!1}}(l,n,r)&&function(e){return void 0===e||-1===e.search(/[^\d]/)&&t(e)>0}(i)})},i={jan:"1",feb:"2",mar:"3",apr:"4",may:"5",jun:"6",jul:"7",aug:"8",sep:"9",oct:"10",nov:"11",dec:"12"},u={sun:"0",mon:"1",tue:"2",wed:"3",thu:"4",fri:"5",sat:"6"},s={alias:!1,seconds:!1,allowBlankDay:!1,allowSevenAsSunday:!1,allowNthWeekdayOfMonth:!1};n.isValidCron=function(e,n){var c=r(r({},s),n),d=function(e){return e.trim().split(/\s+/)}(e);if(d.length>(c.seconds?6:5)||d.length<5)return!1;var m=[];if(6===d.length){var h=d.shift();h&&m.push(function(e){return l(e,0,59)}(h))}var f=d[0],p=d[1],x=d[2],v=d[3],y=d[4];return m.push(function(e){return l(e,0,59)}(f)),m.push(function(e){return l(e,0,23)}(p)),m.push(function(e,n){return n&&a(e)||l(e,1,31)}(x,c.allowBlankDay)),m.push(function(e,n){if(-1!==e.search(/\/[a-zA-Z]/))return!1;if(n){var r=e.toLowerCase().replace(/[a-z]{3}/g,function(e){return void 0===i[e]?e:i[e]});return l(r,1,12)}return l(e,1,12)}(v,c.alias)),m.push(function(e,n){var r=n.allowBlankDay,i=n.alias,s=n.allowSevenAsSunday,c=n.allowNthWeekdayOfMonth;if(r&&a(e))return!0;if(!r&&a(e))return!1;if(-1!==e.search(/\/[a-zA-Z]/))return!1;var d=i?e.toLowerCase().replace(/[a-z]{3}/g,function(e){return void 0===u[e]?e:u[e]}):e,m=s?7:6,h=d.split("#");if(c&&h.length>=2){var f=h[0],p=h[1];return 0===h.slice(2).length&&o(t(p),1,5)&&o(t(f),0,m)}return l(d,0,m)}(y,c)),m.push(function(e,n,r){return!(r&&a(e)&&a(n))}(x,y,c.allowBlankDay)),m.every(Boolean)}},e=>{e.exports=r},(e,n,r)=>{r.r(n),r.d(n,{default:()=>t});const t={Cron:"vBb5040F",CronWeekFont:"O5XKllcf",CronPreview:"Ci4nV30W",CronPreviewItem:"y5qUyBlE"}},(e,n,r)=>{r.r(n),r.d(n,{default:()=>l});var t=r(2),a=r(5),o=function(){return o=Object.assign||function(e){for(var n,r=1,t=arguments.length;r<t;r++)for(var a in n=arguments[r])Object.prototype.hasOwnProperty.call(n,a)&&(e[a]=n[a]);return e},o.apply(this,arguments)};function l(e){return(0,a.forwardRef)(function(n,r){var l=(0,a.useState)(!1),i=l[0],u=l[1],s=(0,a.useRef)(null);(0,a.useImperativeHandle)(r,function(){return{show:function(e){s.current=e,u(!0)},hide:function(){u(!1)}}});var c=function(){u(!1)},d=(0,a.useMemo)(function(){return(0,t.jsx)(e,o({},n,{visible:i,handleCancel:c},s.current))},[i]);return(0,t.jsx)(t.Fragment,{children:i?d:null})})}},(e,n,r)=>{r.r(n),r.d(n,{default:()=>o});var t=r(2),a=r(3);r(9);const o=function(e){var n=e.title,r=e.open,o=e.onClose,l=e.onConfirm,i=e.children,u=e.width,s=e.closable,c=e.cancelText,d=e.okText,m=e.footer,h=e.className,f=e.extra,p=void 0===f?null:f,x=e.loading,v=void 0!==x&&x;return(0,t.jsx)(a.Drawer,{title:(0,t.jsx)("div",{style:{float:"left"},children:n}),placement:"right",className:h,closable:s,onClose:o,width:u,open:r,footer:m||(0,t.jsx)("div",{className:"custom-footer",children:(0,t.jsxs)(a.Space,{children:[(0,t.jsx)(a.Button,{onClick:o,children:c||"取消"}),(0,t.jsx)(a.Button,{type:"primary",onClick:l,children:d||"确定"})]})}),extra:p,loading:v,children:i})}},(e,n,r)=>{r.r(n)},(e,n,r)=>{r.r(n),r.d(n,{default:()=>l});var t=r(2),a=r(3),o=r(5);function l(e){var n=e.children,r=e.onError,l=(0,o.useState)({hasError:!1}),i=l[0],u=l[1],s=(0,o.useCallback)(function(e,n){u({hasError:!0,error:e,errorInfo:n}),r&&r(e,n),console.error("Error caught by boundary:",e,n)},[r]);return(0,o.useEffect)(function(){var e=function(e){s(e,{isAsync:!0,timestamp:(new Date).toISOString()})},n=function(n){n.preventDefault(),e(n.reason)},r=function(n){n.preventDefault(),e(n.error)};return window.addEventListener("unhandledrejection",n),window.addEventListener("error",r),function(){window.removeEventListener("unhandledrejection",n),window.removeEventListener("error",r)}},[s]),i.hasError&&i.error?(0,t.jsx)(t.Fragment,{children:(0,t.jsx)(a.Result,{status:"error",title:"System Failed",subTitle:"Please check and modify the following information before resubmitting.",extra:[(0,t.jsx)(a.Button,{type:"primary",onClick:function(){return window.location.reload()},children:"刷新页面"},"console")]})}):(0,t.jsx)(t.Fragment,{children:n})}},(e,n,r)=>{r.r(n),r.d(n,{default:()=>i});var t=r(2),a=r(3),o=r(5),l=(r(12),function(){return l=Object.assign||function(e){for(var n,r=1,t=arguments.length;r<t;r++)for(var a in n=arguments[r])Object.prototype.hasOwnProperty.call(n,a)&&(e[a]=n[a]);return e},l.apply(this,arguments)});const i=(0,o.memo)(function(e){var n=e.title,r=e.visible,o=e.onOk,i=e.onCancel,u=e.children,s=e.width,c=e.afterClose,d=e.okText,m=e.confirmLoading,h=void 0!==m&&m,f=e.footer,p=void 0===f?void 0:f,x=e.wrapClassName,v=void 0===x?"":x,y=e.cancelText,j=e.className,w=void 0===j?"":j,C=e.keyboard,b=void 0===C||C,g=e.maskClosable,k=void 0===g||g,O=e.mask,N=void 0===O||O,R=e.getContainer,S=e.closable,I=void 0===S||S,E=function(e,n){var r={};for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&n.indexOf(t)<0&&(r[t]=e[t]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var a=0;for(t=Object.getOwnPropertySymbols(e);a<t.length;a++)n.indexOf(t[a])<0&&Object.prototype.propertyIsEnumerable.call(e,t[a])&&(r[t[a]]=e[t[a]])}return r}(e,["title","visible","onOk","onCancel","children","width","afterClose","okText","confirmLoading","footer","wrapClassName","cancelText","className","keyboard","maskClosable","mask","getContainer","closable"]);return(0,t.jsx)(a.Modal,l({mask:N,width:s||320,title:n,open:r,onOk:o,onCancel:i,wrapClassName:"".concat(v," base-modal"),centered:!0,afterClose:c,okText:d||"确定",cancelText:y||"取消",confirmLoading:h,footer:p,destroyOnClose:!0,className:w,keyboard:b,maskClosable:k,getContainer:R,closable:I},E,{children:u}))})},(e,n,r)=>{r.r(n)}],a={};function o(e){var n=a[e];if(void 0!==n)return n.exports;var r=a[e]={exports:{}};return t[e].call(r.exports,r,r.exports,o),r.exports}o.n=e=>{var n=e&&e.__esModule?()=>e.default:()=>e;return o.d(n,{a:n}),n},o.d=(e,n)=>{for(var r in n)o.o(n,r)&&!o.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:n[r]})},o.o=(e,n)=>Object.prototype.hasOwnProperty.call(e,n),o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var l={};(()=>{o.r(l),o.d(l,{BaseModal:()=>a.default,Cron:()=>e.default,CustomDrawer:()=>r.default,ErrorBoundary:()=>t.default,HocModal:()=>n.default});var e=o(1),n=o(7),r=o(8),t=o(10),a=o(11)})();const i=l.BaseModal,u=l.Cron,s=l.CustomDrawer,c=l.ErrorBoundary,d=l.HocModal;export{i as BaseModal,u as Cron,s as CustomDrawer,c as ErrorBoundary,d as HocModal};
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,n){"object"==typeof exports&&"object"==typeof module?module.exports=n(require("antd"),require("react"),require("react/jsx-runtime")):"function"==typeof define&&define.amd?define(["antd","react","react/jsx-runtime"],n):"object"==typeof exports?exports.MFYAllInOne=n(require("antd"),require("react"),require("react/jsx-runtime")):e.MFYAllInOne=n(e.antd,e.React,e["react/jsx-runtime"])}(this,(e,n,r)=>(()=>{"use strict";var t=[,(e,n,r)=>{r.r(n),r.d(n,{default:()=>d});var t=r(2),a=r(3),o=r(4),i=r(5),l=r(6),u=function(){return u=Object.assign||function(e){for(var n,r=1,t=arguments.length;r<t;r++)for(var a in n=arguments[r])Object.prototype.hasOwnProperty.call(n,a)&&(e[a]=n[a]);return e},u.apply(this,arguments)},s=["minute","hour","day","month","week"],c={display:"block",lineHeight:2};const d=(0,i.forwardRef)(function(e,n){var r=e.cronExpression,d=(0,i.useState)(""),m=d[0],h=d[1],f=(0,i.useState)({minute:1,hour:1,day:1,month:1,week:1}),p=f[0],x=f[1],v=(0,i.useState)({minute:{min:1,max:2},hour:{min:0,max:1},day:{min:1,max:2},month:{min:1,max:2},week:{min:2,max:3}}),y=v[0],j=v[1],w=(0,i.useState)({minute:{start:0,end:1},hour:{start:0,end:1},day:{start:1,end:1},month:{start:1,end:1},week:{start:1,end:1}}),C=w[0],b=w[1],g=(0,i.useState)({minute:[],hour:[],day:[],month:[],week:[]}),k=g[0],O=g[1],N=(0,i.useRef)(null),R=(0,i.useState)(void 0),S=R[0],I=R[1],T=function(e,n){switch(e){case"minute":return{minute:n};case"hour":return{hour:n};case"day":return{day:n};case"month":return{month:n};case"week":return{week:n};default:return{}}},z=function(){return m},E=function(){x({minute:1,hour:1,day:1,month:1,week:1}),j({minute:{min:1,max:2},hour:{min:0,max:1},day:{min:1,max:2},month:{min:1,max:2},week:{min:2,max:3}}),b({minute:{start:0,end:1},hour:{start:0,end:1},day:{start:1,end:1},month:{start:1,end:1},week:{start:1,end:1}}),O({minute:[],hour:[],day:[],month:[],week:[]}),h("")},P=function(e,n){for(var r=[],t=e;t<=n;t++)r.push({label:t,value:t});return r},F=function(e){for(var n=[],r=["","一","二","三","四","五","六","日"],t=1;t<=e;t++)n.push({label:"星期".concat(r[t]),value:t+1===8?7:t});return n},B=function(e,n){switch(n){case"week":x(u(u(u({},p),{day:2}),T(n,e.target.value)));break;case"day":x(u(u(u({},p),{week:2}),T(n,e.target.value)));break;default:x(u(u({},p),T(n,e.target.value)))}},M=function(e,n,r){var t,a;r(u(u({},k),((t={})[n]=e,t))),x(u(u({},p),((a={})[n]="point",a)))},D=function(e,n,r){var t=y;t[n]="max"===r?{max:e,min:t[n].min}:{max:t[n].max,min:e},j(u(u({},y),T(n,t[n])))},L=function(e,n,r){var t=C;t[n]="start"===r?{start:e,end:t[n].end}:{start:t[n].start,end:e},b(u(u({},C),T(n,t[n])))};return(0,i.useEffect)(function(){r?function(e){h(e);var n=e.split(" "),r={},t={},a={},o={};n.forEach(function(e,n){if(-1!==e.indexOf("/")&&-1!==e.indexOf("-")){r[s[n]]="loop";var i=e.split("/")[0],l=i.split("-")[0];a[s[n]]={start:"*"===i?0:Number(l),end:Number(e.split("/")[1])}}else-1!==e.indexOf("*")?r[s[n]]="*":-1!==e.indexOf("-")?(r[s[n]]="period",t[s[n]]={min:Number(e.split("-")[0]),max:Number(e.split("-")[1])}):(r[s[n]]="point",o[s[n]]=e.split(",").map(function(e){return Number(e)}))}),j(u(u({},y),t)),b(u(u({},C),a)),O(u(u({},k),o)),x(u(u({},p),r))}(r):E()},[r]),(0,i.useEffect)(function(){!function(){var e={};s.forEach(function(n){return e=u(u({},e),function(e){var n=p[e],r=y[e],t=C[e],a=k[e],o="";switch(n){case"*":default:o="*";break;case"point":for(var i=0,l=a;i<l.length;i++)o=o+l[i]+",";o=o.substring(0,o.length-1);break;case"period":o=r.min+"-"+r.max;break;case"loop":o=t.start+"-"+{minute:59,hour:23,day:31,month:12,week:7}[e]+"/"+t.end}return T(e,o)}(n))});var n=e.minute,r=e.hour,t=e.day,a=e.month,o=e.week;h(n+" "+r+" "+t+" "+a+" "+o)}()},[p,y,C]),(0,i.useImperativeHandle)(n,function(){return{refGetCron:z,resetCronState:E,getValidateStatus:function(){return S}}}),(0,i.useEffect)(function(){var e;!function(e){(0,o.isValidCron)(e)?null==I||I("success"):null==I||I("error")}(m),null===(e=N.current)||void 0===e||e.setFieldsValue({cronText:m})},[m]),(0,t.jsxs)("div",{className:l.default.Cron,children:[(0,t.jsx)(a.Tabs,{type:"card",items:[{label:"分",key:"minute",children:(0,t.jsx)(a.Card,{children:(0,t.jsxs)(a.Radio.Group,{value:p.minute,onChange:function(e){return B(e,"minute")},children:[(0,t.jsx)(a.Radio,{style:c,value:"*",children:"每分执行"}),(0,t.jsxs)(a.Radio,{style:c,value:"period",children:["周期从",(0,t.jsx)(a.InputNumber,{size:"small",min:0,max:58,value:y.minute.min,onChange:function(e){return D(e,"minute","min")}}),"-",(0,t.jsx)(a.InputNumber,{size:"small",min:2,max:59,value:y.minute.max,onChange:function(e){return D(e,"minute","max")}}),"分"]}),(0,t.jsxs)(a.Radio,{style:c,value:"loop",children:["从",(0,t.jsx)(a.InputNumber,{size:"small",min:0,max:58,value:C.minute.start,onChange:function(e){return L(e,"minute","start")}}),"分开始,每",(0,t.jsx)(a.InputNumber,{size:"small",min:1,max:58,value:C.minute.end,onChange:function(e){return L(e,"minute","end")}}),"分执行一次"]}),(0,t.jsxs)(a.Row,{children:[(0,t.jsx)(a.Radio,{style:c,value:"point",children:"指定"}),(0,t.jsx)(a.Col,{span:18,children:(0,t.jsx)(a.Select,{value:k.minute,style:{width:"80%",marginTop:7},mode:"multiple",allowClear:!0,placeholder:"请选择分钟",onChange:function(e){return M(e,"minute",O)},options:P(0,59)})})]})]})})},{label:"时",key:"hour",children:(0,t.jsx)(a.Card,{children:(0,t.jsxs)(a.Radio.Group,{onChange:function(e){return B(e,"hour")},value:p.hour,children:[(0,t.jsx)(a.Radio,{style:c,value:"*",children:"每小时执行"}),(0,t.jsxs)(a.Radio,{style:c,value:"period",children:["周期从",(0,t.jsx)(a.InputNumber,{size:"small",min:0,max:22,value:y.hour.min,onChange:function(e){return D(e,"hour","min")}}),"-",(0,t.jsx)(a.InputNumber,{size:"small",min:1,max:23,value:y.hour.max,onChange:function(e){return D(e,"hour","max")}}),"时"]}),(0,t.jsxs)(a.Radio,{style:c,value:"loop",children:["从",(0,t.jsx)(a.InputNumber,{size:"small",min:0,max:22,value:C.hour.start,onChange:function(e){return L(e,"hour","start")}}),"时开始,每",(0,t.jsx)(a.InputNumber,{size:"small",min:1,max:22,value:C.hour.end,onChange:function(e){return L(e,"hour","end")}}),"时执行一次"]}),(0,t.jsxs)(a.Row,{children:[(0,t.jsx)(a.Radio,{style:c,value:"point",children:"指定"}),(0,t.jsx)(a.Col,{span:18,children:(0,t.jsx)(a.Select,{value:k.hour,style:{width:"80%",marginTop:7},mode:"multiple",allowClear:!0,placeholder:"请选择小时",onChange:function(e){return M(e,"hour",O)},options:P(0,23)})})]})]})})},{label:"日",key:"day",children:(0,t.jsx)(a.Card,{children:(0,t.jsxs)(a.Radio.Group,{onChange:function(e){return B(e,"day")},value:p.day,children:[(0,t.jsx)(a.Radio,{style:c,value:"*",children:"每日执行"}),(0,t.jsxs)(a.Radio,{style:c,value:"period",children:["周期从",(0,t.jsx)(a.InputNumber,{size:"small",min:1,max:30,value:y.day.min,onChange:function(e){return D(e,"day","min")}}),"-",(0,t.jsx)(a.InputNumber,{size:"small",min:2,max:31,value:y.day.max,onChange:function(e){return D(e,"day","max")}}),"日"]}),(0,t.jsxs)(a.Radio,{style:c,value:"loop",children:["从",(0,t.jsx)(a.InputNumber,{size:"small",min:1,max:31,value:C.day.start,onChange:function(e){return L(e,"day","start")}}),"日开始,每",(0,t.jsx)(a.InputNumber,{size:"small",min:1,max:31,value:C.day.end,onChange:function(e){return L(e,"day","end")}}),"日执行一次"]}),(0,t.jsxs)(a.Row,{children:[(0,t.jsx)(a.Radio,{style:c,value:"point",children:"指定"}),(0,t.jsx)(a.Col,{span:18,children:(0,t.jsx)(a.Select,{value:k.day,style:{width:"80%",marginTop:7},mode:"multiple",allowClear:!0,placeholder:"请选择日期",onChange:function(e){return M(e,"day",O)},options:P(1,31)})})]})]})})},{label:"月",key:"month",children:(0,t.jsx)(a.Card,{children:(0,t.jsxs)(a.Radio.Group,{onChange:function(e){return B(e,"month")},value:p.month,children:[(0,t.jsx)(a.Radio,{style:c,value:"*",children:"每月执行"}),(0,t.jsxs)(a.Radio,{style:c,value:"period",children:["周期从",(0,t.jsx)(a.InputNumber,{size:"small",min:1,max:11,value:y.month.min,onChange:function(e){return D(e,"month","min")}}),"-",(0,t.jsx)(a.InputNumber,{size:"small",min:2,max:12,value:y.month.max,onChange:function(e){return D(e,"month","max")}}),"月"]}),(0,t.jsxs)(a.Radio,{style:c,value:"loop",children:["从",(0,t.jsx)(a.InputNumber,{size:"small",min:1,max:12,value:C.month.start,onChange:function(e){return L(e,"month","start")}}),"月开始,每",(0,t.jsx)(a.InputNumber,{size:"small",min:1,max:12,value:C.month.end,onChange:function(e){return L(e,"month","end")}}),"月执行一次"]}),(0,t.jsxs)(a.Row,{children:[(0,t.jsx)(a.Radio,{style:c,value:"point",children:"指定"}),(0,t.jsx)(a.Col,{span:18,children:(0,t.jsx)(a.Select,{value:k.month,style:{width:"80%",marginTop:7},mode:"multiple",allowClear:!0,placeholder:"请选择月份",onChange:function(e){return M(e,"month",O)},options:P(1,12)})})]})]})})},{label:"周",key:"week",children:(0,t.jsx)(a.Card,{children:(0,t.jsxs)(a.Radio.Group,{onChange:function(e){return B(e,"week")},value:p.week,children:[(0,t.jsx)(a.Radio,{style:c,value:"*",children:"每周执行"}),(0,t.jsxs)(a.Row,{children:[(0,t.jsx)(a.Col,{children:(0,t.jsx)(a.Radio,{style:c,value:"period",children:"周期从 周"})}),(0,t.jsx)(a.Col,{children:(0,t.jsx)(a.Select,{style:{marginTop:7},allowClear:!0,value:y.week.min,placeholder:"请选择周",onChange:function(e){return D(e,"week","min")},options:F(7)})}),(0,t.jsx)(a.Col,{className:l.default.CronWeekFont,children:"- 周"}),(0,t.jsx)(a.Col,{children:(0,t.jsx)(a.Select,{style:{marginTop:7},allowClear:!0,value:y.week.max,placeholder:"请选择周",onChange:function(e){return D(e,"week","max")},options:F(7)})})]}),(0,t.jsxs)(a.Row,{children:[(0,t.jsx)(a.Radio,{style:c,value:"point",children:"指定"}),(0,t.jsx)(a.Col,{span:18,children:(0,t.jsx)(a.Select,{value:k.week,style:{width:"80%",marginTop:7},mode:"multiple",allowClear:!0,placeholder:"请选择周",onChange:function(e){return M(e,"week",O)},options:F(7)})})]})]})})}]}),(0,t.jsx)(a.Form,{className:l.default.CronPreview,ref:N,children:(0,t.jsx)(a.Form.Item,{label:"预览",name:"cronText",className:l.default.CronPreviewItem,hasFeedback:!0,validateStatus:S,children:(0,t.jsx)(a.Input,{readOnly:!0,style:{width:150}})})})]})})},e=>{e.exports=r},n=>{n.exports=e},function(e,n){var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var n,r=1,t=arguments.length;r<t;r++)for(var a in n=arguments[r])Object.prototype.hasOwnProperty.call(n,a)&&(e[a]=n[a]);return e},r.apply(this,arguments)};Object.defineProperty(n,"__esModule",{value:!0}),n.isValidCron=void 0;var t=function(e){return/^\d+$/.test(e)?Number(e):NaN},a=function(e){return"?"===e},o=function(e,n,r){return e>=n&&e<=r},i=function(e,n,r){return-1===e.search(/[^\d-,\/*]/)&&e.split(",").every(function(e){var a=e.split("/");if(e.trim().endsWith("/"))return!1;if(a.length>2)return!1;var i=a[0],l=a[1];return function(e,n,r){var a=e.split("-");switch(a.length){case 1:return function(e){return"*"===e}(e)||o(t(e),n,r);case 2:var i=a.map(function(e){return t(e)}),l=i[0],u=i[1];return l<=u&&o(l,n,r)&&o(u,n,r);default:return!1}}(i,n,r)&&function(e){return void 0===e||-1===e.search(/[^\d]/)&&t(e)>0}(l)})},l={jan:"1",feb:"2",mar:"3",apr:"4",may:"5",jun:"6",jul:"7",aug:"8",sep:"9",oct:"10",nov:"11",dec:"12"},u={sun:"0",mon:"1",tue:"2",wed:"3",thu:"4",fri:"5",sat:"6"},s={alias:!1,seconds:!1,allowBlankDay:!1,allowSevenAsSunday:!1,allowNthWeekdayOfMonth:!1};n.isValidCron=function(e,n){var c=r(r({},s),n),d=function(e){return e.trim().split(/\s+/)}(e);if(d.length>(c.seconds?6:5)||d.length<5)return!1;var m=[];if(6===d.length){var h=d.shift();h&&m.push(function(e){return i(e,0,59)}(h))}var f=d[0],p=d[1],x=d[2],v=d[3],y=d[4];return m.push(function(e){return i(e,0,59)}(f)),m.push(function(e){return i(e,0,23)}(p)),m.push(function(e,n){return n&&a(e)||i(e,1,31)}(x,c.allowBlankDay)),m.push(function(e,n){if(-1!==e.search(/\/[a-zA-Z]/))return!1;if(n){var r=e.toLowerCase().replace(/[a-z]{3}/g,function(e){return void 0===l[e]?e:l[e]});return i(r,1,12)}return i(e,1,12)}(v,c.alias)),m.push(function(e,n){var r=n.allowBlankDay,l=n.alias,s=n.allowSevenAsSunday,c=n.allowNthWeekdayOfMonth;if(r&&a(e))return!0;if(!r&&a(e))return!1;if(-1!==e.search(/\/[a-zA-Z]/))return!1;var d=l?e.toLowerCase().replace(/[a-z]{3}/g,function(e){return void 0===u[e]?e:u[e]}):e,m=s?7:6,h=d.split("#");if(c&&h.length>=2){var f=h[0],p=h[1];return 0===h.slice(2).length&&o(t(p),1,5)&&o(t(f),0,m)}return i(d,0,m)}(y,c)),m.push(function(e,n,r){return!(r&&a(e)&&a(n))}(x,y,c.allowBlankDay)),m.every(Boolean)}},e=>{e.exports=n},(e,n,r)=>{r.r(n),r.d(n,{default:()=>t});const t={Cron:"vBb5040F",CronWeekFont:"O5XKllcf",CronPreview:"Ci4nV30W",CronPreviewItem:"y5qUyBlE"}},(e,n,r)=>{r.r(n),r.d(n,{default:()=>i});var t=r(2),a=r(5),o=function(){return o=Object.assign||function(e){for(var n,r=1,t=arguments.length;r<t;r++)for(var a in n=arguments[r])Object.prototype.hasOwnProperty.call(n,a)&&(e[a]=n[a]);return e},o.apply(this,arguments)};function i(e){return(0,a.forwardRef)(function(n,r){var i=(0,a.useState)(!1),l=i[0],u=i[1],s=(0,a.useRef)(null);(0,a.useImperativeHandle)(r,function(){return{show:function(e){s.current=e,u(!0)},hide:function(){u(!1)}}});var c=function(){u(!1)},d=(0,a.useMemo)(function(){return(0,t.jsx)(e,o({},n,{visible:l,handleCancel:c},s.current))},[l]);return(0,t.jsx)(t.Fragment,{children:l?d:null})})}},(e,n,r)=>{r.r(n),r.d(n,{default:()=>o});var t=r(2),a=r(3);r(9);const o=function(e){var n=e.title,r=e.open,o=e.onClose,i=e.onConfirm,l=e.children,u=e.width,s=e.closable,c=e.cancelText,d=e.okText,m=e.footer,h=e.className,f=e.extra,p=void 0===f?null:f,x=e.loading,v=void 0!==x&&x;return(0,t.jsx)(a.Drawer,{title:(0,t.jsx)("div",{style:{float:"left"},children:n}),placement:"right",className:h,closable:s,onClose:o,width:u,open:r,footer:m||(0,t.jsx)("div",{className:"custom-footer",children:(0,t.jsxs)(a.Space,{children:[(0,t.jsx)(a.Button,{onClick:o,children:c||"取消"}),(0,t.jsx)(a.Button,{type:"primary",onClick:i,children:d||"确定"})]})}),extra:p,loading:v,children:l})}},(e,n,r)=>{r.r(n)},(e,n,r)=>{r.r(n),r.d(n,{default:()=>i});var t=r(2),a=r(3),o=r(5);function i(e){var n=e.children,r=e.onError,i=(0,o.useState)({hasError:!1}),l=i[0],u=i[1],s=(0,o.useCallback)(function(e,n){u({hasError:!0,error:e,errorInfo:n}),r&&r(e,n),console.error("Error caught by boundary:",e,n)},[r]);return(0,o.useEffect)(function(){var e=function(e){s(e,{isAsync:!0,timestamp:(new Date).toISOString()})},n=function(n){n.preventDefault(),e(n.reason)},r=function(n){n.preventDefault(),e(n.error)};return window.addEventListener("unhandledrejection",n),window.addEventListener("error",r),function(){window.removeEventListener("unhandledrejection",n),window.removeEventListener("error",r)}},[s]),l.hasError&&l.error?(0,t.jsx)(t.Fragment,{children:(0,t.jsx)(a.Result,{status:"error",title:"System Failed",subTitle:"Please check and modify the following information before resubmitting.",extra:[(0,t.jsx)(a.Button,{type:"primary",onClick:function(){return window.location.reload()},children:"刷新页面"},"console")]})}):(0,t.jsx)(t.Fragment,{children:n})}},(e,n,r)=>{r.r(n),r.d(n,{default:()=>u});var t=r(2),a=r(3),o=r(5),i=r.n(o),l=(r(12),function(){return l=Object.assign||function(e){for(var n,r=1,t=arguments.length;r<t;r++)for(var a in n=arguments[r])Object.prototype.hasOwnProperty.call(n,a)&&(e[a]=n[a]);return e},l.apply(this,arguments)});const u=i().memo(function(e){var n=e.title,r=e.visible,o=e.onOk,i=e.onCancel,u=e.children,s=e.width,c=e.afterClose,d=e.okText,m=e.confirmLoading,h=void 0!==m&&m,f=e.footer,p=void 0===f?void 0:f,x=e.wrapClassName,v=void 0===x?"":x,y=e.cancelText,j=e.className,w=void 0===j?"":j,C=e.keyboard,b=void 0===C||C,g=e.maskClosable,k=void 0===g||g,O=e.mask,N=void 0===O||O,R=e.getContainer,S=e.closable,I=void 0===S||S,T=function(e,n){var r={};for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&n.indexOf(t)<0&&(r[t]=e[t]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var a=0;for(t=Object.getOwnPropertySymbols(e);a<t.length;a++)n.indexOf(t[a])<0&&Object.prototype.propertyIsEnumerable.call(e,t[a])&&(r[t[a]]=e[t[a]])}return r}(e,["title","visible","onOk","onCancel","children","width","afterClose","okText","confirmLoading","footer","wrapClassName","cancelText","className","keyboard","maskClosable","mask","getContainer","closable"]);return(0,t.jsx)(a.Modal,l({mask:N,width:s||320,title:n,open:r,onOk:o,onCancel:i,wrapClassName:"".concat(v," base-modal"),centered:!0,afterClose:c,okText:d||"确定",cancelText:y||"取消",confirmLoading:h,footer:p,destroyOnClose:!0,className:w,keyboard:b,maskClosable:k,getContainer:R,closable:I},T,{children:u}))})},(e,n,r)=>{r.r(n)}],a={};function o(e){var n=a[e];if(void 0!==n)return n.exports;var r=a[e]={exports:{}};return t[e].call(r.exports,r,r.exports,o),r.exports}o.n=e=>{var n=e&&e.__esModule?()=>e.default:()=>e;return o.d(n,{a:n}),n},o.d=(e,n)=>{for(var r in n)o.o(n,r)&&!o.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:n[r]})},o.o=(e,n)=>Object.prototype.hasOwnProperty.call(e,n),o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var i={};return(()=>{o.r(i),o.d(i,{BaseModal:()=>a.default,Cron:()=>e.default,CustomDrawer:()=>r.default,ErrorBoundary:()=>t.default,HocModal:()=>n.default});var e=o(1),n=o(7),r=o(8),t=o(10),a=o(11)})(),i})());
|
|
1
|
+
!function(e,n){"object"==typeof exports&&"object"==typeof module?module.exports=n(require("antd"),require("react"),require("react/jsx-runtime")):"function"==typeof define&&define.amd?define(["antd","react","react/jsx-runtime"],n):"object"==typeof exports?exports.MFYAllInOne=n(require("antd"),require("react"),require("react/jsx-runtime")):e.MFYAllInOne=n(e.antd,e.React,e["react/jsx-runtime"])}(this,(e,n,r)=>(()=>{"use strict";var t=[,(e,n,r)=>{r.r(n),r.d(n,{default:()=>d});var t=r(2),a=r(3),o=r(4),i=r(5),l=r(6),u=function(){return u=Object.assign||function(e){for(var n,r=1,t=arguments.length;r<t;r++)for(var a in n=arguments[r])Object.prototype.hasOwnProperty.call(n,a)&&(e[a]=n[a]);return e},u.apply(this,arguments)},s=["minute","hour","day","month","week"],c={display:"block",lineHeight:2};const d=(0,i.forwardRef)(function(e,n){var r=e.cronExpression,d=(0,i.useState)(""),m=d[0],h=d[1],f=(0,i.useState)({minute:1,hour:1,day:1,month:1,week:1}),p=f[0],x=f[1],v=(0,i.useState)({minute:{min:1,max:2},hour:{min:0,max:1},day:{min:1,max:2},month:{min:1,max:2},week:{min:2,max:3}}),y=v[0],j=v[1],w=(0,i.useState)({minute:{start:0,end:1},hour:{start:0,end:1},day:{start:1,end:1},month:{start:1,end:1},week:{start:1,end:1}}),C=w[0],b=w[1],g=(0,i.useState)({minute:[],hour:[],day:[],month:[],week:[]}),k=g[0],O=g[1],N=(0,i.useRef)(null),R=(0,i.useState)(void 0),S=R[0],I=R[1],T=function(e,n){switch(e){case"minute":return{minute:n};case"hour":return{hour:n};case"day":return{day:n};case"month":return{month:n};case"week":return{week:n};default:return{}}},z=function(){return m},E=function(){x({minute:1,hour:1,day:1,month:1,week:1}),j({minute:{min:1,max:2},hour:{min:0,max:1},day:{min:1,max:2},month:{min:1,max:2},week:{min:2,max:3}}),b({minute:{start:0,end:1},hour:{start:0,end:1},day:{start:1,end:1},month:{start:1,end:1},week:{start:1,end:1}}),O({minute:[],hour:[],day:[],month:[],week:[]}),h("")},P=function(e,n){for(var r=[],t=e;t<=n;t++)r.push({label:t,value:t});return r},F=function(e){for(var n=[],r=["","一","二","三","四","五","六","日"],t=1;t<=e;t++)n.push({label:"星期".concat(r[t]),value:t+1===8?7:t});return n},B=function(e,n){switch(n){case"week":x(u(u(u({},p),{day:2}),T(n,e.target.value)));break;case"day":x(u(u(u({},p),{week:2}),T(n,e.target.value)));break;default:x(u(u({},p),T(n,e.target.value)))}},M=function(e,n,r){var t,a;r(u(u({},k),((t={})[n]=e,t))),x(u(u({},p),((a={})[n]="point",a)))},D=function(e,n,r){var t=y;t[n]="max"===r?{max:e,min:t[n].min}:{max:t[n].max,min:e},j(u(u({},y),T(n,t[n])))},L=function(e,n,r){var t=C;t[n]="start"===r?{start:e,end:t[n].end}:{start:t[n].start,end:e},b(u(u({},C),T(n,t[n])))};return(0,i.useEffect)(function(){r?function(e){h(e);var n=e.split(" "),r={},t={},a={},o={};n.forEach(function(e,n){if(-1!==e.indexOf("/")&&-1!==e.indexOf("-")){r[s[n]]="loop";var i=e.split("/")[0],l=i.split("-")[0];a[s[n]]={start:"*"===i?0:Number(l),end:Number(e.split("/")[1])}}else-1!==e.indexOf("*")?r[s[n]]="*":-1!==e.indexOf("-")?(r[s[n]]="period",t[s[n]]={min:Number(e.split("-")[0]),max:Number(e.split("-")[1])}):(r[s[n]]="point",o[s[n]]=e.split(",").map(function(e){return Number(e)}))}),j(u(u({},y),t)),b(u(u({},C),a)),O(u(u({},k),o)),x(u(u({},p),r))}(r):E()},[r]),(0,i.useEffect)(function(){!function(){var e={};s.forEach(function(n){return e=u(u({},e),function(e){var n=p[e],r=y[e],t=C[e],a=k[e],o="";switch(n){case"*":default:o="*";break;case"point":for(var i=0,l=a;i<l.length;i++)o=o+l[i]+",";o=o.substring(0,o.length-1);break;case"period":o=r.min+"-"+r.max;break;case"loop":o=t.start+"-"+{minute:59,hour:23,day:31,month:12,week:7}[e]+"/"+t.end}return T(e,o)}(n))});var n=e.minute,r=e.hour,t=e.day,a=e.month,o=e.week;h(n+" "+r+" "+t+" "+a+" "+o)}()},[p,y,C]),(0,i.useImperativeHandle)(n,function(){return{refGetCron:z,resetCronState:E,getValidateStatus:function(){return S}}}),(0,i.useEffect)(function(){var e;!function(e){(0,o.isValidCron)(e)?null==I||I("success"):null==I||I("error")}(m),null===(e=N.current)||void 0===e||e.setFieldsValue({cronText:m})},[m]),(0,t.jsxs)("div",{className:l.default.Cron,children:[(0,t.jsx)(a.Tabs,{type:"card",items:[{label:"分",key:"minute",children:(0,t.jsx)(a.Card,{children:(0,t.jsxs)(a.Radio.Group,{value:p.minute,onChange:function(e){return B(e,"minute")},children:[(0,t.jsx)(a.Radio,{style:c,value:"*",children:"每分执行"}),(0,t.jsxs)(a.Radio,{style:c,value:"period",children:["周期从",(0,t.jsx)(a.InputNumber,{size:"small",min:0,max:58,value:y.minute.min,onChange:function(e){return D(e,"minute","min")}}),"-",(0,t.jsx)(a.InputNumber,{size:"small",min:2,max:59,value:y.minute.max,onChange:function(e){return D(e,"minute","max")}}),"分"]}),(0,t.jsxs)(a.Radio,{style:c,value:"loop",children:["从",(0,t.jsx)(a.InputNumber,{size:"small",min:0,max:58,value:C.minute.start,onChange:function(e){return L(e,"minute","start")}}),"分开始,每",(0,t.jsx)(a.InputNumber,{size:"small",min:1,max:58,value:C.minute.end,onChange:function(e){return L(e,"minute","end")}}),"分执行一次"]}),(0,t.jsxs)(a.Row,{children:[(0,t.jsx)(a.Radio,{style:c,value:"point",children:"指定"}),(0,t.jsx)(a.Col,{span:18,children:(0,t.jsx)(a.Select,{value:k.minute,style:{width:"80%",marginTop:7},mode:"multiple",allowClear:!0,placeholder:"请选择分钟",onChange:function(e){return M(e,"minute",O)},options:P(0,59)})})]})]})})},{label:"时",key:"hour",children:(0,t.jsx)(a.Card,{children:(0,t.jsxs)(a.Radio.Group,{onChange:function(e){return B(e,"hour")},value:p.hour,children:[(0,t.jsx)(a.Radio,{style:c,value:"*",children:"每小时执行"}),(0,t.jsxs)(a.Radio,{style:c,value:"period",children:["周期从",(0,t.jsx)(a.InputNumber,{size:"small",min:0,max:22,value:y.hour.min,onChange:function(e){return D(e,"hour","min")}}),"-",(0,t.jsx)(a.InputNumber,{size:"small",min:1,max:23,value:y.hour.max,onChange:function(e){return D(e,"hour","max")}}),"时"]}),(0,t.jsxs)(a.Radio,{style:c,value:"loop",children:["从",(0,t.jsx)(a.InputNumber,{size:"small",min:0,max:22,value:C.hour.start,onChange:function(e){return L(e,"hour","start")}}),"时开始,每",(0,t.jsx)(a.InputNumber,{size:"small",min:1,max:22,value:C.hour.end,onChange:function(e){return L(e,"hour","end")}}),"时执行一次"]}),(0,t.jsxs)(a.Row,{children:[(0,t.jsx)(a.Radio,{style:c,value:"point",children:"指定"}),(0,t.jsx)(a.Col,{span:18,children:(0,t.jsx)(a.Select,{value:k.hour,style:{width:"80%",marginTop:7},mode:"multiple",allowClear:!0,placeholder:"请选择小时",onChange:function(e){return M(e,"hour",O)},options:P(0,23)})})]})]})})},{label:"日",key:"day",children:(0,t.jsx)(a.Card,{children:(0,t.jsxs)(a.Radio.Group,{onChange:function(e){return B(e,"day")},value:p.day,children:[(0,t.jsx)(a.Radio,{style:c,value:"*",children:"每日执行"}),(0,t.jsxs)(a.Radio,{style:c,value:"period",children:["周期从",(0,t.jsx)(a.InputNumber,{size:"small",min:1,max:30,value:y.day.min,onChange:function(e){return D(e,"day","min")}}),"-",(0,t.jsx)(a.InputNumber,{size:"small",min:2,max:31,value:y.day.max,onChange:function(e){return D(e,"day","max")}}),"日"]}),(0,t.jsxs)(a.Radio,{style:c,value:"loop",children:["从",(0,t.jsx)(a.InputNumber,{size:"small",min:1,max:31,value:C.day.start,onChange:function(e){return L(e,"day","start")}}),"日开始,每",(0,t.jsx)(a.InputNumber,{size:"small",min:1,max:31,value:C.day.end,onChange:function(e){return L(e,"day","end")}}),"日执行一次"]}),(0,t.jsxs)(a.Row,{children:[(0,t.jsx)(a.Radio,{style:c,value:"point",children:"指定"}),(0,t.jsx)(a.Col,{span:18,children:(0,t.jsx)(a.Select,{value:k.day,style:{width:"80%",marginTop:7},mode:"multiple",allowClear:!0,placeholder:"请选择日期",onChange:function(e){return M(e,"day",O)},options:P(1,31)})})]})]})})},{label:"月",key:"month",children:(0,t.jsx)(a.Card,{children:(0,t.jsxs)(a.Radio.Group,{onChange:function(e){return B(e,"month")},value:p.month,children:[(0,t.jsx)(a.Radio,{style:c,value:"*",children:"每月执行"}),(0,t.jsxs)(a.Radio,{style:c,value:"period",children:["周期从",(0,t.jsx)(a.InputNumber,{size:"small",min:1,max:11,value:y.month.min,onChange:function(e){return D(e,"month","min")}}),"-",(0,t.jsx)(a.InputNumber,{size:"small",min:2,max:12,value:y.month.max,onChange:function(e){return D(e,"month","max")}}),"月"]}),(0,t.jsxs)(a.Radio,{style:c,value:"loop",children:["从",(0,t.jsx)(a.InputNumber,{size:"small",min:1,max:12,value:C.month.start,onChange:function(e){return L(e,"month","start")}}),"月开始,每",(0,t.jsx)(a.InputNumber,{size:"small",min:1,max:12,value:C.month.end,onChange:function(e){return L(e,"month","end")}}),"月执行一次"]}),(0,t.jsxs)(a.Row,{children:[(0,t.jsx)(a.Radio,{style:c,value:"point",children:"指定"}),(0,t.jsx)(a.Col,{span:18,children:(0,t.jsx)(a.Select,{value:k.month,style:{width:"80%",marginTop:7},mode:"multiple",allowClear:!0,placeholder:"请选择月份",onChange:function(e){return M(e,"month",O)},options:P(1,12)})})]})]})})},{label:"周",key:"week",children:(0,t.jsx)(a.Card,{children:(0,t.jsxs)(a.Radio.Group,{onChange:function(e){return B(e,"week")},value:p.week,children:[(0,t.jsx)(a.Radio,{style:c,value:"*",children:"每周执行"}),(0,t.jsxs)(a.Row,{children:[(0,t.jsx)(a.Col,{children:(0,t.jsx)(a.Radio,{style:c,value:"period",children:"周期从 周"})}),(0,t.jsx)(a.Col,{children:(0,t.jsx)(a.Select,{style:{marginTop:7},allowClear:!0,value:y.week.min,placeholder:"请选择周",onChange:function(e){return D(e,"week","min")},options:F(7)})}),(0,t.jsx)(a.Col,{className:l.default.CronWeekFont,children:"- 周"}),(0,t.jsx)(a.Col,{children:(0,t.jsx)(a.Select,{style:{marginTop:7},allowClear:!0,value:y.week.max,placeholder:"请选择周",onChange:function(e){return D(e,"week","max")},options:F(7)})})]}),(0,t.jsxs)(a.Row,{children:[(0,t.jsx)(a.Radio,{style:c,value:"point",children:"指定"}),(0,t.jsx)(a.Col,{span:18,children:(0,t.jsx)(a.Select,{value:k.week,style:{width:"80%",marginTop:7},mode:"multiple",allowClear:!0,placeholder:"请选择周",onChange:function(e){return M(e,"week",O)},options:F(7)})})]})]})})}]}),(0,t.jsx)(a.Form,{className:l.default.CronPreview,ref:N,children:(0,t.jsx)(a.Form.Item,{label:"预览",name:"cronText",className:l.default.CronPreviewItem,hasFeedback:!0,validateStatus:S,children:(0,t.jsx)(a.Input,{readOnly:!0,style:{width:150}})})})]})})},e=>{e.exports=r},n=>{n.exports=e},function(e,n){var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var n,r=1,t=arguments.length;r<t;r++)for(var a in n=arguments[r])Object.prototype.hasOwnProperty.call(n,a)&&(e[a]=n[a]);return e},r.apply(this,arguments)};Object.defineProperty(n,"__esModule",{value:!0}),n.isValidCron=void 0;var t=function(e){return/^\d+$/.test(e)?Number(e):NaN},a=function(e){return"?"===e},o=function(e,n,r){return e>=n&&e<=r},i=function(e,n,r){return-1===e.search(/[^\d-,\/*]/)&&e.split(",").every(function(e){var a=e.split("/");if(e.trim().endsWith("/"))return!1;if(a.length>2)return!1;var i=a[0],l=a[1];return function(e,n,r){var a=e.split("-");switch(a.length){case 1:return function(e){return"*"===e}(e)||o(t(e),n,r);case 2:var i=a.map(function(e){return t(e)}),l=i[0],u=i[1];return l<=u&&o(l,n,r)&&o(u,n,r);default:return!1}}(i,n,r)&&function(e){return void 0===e||-1===e.search(/[^\d]/)&&t(e)>0}(l)})},l={jan:"1",feb:"2",mar:"3",apr:"4",may:"5",jun:"6",jul:"7",aug:"8",sep:"9",oct:"10",nov:"11",dec:"12"},u={sun:"0",mon:"1",tue:"2",wed:"3",thu:"4",fri:"5",sat:"6"},s={alias:!1,seconds:!1,allowBlankDay:!1,allowSevenAsSunday:!1,allowNthWeekdayOfMonth:!1};n.isValidCron=function(e,n){var c=r(r({},s),n),d=function(e){return e.trim().split(/\s+/)}(e);if(d.length>(c.seconds?6:5)||d.length<5)return!1;var m=[];if(6===d.length){var h=d.shift();h&&m.push(function(e){return i(e,0,59)}(h))}var f=d[0],p=d[1],x=d[2],v=d[3],y=d[4];return m.push(function(e){return i(e,0,59)}(f)),m.push(function(e){return i(e,0,23)}(p)),m.push(function(e,n){return n&&a(e)||i(e,1,31)}(x,c.allowBlankDay)),m.push(function(e,n){if(-1!==e.search(/\/[a-zA-Z]/))return!1;if(n){var r=e.toLowerCase().replace(/[a-z]{3}/g,function(e){return void 0===l[e]?e:l[e]});return i(r,1,12)}return i(e,1,12)}(v,c.alias)),m.push(function(e,n){var r=n.allowBlankDay,l=n.alias,s=n.allowSevenAsSunday,c=n.allowNthWeekdayOfMonth;if(r&&a(e))return!0;if(!r&&a(e))return!1;if(-1!==e.search(/\/[a-zA-Z]/))return!1;var d=l?e.toLowerCase().replace(/[a-z]{3}/g,function(e){return void 0===u[e]?e:u[e]}):e,m=s?7:6,h=d.split("#");if(c&&h.length>=2){var f=h[0],p=h[1];return 0===h.slice(2).length&&o(t(p),1,5)&&o(t(f),0,m)}return i(d,0,m)}(y,c)),m.push(function(e,n,r){return!(r&&a(e)&&a(n))}(x,y,c.allowBlankDay)),m.every(Boolean)}},e=>{e.exports=n},(e,n,r)=>{r.r(n),r.d(n,{default:()=>t});const t={Cron:"vBb5040F",CronWeekFont:"O5XKllcf",CronPreview:"Ci4nV30W",CronPreviewItem:"y5qUyBlE"}},(e,n,r)=>{r.r(n),r.d(n,{default:()=>i});var t=r(2),a=r(5),o=function(){return o=Object.assign||function(e){for(var n,r=1,t=arguments.length;r<t;r++)for(var a in n=arguments[r])Object.prototype.hasOwnProperty.call(n,a)&&(e[a]=n[a]);return e},o.apply(this,arguments)};function i(e){return(0,a.forwardRef)(function(n,r){var i=(0,a.useState)(!1),l=i[0],u=i[1],s=(0,a.useRef)(null);(0,a.useImperativeHandle)(r,function(){return{show:function(e){s.current=e,u(!0)},hide:function(){u(!1)}}});var c=function(){u(!1)},d=(0,a.useMemo)(function(){return(0,t.jsx)(e,o({},n,{visible:l,handleCancel:c},s.current))},[l]);return(0,t.jsx)(t.Fragment,{children:l?d:null})})}},(e,n,r)=>{r.r(n),r.d(n,{default:()=>o});var t=r(2),a=r(3);r(9);const o=function(e){var n=e.title,r=e.open,o=e.onClose,i=e.onConfirm,l=e.children,u=e.width,s=e.closable,c=e.cancelText,d=e.okText,m=e.footer,h=e.className,f=e.extra,p=void 0===f?null:f,x=e.loading,v=void 0!==x&&x;return(0,t.jsx)(a.Drawer,{title:(0,t.jsx)("div",{style:{float:"left"},children:n}),placement:"right",className:h,closable:s,onClose:o,width:u,open:r,footer:m||(0,t.jsx)("div",{className:"custom-footer",children:(0,t.jsxs)(a.Space,{children:[(0,t.jsx)(a.Button,{onClick:o,children:c||"取消"}),(0,t.jsx)(a.Button,{type:"primary",onClick:i,children:d||"确定"})]})}),extra:p,loading:v,children:l})}},(e,n,r)=>{r.r(n)},(e,n,r)=>{r.r(n),r.d(n,{default:()=>i});var t=r(2),a=r(3),o=r(5);function i(e){var n=e.children,r=e.onError,i=(0,o.useState)({hasError:!1}),l=i[0],u=i[1],s=(0,o.useCallback)(function(e,n){u({hasError:!0,error:e,errorInfo:n}),r&&r(e,n),console.error("Error caught by boundary:",e,n)},[r]);return(0,o.useEffect)(function(){var e=function(e){s(e,{isAsync:!0,timestamp:(new Date).toISOString()})},n=function(n){n.preventDefault(),e(n.reason)},r=function(n){n.preventDefault(),e(n.error)};return window.addEventListener("unhandledrejection",n),window.addEventListener("error",r),function(){window.removeEventListener("unhandledrejection",n),window.removeEventListener("error",r)}},[s]),l.hasError&&l.error?(0,t.jsx)(t.Fragment,{children:(0,t.jsx)(a.Result,{status:"error",title:"System Failed",subTitle:"Please check and modify the following information before resubmitting.",extra:[(0,t.jsx)(a.Button,{type:"primary",onClick:function(){return window.location.reload()},children:"刷新页面"},"console")]})}):(0,t.jsx)(t.Fragment,{children:n})}},(e,n,r)=>{r.r(n),r.d(n,{default:()=>l});var t=r(2),a=r(3),o=r(5),i=(r(12),function(){return i=Object.assign||function(e){for(var n,r=1,t=arguments.length;r<t;r++)for(var a in n=arguments[r])Object.prototype.hasOwnProperty.call(n,a)&&(e[a]=n[a]);return e},i.apply(this,arguments)});const l=(0,o.memo)(function(e){var n=e.title,r=e.visible,o=e.onOk,l=e.onCancel,u=e.children,s=e.width,c=e.afterClose,d=e.okText,m=e.confirmLoading,h=void 0!==m&&m,f=e.footer,p=void 0===f?void 0:f,x=e.wrapClassName,v=void 0===x?"":x,y=e.cancelText,j=e.className,w=void 0===j?"":j,C=e.keyboard,b=void 0===C||C,g=e.maskClosable,k=void 0===g||g,O=e.mask,N=void 0===O||O,R=e.getContainer,S=e.closable,I=void 0===S||S,T=function(e,n){var r={};for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&n.indexOf(t)<0&&(r[t]=e[t]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var a=0;for(t=Object.getOwnPropertySymbols(e);a<t.length;a++)n.indexOf(t[a])<0&&Object.prototype.propertyIsEnumerable.call(e,t[a])&&(r[t[a]]=e[t[a]])}return r}(e,["title","visible","onOk","onCancel","children","width","afterClose","okText","confirmLoading","footer","wrapClassName","cancelText","className","keyboard","maskClosable","mask","getContainer","closable"]);return(0,t.jsx)(a.Modal,i({mask:N,width:s||320,title:n,open:r,onOk:o,onCancel:l,wrapClassName:"".concat(v," base-modal"),centered:!0,afterClose:c,okText:d||"确定",cancelText:y||"取消",confirmLoading:h,footer:p,destroyOnClose:!0,className:w,keyboard:b,maskClosable:k,getContainer:R,closable:I},T,{children:u}))})},(e,n,r)=>{r.r(n)}],a={};function o(e){var n=a[e];if(void 0!==n)return n.exports;var r=a[e]={exports:{}};return t[e].call(r.exports,r,r.exports,o),r.exports}o.n=e=>{var n=e&&e.__esModule?()=>e.default:()=>e;return o.d(n,{a:n}),n},o.d=(e,n)=>{for(var r in n)o.o(n,r)&&!o.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:n[r]})},o.o=(e,n)=>Object.prototype.hasOwnProperty.call(e,n),o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var i={};return(()=>{o.r(i),o.d(i,{BaseModal:()=>a.default,Cron:()=>e.default,CustomDrawer:()=>r.default,ErrorBoundary:()=>t.default,HocModal:()=>n.default});var e=o(1),n=o(7),r=o(8),t=o(10),a=o(11)})(),i})());
|
package/package.json
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mingfuyun/star-allinone",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.8",
|
|
4
4
|
"description": "星系运维前端能力包",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
|
+
"bin": {
|
|
7
|
+
"star-allinone": "scripts/cli.js"
|
|
8
|
+
},
|
|
6
9
|
"types": "dist/index.d.ts",
|
|
7
10
|
"style": "dist/index.css",
|
|
8
11
|
"exports": {
|
|
@@ -25,12 +28,16 @@
|
|
|
25
28
|
},
|
|
26
29
|
"files": [
|
|
27
30
|
"dist",
|
|
28
|
-
"README.md"
|
|
31
|
+
"README.md",
|
|
32
|
+
"scripts/cli.js",
|
|
33
|
+
"skills"
|
|
29
34
|
],
|
|
30
35
|
"scripts": {
|
|
31
36
|
"build": "webpack --env format=umd --mode=none && webpack --env format=esm --mode=none",
|
|
32
37
|
"publish": "node scripts/publish.js",
|
|
33
38
|
"publish:dev": "node scripts/publish.js --dev",
|
|
39
|
+
"skills:sync": "node scripts/cli.js skills sync",
|
|
40
|
+
"skills:list": "node scripts/cli.js skills list",
|
|
34
41
|
"prepublishOnly": "npm run build",
|
|
35
42
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
36
43
|
"dev": "webpack --mode=none --watch",
|
package/scripts/cli.js
ADDED
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
const os = require('os');
|
|
5
|
+
const path = require('path');
|
|
6
|
+
|
|
7
|
+
const root = path.resolve(__dirname, '..');
|
|
8
|
+
const skillsRoot = path.join(root, 'skills', 'shared');
|
|
9
|
+
const DEFAULT_PREFIX = 'shared-';
|
|
10
|
+
const CUSTOM_PREFIX = 'custom-';
|
|
11
|
+
|
|
12
|
+
function readJson(file) {
|
|
13
|
+
return JSON.parse(fs.readFileSync(file, 'utf8'));
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function usage() {
|
|
17
|
+
console.log(`Usage:
|
|
18
|
+
star-allinone skills list
|
|
19
|
+
star-allinone skills sync [--target <dir>] [--dry-run]
|
|
20
|
+
|
|
21
|
+
Run the command from a business project containing .star-allinone.json.
|
|
22
|
+
|
|
23
|
+
Sync writes package skills/shared/* to <project>/.agents/skills/shared-*.
|
|
24
|
+
It never writes ~/.codex/skills and never modifies custom-* skills.`);
|
|
25
|
+
process.exitCode = 1;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function listSharedSkillNames() {
|
|
29
|
+
if (!fs.existsSync(skillsRoot)) return [];
|
|
30
|
+
return fs.readdirSync(skillsRoot, { withFileTypes: true })
|
|
31
|
+
.filter((entry) => entry.isDirectory())
|
|
32
|
+
.map((entry) => entry.name)
|
|
33
|
+
.sort();
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function listSkills() {
|
|
37
|
+
const skills = listSharedSkillNames();
|
|
38
|
+
if (!skills.length) {
|
|
39
|
+
console.log('No shared skills found.');
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
for (const name of skills) {
|
|
43
|
+
console.log(`${name} -> ${DEFAULT_PREFIX}${name}`);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function parseArgs(args) {
|
|
48
|
+
const options = { dryRun: false };
|
|
49
|
+
const positional = [];
|
|
50
|
+
for (let index = 0; index < args.length; index += 1) {
|
|
51
|
+
const arg = args[index];
|
|
52
|
+
if (arg === '--dry-run') options.dryRun = true;
|
|
53
|
+
else if (arg === '--target') options.target = args[++index];
|
|
54
|
+
else positional.push(arg);
|
|
55
|
+
}
|
|
56
|
+
return { options, positional };
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function render(content, variables) {
|
|
60
|
+
return content.replace(/\{\{\s*([\w.-]+)\s*\}\}/g, (_, key) => {
|
|
61
|
+
const value = key.split('.').reduce((current, part) => current?.[part], variables);
|
|
62
|
+
if (value === undefined || value === null) {
|
|
63
|
+
throw new Error(`Missing template variable: ${key}`);
|
|
64
|
+
}
|
|
65
|
+
return String(value);
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function publicSkillName(skillName, prefix) {
|
|
70
|
+
return `${prefix}${skillName}`;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function assertSafeDestination(destination) {
|
|
74
|
+
const normalized = path.resolve(destination);
|
|
75
|
+
const codexSkills = path.resolve(os.homedir(), '.codex', 'skills');
|
|
76
|
+
if (normalized === codexSkills || normalized.startsWith(`${codexSkills}${path.sep}`)) {
|
|
77
|
+
throw new Error('Refusing to write to ~/.codex/skills');
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
const TEMPLATE_EXT = new Set(['.md', '.json', '.yml', '.yaml', '.txt']);
|
|
82
|
+
|
|
83
|
+
function copyTree(source, target, variables, options, relativeRoot) {
|
|
84
|
+
for (const entry of fs.readdirSync(source, { withFileTypes: true })) {
|
|
85
|
+
const sourcePath = path.join(source, entry.name);
|
|
86
|
+
const targetPath = path.join(target, entry.name);
|
|
87
|
+
if (entry.isDirectory()) {
|
|
88
|
+
if (!options.dryRun) fs.mkdirSync(targetPath, { recursive: true });
|
|
89
|
+
copyTree(sourcePath, targetPath, variables, options, relativeRoot);
|
|
90
|
+
continue;
|
|
91
|
+
}
|
|
92
|
+
const relativePath = path.relative(relativeRoot, targetPath);
|
|
93
|
+
console.log(`${options.dryRun ? '[dry-run] ' : ''}${relativePath}`);
|
|
94
|
+
if (options.dryRun) continue;
|
|
95
|
+
fs.mkdirSync(path.dirname(targetPath), { recursive: true });
|
|
96
|
+
const ext = path.extname(entry.name).toLowerCase();
|
|
97
|
+
if (TEMPLATE_EXT.has(ext)) {
|
|
98
|
+
fs.writeFileSync(targetPath, render(fs.readFileSync(sourcePath, 'utf8'), variables));
|
|
99
|
+
} else {
|
|
100
|
+
fs.copyFileSync(sourcePath, targetPath);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
function copySkill(source, destination, skillName, prefix, variables, options) {
|
|
106
|
+
const publicName = publicSkillName(skillName, prefix);
|
|
107
|
+
if (publicName.startsWith(CUSTOM_PREFIX)) {
|
|
108
|
+
throw new Error(`Public skill prefix cannot be "${CUSTOM_PREFIX}"`);
|
|
109
|
+
}
|
|
110
|
+
const skillTarget = path.join(destination, publicName);
|
|
111
|
+
if (!options.dryRun) {
|
|
112
|
+
fs.rmSync(skillTarget, { recursive: true, force: true });
|
|
113
|
+
fs.mkdirSync(skillTarget, { recursive: true });
|
|
114
|
+
}
|
|
115
|
+
copyTree(source, skillTarget, { ...variables, sharedSkillName: publicName }, options, destination);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
function pruneStaleShared(destination, prefix, syncedNames, options) {
|
|
119
|
+
if (!fs.existsSync(destination)) return;
|
|
120
|
+
for (const entry of fs.readdirSync(destination, { withFileTypes: true })) {
|
|
121
|
+
if (!entry.isDirectory()) continue;
|
|
122
|
+
if (entry.name.startsWith(CUSTOM_PREFIX)) continue;
|
|
123
|
+
if (!entry.name.startsWith(prefix)) continue;
|
|
124
|
+
if (syncedNames.includes(entry.name)) continue;
|
|
125
|
+
const relativePath = path.relative(destination, path.join(destination, entry.name));
|
|
126
|
+
console.log(`${options.dryRun ? '[dry-run] ' : ''}remove stale ${relativePath}`);
|
|
127
|
+
if (!options.dryRun) {
|
|
128
|
+
fs.rmSync(path.join(destination, entry.name), { recursive: true, force: true });
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
function selectedSharedSkills(config) {
|
|
134
|
+
const available = listSharedSkillNames();
|
|
135
|
+
if (!config.sharedSkills) return available;
|
|
136
|
+
const missing = config.sharedSkills.filter((name) => !available.includes(name));
|
|
137
|
+
if (missing.length) {
|
|
138
|
+
throw new Error(`Unknown sharedSkills: ${missing.join(', ')}`);
|
|
139
|
+
}
|
|
140
|
+
return available.filter((name) => config.sharedSkills.includes(name));
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
function syncProject(options) {
|
|
144
|
+
const target = path.resolve(options.target || process.cwd());
|
|
145
|
+
const configFile = path.join(target, '.star-allinone.json');
|
|
146
|
+
if (!fs.existsSync(configFile)) throw new Error(`Missing project config: ${configFile}`);
|
|
147
|
+
const config = readJson(configFile);
|
|
148
|
+
const prefix = config.publicSkillPrefix || DEFAULT_PREFIX;
|
|
149
|
+
const destination = path.join(target, '.agents', 'skills');
|
|
150
|
+
assertSafeDestination(destination);
|
|
151
|
+
|
|
152
|
+
const variables = { ...config, ...config.variables, project: { ...config, ...config.variables } };
|
|
153
|
+
const skills = selectedSharedSkills(config);
|
|
154
|
+
const syncedNames = skills.map((name) => publicSkillName(name, prefix));
|
|
155
|
+
|
|
156
|
+
if (!options.dryRun) fs.mkdirSync(destination, { recursive: true });
|
|
157
|
+
for (const skillName of skills) {
|
|
158
|
+
copySkill(path.join(skillsRoot, skillName), destination, skillName, prefix, variables, options);
|
|
159
|
+
}
|
|
160
|
+
pruneStaleShared(destination, prefix, syncedNames, options);
|
|
161
|
+
console.log(`${options.dryRun ? 'Would sync' : 'Synced'} shared skills -> ${destination}`);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
function main() {
|
|
165
|
+
const [group, command, ...rest] = process.argv.slice(2);
|
|
166
|
+
if (group !== 'skills') return usage();
|
|
167
|
+
if (command === 'list') return listSkills();
|
|
168
|
+
if (command !== 'sync') return usage();
|
|
169
|
+
const { options, positional } = parseArgs(rest);
|
|
170
|
+
if (positional.length) return usage();
|
|
171
|
+
syncProject(options);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
try {
|
|
175
|
+
main();
|
|
176
|
+
} catch (error) {
|
|
177
|
+
console.error(`Error: ${error.message}`);
|
|
178
|
+
process.exitCode = 1;
|
|
179
|
+
}
|