feat: 添加远程应用连接功能,增强应用的网络交互能力
This commit is contained in:
16
src/index.ts
16
src/index.ts
@@ -2,6 +2,7 @@ import { app } from './app.ts'
|
||||
export { app, db } from './app.ts';
|
||||
export { Core } from './playwright/core.ts';
|
||||
import './routes/index.ts';
|
||||
import { RemoteApp } from '@kevisual/remote-app'
|
||||
// 如果是直接运行,则启动应用
|
||||
// better-sqlite3 不支持 bun
|
||||
// playwright 也不支持 bun
|
||||
@@ -26,3 +27,18 @@ export const browserAgentPlugin = createRouterAgentPluginFn({
|
||||
// router: app.,
|
||||
router: app,
|
||||
})
|
||||
const token = process.env.KEVISUAL_TOKEN || '';
|
||||
|
||||
const remoteApp = new RemoteApp({
|
||||
id: 'browser-helper',
|
||||
url: 'https://kevisual.cn/ws/proxy',
|
||||
token: token,
|
||||
app: app,
|
||||
})
|
||||
const connect = await remoteApp.isConnect()
|
||||
if (connect) {
|
||||
console.log('Remote app connected successfully!');
|
||||
remoteApp.listenProxy()
|
||||
} else {
|
||||
console.error('Failed to connect remote app. Please check your token and network connection.');
|
||||
}
|
||||
Reference in New Issue
Block a user