aicq-chat-plugin 2.6.5 → 2.6.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/openclaw.plugin.json +1 -1
- package/package.json +1 -1
- package/public/index.html +17 -4
package/openclaw.plugin.json
CHANGED
package/package.json
CHANGED
package/public/index.html
CHANGED
|
@@ -419,11 +419,24 @@ let pendingDeleteMsgId = null;
|
|
|
419
419
|
const API = '';
|
|
420
420
|
|
|
421
421
|
// ─── API Helper ─────────────────────────────────────────────────────
|
|
422
|
+
function errMsg(err) {
|
|
423
|
+
if (!err) return '未知错误';
|
|
424
|
+
if (typeof err === 'string') return err;
|
|
425
|
+
if (err.message) return err.message;
|
|
426
|
+
if (err.error && typeof err.error === 'string') return err.error;
|
|
427
|
+
if (err.error && typeof err.error === 'object') return errMsg(err.error);
|
|
428
|
+
try { return JSON.stringify(err); } catch { return '未知错误'; }
|
|
429
|
+
}
|
|
430
|
+
|
|
422
431
|
async function api(method, path, body = null) {
|
|
423
432
|
const opts = { method, headers: { 'Content-Type': 'application/json' } };
|
|
424
433
|
if (body) opts.body = JSON.stringify(body);
|
|
425
434
|
const resp = await fetch(API + path, opts);
|
|
426
|
-
|
|
435
|
+
const data = await resp.json();
|
|
436
|
+
if (!resp.ok && !data.success) {
|
|
437
|
+
throw new Error(errMsg(data.error) || `HTTP ${resp.status}`);
|
|
438
|
+
}
|
|
439
|
+
return data;
|
|
427
440
|
}
|
|
428
441
|
|
|
429
442
|
// ─── Agents ─────────────────────────────────────────────────────────
|
|
@@ -791,7 +804,7 @@ async function uploadFile(input, type) {
|
|
|
791
804
|
if (data.success) {
|
|
792
805
|
await loadMessages();
|
|
793
806
|
} else {
|
|
794
|
-
alert('上传失败: ' + (data.error
|
|
807
|
+
alert('上传失败: ' + errMsg(data.error));
|
|
795
808
|
}
|
|
796
809
|
} catch (e) {
|
|
797
810
|
alert('上传失败: ' + e.message);
|
|
@@ -882,7 +895,7 @@ async function addFriendByCode() {
|
|
|
882
895
|
document.getElementById('friendCodeInput').value = '';
|
|
883
896
|
await loadFriends();
|
|
884
897
|
} else {
|
|
885
|
-
alert('添加失败: ' + (result.error
|
|
898
|
+
alert('添加失败: ' + errMsg(result.error));
|
|
886
899
|
}
|
|
887
900
|
} catch (e) {
|
|
888
901
|
alert('添加失败: ' + e.message);
|
|
@@ -1041,7 +1054,7 @@ async function handlePluginAvatarUpload(input) {
|
|
|
1041
1054
|
}
|
|
1042
1055
|
alert('头像已更新');
|
|
1043
1056
|
} else {
|
|
1044
|
-
alert('上传失败: ' + (data.error
|
|
1057
|
+
alert('上传失败: ' + errMsg(data.error));
|
|
1045
1058
|
}
|
|
1046
1059
|
} catch (e) {
|
|
1047
1060
|
alert('头像上传失败: ' + e.message);
|