Compare commits

...

3 Commits

Author SHA1 Message Date
2ba85992fd Merge branch 'main' into feature/trae-ide-support
All checks were successful
DevStar Studio CI/CD Pipeline / DevStarStudio-CICD-Pipeline (pull_request) Successful in 39m13s
2025-12-31 01:47:13 +00:00
99e17f6a1d feat: add cmd parameter to IDE URLs for correct CLI command
Some checks failed
DevStar Studio CI/CD Pipeline / DevStarStudio-CICD-Pipeline (pull_request) Failing after 27m1s
2025-12-29 23:44:41 +08:00
be212c6c24 feat: add Trae IDE support to DevContainer
Some checks failed
DevStar Studio CI/CD Pipeline / DevStarStudio-CICD-Pipeline (pull_request) Failing after 28m8s
2025-12-29 17:37:56 +08:00
2 changed files with 25 additions and 7 deletions

View File

@@ -152,9 +152,10 @@ func GetDevContainerDetails(ctx *context.Context) {
}
terminalURL, err := devcontainer_service.Get_IDE_TerminalURL(ctx, ctx.Doer, ctx.Repo)
if err == nil {
ctx.Data["VSCodeUrl"] = "vscode" + terminalURL
ctx.Data["CursorUrl"] = "cursor" + terminalURL
ctx.Data["WindsurfUrl"] = "windsurf" + terminalURL
ctx.Data["VSCodeUrl"] = "vscode" + terminalURL + "&cmd=code"
ctx.Data["CursorUrl"] = "cursor" + terminalURL + "&cmd=cursor"
ctx.Data["WindsurfUrl"] = "windsurf" + terminalURL + "&cmd=windsurf"
ctx.Data["TraeUrl"] = "trae" + terminalURL + "&cmd=trae"
}
}
// 3. 携带数据渲染页面,返回
@@ -187,7 +188,7 @@ func GetDevContainerStatus(ctx *context.Context) {
log.Info("%v\n", err)
}
var vscodeUrl, cursorUrl, windsurfUrl string
var vscodeUrl, cursorUrl, windsurfUrl, traeUrl string
// 增加对 ctx.Doer、ctx.Repo、ctx.Repo.Repository 的检查,避免出现空指针异常
// 只在第一次状态变为 "4" 时生成 URL避免频繁调用导致 token 被删除,随 Session 过期(默认 24 小时)
// 通过检查 session 中是否已有 terminal_url 来判断是否是第一次
@@ -198,14 +199,16 @@ func GetDevContainerStatus(ctx *context.Context) {
// 第一次状态为 "4",生成 URL 并缓存
terminalURL, err := devcontainer_service.Get_IDE_TerminalURL(ctx, ctx.Doer, ctx.Repo)
if err == nil {
vscodeUrl = "vscode" + terminalURL
cursorUrl = "cursor" + terminalURL
windsurfUrl = "windsurf" + terminalURL
vscodeUrl = "vscode" + terminalURL + "&cmd=code"
cursorUrl = "cursor" + terminalURL + "&cmd=cursor"
windsurfUrl = "windsurf" + terminalURL + "&cmd=windsurf"
traeUrl = "trae" + terminalURL + "&cmd=trae"
// 缓存 URL 到 session
ctx.Session.Set("terminal_urls", map[string]string{
"vscodeUrl": vscodeUrl,
"cursorUrl": cursorUrl,
"windsurfUrl": windsurfUrl,
"traeUrl": traeUrl,
})
}
} else {
@@ -214,6 +217,7 @@ func GetDevContainerStatus(ctx *context.Context) {
vscodeUrl = urls["vscodeUrl"]
cursorUrl = urls["cursorUrl"]
windsurfUrl = urls["windsurfUrl"]
traeUrl = urls["traeUrl"]
}
} else {
// 状态不是 "4" 或 ctx.Doer 为 nil清除缓存的 URL
@@ -225,6 +229,7 @@ func GetDevContainerStatus(ctx *context.Context) {
"vscodeUrl": vscodeUrl,
"cursorUrl": cursorUrl,
"windsurfUrl": windsurfUrl,
"traeUrl": traeUrl,
})
}

View File

@@ -62,6 +62,7 @@
<div style=" display: none;" id="vsTerminal" class="item"><a class="flex-text-inline" style="color:black; " onclick="window.location.href = '{{.VSCodeUrl}}'">{{svg "octicon-code" 14}}open with VSCode</a ></div>
<div style=" display: none;" id="cursorTerminal" class="item"><a class="flex-text-inline" style="color:black; " onclick="window.location.href = '{{.CursorUrl}}'">{{svg "octicon-code" 14}}open with Cursor</a ></div>
<div style=" display: none;" id="windsurfTerminal" class="item"><a class="flex-text-inline" style="color:black;" onclick="window.location.href = '{{.WindsurfUrl}}'">{{svg "octicon-code" 14}}open with Windsurf</a ></div>
<div style=" display: none;" id="traeTerminal" class="item"><a class="flex-text-inline" style="color:black;" onclick="window.location.href = '{{.TraeUrl}}'">{{svg "octicon-code" 14}}open with Trae</a ></div>
{{end}}
@@ -126,6 +127,7 @@ const webTerminal = document.getElementById('webTerminal');
const vsTerminal = document.getElementById('vsTerminal');
const cursorTerminal = document.getElementById('cursorTerminal');
const windsurfTerminal = document.getElementById('windsurfTerminal');
const traeTerminal = document.getElementById('traeTerminal');
const webTerminalContainer = document.getElementById('webTerminalContainer');
const loadingElement = document.getElementById('loading');
@@ -157,6 +159,9 @@ function concealElement(){
if (windsurfTerminal) {
windsurfTerminal.style.display = 'none';
}
if (traeTerminal) {
traeTerminal.style.display = 'none';
}
if (webTerminalContainer) {
webTerminalContainer.style.display = 'none';
}
@@ -190,6 +195,10 @@ function displayElement(){
if (windsurfTerminal) {
windsurfTerminal.style.display = 'block';
}
if (traeTerminal) {
traeTerminal.style.display = 'block';
}
if (webTerminalContainer) {
webTerminalContainer.style.display = 'block';
}
@@ -255,6 +264,10 @@ function getStatus() {
const windsurfBtn = document.querySelector('#windsurfTerminal a');
if (windsurfBtn) windsurfBtn.onclick = function(e) { e.preventDefault(); window.location.href = data.windsurfUrl; };
}
if (data.traeUrl) {
const traeBtn = document.querySelector('#traeTerminal a');
if (traeBtn) traeBtn.onclick = function(e) { e.preventDefault(); window.location.href = data.traeUrl; };
}
displayElement();
if (loadingElement) {
loadingElement.style.display = 'none';