feat: restructure repo for collaboration + add desktop app source

- Reorganize project: clean structure (portable/ u-claw-app/ usb-scripts/ website/)
- Move docs into website/, rename uclaw-scripts to usb-scripts
- Add u-claw-app/ Electron desktop source code
- Add portable/setup.sh: one-command dev environment setup
- Add portable/SkillHub.html: skill marketplace page
- Update README: dev guide, contribution workflow, project structure
- Update .gitignore: exclude runtime binaries and build artifacts
- Expand China install guide: npm mirrors, detailed onboard wizard
This commit is contained in:
dongsheng123132
2026-03-12 10:59:26 +08:00
parent 75b5daab57
commit be734cb111
21 changed files with 16931 additions and 171 deletions

View File

@@ -653,13 +653,50 @@ function tryPort(port) {
testWs.onopen = () => {
clearTimeout(timeout);
testWs.send(JSON.stringify({ type: 'auth', token: 'uclaw' }));
ws = testWs;
gwPort = port;
connected = true;
setStatus('on', `OpenClaw 已连接(端口 ${port}`);
setupWs();
loadConfig().then(prefillFromConfig);
// Wait for connect.challenge from gateway, then send connect handshake
let connectSent = false;
const sendConnect = () => {
if (connectSent) return;
connectSent = true;
const connectId = String(++reqId);
pendingReqs[connectId] = (msg) => {
delete pendingReqs[connectId];
if (msg.ok !== false) {
ws = testWs;
gwPort = port;
connected = true;
setStatus('on', `OpenClaw 已连接(端口 ${port}`);
setupWs();
loadConfig().then(prefillFromConfig);
} else {
testWs.close();
tryPort(port + 1);
}
};
testWs.send(JSON.stringify({
type: 'req', id: connectId, method: 'connect',
params: {
minProtocol: 3, maxProtocol: 3,
client: { id: 'webchat', version: '2.0.0', platform: 'web', mode: 'webchat' },
role: 'operator',
scopes: ['operator.admin', 'operator.approvals', 'operator.pairing'],
auth: { token: 'uclaw' }
}
}));
};
// Listen for challenge or timeout
testWs.onmessage = (e) => {
try {
const msg = JSON.parse(e.data);
if (msg.type === 'event' && msg.event === 'connect.challenge') {
sendConnect();
} else if (msg.type === 'res' && pendingReqs[msg.id]) {
pendingReqs[msg.id](msg);
}
} catch(err) {}
};
// Fallback: if no challenge in 750ms, send anyway
setTimeout(sendConnect, 750);
};
testWs.onerror = () => { clearTimeout(timeout); tryPort(port + 1); };
testWs.onclose = () => {
@@ -691,7 +728,7 @@ function setupWs() {
function rpc(method, params) {
return new Promise((resolve, reject) => {
if (!ws || ws.readyState !== 1) { reject('未连接'); return; }
const id = ++reqId;
const id = String(++reqId);
pendingReqs[id] = (msg) => msg.ok ? resolve(msg.payload) : reject(msg.payload || msg.error);
ws.send(JSON.stringify({ type: 'req', id, method, params: params || {} }));
setTimeout(() => { if (pendingReqs[id]) { delete pendingReqs[id]; reject('请求超时'); } }, 15000);