Skip to content

Commit 257fd26

Browse files
Copilotsj817
andcommitted
Address code review feedback and improve code quality
- Removed unnecessary onChange handler in checkbox (use readOnly instead) - Improved plugin type detection logic (check exports, type, scoped packages) - Replaced alert() with redirect to token-setup.html for better UX - All linting and build checks pass Co-authored-by: sj817 <74231782+sj817@users.noreply.github.com>
1 parent 81ae9a7 commit 257fd26

File tree

2 files changed

+12
-15
lines changed

2 files changed

+12
-15
lines changed

web/src/App.jsx

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,13 @@ function App() {
2727
if (code) {
2828
// In a production app, you would exchange this code for an access token
2929
// using a backend service (can't expose client secret in frontend)
30-
// For demo purposes, we'll simulate this with a note
30+
// For demo purposes, we'll redirect to the token setup page
3131
console.log('OAuth code received:', code);
32-
alert(
33-
'注意:在生产环境中,需要配置后端服务来处理 OAuth 回调。\n' +
34-
'当前为演示模式,请使用个人访问令牌进行测试。\n\n' +
35-
'获取个人访问令牌:\n' +
36-
'1. 访问 https://github.com/settings/tokens\n' +
37-
'2. 生成新令牌(需要 repo 和 read:user 权限)\n' +
38-
'3. 在控制台输入:localStorage.setItem("github_token", "YOUR_TOKEN")\n' +
39-
'4. 刷新页面'
40-
);
41-
// Clean up URL
32+
33+
// Clean up URL and redirect to token setup
4234
window.history.replaceState({}, document.title, window.location.pathname);
35+
window.location.href = './token-setup.html';
36+
return;
4337
}
4438

4539
setLoading(false);

web/src/components/SubmissionPage.jsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,12 @@ const SubmissionPage = ({ accessToken, user, onLogout }) => {
142142
}
143143

144144
// Check if it's a single JS file (app type)
145-
// For now, we'll check if the package type is determined by file structure
146-
// This is a simplified check - you might need to adjust based on your needs
147-
const isAppType = !repo.packageJson.main && !repo.packageJson.module;
145+
// More robust detection: check for main/module/exports and package type
146+
const isAppType = !packageName.startsWith('@') && // Not scoped package
147+
!repo.packageJson.main &&
148+
!repo.packageJson.module &&
149+
!repo.packageJson.exports &&
150+
repo.packageJson.type !== 'module';
148151

149152
if (!isAppType) {
150153
// Check npm package exists
@@ -243,7 +246,7 @@ const SubmissionPage = ({ accessToken, user, onLogout }) => {
243246
<input
244247
type="checkbox"
245248
checked={isSelected}
246-
onChange={() => {}}
249+
readOnly
247250
className="repo-checkbox"
248251
/>
249252
<div className="repo-info">

0 commit comments

Comments
 (0)