@yorha2b-lab/autodev 2.1.7 → 2.1.9

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yorha2b-lab/autodev",
3
- "version": "2.1.7",
3
+ "version": "2.1.9",
4
4
  "description": "基于视觉大模型的前端(react+Antd)全自动 CRUD 代码生成器",
5
5
  "bin": {
6
6
  "autodev": "bin/autodev.js"
@@ -85,7 +85,21 @@ const bootSequence = async version => {
85
85
  * @param {number} duration - 持续时间(毫秒)
86
86
  * @returns {void}
87
87
  */
88
- const matrixEffect = (duration = 1500) => {
88
+ const matrixEffect = async (duration = 1500) => {
89
+
90
+ let currentTotal = 0
91
+ const MIRROR_URL = 'https://cdn.jsdelivr.net/gh/yorha2b-lab/auto-crud-copilot@github-repo-stats/bunker-stats.json'
92
+
93
+ try {
94
+ const controller = new AbortController()
95
+ const timeoutId = setTimeout(() => controller.abort(), 800)
96
+ const response = await fetch(MIRROR_URL, { signal: controller.signal })
97
+ const stats = await response.json()
98
+ currentTotal = stats.total_clones || 0
99
+ clearTimeout(timeoutId)
100
+ } catch (e) {
101
+ currentTotal = 0
102
+ }
89
103
 
90
104
  const coreFragments = [
91
105
  '47 4c 4f 52 59', // GLORY
@@ -99,13 +113,25 @@ const matrixEffect = (duration = 1500) => {
99
113
  '5f 43 4f 44 45 5f' // _CODE_
100
114
  ]
101
115
 
102
- const width = process.stdout.columns || 80
103
116
  const endTime = Date.now() + duration
117
+ const isLegendary = currentTotal >= 3000
118
+ const width = process.stdout.columns || 80
119
+
120
+ if (isLegendary) {
121
+ coreFragments.push(chalk.yellow.bold('33 30 30 30 2b')) // "3000+" 的十六进制
122
+ coreFragments.push(chalk.yellow.bold('4c 45 47 45 4e 44')) // "LEGEND"
123
+ }
104
124
 
105
125
  const interval = setInterval(() => {
106
126
  if (Date.now() > endTime) {
107
127
  clearInterval(interval)
108
128
  console.log(chalk.white(' [System] ') + chalk.green(language('所有构筑数据已同步至 Bunker 存储节点。', 'All data synced to Bunker storage nodes.')))
129
+ if (isLegendary) {
130
+ console.log(chalk.yellow.bold(language(` [Achievement] 物理克隆总数已超越 3000 战略阈值!当前战力:${currentTotal}`, ` [Achievement] Physical clone count has exceeded 3000 strategic threshold! Current power: ${currentTotal}`)))
131
+ console.log(chalk.yellow(language(' [Bunker] 恭喜指挥官,您的构筑协议已成为人类荣光的一部分。', ' [Bunker] Congratulations, your construction protocol is now part of humanity.')))
132
+ } else {
133
+ console.log(chalk.cyan(language(` [System] 当前构筑总数:${currentTotal}。距离 3000 勋章还剩 ${3000 - currentTotal} 次。`, ` [System] Current clones: ${currentTotal}. ${3000 - currentTotal} to Achievement.`)))
134
+ }
109
135
  console.log(chalk.cyan(language(' [System] 如果它能帮您节省时间,请在 GitHub 上给它点个赞 ⭐。', ' [System] If it saves you time, feel free to give it a ⭐ on GitHub.')))
110
136
  console.log(chalk.cyan('\n[System] Signal Lost. Glory to Mankind.\n'))
111
137
  process.exit(0)
@@ -118,7 +144,7 @@ const matrixEffect = (duration = 1500) => {
118
144
  line += chalk.white.bold(frag) + ' '
119
145
  } else {
120
146
  const hex = Math.floor(Math.random() * 256).toString(16).padStart(2, '0').toUpperCase()
121
- const color = Math.random() > 0.5 ? chalk.cyan : chalk.cyan.dim
147
+ const color = (isLegendary && Math.random() > 0.95) ? chalk.yellow : (Math.random() > 0.5 ? chalk.cyan : chalk.cyan.dim)
122
148
  line += color(hex) + ' '
123
149
  }
124
150
  }
@@ -43,8 +43,6 @@ export const MyModalForm = ({ width, title, submit, record, visible, setModal, l
43
43
  }
44
44
  } catch (error) {
45
45
  console.log('表单校验失败:', error)
46
- } finally {
47
- setPending(false)
48
46
  }
49
47
  }
50
48
 
@@ -1,3 +1,4 @@
1
+ import { useState } from 'react'
1
2
  import { MyTable } from './MyTable'
2
3
  import { Modal, Space, Button } from 'antd'
3
4
  import { MySearchForm } from './MySearchForm'
@@ -6,6 +7,8 @@ import { useTableQuery } from '../hooks/useTableQuery'
6
7
 
7
8
  export const MyModalTable = ({ api, onOk, title, width, footer, visible, columns, setModal, formItems, rowSelection, formatResponse, functionButtons, extraParams = {} }) => {
8
9
 
10
+ const [pending, setPending] = useState(false)
11
+
9
12
  const { total, loading, dataSource, search, setSearch } = useTableQuery(api, formatResponse, extraParams)
10
13
 
11
14
  const handleSearch = values => setSearch({ ...search, ...values, pageNo: 1 })
@@ -14,13 +17,19 @@ export const MyModalTable = ({ api, onOk, title, width, footer, visible, columns
14
17
 
15
18
  const handleOk = () => {
16
19
  if (onOk) {
17
- onOk()
20
+ try {
21
+ setPending(true)
22
+ onOk()
23
+ setPending(false)
24
+ } catch (error) {
25
+ console.log('操作失败:', error)
26
+ }
18
27
  }
19
28
  setModal({ visible: false })
20
29
  }
21
30
 
22
31
  return (
23
- <Modal centered destroyOnClose title={title} width={width} open={visible} onOk={handleOk} footer={footer} onCancel={() => setModal({ visible: false })}>
32
+ <Modal centered destroyOnClose title={title} width={width} open={visible} onOk={handleOk} footer={footer} onCancel={() => setModal({ visible: false })} confirmLoading={pending}>
24
33
  {formItems?.length > 0 && <MySearchForm search={search} formItems={formItems} setSearch={handleSearch} syncUrlParams={false} />}
25
34
  {functionButtons?.length > 0 && <Space>{functionButtons.map(item => <Button key={item.name} type={item.type} onClick={item.onClick}>{item.name}</Button>)}</Space>}
26
35
  <MyTable
@@ -1,5 +1,5 @@
1
- import { useState } from 'react'
2
1
  import { initOSS } from '../utils/utils'
2
+ import { useState, useEffect } from 'react'
3
3
  import { UploadOutlined } from '@ant-design/icons'
4
4
  import { Button, Tree, Radio, Input, Upload, Select, Cascader, Checkbox, DatePicker, InputNumber, TreeSelect, AutoComplete } from 'antd'
5
5
 
@@ -18,6 +18,12 @@ const AliyunOSSUpload = ({ value, onChange, ...restProps }) => {
18
18
  }
19
19
  }
20
20
 
21
+ useEffect(() => {
22
+ if (!OSSData) {
23
+ init()
24
+ }
25
+ }, [])
26
+
21
27
  const handleChange = ({ fileList }) => onChange?.([...fileList])
22
28
 
23
29
  const onRemove = file => {
@@ -35,10 +41,10 @@ const AliyunOSSUpload = ({ value, onChange, ...restProps }) => {
35
41
 
36
42
  const beforeUpload = async file => {
37
43
  const expire = Number(OSSData.expire) * 1000
38
- if (expire < Date.now() || !OSSData) {
44
+ if (expire < Date.now()) {
39
45
  await init()
40
46
  }
41
- file.url = `${OSSData.dir ?? path}/${file.uid}_${file.name}`.replace(/\/\//g, '/')
47
+ file.url = `${OSSData?.dir ?? path}/${file.uid}_${file.name}`.replace(/\/\//g, '/')
42
48
  return file
43
49
  }
44
50