Skip to content

Commit 2ab98f2

Browse files
投稿自动分类:基于代码关键词自动修正分类
1 parent ec5ed7d commit 2ab98f2

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

.github/workflows/approve_submission.yml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,20 @@ jobs:
115115
'小组件': 'widgets', 'Widgets': 'widgets', 'widgets': 'widgets',
116116
'其他': 'other', 'Other': 'other', 'other': 'other'
117117
};
118-
const catId = catMap[category] || 'basic';
118+
let catId = catMap[category] || 'basic';
119+
120+
// 4b. 基于代码关键词自动修正分类
121+
const codeForClassify = scriptContents.map(s => s.content).join('\n');
122+
if (/\bimport\s+scene\b|from\s+scene\s+import\b|scene\.run\s*\(/.test(codeForClassify)) {
123+
catId = 'games';
124+
core.info(`PR #${pr.number}: Auto-classified as "games" (detected scene module)`);
125+
} else if (/\bimport\s+ui\b|from\s+ui\s+import\b|\.present\s*\(/.test(codeForClassify)) {
126+
catId = 'ui';
127+
core.info(`PR #${pr.number}: Auto-classified as "ui" (detected ui module)`);
128+
} else if (/from\s+widget\s+import\b|__WIDGET_LAYOUT__|Widget\s*\(/.test(codeForClassify)) {
129+
catId = 'widgets';
130+
core.info(`PR #${pr.number}: Auto-classified as "widgets" (detected widget module)`);
131+
}
119132
120133
// 5. 基于最新 main 重建分支
121134
execSync('git checkout main', { stdio: 'pipe' });

0 commit comments

Comments
 (0)