Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
B
bit-pm
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
燕伟桐
bit-pm
Commits
cc0ab0fd
提交
cc0ab0fd
authored
4月 18, 2025
作者:
Will Chen
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Reload env path instead of restarting dyad app after node.js install
上级
8d9aab21
显示空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
61 行增加
和
23 行删除
+61
-23
SetupBanner.tsx
src/components/SetupBanner.tsx
+45
-16
node_handlers.ts
src/ipc/handlers/node_handlers.ts
+13
-4
ipc_client.ts
src/ipc/ipc_client.ts
+2
-2
preload.ts
src/preload.ts
+1
-1
没有找到文件。
src/components/SetupBanner.tsx
浏览文件 @
cc0ab0fd
...
@@ -21,6 +21,12 @@ import {
...
@@ -21,6 +21,12 @@ import {
import
{
Button
}
from
"@/components/ui/button"
;
import
{
Button
}
from
"@/components/ui/button"
;
import
{
cn
}
from
"@/lib/utils"
;
import
{
cn
}
from
"@/lib/utils"
;
import
{
NodeSystemInfo
}
from
"@/ipc/ipc_types"
;
import
{
NodeSystemInfo
}
from
"@/ipc/ipc_types"
;
type
NodeInstallStep
=
|
"install"
|
"waiting-for-continue"
|
"continue-processing"
;
export
function
SetupBanner
()
{
export
function
SetupBanner
()
{
const
navigate
=
useNavigate
();
const
navigate
=
useNavigate
();
const
{
isAnyProviderSetup
,
loading
}
=
useSettings
();
const
{
isAnyProviderSetup
,
loading
}
=
useSettings
();
...
@@ -28,7 +34,8 @@ export function SetupBanner() {
...
@@ -28,7 +34,8 @@ export function SetupBanner() {
null
null
);
);
const
[
nodeCheckError
,
setNodeCheckError
]
=
useState
<
boolean
>
(
false
);
const
[
nodeCheckError
,
setNodeCheckError
]
=
useState
<
boolean
>
(
false
);
const
[
nodeInstallLoading
,
setNodeInstallLoading
]
=
useState
<
boolean
>
(
false
);
const
[
nodeInstallStep
,
setNodeInstallStep
]
=
useState
<
NodeInstallStep
>
(
"install"
);
const
checkNode
=
useCallback
(
async
()
=>
{
const
checkNode
=
useCallback
(
async
()
=>
{
try
{
try
{
setNodeCheckError
(
false
);
setNodeCheckError
(
false
);
...
@@ -52,14 +59,16 @@ export function SetupBanner() {
...
@@ -52,14 +59,16 @@ export function SetupBanner() {
});
});
};
};
const
handleNodeInstallClick
=
async
()
=>
{
const
handleNodeInstallClick
=
useCallback
(
async
()
=>
{
setNodeInstall
Loading
(
true
);
setNodeInstall
Step
(
"waiting-for-continue"
);
IpcClient
.
getInstance
().
openExternalUrl
(
nodeSystemInfo
!
.
nodeDownloadUrl
);
IpcClient
.
getInstance
().
openExternalUrl
(
nodeSystemInfo
!
.
nodeDownloadUrl
);
};
}
,
[
nodeSystemInfo
,
setNodeInstallStep
])
;
const
finishNodeInstallAndRestart
=
()
=>
{
const
finishNodeInstall
=
useCallback
(
async
()
=>
{
IpcClient
.
getInstance
().
reloadDyad
();
setNodeInstallStep
(
"continue-processing"
);
};
await
IpcClient
.
getInstance
().
reloadEnvPath
();
await
checkNode
();
},
[
checkNode
,
setNodeInstallStep
]);
const
isNodeSetupComplete
=
Boolean
(
const
isNodeSetupComplete
=
Boolean
(
nodeSystemInfo
?.
nodeVersion
&&
nodeSystemInfo
?.
pnpmVersion
nodeSystemInfo
?.
nodeVersion
&&
nodeSystemInfo
?.
pnpmVersion
...
@@ -123,7 +132,7 @@ export function SetupBanner() {
...
@@ -123,7 +132,7 @@ export function SetupBanner() {
<
div
className=
"flex items-center gap-3"
>
<
div
className=
"flex items-center gap-3"
>
{
getStatusIcon
(
isNodeSetupComplete
,
nodeCheckError
)
}
{
getStatusIcon
(
isNodeSetupComplete
,
nodeCheckError
)
}
<
span
className=
"font-medium text-sm"
>
<
span
className=
"font-medium text-sm"
>
1. Install Node.js
1. Install Node.js
(App Runtime)
</
span
>
</
span
>
</
div
>
</
div
>
</
div
>
</
div
>
...
@@ -146,17 +155,37 @@ export function SetupBanner() {
...
@@ -146,17 +155,37 @@ export function SetupBanner() {
)
:
(
)
:
(
<
div
className=
"text-sm"
>
<
div
className=
"text-sm"
>
<
p
>
Node.js is required to run apps locally.
</
p
>
<
p
>
Node.js is required to run apps locally.
</
p
>
<
p
className=
"mb-3"
>
{
nodeInstallStep
===
"waiting-for-continue"
&&
(
After you have installed node.js, click "Finish setup" to
<
p
className=
"mt-1"
>
restart Dyad.
After you have installed Node.js, click "Continue". If the
installer didn't work, try
{
" "
}
<
a
className=
"text-blue-500 dark:text-blue-400 hover:underline"
onClick=
{
()
=>
{
IpcClient
.
getInstance
().
openExternalUrl
(
"https://nodejs.org/en/download"
);
}
}
>
more download options
</
a
>
.
</
p
>
</
p
>
{
nodeInstallLoading
?
(
)
}
<
Button
onClick=
{
finishNodeInstallAndRestart
}
>
{
nodeInstallStep
===
"install"
?
(
Finish setup and restart Dyad
<
Button
className=
"mt-3"
onClick=
{
handleNodeInstallClick
}
>
Install Node.js Runtime
</
Button
>
</
Button
>
)
:
(
)
:
(
<
Button
onClick=
{
handleNodeInstallClick
}
>
<
Button
className=
"mt-3"
onClick=
{
finishNodeInstall
}
>
Install Node.js Runtime
{
nodeInstallStep
===
"continue-processing"
?
(
<
div
className=
"flex items-center gap-2"
>
<
Loader2
className=
"h-4 w-4 animate-spin"
/>
Checking Node.js setup...
</
div
>
)
:
(
"Continue | I installed Node.js"
)
}
</
Button
>
</
Button
>
)
}
)
}
</
div
>
</
div
>
...
...
src/ipc/handlers/node_handlers.ts
浏览文件 @
cc0ab0fd
import
{
ipcMain
,
app
}
from
"electron"
;
import
{
ipcMain
,
app
}
from
"electron"
;
import
{
spawn
}
from
"child_process"
;
import
{
exec
,
execSync
,
spawn
}
from
"child_process"
;
import
{
platform
,
arch
}
from
"os"
;
import
{
platform
,
arch
}
from
"os"
;
import
{
NodeSystemInfo
}
from
"../ipc_types"
;
import
{
NodeSystemInfo
}
from
"../ipc_types"
;
import
fixPath
from
"fix-path"
;
function
checkCommandExists
(
command
:
string
):
Promise
<
string
|
null
>
{
function
checkCommandExists
(
command
:
string
):
Promise
<
string
|
null
>
{
return
new
Promise
((
resolve
)
=>
{
return
new
Promise
((
resolve
)
=>
{
...
@@ -68,8 +69,16 @@ export function registerNodeHandlers() {
...
@@ -68,8 +69,16 @@ export function registerNodeHandlers() {
return
{
nodeVersion
,
pnpmVersion
,
nodeDownloadUrl
};
return
{
nodeVersion
,
pnpmVersion
,
nodeDownloadUrl
};
});
});
ipcMain
.
handle
(
"reload-dyad"
,
async
():
Promise
<
void
>
=>
{
ipcMain
.
handle
(
"reload-env-path"
,
async
():
Promise
<
void
>
=>
{
app
.
relaunch
();
console
.
debug
(
"Reloading env path, previously:"
,
process
.
env
.
PATH
);
app
.
exit
(
0
);
if
(
platform
()
===
"win32"
)
{
const
newPath
=
execSync
(
"cmd /c echo %PATH%"
,
{
encoding
:
"utf8"
,
}).
trim
();
process
.
env
.
PATH
=
newPath
;
}
else
{
fixPath
();
}
console
.
debug
(
"Reloaded env path, now:"
,
process
.
env
.
PATH
);
});
});
}
}
src/ipc/ipc_client.ts
浏览文件 @
cc0ab0fd
...
@@ -131,8 +131,8 @@ export class IpcClient {
...
@@ -131,8 +131,8 @@ export class IpcClient {
return
IpcClient
.
instance
;
return
IpcClient
.
instance
;
}
}
public
async
reload
Dyad
():
Promise
<
void
>
{
public
async
reload
EnvPath
():
Promise
<
void
>
{
await
this
.
ipcRenderer
.
invoke
(
"reload-
dyad
"
);
await
this
.
ipcRenderer
.
invoke
(
"reload-
env-path
"
);
}
}
// Create a new app with an initial chat
// Create a new app with an initial chat
...
...
src/preload.ts
浏览文件 @
cc0ab0fd
...
@@ -37,7 +37,7 @@ const validInvokeChannels = [
...
@@ -37,7 +37,7 @@ const validInvokeChannels = [
"github:create-repo"
,
"github:create-repo"
,
"github:push"
,
"github:push"
,
"get-app-version"
,
"get-app-version"
,
"reload-
dyad
"
,
"reload-
env-path
"
,
]
as
const
;
]
as
const
;
// Add valid receive channels
// Add valid receive channels
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论