@yangrunchi/a_6 1.0.0

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.
@@ -0,0 +1,132 @@
1
+ const fs = require('fs');
2
+ const { exec } = require('child_process');
3
+ const path = require('path');
4
+
5
+ // 读取配置
6
+ const configPath = path.join(__dirname, 'A1_996_config.json');
7
+ let config = {};
8
+
9
+ try {
10
+ const configContent = fs.readFileSync(configPath, 'utf-8');
11
+ config = JSON.parse(configContent);
12
+ } catch (err) {
13
+ console.error(`Config error: ${err.message}`);
14
+ process.exit(1);
15
+ }
16
+
17
+ // 检查开关
18
+ if (config.watchEnabled === false) {
19
+ console.log(`[WATCH] Disabled by config`);
20
+ process.exit(0);
21
+ }
22
+
23
+ const watchDir = path.join(__dirname, '../../../dev/GUIExport');
24
+ const generateScript = path.join(__dirname, 'A2_generate-panel.js');
25
+
26
+ console.log(`[WATCH] Directory: ${watchDir}`);
27
+ console.log(`[WATCH] Press Ctrl+C to stop\n`);
28
+
29
+ // 存储定时器和最后触发时间
30
+ const timers = new Map();
31
+ const lastTriggerTime = new Map();
32
+ let isGenerating = false;
33
+
34
+ // 执行生成
35
+ function runGenerator(fullPath, filename) {
36
+ if (isGenerating) {
37
+ console.log(`[WAIT] Still generating previous file, skipping: ${filename}`);
38
+ return;
39
+ }
40
+
41
+ isGenerating = true;
42
+ // console.log(`\n[🚀 START] Processing: ${filename}`);
43
+
44
+ exec(`node "${generateScript}" "${fullPath}"`, (error, stdout, stderr) => {
45
+ if (error) console.error(`[EXEC ERROR] ${error.message}`);
46
+ if (stdout) console.log(stdout);
47
+ if (stderr && !stderr.includes('deprecated')) console.error(stderr);
48
+ console.log(`[✅ DONE] Finished: ${filename}\n`);
49
+ isGenerating = false;
50
+ });
51
+ }
52
+
53
+ // 防抖处理 - 延迟执行,合并多次触发
54
+ function debouncedGenerate(fullPath, filename) {
55
+ // 清除之前的定时器
56
+ if (timers.has(filename)) {
57
+ clearTimeout(timers.get(filename));
58
+ console.log(`[DEBOUNCE] Reset timer for: ${filename}`);
59
+ }
60
+
61
+ // 设置新的定时器
62
+ const timer = setTimeout(() => {
63
+ timers.delete(filename);
64
+ runGenerator(fullPath, filename);
65
+ }, 500); // 500ms 内的多次保存只执行最后一次
66
+
67
+ timers.set(filename, timer);
68
+ }
69
+
70
+ fs.watch(watchDir, { recursive: true }, (eventType, filename) => {
71
+ if (!filename) return;
72
+
73
+ // 提取纯文件名
74
+ const baseName = path.basename(filename);
75
+
76
+ // 只处理 .lua 文件的变化
77
+ if (!filename.endsWith('.lua')) {
78
+ return;
79
+ }
80
+
81
+ // 只处理 change 事件,忽略 rename 等其他事件
82
+ if (eventType !== 'change') {
83
+ return;
84
+ }
85
+
86
+ // 检查文件名是否以 UI、UISub、UIMain 开头
87
+ const hasUIPrefix = baseName.startsWith('UI');
88
+ const hasUISubPrefix = baseName.startsWith('UISub');
89
+ const hasUIMainPrefix = baseName.startsWith('UIMain');
90
+
91
+ const isValidUI = hasUIPrefix || hasUISubPrefix || hasUIMainPrefix;
92
+
93
+ if (!isValidUI) {
94
+ // 非 UI 文件,不输出日志避免刷屏(可选)
95
+ // console.log(`[SKIP] Not a UI file: ${baseName}`);
96
+ return;
97
+ }
98
+
99
+ const now = Date.now();
100
+ const lastTime = lastTriggerTime.get(filename) || 0;
101
+
102
+ // 1秒内同一个文件的事件只处理一次
103
+ if (now - lastTime < 1000) {
104
+ // console.log(`[IGNORE] Too frequent: ${baseName}`);
105
+ return;
106
+ }
107
+ lastTriggerTime.set(filename, now);
108
+
109
+ const fullPath = path.join(watchDir, filename);
110
+
111
+ // 检查文件是否存在
112
+ if (!fs.existsSync(fullPath)) {
113
+ return;
114
+ }
115
+
116
+ console.log(`[📝 SAVED] ${filename} at ${new Date().toLocaleTimeString()}`);
117
+
118
+ // 使用防抖处理
119
+ debouncedGenerate(fullPath, filename);
120
+ });
121
+
122
+ console.log('[WATCH] Started. Waiting for file saves...\n');
123
+
124
+ // 优雅退出
125
+ process.on('SIGINT', () => {
126
+ console.log('\n[WATCH] Stopping...');
127
+ // 清理所有定时器
128
+ for (const timer of timers.values()) {
129
+ clearTimeout(timer);
130
+ }
131
+ process.exit(0);
132
+ });
@@ -0,0 +1,31 @@
1
+ -- 作者: {AUTHOR}
2
+ -- 日期: {DATETIME}
3
+ -- 版本: 1.0
4
+ -- 描述: {CLASSNAME}
5
+
6
+ local {CLASSNAME} = {}
7
+
8
+ -- 对象的唯一ID
9
+ {CLASSNAME}.__cname = "{CLASSNAME}"
10
+
11
+ -------------------------------↓↓↓ UI操作 ↓↓↓---------------------------------------
12
+ --打开UI
13
+ function {CLASSNAME}:main(objcfg)
14
+ local parent = GUI:Win_Create(self.__cname, 0, 0, 0, 0, false, false, true, false)
15
+ GUI:LoadExport(parent, objcfg.UI_PATH)
16
+ self.ui = GUI:ui_delegate(parent)
17
+ self._parent = parent
18
+ end
19
+
20
+ function {CLASSNAME}:Dispose()
21
+
22
+ end
23
+
24
+ --初始化事件
25
+ function {CLASSNAME}:InitEvent()
26
+ -- GUI:addOnClickEvent(self.ui.btn_xxx, function()
27
+ -- -- 点击事件处理
28
+ -- end)
29
+ end
30
+
31
+ return {CLASSNAME}
@@ -0,0 +1,30 @@
1
+ -- 作者: {AUTHOR}
2
+ -- 日期: {DATETIME}
3
+ -- 版本: 1.0
4
+ -- 描述: {CLASSNAME}
5
+
6
+ local {CLASSNAME} = {}
7
+
8
+ -- 对象的唯一ID
9
+ {CLASSNAME}.__cname = "{CLASSNAME}"
10
+
11
+ -------------------------------↓↓↓ UI操作 ↓↓↓---------------------------------------
12
+ --打开UI
13
+ function {CLASSNAME}:main(objcfg, data, parent_ui)
14
+ self.ui = parent_ui
15
+ self._parent = GUI:getParent(parent_ui.Page_Layer)
16
+ self:InitEvent()
17
+ end
18
+
19
+ function {CLASSNAME}:Dispose()
20
+
21
+ end
22
+
23
+ --初始化事件
24
+ function {CLASSNAME}:InitEvent()
25
+ -- GUI:addOnClickEvent(self.ui.btn_xxx, function()
26
+ -- -- 点击事件处理
27
+ -- end)
28
+ end
29
+
30
+ return {CLASSNAME}
@@ -0,0 +1,9 @@
1
+ {
2
+ "excludeModules": [
3
+ "test",
4
+ "SwitchCareer",
5
+ "DailyOnline",
6
+ "SignIn",
7
+ "Recycle",
8
+ ]
9
+ }
@@ -0,0 +1,30 @@
1
+ -- 作者: {AUTHOR}
2
+ -- 日期: {DATETIME}
3
+ -- 版本: 1.0
4
+ -- 描述: {CLASSNAME}
5
+
6
+ -- 声明该类,便于IDE提供代码提示
7
+ ---@class {CLASSNAME}
8
+ local {CLASSNAME} = {}
9
+
10
+ -- 对象的唯一ID
11
+ {CLASSNAME}.__cname = "{CLASSNAME}"
12
+ {CLASSNAME}.NAME = {CLASSNAME}.__cname
13
+
14
+ function {CLASSNAME}:ctor()
15
+ self.name = "nil" --名字
16
+ --注册协议
17
+ ssrMessage:RegisterNetMsg(ssrNetMsgCfg.{MODULE_NAME}, self)
18
+ end
19
+
20
+ --------------------------------自动生成 ↓↓↓ 请求方法 ↓↓↓ start---------------------------------------
21
+ {REQUEST_METHODS}
22
+ --------------------------------自动生成 ↓↓↓ 请求方法 ↓↓↓ end---------------------------------------
23
+
24
+ --------------------------------自动生成 ↓↓↓ 响应方法 ↓↓↓ start---------------------------------------
25
+ {RESPONSE_METHODS}
26
+ --------------------------------自动生成 ↓↓↓ 响应方法 ↓↓↓ end---------------------------------------
27
+
28
+ {CLASSNAME}:ctor()
29
+
30
+ return {CLASSNAME}
@@ -0,0 +1,25 @@
1
+ -- 作者: {AUTHOR}
2
+ -- 日期: {DATETIME}
3
+ -- 版本: 1.0
4
+ -- 描述: funcData 统一管理器
5
+
6
+ -- Auto-generated. Do not edit manually.
7
+ ---@class ssrFuncDataMgr
8
+ local ssrFuncDataMgr = {}
9
+
10
+ ssrFuncDataMgr.__cname = "ssrFuncDataMgr"
11
+ ssrFuncDataMgr.NAME = ssrFuncDataMgr.__cname
12
+
13
+ function ssrFuncDataMgr:ctor()
14
+
15
+ --------------------------------自动注册数据类名 csvcfg ↓↓↓ start---------------------------------------
16
+
17
+ {REQUIRE_LINES}
18
+
19
+ --------------------------------自动注册数据类名 csvcfg ↓↓↓ start---------------------------------------
20
+
21
+ end
22
+
23
+ ssrFuncDataMgr:ctor()
24
+
25
+ return ssrFuncDataMgr