现在代码上传逻辑存在问题
This commit is contained in:
@@ -5,7 +5,10 @@ class BaseView {
|
||||
constructor(extensionUri) {
|
||||
this.extensionUri = extensionUri;
|
||||
}
|
||||
getStyles() {
|
||||
/**
|
||||
* 获取通用的样式和脚本
|
||||
*/
|
||||
getBaseStylesAndScripts() {
|
||||
return `
|
||||
<style>
|
||||
body {
|
||||
@@ -169,6 +172,94 @@ class BaseView {
|
||||
}
|
||||
</style>
|
||||
<script>
|
||||
// 对话框工具函数
|
||||
function showConfirmDialog(title, message, onConfirm, onCancel) {
|
||||
const overlay = document.createElement('div');
|
||||
overlay.className = 'modal-overlay';
|
||||
overlay.id = 'confirmModal';
|
||||
|
||||
overlay.innerHTML = \`
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-title">\${title}</div>
|
||||
<div>\${message}</div>
|
||||
<div class="modal-buttons">
|
||||
<button class="modal-btn modal-btn-secondary" onclick="closeConfirmDialog(false)">取消</button>
|
||||
<button class="modal-btn modal-btn-primary" onclick="closeConfirmDialog(true)">确定</button>
|
||||
</div>
|
||||
</div>
|
||||
\`;
|
||||
|
||||
document.body.appendChild(overlay);
|
||||
|
||||
window.confirmCallback = function(result) {
|
||||
if (result && onConfirm) {
|
||||
onConfirm();
|
||||
} else if (!result && onCancel) {
|
||||
onCancel();
|
||||
}
|
||||
delete window.confirmCallback;
|
||||
};
|
||||
}
|
||||
|
||||
function closeConfirmDialog(result) {
|
||||
const modal = document.getElementById('confirmModal');
|
||||
if (modal) {
|
||||
modal.remove();
|
||||
}
|
||||
if (window.confirmCallback) {
|
||||
window.confirmCallback(result);
|
||||
}
|
||||
}
|
||||
|
||||
function showPromptDialog(title, message, defaultValue, onConfirm) {
|
||||
const overlay = document.createElement('div');
|
||||
overlay.className = 'modal-overlay';
|
||||
overlay.id = 'promptModal';
|
||||
|
||||
overlay.innerHTML = \`
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-title">\${title}</div>
|
||||
<div>\${message}</div>
|
||||
<input type="text" id="promptInput" value="\${defaultValue}" style="width: 100%; margin: 10px 0; padding: 6px; background: var(--vscode-input-background); color: var(--vscode-input-foreground); border: 1px solid var(--vscode-input-border);">
|
||||
<div class="modal-buttons">
|
||||
<button class="modal-btn modal-btn-secondary" onclick="closePromptDialog(null)">取消</button>
|
||||
<button class="modal-btn modal-btn-primary" onclick="closePromptDialog(document.getElementById('promptInput').value)">确定</button>
|
||||
</div>
|
||||
</div>
|
||||
\`;
|
||||
|
||||
document.body.appendChild(overlay);
|
||||
|
||||
setTimeout(() => {
|
||||
const input = document.getElementById('promptInput');
|
||||
if (input) {
|
||||
input.focus();
|
||||
input.select();
|
||||
}
|
||||
}, 100);
|
||||
|
||||
window.promptCallback = onConfirm;
|
||||
}
|
||||
|
||||
function closePromptDialog(result) {
|
||||
const modal = document.getElementById('promptModal');
|
||||
if (modal) {
|
||||
modal.remove();
|
||||
}
|
||||
if (window.promptCallback) {
|
||||
window.promptCallback(result);
|
||||
}
|
||||
delete window.promptCallback;
|
||||
}
|
||||
</script>
|
||||
`;
|
||||
}
|
||||
/**
|
||||
* 获取仓库选择对话框的脚本(仅ConfigView需要)
|
||||
*/
|
||||
getRepoSelectScript() {
|
||||
return `
|
||||
<script>
|
||||
(function () {
|
||||
// 避免在同一个 Webview 中重复注册
|
||||
if (window.__dcspRepoDialogInitialized) {
|
||||
@@ -201,7 +292,7 @@ class BaseView {
|
||||
|
||||
var noRepoTip = '';
|
||||
if (!hasRepos) {
|
||||
noRepoTip = '<div style="margin-top:8px; font-size:12px; color: var(--vscode-descriptionForeground);">当前配置中没有仓库,请先在“仓库配置”中添加。</div>';
|
||||
noRepoTip = '<div style="margin-top:8px; font-size:12px; color: var(--vscode-descriptionForeground);">当前配置中没有仓库,请先在"仓库配置"中添加。</div>';
|
||||
}
|
||||
|
||||
overlay.innerHTML =
|
||||
@@ -228,7 +319,6 @@ class BaseView {
|
||||
|
||||
if (cancelBtn) {
|
||||
cancelBtn.addEventListener('click', function () {
|
||||
// 通知后端取消,清理可能的状态(例如待上传的本地文件夹)
|
||||
if (typeof vscode !== 'undefined') {
|
||||
vscode.postMessage({
|
||||
type: 'repoSelectCanceled'
|
||||
@@ -271,6 +361,12 @@ class BaseView {
|
||||
</script>
|
||||
`;
|
||||
}
|
||||
/**
|
||||
* 获取样式(被子类覆盖)
|
||||
*/
|
||||
getStyles() {
|
||||
return this.getBaseStylesAndScripts();
|
||||
}
|
||||
}
|
||||
exports.BaseView = BaseView;
|
||||
//# sourceMappingURL=BaseView.js.map
|
||||
Reference in New Issue
Block a user