diff --git a/src/components/dashboard/PublishModal.tsx b/src/components/dashboard/PublishModal.tsx index 9f65df6..4fc049f 100644 --- a/src/components/dashboard/PublishModal.tsx +++ b/src/components/dashboard/PublishModal.tsx @@ -93,8 +93,8 @@ export function PublishModal({ project, onClose }: Props) { if (needGitignore) steps.push({ label: "生成 .gitignore", status: "pending" }); steps.push({ label: "在 GitHub 创建远端仓库", status: "pending" }); - if (needInit || scan.has_changes) { - steps.push({ label: `提交本地代码(${commitMsg})`, status: "pending" }); + if (needInit) { + steps.push({ label: `初始化并提交代码(${commitMsg})`, status: "pending" }); } steps.push({ label: "配置 origin remote", status: "pending" }); steps.push({ label: `推送到 GitHub (${branch})`, status: "pending" }); @@ -133,8 +133,8 @@ export function PublishModal({ project, onClose }: Props) { cloneUrl = await githubCreateRepo(repoName, repoDesc, isPrivate); updateLog(logIdx++, "ok", cloneUrl); - // 3. 提交本地代码(需要 init 或有改动) - const needCommit = !scan.has_git || !scan.has_commits || scan.has_changes; + // 3. 全新项目:git init + 提交所有文件 + const needCommit = !scan.has_git || !scan.has_commits; if (needCommit) { updateLog(logIdx, "pending", "git add & commit…"); await gitInitAndCommit(localPath, commitMsg); @@ -304,46 +304,48 @@ export function PublishModal({ project, onClose }: Props) { )} - {/* 改动文件预览 */} - {(() => { - const needCommit = !scan.has_git || !scan.has_commits || scan.has_changes; - if (!needCommit) return null; - return ( -
- {scan.has_changes ? ( - <> -

待提交文件({scan.changed_files.length} 个)

-
- {scan.changed_files.slice(0, 50).map((f, i) => ( -
- {f.status} - {f.path} -
- ))} - {scan.changed_files.length > 50 && ( -

…还有 {scan.changed_files.length - 50} 个文件

- )} -
- - ) : ( -

- {!scan.has_git ? "全新项目,将执行 git init 并提交所有文件" : "无历史提交,将提交当前所有文件"} -

+ {/* 未提交内容:阻断发布 */} + {scan.has_changes && ( +
+

+ ⚠ 存在 {scan.changed_files.length} 个未提交文件,请先提交后再发布 +

+
+ {scan.changed_files.slice(0, 50).map((f, i) => ( +
+ {f.status} + {f.path} +
+ ))} + {scan.changed_files.length > 50 && ( +

…还有 {scan.changed_files.length - 50} 个文件

)} -
- - setCommitMsg(e.target.value)} - /> -
- ); - })()} +

+ 请在 VSCodeClaude 中完成提交,然后重新扫描。 +

+
+ )} + + {/* 全新项目提示(无 git / 无提交记录,但工作区干净) */} + {!scan.has_changes && (!scan.has_git || !scan.has_commits) && ( +
+

+ {!scan.has_git ? "全新项目:将自动执行 git init 并提交所有文件" : "尚无提交记录:将自动提交当前所有文件"} +

+
+ + setCommitMsg(e.target.value)} + /> +
+
+ )} {/* GitHub 仓库配置 */}
@@ -430,6 +432,7 @@ export function PublishModal({ project, onClose }: Props) { onClick={handleExecute} disabled={ !repoName.trim() || + scan.has_changes || (scan.suspicious_files.length > 0 && !confirmedSensitive) } className="px-4 py-2 text-sm bg-blue-600 text-white rounded-lg hover:bg-blue-700 disabled:opacity-50"