|
8 | 8 | header_font_color: 'rgb(100, 106, 115)',
|
9 | 9 | x_type: 'right',
|
10 | 10 | y_type: 'bottom',
|
11 |
| - x_value: '-5', |
12 |
| - y_value: '33', |
| 11 | + x_val: '30', |
| 12 | + y_val: '30', |
| 13 | + float_icon_drag: false, |
13 | 14 | }
|
14 | 15 | const script_id_prefix = 'sqlbot-assistant-float-script-'
|
15 | 16 | const guideHtml = `
|
|
35 | 36 |
|
36 | 37 | const chatButtonHtml = (data) => `
|
37 | 38 | <div class="sqlbot-assistant-chat-button">
|
38 |
| - <img style="height:100%;width:100%;display:none;" src="${data.float_icon}"> |
39 |
| - <svg style="display:none;margin-right: 20px;" data-v-39a51454="" xmlns="http://www.w3.org/2000/svg" width="30" height="30" fill="none"> |
| 39 | + <img style="height:30px;width:30px;display:none;" src="${data.float_icon}"> |
| 40 | + <svg style="display:none;" data-v-39a51454="" xmlns="http://www.w3.org/2000/svg" width="30" height="30" fill="none"> |
40 | 41 | <path fill="#149CC5" d="M28.333 13.669h-.231c.138.758.207 1.527.206 2.298.005.946-.107 1.89-.335 2.808h.65a1.05 1.05 0 0 0 1.05-1.05V15.01a1.343 1.343 0 0 0-1.34-1.341"></path>
|
41 | 42 | <path fill="#69CAA4" d="M1.692 15.967c0-.77.068-1.54.206-2.298h-.23a1.34 1.34 0 0 0-1.342 1.34v2.716a1.05 1.05 0 0 0 1.05 1.05h.651a11.4 11.4 0 0 1-.335-2.808"></path>
|
42 | 43 | <path fill="url(#a)" d="M15 3.795c-6.89 0-12.474 5.282-12.474 12.171 0 6.89 5.585 10.239 12.474 10.239s12.474-3.35 12.474-10.238c0-6.89-5.585-12.172-12.474-12.172m3.026 17.33h-6.052a6 6 0 0 1-2.484-.535c-.564-.256-2.208.282-2.663-.127-.551-.495.117-1.969-.221-2.636a6.014 6.014 0 0 1 5.368-8.73h6.052a6.014 6.014 0 0 1 0 12.029"></path>
|
|
158 | 159 | }
|
159 | 160 | const drag = (e) => {
|
160 | 161 | if (['touchmove', 'touchstart'].includes(e.type)) {
|
161 |
| - chat_button.style.top = e.touches[0].clientY - chat_button_img.naturalHeight / 2 + 'px' |
162 |
| - chat_button.style.left = e.touches[0].clientX - chat_button_img.naturalWidth / 2 + 'px' |
| 162 | + chat_button.style.top = e.touches[0].clientY - chat_button_img.clientHeight / 2 + 'px' |
| 163 | + chat_button.style.left = e.touches[0].clientX - chat_button_img.clientHeight / 2 + 'px' |
163 | 164 | } else {
|
164 |
| - chat_button.style.top = e.y - chat_button_img.naturalHeight / 2 + 'px' |
165 |
| - chat_button.style.left = e.x - chat_button_img.naturalWidth / 2 + 'px' |
| 165 | + chat_button.style.top = e.y - chat_button_img.clientHeight / 2 + 'px' |
| 166 | + chat_button.style.left = e.x - chat_button_img.clientHeight / 2 + 'px' |
166 | 167 | }
|
167 |
| - chat_button.style.width = chat_button_img.naturalWidth + 'px' |
168 |
| - chat_button.style.height = chat_button_img.naturalHeight + 'px' |
| 168 | + chat_button.style.width = chat_button_img.clientHeight + 'px' |
| 169 | + chat_button.style.height = chat_button_img.clientHeight + 'px' |
169 | 170 | }
|
170 |
| - if (data.is_draggable) { |
| 171 | + if (data.float_icon_drag) { |
171 | 172 | chat_button.addEventListener('drag', drag)
|
172 | 173 | chat_button.addEventListener('dragover', (e) => {
|
173 | 174 | e.preventDefault()
|
|
234 | 235 | height: 64px;
|
235 | 236 | box-shadow: 1px 1px 1px 9999px rgba(0,0,0,.6);
|
236 | 237 | position: absolute;
|
237 |
| - ${data.x_type}: ${data.x_value}px; |
238 |
| - ${data.y_type}: ${data.y_value}px; |
| 238 | + ${data.x_type}: ${data.x_val}px; |
| 239 | + ${data.y_type}: ${data.y_val}px; |
239 | 240 | z-index: 10001;
|
240 | 241 | }
|
241 | 242 | #sqlbot-assistant .sqlbot-assistant-tips {
|
242 | 243 | position: fixed;
|
243 |
| - ${data.x_type}:calc(${data.x_value}px + 75px); |
244 |
| - ${data.y_type}: calc(${data.y_value}px + 0px); |
| 244 | + ${data.x_type}:calc(${data.x_val}px + 75px); |
| 245 | + ${data.y_type}: calc(${data.y_val}px + 0px); |
245 | 246 | padding: 22px 24px 24px;
|
246 | 247 | border-radius: 6px;
|
247 | 248 | color: #ffffff;
|
|
297 | 298 | display:none;
|
298 | 299 | }
|
299 | 300 | @media only screen and (max-width: 768px) {
|
300 |
| - #sqlbot-assistant-chat-container { |
301 |
| - width: 100%; |
302 |
| - height: 70%; |
303 |
| - right: 0 !important; |
304 |
| - } |
305 |
| - } |
306 |
| -
|
307 |
| - #sqlbot-assistant .sqlbot-assistant-chat-button{ |
308 |
| - position: fixed; |
309 |
| - ${data.x_type}: ${data.x_value}px; |
310 |
| - ${data.y_type}: ${data.y_value}px; |
311 |
| - cursor: pointer; |
312 |
| - z-index:10000; |
313 |
| - } |
314 |
| - #sqlbot-assistant #sqlbot-assistant-chat-container{ |
315 |
| - z-index:10000;position: relative; |
316 |
| - border-radius: 8px; |
317 |
| - //border: 1px solid #ffffff; |
318 |
| - background: linear-gradient(188deg, rgba(235, 241, 255, 0.20) 39.6%, rgba(231, 249, 255, 0.20) 94.3%), #EFF0F1; |
319 |
| - box-shadow: 0px 4px 8px 0px rgba(31, 35, 41, 0.10); |
320 |
| - position: fixed;bottom: 16px;right: 16px;overflow: hidden; |
| 301 | + #sqlbot-assistant-chat-container { |
| 302 | + width: 100%; |
| 303 | + height: 70%; |
| 304 | + right: 0 !important; |
321 | 305 | }
|
| 306 | + } |
322 | 307 |
|
323 |
| - .ed-overlay-dialog { |
324 |
| - margin-top: 50px; |
325 |
| - } |
326 |
| - .ed-drawer { |
327 |
| - margin-top: 50px; |
328 |
| - } |
| 308 | + #sqlbot-assistant .sqlbot-assistant-chat-button{ |
| 309 | + position: fixed; |
| 310 | + ${data.x_type}: ${data.x_val}px; |
| 311 | + ${data.y_type}: ${data.y_val}px; |
| 312 | + cursor: pointer; |
| 313 | + z-index:10000; |
| 314 | + } |
| 315 | + #sqlbot-assistant #sqlbot-assistant-chat-container{ |
| 316 | + z-index:10000;position: relative; |
| 317 | + border-radius: 8px; |
| 318 | + //border: 1px solid #ffffff; |
| 319 | + background: linear-gradient(188deg, rgba(235, 241, 255, 0.20) 39.6%, rgba(231, 249, 255, 0.20) 94.3%), #EFF0F1; |
| 320 | + box-shadow: 0px 4px 8px 0px rgba(31, 35, 41, 0.10); |
| 321 | + position: fixed;bottom: 16px;right: 16px;overflow: hidden; |
| 322 | + } |
329 | 323 |
|
330 |
| - #sqlbot-assistant #sqlbot-assistant-chat-container .sqlbot-assistant-operate{ |
331 |
| - top: 18px; |
332 |
| - right: 15px; |
333 |
| - position: absolute; |
334 |
| - display: flex; |
335 |
| - align-items: center; |
336 |
| - line-height: 18px; |
337 |
| - } |
338 |
| - #sqlbot-assistant #sqlbot-assistant-chat-container .sqlbot-assistant-operate .sqlbot-assistant-chat-close{ |
339 |
| - margin-left:15px; |
340 |
| - cursor: pointer; |
341 |
| - } |
342 |
| - #sqlbot-assistant #sqlbot-assistant-chat-container .sqlbot-assistant-operate .sqlbot-assistant-openviewport{ |
| 324 | + .ed-overlay-dialog { |
| 325 | + margin-top: 50px; |
| 326 | + } |
| 327 | + .ed-drawer { |
| 328 | + margin-top: 50px; |
| 329 | + } |
343 | 330 |
|
344 |
| - cursor: pointer; |
345 |
| - } |
346 |
| - #sqlbot-assistant #sqlbot-assistant-chat-container .sqlbot-assistant-operate .sqlbot-assistant-closeviewport{ |
| 331 | + #sqlbot-assistant #sqlbot-assistant-chat-container .sqlbot-assistant-operate{ |
| 332 | + top: 18px; |
| 333 | + right: 15px; |
| 334 | + position: absolute; |
| 335 | + display: flex; |
| 336 | + align-items: center; |
| 337 | + line-height: 18px; |
| 338 | + } |
| 339 | + #sqlbot-assistant #sqlbot-assistant-chat-container .sqlbot-assistant-operate .sqlbot-assistant-chat-close{ |
| 340 | + margin-left:15px; |
| 341 | + cursor: pointer; |
| 342 | + } |
| 343 | + #sqlbot-assistant #sqlbot-assistant-chat-container .sqlbot-assistant-operate .sqlbot-assistant-openviewport{ |
347 | 344 |
|
348 |
| - cursor: pointer; |
349 |
| - } |
350 |
| - #sqlbot-assistant #sqlbot-assistant-chat-container .sqlbot-assistant-viewportnone{ |
351 |
| - display:none; |
| 345 | + cursor: pointer; |
| 346 | + } |
| 347 | + #sqlbot-assistant #sqlbot-assistant-chat-container .sqlbot-assistant-operate .sqlbot-assistant-closeviewport{ |
| 348 | +
|
| 349 | + cursor: pointer; |
| 350 | + } |
| 351 | + #sqlbot-assistant #sqlbot-assistant-chat-container .sqlbot-assistant-viewportnone{ |
| 352 | + display:none; |
| 353 | + } |
| 354 | + #sqlbot-assistant #sqlbot-assistant-chat-container #sqlbot-assistant-chat-iframe-${data.id} { |
| 355 | + height:100%; |
| 356 | + width:100%; |
| 357 | + border: none; |
| 358 | + } |
| 359 | + #sqlbot-assistant #sqlbot-assistant-chat-container { |
| 360 | + animation: appear .4s ease-in-out; |
| 361 | + } |
| 362 | + @keyframes appear { |
| 363 | + from { |
| 364 | + height: 0;; |
352 | 365 | }
|
353 |
| - #sqlbot-assistant #sqlbot-assistant-chat-container #sqlbot-assistant-chat-iframe-${data.id}{ |
354 |
| - height:100%; |
355 |
| - width:100%; |
356 |
| - border: none; |
357 |
| -} |
358 |
| - #sqlbot-assistant #sqlbot-assistant-chat-container { |
359 |
| - animation: appear .4s ease-in-out; |
360 |
| - } |
361 |
| - @keyframes appear { |
362 |
| - from { |
363 |
| - height: 0;; |
364 |
| - } |
365 | 366 |
|
366 |
| - to { |
367 |
| - height: 600px; |
368 |
| - } |
369 |
| - }`.replaceAll('#sqlbot-assistant ', `#${sqlbot_assistantId} `) |
| 367 | + to { |
| 368 | + height: 600px; |
| 369 | + } |
| 370 | + }`.replaceAll('#sqlbot-assistant ', `#${sqlbot_assistantId} `) |
370 | 371 | root.appendChild(style)
|
371 | 372 | }
|
372 | 373 | function getParam(src, key) {
|
|
460 | 461 | }
|
461 | 462 | const data = res.data
|
462 | 463 | const config_json = data.configuration
|
463 |
| - let tempData = Object.assign(defaultData, { id, domain_url, name: data.name }) |
| 464 | + let tempData = Object.assign(defaultData, data) |
| 465 | + if (tempData.configuration) { |
| 466 | + delete tempData.configuration |
| 467 | + } |
464 | 468 | if (config_json) {
|
465 | 469 | const config = JSON.parse(config_json)
|
466 | 470 | if (config) {
|
467 | 471 | delete config.id
|
468 | 472 | tempData = Object.assign(tempData, config)
|
469 | 473 | }
|
470 | 474 | }
|
| 475 | + tempData['id'] = id |
| 476 | + tempData['domain_url'] = domain_url |
| 477 | + |
| 478 | + if (tempData['float_icon'] && !tempData['float_icon'].startsWith('http://')) { |
| 479 | + tempData['float_icon'] = |
| 480 | + `${domain_url}/api/v1/system/assistant/picture/${tempData['float_icon']}` |
| 481 | + |
| 482 | + if (domain_url.includes('5173')) { |
| 483 | + tempData['float_icon'] = tempData['float_icon'].replace('5173', '8000') |
| 484 | + } |
| 485 | + } |
| 486 | + |
471 | 487 | tempData['online'] = online && online.toString().toLowerCase() == 'true'
|
472 | 488 | initsqlbot_assistant(tempData)
|
473 | 489 | if (data.type == 1) {
|
|
0 commit comments