Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
B
bit-pm
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
燕伟桐
bit-pm
Commits
42b759d8
提交
42b759d8
authored
4月 23, 2025
作者:
Will Chen
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Refresh UI when receiving deep link
上级
ae2cb0fc
显示空白字符变更
内嵌
并排
正在显示
7 个修改的文件
包含
83 行增加
和
3 行删除
+83
-3
layout.tsx
src/app/layout.tsx
+3
-0
SupabaseConnector.tsx
src/components/SupabaseConnector.tsx
+14
-2
DeepLinkContext.tsx
src/contexts/DeepLinkContext.tsx
+34
-0
useSettings.ts
src/hooks/useSettings.ts
+1
-1
ipc_client.ts
src/ipc/ipc_client.ts
+18
-0
main.ts
src/main.ts
+12
-0
preload.ts
src/preload.ts
+1
-0
没有找到文件。
src/app/layout.tsx
浏览文件 @
42b759d8
import
{
SidebarProvider
}
from
"@/components/ui/sidebar"
;
import
{
AppSidebar
}
from
"@/components/app-sidebar"
;
import
{
ThemeProvider
}
from
"../contexts/ThemeContext"
;
import
{
DeepLinkProvider
}
from
"../contexts/DeepLinkContext"
;
import
{
Toaster
}
from
"sonner"
;
import
{
TitleBar
}
from
"./TitleBar"
;
...
...
@@ -13,6 +14,7 @@ export default function RootLayout({
<>
<
TitleBar
/>
<
ThemeProvider
>
<
DeepLinkProvider
>
<
SidebarProvider
>
<
AppSidebar
/>
<
div
className=
"flex h-screenish w-full overflow-x-hidden mt-8 mb-4 mr-4 border-t border-l border-border rounded-lg bg-background"
>
...
...
@@ -20,6 +22,7 @@ export default function RootLayout({
</
div
>
<
Toaster
richColors
/>
</
SidebarProvider
>
</
DeepLinkProvider
>
</
ThemeProvider
>
</>
);
...
...
src/components/SupabaseConnector.tsx
浏览文件 @
42b759d8
...
...
@@ -23,12 +23,24 @@ import {
}
from
"@/components/ui/card"
;
import
{
Skeleton
}
from
"@/components/ui/skeleton"
;
import
{
useLoadApp
}
from
"@/hooks/useLoadApp"
;
import
{
useDeepLink
}
from
"@/contexts/DeepLinkContext"
;
const
OAUTH_CLIENT_ID
=
"bf747de7-60bb-48a2-9015-6494e0b04983"
;
export
function
SupabaseConnector
({
appId
}:
{
appId
:
number
})
{
const
[
isConnecting
,
setIsConnecting
]
=
useState
(
false
);
const
{
settings
}
=
useSettings
();
const
{
settings
,
refreshSettings
}
=
useSettings
();
const
{
app
,
refreshApp
}
=
useLoadApp
(
appId
);
const
{
lastDeepLink
}
=
useDeepLink
();
useEffect
(()
=>
{
const
handleDeepLink
=
async
()
=>
{
if
(
lastDeepLink
?.
type
===
"supabase-oauth-return"
)
{
await
refreshSettings
();
await
refreshApp
();
}
};
handleDeepLink
();
},
[
lastDeepLink
]);
const
{
projects
,
loading
,
...
...
@@ -176,7 +188,7 @@ export function SupabaseConnector({ appId }: { appId: number }) {
return
(
<
div
className=
"flex flex-col space-y-4 p-4 border rounded-md"
>
<
h2
className=
"text-lg font-semibold"
>
Connect to Supabase
</
h2
>
<
h2
className=
"text-lg font-semibold"
>
Supabase Integration
</
h2
>
<
Button
onClick=
{
handleConnect
}
...
...
src/contexts/DeepLinkContext.tsx
0 → 100644
浏览文件 @
42b759d8
import
React
,
{
createContext
,
useContext
,
useEffect
,
useState
}
from
"react"
;
import
{
IpcClient
,
DeepLinkData
}
from
"../ipc/ipc_client"
;
type
DeepLinkContextType
=
{
lastDeepLink
:
(
DeepLinkData
&
{
timestamp
:
number
})
|
null
;
};
const
DeepLinkContext
=
createContext
<
DeepLinkContextType
>
({
lastDeepLink
:
null
,
});
export
function
DeepLinkProvider
({
children
}:
{
children
:
React
.
ReactNode
})
{
const
[
lastDeepLink
,
setLastDeepLink
]
=
useState
<
(
DeepLinkData
&
{
timestamp
:
number
})
|
null
>
(
null
);
useEffect
(()
=>
{
const
ipcClient
=
IpcClient
.
getInstance
();
const
unsubscribe
=
ipcClient
.
onDeepLinkReceived
((
data
)
=>
{
// Update with timestamp to ensure state change even if same type comes twice
setLastDeepLink
({
...
data
,
timestamp
:
Date
.
now
()
});
});
return
unsubscribe
;
},
[]);
return
(
<
DeepLinkContext
.
Provider
value=
{
{
lastDeepLink
}
}
>
{
children
}
</
DeepLinkContext
.
Provider
>
);
}
export
const
useDeepLink
=
()
=>
useContext
(
DeepLinkContext
);
src/hooks/useSettings.ts
浏览文件 @
42b759d8
...
...
@@ -98,7 +98,7 @@ export function useSettings() {
);
},
refreshSettings
:
()
=>
{
loadInitialData
();
return
loadInitialData
();
},
};
}
...
...
src/ipc/ipc_client.ts
浏览文件 @
42b759d8
...
...
@@ -45,6 +45,11 @@ export interface GitHubDeviceFlowErrorData {
error
:
string
;
}
export
interface
DeepLinkData
{
type
:
string
;
url
?:
string
;
}
export
class
IpcClient
{
private
static
instance
:
IpcClient
;
private
ipcRenderer
:
IpcRenderer
;
...
...
@@ -731,4 +736,17 @@ export class IpcClient {
throw
error
;
}
}
// Listen for deep link events
public
onDeepLinkReceived
(
callback
:
(
data
:
DeepLinkData
)
=>
void
):
()
=>
void
{
const
listener
=
(
data
:
any
)
=>
{
callback
(
data
as
DeepLinkData
);
};
this
.
ipcRenderer
.
on
(
"deep-link-received"
,
listener
);
return
()
=>
{
this
.
ipcRenderer
.
removeListener
(
"deep-link-received"
,
listener
);
};
}
}
src/main.ts
浏览文件 @
42b759d8
...
...
@@ -152,6 +152,13 @@ app.on("open-url", (event, url) => {
function
handleDeepLinkReturn
(
url
:
string
)
{
// example url: "dyad://supabase-oauth-return?token=a&refreshToken=b"
const
parsed
=
new
URL
(
url
);
// Intentionally do NOT log the full URL which may contain sensitive tokens.
log
.
log
(
"Handling deep link: protocol"
,
parsed
.
protocol
,
"hostname"
,
parsed
.
hostname
);
if
(
parsed
.
protocol
!==
"dyad:"
)
{
dialog
.
showErrorBox
(
"Invalid Protocol"
,
...
...
@@ -170,6 +177,11 @@ function handleDeepLinkReturn(url: string) {
return
;
}
handleSupabaseOAuthReturn
({
token
,
refreshToken
,
expiresIn
});
// Send message to renderer to trigger re-render
mainWindow
?.
webContents
.
send
(
"deep-link-received"
,
{
type
:
parsed
.
hostname
,
url
,
});
}
}
...
...
src/preload.ts
浏览文件 @
42b759d8
...
...
@@ -56,6 +56,7 @@ const validReceiveChannels = [
"github:flow-update"
,
"github:flow-success"
,
"github:flow-error"
,
"deep-link-received"
,
]
as
const
;
type
ValidInvokeChannel
=
(
typeof
validInvokeChannels
)[
number
];
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论