pcm-agents 0.3.0 → 0.3.2
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/LICENSE +21 -21
- package/dist/cjs/index-BFPEnLbS.js +195 -0
- package/dist/cjs/index-BFPEnLbS.js.map +1 -0
- package/dist/cjs/index.cjs.js +1 -1
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/my-component.cjs.entry.js +2 -2
- package/dist/cjs/my-component.cjs.entry.js.map +1 -1
- package/dist/cjs/my-component.entry.cjs.js.map +1 -1
- package/dist/cjs/pcm-agents.cjs.js +1 -1
- package/dist/cjs/pcm-app-chat-modal.pcm-chat-message.pcm-hr-chat-modal.pcm-jlpx-modal.pcm-mnms-modal.pcm-video-chat-modal.pcm-zygh-modal.entry.cjs.js.map +1 -0
- package/dist/cjs/pcm-app-chat-modal_7.cjs.entry.js +6560 -0
- package/dist/cjs/pcm-app-chat-modal_7.cjs.entry.js.map +1 -0
- package/dist/cjs/pcm-chat-modal.cjs.entry.js +17 -32
- package/dist/cjs/pcm-chat-modal.cjs.entry.js.map +1 -1
- package/dist/cjs/pcm-chat-modal.entry.cjs.js.map +1 -1
- package/dist/collection/collection-manifest.json +2 -0
- package/dist/collection/components/my-component/my-component.css +3 -3
- package/dist/collection/components/my-component/my-component.js +1 -1
- package/dist/collection/components/my-component/my-component.js.map +1 -1
- package/dist/collection/components/pcm-app-chat-modal/pcm-app-chat-modal.css +2 -1
- package/dist/collection/components/pcm-app-chat-modal/pcm-app-chat-modal.js +137 -159
- package/dist/collection/components/pcm-app-chat-modal/pcm-app-chat-modal.js.map +1 -1
- package/dist/collection/components/pcm-chat-message/pcm-chat-message.css +66 -12
- package/dist/collection/components/pcm-chat-message/pcm-chat-message.js +106 -13
- package/dist/collection/components/pcm-chat-message/pcm-chat-message.js.map +1 -1
- package/dist/collection/components/pcm-chat-modal/pcm-chat-modal.js +39 -34
- package/dist/collection/components/pcm-chat-modal/pcm-chat-modal.js.map +1 -1
- package/dist/collection/components/pcm-hr-chat-modal/pcm-hr-chat-modal.js +76 -105
- package/dist/collection/components/pcm-hr-chat-modal/pcm-hr-chat-modal.js.map +1 -1
- package/dist/collection/components/pcm-jlpx-modal/pcm-jlpx-modal.css +162 -0
- package/dist/collection/components/pcm-jlpx-modal/pcm-jlpx-modal.js +616 -0
- package/dist/collection/components/pcm-jlpx-modal/pcm-jlpx-modal.js.map +1 -0
- package/dist/collection/components/pcm-mnms-modal/pcm-mnms-modal.css +0 -79
- package/dist/collection/components/pcm-mnms-modal/pcm-mnms-modal.js +133 -81
- package/dist/collection/components/pcm-mnms-modal/pcm-mnms-modal.js.map +1 -1
- package/dist/collection/components/pcm-video-chat-modal/pcm-video-chat-modal.js +77 -101
- package/dist/collection/components/pcm-video-chat-modal/pcm-video-chat-modal.js.map +1 -1
- package/dist/collection/components/pcm-zygh-modal/pcm-zygh-modal.css +273 -0
- package/dist/collection/components/pcm-zygh-modal/pcm-zygh-modal.js +613 -0
- package/dist/collection/components/pcm-zygh-modal/pcm-zygh-modal.js.map +1 -0
- package/dist/collection/global/global.css +324 -0
- package/dist/collection/index.js.map +1 -1
- package/dist/collection/interfaces/chat.js.map +1 -1
- package/dist/collection/utils/utils.js +54 -113
- package/dist/collection/utils/utils.js.map +1 -1
- package/dist/components/index.js +1298 -11280
- package/dist/components/index.js.map +1 -1
- package/dist/components/my-component.js +2 -3
- package/dist/components/my-component.js.map +1 -1
- package/dist/components/{p-C4l_DOnx.js → p-BctfuDvG.js} +106 -147
- package/dist/components/p-BctfuDvG.js.map +1 -0
- package/dist/components/{p-D0s1Q-3O.js → p-LkDC0SN2.js} +343 -16
- package/dist/components/p-LkDC0SN2.js.map +1 -0
- package/dist/components/pcm-app-chat-modal.js +1 -1
- package/dist/components/pcm-chat-message.js +1 -1
- package/dist/components/pcm-chat-modal.js +19 -34
- package/dist/components/pcm-chat-modal.js.map +1 -1
- package/dist/components/pcm-hr-chat-modal.js +70 -100
- package/dist/components/pcm-hr-chat-modal.js.map +1 -1
- package/dist/components/pcm-jlpx-modal.d.ts +11 -0
- package/dist/components/pcm-jlpx-modal.js +339 -0
- package/dist/components/pcm-jlpx-modal.js.map +1 -0
- package/dist/components/pcm-mnms-modal.js +109 -57
- package/dist/components/pcm-mnms-modal.js.map +1 -1
- package/dist/components/pcm-video-chat-modal.js +74 -99
- package/dist/components/pcm-video-chat-modal.js.map +1 -1
- package/dist/components/pcm-zygh-modal.d.ts +11 -0
- package/dist/components/pcm-zygh-modal.js +330 -0
- package/dist/components/pcm-zygh-modal.js.map +1 -0
- package/dist/esm/index-nVjZGfA8.js +189 -0
- package/dist/esm/index-nVjZGfA8.js.map +1 -0
- package/dist/esm/index.js +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/esm/my-component.entry.js +2 -2
- package/dist/esm/my-component.entry.js.map +1 -1
- package/dist/esm/pcm-agents.js +1 -1
- package/dist/esm/pcm-app-chat-modal.pcm-chat-message.pcm-hr-chat-modal.pcm-jlpx-modal.pcm-mnms-modal.pcm-video-chat-modal.pcm-zygh-modal.entry.js.map +1 -0
- package/dist/esm/pcm-app-chat-modal_7.entry.js +6552 -0
- package/dist/esm/pcm-app-chat-modal_7.entry.js.map +1 -0
- package/dist/esm/pcm-chat-modal.entry.js +17 -32
- package/dist/esm/pcm-chat-modal.entry.js.map +1 -1
- package/dist/pcm-agents/index.esm.js +1 -1
- package/dist/pcm-agents/my-component.entry.esm.js.map +1 -1
- package/dist/pcm-agents/p-55417392.entry.js +2 -0
- package/dist/pcm-agents/p-55417392.entry.js.map +1 -0
- package/dist/pcm-agents/p-a698b59f.entry.js +2 -0
- package/dist/pcm-agents/p-a698b59f.entry.js.map +1 -0
- package/dist/pcm-agents/p-f3ca99b4.entry.js +2 -0
- package/dist/pcm-agents/p-f3ca99b4.entry.js.map +1 -0
- package/dist/pcm-agents/p-nVjZGfA8.js +2 -0
- package/dist/pcm-agents/p-nVjZGfA8.js.map +1 -0
- package/dist/pcm-agents/pcm-agents.esm.js +1 -1
- package/dist/pcm-agents/pcm-app-chat-modal.pcm-chat-message.pcm-hr-chat-modal.pcm-jlpx-modal.pcm-mnms-modal.pcm-video-chat-modal.pcm-zygh-modal.entry.esm.js.map +1 -0
- package/dist/pcm-agents/pcm-chat-modal.entry.esm.js.map +1 -1
- package/dist/types/components/pcm-app-chat-modal/pcm-app-chat-modal.d.ts +13 -8
- package/dist/types/components/pcm-chat-message/pcm-chat-message.d.ts +5 -0
- package/dist/types/components/pcm-chat-modal/pcm-chat-modal.d.ts +8 -8
- package/dist/types/components/pcm-hr-chat-modal/pcm-hr-chat-modal.d.ts +6 -12
- package/dist/types/components/pcm-jlpx-modal/pcm-jlpx-modal.d.ts +113 -0
- package/dist/types/components/pcm-mnms-modal/pcm-mnms-modal.d.ts +19 -20
- package/dist/types/components/pcm-video-chat-modal/pcm-video-chat-modal.d.ts +4 -4
- package/dist/types/components/pcm-zygh-modal/pcm-zygh-modal.d.ts +117 -0
- package/dist/types/components.d.ts +429 -80
- package/dist/types/interfaces/chat.d.ts +0 -4
- package/dist/types/utils/utils.d.ts +29 -83
- package/package.json +61 -60
- package/readme.md +307 -307
- package/dist/cjs/index-DfIUl99H.js +0 -11413
- package/dist/cjs/index-DfIUl99H.js.map +0 -1
- package/dist/cjs/pcm-app-chat-modal.pcm-chat-message.pcm-mnms-modal.entry.cjs.js.map +0 -1
- package/dist/cjs/pcm-app-chat-modal_3.cjs.entry.js +0 -3734
- package/dist/cjs/pcm-app-chat-modal_3.cjs.entry.js.map +0 -1
- package/dist/cjs/pcm-hr-chat-modal.cjs.entry.js +0 -1078
- package/dist/cjs/pcm-hr-chat-modal.cjs.entry.js.map +0 -1
- package/dist/cjs/pcm-hr-chat-modal.entry.cjs.js.map +0 -1
- package/dist/cjs/pcm-video-chat-modal.cjs.entry.js +0 -927
- package/dist/cjs/pcm-video-chat-modal.cjs.entry.js.map +0 -1
- package/dist/cjs/pcm-video-chat-modal.entry.cjs.js.map +0 -1
- package/dist/components/p-C4l_DOnx.js.map +0 -1
- package/dist/components/p-CgDy4pJp.js +0 -1244
- package/dist/components/p-CgDy4pJp.js.map +0 -1
- package/dist/components/p-D0s1Q-3O.js.map +0 -1
- package/dist/esm/index-B2EtEi7v.js +0 -11409
- package/dist/esm/index-B2EtEi7v.js.map +0 -1
- package/dist/esm/pcm-app-chat-modal.pcm-chat-message.pcm-mnms-modal.entry.js.map +0 -1
- package/dist/esm/pcm-app-chat-modal_3.entry.js +0 -3730
- package/dist/esm/pcm-app-chat-modal_3.entry.js.map +0 -1
- package/dist/esm/pcm-hr-chat-modal.entry.js +0 -1076
- package/dist/esm/pcm-hr-chat-modal.entry.js.map +0 -1
- package/dist/esm/pcm-video-chat-modal.entry.js +0 -925
- package/dist/esm/pcm-video-chat-modal.entry.js.map +0 -1
- package/dist/pcm-agents/p-0ddd5c47.entry.js +0 -2
- package/dist/pcm-agents/p-0ddd5c47.entry.js.map +0 -1
- package/dist/pcm-agents/p-5f624943.entry.js +0 -2
- package/dist/pcm-agents/p-5f624943.entry.js.map +0 -1
- package/dist/pcm-agents/p-6c07f155.entry.js +0 -2
- package/dist/pcm-agents/p-6c07f155.entry.js.map +0 -1
- package/dist/pcm-agents/p-9a1fb6ca.entry.js +0 -2
- package/dist/pcm-agents/p-9a1fb6ca.entry.js.map +0 -1
- package/dist/pcm-agents/p-B2EtEi7v.js +0 -146
- package/dist/pcm-agents/p-B2EtEi7v.js.map +0 -1
- package/dist/pcm-agents/p-e21bc169.entry.js +0 -2
- package/dist/pcm-agents/p-e21bc169.entry.js.map +0 -1
- package/dist/pcm-agents/pcm-app-chat-modal.pcm-chat-message.pcm-mnms-modal.entry.esm.js.map +0 -1
- package/dist/pcm-agents/pcm-hr-chat-modal.entry.esm.js.map +0 -1
- package/dist/pcm-agents/pcm-video-chat-modal.entry.esm.js.map +0 -1
|
@@ -1,1076 +0,0 @@
|
|
|
1
|
-
import { r as registerInstance, c as createEvent, g as getElement, h } from './index-DaMwkrv5.js';
|
|
2
|
-
import { a as sendSSERequest, s as sendHttpRequest } from './index-B2EtEi7v.js';
|
|
3
|
-
|
|
4
|
-
const pcmHrChatModalCss = ":host{display:block}.modal-overlay{position:fixed;top:0;left:0;right:0;bottom:0;background-color:rgba(0, 0, 0, 0.5);display:flex;justify-content:center;align-items:center;overflow-y:auto;padding:20px;z-index:1000}.fullscreen-overlay{padding:0}.modal-container{background:white;border-radius:8px;width:100%;max-width:800px;display:flex;flex-direction:column;position:relative;margin:auto}.modal-container.fullscreen{width:100vw;max-width:none;height:100%;border-radius:0;margin:0;display:flex;flex-direction:column;height:100vh;max-height:100vh}.modal-container.fullscreen>div:not(.modal-header):not(.initial-upload){display:flex;flex-direction:column;flex:1;overflow:hidden;height:100%}.pc-layout{width:80%;max-width:800px;min-width:320px;min-height:400px}.mobile-layout{width:100%;height:100%;border-radius:0}@media screen and (max-width: 768px){.pc-layout{width:95%;}.modal-overlay{padding:0}.modal-container.fullscreen{height:-webkit-fill-available;max-height:-webkit-fill-available;padding:env(safe-area-inset-top) 0 env(safe-area-inset-bottom)}.modal-container.mobile-layout{width:100%;height:100vh;max-height:100vh;min-height:100vh;border-radius:0;margin:0;display:flex;flex-direction:column}}.video-preview.placeholder{display:flex;justify-content:center;align-items:center;background:#EAEAEA}.placeholder-status{color:#00000066}.waiting-message p{margin:0;font-size:16px;color:white;font-weight:500}.recording-container{width:100%;display:flex;flex-direction:column;align-items:center}.video-area{width:100%;display:flex;flex-direction:column;align-items:center}.stop-recording-button{width:100%;height:100%;font-size:16px;background:#f44336;border-radius:6px;color:white;border:none;cursor:pointer}.stop-recording-button:hover{background:#d32f2f}.play-audio-container{width:100%;height:100%;display:flex;justify-content:center;align-items:center}.modal-header{display:flex;justify-content:space-between;align-items:center;padding:4px 16px;height:50px;border-bottom:1px solid #e8e8e8;flex-shrink:0;}.header-left{display:flex;align-items:center;gap:8px}.header-icon{width:24px;height:24px}.close-button{background:transparent;border:none;cursor:pointer;padding:8px;display:flex;align-items:center;justify-content:center;width:32px;height:32px;border-radius:4px}.close-button:hover{background-color:rgba(0, 0, 0, 0.04)}.close-button span{font-size:24px;line-height:1;color:#999}.close-button:hover span{color:#666}.chat-history{position:relative;flex:1;overflow-y:auto;padding:20px;scroll-behavior:smooth;min-height:200px;background:url(https://pcm-resource-1312611446.cos.ap-guangzhou.myqcloud.com/web/sdk/chat_bg.png);background-size:100%}.fullscreen .chat-history{height:auto;flex:1 1 auto}.message-input{padding:16px;border-top:1px solid #eee;display:flex;gap:8px;align-items:center}.message-input input{flex:1;padding:8px 12px;border:1px solid #ddd;border-radius:4px;outline:none;transition:border-color 0.2s ease}.message-input input:focus{border-color:#bbb}.message{margin-bottom:16px;opacity:1;transition:opacity 0.3s ease}.message-content{max-width:70%;padding:8px 12px;border-radius:8px;word-break:break-word}.message-content p{margin:0;word-break:break-word}.user-message{display:flex;justify-content:flex-end}.agent-message{display:flex;justify-content:flex-start}.user-message .message-content{background-color:#007bff;color:white}.agent-message .message-content{background-color:#f1f1f1}.message-time{font-size:12px;color:#999;margin-top:4px;display:block}.send-button{background-color:#1890ff;color:white;border:none;border-radius:4px;padding:8px 16px;cursor:pointer;font-weight:500}.send-button:disabled{background-color:#ccc;cursor:not-allowed}.empty-state{display:flex;justify-content:center;align-items:center;height:100%;color:#999;text-align:center}.loading-container{position:absolute;top:0;left:0;right:0;bottom:0;display:flex;flex-direction:column;justify-content:center;align-items:center;background-color:rgba(255, 255, 255, 0.98);z-index:1;opacity:1;transition:opacity 0.3s ease}.loading-container p{margin-top:16px;color:#666;font-size:14px}.loading-spinner{width:40px;height:40px;border:3px solid #f3f3f3;border-top:3px solid #1890ff;border-radius:50%;animation:spin 1s linear infinite}@keyframes spin{0%{transform:rotate(0deg)}100%{transform:rotate(360deg)}}.messages-wrapper{width:100%;min-height:100%;display:flex;flex-direction:column;justify-content:flex-end}.messages-wrapper.has-overflow{justify-content:flex-start}.suggested-questions{display:flex;flex-direction:column;gap:8px;padding:16px}.suggested-question{display:flex;align-items:center;justify-content:space-between;padding:8px 12px;background-color:#f3f4f6;border-radius:4px;cursor:pointer;font-size:14px;color:#374151;transition:background-color 0.2s}.suggested-question:hover{background-color:#e5e7eb}.arrow-right{margin-left:8px}.loading-suggestions{display:flex;justify-content:center;padding:16px}.loading-spinner-small{width:20px;height:20px;border:2px solid #e5e7eb;border-top-color:#6b7280;border-radius:50%;animation:spin 1s linear infinite}.upload-button{background:transparent;border:none;cursor:pointer;padding:8px;display:flex;align-items:center;justify-content:center;color:#666;border-radius:4px;transition:background-color 0.2s}.upload-button:hover{background-color:rgba(0, 0, 0, 0.04)}.upload-button svg{width:20px;height:20px}.file-input{display:none}.selected-file{font-size:12px;color:#666;margin-left:8px;max-width:150px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.input-wrapper{flex:1;display:flex;align-items:center;border:1px solid #ddd;border-radius:4px;padding:0 4px;background:white}.input-wrapper input{border:none;flex:1;padding:8px;outline:none}.input-wrapper:focus-within{border-color:#bbb}.file-preview{padding:8px 16px;border-top:1px solid #eee;background-color:#f9f9f9}.file-info{display:flex;align-items:center;justify-content:space-between;padding:8px;background:white;border:1px solid #e8e8e8;border-radius:4px}.file-name{font-size:13px;color:#333;margin-right:8px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;max-width:calc(100% - 30px)}.remove-file{background:transparent;border:none;color:#999;cursor:pointer;padding:4px 8px;font-size:16px;line-height:1;border-radius:4px;transition:all 0.2s}.remove-file:hover{background-color:#f0f0f0;color:#666}.initial-upload{padding:1rem 1rem;display:flex;flex-direction:column;align-items:center;height:100%}.upload-section{max-width:600px;width:100%;text-align:center}.upload-area{border:2px dashed #ddd;border-radius:8px;padding:1rem;cursor:pointer;transition:all 0.3s ease}.upload-area:hover{border-color:#1890ff;background-color:rgba(24, 144, 255, 0.05)}.upload-placeholder{display:flex;flex-direction:column;align-items:center;color:#666}.upload-hint{font-size:0.8rem;color:#999;margin-top:0.5rem}.function-select{margin-top:2rem}.function-options{display:flex;flex-wrap:wrap;gap:1rem;justify-content:center;margin-top:1rem}.function-button{padding:0.5rem 1rem;border:1px solid #ddd;border-radius:4px;background:white;cursor:pointer;transition:all 0.3s ease}.function-button:hover{border-color:#1890ff;color:#1890ff}.function-button.selected{background:#1890ff;color:white;border-color:#1890ff}.submit-button{margin-top:1rem;padding:0.8rem 2rem;background:#1890ff;color:white;border:none;border-radius:4px;font-size:1rem;cursor:pointer;transition:all 0.3s ease;width:95%}.submit-button:disabled{background:#ccc;cursor:not-allowed}.submit-button:hover:not(:disabled){background:#40a9ff}.category-select,.dimension-select{margin:30px 0}.category-options,.dimension-options{display:flex;flex-wrap:wrap;gap:10px;margin-top:10px}.category-button,.dimension-button{padding:12px 16px;border:1px solid #E5E5E5;border-radius:6px;background:white;cursor:pointer;transition:all 0.3s}.category-button:hover,.dimension-button:hover{background:#f5f5f5}.category-button.selected{background-image:linear-gradient(111deg, #4A9FFF 0%, #1058FF 100%);color:white}.dimension-button.selected{background-image:linear-gradient(111deg, #4A9FFF 0%, #1058FF 100%);color:white}.recording-section{border-top:1px solid #eee;display:flex;flex-direction:column;align-items:center;padding:20px;border-radius:14px 14px 0 0;flex:0 0 auto}.recording-section .video-preview{width:100%;height:200px;max-width:400px;position:relative;margin-bottom:10px;border:1px solid #ddd;border-radius:12px;overflow:hidden}.recording-section video{width:100%;height:100%;object-fit:cover}.recording-status{position:absolute;top:10px;left:10px;background-color:rgba(0, 0, 0, 0.6);color:white;padding:4px 8px;border-radius:4px;display:flex;align-items:center;gap:5px;font-size:0.8rem;z-index:2}.recording-status .recording-dot{display:inline-block;width:10px;height:10px;background-color:red;border-radius:50%;margin-right:5px;animation:blink 1s infinite}.recording-status.warning{color:#ff4d4f;animation:blink 1s infinite}@keyframes blink{0%{opacity:1}50%{opacity:0.5}100%{opacity:1}}.recording-section .stop-recording-button{background-color:#f44336;color:white;border:none;cursor:pointer;font-weight:bold}.recording-section .stop-recording-button:hover{background-color:#d32f2f}.fullscreen{width:100vw;border-radius:0;height:100vh;display:flex;flex-direction:column;overflow-y:auto}.recording-controls{margin-top:10px;height:53px;width:100%;max-width:400px;display:flex;justify-content:center}.recording-controls .waiting-message{text-align:center;color:white;font-size:1rem;background-image:linear-gradient(100deg, #4A9FFF 0%, #1058FF 100%);border-radius:6px;box-shadow:0 2px 8px rgba(0, 0, 0, 0.15);width:95%;display:flex;justify-content:center;align-items:center;cursor:pointer}.recording-controls .waiting-message.loading{background:#faad14}.recording-controls .waiting-message p{margin:0;font-size:16px;color:white;font-weight:500}.recording-controls .stop-recording-button{background-color:#dc3545;color:white;border:none;cursor:pointer;font-size:1rem}.recording-controls .stop-recording-button:hover{background-color:#c82333}.recording-controls .stop-recording-button.disabled{background:#ccc;cursor:not-allowed}.recording-controls .stop-recording-button.disabled:hover{background:#ccc}.progress-container{display:flex;justify-content:space-between;align-items:center;width:100%;max-width:400px;margin-top:10px;padding:0 5px}.progress-bar-container{height:4px;background-color:#E5E5E5;border-radius:2px;overflow:hidden;margin-right:10px;width:75px}.progress-bar{height:100%;background-image:linear-gradient(111deg, #4A9FFF 0%, #1058FF 100%);border-radius:2px;transition:width 0.3s ease}.progress-text{font-size:14px;color:#666;white-space:nowrap}";
|
|
5
|
-
|
|
6
|
-
const ChatHRModal = class {
|
|
7
|
-
constructor(hostRef) {
|
|
8
|
-
registerInstance(this, hostRef);
|
|
9
|
-
this.modalClosed = createEvent(this, "modalClosed");
|
|
10
|
-
this.streamComplete = createEvent(this, "streamComplete");
|
|
11
|
-
this.interviewComplete = createEvent(this, "interviewComplete");
|
|
12
|
-
this.recordingError = createEvent(this, "recordingError");
|
|
13
|
-
this.recordingStatusChange = createEvent(this, "recordingStatusChange");
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* 模态框标题
|
|
17
|
-
*/
|
|
18
|
-
modalTitle = '在线客服';
|
|
19
|
-
/**
|
|
20
|
-
* API鉴权密钥
|
|
21
|
-
*/
|
|
22
|
-
apiKey = '';
|
|
23
|
-
/**
|
|
24
|
-
* 是否显示聊天模态框
|
|
25
|
-
*/
|
|
26
|
-
isOpen = false;
|
|
27
|
-
/**
|
|
28
|
-
* 聊天消息历史
|
|
29
|
-
*/
|
|
30
|
-
messages = [];
|
|
31
|
-
/**
|
|
32
|
-
* 当点击模态框关闭时触发
|
|
33
|
-
*/
|
|
34
|
-
modalClosed;
|
|
35
|
-
/**
|
|
36
|
-
* 应用图标URL
|
|
37
|
-
*/
|
|
38
|
-
icon;
|
|
39
|
-
/**
|
|
40
|
-
* 聊天框的页面层级
|
|
41
|
-
*/
|
|
42
|
-
zIndex = 1000;
|
|
43
|
-
/**
|
|
44
|
-
* 是否展示顶部标题栏
|
|
45
|
-
*/
|
|
46
|
-
isShowHeader = true;
|
|
47
|
-
/**
|
|
48
|
-
* 是否展示右上角的关闭按钮
|
|
49
|
-
*/
|
|
50
|
-
isNeedClose = true;
|
|
51
|
-
/**
|
|
52
|
-
* 会话ID
|
|
53
|
-
*/
|
|
54
|
-
conversationId;
|
|
55
|
-
/**
|
|
56
|
-
* 当前助手回复的消息
|
|
57
|
-
*/
|
|
58
|
-
currentAssistantMessage = '';
|
|
59
|
-
/**
|
|
60
|
-
* 是否正在加载回复
|
|
61
|
-
*/
|
|
62
|
-
isLoading = false;
|
|
63
|
-
/**
|
|
64
|
-
* 当前正在流式输出的消息
|
|
65
|
-
*/
|
|
66
|
-
currentStreamingMessage = null;
|
|
67
|
-
// 添加新的状态控制
|
|
68
|
-
shouldAutoScroll = true;
|
|
69
|
-
isLoadingHistory = false;
|
|
70
|
-
get hostElement() { return getElement(this); }
|
|
71
|
-
// 添加新的 Event
|
|
72
|
-
streamComplete;
|
|
73
|
-
selectedFile = null;
|
|
74
|
-
isUploading = false;
|
|
75
|
-
uploadedFileInfo = [];
|
|
76
|
-
/**
|
|
77
|
-
* 默认查询文本
|
|
78
|
-
*/
|
|
79
|
-
defaultQuery = '';
|
|
80
|
-
// 添加新的状态
|
|
81
|
-
showInitialUpload = true;
|
|
82
|
-
selectedJobCategory = '';
|
|
83
|
-
jobCategories = [
|
|
84
|
-
'人力资源学生(实习)',
|
|
85
|
-
'人力资源专员',
|
|
86
|
-
'人力资源主管',
|
|
87
|
-
'人力资源经理',
|
|
88
|
-
'人力资源总监'
|
|
89
|
-
];
|
|
90
|
-
dimensions = [
|
|
91
|
-
'人力资源规划',
|
|
92
|
-
'招聘与配置',
|
|
93
|
-
'员工关系',
|
|
94
|
-
'培训与开发',
|
|
95
|
-
'薪酬与绩效',
|
|
96
|
-
'组织与人才发展'
|
|
97
|
-
];
|
|
98
|
-
selectedDimensions = [];
|
|
99
|
-
// 添加视频录制相关状态
|
|
100
|
-
isRecording = false;
|
|
101
|
-
recordingStream = null;
|
|
102
|
-
recordedBlob = null;
|
|
103
|
-
mediaRecorder = null;
|
|
104
|
-
recordingTimeLeft = 0;
|
|
105
|
-
showRecordingUI = false;
|
|
106
|
-
recordingTimer = null;
|
|
107
|
-
recordingStartTime = 0;
|
|
108
|
-
recordingMaxTime = 120; // 最大录制时间(秒)
|
|
109
|
-
waitingToRecord = false;
|
|
110
|
-
waitingTimer = null;
|
|
111
|
-
waitingTimeLeft = 10; // 等待时间(秒)
|
|
112
|
-
// 添加一个新的私有属性来存储视频元素的引用
|
|
113
|
-
videoRef = null;
|
|
114
|
-
/**
|
|
115
|
-
* 总题目数量
|
|
116
|
-
*/
|
|
117
|
-
totalQuestions = 2;
|
|
118
|
-
/**
|
|
119
|
-
* 当前题目序号
|
|
120
|
-
*/
|
|
121
|
-
currentQuestionNumber = 0;
|
|
122
|
-
/**
|
|
123
|
-
* 面试是否已完成
|
|
124
|
-
*/
|
|
125
|
-
isInterviewComplete = false;
|
|
126
|
-
/**
|
|
127
|
-
* 当面试完成时触发
|
|
128
|
-
*/
|
|
129
|
-
interviewComplete;
|
|
130
|
-
SCROLL_THRESHOLD = 30;
|
|
131
|
-
/**
|
|
132
|
-
* 视频录制最大时长(秒)
|
|
133
|
-
*/
|
|
134
|
-
maxRecordingTime = 120;
|
|
135
|
-
/**
|
|
136
|
-
* 录制倒计时提醒时间(秒)
|
|
137
|
-
* 当剩余时间小于此值时,显示倒计时警告
|
|
138
|
-
*/
|
|
139
|
-
countdownWarningTime = 30;
|
|
140
|
-
showCountdownWarning = false;
|
|
141
|
-
/**
|
|
142
|
-
* 接收报告的邮箱地址
|
|
143
|
-
*/
|
|
144
|
-
toEmail = '';
|
|
145
|
-
/**
|
|
146
|
-
* 是否以全屏模式打开
|
|
147
|
-
*/
|
|
148
|
-
fullscreen = false;
|
|
149
|
-
// 添加新的状态来跟踪视频上传
|
|
150
|
-
isUploadingVideo = false;
|
|
151
|
-
/**
|
|
152
|
-
* 是否需要上传简历
|
|
153
|
-
*/
|
|
154
|
-
requireResume = false;
|
|
155
|
-
// 添加新的状态和属性
|
|
156
|
-
isPlayingAudio = false;
|
|
157
|
-
audioUrl = null;
|
|
158
|
-
audioElement = null;
|
|
159
|
-
/**
|
|
160
|
-
* 录制错误事件
|
|
161
|
-
*/
|
|
162
|
-
recordingError;
|
|
163
|
-
/**
|
|
164
|
-
* 录制状态变化事件
|
|
165
|
-
*/
|
|
166
|
-
recordingStatusChange;
|
|
167
|
-
/**
|
|
168
|
-
* 是否播放语音问题
|
|
169
|
-
*/
|
|
170
|
-
enableVoice = true;
|
|
171
|
-
/**
|
|
172
|
-
* 是否显示题干内容
|
|
173
|
-
* 1: 显示题干内容
|
|
174
|
-
* 0: 不显示题干内容
|
|
175
|
-
*/
|
|
176
|
-
displayContentStatus = "1";
|
|
177
|
-
/**
|
|
178
|
-
* 用户ID
|
|
179
|
-
*/
|
|
180
|
-
userId = '';
|
|
181
|
-
handleClose = () => {
|
|
182
|
-
this.stopRecording();
|
|
183
|
-
this.modalClosed.emit();
|
|
184
|
-
};
|
|
185
|
-
handleFileChange = async (event) => {
|
|
186
|
-
const input = event.target;
|
|
187
|
-
if (input.files && input.files.length > 0) {
|
|
188
|
-
this.selectedFile = input.files[0];
|
|
189
|
-
}
|
|
190
|
-
};
|
|
191
|
-
async uploadFile() {
|
|
192
|
-
if (!this.selectedFile || this.uploadedFileInfo.length > 0)
|
|
193
|
-
return;
|
|
194
|
-
this.isUploading = true;
|
|
195
|
-
try {
|
|
196
|
-
const formData = new FormData();
|
|
197
|
-
formData.append('file', this.selectedFile);
|
|
198
|
-
const response = await fetch('https://pcm_api.ylzhaopin.com/external/v1/files/upload', {
|
|
199
|
-
method: 'POST',
|
|
200
|
-
headers: {
|
|
201
|
-
'authorization': 'Bearer ' + this.apiKey
|
|
202
|
-
},
|
|
203
|
-
body: formData
|
|
204
|
-
});
|
|
205
|
-
const result = await response.json();
|
|
206
|
-
if (!response.ok) {
|
|
207
|
-
throw new Error(result.message || '文件上传失败');
|
|
208
|
-
}
|
|
209
|
-
if (result) {
|
|
210
|
-
this.uploadedFileInfo = [{
|
|
211
|
-
cos_key: result.cos_key,
|
|
212
|
-
filename: result.filename,
|
|
213
|
-
ext: result.ext,
|
|
214
|
-
presigned_url: result.presigned_url
|
|
215
|
-
}];
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
catch (error) {
|
|
219
|
-
console.error('文件上传错误:', error);
|
|
220
|
-
this.clearSelectedFile();
|
|
221
|
-
alert(error instanceof Error ? error.message : '文件上传失败,请重试');
|
|
222
|
-
}
|
|
223
|
-
finally {
|
|
224
|
-
this.isUploading = false;
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
handleUploadClick = () => {
|
|
228
|
-
const fileInput = this.hostElement.shadowRoot?.querySelector('.file-input');
|
|
229
|
-
fileInput?.click();
|
|
230
|
-
};
|
|
231
|
-
clearSelectedFile = () => {
|
|
232
|
-
this.selectedFile = null;
|
|
233
|
-
this.uploadedFileInfo = [];
|
|
234
|
-
const fileInput = this.hostElement.shadowRoot?.querySelector('.file-input');
|
|
235
|
-
if (fileInput) {
|
|
236
|
-
fileInput.value = '';
|
|
237
|
-
}
|
|
238
|
-
};
|
|
239
|
-
async sendMessageToAPI(message) {
|
|
240
|
-
this.isLoading = true;
|
|
241
|
-
let answer = '';
|
|
242
|
-
let llmText = ''; // 添加变量存储 LLMText
|
|
243
|
-
const now = new Date();
|
|
244
|
-
const time = `${now.getHours()}:${now.getMinutes().toString().padStart(2, '0')}`;
|
|
245
|
-
// 如果消息为空但有文件,使用默认文本
|
|
246
|
-
const queryText = message.trim() || (this.uploadedFileInfo.length > 0 ? '请分析这个文件' : '');
|
|
247
|
-
// 获取上一条AI消息的回答内容
|
|
248
|
-
const lastAIMessage = this.messages.length > 0 ? this.messages[this.messages.length - 1] : null;
|
|
249
|
-
// 保存AI提问和用户回答
|
|
250
|
-
if (lastAIMessage && this.conversationId && message !== "下一题") {
|
|
251
|
-
this.saveAnswer(this.conversationId, lastAIMessage.answer, // AI的提问作为question
|
|
252
|
-
queryText // 用户的输入作为answer
|
|
253
|
-
);
|
|
254
|
-
}
|
|
255
|
-
// 检查是否是最后一题的"下一题"请求
|
|
256
|
-
const isLastQuestion = (this.currentQuestionNumber >= this.totalQuestions) && message === "下一题";
|
|
257
|
-
// 创建新的消息对象
|
|
258
|
-
const newMessage = {
|
|
259
|
-
id: `temp-${Date.now()}`, // 消息唯一标识
|
|
260
|
-
time: time, // 消息时间
|
|
261
|
-
query: queryText, // 用户输入的消息内容
|
|
262
|
-
answer: '',
|
|
263
|
-
isStreaming: true, // 是否正在流式输出
|
|
264
|
-
conversation_id: this.conversationId, // 会话ID
|
|
265
|
-
inputs: {}, // 输入参数
|
|
266
|
-
status: "normal", // 消息状态
|
|
267
|
-
error: null // 错误信息
|
|
268
|
-
};
|
|
269
|
-
// 设置当前流式消息
|
|
270
|
-
this.currentStreamingMessage = newMessage;
|
|
271
|
-
this.shouldAutoScroll = true;
|
|
272
|
-
// 滚动到底部
|
|
273
|
-
this.scrollToBottom();
|
|
274
|
-
// 如果是最后一题,直接显示结束消息并完成面试
|
|
275
|
-
if (isLastQuestion) {
|
|
276
|
-
this.messages = [...this.messages, newMessage];
|
|
277
|
-
this.currentStreamingMessage = null;
|
|
278
|
-
this.isLoading = false;
|
|
279
|
-
this.isInterviewComplete = true;
|
|
280
|
-
await this.completeInterview();
|
|
281
|
-
this.interviewComplete.emit({
|
|
282
|
-
conversation_id: this.conversationId,
|
|
283
|
-
total_questions: this.totalQuestions
|
|
284
|
-
});
|
|
285
|
-
return;
|
|
286
|
-
}
|
|
287
|
-
// 准备请求数据
|
|
288
|
-
const requestData = {
|
|
289
|
-
response_mode: 'streaming',
|
|
290
|
-
conversation_id: this.conversationId,
|
|
291
|
-
query: queryText,
|
|
292
|
-
user: this.userId // 使用传入的 userId
|
|
293
|
-
};
|
|
294
|
-
requestData.inputs = {
|
|
295
|
-
job_info: this.selectedJobCategory,
|
|
296
|
-
dimensional_info: this.selectedDimensions.join(','),
|
|
297
|
-
email: this.toEmail,
|
|
298
|
-
display_content_status: this.displayContentStatus
|
|
299
|
-
};
|
|
300
|
-
// 如果有上传的文件,添加到inputs参数
|
|
301
|
-
if (this.uploadedFileInfo.length > 0) {
|
|
302
|
-
const fileUrls = this.uploadedFileInfo.map(fileInfo => fileInfo.cos_key).join(',');
|
|
303
|
-
requestData.inputs.file_urls = fileUrls;
|
|
304
|
-
}
|
|
305
|
-
await sendSSERequest({
|
|
306
|
-
url: `https://pcm_api.ylzhaopin.com/external/v1/chat/chat-messages`,
|
|
307
|
-
method: 'POST',
|
|
308
|
-
headers: {
|
|
309
|
-
'authorization': 'Bearer ' + this.apiKey
|
|
310
|
-
},
|
|
311
|
-
data: requestData,
|
|
312
|
-
onMessage: (data) => {
|
|
313
|
-
console.log('收到Stream数据:', data);
|
|
314
|
-
if (data.conversation_id && !this.conversationId) {
|
|
315
|
-
this.conversationId = data.conversation_id;
|
|
316
|
-
this.updateUrlWithConversationId(data.conversation_id);
|
|
317
|
-
}
|
|
318
|
-
// 检查是否有 node_finished 事件和 LLMText
|
|
319
|
-
if (data.event === 'node_finished' && data.data.inputs && data.data.inputs.LLMText) {
|
|
320
|
-
llmText = data.data.inputs.LLMText;
|
|
321
|
-
console.log('获取到 LLMText:', llmText);
|
|
322
|
-
}
|
|
323
|
-
if (data.event === 'message') {
|
|
324
|
-
if (data.event === 'agent_message' || data.event === 'message') {
|
|
325
|
-
if (data.answer) {
|
|
326
|
-
answer += data.answer;
|
|
327
|
-
const updatedMessage = {
|
|
328
|
-
...this.currentStreamingMessage,
|
|
329
|
-
answer,
|
|
330
|
-
isStreaming: true
|
|
331
|
-
};
|
|
332
|
-
this.currentStreamingMessage = updatedMessage;
|
|
333
|
-
this.scrollToBottom();
|
|
334
|
-
}
|
|
335
|
-
}
|
|
336
|
-
}
|
|
337
|
-
if (data.event === "message_end") {
|
|
338
|
-
this.streamComplete.emit({
|
|
339
|
-
conversation_id: data.conversation_id || '',
|
|
340
|
-
event: data.event,
|
|
341
|
-
message_id: data.message_id,
|
|
342
|
-
id: data.id,
|
|
343
|
-
});
|
|
344
|
-
}
|
|
345
|
-
},
|
|
346
|
-
onError: (error) => {
|
|
347
|
-
console.error('发生错误:', error);
|
|
348
|
-
alert(error instanceof Error ? error.message : '消息发送失败,请稍后再试');
|
|
349
|
-
this.messages = [...this.messages, {
|
|
350
|
-
...newMessage,
|
|
351
|
-
answer: '抱歉,发生了错误,请稍后再试。',
|
|
352
|
-
error: error,
|
|
353
|
-
isStreaming: false
|
|
354
|
-
}];
|
|
355
|
-
this.currentStreamingMessage = null;
|
|
356
|
-
this.isLoading = false;
|
|
357
|
-
},
|
|
358
|
-
onComplete: async () => {
|
|
359
|
-
console.log('请求完成');
|
|
360
|
-
this.isLoading = false;
|
|
361
|
-
// 获取最新的AI回复内容
|
|
362
|
-
const latestAIMessage = this.currentStreamingMessage;
|
|
363
|
-
// 更新消息列表
|
|
364
|
-
this.messages = [...this.messages, this.currentStreamingMessage];
|
|
365
|
-
this.currentStreamingMessage = null;
|
|
366
|
-
// 如果是初始消息或"下一题"消息,增加题目计数
|
|
367
|
-
if (message === "下一题" || this.currentQuestionNumber === 0) {
|
|
368
|
-
this.currentQuestionNumber++;
|
|
369
|
-
}
|
|
370
|
-
console.log(this.currentQuestionNumber);
|
|
371
|
-
console.log(message);
|
|
372
|
-
if (latestAIMessage && latestAIMessage.answer) {
|
|
373
|
-
// 优先使用 LLMText,如果没有则使用 answer
|
|
374
|
-
const textForSynthesis = llmText || latestAIMessage.answer;
|
|
375
|
-
if (textForSynthesis) {
|
|
376
|
-
// 合成语音
|
|
377
|
-
const audioUrl = await this.synthesizeAudio(textForSynthesis);
|
|
378
|
-
if (this.enableVoice) {
|
|
379
|
-
// 自动播放语音
|
|
380
|
-
await this.playAudio(audioUrl);
|
|
381
|
-
// 自动播放模式下,播放完成后立即开始等待录制
|
|
382
|
-
this.startWaitingToRecord();
|
|
383
|
-
}
|
|
384
|
-
else {
|
|
385
|
-
// 只保存音频URL,不自动播放
|
|
386
|
-
this.audioUrl = audioUrl;
|
|
387
|
-
// 非自动播放模式下,不立即开始等待录制
|
|
388
|
-
}
|
|
389
|
-
}
|
|
390
|
-
}
|
|
391
|
-
}
|
|
392
|
-
});
|
|
393
|
-
}
|
|
394
|
-
// 添加保存答案的方法
|
|
395
|
-
async saveAnswer(conversationId, question, answer) {
|
|
396
|
-
try {
|
|
397
|
-
await sendHttpRequest({
|
|
398
|
-
url: 'https://pcm_api.ylzhaopin.com/agents/hr_competition/answer',
|
|
399
|
-
method: 'POST',
|
|
400
|
-
headers: {
|
|
401
|
-
'authorization': 'Bearer ' + this.apiKey
|
|
402
|
-
},
|
|
403
|
-
data: {
|
|
404
|
-
conversation_id: conversationId,
|
|
405
|
-
user: this.userId, // 使用传入的 userId
|
|
406
|
-
question: question,
|
|
407
|
-
answer: answer
|
|
408
|
-
},
|
|
409
|
-
});
|
|
410
|
-
}
|
|
411
|
-
catch (error) {
|
|
412
|
-
console.error('保存答案失败:', error);
|
|
413
|
-
}
|
|
414
|
-
}
|
|
415
|
-
// 监听滚动事件,用于控制聊天历史记录的自动滚动行为。
|
|
416
|
-
handleScroll = () => {
|
|
417
|
-
const chatHistory = this.hostElement.shadowRoot?.querySelector('.chat-history');
|
|
418
|
-
if (!chatHistory)
|
|
419
|
-
return;
|
|
420
|
-
const { scrollTop, scrollHeight, clientHeight } = chatHistory;
|
|
421
|
-
const distanceFromBottom = scrollHeight - scrollTop - clientHeight;
|
|
422
|
-
// 更新是否应该自动滚动的状态
|
|
423
|
-
this.shouldAutoScroll = distanceFromBottom <= this.SCROLL_THRESHOLD;
|
|
424
|
-
};
|
|
425
|
-
scrollToBottom() {
|
|
426
|
-
if (!this.shouldAutoScroll)
|
|
427
|
-
return;
|
|
428
|
-
const chatHistory = this.hostElement.shadowRoot?.querySelector('.chat-history');
|
|
429
|
-
if (chatHistory && this.isOpen) {
|
|
430
|
-
// 强制浏览器重新计算布局
|
|
431
|
-
chatHistory.scrollTop = chatHistory.scrollHeight;
|
|
432
|
-
}
|
|
433
|
-
}
|
|
434
|
-
// 添加 componentDidRender 生命周期方法,用于在组件渲染后滚动到底部
|
|
435
|
-
componentDidRender() {
|
|
436
|
-
if (this.isLoadingHistory || (this.shouldAutoScroll && this.isOpen)) {
|
|
437
|
-
const chatHistory = this.hostElement.shadowRoot?.querySelector('.chat-history');
|
|
438
|
-
if (chatHistory) {
|
|
439
|
-
chatHistory.scrollTop = chatHistory.scrollHeight;
|
|
440
|
-
}
|
|
441
|
-
}
|
|
442
|
-
}
|
|
443
|
-
updateUrlWithConversationId(conversationId) {
|
|
444
|
-
const urlParams = new URLSearchParams(window.location.search);
|
|
445
|
-
if (!urlParams.get('conversation_id')) {
|
|
446
|
-
const newUrl = new URL(window.location.href);
|
|
447
|
-
newUrl.searchParams.set('conversation_id', conversationId);
|
|
448
|
-
window.history.replaceState({}, '', newUrl);
|
|
449
|
-
}
|
|
450
|
-
}
|
|
451
|
-
// 修改 loadHistoryMessages 方法
|
|
452
|
-
async loadHistoryMessages() {
|
|
453
|
-
if (!this.conversationId)
|
|
454
|
-
return;
|
|
455
|
-
this.isLoadingHistory = true;
|
|
456
|
-
console.log('加载历史消息...');
|
|
457
|
-
try {
|
|
458
|
-
await sendHttpRequest({
|
|
459
|
-
url: `https://pcm_api.ylzhaopin.com/external/v1/chat/messages`,
|
|
460
|
-
method: 'GET',
|
|
461
|
-
headers: {
|
|
462
|
-
'authorization': 'Bearer ' + this.apiKey
|
|
463
|
-
},
|
|
464
|
-
data: {
|
|
465
|
-
conversation_id: this.conversationId,
|
|
466
|
-
limit: 20
|
|
467
|
-
},
|
|
468
|
-
onMessage: (data) => {
|
|
469
|
-
if (data.data) {
|
|
470
|
-
const historyData = data.data || [];
|
|
471
|
-
const formattedMessages = historyData.map(msg => {
|
|
472
|
-
const time = new Date(msg.created_at * 1000);
|
|
473
|
-
const hours = time.getHours().toString().padStart(2, '0');
|
|
474
|
-
const minutes = time.getMinutes().toString().padStart(2, '0');
|
|
475
|
-
const timeStr = `${hours}:${minutes}`;
|
|
476
|
-
// 创建新的消息对象,不包含 inputs 字段
|
|
477
|
-
const { inputs, ...msgWithoutInputs } = msg;
|
|
478
|
-
return {
|
|
479
|
-
...msgWithoutInputs,
|
|
480
|
-
time: timeStr,
|
|
481
|
-
isStreaming: false,
|
|
482
|
-
status: msg.status === 'error' ? 'error' : 'normal'
|
|
483
|
-
};
|
|
484
|
-
});
|
|
485
|
-
this.messages = formattedMessages;
|
|
486
|
-
this.isLoadingHistory = false;
|
|
487
|
-
requestAnimationFrame(() => {
|
|
488
|
-
this.shouldAutoScroll = true;
|
|
489
|
-
this.scrollToBottom();
|
|
490
|
-
});
|
|
491
|
-
}
|
|
492
|
-
else {
|
|
493
|
-
this.isLoadingHistory = false;
|
|
494
|
-
}
|
|
495
|
-
},
|
|
496
|
-
onError: (error) => {
|
|
497
|
-
console.error('加载历史消息失败:', error);
|
|
498
|
-
alert(error instanceof Error ? error.message : '加载历史消息失败,请刷新重试');
|
|
499
|
-
this.isLoadingHistory = false;
|
|
500
|
-
},
|
|
501
|
-
onComplete: () => {
|
|
502
|
-
this.isLoadingHistory = false;
|
|
503
|
-
}
|
|
504
|
-
});
|
|
505
|
-
}
|
|
506
|
-
catch (error) {
|
|
507
|
-
console.error('加载历史消息失败:', error);
|
|
508
|
-
alert(error instanceof Error ? error.message : '加载历史消息失败,请刷新重试');
|
|
509
|
-
this.isLoadingHistory = false;
|
|
510
|
-
}
|
|
511
|
-
}
|
|
512
|
-
// 修改 isOpen 的 watch 方法
|
|
513
|
-
async handleIsOpenChange(newValue) {
|
|
514
|
-
if (newValue) {
|
|
515
|
-
if (this.conversationId) {
|
|
516
|
-
await this.loadHistoryMessages();
|
|
517
|
-
}
|
|
518
|
-
}
|
|
519
|
-
}
|
|
520
|
-
handleJobCategorySelect = (category) => {
|
|
521
|
-
this.selectedJobCategory = category;
|
|
522
|
-
};
|
|
523
|
-
handleDimensionSelect = (dimension) => {
|
|
524
|
-
if (this.selectedDimensions.includes(dimension)) {
|
|
525
|
-
this.selectedDimensions = this.selectedDimensions.filter(d => d !== dimension);
|
|
526
|
-
}
|
|
527
|
-
else {
|
|
528
|
-
this.selectedDimensions = [...this.selectedDimensions, dimension];
|
|
529
|
-
}
|
|
530
|
-
};
|
|
531
|
-
handleInitialSubmit = async () => {
|
|
532
|
-
// 修改验证逻辑
|
|
533
|
-
if (this.requireResume && !this.selectedFile) {
|
|
534
|
-
alert('请上传简历');
|
|
535
|
-
return;
|
|
536
|
-
}
|
|
537
|
-
if (!this.selectedJobCategory) {
|
|
538
|
-
alert('请选择职能类别');
|
|
539
|
-
return;
|
|
540
|
-
}
|
|
541
|
-
if (this.selectedDimensions.length === 0) {
|
|
542
|
-
alert('请至少选择一个关注模块');
|
|
543
|
-
return;
|
|
544
|
-
}
|
|
545
|
-
// 不再显示欢迎确认对话框,因为已经在组件打开时显示了
|
|
546
|
-
// 直接询问用户是否准备好开始面试
|
|
547
|
-
const confirmed = confirm('如果您已做好准备请点击"确定"开始面试。');
|
|
548
|
-
if (!confirmed) {
|
|
549
|
-
return;
|
|
550
|
-
}
|
|
551
|
-
// 修改文件上传逻辑
|
|
552
|
-
if (this.requireResume) {
|
|
553
|
-
await this.uploadFile();
|
|
554
|
-
if (this.uploadedFileInfo.length === 0) {
|
|
555
|
-
return;
|
|
556
|
-
}
|
|
557
|
-
}
|
|
558
|
-
this.showInitialUpload = false;
|
|
559
|
-
const message = `我是一名${this.selectedJobCategory},请您开始提问`;
|
|
560
|
-
this.sendMessageToAPI(message);
|
|
561
|
-
};
|
|
562
|
-
// 开始等待录制
|
|
563
|
-
startWaitingToRecord() {
|
|
564
|
-
// 清除可能存在的计时器
|
|
565
|
-
if (this.waitingTimer) {
|
|
566
|
-
clearInterval(this.waitingTimer);
|
|
567
|
-
}
|
|
568
|
-
if (this.recordingTimer) {
|
|
569
|
-
clearInterval(this.recordingTimer);
|
|
570
|
-
}
|
|
571
|
-
this.waitingToRecord = true;
|
|
572
|
-
this.waitingTimeLeft = 10;
|
|
573
|
-
this.waitingTimer = setInterval(() => {
|
|
574
|
-
this.waitingTimeLeft--;
|
|
575
|
-
if (this.waitingTimeLeft <= 0) {
|
|
576
|
-
clearInterval(this.waitingTimer);
|
|
577
|
-
this.waitingTimer = null;
|
|
578
|
-
this.waitingToRecord = false;
|
|
579
|
-
this.startRecording();
|
|
580
|
-
}
|
|
581
|
-
}, 1000);
|
|
582
|
-
}
|
|
583
|
-
// 开始录制视频
|
|
584
|
-
async startRecording() {
|
|
585
|
-
try {
|
|
586
|
-
const stream = await navigator.mediaDevices.getUserMedia({
|
|
587
|
-
audio: true,
|
|
588
|
-
video: {
|
|
589
|
-
width: { ideal: 1280 },
|
|
590
|
-
height: { ideal: 720 },
|
|
591
|
-
frameRate: { ideal: 30 }
|
|
592
|
-
}
|
|
593
|
-
});
|
|
594
|
-
this.recordingStream = stream;
|
|
595
|
-
this.showRecordingUI = true;
|
|
596
|
-
this.showCountdownWarning = false;
|
|
597
|
-
// 重置视频引用
|
|
598
|
-
this.videoRef = null;
|
|
599
|
-
// 确保视频元素获取到流
|
|
600
|
-
this.setupVideoPreview(stream);
|
|
601
|
-
// 检测浏览器支持的MIME类型
|
|
602
|
-
const mimeType = this.getSupportedMimeType();
|
|
603
|
-
// 创建MediaRecorder实例
|
|
604
|
-
let mediaRecorder;
|
|
605
|
-
try {
|
|
606
|
-
mediaRecorder = new MediaRecorder(stream, {
|
|
607
|
-
mimeType: mimeType
|
|
608
|
-
});
|
|
609
|
-
}
|
|
610
|
-
catch (e) {
|
|
611
|
-
// 如果指定MIME类型失败,尝试使用默认设置
|
|
612
|
-
console.warn('指定的MIME类型不受支持,使用默认设置:', e);
|
|
613
|
-
try {
|
|
614
|
-
mediaRecorder = new MediaRecorder(stream);
|
|
615
|
-
}
|
|
616
|
-
catch (recorderError) {
|
|
617
|
-
// 通知父组件录制器创建失败
|
|
618
|
-
this.recordingError.emit({
|
|
619
|
-
type: 'recorder_creation_failed',
|
|
620
|
-
message: '无法创建媒体录制器,您的浏览器可能不支持此功能',
|
|
621
|
-
details: recorderError
|
|
622
|
-
});
|
|
623
|
-
this.showRecordingUI = false;
|
|
624
|
-
return;
|
|
625
|
-
}
|
|
626
|
-
}
|
|
627
|
-
this.mediaRecorder = mediaRecorder;
|
|
628
|
-
const chunks = [];
|
|
629
|
-
mediaRecorder.ondataavailable = (event) => {
|
|
630
|
-
if (event.data.size > 0) {
|
|
631
|
-
chunks.push(event.data);
|
|
632
|
-
}
|
|
633
|
-
};
|
|
634
|
-
mediaRecorder.onerror = (event) => {
|
|
635
|
-
// 通知父组件录制过程中发生错误
|
|
636
|
-
this.recordingError.emit({
|
|
637
|
-
type: 'recording_error',
|
|
638
|
-
message: '录制过程中发生错误',
|
|
639
|
-
details: event
|
|
640
|
-
});
|
|
641
|
-
this.stopRecording();
|
|
642
|
-
};
|
|
643
|
-
mediaRecorder.onstop = () => {
|
|
644
|
-
try {
|
|
645
|
-
// 根据实际使用的MIME类型创建Blob
|
|
646
|
-
const blobType = mimeType || 'video/mp4';
|
|
647
|
-
const blob = new Blob(chunks, { type: blobType });
|
|
648
|
-
if (blob.size === 0) {
|
|
649
|
-
// 通知父组件录制的视频为空
|
|
650
|
-
this.recordingError.emit({
|
|
651
|
-
type: 'empty_recording',
|
|
652
|
-
message: '录制的视频为空'
|
|
653
|
-
});
|
|
654
|
-
this.showRecordingUI = false;
|
|
655
|
-
return;
|
|
656
|
-
}
|
|
657
|
-
this.recordedBlob = blob;
|
|
658
|
-
// 通知父组件录制已完成
|
|
659
|
-
this.recordingStatusChange.emit({
|
|
660
|
-
status: 'stopped',
|
|
661
|
-
details: {
|
|
662
|
-
duration: Math.floor((Date.now() - this.recordingStartTime) / 1000),
|
|
663
|
-
size: blob.size,
|
|
664
|
-
type: blob.type
|
|
665
|
-
}
|
|
666
|
-
});
|
|
667
|
-
this.uploadRecordedVideo();
|
|
668
|
-
}
|
|
669
|
-
catch (error) {
|
|
670
|
-
// 通知父组件处理录制视频时出错
|
|
671
|
-
this.recordingError.emit({
|
|
672
|
-
type: 'processing_error',
|
|
673
|
-
message: '处理录制视频时出错',
|
|
674
|
-
details: error
|
|
675
|
-
});
|
|
676
|
-
this.showRecordingUI = false;
|
|
677
|
-
}
|
|
678
|
-
};
|
|
679
|
-
// 开始录制
|
|
680
|
-
try {
|
|
681
|
-
mediaRecorder.start();
|
|
682
|
-
this.isRecording = true;
|
|
683
|
-
this.recordingStartTime = Date.now();
|
|
684
|
-
this.recordingTimeLeft = this.maxRecordingTime;
|
|
685
|
-
// 通知父组件录制已开始
|
|
686
|
-
this.recordingStatusChange.emit({
|
|
687
|
-
status: 'started',
|
|
688
|
-
details: {
|
|
689
|
-
maxDuration: this.maxRecordingTime,
|
|
690
|
-
mimeType: mediaRecorder.mimeType
|
|
691
|
-
}
|
|
692
|
-
});
|
|
693
|
-
}
|
|
694
|
-
catch (startError) {
|
|
695
|
-
// 通知父组件开始录制失败
|
|
696
|
-
this.recordingError.emit({
|
|
697
|
-
type: 'start_failed',
|
|
698
|
-
message: '开始录制失败,请检查您的设备权限',
|
|
699
|
-
details: startError
|
|
700
|
-
});
|
|
701
|
-
this.showRecordingUI = false;
|
|
702
|
-
return;
|
|
703
|
-
}
|
|
704
|
-
// 设置录制计时器
|
|
705
|
-
this.recordingTimer = setInterval(() => {
|
|
706
|
-
const elapsedTime = Math.floor((Date.now() - this.recordingStartTime) / 1000);
|
|
707
|
-
this.recordingTimeLeft = Math.max(0, this.maxRecordingTime - elapsedTime);
|
|
708
|
-
// 检查是否需要显示倒计时警告
|
|
709
|
-
if (this.recordingTimeLeft <= this.countdownWarningTime && !this.showCountdownWarning) {
|
|
710
|
-
this.showCountdownWarning = true;
|
|
711
|
-
}
|
|
712
|
-
// 时间到自动停止录制
|
|
713
|
-
if (this.recordingTimeLeft <= 0) {
|
|
714
|
-
this.stopRecording();
|
|
715
|
-
}
|
|
716
|
-
}, 1000);
|
|
717
|
-
}
|
|
718
|
-
catch (error) {
|
|
719
|
-
console.error('无法访问摄像头或麦克风:', error);
|
|
720
|
-
// 通知父组件无法访问媒体设备
|
|
721
|
-
this.recordingError.emit({
|
|
722
|
-
type: 'media_access_failed',
|
|
723
|
-
message: '无法访问摄像头或麦克风,请确保已授予权限',
|
|
724
|
-
details: error
|
|
725
|
-
});
|
|
726
|
-
this.showRecordingUI = false;
|
|
727
|
-
}
|
|
728
|
-
}
|
|
729
|
-
// 添加新方法来设置视频预览
|
|
730
|
-
setupVideoPreview(stream) {
|
|
731
|
-
// 延迟执行以确保DOM已更新
|
|
732
|
-
setTimeout(() => {
|
|
733
|
-
const videoElement = this.hostElement.shadowRoot?.querySelector('video');
|
|
734
|
-
if (videoElement && stream) {
|
|
735
|
-
// 先尝试使用标准方法
|
|
736
|
-
try {
|
|
737
|
-
videoElement.srcObject = stream;
|
|
738
|
-
videoElement.play().catch(err => {
|
|
739
|
-
console.error('视频播放失败:', err);
|
|
740
|
-
});
|
|
741
|
-
}
|
|
742
|
-
catch (e) {
|
|
743
|
-
console.warn('设置srcObject失败,尝试替代方法:', e);
|
|
744
|
-
// 对于不支持srcObject的旧浏览器,使用URL.createObjectURL
|
|
745
|
-
try {
|
|
746
|
-
// 使用类型断言解决TypeScript错误
|
|
747
|
-
const objectUrl = URL.createObjectURL(stream);
|
|
748
|
-
videoElement.src = objectUrl;
|
|
749
|
-
// 确保在视频元素不再使用时释放URL
|
|
750
|
-
videoElement.onended = () => {
|
|
751
|
-
URL.revokeObjectURL(objectUrl);
|
|
752
|
-
};
|
|
753
|
-
}
|
|
754
|
-
catch (urlError) {
|
|
755
|
-
console.error('创建对象URL失败:', urlError);
|
|
756
|
-
}
|
|
757
|
-
}
|
|
758
|
-
}
|
|
759
|
-
else {
|
|
760
|
-
console.warn('未找到视频元素或媒体流无效');
|
|
761
|
-
}
|
|
762
|
-
}, 100);
|
|
763
|
-
}
|
|
764
|
-
// 添加一个新方法来检测浏览器支持的MIME类型
|
|
765
|
-
getSupportedMimeType() {
|
|
766
|
-
// 按优先级排列的MIME类型列表
|
|
767
|
-
const mimeTypes = [
|
|
768
|
-
'video/webm;codecs=vp8,opus',
|
|
769
|
-
'video/webm;codecs=vp9,opus',
|
|
770
|
-
'video/webm',
|
|
771
|
-
'video/mp4',
|
|
772
|
-
'video/mp4;codecs=h264,aac',
|
|
773
|
-
'' // 空字符串表示使用浏览器默认值
|
|
774
|
-
];
|
|
775
|
-
// 检查MediaRecorder是否可用
|
|
776
|
-
if (!window.MediaRecorder) {
|
|
777
|
-
console.warn('MediaRecorder API不可用');
|
|
778
|
-
return '';
|
|
779
|
-
}
|
|
780
|
-
// 检查每种MIME类型是否受支持
|
|
781
|
-
for (const type of mimeTypes) {
|
|
782
|
-
if (!type)
|
|
783
|
-
return ''; // 如果是空字符串,直接返回
|
|
784
|
-
try {
|
|
785
|
-
if (MediaRecorder.isTypeSupported(type)) {
|
|
786
|
-
console.log('使用支持的MIME类型:', type);
|
|
787
|
-
return type;
|
|
788
|
-
}
|
|
789
|
-
}
|
|
790
|
-
catch (e) {
|
|
791
|
-
console.warn(`检查MIME类型支持时出错 ${type}:`, e);
|
|
792
|
-
}
|
|
793
|
-
}
|
|
794
|
-
// 如果没有找到支持的类型,返回空字符串
|
|
795
|
-
console.warn('没有找到支持的MIME类型,将使用浏览器默认值');
|
|
796
|
-
return '';
|
|
797
|
-
}
|
|
798
|
-
// 停止录制
|
|
799
|
-
stopRecording() {
|
|
800
|
-
if (this.mediaRecorder && this.isRecording) {
|
|
801
|
-
this.mediaRecorder.stop();
|
|
802
|
-
this.isRecording = false;
|
|
803
|
-
// 清理计时器
|
|
804
|
-
if (this.recordingTimer) {
|
|
805
|
-
clearInterval(this.recordingTimer);
|
|
806
|
-
this.recordingTimer = null;
|
|
807
|
-
}
|
|
808
|
-
// 停止并释放媒体流
|
|
809
|
-
if (this.recordingStream) {
|
|
810
|
-
this.recordingStream.getTracks().forEach(track => track.stop());
|
|
811
|
-
this.recordingStream = null;
|
|
812
|
-
}
|
|
813
|
-
// 清理视频引用
|
|
814
|
-
this.videoRef = null;
|
|
815
|
-
}
|
|
816
|
-
}
|
|
817
|
-
// 上传录制的视频
|
|
818
|
-
async uploadRecordedVideo() {
|
|
819
|
-
if (!this.recordedBlob)
|
|
820
|
-
return;
|
|
821
|
-
try {
|
|
822
|
-
this.isUploadingVideo = true; // 开始上传时设置状态
|
|
823
|
-
this.showRecordingUI = false; // 隐藏视频预览
|
|
824
|
-
// 根据Blob类型确定文件扩展名
|
|
825
|
-
const fileExtension = this.recordedBlob.type.includes('webm') ? 'webm' : 'mp4';
|
|
826
|
-
const fileName = `answer.${fileExtension}`;
|
|
827
|
-
const formData = new FormData();
|
|
828
|
-
formData.append('file', this.recordedBlob, fileName);
|
|
829
|
-
const response = await fetch('https://pcm_api.ylzhaopin.com/external/v1/files/upload', {
|
|
830
|
-
method: 'POST',
|
|
831
|
-
headers: {
|
|
832
|
-
'authorization': 'Bearer ' + this.apiKey
|
|
833
|
-
},
|
|
834
|
-
body: formData
|
|
835
|
-
});
|
|
836
|
-
const result = await response.json();
|
|
837
|
-
console.log('视频上传结果:', result);
|
|
838
|
-
if (result && result.cos_key) {
|
|
839
|
-
// 保存视频答案
|
|
840
|
-
await this.saveVideoAnswer(result.cos_key);
|
|
841
|
-
// 发送"下一题"请求
|
|
842
|
-
this.sendNextQuestion();
|
|
843
|
-
}
|
|
844
|
-
else {
|
|
845
|
-
throw new Error('视频上传失败');
|
|
846
|
-
}
|
|
847
|
-
}
|
|
848
|
-
catch (error) {
|
|
849
|
-
console.error('视频上传错误:', error);
|
|
850
|
-
// 通知父组件视频上传失败
|
|
851
|
-
this.recordingError.emit({
|
|
852
|
-
type: 'upload_failed',
|
|
853
|
-
message: '视频上传失败',
|
|
854
|
-
details: error
|
|
855
|
-
});
|
|
856
|
-
}
|
|
857
|
-
finally {
|
|
858
|
-
this.isUploadingVideo = false; // 上传完成后重置状态
|
|
859
|
-
this.showRecordingUI = false;
|
|
860
|
-
this.recordedBlob = null;
|
|
861
|
-
}
|
|
862
|
-
}
|
|
863
|
-
// 保存视频答案
|
|
864
|
-
async saveVideoAnswer(cosKey) {
|
|
865
|
-
if (!this.conversationId)
|
|
866
|
-
return;
|
|
867
|
-
try {
|
|
868
|
-
const lastAIMessage = this.messages.length > 0 ? this.messages[this.messages.length - 1] : null;
|
|
869
|
-
if (!lastAIMessage)
|
|
870
|
-
return;
|
|
871
|
-
await sendHttpRequest({
|
|
872
|
-
url: 'https://pcm_api.ylzhaopin.com/agents/hr_competition/answer',
|
|
873
|
-
method: 'POST',
|
|
874
|
-
headers: {
|
|
875
|
-
'authorization': 'Bearer ' + this.apiKey
|
|
876
|
-
},
|
|
877
|
-
data: {
|
|
878
|
-
conversation_id: this.conversationId,
|
|
879
|
-
user: this.userId, // 使用传入的 userId
|
|
880
|
-
question: lastAIMessage.answer,
|
|
881
|
-
file_url: cosKey
|
|
882
|
-
},
|
|
883
|
-
});
|
|
884
|
-
}
|
|
885
|
-
catch (error) {
|
|
886
|
-
console.error('保存视频答案失败:', error);
|
|
887
|
-
}
|
|
888
|
-
}
|
|
889
|
-
// 发送"下一题"请求
|
|
890
|
-
sendNextQuestion() {
|
|
891
|
-
this.sendMessageToAPI("下一题");
|
|
892
|
-
}
|
|
893
|
-
/**
|
|
894
|
-
* 发送面试完成请求
|
|
895
|
-
*/
|
|
896
|
-
async completeInterview() {
|
|
897
|
-
if (!this.conversationId)
|
|
898
|
-
return;
|
|
899
|
-
try {
|
|
900
|
-
await sendHttpRequest({
|
|
901
|
-
url: `https://pcm_api.ylzhaopin.com/agents/hr_competition/${this.conversationId}/end`,
|
|
902
|
-
method: 'POST',
|
|
903
|
-
headers: {
|
|
904
|
-
'authorization': 'Bearer ' + this.apiKey
|
|
905
|
-
},
|
|
906
|
-
});
|
|
907
|
-
}
|
|
908
|
-
catch (error) {
|
|
909
|
-
console.error('发送面试完成请求失败:', error);
|
|
910
|
-
}
|
|
911
|
-
}
|
|
912
|
-
// 添加TTS合成音频的方法
|
|
913
|
-
async synthesizeAudio(text) {
|
|
914
|
-
try {
|
|
915
|
-
const response = await fetch('https://pcm_api.ylzhaopin.com/external/v1/tts/synthesize_audio', {
|
|
916
|
-
method: 'POST',
|
|
917
|
-
headers: {
|
|
918
|
-
'Content-Type': 'application/json',
|
|
919
|
-
'authorization': 'Bearer ' + this.apiKey
|
|
920
|
-
},
|
|
921
|
-
body: JSON.stringify({ text })
|
|
922
|
-
});
|
|
923
|
-
if (!response.ok) {
|
|
924
|
-
throw new Error('语音合成失败');
|
|
925
|
-
}
|
|
926
|
-
// 获取音频数据并创建Blob URL
|
|
927
|
-
const audioBlob = await response.blob();
|
|
928
|
-
return URL.createObjectURL(audioBlob);
|
|
929
|
-
}
|
|
930
|
-
catch (error) {
|
|
931
|
-
console.error('语音合成错误:', error);
|
|
932
|
-
throw error;
|
|
933
|
-
}
|
|
934
|
-
}
|
|
935
|
-
// 播放音频的方法
|
|
936
|
-
playAudio(audioUrl) {
|
|
937
|
-
return new Promise((resolve) => {
|
|
938
|
-
this.isPlayingAudio = true;
|
|
939
|
-
this.audioUrl = audioUrl;
|
|
940
|
-
// 创建音频元素
|
|
941
|
-
if (!this.audioElement) {
|
|
942
|
-
this.audioElement = new Audio();
|
|
943
|
-
}
|
|
944
|
-
this.audioElement.src = audioUrl;
|
|
945
|
-
this.audioElement.onended = () => {
|
|
946
|
-
this.isPlayingAudio = false;
|
|
947
|
-
this.audioUrl = null;
|
|
948
|
-
resolve();
|
|
949
|
-
};
|
|
950
|
-
this.audioElement.onerror = () => {
|
|
951
|
-
console.error('音频播放错误');
|
|
952
|
-
this.isPlayingAudio = false;
|
|
953
|
-
this.audioUrl = null;
|
|
954
|
-
resolve();
|
|
955
|
-
};
|
|
956
|
-
this.audioElement.play().catch(error => {
|
|
957
|
-
console.error('音频播放失败:', error);
|
|
958
|
-
this.isPlayingAudio = false;
|
|
959
|
-
this.audioUrl = null;
|
|
960
|
-
resolve();
|
|
961
|
-
});
|
|
962
|
-
});
|
|
963
|
-
}
|
|
964
|
-
// 修改 componentDidLoad 生命周期方法,确保组件卸载时释放资源
|
|
965
|
-
disconnectedCallback() {
|
|
966
|
-
// 释放音频资源
|
|
967
|
-
if (this.audioElement) {
|
|
968
|
-
this.audioElement.pause();
|
|
969
|
-
this.audioElement.src = '';
|
|
970
|
-
this.audioElement = null;
|
|
971
|
-
}
|
|
972
|
-
// 释放 Blob URL
|
|
973
|
-
if (this.audioUrl) {
|
|
974
|
-
URL.revokeObjectURL(this.audioUrl);
|
|
975
|
-
this.audioUrl = null;
|
|
976
|
-
}
|
|
977
|
-
// 清理其他计时器
|
|
978
|
-
if (this.waitingTimer) {
|
|
979
|
-
clearInterval(this.waitingTimer);
|
|
980
|
-
this.waitingTimer = null;
|
|
981
|
-
}
|
|
982
|
-
if (this.recordingTimer) {
|
|
983
|
-
clearInterval(this.recordingTimer);
|
|
984
|
-
this.recordingTimer = null;
|
|
985
|
-
}
|
|
986
|
-
// 停止录制
|
|
987
|
-
this.stopRecording();
|
|
988
|
-
}
|
|
989
|
-
// 修改手动播放音频的方法
|
|
990
|
-
handlePlayAudio = async () => {
|
|
991
|
-
if (this.audioUrl) {
|
|
992
|
-
await this.playAudio(this.audioUrl);
|
|
993
|
-
// 手动播放完成后开始等待录制
|
|
994
|
-
this.startWaitingToRecord();
|
|
995
|
-
}
|
|
996
|
-
};
|
|
997
|
-
render() {
|
|
998
|
-
if (!this.isOpen)
|
|
999
|
-
return null;
|
|
1000
|
-
const modalStyle = {
|
|
1001
|
-
zIndex: String(this.zIndex)
|
|
1002
|
-
};
|
|
1003
|
-
const containerClass = {
|
|
1004
|
-
'modal-container': true,
|
|
1005
|
-
'fullscreen': this.fullscreen
|
|
1006
|
-
};
|
|
1007
|
-
const overlayClass = {
|
|
1008
|
-
'modal-overlay': true,
|
|
1009
|
-
'fullscreen-overlay': this.fullscreen
|
|
1010
|
-
};
|
|
1011
|
-
const renderVideoPreview = () => (h("div", { class: "video-preview" }, h("video", { autoPlay: true, playsInline: true, muted: true, style: { transform: 'scaleX(-1)' }, ref: (el) => {
|
|
1012
|
-
if (el && this.recordingStream && !this.videoRef) {
|
|
1013
|
-
this.videoRef = el;
|
|
1014
|
-
// 不在这里设置srcObject,而是使用setupVideoPreview方法
|
|
1015
|
-
}
|
|
1016
|
-
} }), h("div", { class: {
|
|
1017
|
-
'recording-status': true,
|
|
1018
|
-
'warning': this.showCountdownWarning
|
|
1019
|
-
} }, h("span", { class: "recording-dot" }), h("span", null, "\u5F55\u5236\u4E2D ", Math.floor(this.recordingTimeLeft / 60), ":", (this.recordingTimeLeft % 60).toString().padStart(2, '0'), this.showCountdownWarning && ` (即将自动完成)`))));
|
|
1020
|
-
// 渲染占位符状态信息
|
|
1021
|
-
const renderPlaceholderStatus = () => {
|
|
1022
|
-
// 正在播放音频
|
|
1023
|
-
if (this.isPlayingAudio) {
|
|
1024
|
-
return (h("div", { class: "placeholder-status" }, h("p", null, "\u6B63\u5728\u64AD\u653E\u95EE\u9898\uFF0C\u8BF7\u542C\u5B8C\u540E\u51C6\u5907\u56DE\u7B54...")));
|
|
1025
|
-
}
|
|
1026
|
-
// 正在上传视频
|
|
1027
|
-
if (this.isUploadingVideo) {
|
|
1028
|
-
return (h("div", { class: "placeholder-status" }, h("p", null, "\u6B63\u5728\u4E0A\u4F20\u89C6\u9891\uFF0C\u8BF7\u7A0D\u5019...")));
|
|
1029
|
-
}
|
|
1030
|
-
// 正在加载或等待AI回复
|
|
1031
|
-
if (this.isLoading || this.currentStreamingMessage) {
|
|
1032
|
-
return (h("div", { class: "placeholder-status" }, h("p", null, "\u8BF7\u7B49\u5F85\u9898\u76EE...")));
|
|
1033
|
-
}
|
|
1034
|
-
// 等待开始录制
|
|
1035
|
-
if (this.waitingToRecord) {
|
|
1036
|
-
return (h("div", { class: "placeholder-status" }, h("p", null, "\u8BF7\u51C6\u5907\u597D\uFF0C", this.waitingTimeLeft, "\u79D2\u540E\u5C06\u5F00\u59CB\u5F55\u5236\u60A8\u7684\u56DE\u7B54...")));
|
|
1037
|
-
}
|
|
1038
|
-
// 添加默认状态
|
|
1039
|
-
return (h("div", { class: "placeholder-status default-status" }, h("p", null, "\u51C6\u5907\u4E2D...")));
|
|
1040
|
-
};
|
|
1041
|
-
return (h("div", { class: overlayClass, style: modalStyle }, h("div", { class: containerClass }, this.isShowHeader && (h("div", { class: "modal-header" }, h("div", { class: "header-left" }, this.icon && h("img", { src: this.icon, class: "header-icon", alt: "\u5E94\u7528\u56FE\u6807" }), h("div", null, this.modalTitle)), this.isNeedClose && (h("button", { class: "close-button", onClick: this.handleClose }, h("span", null, "\u00D7"))))), this.showInitialUpload ? (h("div", { class: "initial-upload" }, h("div", { class: "upload-section" }, this.requireResume && (h(h.Fragment, null, h("h3", null, "\u5F00\u59CB\u524D\uFF0C\u8BF7\u4E0A\u4F20\u60A8\u7684\u7B80\u5386"), h("div", { class: "upload-area", onClick: this.handleUploadClick }, this.selectedFile ? (h("div", { class: "file-info" }, h("span", null, this.selectedFile.name), h("button", { class: "remove-file", onClick: (e) => {
|
|
1042
|
-
e.stopPropagation();
|
|
1043
|
-
this.clearSelectedFile();
|
|
1044
|
-
} }, "\u00D7"))) : (h("div", { class: "upload-placeholder" }, h("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", width: "48", height: "48" }, h("path", { "stroke-linecap": "round", "stroke-linejoin": "round", "stroke-width": "2", d: "M12 4v16m0-16l-4 4m4-4l4 4" })), h("p", null, "\u70B9\u51FB\u4E0A\u4F20\u7B80\u5386"), h("p", { class: "upload-hint" }, "\u652F\u6301 txt\u3001 markdown\u3001 pdf\u3001 docx\u3001 md \u683C\u5F0F")))))), h("div", { class: "category-select" }, h("h3", null, "\u8BF7\u9009\u62E9\u60A8\u7684\u804C\u80FD\u7C7B\u522B\uFF08\u5355\u9009\uFF09"), h("div", { class: "category-options" }, this.jobCategories.map(category => (h("button", { class: {
|
|
1045
|
-
'category-button': true,
|
|
1046
|
-
'selected': this.selectedJobCategory === category
|
|
1047
|
-
}, onClick: () => this.handleJobCategorySelect(category) }, category))))), h("div", { class: "dimension-select" }, h("h3", null, "\u8BF7\u9009\u62E9\u5173\u6CE8\u7684\u6A21\u5757\uFF08\u53EF\u591A\u9009\uFF09"), h("div", { class: "dimension-options" }, this.dimensions.map(dimension => (h("button", { class: {
|
|
1048
|
-
'dimension-button': true,
|
|
1049
|
-
'selected': this.selectedDimensions.includes(dimension)
|
|
1050
|
-
}, onClick: () => this.handleDimensionSelect(dimension) }, dimension))))), h("button", { class: "submit-button", disabled: (this.requireResume && !this.selectedFile) ||
|
|
1051
|
-
!this.selectedJobCategory ||
|
|
1052
|
-
this.selectedDimensions.length === 0 ||
|
|
1053
|
-
(this.requireResume && this.isUploading), onClick: this.handleInitialSubmit }, this.requireResume && this.isUploading ? '上传中...' : '开始面试')), this.requireResume && (h("input", { type: "file", class: "file-input", onChange: this.handleFileChange, accept: ".pdf,.doc,.docx,.txt" })))) : (h("div", { style: { height: '100%' } }, h("div", { class: "chat-history", onScroll: this.handleScroll }, this.isLoadingHistory ? (h("div", { class: "loading-container" }, h("div", { class: "loading-spinner" }), h("p", null, "\u52A0\u8F7D\u5386\u53F2\u6D88\u606F\u4E2D..."))) : (h("div", null, this.messages.map((message) => (h("div", { id: `message_${message.id}`, key: message.id }, h("pcm-chat-message", { message: message, onMessageChange: (event) => {
|
|
1054
|
-
const updatedMessages = this.messages.map(msg => msg.id === message.id ? { ...msg, ...event.detail } : msg);
|
|
1055
|
-
this.messages = updatedMessages;
|
|
1056
|
-
} })))), this.currentStreamingMessage && (h("div", { id: `message_${this.currentStreamingMessage.id}` }, h("pcm-chat-message", { message: this.currentStreamingMessage }))), this.messages.length === 0 && !this.currentStreamingMessage && (h("div", { class: "empty-state" }, h("p", null, "\u8BF7\u4E0A\u4F20\u7B80\u5386\u5F00\u59CB\u9762\u8BD5")))))), h("div", { class: "recording-section" }, h("div", { class: "recording-container" }, h("div", { class: "video-area" }, this.showRecordingUI ? (renderVideoPreview()) : (h("div", { class: "video-preview placeholder" }, renderPlaceholderStatus()))), h("div", { class: "progress-container" }, h("div", { class: "progress-bar-container" }, h("div", { class: "progress-bar", style: {
|
|
1057
|
-
width: `${Math.max(0, this.currentQuestionNumber - 1) / this.totalQuestions * 100}%`
|
|
1058
|
-
} })), h("div", { class: "progress-text" }, "\u5DF2\u5B8C\u6210", Math.max(0, this.currentQuestionNumber - 1), "/", this.totalQuestions)), h("div", { class: "recording-controls" }, this.showRecordingUI ? (h("button", { class: "stop-recording-button", onClick: () => this.stopRecording() }, "\u5B8C\u6210\u672C\u9898\u56DE\u7B54")) : (h("div", { class: "waiting-message" }, (() => {
|
|
1059
|
-
// 显示播放按钮(当不自动播放且有音频URL时)
|
|
1060
|
-
if (!this.enableVoice && this.audioUrl && !this.isPlayingAudio) {
|
|
1061
|
-
return (h("div", { class: "play-audio-container", onClick: this.handlePlayAudio }, h("p", null, h("svg", { viewBox: "0 0 24 24", width: "24", height: "24", fill: "currentColor", style: { verticalAlign: 'middle', marginRight: '8px' } }, h("path", { d: "M8 5v14l11-7z" })), h("span", { style: { verticalAlign: 'middle' } }, "\u64AD\u653E\u9898\u76EE"))));
|
|
1062
|
-
}
|
|
1063
|
-
// 其他状态下显示禁用的"完成回答"按钮
|
|
1064
|
-
return (h("button", { class: "stop-recording-button disabled", disabled: true }, "\u5B8C\u6210\u56DE\u7B54"));
|
|
1065
|
-
})()))))))))));
|
|
1066
|
-
}
|
|
1067
|
-
static get watchers() { return {
|
|
1068
|
-
"isOpen": ["handleIsOpenChange"]
|
|
1069
|
-
}; }
|
|
1070
|
-
};
|
|
1071
|
-
ChatHRModal.style = pcmHrChatModalCss;
|
|
1072
|
-
|
|
1073
|
-
export { ChatHRModal as pcm_hr_chat_modal };
|
|
1074
|
-
//# sourceMappingURL=pcm-hr-chat-modal.entry.js.map
|
|
1075
|
-
|
|
1076
|
-
//# sourceMappingURL=pcm-hr-chat-modal.entry.js.map
|