@aiyiran/myclaw 1.0.27 → 1.0.28
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/assets/myclaw-inject.js +30 -0
- package/package.json +1 -1
package/assets/myclaw-inject.js
CHANGED
|
@@ -51,10 +51,40 @@
|
|
|
51
51
|
].join(";");
|
|
52
52
|
bar.textContent = "\uD83D\uDC3E MyClaw v" + MYCLAW_VERSION;
|
|
53
53
|
|
|
54
|
+
// 测试麦克风按钮
|
|
55
|
+
var testBtn = document.createElement("button");
|
|
56
|
+
testBtn.textContent = "\uD83D\uDD0A \u6D4B\u8BD5\u9EA6\u514B\u98CE";
|
|
57
|
+
testBtn.style.cssText = "background:#e94560;color:white;border:none;padding:2px 8px;border-radius:4px;cursor:pointer;font-size:11px;font-family:monospace;";
|
|
58
|
+
testBtn.onclick = function(e) {
|
|
59
|
+
e.stopPropagation();
|
|
60
|
+
console.log("[myclaw] \u6D4B\u8BD5\u9EA6\u514B\u98CE\u70B9\u51FB");
|
|
61
|
+
testMicrophone();
|
|
62
|
+
};
|
|
63
|
+
bar.appendChild(testBtn);
|
|
64
|
+
|
|
54
65
|
document.body.prepend(bar);
|
|
55
66
|
document.body.style.paddingTop = "28px";
|
|
56
67
|
}
|
|
57
68
|
|
|
69
|
+
// \u6D4B\u8BD5\u9EA6\u514B\u98CE\u51FD\u6570
|
|
70
|
+
function testMicrophone() {
|
|
71
|
+
console.log("[myclaw] \u5F00\u59CB\u6D4B\u8BD5\u9EA6\u514B\u98CE...");
|
|
72
|
+
if (typeof window.VoiceInput === "undefined") {
|
|
73
|
+
alert("VoiceInput SDK \u672A\u52A0\u8F7D");
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
navigator.mediaDevices.getUserMedia({ audio: true })
|
|
77
|
+
.then(function(stream) {
|
|
78
|
+
console.log("[myclaw] \u9EA6\u514B\u98CE\u6743\u9650\u83B7\u53D6\u6210\u529F!");
|
|
79
|
+
stream.getTracks().forEach(function(track) { track.stop(); });
|
|
80
|
+
alert("\u9EA6\u514B\u98CE\u6B63\u5E38!");
|
|
81
|
+
})
|
|
82
|
+
.catch(function(err) {
|
|
83
|
+
console.error("[myclaw] \u9EA6\u514B\u98CE\u6743\u9650\u83B7\u53D6\u5931\u8D25:", err.message);
|
|
84
|
+
alert("\u9EA6\u514B\u98CE\u6743\u9650\u88AB\u62D2\u7EDD: " + err.message);
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
|
|
58
88
|
// ═══ 2. textarea 工具 ═══
|
|
59
89
|
|
|
60
90
|
/**
|