mirror of
https://github.com/qingchencloud/clawpanel.git
synced 2026-05-06 20:02:49 +08:00
- 飞书渠道从 @openclaw/feishu 迁移到 @larksuite/openclaw-lark 官方插件 - 保存飞书配置时自动禁用旧 feishu 插件,防止新旧插件冲突 - 所有主要渠道(飞书/Telegram/Discord/Slack)启用配对审批UI - gateway_command 增加20s超时,超时后force-kill+fresh start - 全平台启动前端口占用检查,防止Guardian无限拉起 - Linux gateway_command 补齐 Duration 导入和 cleanup_zombie 实现 - Guardian自动守护在Tauri桌面端也启用,轮询间隔30s→15s - 微信渠道:升级操作不再弹出扫码二维码,按钮文案区分安装/升级 - 版本更新检测:CI不再将minAppVersion写死为当前版本 - 部署脚本增强OpenClaw检测,支持已安装的官方版 - 日间/夜间模式圆形扩散切换动画(View Transitions API) - API错误信息完整展示(429限流等),URL自动转可点击链接 - 第三方API接入引导优化:移除内置密钥,引导式流程 - 修复全平台 Clippy 警告(strip_prefix/dead_code/unnecessary_unwrap等) - Rust代码格式化修复(cargo fmt) - toast组件支持HTML内容渲染 - Rust后端test_model返回详细错误信息
70 lines
2.1 KiB
JavaScript
70 lines
2.1 KiB
JavaScript
import { defineConfig } from 'vite'
|
||
import { devApiPlugin } from './scripts/dev-api.js'
|
||
import fs from 'fs'
|
||
import path from 'path'
|
||
import { homedir } from 'os'
|
||
|
||
// 读取 package.json 版本号,构建时注入前端
|
||
const pkg = JSON.parse(fs.readFileSync(new URL('./package.json', import.meta.url), 'utf8'))
|
||
|
||
// 读取 Gateway 端口(启动时读取一次)
|
||
// 注意:Gateway 默认端口是 18789,不是 18790
|
||
let gatewayPort = 18789
|
||
try {
|
||
const cfgPath = path.join(homedir(), '.openclaw', 'openclaw.json')
|
||
if (fs.existsSync(cfgPath)) {
|
||
const cfg = JSON.parse(fs.readFileSync(cfgPath, 'utf8'))
|
||
// 端口必须 > 0 且 < 65536
|
||
const port = cfg?.gateway?.port
|
||
if (port && typeof port === 'number' && port > 0 && port < 65536) {
|
||
gatewayPort = port
|
||
}
|
||
}
|
||
} catch (e) {
|
||
console.warn('[vite] 读取 Gateway 端口配置失败,使用默认端口 18789:', e.message)
|
||
}
|
||
|
||
console.log(`[vite] Gateway WebSocket 代理目标: ws://127.0.0.1:${gatewayPort}`)
|
||
|
||
export default defineConfig({
|
||
plugins: [devApiPlugin()],
|
||
define: {
|
||
__APP_VERSION__: JSON.stringify(pkg.version),
|
||
},
|
||
clearScreen: false,
|
||
server: {
|
||
port: 1420,
|
||
strictPort: true,
|
||
proxy: {
|
||
'/ws': {
|
||
target: `ws://127.0.0.1:${gatewayPort}`,
|
||
ws: true,
|
||
changeOrigin: true,
|
||
timeout: 30000,
|
||
configure: (proxy, options) => {
|
||
proxy.on('proxyReqWs', (proxyReq, req, socket) => {
|
||
socket.setTimeout(30000)
|
||
socket.on('timeout', () => {
|
||
console.warn('[vite/ws] WebSocket 超时,关闭连接')
|
||
socket.destroy()
|
||
})
|
||
})
|
||
proxy.on('error', (err, req, socket) => {
|
||
console.warn(`[vite/ws] 代理错误: ${err.code} ${err.message}`)
|
||
// WebSocket 升级后 socket 是 net.Socket,无 headersSent
|
||
if (socket && !socket.destroyed) {
|
||
socket.destroy()
|
||
}
|
||
})
|
||
},
|
||
},
|
||
},
|
||
},
|
||
envPrefix: ['VITE_', 'TAURI_'],
|
||
build: {
|
||
target: ['es2021', 'chrome100', 'safari13'],
|
||
minify: !process.env.TAURI_DEBUG ? 'esbuild' : false,
|
||
sourcemap: !!process.env.TAURI_DEBUG,
|
||
},
|
||
})
|