@opentiny/next-sdk 0.1.14 → 0.1.15
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/agent/AgentModelProvider.ts +49 -20
- package/agent/type.ts +4 -4
- package/dist/McpSdk.d.ts +14 -0
- package/dist/WebAgent.d.ts +5 -0
- package/dist/WebMcp.d.ts +20 -0
- package/dist/WebMcpClient.d.ts +250 -1152
- package/dist/WebMcpServer.d.ts +190 -78
- package/dist/Zod.d.ts +1 -0
- package/dist/agent/AgentModelProvider.d.ts +6 -4
- package/dist/agent/type.d.ts +6 -2
- package/dist/agent/utils/getAISDKTools.d.ts +1 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.es.dev.js +21741 -23457
- package/dist/index.es.js +24309 -23733
- package/dist/index.js +1789 -25
- package/dist/index.umd.dev.js +21720 -23436
- package/dist/index.umd.js +184 -132
- package/dist/{mcpsdk@1.17.0.dev.js → mcpsdk@1.23.0.dev.js} +14784 -15255
- package/dist/{mcpsdk@1.17.0.es.dev.js → mcpsdk@1.23.0.es.dev.js} +14787 -15258
- package/dist/mcpsdk@1.23.0.es.js +15584 -0
- package/dist/mcpsdk@1.23.0.js +43 -0
- package/dist/remoter/createRemoter.d.ts +9 -0
- package/dist/remoter/tooltips.d.ts +36 -0
- package/dist/script/utils.d.ts +1 -0
- package/dist/transport/ExtensionClientTransport.d.ts +3 -2
- package/dist/transport/ExtensionContentServerTransport.d.ts +3 -2
- package/dist/transport/ExtensionPageServerTransport.d.ts +3 -2
- package/dist/vite-build-tsc.d.ts +2 -0
- package/dist/vite.config.d.ts +2 -0
- package/dist/vite.config.mcpSdk.d.ts +2 -0
- package/dist/vite.config.webAgent.d.ts +2 -0
- package/dist/vite.config.webMcp.d.ts +2 -0
- package/dist/vite.config.webMcpFull.d.ts +2 -0
- package/dist/vite.config.zod.d.ts +2 -0
- package/dist/webagent.dev.js +18780 -18491
- package/dist/webagent.es.dev.js +18455 -18166
- package/dist/webagent.es.js +22389 -20343
- package/dist/webagent.js +172 -113
- package/dist/webmcp-full.dev.js +14943 -15356
- package/dist/webmcp-full.es.dev.js +14959 -15372
- package/dist/webmcp-full.es.js +13785 -12666
- package/dist/webmcp-full.js +43 -16
- package/package.json +3 -2
- package/remoter/createRemoter.ts +126 -71
- package/remoter/tooltips.ts +260 -0
- package/tsconfig.json +5 -3
- package/vite-build-tsc.ts +60 -0
- package/vite-env.d.ts +5 -0
- package/dist/WebMcpClient.js +0 -363
- package/dist/WebMcpServer.js +0 -283
- package/dist/agent/AgentModelProvider.js +0 -293
- package/dist/agent/type.js +0 -1
- package/dist/agent/utils/getAISDKTools.js +0 -36
- package/dist/mcpsdk@1.17.0.es.js +0 -14505
- package/dist/mcpsdk@1.17.0.js +0 -16
- package/dist/remoter/QrCode.js +0 -55
- package/dist/remoter/createRemoter.js +0 -743
- package/dist/transport/ExtensionClientTransport.js +0 -81
- package/dist/transport/ExtensionContentServerTransport.js +0 -128
- package/dist/transport/ExtensionPageServerTransport.js +0 -118
- package/dist/transport/messages.js +0 -51
- package/dist/utils/uuid.js +0 -10
package/dist/index.js
CHANGED
|
@@ -1,25 +1,1789 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
1
|
+
import { default as G2 } from "ajv";
|
|
2
|
+
import { z as t0 } from "zod";
|
|
3
|
+
import { MessageChannelServerTransport as g, createTransportPair as I, MessageChannelClientTransport as u, sseOptions as q, streamOptions as Z, createSseProxy as U, createSocketProxy as z, createStreamProxy as H, MessageChannelTransport as $ } from "@opentiny/next";
|
|
4
|
+
import { AuthClientProvider as s0 } from "@opentiny/next";
|
|
5
|
+
import { McpServer as T } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
6
|
+
import { ResourceTemplate as r0 } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
7
|
+
import { UriTemplate as a0 } from "@modelcontextprotocol/sdk/shared/uriTemplate.js";
|
|
8
|
+
import { completable as l0 } from "@modelcontextprotocol/sdk/server/completable.js";
|
|
9
|
+
import { getDisplayName as d0 } from "@modelcontextprotocol/sdk/shared/metadataUtils.js";
|
|
10
|
+
import { InMemoryTransport as N } from "@modelcontextprotocol/sdk/inMemory.js";
|
|
11
|
+
import { InMemoryTransport as C0 } from "@modelcontextprotocol/sdk/inMemory.js";
|
|
12
|
+
import { SetLevelRequestSchema as v, SubscribeRequestSchema as F, UnsubscribeRequestSchema as O, ListResourcesRequestSchema as j, RootsListChangedNotificationSchema as B, CallToolResultSchema as D, ElicitRequestSchema as A, CreateMessageRequestSchema as W, ListRootsRequestSchema as Y, ToolListChangedNotificationSchema as V, PromptListChangedNotificationSchema as Q, ResourceListChangedNotificationSchema as K, ResourceUpdatedNotificationSchema as X, LoggingMessageNotificationSchema as J, JSONRPCMessageSchema as f } from "@modelcontextprotocol/sdk/types.js";
|
|
13
|
+
import { Client as S } from "@modelcontextprotocol/sdk/client/index.js";
|
|
14
|
+
import { SSEClientTransport as w } from "@modelcontextprotocol/sdk/client/sse.js";
|
|
15
|
+
import { StreamableHTTPClientTransport as p } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
|
|
16
|
+
import { WebSocketClientTransport as G } from "@modelcontextprotocol/sdk/client/websocket.js";
|
|
17
|
+
import x from "qrcode";
|
|
18
|
+
import { dynamicTool as e2, jsonSchema as t2, experimental_createMCPClient as i2, stepCountIs as s2, generateText as o2, streamText as r2 } from "ai";
|
|
19
|
+
import { createOpenAI as n2 } from "@ai-sdk/openai";
|
|
20
|
+
import { createDeepSeek as a2 } from "@ai-sdk/deepseek";
|
|
21
|
+
class z2 {
|
|
22
|
+
constructor(e, t) {
|
|
23
|
+
const i = {
|
|
24
|
+
name: "web-mcp-server",
|
|
25
|
+
version: "1.0.0"
|
|
26
|
+
}, s = {
|
|
27
|
+
prompts: { listChanged: !0 },
|
|
28
|
+
resources: { subscribe: !0, listChanged: !0 },
|
|
29
|
+
tools: { listChanged: !0 },
|
|
30
|
+
completions: {},
|
|
31
|
+
logging: {}
|
|
32
|
+
};
|
|
33
|
+
this.server = new T(e || i, t || { capabilities: s }), this.server.server.oninitialized = () => {
|
|
34
|
+
var o;
|
|
35
|
+
(o = this.oninitialized) == null || o.call(this);
|
|
36
|
+
}, this.server.server.onclose = () => {
|
|
37
|
+
var o;
|
|
38
|
+
(o = this.onclose) == null || o.call(this);
|
|
39
|
+
}, this.server.server.onerror = (o) => {
|
|
40
|
+
var n;
|
|
41
|
+
(n = this.onerror) == null || n.call(this, o);
|
|
42
|
+
}, this.server.server.setRequestHandler(v, async () => ({}));
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Connects the server to a transport via the specified option.
|
|
46
|
+
*/
|
|
47
|
+
async connect(e) {
|
|
48
|
+
return typeof e.start == "function" ? (this.transport = e, this.transport.onclose = void 0, this.transport.onerror = void 0, this.transport.onmessage = void 0) : (this.transport = new g(e), await this.transport.listen()), await this.server.connect(this.transport), this.transport;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Closes the connection.
|
|
52
|
+
*/
|
|
53
|
+
async close() {
|
|
54
|
+
await this.server.close();
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Registers a tool with a config object and callback.
|
|
58
|
+
*/
|
|
59
|
+
registerTool(e, t, i) {
|
|
60
|
+
return this.server.registerTool(e, t, i);
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Registers a prompt with a config object and callback.
|
|
64
|
+
*/
|
|
65
|
+
registerPrompt(e, t, i) {
|
|
66
|
+
return this.server.registerPrompt(e, t, i);
|
|
67
|
+
}
|
|
68
|
+
registerResource(e, t, i, s) {
|
|
69
|
+
return typeof t == "string" ? this.server.registerResource(e, t, i, s) : this.server.registerResource(e, t, i, s);
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Checks if the server is connected to a transport.
|
|
73
|
+
* @returns True if the server is connected
|
|
74
|
+
*/
|
|
75
|
+
isConnected() {
|
|
76
|
+
return this.server.isConnected();
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Sends a resource list changed event to the client, if connected.
|
|
80
|
+
*/
|
|
81
|
+
sendResourceListChanged() {
|
|
82
|
+
this.server.sendResourceListChanged();
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Sends a tool list changed event to the client, if connected.
|
|
86
|
+
*/
|
|
87
|
+
sendToolListChanged() {
|
|
88
|
+
this.server.sendToolListChanged();
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Sends a prompt list changed event to the client, if connected.
|
|
92
|
+
*/
|
|
93
|
+
sendPromptListChanged() {
|
|
94
|
+
this.server.sendPromptListChanged();
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* After initialization has completed, this will be populated with the client's reported capabilities.
|
|
98
|
+
*/
|
|
99
|
+
getClientCapabilities() {
|
|
100
|
+
return this.server.server.getClientCapabilities();
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* After initialization has completed, this will be populated with information about the client's name and version.
|
|
104
|
+
*/
|
|
105
|
+
getClientVersion() {
|
|
106
|
+
return this.server.server.getClientVersion();
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Sends a ping to the client to check if it is still connected.
|
|
110
|
+
*/
|
|
111
|
+
async ping() {
|
|
112
|
+
return await this.server.server.ping();
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Creates a LLM message to be sent to the client.
|
|
116
|
+
*/
|
|
117
|
+
async createMessage(e, t) {
|
|
118
|
+
return await this.server.server.createMessage(e, t);
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Elicits input from the client, such as a prompt or resource.
|
|
122
|
+
*/
|
|
123
|
+
async elicitInput(e, t) {
|
|
124
|
+
return await this.server.server.elicitInput(e, t);
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Lists the root resources available to the client.
|
|
128
|
+
*/
|
|
129
|
+
async listRoots(e, t) {
|
|
130
|
+
return await this.server.server.listRoots(e, t);
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Sends a logging message to the client.
|
|
134
|
+
*/
|
|
135
|
+
async sendLoggingMessage(e) {
|
|
136
|
+
return await this.server.server.sendLoggingMessage(e);
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Sends a resource updated notification to the client.
|
|
140
|
+
*/
|
|
141
|
+
async sendResourceUpdated(e) {
|
|
142
|
+
return await this.server.server.sendResourceUpdated(e);
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Sends a request and wait for a response.
|
|
146
|
+
*
|
|
147
|
+
* Do not use this method to emit notifications! Use notification() instead.
|
|
148
|
+
*/
|
|
149
|
+
request(e, t, i) {
|
|
150
|
+
return this.server.server.request(e, t, i);
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Emits a notification, which is a one-way message that does not expect a response.
|
|
154
|
+
*/
|
|
155
|
+
async notification(e, t) {
|
|
156
|
+
return await this.server.server.notification(e, t);
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Registers a handler to invoke when this protocol object receives a request with the given method.
|
|
160
|
+
*
|
|
161
|
+
* Note that this will replace any previous request handler for the same method.
|
|
162
|
+
*/
|
|
163
|
+
setRequestHandler(e, t) {
|
|
164
|
+
this.server.server.setRequestHandler(e, t);
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Removes the request handler for the given method.
|
|
168
|
+
*/
|
|
169
|
+
removeRequestHandler(e) {
|
|
170
|
+
this.server.server.removeRequestHandler(e);
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Registers a handler to invoke when this protocol object receives a notification with the given method.
|
|
174
|
+
*
|
|
175
|
+
* Note that this will replace any previous notification handler for the same method.
|
|
176
|
+
*/
|
|
177
|
+
setNotificationHandler(e, t) {
|
|
178
|
+
this.server.server.setNotificationHandler(e, t);
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Removes the notification handler for the given method.
|
|
182
|
+
*/
|
|
183
|
+
removeNotificationHandler(e) {
|
|
184
|
+
this.server.server.removeNotificationHandler(e);
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Registers a handler for the subscribe request.
|
|
188
|
+
*/
|
|
189
|
+
onSubscribe(e) {
|
|
190
|
+
this.server.server.setRequestHandler(F, e);
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Registers a handler for the unsubscribe request.
|
|
194
|
+
*/
|
|
195
|
+
onUnsubscribe(e) {
|
|
196
|
+
this.server.server.setRequestHandler(O, e);
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Registers a handler for the set log level request.
|
|
200
|
+
*/
|
|
201
|
+
onSetLogLevel(e) {
|
|
202
|
+
this.server.server.setRequestHandler(v, e);
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Registers a handler for the list tools request.
|
|
206
|
+
*/
|
|
207
|
+
onListResources(e) {
|
|
208
|
+
this.server.server.setRequestHandler(j, e);
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Registers a handler for the roots list changed notification.
|
|
212
|
+
*/
|
|
213
|
+
onRootsListChanged(e) {
|
|
214
|
+
this.server.server.setNotificationHandler(B, e);
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Close the transport for window.addEventListener('pagehide')
|
|
218
|
+
*/
|
|
219
|
+
async onPagehide(e) {
|
|
220
|
+
e.persisted || this.transport && typeof this.transport.close == "function" && await this.transport.close();
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
const H2 = (r, e) => new g(r, e), $2 = () => I(), N2 = (r) => r instanceof g, F2 = (r) => r instanceof T;
|
|
224
|
+
class c2 {
|
|
225
|
+
constructor(e, t) {
|
|
226
|
+
const i = {
|
|
227
|
+
name: "web-mcp-client",
|
|
228
|
+
version: "1.0.0"
|
|
229
|
+
}, s = {
|
|
230
|
+
roots: { listChanged: !0 },
|
|
231
|
+
sampling: {},
|
|
232
|
+
elicitation: {}
|
|
233
|
+
};
|
|
234
|
+
this.client = new S(e || i, t || { capabilities: s }), this.client.onclose = () => {
|
|
235
|
+
var o;
|
|
236
|
+
(o = this.onclose) == null || o.call(this);
|
|
237
|
+
}, this.client.onerror = (o) => {
|
|
238
|
+
var n;
|
|
239
|
+
(n = this.onerror) == null || n.call(this, o);
|
|
240
|
+
};
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Connects the client to a transport via the specified option.
|
|
244
|
+
*/
|
|
245
|
+
async connect(e) {
|
|
246
|
+
if (typeof e.start == "function")
|
|
247
|
+
return this.transport = e, this.transport.onclose = void 0, this.transport.onerror = void 0, this.transport.onmessage = void 0, await this.client.connect(this.transport), { transport: this.transport, sessionId: this.transport.sessionId };
|
|
248
|
+
const { url: t, token: i, sessionId: s, type: o, agent: n, onError: a } = e;
|
|
249
|
+
if (n === !0) {
|
|
250
|
+
const h = { client: this.client, url: t, token: i, sessionId: s };
|
|
251
|
+
let y;
|
|
252
|
+
return await (async () => {
|
|
253
|
+
const { transport: L, sessionId: E } = o === "sse" ? await U(h) : o === "socket" ? await z(h) : await H(h);
|
|
254
|
+
L.onerror = async (R) => {
|
|
255
|
+
a == null || a(R);
|
|
256
|
+
}, y = { transport: L, sessionId: E };
|
|
257
|
+
})(), y;
|
|
258
|
+
}
|
|
259
|
+
const c = new URL(t);
|
|
260
|
+
let l;
|
|
261
|
+
if (o === "channel" && (l = new u(t), await this.client.connect(l)), o === "sse") {
|
|
262
|
+
const h = q(i, s);
|
|
263
|
+
l = new w(c, h), await this.client.connect(l);
|
|
264
|
+
}
|
|
265
|
+
if (o === "socket" && (l = new G(new URL(`${t}?sessionId=${s}&token=${i}`)), l.sessionId = s, await this.client.connect(l)), typeof l > "u") {
|
|
266
|
+
const h = Z(i, s);
|
|
267
|
+
l = new p(c, h), await this.client.connect(l);
|
|
268
|
+
}
|
|
269
|
+
return this.transport = l, { transport: this.transport, sessionId: this.transport.sessionId };
|
|
270
|
+
}
|
|
271
|
+
/**
|
|
272
|
+
* Closes the connection.
|
|
273
|
+
*/
|
|
274
|
+
async close() {
|
|
275
|
+
await this.client.close();
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
278
|
+
* After initialization has completed, this will be populated with the server's reported capabilities.
|
|
279
|
+
*/
|
|
280
|
+
getServerCapabilities() {
|
|
281
|
+
return this.client.getServerCapabilities();
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* After initialization has completed, this will be populated with information about the server's name and version.
|
|
285
|
+
*/
|
|
286
|
+
getServerVersion() {
|
|
287
|
+
return this.client.getServerVersion();
|
|
288
|
+
}
|
|
289
|
+
/**
|
|
290
|
+
* After initialization has completed, this may be populated with information about the server's instructions.
|
|
291
|
+
*/
|
|
292
|
+
getInstructions() {
|
|
293
|
+
return this.client.getInstructions();
|
|
294
|
+
}
|
|
295
|
+
/**
|
|
296
|
+
* Sends a ping to the server to check if it is still connected.
|
|
297
|
+
*/
|
|
298
|
+
async ping(e) {
|
|
299
|
+
return await this.client.ping(e);
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* Sends a completion request to the server.
|
|
303
|
+
*/
|
|
304
|
+
async complete(e, t) {
|
|
305
|
+
return await this.client.complete(e, t);
|
|
306
|
+
}
|
|
307
|
+
/**
|
|
308
|
+
* Sends a request for setting the logging level to the server.
|
|
309
|
+
*/
|
|
310
|
+
async setLoggingLevel(e, t) {
|
|
311
|
+
return await this.client.setLoggingLevel(e, t);
|
|
312
|
+
}
|
|
313
|
+
/**
|
|
314
|
+
* Gets the prompt with the given params from the server.
|
|
315
|
+
*/
|
|
316
|
+
async getPrompt(e, t) {
|
|
317
|
+
return await this.client.getPrompt(e, t);
|
|
318
|
+
}
|
|
319
|
+
/**
|
|
320
|
+
* Lists all prompts available on the server.
|
|
321
|
+
*/
|
|
322
|
+
async listPrompts(e, t) {
|
|
323
|
+
return await this.client.listPrompts(e, t);
|
|
324
|
+
}
|
|
325
|
+
/**
|
|
326
|
+
* Lists all resources available on the server.
|
|
327
|
+
*/
|
|
328
|
+
async listResources(e, t) {
|
|
329
|
+
return await this.client.listResources(e, t);
|
|
330
|
+
}
|
|
331
|
+
/**
|
|
332
|
+
* Lists all resource templates available on the server.
|
|
333
|
+
*/
|
|
334
|
+
async listResourceTemplates(e, t) {
|
|
335
|
+
return await this.client.listResourceTemplates(e, t);
|
|
336
|
+
}
|
|
337
|
+
/**
|
|
338
|
+
* Reads the resource with the given params from the server.
|
|
339
|
+
*/
|
|
340
|
+
async readResource(e, t) {
|
|
341
|
+
return await this.client.readResource(e, t);
|
|
342
|
+
}
|
|
343
|
+
/**
|
|
344
|
+
* Subscribes to a resource on the server.
|
|
345
|
+
*/
|
|
346
|
+
async subscribeResource(e, t) {
|
|
347
|
+
return await this.client.subscribeResource(e, t);
|
|
348
|
+
}
|
|
349
|
+
/**
|
|
350
|
+
* Unsubscribes from a resource on the server.
|
|
351
|
+
*/
|
|
352
|
+
async unsubscribeResource(e, t) {
|
|
353
|
+
return await this.client.unsubscribeResource(e, t);
|
|
354
|
+
}
|
|
355
|
+
/**
|
|
356
|
+
* Calls a tool on the server with the given parameters.
|
|
357
|
+
*/
|
|
358
|
+
async callTool(e, t) {
|
|
359
|
+
return await this.client.callTool(e, D, t);
|
|
360
|
+
}
|
|
361
|
+
/**
|
|
362
|
+
* Lists all tools available on the server.
|
|
363
|
+
*/
|
|
364
|
+
async listTools(e, t) {
|
|
365
|
+
return await this.client.listTools(e, t);
|
|
366
|
+
}
|
|
367
|
+
/**
|
|
368
|
+
* Sends a notification for the roots list changed event to the server.
|
|
369
|
+
*/
|
|
370
|
+
async sendRootsListChanged() {
|
|
371
|
+
return await this.client.sendRootsListChanged();
|
|
372
|
+
}
|
|
373
|
+
/**
|
|
374
|
+
* Sends a request and wait for a response.
|
|
375
|
+
*
|
|
376
|
+
* Do not use this method to emit notifications! Use notification() instead.
|
|
377
|
+
*/
|
|
378
|
+
request(e, t, i) {
|
|
379
|
+
return this.client.request(e, t, i);
|
|
380
|
+
}
|
|
381
|
+
/**
|
|
382
|
+
* Emits a notification, which is a one-way message that does not expect a response.
|
|
383
|
+
*/
|
|
384
|
+
async notification(e, t) {
|
|
385
|
+
return await this.client.notification(e, t);
|
|
386
|
+
}
|
|
387
|
+
/**
|
|
388
|
+
* Registers a handler to invoke when this protocol object receives a request with the given method.
|
|
389
|
+
*
|
|
390
|
+
* Note that this will replace any previous request handler for the same method.
|
|
391
|
+
*/
|
|
392
|
+
setRequestHandler(e, t) {
|
|
393
|
+
this.client.setRequestHandler(e, t);
|
|
394
|
+
}
|
|
395
|
+
/**
|
|
396
|
+
* Removes the request handler for the given method.
|
|
397
|
+
*/
|
|
398
|
+
removeRequestHandler(e) {
|
|
399
|
+
this.client.removeRequestHandler(e);
|
|
400
|
+
}
|
|
401
|
+
/**
|
|
402
|
+
* Registers a handler to invoke when this protocol object receives a notification with the given method.
|
|
403
|
+
*
|
|
404
|
+
* Note that this will replace any previous notification handler for the same method.
|
|
405
|
+
*/
|
|
406
|
+
setNotificationHandler(e, t) {
|
|
407
|
+
this.client.setNotificationHandler(e, t);
|
|
408
|
+
}
|
|
409
|
+
/**
|
|
410
|
+
* Removes the notification handler for the given method.
|
|
411
|
+
*/
|
|
412
|
+
removeNotificationHandler(e) {
|
|
413
|
+
this.client.removeNotificationHandler(e);
|
|
414
|
+
}
|
|
415
|
+
/**
|
|
416
|
+
* Registers a handler for the elicitation request.
|
|
417
|
+
*/
|
|
418
|
+
onElicit(e) {
|
|
419
|
+
this.client.setRequestHandler(A, e);
|
|
420
|
+
}
|
|
421
|
+
/**
|
|
422
|
+
* Registers a handler for the create LLM message request.
|
|
423
|
+
*/
|
|
424
|
+
onCreateMessage(e) {
|
|
425
|
+
this.client.setRequestHandler(W, e);
|
|
426
|
+
}
|
|
427
|
+
/**
|
|
428
|
+
* Registers a handler for the list roots request.
|
|
429
|
+
*/
|
|
430
|
+
onListRoots(e) {
|
|
431
|
+
this.client.setRequestHandler(Y, e);
|
|
432
|
+
}
|
|
433
|
+
/**
|
|
434
|
+
* Registers a handler for the tool list changed notification.
|
|
435
|
+
*/
|
|
436
|
+
onToolListChanged(e) {
|
|
437
|
+
this.client.setNotificationHandler(V, e);
|
|
438
|
+
}
|
|
439
|
+
/**
|
|
440
|
+
* Registers a handler for the prompt list changed notification.
|
|
441
|
+
*/
|
|
442
|
+
onPromptListChanged(e) {
|
|
443
|
+
this.client.setNotificationHandler(Q, e);
|
|
444
|
+
}
|
|
445
|
+
/**
|
|
446
|
+
* Registers a handler for the resource list changed notification.
|
|
447
|
+
*/
|
|
448
|
+
onResourceListChanged(e) {
|
|
449
|
+
this.client.setNotificationHandler(K, e);
|
|
450
|
+
}
|
|
451
|
+
/**
|
|
452
|
+
* Registers a handler for the resource updated notification.
|
|
453
|
+
*/
|
|
454
|
+
onResourceUpdated(e) {
|
|
455
|
+
this.client.setNotificationHandler(X, e);
|
|
456
|
+
}
|
|
457
|
+
/**
|
|
458
|
+
* Registers a handler for the logging message notification.
|
|
459
|
+
*/
|
|
460
|
+
onLoggingMessage(e) {
|
|
461
|
+
this.client.setNotificationHandler(J, e);
|
|
462
|
+
}
|
|
463
|
+
/**
|
|
464
|
+
* Close the transport for window.addEventListener('pagehide')
|
|
465
|
+
*/
|
|
466
|
+
async onPagehide(e) {
|
|
467
|
+
e.persisted || (l2(this.transport) ? await this.transport.terminateSession() : this.transport && typeof this.transport.close == "function" && await this.transport.close());
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
const O2 = (r, e) => new w(r, e), j2 = (r, e) => new p(r, e), B2 = (r, e) => new u(r, e), D2 = (r) => r instanceof w, l2 = (r) => r instanceof p, A2 = (r) => r instanceof u, W2 = (r) => r instanceof S, d = (r, e, t) => {
|
|
471
|
+
window.postMessage({ type: r, direction: t, data: e }, "*");
|
|
472
|
+
}, b = (r, e, t) => {
|
|
473
|
+
const i = async function(s) {
|
|
474
|
+
s.source === window && s.data.type === r && s.data.direction === t && await e(s.data.data);
|
|
475
|
+
};
|
|
476
|
+
return window.addEventListener("message", i), () => window.removeEventListener("message", i);
|
|
477
|
+
}, C = (r, e, t) => {
|
|
478
|
+
if (t.endsWith("content"))
|
|
479
|
+
chrome.tabs.query({}, (i) => {
|
|
480
|
+
i.forEach((s) => {
|
|
481
|
+
chrome.tabs.sendMessage(s.id, { type: r, data: e, direction: t, tabId: s.id });
|
|
482
|
+
});
|
|
483
|
+
});
|
|
484
|
+
else
|
|
485
|
+
return chrome.runtime.sendMessage({ direction: t, type: r, data: e });
|
|
486
|
+
}, m = (r, e, t, i) => {
|
|
487
|
+
const s = (o, n, a) => {
|
|
488
|
+
if (o.type === r && o.direction === t && (!i || i && o.tabId === i)) {
|
|
489
|
+
const { data: c } = o;
|
|
490
|
+
e(c, n, a), a(n);
|
|
491
|
+
}
|
|
492
|
+
};
|
|
493
|
+
return chrome.runtime.onMessage.addListener(s), () => chrome.runtime.onMessage.removeListener(s);
|
|
494
|
+
};
|
|
495
|
+
class h2 {
|
|
496
|
+
constructor(e) {
|
|
497
|
+
this._isStarted = !1, this._isClosed = !1, this.targetSessionId = e, this._messageListener = m(
|
|
498
|
+
"mcp-server-to-client",
|
|
499
|
+
(t) => {
|
|
500
|
+
var i;
|
|
501
|
+
try {
|
|
502
|
+
if (t.sessionId !== this.targetSessionId) return;
|
|
503
|
+
const s = f.parse(t.mcpMessage);
|
|
504
|
+
(i = this.onmessage) == null || i.call(this, s);
|
|
505
|
+
} catch (s) {
|
|
506
|
+
console.log("【Client Transport】处理server消息错误:", s);
|
|
507
|
+
}
|
|
508
|
+
},
|
|
509
|
+
"content->side"
|
|
510
|
+
);
|
|
511
|
+
}
|
|
512
|
+
// 是否已关闭
|
|
513
|
+
_throwError(e, t) {
|
|
514
|
+
if (e()) {
|
|
515
|
+
const i = new Error(t);
|
|
516
|
+
throw console.log(t, i), this.onerror && this.onerror(i), i;
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
/** 启动 transport,开始监听消息 */
|
|
520
|
+
async start() {
|
|
521
|
+
this._throwError(() => this._isClosed, "【Client Transport】 未启动,无法重新启动"), this._isStarted = !0;
|
|
522
|
+
}
|
|
523
|
+
/** 发送消息到 MCP Server */
|
|
524
|
+
async send(e, t) {
|
|
525
|
+
this._throwError(() => !this._isStarted, "【Client Transport】 未启动,无法发送消息"), this._throwError(() => this._isClosed, "【Client Transport】 已关闭,无法发送消息");
|
|
526
|
+
const i = chrome.sessionRegistry.get(this.targetSessionId);
|
|
527
|
+
this._throwError(() => !i, `【Client Transport】sessionRegistry中未找到${this.targetSessionId}`);
|
|
528
|
+
const s = i.tabIds[i.tabIds.length - 1];
|
|
529
|
+
C(
|
|
530
|
+
"mcp-client-to-server",
|
|
531
|
+
{ sessionId: this.targetSessionId, tabId: s, mcpMessage: e },
|
|
532
|
+
"side->content"
|
|
533
|
+
);
|
|
534
|
+
}
|
|
535
|
+
/** 关闭 transport */
|
|
536
|
+
async close() {
|
|
537
|
+
if (!this._isClosed)
|
|
538
|
+
try {
|
|
539
|
+
this._isClosed = !0, this._isStarted = !1, this._messageListener && this._messageListener(), this.onclose && this.onclose();
|
|
540
|
+
} catch {
|
|
541
|
+
this._throwError(() => !0, "【Client Transport】 关闭时发生错误");
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
const P = () => typeof crypto < "u" && crypto.randomUUID ? crypto.randomUUID() : "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (r) => {
|
|
546
|
+
const e = Math.random() * 16 | 0;
|
|
547
|
+
return (r === "x" ? e : e & 3 | 8).toString(16);
|
|
548
|
+
});
|
|
549
|
+
class Y2 {
|
|
550
|
+
constructor(e = null, t) {
|
|
551
|
+
this._isStarted = !1, this._isClosed = !1, this._lastRegistration = null, this.sessionId = e || P(), this.tabId = t, this._messageListener1 = b(
|
|
552
|
+
"sidepanel-ready-to-page",
|
|
553
|
+
() => {
|
|
554
|
+
this._lastRegistration && this._isStarted && this.notifyRegistration(this._lastRegistration).catch((i) => {
|
|
555
|
+
console.error("【Page Svr Transport】 notifyRegistration失败:", i);
|
|
556
|
+
});
|
|
557
|
+
},
|
|
558
|
+
"content->page"
|
|
559
|
+
), this._messageListener2 = b(
|
|
560
|
+
"mcp-client-to-server-to-page",
|
|
561
|
+
(i) => {
|
|
562
|
+
var n, a, c;
|
|
563
|
+
if (i.sessionId !== this.sessionId || i.tabId !== this.tabId) return;
|
|
564
|
+
console.log("【Page Svr Transport】 即将处理 mcpMessage", i.mcpMessage);
|
|
565
|
+
const s = f.parse(i.mcpMessage);
|
|
566
|
+
(n = this.onmessage) == null || n.call(this, s), ((a = i.mcpMessage.params) == null ? void 0 : a.name) && d(
|
|
567
|
+
"update-page-app-message",
|
|
568
|
+
{ status: "run", message: (c = i.mcpMessage.params) == null ? void 0 : c.name },
|
|
569
|
+
"page->content"
|
|
570
|
+
);
|
|
571
|
+
},
|
|
572
|
+
"content->page"
|
|
573
|
+
);
|
|
574
|
+
}
|
|
575
|
+
// 最后一次注册信息(用于 Sidepanel 刷新后重新注册)
|
|
576
|
+
_throwError(e, t) {
|
|
577
|
+
if (e()) {
|
|
578
|
+
const i = new Error(t);
|
|
579
|
+
throw console.log(t, i), this.onerror && this.onerror(i), i;
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
/** 启动 transport,开始监听消息 */
|
|
583
|
+
async start() {
|
|
584
|
+
if (!this._isStarted) {
|
|
585
|
+
if (this._isClosed) throw new Error("【Page Svr Transport】 已关闭,无法重新启动");
|
|
586
|
+
this._isStarted = !0;
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
/** 发送消息到 MCP Client */
|
|
590
|
+
async send(e, t) {
|
|
591
|
+
var i;
|
|
592
|
+
this._throwError(() => !this._isStarted, "【Page Svr Transport】 未启动,无法发送消息"), this._throwError(() => this._isClosed, "【Page Svr Transport】 已关闭,无法发送消息"), d(
|
|
593
|
+
"mcp-server-to-client-from-page",
|
|
594
|
+
{
|
|
595
|
+
sessionId: this.sessionId,
|
|
596
|
+
mcpMessage: e
|
|
597
|
+
},
|
|
598
|
+
"page->content"
|
|
599
|
+
), "result" in e && ((i = e.result) != null && i.content) && d(
|
|
600
|
+
"update-page-app-message",
|
|
601
|
+
{ status: "ready", message: "" },
|
|
602
|
+
"page->content"
|
|
603
|
+
// 此处应该是 content->content, 但为了和pageServerTransport统一。
|
|
604
|
+
);
|
|
605
|
+
}
|
|
606
|
+
/** 通知 Sidepanel 此 Server 已启动并准备接受连接 */
|
|
607
|
+
async notifyRegistration(e) {
|
|
608
|
+
this._throwError(() => !this._isStarted, "【Page Svr Transport】 未启动,无法注册消息"), this._lastRegistration = e;
|
|
609
|
+
try {
|
|
610
|
+
d(
|
|
611
|
+
"mcp-server-register-from-page",
|
|
612
|
+
{
|
|
613
|
+
sessionId: this.sessionId,
|
|
614
|
+
serverInfo: {
|
|
615
|
+
...e,
|
|
616
|
+
url: window.location.origin,
|
|
617
|
+
title: document.title
|
|
618
|
+
}
|
|
619
|
+
},
|
|
620
|
+
"page->content"
|
|
621
|
+
);
|
|
622
|
+
} catch (t) {
|
|
623
|
+
this._throwError(() => !0, "【Page Svr Transport】 注册 server 失败" + String(t));
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
/** 关闭 transport */
|
|
627
|
+
async close() {
|
|
628
|
+
if (!this._isClosed)
|
|
629
|
+
try {
|
|
630
|
+
this._messageListener1 && this._messageListener1(), this._messageListener2 && this._messageListener2(), this._isClosed = !0, this._isStarted = !1, this.onclose && this.onclose();
|
|
631
|
+
} catch (e) {
|
|
632
|
+
this._throwError(() => !0, "【Page Svr Transport】 关闭时发生错误" + String(e));
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
class V2 {
|
|
637
|
+
constructor(e = null, t) {
|
|
638
|
+
this._isStarted = !1, this._isClosed = !1, this._lastRegistration = null, this.sessionId = e || P(), this.tabId = t, m(
|
|
639
|
+
"sidepanel-ready",
|
|
640
|
+
() => {
|
|
641
|
+
this._lastRegistration && this._isStarted && this.notifyRegistration(this._lastRegistration).catch((i) => {
|
|
642
|
+
console.log("【Content Svr Transport】 notifyRegistration 失败", i);
|
|
643
|
+
});
|
|
644
|
+
},
|
|
645
|
+
"side->content",
|
|
646
|
+
this.tabId
|
|
647
|
+
);
|
|
648
|
+
}
|
|
649
|
+
// 最后一次注册信息(用于 Sidepanel 刷新后重新注册)
|
|
650
|
+
_throwError(e, t) {
|
|
651
|
+
if (e()) {
|
|
652
|
+
const i = new Error(t);
|
|
653
|
+
throw console.log(t, i), this.onerror && this.onerror(i), i;
|
|
654
|
+
}
|
|
655
|
+
}
|
|
656
|
+
/** 启动 transport,开始监听MCP client 消息 */
|
|
657
|
+
async start() {
|
|
658
|
+
if (console.log("【Content Svr Transport】 启动 start", this.sessionId), !this._isStarted) {
|
|
659
|
+
if (this._isClosed) throw new Error("【Content Svr Transport】 已关闭,无法重新启动");
|
|
660
|
+
m(
|
|
661
|
+
"mcp-client-to-server",
|
|
662
|
+
(e) => {
|
|
663
|
+
var t, i, s;
|
|
664
|
+
if (!(e.sessionId !== this.sessionId || e.tabId !== this.tabId))
|
|
665
|
+
try {
|
|
666
|
+
console.log("【Content Svr Transport】 即将处理 mcpMessage", e.mcpMessage);
|
|
667
|
+
const o = f.parse(e.mcpMessage);
|
|
668
|
+
(t = this.onmessage) == null || t.call(this, o), ((i = e.mcpMessage.params) == null ? void 0 : i.name) && d(
|
|
669
|
+
"update-page-app-message",
|
|
670
|
+
{ status: "run", message: (s = e.mcpMessage.params) == null ? void 0 : s.name },
|
|
671
|
+
"page->content"
|
|
672
|
+
// 此处应该是 content->content, 但为了和pageServerTransport统一。
|
|
673
|
+
);
|
|
674
|
+
} catch (o) {
|
|
675
|
+
console.log("【Content Svr Transport】 处理消息时发生错误:", o);
|
|
676
|
+
}
|
|
677
|
+
},
|
|
678
|
+
"side->content",
|
|
679
|
+
this.tabId
|
|
680
|
+
), this._isStarted = !0;
|
|
681
|
+
}
|
|
682
|
+
}
|
|
683
|
+
/** 发送消息到 MCP Client */
|
|
684
|
+
async send(e, t) {
|
|
685
|
+
var i;
|
|
686
|
+
this._throwError(() => !this._isStarted, "【Content Svr Transport】 未启动,无法发送消息"), this._throwError(() => this._isClosed, "【Content Svr Transport】 已关闭,无法发送消息");
|
|
687
|
+
try {
|
|
688
|
+
console.log("【Content Svr Transport】 发送消息到 MCP Client", e), C(
|
|
689
|
+
"mcp-server-to-client",
|
|
690
|
+
{
|
|
691
|
+
sessionId: this.sessionId,
|
|
692
|
+
mcpMessage: e
|
|
693
|
+
},
|
|
694
|
+
"content->side"
|
|
695
|
+
), "result" in e && ((i = e.result) != null && i.content) && d(
|
|
696
|
+
"update-page-app-message",
|
|
697
|
+
{ status: "ready", message: "" },
|
|
698
|
+
"page->content"
|
|
699
|
+
// 此处应该是 content->content, 但为了和pageServerTransport统一。
|
|
700
|
+
);
|
|
701
|
+
} catch (s) {
|
|
702
|
+
this._throwError(() => !0, "【Content Svr Transport】发送消息失败" + String(s));
|
|
703
|
+
}
|
|
704
|
+
}
|
|
705
|
+
/** 通知 Sidepanel 此 Server 已启动并准备接受连接 */
|
|
706
|
+
async notifyRegistration(e) {
|
|
707
|
+
this._isStarted && (this._lastRegistration = e, C(
|
|
708
|
+
"mcp-server-register",
|
|
709
|
+
{
|
|
710
|
+
sessionId: this.sessionId,
|
|
711
|
+
serverInfo: {
|
|
712
|
+
...e,
|
|
713
|
+
url: window.location.origin,
|
|
714
|
+
title: document.title
|
|
715
|
+
}
|
|
716
|
+
},
|
|
717
|
+
"content->side"
|
|
718
|
+
));
|
|
719
|
+
}
|
|
720
|
+
async close() {
|
|
721
|
+
if (!this._isClosed)
|
|
722
|
+
try {
|
|
723
|
+
this._isClosed = !0, this._isStarted = !1, this.onclose && this.onclose();
|
|
724
|
+
} catch (e) {
|
|
725
|
+
this._throwError(() => !0, "【Content Svr Transport】 关闭时发生错误" + String(e));
|
|
726
|
+
}
|
|
727
|
+
}
|
|
728
|
+
}
|
|
729
|
+
class d2 {
|
|
730
|
+
constructor(e, { size: t = 200, margin: i = 4, color: s = "#000", bgColor: o = "#fff" }) {
|
|
731
|
+
this.value = e, this.size = t, this.margin = i, this.color = s, this.bgColor = o;
|
|
732
|
+
}
|
|
733
|
+
get qrCodeOption() {
|
|
734
|
+
return {
|
|
735
|
+
width: this.size,
|
|
736
|
+
margin: this.margin,
|
|
737
|
+
color: {
|
|
738
|
+
dark: this.color,
|
|
739
|
+
// 前景色
|
|
740
|
+
light: this.bgColor
|
|
741
|
+
// 背景色
|
|
742
|
+
}
|
|
743
|
+
};
|
|
744
|
+
}
|
|
745
|
+
/** 生成二维码的 Data URL(base64 图片) */
|
|
746
|
+
async toDataURL() {
|
|
747
|
+
return x.toDataURL(this.value, this.qrCodeOption);
|
|
748
|
+
}
|
|
749
|
+
/** 渲染二维码到指定的 canvas 元素 */
|
|
750
|
+
async toCanvas(e) {
|
|
751
|
+
return x.toCanvas(e, this.value, this.qrCodeOption);
|
|
752
|
+
}
|
|
753
|
+
/** 渲染二维码到指定的 img 元素 */
|
|
754
|
+
async toImage(e) {
|
|
755
|
+
e.src = await this.toDataURL();
|
|
756
|
+
}
|
|
757
|
+
}
|
|
758
|
+
const p2 = {
|
|
759
|
+
content: "",
|
|
760
|
+
placement: "top",
|
|
761
|
+
trigger: "hover",
|
|
762
|
+
delay: 150,
|
|
763
|
+
hideDelay: 150,
|
|
764
|
+
container: document.body,
|
|
765
|
+
className: "tiny-remoter-native-tooltip"
|
|
766
|
+
};
|
|
767
|
+
class C2 {
|
|
768
|
+
constructor(e, t = {}) {
|
|
769
|
+
if (this.tip = null, this.showTimer = 0, this.hideTimer = 0, this.clickOutside = null, this.el = typeof e == "string" ? document.querySelector(e) : e, !this.el) throw new Error("Tooltip: invalid element");
|
|
770
|
+
this.opts = { ...p2, ...t }, this.bindEvents();
|
|
771
|
+
}
|
|
772
|
+
/* 公开 API */
|
|
773
|
+
open() {
|
|
774
|
+
this.isShown() || (this.clearTimer(), this.showTimer = window.setTimeout(() => {
|
|
775
|
+
this.render(), this.opts.container.appendChild(this.tip), this.reposition(), this.attachExtraEvents();
|
|
776
|
+
}, this.opts.delay));
|
|
777
|
+
}
|
|
778
|
+
close() {
|
|
779
|
+
this.clearTimer(), this.hideTimer = window.setTimeout(() => {
|
|
780
|
+
var e;
|
|
781
|
+
(e = this.tip) == null || e.remove(), this.detachExtraEvents();
|
|
782
|
+
}, this.opts.hideDelay);
|
|
783
|
+
}
|
|
784
|
+
toggle() {
|
|
785
|
+
this.isShown() ? this.close() : this.open();
|
|
786
|
+
}
|
|
787
|
+
destroy() {
|
|
788
|
+
this.close();
|
|
789
|
+
const e = this.opts.trigger;
|
|
790
|
+
this.el.removeEventListener("mouseenter", this.open), this.el.removeEventListener("mouseleave", this.close), this.el.removeEventListener("focus", this.open), this.el.removeEventListener("blur", this.close), e === "click" && this.el.removeEventListener("click", this.toggle);
|
|
791
|
+
}
|
|
792
|
+
/* 私有方法 */
|
|
793
|
+
bindEvents() {
|
|
794
|
+
const e = this.opts.trigger;
|
|
795
|
+
e === "hover" ? (this.el.addEventListener("mouseenter", () => this.open()), this.el.addEventListener("mouseleave", () => this.close())) : e === "focus" ? (this.el.addEventListener("focus", () => this.open()), this.el.addEventListener("blur", () => this.close())) : e === "click" && this.el.addEventListener("click", () => this.toggle());
|
|
796
|
+
}
|
|
797
|
+
render() {
|
|
798
|
+
if (this.tip) return;
|
|
799
|
+
const e = typeof this.opts.content == "function" ? this.opts.content() : this.opts.content;
|
|
800
|
+
this.tip = document.createElement("div"), this.tip.className = `${this.opts.className} ${this.opts.className}--${this.opts.placement}`, this.tip.innerHTML = `
|
|
801
|
+
<div class="${this.opts.className}__arrow"></div>
|
|
802
|
+
<div class="${this.opts.className}__inner">${e}</div>
|
|
803
|
+
`;
|
|
804
|
+
}
|
|
805
|
+
reposition() {
|
|
806
|
+
const e = this.placementList(this.opts.placement);
|
|
807
|
+
for (const t of e) {
|
|
808
|
+
const i = this.calcStyle(t);
|
|
809
|
+
if (this.checkViewport(i)) {
|
|
810
|
+
this.applyStyle(i), this.tip.className = `${this.opts.className} ${this.opts.className}--${t}`;
|
|
811
|
+
return;
|
|
812
|
+
}
|
|
813
|
+
}
|
|
814
|
+
this.applyStyle(this.calcStyle("top"));
|
|
815
|
+
}
|
|
816
|
+
calcStyle(e) {
|
|
817
|
+
const t = this.el.getBoundingClientRect(), i = this.tip.getBoundingClientRect(), s = window.pageYOffset || document.documentElement.scrollTop, o = window.pageXOffset || document.documentElement.scrollLeft, n = 6, [a, c = "center"] = e.split("-");
|
|
818
|
+
let l = 0, h = 0;
|
|
819
|
+
return a === "top" ? l = t.top + s - i.height - n : a === "bottom" ? l = t.bottom + s + n : a === "left" ? h = t.left + o - i.width - n : a === "right" && (h = t.right + o + n), (a === "top" || a === "bottom") && (c === "start" ? h = t.left + o : c === "end" ? h = t.right + o - i.width : h = (t.left + t.right) / 2 + o - i.width / 2), (a === "left" || a === "right") && (c === "start" ? l = t.top + s : c === "end" ? l = t.bottom + s - i.height : l = (t.top + t.bottom) / 2 + s - i.height / 2), { top: Math.round(l), left: Math.round(h) };
|
|
820
|
+
}
|
|
821
|
+
applyStyle({ top: e, left: t }) {
|
|
822
|
+
Object.assign(this.tip.style, {
|
|
823
|
+
position: "absolute",
|
|
824
|
+
top: `${e}px`,
|
|
825
|
+
left: `${t}px`
|
|
826
|
+
});
|
|
827
|
+
}
|
|
828
|
+
checkViewport({ top: e, left: t }) {
|
|
829
|
+
const s = window.innerWidth, o = window.innerHeight, n = this.tip.getBoundingClientRect();
|
|
830
|
+
return t >= 5 && e >= 5 && t + n.width <= s - 5 && e + n.height <= o - 5;
|
|
831
|
+
}
|
|
832
|
+
placementList(e) {
|
|
833
|
+
const t = {
|
|
834
|
+
top: ["top", "bottom", "top-start", "bottom-start", "top-end", "bottom-end"],
|
|
835
|
+
bottom: ["bottom", "top", "bottom-start", "top-start", "bottom-end", "top-end"],
|
|
836
|
+
left: ["left", "right", "left-start", "right-start", "left-end", "right-end"],
|
|
837
|
+
right: ["right", "left", "right-start", "left-start", "right-end", "left-end"]
|
|
838
|
+
};
|
|
839
|
+
return t[e.split("-")[0]] || t.top;
|
|
840
|
+
}
|
|
841
|
+
attachExtraEvents() {
|
|
842
|
+
this.opts.trigger === "click" ? (this.clickOutside = (e) => {
|
|
843
|
+
const t = e.composedPath();
|
|
844
|
+
!t.includes(this.el) && !t.includes(this.tip) && this.close();
|
|
845
|
+
}, document.addEventListener("mousedown", this.clickOutside)) : this.opts.trigger === "hover" && (this.tip.addEventListener("mouseenter", () => this.clearTimer()), this.tip.addEventListener("mouseleave", () => this.close()));
|
|
846
|
+
}
|
|
847
|
+
detachExtraEvents() {
|
|
848
|
+
this.clickOutside && (document.removeEventListener("mousedown", this.clickOutside), this.clickOutside = null);
|
|
849
|
+
}
|
|
850
|
+
clearTimer() {
|
|
851
|
+
clearTimeout(this.showTimer), clearTimeout(this.hideTimer);
|
|
852
|
+
}
|
|
853
|
+
isShown() {
|
|
854
|
+
var e;
|
|
855
|
+
return !!((e = this.tip) != null && e.parentNode);
|
|
856
|
+
}
|
|
857
|
+
}
|
|
858
|
+
const _ = "tiny-remoter-native-tooltip-style";
|
|
859
|
+
(() => {
|
|
860
|
+
if (document.getElementById(_)) return;
|
|
861
|
+
const r = document.createElement("style");
|
|
862
|
+
r.id = _, r.textContent = `
|
|
863
|
+
.tiny-remoter-native-tooltip {
|
|
864
|
+
position: absolute;
|
|
865
|
+
z-index: 9999;
|
|
866
|
+
max-width: 200px;
|
|
867
|
+
padding: 6px 10px;
|
|
868
|
+
font-size: 12px;
|
|
869
|
+
line-height: 1.4;
|
|
870
|
+
color: #fff;
|
|
871
|
+
background: #191919;
|
|
872
|
+
border-radius: 4px;
|
|
873
|
+
pointer-events: none;
|
|
874
|
+
box-shadow: 0px 4px 8px 0px rgba(0, 0, 0, 0.2);
|
|
875
|
+
}
|
|
876
|
+
.tiny-remoter-native-tooltip__arrow {
|
|
877
|
+
position: absolute;
|
|
878
|
+
width: 0; height: 0;
|
|
879
|
+
border: 6px solid transparent;
|
|
880
|
+
}
|
|
881
|
+
.tiny-remoter-native-tooltip--top
|
|
882
|
+
.tiny-remoter-native-tooltip__arrow {
|
|
883
|
+
bottom: -12px;
|
|
884
|
+
left: 50%; transform:
|
|
885
|
+
translateX(-50%);
|
|
886
|
+
border-top-color: rgba(0,0,0,.75);
|
|
887
|
+
}
|
|
888
|
+
.tiny-remoter-native-tooltip--bottom
|
|
889
|
+
.tiny-remoter-native-tooltip__arrow {
|
|
890
|
+
top: -12px;
|
|
891
|
+
left: 50%; transform:
|
|
892
|
+
translateX(-50%);
|
|
893
|
+
border-bottom-color: rgba(0,0,0,.75);
|
|
894
|
+
}
|
|
895
|
+
.tiny-remoter-native-tooltip--left
|
|
896
|
+
.tiny-remoter-native-tooltip__arrow {
|
|
897
|
+
right: -12px;
|
|
898
|
+
top: 50%;
|
|
899
|
+
transform: translateY(-50%);
|
|
900
|
+
border-left-color: rgba(0,0,0,.75);
|
|
901
|
+
}
|
|
902
|
+
.tiny-remoter-native-tooltip--right
|
|
903
|
+
.tiny-remoter-native-tooltip__arrow {
|
|
904
|
+
left: -12px;
|
|
905
|
+
top: 50%;
|
|
906
|
+
transform: translateY(-50%);
|
|
907
|
+
border-right-color: rgba(0,0,0,.75);
|
|
908
|
+
}
|
|
909
|
+
`, document.head.appendChild(r);
|
|
910
|
+
})();
|
|
911
|
+
const m2 = "data:image/svg+xml,%3csvg%20viewBox='0%200%2040%2039.9692'%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20width='40.000000'%20height='39.969238'%20fill='none'%20customFrame='url(%23clipPath_3)'%3e%3cdefs%3e%3cclipPath%20id='clipPath_3'%3e%3crect%20width='40.000000'%20height='39.969238'%20x='0.000000'%20y='0.000000'%20rx='12.000000'%20fill='rgb(255,255,255)'%20/%3e%3c/clipPath%3e%3cclipPath%20id='clipPath_4'%3e%3crect%20width='24.000000'%20height='24.000000'%20x='8.000000'%20y='7.984619'%20fill='rgb(255,255,255)'%20/%3e%3c/clipPath%3e%3cclipPath%20id='clipPath_5'%3e%3crect%20width='20.000000'%20height='20.000000'%20x='10.000000'%20y='9.984619'%20fill='rgb(255,255,255)'%20/%3e%3c/clipPath%3e%3cclipPath%20id='clipPath_6'%3e%3crect%20width='20.000000'%20height='20.000000'%20x='10.000000'%20y='9.984619'%20fill='rgb(255,255,255)'%20/%3e%3c/clipPath%3e%3cclipPath%20id='clipPath_7'%3e%3crect%20width='21.666666'%20height='13.333333'%20x='20.000000'%20y='9.984619'%20rx='6.666667'%20fill='rgb(255,255,255)'%20/%3e%3c/clipPath%3e%3cclipPath%20id='clipPath_8'%3e%3crect%20width='6.666667'%20height='6.666667'%20x='23.333496'%20y='9.984619'%20fill='rgb(255,255,255)'%20/%3e%3c/clipPath%3e%3c/defs%3e%3crect%20id='2'%20width='40.000000'%20height='39.969238'%20x='0.000000'%20y='0.000000'%20rx='12.000000'%20fill='rgb(239,246,255)'%20/%3e%3cg%20id='物业'%20clip-path='url(%23clipPath_4)'%20customFrame='url(%23clipPath_4)'%3e%3crect%20id='物业'%20width='24.000000'%20height='24.000000'%20x='8.000000'%20y='7.984619'%20/%3e%3cg%20id='物业服务'%3e%3cg%20id='00公共/红点/图标+红点'%20customFrame='url(%23clipPath_5)'%3e%3crect%20id='00公共/红点/图标+红点'%20width='20.000000'%20height='20.000000'%20x='10.000000'%20y='9.984619'%20/%3e%3cg%20id='common_chats_line'%20customFrame='url(%23clipPath_6)'%3e%3crect%20id='common_chats_line'%20width='20.000000'%20height='20.000000'%20x='10.000000'%20y='9.984619'%20/%3e%3cpath%20id='形状'%20d='M28.3332%2019.9847C28.3332%2015.3823%2024.6022%2011.6514%2019.9998%2011.6514C15.3975%2011.6514%2011.6665%2015.3823%2011.6665%2019.9847C11.6665%2024.5871%2015.3975%2028.318%2019.9998%2028.318C21.0018%2028.318%2021.9624%2028.1412%2022.8522%2027.8171L26.581%2028.1578C26.7205%2028.1706%2026.8611%2028.1598%2026.9971%2028.1259C27.6669%2027.959%2028.0746%2027.2806%2027.9077%2026.6108L27.2716%2024.0578C27.9477%2022.8535%2028.3332%2021.4641%2028.3332%2019.9847ZM19.9998%2013.1514C16.2259%2013.1514%2013.1665%2016.2108%2013.1665%2019.9847C13.1665%2023.7586%2016.2259%2026.818%2019.9998%2026.818C20.8089%2026.818%2021.5967%2026.678%2022.3388%2026.4077C22.505%2026.3471%2022.6803%2026.3166%2022.8565%2026.3171L22.9887%2026.3233L26.3665%2026.6322L25.8161%2024.4205C25.7352%2024.0958%2025.7655%2023.7548%2025.8997%2023.4512L25.9636%2023.3236C26.5311%2022.3126%2026.8332%2021.1723%2026.8332%2019.9847C26.8332%2016.2108%2023.7738%2013.1514%2019.9998%2013.1514ZM23.1152%2021.2468C23.352%2020.9069%2023.2684%2020.4394%2022.9286%2020.2026C22.5887%2019.9659%2022.1212%2020.0494%2021.8845%2020.3893C21.2894%2021.2433%2020.4268%2021.7347%2019.5102%2021.7347C18.9513%2021.7347%2018.4132%2021.554%2017.9375%2021.2122C17.6011%2020.9705%2017.1325%2021.0472%2016.8908%2021.3836C16.6491%2021.7199%2016.7258%2022.1886%2017.0622%2022.4303C17.7879%2022.9518%2018.6305%2023.2347%2019.5102%2023.2347C20.9394%2023.2347%2022.2505%2022.4878%2023.1152%2021.2468Z'%20fill='rgb(65,142,255)'%20fill-rule='evenodd'%20/%3e%3c/g%3e%3cg%20id='00公共/3位数红点'%20opacity='0'%20customFrame='url(%23clipPath_7)'%3e%3crect%20id='00公共/3位数红点'%20width='21.666666'%20height='13.333333'%20x='20.000000'%20y='9.984619'%20rx='6.666667'%20opacity='0'%20fill='rgb(243,111,100)'%20/%3e%3cpath%20id='文本'%20d='M26.0421%2013.4421C26.4259%2013.4421%2026.7677%2013.5255%2027.0675%2013.6923C27.3672%2013.8591%2027.6005%2014.0931%2027.7673%2014.3942C27.9342%2014.694%2028.0176%2015.0351%2028.0176%2015.4176C28.0176%2015.7173%2027.9633%2015.994%2027.8548%2016.2476C27.7463%2016.4999%2027.5673%2016.8315%2027.3177%2017.2425L25.859%2019.6432L25.0167%2019.6432L26.276%2017.5924C26.3534%2017.4704%2026.4307%2017.3564%2026.508%2017.2507C26.3357%2017.3063%2026.1445%2017.3341%2025.9342%2017.3341C25.5721%2017.3341%2025.2493%2017.2479%2024.9658%2017.0757C24.6837%2016.9034%2024.4633%2016.6701%2024.3046%2016.3758C24.1459%2016.0815%2024.0666%2015.7566%2024.0666%2015.4013C24.0666%2015.0351%2024.1513%2014.7021%2024.3209%2014.4023C24.4904%2014.1012%2024.7264%2013.8659%2025.0289%2013.6964C25.3314%2013.5268%2025.6691%2013.4421%2026.0421%2013.4421ZM26.0421%2016.6505C26.4029%2016.6505%2026.6904%2016.5325%2026.9047%2016.2965C27.119%2016.0605%2027.2262%2015.7539%2027.2262%2015.3769C27.2262%2014.9985%2027.119%2014.694%2026.9047%2014.4634C26.6904%2014.2328%2026.4029%2014.1175%2026.0421%2014.1175C25.6867%2014.1175%2025.4019%2014.2342%2025.1876%2014.4674C24.9733%2014.7007%2024.8661%2015.0039%2024.8661%2015.3769C24.8661%2015.7539%2024.9719%2016.0605%2025.1835%2016.2965C25.3951%2016.5325%2025.6813%2016.6505%2026.0421%2016.6505ZM30.7921%2013.4421C31.1759%2013.4421%2031.5177%2013.5255%2031.8175%2013.6923C32.1172%2013.8591%2032.3505%2014.0931%2032.5173%2014.3942C32.6842%2014.694%2032.7676%2015.0351%2032.7676%2015.4176C32.7676%2015.7173%2032.7133%2015.994%2032.6048%2016.2476C32.4963%2016.4999%2032.3173%2016.8315%2032.0677%2017.2425L30.609%2019.6432L29.7667%2019.6432L31.026%2017.5924C31.1034%2017.4704%2031.1807%2017.3564%2031.258%2017.2507C31.0857%2017.3063%2030.8945%2017.3341%2030.6842%2017.3341C30.3221%2017.3341%2029.9993%2017.2479%2029.7158%2017.0757C29.4337%2016.9034%2029.2133%2016.6701%2029.0546%2016.3758C28.8959%2016.0815%2028.8166%2015.7566%2028.8166%2015.4013C28.8166%2015.0351%2028.9013%2014.7021%2029.0709%2014.4023C29.2404%2014.1012%2029.4764%2013.8659%2029.7789%2013.6964C30.0814%2013.5268%2030.4191%2013.4421%2030.7921%2013.4421ZM30.7921%2016.6505C31.1529%2016.6505%2031.4404%2016.5325%2031.6547%2016.2965C31.869%2016.0605%2031.9762%2015.7539%2031.9762%2015.3769C31.9762%2014.9985%2031.869%2014.694%2031.6547%2014.4634C31.4404%2014.2328%2031.1529%2014.1175%2030.7921%2014.1175C30.4367%2014.1175%2030.1519%2014.2342%2029.9376%2014.4674C29.7233%2014.7007%2029.6161%2015.0039%2029.6161%2015.3769C29.6161%2015.7539%2029.7219%2016.0605%2029.9335%2016.2965C30.1451%2016.5325%2030.4313%2016.6505%2030.7921%2016.6505ZM35.2674%2014.6851L35.9001%2014.6851L35.9001%2016.3188L37.5339%2016.3188L37.5339%2016.9516L35.9001%2016.9516L35.9001%2018.5853L35.2674%2018.5853L35.2674%2016.9516L33.6337%2016.9516L33.6337%2016.3188L35.2674%2016.3188L35.2674%2014.6851Z'%20fill='rgb(255,255,255)'%20fill-rule='nonzero'%20/%3e%3c/g%3e%3cg%20id='00公共/单红点'%20opacity='0'%20customFrame='url(%23clipPath_8)'%3e%3crect%20id='00公共/单红点'%20width='6.666667'%20height='6.666667'%20x='23.333496'%20y='9.984619'%20opacity='0'%20fill='rgb(255,255,255)'%20fill-opacity='0'%20/%3e%3ccircle%20id='红点'%20cx='26.6668301'%20cy='13.3179522'%20r='3.33333325'%20fill='rgb(243,111,100)'%20/%3e%3c/g%3e%3c/g%3e%3c/g%3e%3c/g%3e%3c/svg%3e", g2 = "data:image/svg+xml,%3csvg%20viewBox='0%200%2040%2040'%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20width='40.000000'%20height='40.000000'%20fill='none'%20customFrame='url(%23clipPath_12)'%3e%3cdefs%3e%3cclipPath%20id='clipPath_12'%3e%3crect%20width='40.000000'%20height='40.000000'%20x='0.000000'%20y='0.000000'%20rx='12.000000'%20fill='rgb(255,255,255)'%20/%3e%3c/clipPath%3e%3cclipPath%20id='clipPath_13'%3e%3crect%20width='24.000000'%20height='24.000000'%20x='8.000000'%20y='8.000000'%20fill='rgb(255,255,255)'%20/%3e%3c/clipPath%3e%3cclipPath%20id='clipPath_14'%3e%3crect%20width='20.000000'%20height='20.000000'%20x='10.000000'%20y='10.000000'%20fill='rgb(255,255,255)'%20/%3e%3c/clipPath%3e%3c/defs%3e%3crect%20id='4'%20width='40.000000'%20height='40.000000'%20x='0.000000'%20y='0.000000'%20rx='12.000000'%20fill='rgb(234,255,244)'%20/%3e%3cg%20id='我的信息'%20clip-path='url(%23clipPath_13)'%20customFrame='url(%23clipPath_13)'%3e%3crect%20id='我的信息'%20width='24.000000'%20height='24.000000'%20x='8.000000'%20y='8.000000'%20/%3e%3cg%20id='组合%208'%20customFrame='url(%23clipPath_14)'%3e%3crect%20id='组合%208'%20width='20.000000'%20height='20.000000'%20x='10.000000'%20y='10.000000'%20/%3e%3cpath%20id='合并'%20d='M28.4994%2012.3142C28.4994%2012.2578%2028.4937%2012.2018%2028.4825%2012.1465C28.4713%2012.0911%2028.4547%2012.0373%2028.4327%2011.9851C28.4107%2011.933%2028.3836%2011.8835%2028.3516%2011.8365C28.3197%2011.7896%2028.2834%2011.7461%2028.2427%2011.7062C28.202%2011.6663%2028.1579%2011.6307%2028.1101%2011.5993C28.0622%2011.568%2028.0117%2011.5415%2027.9585%2011.5199C27.9054%2011.4983%2027.8506%2011.4819%2027.7942%2011.4709C27.7378%2011.4599%2027.6806%2011.4544%2027.6231%2011.4544L24.1832%2011.5199L24.1832%2010L29.0796%2010C29.1472%2010%2029.2143%2010.0065%2029.2806%2010.0194C29.347%2010.0324%2029.4114%2010.0516%2029.4739%2010.077C29.5364%2010.1024%2029.5961%2010.1336%2029.6523%2010.1705C29.7086%2010.2074%2029.7605%2010.2493%2029.8084%2010.2963C29.8562%2010.3433%2029.8991%2010.3944%2029.9367%2010.4496C29.9743%2010.5048%2030.006%2010.5631%2030.0319%2010.6244C30.0578%2010.6858%2030.0773%2010.7491%2030.0905%2010.8142C30.1037%2010.8794%2030.1104%2010.9451%2030.1104%2011.0115L30.1832%2014.4522L28.4992%2014.5L28.4994%2012.3142ZM11.6995%2012.3143C11.6995%2012.2579%2011.7051%2012.2019%2011.7163%2012.1466C11.7275%2012.0912%2011.7441%2012.0374%2011.7661%2011.9852C11.7882%2011.9331%2011.8152%2011.8836%2011.8472%2011.8366C11.8791%2011.7897%2011.9155%2011.7462%2011.9562%2011.7063C11.9968%2011.6664%2012.0409%2011.6308%2012.0888%2011.5994C12.1366%2011.5681%2012.1871%2011.5416%2012.2403%2011.52C12.2934%2011.4984%2012.3482%2011.482%2012.4046%2011.471C12.4611%2011.46%2012.5182%2011.4545%2012.5758%2011.4545L16.0157%2011.52L16.0157%2010.0001L11.1193%2010.0001C11.0516%2010.0001%2010.9846%2010.0066%2010.9182%2010.0196C10.8518%2010.0325%2010.7874%2010.0517%2010.7249%2010.0771C10.6624%2010.1025%2010.6028%2010.1337%2010.5465%2010.1706C10.4902%2010.2075%2010.4383%2010.2494%2010.3904%2010.2964C10.3426%2010.3434%2010.2997%2010.3945%2010.2621%2010.4497C10.2245%2010.5049%2010.1929%2010.5632%2010.167%2010.6245C10.1411%2010.6859%2010.1215%2010.7492%2010.1083%2010.8143C10.0951%2010.8795%2010.0885%2010.9452%2010.0884%2011.0116L10.0157%2014.4523L11.6997%2014.5L11.6995%2012.3143ZM25.3135%2021.8051L25.3135%2022.8167C25.7656%2022.8929%2026.2209%2022.9249%2026.6792%2022.9127C28.3381%2022.9127%2029.1675%2022.326%2029.1675%2021.1527C29.1733%2020.9869%2029.151%2020.825%2029.1006%2020.667C29.0503%2020.509%2028.9747%2020.3641%2028.8742%2020.2322C28.767%2020.1025%2028.6403%2019.9963%2028.4938%2019.9134C28.3474%2019.8306%2028.191%2019.7767%2028.0246%2019.7517L28.0246%2019.7011C28.0971%2019.6839%2028.1676%2019.6606%2028.236%2019.6311C28.3044%2019.6016%2028.3698%2019.5665%2028.4321%2019.5257C28.4944%2019.4848%2028.5526%2019.4389%2028.6069%2019.3879C28.6613%2019.3369%2028.7109%2019.2816%2028.7556%2019.222C28.8003%2019.1624%2028.8394%2019.0994%2028.8732%2019.033C28.9069%2018.9665%2028.9346%2018.8977%2028.9564%2018.8265C28.9782%2018.7552%2028.9937%2018.6826%2029.0028%2018.6086C29.0119%2018.5347%2029.0145%2018.4605%2029.0107%2018.3861C29.0217%2018.2675%2029.0176%2018.1495%2028.9984%2018.0319C28.9791%2017.9144%2028.9454%2017.8012%2028.8971%2017.6923C28.8489%2017.5834%2028.7875%2017.4823%2028.7134%2017.3891C28.6393%2017.2959%2028.5547%2017.2135%2028.4595%2017.1419C28.219%2017.0003%2027.963%2016.8972%2027.6915%2016.8326C27.4199%2016.7679%2027.1449%2016.7446%2026.8664%2016.7626C26.6258%2016.7621%2026.3864%2016.7791%2026.1482%2016.8132C25.9479%2016.8386%2025.7504%2016.8791%2025.5563%2016.9346L25.5563%2017.8854C25.743%2017.8264%2025.9337%2017.7842%2026.128%2017.759C26.3276%2017.73%2026.5282%2017.7148%2026.7298%2017.7134C27.0252%2017.6949%2027.3049%2017.7523%2027.5692%2017.8854C27.6168%2017.9161%2027.6595%2017.9525%2027.6972%2017.9947C27.7348%2018.037%2027.766%2018.0835%2027.791%2018.1343C27.816%2018.1851%2027.8337%2018.2383%2027.8441%2018.294C27.8545%2018.3496%2027.8573%2018.4056%2027.8525%2018.462C27.8566%2018.5278%2027.8514%2018.5927%2027.8367%2018.657C27.822%2018.7212%2027.7986%2018.7821%2027.7663%2018.8395C27.734%2018.897%2027.694%2018.9487%2027.6468%2018.9946C27.5995%2019.0405%2027.5468%2019.0787%2027.4885%2019.1093C27.1544%2019.2631%2026.8037%2019.3306%2026.4364%2019.3117L25.9862%2019.3117L25.9862%2020.1917L26.4466%2020.1917C26.8409%2020.1669%2027.2202%2020.2309%2027.5845%2020.3839C27.6459%2020.4167%2027.7011%2020.4576%2027.7505%2020.5066C27.7999%2020.5556%2027.8412%2020.6107%2027.8745%2020.6718C27.9077%2020.733%2027.9315%2020.7976%2027.9458%2020.8656C27.9602%2020.9337%2027.9644%2021.0024%2027.9587%2021.0717C27.9648%2021.1402%2027.9612%2021.2083%2027.9478%2021.2757C27.9344%2021.3432%2027.912%2021.4074%2027.8801%2021.4683C27.8483%2021.5293%2027.8086%2021.5846%2027.7609%2021.6341C27.7132%2021.6837%2027.6593%2021.7254%2027.5996%2021.7596C27.2884%2021.9045%2026.9613%2021.9685%2026.6184%2021.9518C26.1786%2021.9465%2025.7436%2021.8977%2025.3135%2021.8051ZM21.3382%2018.6238C21.3445%2018.5593%2021.343%2018.495%2021.3335%2018.4308C21.3241%2018.3667%2021.3069%2018.3046%2021.2822%2018.2447C21.2575%2018.1847%2021.226%2018.1287%2021.1876%2018.0765C21.1492%2018.0242%2021.1049%2017.9774%2021.055%2017.936C20.9359%2017.8608%2020.808%2017.806%2020.6714%2017.7714C20.5349%2017.7368%2020.3964%2017.7242%2020.2558%2017.7337C19.8009%2017.7395%2019.356%2017.8087%2018.9208%2017.9411L18.9208%2016.9598C19.4252%2016.8181%2019.9393%2016.7524%2020.4633%2016.7626C20.7322%2016.7484%2020.9964%2016.7773%2021.256%2016.8491C21.5156%2016.9209%2021.7571%2017.032%2021.9806%2017.1824C22.0729%2017.2601%2022.1548%2017.3474%2022.2263%2017.4446C22.2978%2017.5418%2022.3567%2017.646%2022.4034%2017.7573C22.45%2017.8686%2022.483%2017.9838%2022.5021%2018.1029C22.5213%2018.222%2022.5261%2018.3417%2022.5167%2018.462C22.5245%2018.7882%2022.4655%2019.1017%2022.3396%2019.4027C22.1879%2019.7384%2021.984%2020.0384%2021.7277%2020.3029C21.3021%2020.7337%2020.8502%2021.135%2020.3721%2021.5067L19.9928%2021.8051L19.9928%2021.8759L22.6938%2021.8759L22.6938%2022.8419L18.5464%2022.8419L18.5464%2021.7697C19.2882%2021.1796%2019.8579%2020.6975%2020.2558%2020.3232C20.574%2020.0432%2020.8523%2019.728%2021.0905%2019.3774C21.1675%2019.2665%2021.2269%2019.1469%2021.2691%2019.0187C21.3113%2018.8904%2021.3344%2018.7588%2021.3382%2018.6238ZM12.3102%2017.2127L12.3102%2018.1939L13.7769%2017.9107L13.7769%2022.8419L14.9605%2022.8419L14.9605%2016.8486L14.0957%2016.8486L12.3102%2017.2127ZM28.5524%2028.0475C28.5524%2028.104%2028.5467%2028.1599%2028.5353%2028.2152C28.5239%2028.2706%2028.5071%2028.3244%2028.4849%2028.3766C28.4626%2028.4287%2028.4352%2028.4782%2028.4028%2028.5252C28.3705%2028.5721%2028.3337%2028.6156%2028.2925%2028.6555C28.2513%2028.6954%2028.2067%2028.731%2028.1583%2028.7624C28.1098%2028.7937%2028.0587%2028.8202%2028.0049%2028.8418C27.9511%2028.8634%2027.8957%2028.8798%2027.8385%2028.8908C27.7814%2028.9018%2027.7235%2028.9073%2027.6653%2028.9073L24.1832%2028.8418L24.1832%2030.3617L29.1397%2030.3617C29.2082%2030.3617%2029.276%2030.3552%2029.3432%2030.3423C29.4104%2030.3293%2029.4756%2030.3101%2029.5389%2030.2847C29.6022%2030.2593%2029.6625%2030.2281%2029.7195%2030.1912C29.7765%2030.1543%2029.829%2030.1124%2029.8774%2030.0654C29.9259%2030.0184%2029.9693%2029.9673%2030.0074%2029.9121C30.0454%2029.8569%2030.0774%2029.7986%2030.1037%2029.7373C30.1299%2029.6759%2030.1497%2029.6126%2030.163%2029.5475C30.1764%2029.4823%2030.1831%2029.4166%2030.1832%2029.3502L30.1832%2026.0478L28.4785%2026L28.5524%2028.0475ZM11.6308%2028.0099C11.6308%2028.0664%2011.6365%2028.1223%2011.6479%2028.1777C11.6592%2028.233%2011.676%2028.2868%2011.6983%2028.339C11.7206%2028.3911%2011.748%2028.4406%2011.7803%2028.4876C11.8127%2028.5345%2011.8495%2028.578%2011.8906%2028.6179C11.9318%2028.6578%2011.9765%2028.6934%2012.0249%2028.7248C12.0733%2028.7562%2012.1244%2028.7826%2012.1783%2028.8042C12.2321%2028.8259%2012.2875%2028.8422%2012.3446%2028.8532C12.4017%2028.8642%2012.4596%2028.8697%2012.5178%2028.8698L16%2028.8042L16%2030.3241L11.0435%2030.3241C10.975%2030.3241%2010.9071%2030.3176%2010.8399%2030.3047C10.7727%2030.2917%2010.7076%2030.2725%2010.6443%2030.2471C10.581%2030.2217%2010.5206%2030.1906%2010.4637%2030.1537C10.4067%2030.1168%2010.3542%2030.0748%2010.3057%2030.0278C10.2573%2029.9809%2010.2138%2029.9298%2010.1758%2029.8745C10.1377%2029.8193%2010.1057%2029.7611%2010.0795%2029.6997C10.0533%2029.6383%2010.0335%2029.575%2010.0201%2029.5099C10.0068%2029.4448%2010%2029.379%2010%2029.3126L10%2026.0478L11.7047%2026L11.6308%2028.0099Z'%20fill='rgb(14,191,241)'%20fill-rule='evenodd'%20/%3e%3c/g%3e%3c/g%3e%3c/svg%3e", u2 = "data:image/svg+xml,%3csvg%20viewBox='0%200%2040%2040'%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20width='40.000000'%20height='40.000000'%20fill='none'%20customFrame='url(%23clipPath_9)'%3e%3cdefs%3e%3cclipPath%20id='clipPath_9'%3e%3crect%20width='40.000000'%20height='40.000000'%20x='0.000000'%20y='0.000000'%20rx='12.000000'%20fill='rgb(255,255,255)'%20/%3e%3c/clipPath%3e%3cclipPath%20id='clipPath_10'%3e%3crect%20width='24.000000'%20height='24.000000'%20x='8.000000'%20y='8.000000'%20fill='rgb(255,255,255)'%20/%3e%3c/clipPath%3e%3cclipPath%20id='clipPath_11'%3e%3crect%20width='20.000000'%20height='20.000000'%20x='10.000000'%20y='10.000000'%20fill='rgb(255,255,255)'%20/%3e%3c/clipPath%3e%3c/defs%3e%3crect%20id='3'%20width='40.000000'%20height='40.000000'%20x='0.000000'%20y='0.000000'%20rx='12.000000'%20fill='rgb(236,250,254)'%20/%3e%3cg%20id='画板%202310'%20customFrame='url(%23clipPath_10)'%3e%3crect%20id='画板%202310'%20width='24.000000'%20height='24.000000'%20x='8.000000'%20y='8.000000'%20fill='rgb(255,255,255)'%20fill-opacity='0'%20/%3e%3cg%20id='人事服务'%3e%3cg%20id='ic_public_link'%20clip-path='url(%23clipPath_11)'%20customFrame='url(%23clipPath_11)'%3e%3crect%20id='ic_public_link'%20width='20.000000'%20height='20.000000'%20x='10.000000'%20y='10.000000'%20/%3e%3cpath%20id='path1'%20d='M9.9999%2019.9917C9.9999%2018.4292%209.99573%2016.8667%209.9999%2015.3042C9.99573%2014.5459%2010.0916%2013.7917%2010.2749%2013.0626C10.6874%2011.5126%2011.6957%2010.5917%2013.2457%2010.2334C14.0207%2010.0667%2014.8166%209.98756%2015.6082%2010.0001C18.6041%2010.0001%2021.5999%2010.0001%2024.5999%2010.0001C25.3541%209.99589%2026.1082%2010.0792%2026.8457%2010.2584C28.4416%2010.6459%2029.3999%2011.6584%2029.7624%2013.2501C29.9291%2014.0001%2030.0041%2014.7667%2029.9957%2015.5376C29.9957%2018.5667%2029.9957%2021.5959%2029.9957%2024.6209C29.9999%2025.3709%2029.9166%2026.1209%2029.7416%2026.8459C29.3499%2028.4459%2028.3332%2029.3959%2026.7457%2029.7626C25.9666%2029.9292%2025.1749%2030.0084%2024.3791%2029.9959C21.3957%2029.9959%2018.4124%2029.9959%2015.4291%2029.9959C14.6666%2030.0042%2013.9082%2029.9167%2013.1666%2029.7417C11.5624%2029.3542%2010.5999%2028.3376%2010.2374%2026.7376C10.0499%2025.9251%209.9999%2025.1126%209.9999%2024.2917C9.9999%2022.8584%209.9999%2021.4251%209.9999%2019.9917Z'%20fill='rgb(255,255,255)'%20fill-opacity='0'%20fill-rule='evenodd'%20/%3e%3ccircle%20id='path2'%20cx='20'%20cy='20'%20r='10'%20fill='rgb(255,255,255)'%20fill-opacity='0'%20/%3e%3cpath%20id='path3'%20d='M25.0333%2021.8666L26.9%2020C28.8083%2018.0916%2028.8083%2015%2026.9%2013.0958C24.9958%2011.1875%2021.9041%2011.1875%2020%2013.0958L18.1291%2014.9625M21.8666%2025.0333L20%2026.9C18.0916%2028.8083%2015%2028.8083%2013.0958%2026.9C11.1875%2024.9958%2011.1875%2021.9041%2013.0958%2020L14.9625%2018.1291'%20fill-rule='nonzero'%20stroke='rgb(14,191,241)'%20stroke-linecap='round'%20stroke-width='1.25'%20/%3e%3cpath%20id='pah4'%20d='M18.125%2021.875L21.875%2018.125'%20stroke='rgb(14,191,241)'%20stroke-linecap='round'%20stroke-linejoin='round'%20stroke-width='1.25'%20/%3e%3cpath%20id='path5'%20d='M25.8207%2019.2626L24.0457%2021.0376C23.7998%2021.2834%2023.6748%2021.5292%2023.6748%2021.7751C23.6748%2022.0209%2023.7998%2022.2667%2024.0457%2022.5126C24.1498%2022.6167%2024.2665%2022.6959%2024.3915%2022.7459C24.5123%2022.7917%2024.6415%2022.8167%2024.779%2022.8167C24.9207%2022.8167%2025.0498%2022.7917%2025.1665%2022.7459C25.2957%2022.6959%2025.4123%2022.6167%2025.5165%2022.5126L27.2915%2020.7334C27.8165%2020.2126%2028.2165%2019.6334%2028.4957%2019.0001C28.5082%2018.9667%2028.5248%2018.9334%2028.5373%2018.8959C28.554%2018.8626%2028.5665%2018.8292%2028.579%2018.7917C28.8332%2018.1501%2028.9582%2017.4584%2028.9582%2016.7209C28.9582%2015.9792%2028.8332%2015.2876%2028.579%2014.6459C28.5665%2014.6084%2028.554%2014.5751%2028.5373%2014.5417C28.5248%2014.5042%2028.5082%2014.4709%2028.4957%2014.4376C28.2165%2013.8042%2027.8165%2013.2292%2027.2915%2012.7042C26.7707%2012.1792%2026.1915%2011.7792%2025.5582%2011.5001C25.5248%2011.4876%2025.4915%2011.4709%2025.454%2011.4584C25.4207%2011.4417%2025.3873%2011.4292%2025.354%2011.4167C24.7082%2011.1667%2024.0165%2011.0417%2023.279%2011.0417C22.5373%2011.0417%2021.8457%2011.1667%2021.204%2011.4167C21.1665%2011.4292%2021.1332%2011.4417%2021.0998%2011.4584C21.0623%2011.4709%2021.029%2011.4876%2020.9957%2011.5001C20.3623%2011.7792%2019.7832%2012.1792%2019.2623%2012.7042L17.4832%2014.4792C17.379%2014.5834%2017.2998%2014.7001%2017.2498%2014.8292C17.204%2014.9501%2017.179%2015.0751%2017.179%2015.2167C17.179%2015.3542%2017.204%2015.4834%2017.2498%2015.6042C17.2998%2015.7292%2017.379%2015.8459%2017.4832%2015.9542C17.5915%2016.0584%2017.7082%2016.1376%2017.8332%2016.1876C17.954%2016.2334%2018.0832%2016.2584%2018.2207%2016.2584C18.3623%2016.2584%2018.4915%2016.2334%2018.6082%2016.1876C18.7373%2016.1376%2018.854%2016.0584%2018.9582%2015.9542L20.7332%2014.1751C21.0873%2013.8209%2021.4748%2013.5584%2021.8957%2013.3834C22.3165%2013.2084%2022.779%2013.1251%2023.279%2013.1251C23.7748%2013.1251%2024.2373%2013.2084%2024.6582%2013.3834C25.079%2013.5584%2025.4665%2013.8209%2025.8207%2014.1751C26.1748%2014.5292%2026.4373%2014.9167%2026.6123%2015.3376C26.7873%2015.7584%2026.8748%2016.2167%2026.8748%2016.7209C26.8748%2017.2209%2026.7873%2017.6792%2026.6123%2018.1001C26.4373%2018.5209%2026.1748%2018.9084%2025.8207%2019.2626ZM13.3832%2021.8959C13.5582%2021.4751%2013.8207%2021.0876%2014.1748%2020.7334L15.954%2018.9584C16.0582%2018.8542%2016.1373%2018.7376%2016.1873%2018.6084C16.2332%2018.4876%2016.2582%2018.3626%2016.2582%2018.2209C16.2582%2018.0834%2016.2332%2017.9542%2016.1873%2017.8334C16.1373%2017.7084%2016.0582%2017.5917%2015.954%2017.4834C15.7082%2017.2417%2015.4623%2017.1167%2015.2165%2017.1167C14.9707%2017.1167%2014.7248%2017.2417%2014.479%2017.4834L12.704%2019.2626C12.179%2019.7876%2011.779%2020.3626%2011.4998%2020.9959C11.4873%2021.0292%2011.4707%2021.0626%2011.4582%2021.1001C11.4415%2021.1334%2011.429%2021.1667%2011.4165%2021.2042C11.1665%2021.8459%2011.0415%2022.5376%2011.0415%2023.2792C11.0415%2024.0167%2011.1665%2024.7084%2011.4165%2025.3542C11.429%2025.3876%2011.4415%2025.4209%2011.4582%2025.4584C11.4707%2025.4917%2011.4873%2025.5251%2011.4998%2025.5584C11.779%2026.1917%2012.179%2026.7709%2012.704%2027.2917C13.2248%2027.8167%2013.804%2028.2167%2014.4373%2028.4959C14.4707%2028.5084%2014.504%2028.5251%2014.5415%2028.5376C14.5748%2028.5542%2014.6082%2028.5667%2014.6457%2028.5792C15.2873%2028.8292%2015.979%2028.9584%2016.7207%2028.9584C17.4582%2028.9584%2018.1498%2028.8292%2018.7915%2028.5792C18.829%2028.5667%2018.8623%2028.5542%2018.8957%2028.5376C18.9332%2028.5251%2018.9665%2028.5084%2018.9998%2028.4959C19.6332%2028.2167%2020.2123%2027.8167%2020.7332%2027.2917L22.5123%2025.5167C22.6165%2025.4126%2022.6957%2025.2959%2022.7457%2025.1667C22.7915%2025.0459%2022.8165%2024.9209%2022.8165%2024.7792C22.8165%2024.6417%2022.7915%2024.5126%2022.7457%2024.3917C22.6957%2024.2667%2022.6165%2024.1501%2022.5123%2024.0417C22.2665%2023.8001%2022.0207%2023.6751%2021.7748%2023.6751C21.529%2023.6751%2021.2832%2023.8001%2021.0373%2024.0417L19.2623%2025.8209C18.9082%2026.1751%2018.5207%2026.4376%2018.0998%2026.6126C17.679%2026.7876%2017.2165%2026.8751%2016.7207%2026.8751C16.2207%2026.8751%2015.7582%2026.7876%2015.3373%2026.6126C14.9165%2026.4376%2014.529%2026.1751%2014.1748%2025.8209C13.8207%2025.4667%2013.5582%2025.0792%2013.3832%2024.6584C13.2082%2024.2376%2013.1248%2023.7792%2013.1248%2023.2792C13.1248%2022.7751%2013.2082%2022.3167%2013.3832%2021.8959Z'%20fill='rgb(255,255,255)'%20fill-opacity='0'%20fill-rule='evenodd'%20/%3e%3cpath%20id='path6'%20d='M21.8127%2016.7458C21.746%2016.7874%2021.6877%2016.8374%2021.6293%2016.8916L16.8918%2021.6291C16.8377%2021.6874%2016.7877%2021.7499%2016.746%2021.8124C16.7127%2021.8624%2016.6877%2021.9166%2016.6627%2021.9749C16.6377%2022.0374%2016.6168%2022.1041%2016.6043%2022.1708C16.5918%2022.2333%2016.5835%2022.2999%2016.5835%2022.3666C16.5835%2022.4333%2016.5918%2022.4999%2016.6043%2022.5666C16.6168%2022.6333%2016.6377%2022.6999%2016.6627%2022.7624C16.6877%2022.8166%2016.7127%2022.8708%2016.746%2022.9208C16.7877%2022.9874%2016.8377%2023.0499%2016.8918%2023.1041C16.946%2023.1583%2017.0085%2023.2083%2017.0752%2023.2499C17.1252%2023.2833%2017.1793%2023.3083%2017.2335%2023.3333C17.3002%2023.3583%2017.3627%2023.3791%2017.4293%2023.3916C17.496%2023.4041%2017.5627%2023.4124%2017.6293%2023.4124C17.696%2023.4124%2017.7627%2023.4041%2017.8252%2023.3916C17.8918%2023.3791%2017.9585%2023.3583%2018.021%2023.3333C18.0793%2023.3083%2018.1335%2023.2833%2018.1835%2023.2499C18.246%2023.2083%2018.3085%2023.1583%2018.3668%2023.1041L23.1043%2018.3666C23.1585%2018.3083%2023.2085%2018.2499%2023.2502%2018.1833C23.2835%2018.1333%2023.3085%2018.0791%2023.3335%2018.0208C23.3585%2017.9583%2023.3793%2017.8916%2023.3918%2017.8249C23.4043%2017.7624%2023.4127%2017.6958%2023.4127%2017.6291C23.4127%2017.5624%2023.4043%2017.4958%2023.3918%2017.4291C23.3793%2017.3624%2023.3585%2017.2999%2023.3335%2017.2333C23.3085%2017.1791%2023.2835%2017.1249%2023.2502%2017.0749C23.2085%2017.0083%2023.1585%2016.9458%2023.1043%2016.8916C23.046%2016.8374%2022.9877%2016.7874%2022.921%2016.7458C22.871%2016.7124%2022.8168%2016.6874%2022.7627%2016.6624C22.696%2016.6374%2022.6335%2016.6166%2022.5668%2016.6041C22.5002%2016.5916%2022.4335%2016.5833%2022.3668%2016.5833C22.3002%2016.5833%2022.2335%2016.5916%2022.171%2016.6041C22.1043%2016.6166%2022.0377%2016.6374%2021.9752%2016.6624C21.9168%2016.6874%2021.8627%2016.7124%2021.8127%2016.7458Z'%20fill='rgb(255,255,255)'%20fill-opacity='0'%20fill-rule='evenodd'%20/%3e%3c/g%3e%3c/g%3e%3c/g%3e%3c/svg%3e", f2 = "data:image/svg+xml,%3csvg%20viewBox='0%200%2040%2040'%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20width='40.000000'%20height='40.000000'%20fill='none'%20customFrame='url(%23clipPath_0)'%3e%3cdefs%3e%3cclipPath%20id='clipPath_0'%3e%3crect%20width='40.000000'%20height='40.000000'%20x='0.000000'%20y='0.000000'%20rx='12.000000'%20fill='rgb(255,255,255)'%20/%3e%3c/clipPath%3e%3cclipPath%20id='clipPath_1'%3e%3crect%20width='24.000000'%20height='24.000000'%20x='8.000000'%20y='8.000000'%20fill='rgb(255,255,255)'%20/%3e%3c/clipPath%3e%3cclipPath%20id='clipPath_2'%3e%3crect%20width='20.000000'%20height='20.000000'%20x='10.000000'%20y='10.000000'%20fill='rgb(255,255,255)'%20/%3e%3c/clipPath%3e%3c/defs%3e%3crect%20id='1'%20width='40.000000'%20height='40.000000'%20x='0.000000'%20y='0.000000'%20rx='12.000000'%20fill='rgb(236,250,254)'%20/%3e%3cg%20id='车辆'%20clip-path='url(%23clipPath_1)'%20customFrame='url(%23clipPath_1)'%3e%3crect%20id='车辆'%20width='24.000000'%20height='24.000000'%20x='8.000000'%20y='8.000000'%20/%3e%3cg%20id='编组'%3e%3cg%20id='ic_public_qrcode'%20clip-path='url(%23clipPath_2)'%20customFrame='url(%23clipPath_2)'%3e%3crect%20id='ic_public_qrcode'%20width='20.000000'%20height='20.000000'%20x='10.000000'%20y='10.000000'%20/%3e%3cg%20id='ic_public_qrcode_1_1'%3e%3cpath%20id='ic_public_qrcode_2_0'%20d='M10.6273%2019.9924C10.6273%2018.5277%2010.6222%2017.0631%2010.6273%2015.5985C10.6243%2014.8898%2010.7114%2014.1836%2010.8865%2013.4968C11.2702%2012.0432%2012.2171%2011.1805%2013.6693%2010.8458C14.3974%2010.6885%2015.1411%2010.6148%2015.886%2010.6261C18.6946%2010.6261%2021.5035%2010.6261%2024.3127%2010.6261C25.0221%2010.6217%2025.7295%2010.7029%2026.4195%2010.8678C27.9156%2011.2339%2028.8134%2012.1816%2029.1554%2013.6725C29.3092%2014.3772%2029.3826%2015.097%2029.3744%2015.8182C29.3744%2018.6571%2029.3744%2021.4963%2029.3744%2024.3357C29.3782%2025.0383%2029.2973%2025.7388%2029.1334%2026.422C28.7673%2027.9189%2027.8153%2028.8123%2026.3243%2029.1543C25.5961%2029.311%2024.8524%2029.3847%2024.1076%2029.374C21.3107%2029.374%2018.514%2029.374%2015.7176%2029.374C15.0027%2029.3798%2014.2897%2029.2999%2013.5939%2029.136C12.0912%2028.7698%2011.189%2027.8178%2010.8477%2026.3195C10.6734%2025.5579%2010.6273%2024.7941%2010.6273%2024.0237C10.6273%2022.6802%2010.6273%2021.3364%2010.6273%2019.9924Z'%20fill='rgb(255,255,255)'%20fill-opacity='0'%20fill-rule='nonzero'%20/%3e%3cpath%20id='ic_public_qrcode_2_0'%20d='M10.6273%2015.5985C10.6243%2014.8898%2010.7114%2014.1836%2010.8865%2013.4968C11.2702%2012.0432%2012.2171%2011.1805%2013.6693%2010.8458C14.3974%2010.6885%2015.1411%2010.6148%2015.886%2010.6261C18.6946%2010.6261%2021.5035%2010.6261%2024.3127%2010.6261C25.0221%2010.6217%2025.7295%2010.7029%2026.4195%2010.8678C27.9156%2011.2339%2028.8134%2012.1816%2029.1554%2013.6725C29.3092%2014.3772%2029.3826%2015.097%2029.3744%2015.8182C29.3744%2018.6571%2029.3744%2021.4963%2029.3744%2024.3357C29.3782%2025.0383%2029.2973%2025.7388%2029.1334%2026.422C28.7673%2027.9189%2027.8153%2028.8123%2026.3243%2029.1543C25.5961%2029.311%2024.8524%2029.3847%2024.1076%2029.374C21.3107%2029.374%2018.514%2029.374%2015.7176%2029.374C15.0027%2029.3798%2014.2897%2029.2999%2013.5939%2029.136C12.0912%2028.7698%2011.189%2027.8178%2010.8477%2026.3195C10.6734%2025.5579%2010.6273%2024.7941%2010.6273%2024.0237C10.6273%2022.6802%2010.6273%2021.3364%2010.6273%2019.9924C10.6273%2018.5277%2010.6222%2017.0631%2010.6273%2015.5985Z'%20fill-rule='nonzero'%20stroke='rgb(255,255,255)'%20stroke-opacity='0'%20stroke-width='1.25'%20/%3e%3cpath%20id='ic_public_qrcode_2_1'%20d='M10.6273%2015.5985C10.6243%2014.8898%2010.7114%2014.1836%2010.8865%2013.4968C11.2702%2012.0432%2012.2171%2011.1805%2013.6693%2010.8458C14.3974%2010.6885%2015.1411%2010.6148%2015.886%2010.6261C18.6946%2010.6261%2021.5035%2010.6261%2024.3127%2010.6261C25.0221%2010.6217%2025.7295%2010.7029%2026.4195%2010.8678C27.9156%2011.2339%2028.8134%2012.1816%2029.1554%2013.6725C29.3092%2014.3772%2029.3826%2015.097%2029.3744%2015.8182C29.3744%2018.6571%2029.3744%2021.4963%2029.3744%2024.3357C29.3782%2025.0383%2029.2973%2025.7388%2029.1334%2026.422C28.7673%2027.9189%2027.8153%2028.8123%2026.3243%2029.1543C25.5961%2029.311%2024.8524%2029.3847%2024.1076%2029.374C21.3107%2029.374%2018.514%2029.374%2015.7176%2029.374C15.0027%2029.3798%2014.2897%2029.2999%2013.5939%2029.136C12.0912%2028.7698%2011.189%2027.8178%2010.8477%2026.3195C10.6734%2025.5579%2010.6273%2024.7941%2010.6273%2024.0237C10.6273%2022.6802%2010.6273%2021.3364%2010.6273%2019.9924C10.6273%2018.5277%2010.6222%2017.0631%2010.6273%2015.5985Z'%20opacity='0.200000003'%20fill-rule='nonzero'%20stroke='rgb(255,255,255)'%20stroke-opacity='0'%20stroke-width='1.25'%20/%3e%3ccircle%20id='ic_public_qrcode_2_2'%20cx='20'%20cy='20'%20r='10'%20fill='rgb(255,255,255)'%20fill-opacity='0'%20/%3e%3cpath%20id='ic_public_qrcode_2_3'%20d='M17.5%2011.25C17.9602%2011.25%2018.3333%2011.6231%2018.3333%2012.0833L18.3333%2017.5C18.3333%2017.9602%2017.9602%2018.3333%2017.5%2018.3333L12.0833%2018.3333C11.6231%2018.3333%2011.25%2017.9602%2011.25%2017.5L11.25%2012.0833C11.25%2011.6231%2011.6231%2011.25%2012.0833%2011.25L17.5%2011.25ZM17.5%2021.6667C17.9602%2021.6667%2018.3333%2022.0398%2018.3333%2022.5L18.3333%2027.9167C18.3333%2028.3769%2017.9602%2028.75%2017.5%2028.75L12.0833%2028.75C11.6231%2028.75%2011.25%2028.3769%2011.25%2027.9167L11.25%2022.5C11.25%2022.0398%2011.6231%2021.6667%2012.0833%2021.6667L17.5%2021.6667ZM27.9167%2011.25C28.3769%2011.25%2028.75%2011.6231%2028.75%2012.0833L28.75%2017.5C28.75%2017.9602%2028.3769%2018.3333%2027.9167%2018.3333L22.5%2018.3333C22.0398%2018.3333%2021.6667%2017.9602%2021.6667%2017.5L21.6667%2012.0833C21.6667%2011.6231%2022.0398%2011.25%2022.5%2011.25L27.9167%2011.25Z'%20fill-rule='evenodd'%20stroke='rgb(14,191,241)'%20stroke-linecap='round'%20stroke-linejoin='round'%20stroke-width='1.25'%20/%3e%3cpath%20id='ic_public_qrcode_2_4'%20d='M17.5002%2010.8333C18.1905%2010.8333%2018.7502%2011.3929%2018.7502%2012.0833L18.7502%2017.4999C18.7502%2018.1903%2018.1905%2018.7499%2017.5002%2018.7499L12.0835%2018.7499C11.3931%2018.7499%2010.8335%2018.1903%2010.8335%2017.4999L10.8335%2012.0833C10.8335%2011.3929%2011.3931%2010.8333%2012.0835%2010.8333L17.5002%2010.8333ZM17.5002%2011.6666L12.0835%2011.6666C11.8534%2011.6666%2011.6668%2011.8531%2011.6668%2012.0833L11.6668%2017.4999C11.6668%2017.73%2011.8534%2017.9166%2012.0835%2017.9166L17.5002%2017.9166C17.7303%2017.9166%2017.9168%2017.73%2017.9168%2017.4999L17.9168%2012.0833C17.9168%2011.8531%2017.7303%2011.6666%2017.5002%2011.6666ZM17.5002%2021.2499C18.1905%2021.2499%2018.7502%2021.8096%2018.7502%2022.4999L18.7502%2027.9166C18.7502%2028.6069%2018.1905%2029.1666%2017.5002%2029.1666L12.0835%2029.1666C11.3931%2029.1666%2010.8335%2028.6069%2010.8335%2027.9166L10.8335%2022.4999C10.8335%2021.8096%2011.3931%2021.2499%2012.0835%2021.2499L17.5002%2021.2499ZM17.5002%2022.0833L12.0835%2022.0833C11.8534%2022.0833%2011.6668%2022.2698%2011.6668%2022.4999L11.6668%2027.9166C11.6668%2028.1467%2011.8534%2028.3333%2012.0835%2028.3333L17.5002%2028.3333C17.7303%2028.3333%2017.9168%2028.1467%2017.9168%2027.9166L17.9168%2022.4999C17.9168%2022.2698%2017.7303%2022.0833%2017.5002%2022.0833ZM27.9168%2010.8333C28.6072%2010.8333%2029.1668%2011.3929%2029.1668%2012.0833L29.1668%2017.4999C29.1668%2018.1903%2028.6072%2018.7499%2027.9168%2018.7499L22.5002%2018.7499C21.8098%2018.7499%2021.2502%2018.1903%2021.2502%2017.4999L21.2502%2012.0833C21.2502%2011.3929%2021.8098%2010.8333%2022.5002%2010.8333L27.9168%2010.8333ZM27.9168%2011.6666L22.5002%2011.6666C22.27%2011.6666%2022.0835%2011.8531%2022.0835%2012.0833L22.0835%2017.4999C22.0835%2017.73%2022.27%2017.9166%2022.5002%2017.9166L27.9168%2017.9166C28.1469%2017.9166%2028.3335%2017.73%2028.3335%2017.4999L28.3335%2012.0833C28.3335%2011.8531%2028.1469%2011.6666%2027.9168%2011.6666Z'%20fill='rgb(255,255,255)'%20fill-opacity='0'%20fill-rule='nonzero'%20/%3e%3cpath%20id='ic_public_qrcode_2_4'%20d='M18.7502%2012.0833L18.7502%2017.4999C18.7502%2018.1903%2018.1905%2018.7499%2017.5002%2018.7499L12.0835%2018.7499C11.3931%2018.7499%2010.8335%2018.1903%2010.8335%2017.4999L10.8335%2012.0833C10.8335%2011.3929%2011.3931%2010.8333%2012.0835%2010.8333L17.5002%2010.8333C18.1905%2010.8333%2018.7502%2011.3929%2018.7502%2012.0833ZM12.0835%2011.6666C11.8534%2011.6666%2011.6668%2011.8531%2011.6668%2012.0833L11.6668%2017.4999C11.6668%2017.73%2011.8534%2017.9166%2012.0835%2017.9166L17.5002%2017.9166C17.7303%2017.9166%2017.9168%2017.73%2017.9168%2017.4999L17.9168%2012.0833C17.9168%2011.8531%2017.7303%2011.6666%2017.5002%2011.6666L12.0835%2011.6666ZM18.7502%2022.4999L18.7502%2027.9166C18.7502%2028.6069%2018.1905%2029.1666%2017.5002%2029.1666L12.0835%2029.1666C11.3931%2029.1666%2010.8335%2028.6069%2010.8335%2027.9166L10.8335%2022.4999C10.8335%2021.8096%2011.3931%2021.2499%2012.0835%2021.2499L17.5002%2021.2499C18.1905%2021.2499%2018.7502%2021.8096%2018.7502%2022.4999ZM12.0835%2022.0833C11.8534%2022.0833%2011.6668%2022.2698%2011.6668%2022.4999L11.6668%2027.9166C11.6668%2028.1467%2011.8534%2028.3333%2012.0835%2028.3333L17.5002%2028.3333C17.7303%2028.3333%2017.9168%2028.1467%2017.9168%2027.9166L17.9168%2022.4999C17.9168%2022.2698%2017.7303%2022.0833%2017.5002%2022.0833L12.0835%2022.0833ZM29.1668%2012.0833L29.1668%2017.4999C29.1668%2018.1903%2028.6072%2018.7499%2027.9168%2018.7499L22.5002%2018.7499C21.8098%2018.7499%2021.2502%2018.1903%2021.2502%2017.4999L21.2502%2012.0833C21.2502%2011.3929%2021.8098%2010.8333%2022.5002%2010.8333L27.9168%2010.8333C28.6072%2010.8333%2029.1668%2011.3929%2029.1668%2012.0833ZM22.5002%2011.6666C22.27%2011.6666%2022.0835%2011.8531%2022.0835%2012.0833L22.0835%2017.4999C22.0835%2017.73%2022.27%2017.9166%2022.5002%2017.9166L27.9168%2017.9166C28.1469%2017.9166%2028.3335%2017.73%2028.3335%2017.4999L28.3335%2012.0833C28.3335%2011.8531%2028.1469%2011.6666%2027.9168%2011.6666L22.5002%2011.6666Z'%20fill-rule='nonzero'%20stroke='rgb(255,255,255)'%20stroke-opacity='0'%20stroke-linejoin='round'%20stroke-width='1.25'%20/%3e%3cpath%20id='ic_public_qrcode_2_5'%20d='M27.9165%2021.6667L27.9165%2024.5834L28.7498%2024.5834L28.7498%2021.6667L27.9165%2021.6667ZM24.5832%2021.6667L24.5832%2022.639L24.5828%2022.6388L24.5832%2024.5834L23.6109%2024.5834L23.6107%2022.6388L21.6665%2022.639L21.6665%2021.6667L24.5832%2021.6667ZM21.6665%2025.8334L21.6665%2028.7501L22.4998%2028.7501L22.4998%2025.8334L21.6665%2025.8334ZM27.9165%2027.9167L27.9165%2028.7501L28.7498%2028.7501L28.7498%2027.9167L27.9165%2027.9167ZM25.8332%2025.8334L25.8332%2026.6667L26.6665%2026.6667L26.6665%2025.8334L25.8332%2025.8334Z'%20fill='rgb(14,191,241)'%20fill-rule='nonzero'%20/%3e%3cpath%20id='ic_public_qrcode_2_5'%20d='M27.9165%2024.5834L28.7498%2024.5834L28.7498%2021.6667L27.9165%2021.6667L27.9165%2024.5834ZM24.5832%2022.639L24.5828%2022.6388L24.5832%2024.5834L23.6109%2024.5834L23.6107%2022.6388L21.6665%2022.639L21.6665%2021.6667L24.5832%2021.6667L24.5832%2022.639ZM21.6665%2028.7501L22.4998%2028.7501L22.4998%2025.8334L21.6665%2025.8334L21.6665%2028.7501ZM27.9165%2028.7501L28.7498%2028.7501L28.7498%2027.9167L27.9165%2027.9167L27.9165%2028.7501ZM25.8332%2026.6667L26.6665%2026.6667L26.6665%2025.8334L25.8332%2025.8334L25.8332%2026.6667Z'%20fill-rule='nonzero'%20stroke='rgb(14,191,241)'%20stroke-linejoin='round'%20stroke-width='1.25'%20/%3e%3cpath%20id='ic_public_qrcode_2_6'%20d='M14.375%2014.375L14.375%2015.2083L15.2083%2015.2083L15.2083%2014.375L14.375%2014.375ZM14.375%2024.7917L14.375%2025.625L15.2083%2025.625L15.2083%2024.7917L14.375%2024.7917ZM24.7917%2014.375L24.7917%2015.2083L25.625%2015.2083L25.625%2014.375L24.7917%2014.375Z'%20fill='rgb(14,191,241)'%20fill-rule='nonzero'%20/%3e%3cpath%20id='ic_public_qrcode_2_6'%20d='M14.375%2015.2083L15.2083%2015.2083L15.2083%2014.375L14.375%2014.375L14.375%2015.2083ZM14.375%2025.625L15.2083%2025.625L15.2083%2024.7917L14.375%2024.7917L14.375%2025.625ZM24.7917%2015.2083L25.625%2015.2083L25.625%2014.375L24.7917%2014.375L24.7917%2015.2083Z'%20fill-rule='nonzero'%20stroke='rgb(14,191,241)'%20stroke-linejoin='round'%20stroke-width='1.25'%20/%3e%3c/g%3e%3c/g%3e%3c/g%3e%3c/g%3e%3c/svg%3e", w2 = "data:image/svg+xml,%3csvg%20viewBox='0%200%2012%2012'%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20width='12.000000'%20height='12.000000'%20fill='none'%3e%3cdefs%3e%3cfilter%20id='pixso_custom_mask_type_luminance'%3e%3cfeColorMatrix%20type='matrix'%20values='1%200%200%200%200%200%201%200%200%200%200%200%201%200%200%200%200%200%201%200%20'%20/%3e%3c/filter%3e%3c/defs%3e%3cmask%20id='mask_0'%20width='11.999876'%20height='11.999876'%20x='0.000000'%20y='0.000000'%20maskUnits='userSpaceOnUse'%3e%3cg%20filter='url(%23pixso_custom_mask_type_luminance)'%3e%3cg%20id='mask401_19830'%3e%3cpath%20id='蒙版'%20d='M0%200L11.9999%200L11.9999%2011.9999L0%2011.9999L0%200ZM2.69992%201.34999L8.09977%201.34999C9.5082%201.34999%2010.6498%202.49167%2010.6498%203.89998L10.6498%209.2999C10.6498%2010.7082%209.5082%2011.8499%208.09977%2011.8499L2.69992%2011.8499C1.29149%2011.8499%200.149901%2010.7082%200.149901%209.2999L0.149901%203.89998C0.149901%202.49167%201.29149%201.34999%202.69992%201.34999Z'%20fill='rgb(196,196,196)'%20fill-rule='evenodd'%20/%3e%3c/g%3e%3c/g%3e%3c/mask%3e%3crect%20id='ic_public_copy'%20width='12.000000'%20height='12.000000'%20x='0.000000'%20y='0.000000'%20/%3e%3crect%20id='ic_public_copy-复制/base/ic_public_copy'%20width='11.999876'%20height='11.999876'%20x='0.000000'%20y='0.000000'%20fill='rgb(255,255,255)'%20fill-opacity='0'%20/%3e%3cpath%20id='path1'%20d='M0.000134537%205.99497C0.000134537%205.05748%20-0.00236544%204.11999%200.000134537%203.1825C-0.00236544%202.72751%200.055134%202.27501%200.165133%201.83752C0.41263%200.907526%201.01762%200.355032%201.94761%200.140034C2.41261%200.040035%202.8901%20-0.00746449%203.3651%203.54269e-05C5.16258%203.54269e-05%206.96006%203.54269e-05%208.76004%203.54269e-05C9.21254%20-0.00246455%209.66503%200.0475349%2010.1075%200.155034C11.065%200.387531%2011.64%200.995025%2011.8575%201.95002C11.9575%202.40001%2012.005%202.86001%2011.9975%203.3225C11.9975%205.13998%2011.9975%206.95746%2011.9975%208.77244C12%209.22244%2011.95%209.67243%2011.845%2010.1099C11.61%2011.0674%2011%2011.6374%2010.0475%2011.8574C9.58003%2011.9574%209.10504%2012.0049%208.62754%2011.9974C6.83756%2011.9974%205.04758%2011.9974%203.2576%2011.9974C2.80011%2012.0024%202.34511%2011.9499%201.90011%2011.8449C0.937625%2011.6124%200.360131%2011.0024%200.142633%2010.0424C0.0301342%209.55494%200.000134537%209.06744%200.000134537%208.57495C0.000134537%207.71495%200.000134537%206.85496%200.000134537%205.99497Z'%20fill='rgb(255,255,255)'%20fill-opacity='0'%20fill-rule='evenodd'%20/%3e%3ccircle%20id='path2'%20cx='5.99993801'%20cy='5.99993801'%20r='5.99993801'%20fill='rgb(255,255,255)'%20fill-opacity='0'%20/%3e%3cg%20id='mask'%20mask='url(%23mask_0)'%3e%3cg%20id='组合%208'%3e%3cpath%20id='path'%20d='M11.1%203.89993L11.1%206.8999C11.1%208.55488%209.75502%209.89737%208.10004%209.89737L5.10007%209.89737C3.44258%209.89737%202.1001%208.55488%202.1001%206.8999L2.1001%203.89993C2.1001%202.24245%203.44258%200.897461%205.10007%200.897461L8.10004%200.897461C9.75502%200.897461%2011.1%202.24245%2011.1%203.89993Z'%20fill-rule='nonzero'%20stroke='rgb(25,25,25)'%20stroke-linejoin='round'%20stroke-width='0.749992251'%20/%3e%3c/g%3e%3c/g%3e%3cpath%20id='path4'%20d='M2.10008%202.39746L8.10002%202.39746C8.92751%202.39746%209.6%203.06995%209.6%203.89995L9.6%209.89738C9.6%2010.7274%208.92751%2011.3999%208.10002%2011.3999L2.10008%2011.3999C1.27009%2011.3999%200.600098%2010.7274%200.600098%209.89738L0.600098%203.89995C0.600098%203.06995%201.27009%202.39746%202.10008%202.39746Z'%20fill='rgb(255,255,255)'%20fill-opacity='0'%20fill-rule='evenodd'%20/%3e%3cpath%20id='path4'%20d='M9.6%203.89995L9.6%209.89738C9.6%2010.7274%208.92751%2011.3999%208.10002%2011.3999L2.10008%2011.3999C1.27009%2011.3999%200.600098%2010.7274%200.600098%209.89738L0.600098%203.89995C0.600098%203.06995%201.27009%202.39746%202.10008%202.39746L8.10002%202.39746C8.92751%202.39746%209.6%203.06995%209.6%203.89995Z'%20fill-rule='nonzero'%20stroke='rgb(25,25,25)'%20stroke-linejoin='round'%20stroke-width='0.749992251'%20/%3e%3c/svg%3e", y2 = "https://agent.opentiny.design/tiny-robot", M = "https://ai.opentiny.design/next-remoter", k = (r) => [
|
|
912
|
+
{
|
|
913
|
+
action: "qr-code",
|
|
914
|
+
show: !0,
|
|
915
|
+
text: "扫码登录",
|
|
916
|
+
desc: "使用手机遥控页面",
|
|
917
|
+
icon: f2
|
|
918
|
+
},
|
|
919
|
+
{
|
|
920
|
+
action: "ai-chat",
|
|
921
|
+
show: !0,
|
|
922
|
+
text: "打开对话框",
|
|
923
|
+
desc: "支持在网页端操作AI",
|
|
924
|
+
icon: m2
|
|
925
|
+
},
|
|
926
|
+
{
|
|
927
|
+
action: "remote-url",
|
|
928
|
+
show: !0,
|
|
929
|
+
text: "遥控器链接",
|
|
930
|
+
desc: `${r.remoteUrl}`,
|
|
931
|
+
active: !0,
|
|
932
|
+
tip: r.remoteUrl,
|
|
933
|
+
showCopyIcon: !0,
|
|
934
|
+
icon: u2
|
|
935
|
+
},
|
|
936
|
+
{
|
|
937
|
+
action: "remote-control",
|
|
938
|
+
show: !0,
|
|
939
|
+
text: "识别码",
|
|
940
|
+
desc: `${r.sessionId.slice(-6)}`,
|
|
941
|
+
know: !0,
|
|
942
|
+
showCopyIcon: !0,
|
|
943
|
+
icon: g2
|
|
944
|
+
}
|
|
945
|
+
];
|
|
946
|
+
class L2 {
|
|
947
|
+
constructor(e) {
|
|
948
|
+
if (this.isExpanded = !1, this.getImageUrl = (t) => {
|
|
949
|
+
if (!t) return;
|
|
950
|
+
const i = new Image();
|
|
951
|
+
return i.src = t, i;
|
|
952
|
+
}, this.renderItem = () => {
|
|
953
|
+
this.menuItems.filter((t) => t.show !== !1).map(
|
|
954
|
+
(t) => {
|
|
955
|
+
const i = document.getElementById(`tiny-remoter-icon-item-${t.action}`);
|
|
956
|
+
if (!i) return;
|
|
957
|
+
i.innerHTML = "";
|
|
958
|
+
const s = this.getImageUrl(t.icon);
|
|
959
|
+
s && i.appendChild(s);
|
|
960
|
+
}
|
|
961
|
+
);
|
|
962
|
+
}, this.readyTips = (t) => {
|
|
963
|
+
const i = document.getElementById(t);
|
|
964
|
+
i && new C2(i, {
|
|
965
|
+
content: "复制",
|
|
966
|
+
placement: "top",
|
|
967
|
+
trigger: "hover"
|
|
968
|
+
});
|
|
969
|
+
}, !e.sessionId)
|
|
970
|
+
throw new Error("sessionId is required");
|
|
971
|
+
this.options = {
|
|
972
|
+
...e,
|
|
973
|
+
qrCodeUrl: e.qrCodeUrl || M,
|
|
974
|
+
remoteUrl: e.remoteUrl || y2
|
|
975
|
+
}, this.menuItems = this.mergeMenuItems(e.menuItems), this.init();
|
|
976
|
+
}
|
|
977
|
+
// 计算 sessionPrefix 属性
|
|
978
|
+
get sessionPrefix() {
|
|
979
|
+
var e;
|
|
980
|
+
return (e = this.options.qrCodeUrl) != null && e.includes("?") ? "&sessionId=" : "?sessionId=";
|
|
981
|
+
}
|
|
982
|
+
/**
|
|
983
|
+
* 合并菜单项配置
|
|
984
|
+
* @param userMenuItems 用户自定义菜单项配置
|
|
985
|
+
* @returns 合并后的菜单项配置
|
|
986
|
+
*/
|
|
987
|
+
mergeMenuItems(e) {
|
|
988
|
+
return e ? k(this.options).map((t) => {
|
|
989
|
+
const i = e.find((s) => s.action === t.action);
|
|
990
|
+
return i ? {
|
|
991
|
+
...t,
|
|
992
|
+
...i,
|
|
993
|
+
// 确保show属性存在,默认为true
|
|
994
|
+
show: i.show !== void 0 ? i.show : t.show
|
|
995
|
+
} : t;
|
|
996
|
+
}) : k(this.options);
|
|
997
|
+
}
|
|
998
|
+
init() {
|
|
999
|
+
this.createFloatingBlock(), this.createDropdownMenu(), this.bindEvents(), this.addStyles();
|
|
1000
|
+
}
|
|
1001
|
+
// 创建主浮动块
|
|
1002
|
+
createFloatingBlock() {
|
|
1003
|
+
this.floatingBlock = document.createElement("div"), this.floatingBlock.className = "tiny-remoter-floating-block", this.floatingBlock.innerHTML = `
|
|
1004
|
+
<div class="tiny-remoter-floating-block__icon">
|
|
1005
|
+
<img style="display: block; width: 56px;" src="${M}/svgs/logo-next-no-bg-left.svg" alt="icon" />
|
|
1006
|
+
</div>
|
|
1007
|
+
`, document.body.appendChild(this.floatingBlock);
|
|
1008
|
+
}
|
|
1009
|
+
// 创建下拉菜单
|
|
1010
|
+
createDropdownMenu() {
|
|
1011
|
+
this.dropdownMenu = document.createElement("div"), this.dropdownMenu.className = "tiny-remoter-floating-dropdown";
|
|
1012
|
+
const e = this.menuItems.filter((t) => t.show !== !1).map(
|
|
1013
|
+
(t) => `
|
|
1014
|
+
<div class="tiny-remoter-dropdown-item" data-action="${t.action}">
|
|
1015
|
+
<div id="tiny-remoter-icon-item-${t.action}" class="tiny-remoter-dropdown-item__icon">
|
|
1016
|
+
</div>
|
|
1017
|
+
<div class="tiny-remoter-dropdown-item__content">
|
|
1018
|
+
<div title="${t.tip}">${t.text}</div>
|
|
1019
|
+
<div class="tiny-remoter-dropdown-item__desc-wrapper">
|
|
1020
|
+
<div class="tiny-remoter-dropdown-item__desc ${t.active ? "tiny-remoter-dropdown-item__desc--active" : ""} ${t.know ? "tiny-remoter-dropdown-item__desc--know" : ""}">${t.desc}</div>
|
|
1021
|
+
<div>
|
|
1022
|
+
${t.showCopyIcon ? `
|
|
1023
|
+
<div class="tiny-remoter-copy-icon" id="${t.action}" data-action="${t.action}">
|
|
1024
|
+
<img src="${w2}"/>
|
|
1025
|
+
</div>
|
|
1026
|
+
` : ""}
|
|
1027
|
+
</div>
|
|
1028
|
+
</div>
|
|
1029
|
+
</div>
|
|
1030
|
+
</div>
|
|
1031
|
+
`
|
|
1032
|
+
).join("");
|
|
1033
|
+
this.dropdownMenu.innerHTML = e, document.body.appendChild(this.dropdownMenu), this.renderItem(), this.readyTips("remote-control"), this.readyTips("remote-url");
|
|
1034
|
+
}
|
|
1035
|
+
bindEvents() {
|
|
1036
|
+
this.floatingBlock.addEventListener("click", () => {
|
|
1037
|
+
this.toggleDropdown();
|
|
1038
|
+
}), this.dropdownMenu.addEventListener("click", (e) => {
|
|
1039
|
+
const t = e.target, i = t.closest(".tiny-remoter-copy-icon");
|
|
1040
|
+
if (i) {
|
|
1041
|
+
e.stopPropagation();
|
|
1042
|
+
const n = i.dataset.action;
|
|
1043
|
+
n && this.handleAction(n);
|
|
1044
|
+
return;
|
|
1045
|
+
}
|
|
1046
|
+
const s = t.closest(".tiny-remoter-dropdown-item"), o = s == null ? void 0 : s.dataset.action;
|
|
1047
|
+
o && this.handleAction(o);
|
|
1048
|
+
}), document.addEventListener("click", (e) => {
|
|
1049
|
+
const t = e.target;
|
|
1050
|
+
!this.floatingBlock.contains(t) && !this.dropdownMenu.contains(t) && this.closeDropdown();
|
|
1051
|
+
}), document.addEventListener("keydown", (e) => {
|
|
1052
|
+
e.key === "Escape" && this.closeDropdown();
|
|
1053
|
+
});
|
|
1054
|
+
}
|
|
1055
|
+
toggleDropdown() {
|
|
1056
|
+
this.isExpanded ? this.closeDropdown() : this.openDropdown();
|
|
1057
|
+
}
|
|
1058
|
+
openDropdown() {
|
|
1059
|
+
this.isExpanded = !0, this.floatingBlock.classList.add("expanded"), this.dropdownMenu.classList.add("show");
|
|
1060
|
+
}
|
|
1061
|
+
closeDropdown() {
|
|
1062
|
+
this.isExpanded = !1, this.floatingBlock.classList.remove("expanded"), this.dropdownMenu.classList.remove("show");
|
|
1063
|
+
}
|
|
1064
|
+
handleAction(e) {
|
|
1065
|
+
switch (e) {
|
|
1066
|
+
case "qr-code":
|
|
1067
|
+
this.showQRCode();
|
|
1068
|
+
break;
|
|
1069
|
+
case "ai-chat":
|
|
1070
|
+
this.showAIChat();
|
|
1071
|
+
break;
|
|
1072
|
+
case "remote-control":
|
|
1073
|
+
this.copyRemoteControl();
|
|
1074
|
+
break;
|
|
1075
|
+
case "remote-url":
|
|
1076
|
+
this.copyRemoteURL();
|
|
1077
|
+
break;
|
|
1078
|
+
}
|
|
1079
|
+
this.closeDropdown();
|
|
1080
|
+
}
|
|
1081
|
+
copyRemoteControl() {
|
|
1082
|
+
this.copyToClipboard(this.options.sessionId.slice(-6));
|
|
1083
|
+
}
|
|
1084
|
+
copyRemoteURL() {
|
|
1085
|
+
this.copyToClipboard(this.options.remoteUrl + this.sessionPrefix + this.options.sessionId);
|
|
1086
|
+
}
|
|
1087
|
+
// 实现复制到剪贴板功能
|
|
1088
|
+
async copyToClipboard(e) {
|
|
1089
|
+
try {
|
|
1090
|
+
if (navigator.clipboard && window.isSecureContext)
|
|
1091
|
+
await navigator.clipboard.writeText(e), this.showCopyFeedback(!0);
|
|
1092
|
+
else {
|
|
1093
|
+
const t = document.createElement("textarea");
|
|
1094
|
+
t.value = e, t.style.position = "fixed", t.style.left = "-999999px", t.style.top = "-999999px", document.body.appendChild(t), t.focus(), t.select();
|
|
1095
|
+
const i = document.execCommand("copy");
|
|
1096
|
+
document.body.removeChild(t), i ? this.showCopyFeedback(!0) : this.showCopyFeedback(!1);
|
|
1097
|
+
}
|
|
1098
|
+
} catch (t) {
|
|
1099
|
+
console.error("复制失败:", t), this.showCopyFeedback(!1);
|
|
1100
|
+
}
|
|
1101
|
+
}
|
|
1102
|
+
// 显示复制反馈提示
|
|
1103
|
+
showCopyFeedback(e) {
|
|
1104
|
+
const t = e ? "复制成功!" : "复制失败,请手动复制", i = document.createElement("div");
|
|
1105
|
+
i.className = `tiny-remoter-copy-feedback ${e ? "success" : "error"}`, i.textContent = t, document.body.appendChild(i), setTimeout(() => i.classList.add("show"), 10), setTimeout(() => {
|
|
1106
|
+
i.classList.remove("show"), setTimeout(() => {
|
|
1107
|
+
i.parentNode && i.parentNode.removeChild(i);
|
|
1108
|
+
}, 300);
|
|
1109
|
+
}, 1500);
|
|
1110
|
+
}
|
|
1111
|
+
// 创建二维码弹窗
|
|
1112
|
+
async showQRCode() {
|
|
1113
|
+
const t = await new d2((this.options.qrCodeUrl || "") + this.sessionPrefix + this.options.sessionId, {}).toDataURL(), i = this.createModal(
|
|
1114
|
+
"扫码前往智能遥控器",
|
|
1115
|
+
`
|
|
1116
|
+
<div style="text-align: center; padding: 32px;">
|
|
1117
|
+
<!-- 二维码容器 - 添加渐变背景和阴影效果 -->
|
|
1118
|
+
<div style="
|
|
1119
|
+
width: 240px;
|
|
1120
|
+
height: 240px;
|
|
1121
|
+
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
|
1122
|
+
margin: 0 auto 24px;
|
|
1123
|
+
display: flex;
|
|
1124
|
+
align-items: center;
|
|
1125
|
+
justify-content: center;
|
|
1126
|
+
border-radius: 20px;
|
|
1127
|
+
box-shadow: 0 20px 40px rgba(102, 126, 234, 0.3);
|
|
1128
|
+
position: relative;
|
|
1129
|
+
overflow: hidden;
|
|
1130
|
+
">
|
|
1131
|
+
<!-- 装饰性背景元素 -->
|
|
1132
|
+
<div style="
|
|
1133
|
+
position: absolute;
|
|
1134
|
+
top: -50%;
|
|
1135
|
+
left: -50%;
|
|
1136
|
+
width: 200%;
|
|
1137
|
+
height: 200%;
|
|
1138
|
+
background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 70%);
|
|
1139
|
+
animation: rotate 20s linear infinite;
|
|
1140
|
+
"></div>
|
|
1141
|
+
|
|
1142
|
+
<!-- 二维码图片容器 -->
|
|
1143
|
+
<div style="
|
|
1144
|
+
width: 200px;
|
|
1145
|
+
height: 200px;
|
|
1146
|
+
background: white;
|
|
1147
|
+
border-radius: 16px;
|
|
1148
|
+
padding: 16px;
|
|
1149
|
+
box-shadow: 0 8px 32px rgba(0,0,0,0.1);
|
|
1150
|
+
position: relative;
|
|
1151
|
+
z-index: 1;
|
|
1152
|
+
">
|
|
1153
|
+
<img src="${t}" alt="二维码" style="
|
|
1154
|
+
width: 100%;
|
|
1155
|
+
height: 100%;
|
|
1156
|
+
object-fit: contain;
|
|
1157
|
+
border-radius: 8px;
|
|
1158
|
+
">
|
|
1159
|
+
</div>
|
|
1160
|
+
</div>
|
|
1161
|
+
|
|
1162
|
+
<!-- 标题文字 -->
|
|
1163
|
+
<h3 style="
|
|
1164
|
+
color: #333;
|
|
1165
|
+
margin: 0 0 12px 0;
|
|
1166
|
+
font-size: 20px;
|
|
1167
|
+
font-weight: 600;
|
|
1168
|
+
letter-spacing: 0.5px;
|
|
1169
|
+
">扫描二维码</h3>
|
|
1170
|
+
|
|
1171
|
+
<!-- 描述文字 -->
|
|
1172
|
+
<p style="
|
|
1173
|
+
color: #666;
|
|
1174
|
+
margin: 0 auto;
|
|
1175
|
+
margin-bottom: 20px;
|
|
1176
|
+
font-size: 14px;
|
|
1177
|
+
line-height: 1.6;
|
|
1178
|
+
max-width: 280px;
|
|
1179
|
+
">请使用手机微信或者浏览器扫描二维码跳转到智能遥控器</p>
|
|
1180
|
+
|
|
1181
|
+
<!-- 提示图标和文字 -->
|
|
1182
|
+
<div style="
|
|
1183
|
+
display: flex;
|
|
1184
|
+
align-items: center;
|
|
1185
|
+
justify-content: center;
|
|
1186
|
+
gap: 8px;
|
|
1187
|
+
color: #999;
|
|
1188
|
+
font-size: 12px;
|
|
1189
|
+
">
|
|
1190
|
+
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" style="opacity: 0.7;">
|
|
1191
|
+
<path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-2 15l-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z" fill="currentColor"/>
|
|
1192
|
+
</svg>
|
|
1193
|
+
<span>支持微信、浏览器等多种方式</span>
|
|
1194
|
+
</div>
|
|
1195
|
+
</div>
|
|
1196
|
+
`
|
|
1197
|
+
);
|
|
1198
|
+
this.showModal(i);
|
|
1199
|
+
}
|
|
1200
|
+
// 创建AI对话弹窗--- 暂时调 “用户函数”
|
|
1201
|
+
showAIChat() {
|
|
1202
|
+
var e, t;
|
|
1203
|
+
(t = (e = this.options).onShowAIChat) == null || t.call(e);
|
|
1204
|
+
}
|
|
1205
|
+
createModal(e, t) {
|
|
1206
|
+
const i = document.createElement("div");
|
|
1207
|
+
i.className = "tiny-remoter-floating-modal", i.innerHTML = `
|
|
1208
|
+
<div class="tiny-remoter-modal-overlay"></div>
|
|
1209
|
+
<div class="tiny-remoter-modal-content">
|
|
1210
|
+
<div class="tiny-remoter-modal-header">
|
|
1211
|
+
<h3>${e}</h3>
|
|
1212
|
+
<button class="tiny-remoter-modal-close">×</button>
|
|
1213
|
+
</div>
|
|
1214
|
+
<div class="tiny-remoter-modal-body">
|
|
1215
|
+
${t}
|
|
1216
|
+
</div>
|
|
1217
|
+
</div>
|
|
1218
|
+
`;
|
|
1219
|
+
const s = i.querySelector(".tiny-remoter-modal-close"), o = i.querySelector(".tiny-remoter-modal-overlay");
|
|
1220
|
+
return s.addEventListener("click", () => this.hideModal(i)), o.addEventListener("click", () => this.hideModal(i)), i;
|
|
1221
|
+
}
|
|
1222
|
+
showModal(e) {
|
|
1223
|
+
document.body.appendChild(e), setTimeout(() => e.classList.add("show"), 10);
|
|
1224
|
+
}
|
|
1225
|
+
hideModal(e) {
|
|
1226
|
+
e.classList.remove("show"), setTimeout(() => {
|
|
1227
|
+
e.parentNode && e.parentNode.removeChild(e);
|
|
1228
|
+
}, 100);
|
|
1229
|
+
}
|
|
1230
|
+
// 创建样式表
|
|
1231
|
+
addStyles() {
|
|
1232
|
+
const e = document.createElement("style");
|
|
1233
|
+
e.textContent = `
|
|
1234
|
+
/* 浮动块样式 */
|
|
1235
|
+
.tiny-remoter-floating-block {
|
|
1236
|
+
position: fixed;
|
|
1237
|
+
bottom: 30px;
|
|
1238
|
+
right: 30px;
|
|
1239
|
+
width: 60px;
|
|
1240
|
+
height: 60px;
|
|
1241
|
+
cursor: pointer;
|
|
1242
|
+
display: flex;
|
|
1243
|
+
align-items: center;
|
|
1244
|
+
justify-content: center;
|
|
1245
|
+
color: white;
|
|
1246
|
+
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
|
1247
|
+
z-index: 99;
|
|
1248
|
+
overflow: hidden;
|
|
1249
|
+
border-radius: 50%;
|
|
1250
|
+
}
|
|
1251
|
+
|
|
1252
|
+
.tiny-remoter-floating-block__icon {
|
|
1253
|
+
transform: scale(0.8);
|
|
1254
|
+
transition: transform 0.3s ease;
|
|
1255
|
+
}
|
|
1256
|
+
|
|
1257
|
+
.tiny-remoter-floating-block__icon:hover {
|
|
1258
|
+
transform: scale(1.1);
|
|
1259
|
+
}
|
|
1260
|
+
|
|
1261
|
+
.tiny-remoter-floating-block.expanded .tiny-remoter-floating-block__icon {
|
|
1262
|
+
transform: scale(1.1);
|
|
1263
|
+
}
|
|
1264
|
+
|
|
1265
|
+
/* 下拉菜单样式 */
|
|
1266
|
+
.tiny-remoter-floating-dropdown {
|
|
1267
|
+
position: fixed;
|
|
1268
|
+
bottom: 100px;
|
|
1269
|
+
right: 30px;
|
|
1270
|
+
background: white;
|
|
1271
|
+
border-radius: 18px;
|
|
1272
|
+
box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
|
|
1273
|
+
padding: 24px 24px 0px 24px;
|
|
1274
|
+
opacity: 0;
|
|
1275
|
+
visibility: hidden;
|
|
1276
|
+
transform: translateY(20px) scale(0.95);
|
|
1277
|
+
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
|
1278
|
+
z-index: 999;
|
|
1279
|
+
min-width: 200px;
|
|
1280
|
+
width: 223px;
|
|
1281
|
+
height: auto;
|
|
1282
|
+
}
|
|
1283
|
+
|
|
1284
|
+
.tiny-remoter-floating-dropdown.show {
|
|
1285
|
+
opacity: 1;
|
|
1286
|
+
visibility: visible;
|
|
1287
|
+
transform: translateY(0) scale(1);
|
|
1288
|
+
}
|
|
1289
|
+
|
|
1290
|
+
.tiny-remoter-dropdown-item {
|
|
1291
|
+
display: flex;
|
|
1292
|
+
align-items: center;
|
|
1293
|
+
border-radius: 12px;
|
|
1294
|
+
cursor: pointer;
|
|
1295
|
+
transition: all 0.2s ease;
|
|
1296
|
+
color: #333;
|
|
1297
|
+
margin-bottom: 24px;
|
|
1298
|
+
height: 40px;
|
|
1299
|
+
}
|
|
1300
|
+
|
|
1301
|
+
.tiny-remoter-dropdown-item:last-child {
|
|
1302
|
+
margin-bottom: 32px;
|
|
1303
|
+
}
|
|
1304
|
+
|
|
1305
|
+
.tiny-remoter-dropdown-item > span {
|
|
1306
|
+
flex: 1;
|
|
1307
|
+
overflow: hidden;
|
|
1308
|
+
max-width: 120px;
|
|
1309
|
+
text-overflow: ellipsis;
|
|
1310
|
+
white-space: nowrap;
|
|
1311
|
+
}
|
|
1312
|
+
|
|
1313
|
+
.tiny-remoter-dropdown-item__icon {
|
|
1314
|
+
display: flex;
|
|
1315
|
+
align-items: center;
|
|
1316
|
+
justify-content: center;
|
|
1317
|
+
width: 40px;
|
|
1318
|
+
height: 40px;
|
|
1319
|
+
background: #f8f9fa;
|
|
1320
|
+
border-radius: 8px;
|
|
1321
|
+
color: #667eea;
|
|
1322
|
+
}
|
|
1323
|
+
|
|
1324
|
+
.tiny-remoter-dropdown-item__content {
|
|
1325
|
+
flex: 1;
|
|
1326
|
+
display: flex;
|
|
1327
|
+
flex-direction: column;
|
|
1328
|
+
gap: 4px;
|
|
1329
|
+
overflow: hidden;
|
|
1330
|
+
font-size: 12px;
|
|
1331
|
+
margin-left: 16px;
|
|
1332
|
+
}
|
|
1333
|
+
|
|
1334
|
+
.tiny-remoter-dropdown-item__desc-wrapper {
|
|
1335
|
+
display: flex;
|
|
1336
|
+
align-items: center;
|
|
1337
|
+
gap: 4px;
|
|
1338
|
+
}
|
|
1339
|
+
|
|
1340
|
+
.tiny-remoter-dropdown-item__desc {
|
|
1341
|
+
color: #808080;
|
|
1342
|
+
overflow: hidden;
|
|
1343
|
+
white-space: nowrap;
|
|
1344
|
+
text-overflow: ellipsis;
|
|
1345
|
+
}
|
|
1346
|
+
|
|
1347
|
+
.tiny-remoter-dropdown-item__desc--active {
|
|
1348
|
+
color: #1476ff;
|
|
1349
|
+
}
|
|
1350
|
+
|
|
1351
|
+
.tiny-remoter-dropdown-item__desc--know {
|
|
1352
|
+
color: #191919;
|
|
1353
|
+
}
|
|
1354
|
+
|
|
1355
|
+
/* 复制图标样式 */
|
|
1356
|
+
.tiny-remoter-copy-icon {
|
|
1357
|
+
display: flex;
|
|
1358
|
+
align-items: center;
|
|
1359
|
+
justify-content: center;
|
|
1360
|
+
width: 24px;
|
|
1361
|
+
height: 24px;
|
|
1362
|
+
background: #f0f0f0;
|
|
1363
|
+
border-radius: 6px;
|
|
1364
|
+
color: #666;
|
|
1365
|
+
cursor: pointer;
|
|
1366
|
+
transition: all 0.2s ease;
|
|
1367
|
+
opacity: 0.7;
|
|
1368
|
+
margin-left: auto;
|
|
1369
|
+
}
|
|
1370
|
+
|
|
1371
|
+
.tiny-remoter-copy-icon:hover {
|
|
1372
|
+
background: #e0e0e0;
|
|
1373
|
+
color: #333;
|
|
1374
|
+
opacity: 1;
|
|
1375
|
+
transform: scale(1.1);
|
|
1376
|
+
}
|
|
1377
|
+
|
|
1378
|
+
.tiny-remoter-copy-icon:active {
|
|
1379
|
+
transform: scale(0.95);
|
|
1380
|
+
}
|
|
1381
|
+
|
|
1382
|
+
/* 弹窗样式 */
|
|
1383
|
+
.tiny-remoter-floating-modal {
|
|
1384
|
+
position: fixed;
|
|
1385
|
+
top: 0;
|
|
1386
|
+
left: 0;
|
|
1387
|
+
width: 100%;
|
|
1388
|
+
height: 100%;
|
|
1389
|
+
z-index: 2000;
|
|
1390
|
+
display: flex;
|
|
1391
|
+
align-items: center;
|
|
1392
|
+
justify-content: center;
|
|
1393
|
+
}
|
|
1394
|
+
|
|
1395
|
+
.tiny-remoter-modal-overlay {
|
|
1396
|
+
position: absolute;
|
|
1397
|
+
top: 0;
|
|
1398
|
+
left: 0;
|
|
1399
|
+
width: 100%;
|
|
1400
|
+
height: 100%;
|
|
1401
|
+
background: rgba(0, 0, 0, 0.5);
|
|
1402
|
+
backdrop-filter: blur(4px);
|
|
1403
|
+
opacity: 0;
|
|
1404
|
+
transition: opacity 0.3s ease;
|
|
1405
|
+
}
|
|
1406
|
+
|
|
1407
|
+
.tiny-remoter-modal-content {
|
|
1408
|
+
background: white;
|
|
1409
|
+
border-radius: 16px;
|
|
1410
|
+
box-shadow: 0 25px 80px rgba(0, 0, 0, 0.2);
|
|
1411
|
+
max-width: 500px;
|
|
1412
|
+
width: 90%;
|
|
1413
|
+
max-height: 80vh;
|
|
1414
|
+
overflow: hidden;
|
|
1415
|
+
transform: scale(0.9) translateY(20px);
|
|
1416
|
+
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
|
1417
|
+
}
|
|
1418
|
+
|
|
1419
|
+
.tiny-remoter-floating-modal.show .tiny-remoter-modal-overlay {
|
|
1420
|
+
opacity: 1;
|
|
1421
|
+
}
|
|
1422
|
+
|
|
1423
|
+
.tiny-remoter-floating-modal.show .tiny-remoter-modal-content {
|
|
1424
|
+
transform: scale(1) translateY(0);
|
|
1425
|
+
}
|
|
1426
|
+
|
|
1427
|
+
.tiny-remoter-modal-header {
|
|
1428
|
+
display: flex;
|
|
1429
|
+
align-items: center;
|
|
1430
|
+
justify-content: space-between;
|
|
1431
|
+
padding: 20px 24px;
|
|
1432
|
+
border-bottom: 1px solid #f0f0f0;
|
|
1433
|
+
}
|
|
1434
|
+
|
|
1435
|
+
.tiny-remoter-modal-header h3 {
|
|
1436
|
+
margin: 0;
|
|
1437
|
+
font-size: 18px;
|
|
1438
|
+
font-weight: 600;
|
|
1439
|
+
color: #333;
|
|
1440
|
+
}
|
|
1441
|
+
|
|
1442
|
+
.tiny-remoter-modal-close {
|
|
1443
|
+
background: none;
|
|
1444
|
+
border: none;
|
|
1445
|
+
font-size: 24px;
|
|
1446
|
+
cursor: pointer;
|
|
1447
|
+
color: #999;
|
|
1448
|
+
padding: 0;
|
|
1449
|
+
width: 32px;
|
|
1450
|
+
height: 32px;
|
|
1451
|
+
border-radius: 50%;
|
|
1452
|
+
display: flex;
|
|
1453
|
+
align-items: center;
|
|
1454
|
+
justify-content: center;
|
|
1455
|
+
transition: all 0.2s ease;
|
|
1456
|
+
}
|
|
1457
|
+
|
|
1458
|
+
.tiny-remoter-modal-close:hover {
|
|
1459
|
+
background: #f5f5f5;
|
|
1460
|
+
color: #666;
|
|
1461
|
+
}
|
|
1462
|
+
|
|
1463
|
+
.tiny-remoter-modal-body {
|
|
1464
|
+
padding: 24px;
|
|
1465
|
+
}
|
|
1466
|
+
|
|
1467
|
+
/* 二维码弹窗动画 */
|
|
1468
|
+
@keyframes rotate {
|
|
1469
|
+
from {
|
|
1470
|
+
transform: rotate(0deg);
|
|
1471
|
+
}
|
|
1472
|
+
to {
|
|
1473
|
+
transform: rotate(360deg);
|
|
1474
|
+
}
|
|
1475
|
+
}
|
|
1476
|
+
|
|
1477
|
+
/* 响应式设计 */
|
|
1478
|
+
@media (max-width: 768px) {
|
|
1479
|
+
.tiny-remoter-floating-block {
|
|
1480
|
+
bottom: 20px;
|
|
1481
|
+
right: 20px;
|
|
1482
|
+
width: 56px;
|
|
1483
|
+
height: 56px;
|
|
1484
|
+
}
|
|
1485
|
+
|
|
1486
|
+
.tiny-remoter-floating-dropdown {
|
|
1487
|
+
bottom: 90px;
|
|
1488
|
+
right: 20px;
|
|
1489
|
+
min-width: 180px;
|
|
1490
|
+
}
|
|
1491
|
+
|
|
1492
|
+
.tiny-remoter-modal-content {
|
|
1493
|
+
width: 95%;
|
|
1494
|
+
margin: 20px;
|
|
1495
|
+
}
|
|
1496
|
+
}
|
|
1497
|
+
|
|
1498
|
+
/* 复制反馈提示样式 */
|
|
1499
|
+
.tiny-remoter-copy-feedback {
|
|
1500
|
+
position: fixed;
|
|
1501
|
+
top: 50%;
|
|
1502
|
+
left: 50%;
|
|
1503
|
+
transform: translate(-50%, -50%);
|
|
1504
|
+
background: rgba(0, 0, 0, 0.8);
|
|
1505
|
+
color: white;
|
|
1506
|
+
padding: 12px 24px;
|
|
1507
|
+
border-radius: 8px;
|
|
1508
|
+
font-size: 14px;
|
|
1509
|
+
font-weight: 500;
|
|
1510
|
+
z-index: 10000;
|
|
1511
|
+
opacity: 0;
|
|
1512
|
+
visibility: hidden;
|
|
1513
|
+
transition: all 0.3s ease;
|
|
1514
|
+
backdrop-filter: blur(4px);
|
|
1515
|
+
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
|
|
1516
|
+
}
|
|
1517
|
+
|
|
1518
|
+
.tiny-remoter-copy-feedback.show {
|
|
1519
|
+
opacity: 1;
|
|
1520
|
+
visibility: visible;
|
|
1521
|
+
transform: translate(-50%, -50%) scale(1);
|
|
1522
|
+
}
|
|
1523
|
+
|
|
1524
|
+
.tiny-remoter-copy-feedback.success {
|
|
1525
|
+
background: rgba(34, 197, 94, 0.9);
|
|
1526
|
+
}
|
|
1527
|
+
|
|
1528
|
+
.tiny-remoter-copy-feedback.error {
|
|
1529
|
+
background: rgba(239, 68, 68, 0.9);
|
|
1530
|
+
}
|
|
1531
|
+
|
|
1532
|
+
/* 深色主题支持 */
|
|
1533
|
+
@media (prefers-color-scheme: dark) {
|
|
1534
|
+
.tiny-remoter-floating-dropdown {
|
|
1535
|
+
background: #1a1a1a;
|
|
1536
|
+
color: white;
|
|
1537
|
+
}
|
|
1538
|
+
|
|
1539
|
+
.tiny-remoter-dropdown-item {
|
|
1540
|
+
color: white;
|
|
1541
|
+
}
|
|
1542
|
+
|
|
1543
|
+
|
|
1544
|
+
.tiny-remoter-copy-icon {
|
|
1545
|
+
background: #2a2a2a;
|
|
1546
|
+
color: #ccc;
|
|
1547
|
+
}
|
|
1548
|
+
|
|
1549
|
+
.tiny-remoter-copy-icon:hover {
|
|
1550
|
+
background: #3a3a3a;
|
|
1551
|
+
color: white;
|
|
1552
|
+
}
|
|
1553
|
+
|
|
1554
|
+
.tiny-remoter-modal-content {
|
|
1555
|
+
background: #1a1a1a;
|
|
1556
|
+
color: white;
|
|
1557
|
+
}
|
|
1558
|
+
|
|
1559
|
+
.tiny-remoter-modal-header {
|
|
1560
|
+
border-bottom-color: #333;
|
|
1561
|
+
}
|
|
1562
|
+
|
|
1563
|
+
.tiny-remoter-modal-header h3 {
|
|
1564
|
+
color: white;
|
|
1565
|
+
}
|
|
1566
|
+
}
|
|
1567
|
+
`, document.head.appendChild(e);
|
|
1568
|
+
}
|
|
1569
|
+
// 销毁组件
|
|
1570
|
+
destroy() {
|
|
1571
|
+
this.floatingBlock.parentNode && this.floatingBlock.parentNode.removeChild(this.floatingBlock), this.dropdownMenu.parentNode && this.dropdownMenu.parentNode.removeChild(this.dropdownMenu);
|
|
1572
|
+
}
|
|
1573
|
+
}
|
|
1574
|
+
const Q2 = (r = {}) => new L2(r), v2 = async (r) => {
|
|
1575
|
+
const e = {};
|
|
1576
|
+
try {
|
|
1577
|
+
const t = await r.listTools();
|
|
1578
|
+
for (const { name: i, description: s, inputSchema: o } of t.tools) {
|
|
1579
|
+
const n = async (a, c) => r.callTool({ name: i, arguments: a }, { signal: c == null ? void 0 : c.abortSignal });
|
|
1580
|
+
e[i] = e2({
|
|
1581
|
+
description: s,
|
|
1582
|
+
inputSchema: t2({
|
|
1583
|
+
...o,
|
|
1584
|
+
properties: o.properties ?? {},
|
|
1585
|
+
additionalProperties: !1
|
|
1586
|
+
}),
|
|
1587
|
+
execute: n
|
|
1588
|
+
});
|
|
1589
|
+
}
|
|
1590
|
+
return e;
|
|
1591
|
+
} catch (t) {
|
|
1592
|
+
throw t;
|
|
1593
|
+
}
|
|
1594
|
+
}, x2 = {
|
|
1595
|
+
openai: n2,
|
|
1596
|
+
deepseek: a2
|
|
1597
|
+
};
|
|
1598
|
+
class K2 {
|
|
1599
|
+
constructor({ llmConfig: e, mcpServers: t }) {
|
|
1600
|
+
if (this.mcpServers = {}, this.mcpClients = {}, this.mcpTools = {}, this.ignoreToolnames = [], this.messages = [], !e)
|
|
1601
|
+
throw new Error("llmConfig is required to initialize AgentModelProvider");
|
|
1602
|
+
if (this.mcpServers = t || {}, this.mcpClients = {}, this.mcpTools = {}, e.llm)
|
|
1603
|
+
this.llm = e.llm;
|
|
1604
|
+
else if (e.providerType) {
|
|
1605
|
+
const i = e.providerType;
|
|
1606
|
+
let s;
|
|
1607
|
+
typeof i == "string" ? s = x2[i] : s = i, this.llm = s({
|
|
1608
|
+
apiKey: e.apiKey,
|
|
1609
|
+
baseURL: e.baseURL
|
|
1610
|
+
});
|
|
1611
|
+
} else
|
|
1612
|
+
throw new Error("Either llmConfig.llm or llmConfig.providerType must be provided");
|
|
1613
|
+
}
|
|
1614
|
+
/** 创建一个 ai-sdk的 mcpClient, 创建失败则返回 null */
|
|
1615
|
+
async _createOneClient(e) {
|
|
1616
|
+
try {
|
|
1617
|
+
let t;
|
|
1618
|
+
if ("type" in e && e.type.toLocaleLowerCase() === "streamablehttp" ? t = new p(new URL(e.url)) : "type" in e && e.type === "extension" ? t = new h2(e.sessionId) : t = e, e.useAISdkClient ?? !1) {
|
|
1619
|
+
const s = await i2({ transport: t });
|
|
1620
|
+
return s.__transport__ = t, s;
|
|
1621
|
+
} else {
|
|
1622
|
+
const s = new c2(
|
|
1623
|
+
{ name: "mcp-web-client", version: "1.0.0" },
|
|
1624
|
+
{ capabilities: { roots: { listChanged: !0 }, sampling: {}, elicitation: {} } }
|
|
1625
|
+
);
|
|
1626
|
+
return await s.connect(t), s.__transport__ = t, s;
|
|
1627
|
+
}
|
|
1628
|
+
} catch (t) {
|
|
1629
|
+
return this.onError && this.onError((t == null ? void 0 : t.message) || "Failed to create MCP client", t), console.error("Failed to create MCP client", e, t), null;
|
|
1630
|
+
}
|
|
1631
|
+
}
|
|
1632
|
+
/** 关闭一个 mcpClient */
|
|
1633
|
+
async _closeOneClient(e) {
|
|
1634
|
+
var t, i, s;
|
|
1635
|
+
try {
|
|
1636
|
+
const o = e.__transport__;
|
|
1637
|
+
if (o && o instanceof N || o && o instanceof $)
|
|
1638
|
+
return;
|
|
1639
|
+
await ((t = o == null ? void 0 : o.terminateSession) == null ? void 0 : t.call(o)), await ((i = o == null ? void 0 : o.close) == null ? void 0 : i.call(o)), await ((s = e == null ? void 0 : e.close) == null ? void 0 : s.call(e));
|
|
1640
|
+
} catch {
|
|
1641
|
+
}
|
|
1642
|
+
}
|
|
1643
|
+
/** 创建所有 mcpClients */
|
|
1644
|
+
async _createMpcClients() {
|
|
1645
|
+
const e = Object.entries(this.mcpServers), t = await Promise.all(
|
|
1646
|
+
e.map(async ([i, s]) => {
|
|
1647
|
+
const o = await this._createOneClient(s);
|
|
1648
|
+
return { serverName: i, client: o };
|
|
1649
|
+
})
|
|
1650
|
+
);
|
|
1651
|
+
this.mcpClients = {}, t.forEach(({ serverName: i, client: s }) => {
|
|
1652
|
+
this.mcpClients[i] = s;
|
|
1653
|
+
});
|
|
1654
|
+
}
|
|
1655
|
+
/** 兼容两种 client 类型的 tools 获取方法 */
|
|
1656
|
+
async _getClientTools(e, t) {
|
|
1657
|
+
if (!e)
|
|
1658
|
+
return null;
|
|
1659
|
+
try {
|
|
1660
|
+
return typeof e.tools == "function" ? await e.tools() : await v2(e);
|
|
1661
|
+
} catch (i) {
|
|
1662
|
+
return this.onError && this.onError((i == null ? void 0 : i.message) || `Failed to query tools for ${t}`, i), console.error(`Failed to query tools for ${t}`, i), null;
|
|
1663
|
+
}
|
|
1664
|
+
}
|
|
1665
|
+
/** 查询所有 mcpClients 的 tools, 失败则保存为null */
|
|
1666
|
+
async _createMpcTools() {
|
|
1667
|
+
const e = Object.entries(this.mcpClients), t = await Promise.all(
|
|
1668
|
+
e.map(async ([i, s]) => {
|
|
1669
|
+
const o = await this._getClientTools(s, i);
|
|
1670
|
+
return { serverName: i, tools: o };
|
|
1671
|
+
})
|
|
1672
|
+
);
|
|
1673
|
+
this.mcpTools = {}, t.forEach(({ serverName: i, tools: s }) => {
|
|
1674
|
+
const o = s && typeof s == "object" ? s : {};
|
|
1675
|
+
this.mcpTools[i] = o;
|
|
1676
|
+
});
|
|
1677
|
+
}
|
|
1678
|
+
/** 关闭所有的 clients */
|
|
1679
|
+
async closeAll() {
|
|
1680
|
+
await Promise.all(
|
|
1681
|
+
Object.values(this.mcpClients).map(async (e) => {
|
|
1682
|
+
try {
|
|
1683
|
+
await this._closeOneClient(e);
|
|
1684
|
+
} catch (t) {
|
|
1685
|
+
this.onError && this.onError((t == null ? void 0 : t.message) || "Failed to close client", t), console.error("Failed to close client", t);
|
|
1686
|
+
}
|
|
1687
|
+
})
|
|
1688
|
+
);
|
|
1689
|
+
}
|
|
1690
|
+
/** 创建所有的 mcpClients,并更新它们的tools */
|
|
1691
|
+
async initClientsAndTools() {
|
|
1692
|
+
var e;
|
|
1693
|
+
await this._createMpcClients(), await this._createMpcTools(), (e = this.onUpdatedTools) == null || e.call(this);
|
|
1694
|
+
}
|
|
1695
|
+
/** 全量更新所有的 mcpServers */
|
|
1696
|
+
async updateMcpServers(e) {
|
|
1697
|
+
await this.closeAll(), this.mcpServers = e || this.mcpServers, await this.initClientsAndTools();
|
|
1698
|
+
}
|
|
1699
|
+
/** 插入一个新的mcpServer,如果已经存在则返回false */
|
|
1700
|
+
async insertMcpServer(e, t) {
|
|
1701
|
+
var o, n;
|
|
1702
|
+
if (this.mcpServers[e])
|
|
1703
|
+
return !1;
|
|
1704
|
+
const i = await this._createOneClient(t);
|
|
1705
|
+
if (!i)
|
|
1706
|
+
return (o = this.onError) == null || o.call(this, `Failed to create MCP client: ${e}`), null;
|
|
1707
|
+
this.mcpClients[e] = i;
|
|
1708
|
+
const s = await this._getClientTools(i, e);
|
|
1709
|
+
return this.mcpTools[e] = s && typeof s == "object" ? s : {}, this.mcpServers[e] = t, (n = this.onUpdatedTools) == null || n.call(this), i;
|
|
1710
|
+
}
|
|
1711
|
+
/** 通过服务器名称删除mcpServer: mcpServers mcpClients mcpTools ignoreToolnames */
|
|
1712
|
+
async removeMcpServer(e) {
|
|
1713
|
+
var s;
|
|
1714
|
+
if (!this.mcpServers[e])
|
|
1715
|
+
return;
|
|
1716
|
+
delete this.mcpServers[e];
|
|
1717
|
+
const t = this.mcpClients[e];
|
|
1718
|
+
delete this.mcpClients[e];
|
|
1719
|
+
try {
|
|
1720
|
+
await this._closeOneClient(t);
|
|
1721
|
+
} catch {
|
|
1722
|
+
}
|
|
1723
|
+
const i = this.mcpTools[e];
|
|
1724
|
+
delete this.mcpTools[e], i && Object.keys(i).forEach((o) => {
|
|
1725
|
+
this.ignoreToolnames = this.ignoreToolnames.filter((n) => n !== o);
|
|
1726
|
+
}), (s = this.onUpdatedTools) == null || s.call(this);
|
|
1727
|
+
}
|
|
1728
|
+
/** 创建临时允许调用的tools集合 */
|
|
1729
|
+
_tempMergeTools(e = {}) {
|
|
1730
|
+
const t = Object.values(this.mcpTools).reduce((i, s) => ({ ...i, ...s }), {});
|
|
1731
|
+
return Object.assign(t, e), this.ignoreToolnames.forEach((i) => {
|
|
1732
|
+
delete t[i];
|
|
1733
|
+
}), t;
|
|
1734
|
+
}
|
|
1735
|
+
async _chat(e, { model: t, maxSteps: i = 5, ...s }) {
|
|
1736
|
+
var a;
|
|
1737
|
+
if (!this.llm)
|
|
1738
|
+
throw new Error("LLM is not initialized");
|
|
1739
|
+
await this.initClientsAndTools();
|
|
1740
|
+
const o = {
|
|
1741
|
+
// @ts-ignore ProviderV2 是所有llm的父类, 在每一个具体的llm 类都有一个选择model的函数用法
|
|
1742
|
+
model: this.llm(t),
|
|
1743
|
+
stopWhen: s2(i),
|
|
1744
|
+
...s,
|
|
1745
|
+
tools: this._tempMergeTools(s.tools)
|
|
1746
|
+
};
|
|
1747
|
+
s.message && !s.messages && (this.messages.push({ role: "user", content: s.message }), o.messages = [...this.messages]);
|
|
1748
|
+
const n = e(o);
|
|
1749
|
+
return (a = n == null ? void 0 : n.response) == null || a.then((c) => {
|
|
1750
|
+
this.messages.push(...c.messages);
|
|
1751
|
+
}), n;
|
|
1752
|
+
}
|
|
1753
|
+
async chat(e) {
|
|
1754
|
+
return this._chat(o2, e);
|
|
1755
|
+
}
|
|
1756
|
+
async chatStream(e) {
|
|
1757
|
+
return this._chat(r2, e);
|
|
1758
|
+
}
|
|
1759
|
+
}
|
|
1760
|
+
export {
|
|
1761
|
+
K2 as AgentModelProvider,
|
|
1762
|
+
G2 as Ajv,
|
|
1763
|
+
s0 as AuthClientProvider,
|
|
1764
|
+
V2 as ContentScriptServerTransport,
|
|
1765
|
+
h2 as ExtensionClientTransport,
|
|
1766
|
+
Y2 as ExtensionPageServerTransport,
|
|
1767
|
+
C0 as InMemoryTransport,
|
|
1768
|
+
d2 as QrCode,
|
|
1769
|
+
r0 as ResourceTemplate,
|
|
1770
|
+
a0 as UriTemplate,
|
|
1771
|
+
c2 as WebMcpClient,
|
|
1772
|
+
z2 as WebMcpServer,
|
|
1773
|
+
l0 as completable,
|
|
1774
|
+
B2 as createMessageChannelClientTransport,
|
|
1775
|
+
$2 as createMessageChannelPairTransport,
|
|
1776
|
+
H2 as createMessageChannelServerTransport,
|
|
1777
|
+
Q2 as createRemoter,
|
|
1778
|
+
O2 as createSSEClientTransport,
|
|
1779
|
+
j2 as createStreamableHTTPClientTransport,
|
|
1780
|
+
v2 as getAISDKTools,
|
|
1781
|
+
d0 as getDisplayName,
|
|
1782
|
+
W2 as isMcpClient,
|
|
1783
|
+
F2 as isMcpServer,
|
|
1784
|
+
A2 as isMessageChannelClientTransport,
|
|
1785
|
+
N2 as isMessageChannelServerTransport,
|
|
1786
|
+
D2 as isSSEClientTransport,
|
|
1787
|
+
l2 as isStreamableHTTPClientTransport,
|
|
1788
|
+
t0 as z
|
|
1789
|
+
};
|