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.
Files changed (146) hide show
  1. package/LICENSE +21 -21
  2. package/dist/cjs/index-BFPEnLbS.js +195 -0
  3. package/dist/cjs/index-BFPEnLbS.js.map +1 -0
  4. package/dist/cjs/index.cjs.js +1 -1
  5. package/dist/cjs/loader.cjs.js +1 -1
  6. package/dist/cjs/my-component.cjs.entry.js +2 -2
  7. package/dist/cjs/my-component.cjs.entry.js.map +1 -1
  8. package/dist/cjs/my-component.entry.cjs.js.map +1 -1
  9. package/dist/cjs/pcm-agents.cjs.js +1 -1
  10. 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
  11. package/dist/cjs/pcm-app-chat-modal_7.cjs.entry.js +6560 -0
  12. package/dist/cjs/pcm-app-chat-modal_7.cjs.entry.js.map +1 -0
  13. package/dist/cjs/pcm-chat-modal.cjs.entry.js +17 -32
  14. package/dist/cjs/pcm-chat-modal.cjs.entry.js.map +1 -1
  15. package/dist/cjs/pcm-chat-modal.entry.cjs.js.map +1 -1
  16. package/dist/collection/collection-manifest.json +2 -0
  17. package/dist/collection/components/my-component/my-component.css +3 -3
  18. package/dist/collection/components/my-component/my-component.js +1 -1
  19. package/dist/collection/components/my-component/my-component.js.map +1 -1
  20. package/dist/collection/components/pcm-app-chat-modal/pcm-app-chat-modal.css +2 -1
  21. package/dist/collection/components/pcm-app-chat-modal/pcm-app-chat-modal.js +137 -159
  22. package/dist/collection/components/pcm-app-chat-modal/pcm-app-chat-modal.js.map +1 -1
  23. package/dist/collection/components/pcm-chat-message/pcm-chat-message.css +66 -12
  24. package/dist/collection/components/pcm-chat-message/pcm-chat-message.js +106 -13
  25. package/dist/collection/components/pcm-chat-message/pcm-chat-message.js.map +1 -1
  26. package/dist/collection/components/pcm-chat-modal/pcm-chat-modal.js +39 -34
  27. package/dist/collection/components/pcm-chat-modal/pcm-chat-modal.js.map +1 -1
  28. package/dist/collection/components/pcm-hr-chat-modal/pcm-hr-chat-modal.js +76 -105
  29. package/dist/collection/components/pcm-hr-chat-modal/pcm-hr-chat-modal.js.map +1 -1
  30. package/dist/collection/components/pcm-jlpx-modal/pcm-jlpx-modal.css +162 -0
  31. package/dist/collection/components/pcm-jlpx-modal/pcm-jlpx-modal.js +616 -0
  32. package/dist/collection/components/pcm-jlpx-modal/pcm-jlpx-modal.js.map +1 -0
  33. package/dist/collection/components/pcm-mnms-modal/pcm-mnms-modal.css +0 -79
  34. package/dist/collection/components/pcm-mnms-modal/pcm-mnms-modal.js +133 -81
  35. package/dist/collection/components/pcm-mnms-modal/pcm-mnms-modal.js.map +1 -1
  36. package/dist/collection/components/pcm-video-chat-modal/pcm-video-chat-modal.js +77 -101
  37. package/dist/collection/components/pcm-video-chat-modal/pcm-video-chat-modal.js.map +1 -1
  38. package/dist/collection/components/pcm-zygh-modal/pcm-zygh-modal.css +273 -0
  39. package/dist/collection/components/pcm-zygh-modal/pcm-zygh-modal.js +613 -0
  40. package/dist/collection/components/pcm-zygh-modal/pcm-zygh-modal.js.map +1 -0
  41. package/dist/collection/global/global.css +324 -0
  42. package/dist/collection/index.js.map +1 -1
  43. package/dist/collection/interfaces/chat.js.map +1 -1
  44. package/dist/collection/utils/utils.js +54 -113
  45. package/dist/collection/utils/utils.js.map +1 -1
  46. package/dist/components/index.js +1298 -11280
  47. package/dist/components/index.js.map +1 -1
  48. package/dist/components/my-component.js +2 -3
  49. package/dist/components/my-component.js.map +1 -1
  50. package/dist/components/{p-C4l_DOnx.js → p-BctfuDvG.js} +106 -147
  51. package/dist/components/p-BctfuDvG.js.map +1 -0
  52. package/dist/components/{p-D0s1Q-3O.js → p-LkDC0SN2.js} +343 -16
  53. package/dist/components/p-LkDC0SN2.js.map +1 -0
  54. package/dist/components/pcm-app-chat-modal.js +1 -1
  55. package/dist/components/pcm-chat-message.js +1 -1
  56. package/dist/components/pcm-chat-modal.js +19 -34
  57. package/dist/components/pcm-chat-modal.js.map +1 -1
  58. package/dist/components/pcm-hr-chat-modal.js +70 -100
  59. package/dist/components/pcm-hr-chat-modal.js.map +1 -1
  60. package/dist/components/pcm-jlpx-modal.d.ts +11 -0
  61. package/dist/components/pcm-jlpx-modal.js +339 -0
  62. package/dist/components/pcm-jlpx-modal.js.map +1 -0
  63. package/dist/components/pcm-mnms-modal.js +109 -57
  64. package/dist/components/pcm-mnms-modal.js.map +1 -1
  65. package/dist/components/pcm-video-chat-modal.js +74 -99
  66. package/dist/components/pcm-video-chat-modal.js.map +1 -1
  67. package/dist/components/pcm-zygh-modal.d.ts +11 -0
  68. package/dist/components/pcm-zygh-modal.js +330 -0
  69. package/dist/components/pcm-zygh-modal.js.map +1 -0
  70. package/dist/esm/index-nVjZGfA8.js +189 -0
  71. package/dist/esm/index-nVjZGfA8.js.map +1 -0
  72. package/dist/esm/index.js +1 -1
  73. package/dist/esm/loader.js +1 -1
  74. package/dist/esm/my-component.entry.js +2 -2
  75. package/dist/esm/my-component.entry.js.map +1 -1
  76. package/dist/esm/pcm-agents.js +1 -1
  77. 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
  78. package/dist/esm/pcm-app-chat-modal_7.entry.js +6552 -0
  79. package/dist/esm/pcm-app-chat-modal_7.entry.js.map +1 -0
  80. package/dist/esm/pcm-chat-modal.entry.js +17 -32
  81. package/dist/esm/pcm-chat-modal.entry.js.map +1 -1
  82. package/dist/pcm-agents/index.esm.js +1 -1
  83. package/dist/pcm-agents/my-component.entry.esm.js.map +1 -1
  84. package/dist/pcm-agents/p-55417392.entry.js +2 -0
  85. package/dist/pcm-agents/p-55417392.entry.js.map +1 -0
  86. package/dist/pcm-agents/p-a698b59f.entry.js +2 -0
  87. package/dist/pcm-agents/p-a698b59f.entry.js.map +1 -0
  88. package/dist/pcm-agents/p-f3ca99b4.entry.js +2 -0
  89. package/dist/pcm-agents/p-f3ca99b4.entry.js.map +1 -0
  90. package/dist/pcm-agents/p-nVjZGfA8.js +2 -0
  91. package/dist/pcm-agents/p-nVjZGfA8.js.map +1 -0
  92. package/dist/pcm-agents/pcm-agents.esm.js +1 -1
  93. 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
  94. package/dist/pcm-agents/pcm-chat-modal.entry.esm.js.map +1 -1
  95. package/dist/types/components/pcm-app-chat-modal/pcm-app-chat-modal.d.ts +13 -8
  96. package/dist/types/components/pcm-chat-message/pcm-chat-message.d.ts +5 -0
  97. package/dist/types/components/pcm-chat-modal/pcm-chat-modal.d.ts +8 -8
  98. package/dist/types/components/pcm-hr-chat-modal/pcm-hr-chat-modal.d.ts +6 -12
  99. package/dist/types/components/pcm-jlpx-modal/pcm-jlpx-modal.d.ts +113 -0
  100. package/dist/types/components/pcm-mnms-modal/pcm-mnms-modal.d.ts +19 -20
  101. package/dist/types/components/pcm-video-chat-modal/pcm-video-chat-modal.d.ts +4 -4
  102. package/dist/types/components/pcm-zygh-modal/pcm-zygh-modal.d.ts +117 -0
  103. package/dist/types/components.d.ts +429 -80
  104. package/dist/types/interfaces/chat.d.ts +0 -4
  105. package/dist/types/utils/utils.d.ts +29 -83
  106. package/package.json +61 -60
  107. package/readme.md +307 -307
  108. package/dist/cjs/index-DfIUl99H.js +0 -11413
  109. package/dist/cjs/index-DfIUl99H.js.map +0 -1
  110. package/dist/cjs/pcm-app-chat-modal.pcm-chat-message.pcm-mnms-modal.entry.cjs.js.map +0 -1
  111. package/dist/cjs/pcm-app-chat-modal_3.cjs.entry.js +0 -3734
  112. package/dist/cjs/pcm-app-chat-modal_3.cjs.entry.js.map +0 -1
  113. package/dist/cjs/pcm-hr-chat-modal.cjs.entry.js +0 -1078
  114. package/dist/cjs/pcm-hr-chat-modal.cjs.entry.js.map +0 -1
  115. package/dist/cjs/pcm-hr-chat-modal.entry.cjs.js.map +0 -1
  116. package/dist/cjs/pcm-video-chat-modal.cjs.entry.js +0 -927
  117. package/dist/cjs/pcm-video-chat-modal.cjs.entry.js.map +0 -1
  118. package/dist/cjs/pcm-video-chat-modal.entry.cjs.js.map +0 -1
  119. package/dist/components/p-C4l_DOnx.js.map +0 -1
  120. package/dist/components/p-CgDy4pJp.js +0 -1244
  121. package/dist/components/p-CgDy4pJp.js.map +0 -1
  122. package/dist/components/p-D0s1Q-3O.js.map +0 -1
  123. package/dist/esm/index-B2EtEi7v.js +0 -11409
  124. package/dist/esm/index-B2EtEi7v.js.map +0 -1
  125. package/dist/esm/pcm-app-chat-modal.pcm-chat-message.pcm-mnms-modal.entry.js.map +0 -1
  126. package/dist/esm/pcm-app-chat-modal_3.entry.js +0 -3730
  127. package/dist/esm/pcm-app-chat-modal_3.entry.js.map +0 -1
  128. package/dist/esm/pcm-hr-chat-modal.entry.js +0 -1076
  129. package/dist/esm/pcm-hr-chat-modal.entry.js.map +0 -1
  130. package/dist/esm/pcm-video-chat-modal.entry.js +0 -925
  131. package/dist/esm/pcm-video-chat-modal.entry.js.map +0 -1
  132. package/dist/pcm-agents/p-0ddd5c47.entry.js +0 -2
  133. package/dist/pcm-agents/p-0ddd5c47.entry.js.map +0 -1
  134. package/dist/pcm-agents/p-5f624943.entry.js +0 -2
  135. package/dist/pcm-agents/p-5f624943.entry.js.map +0 -1
  136. package/dist/pcm-agents/p-6c07f155.entry.js +0 -2
  137. package/dist/pcm-agents/p-6c07f155.entry.js.map +0 -1
  138. package/dist/pcm-agents/p-9a1fb6ca.entry.js +0 -2
  139. package/dist/pcm-agents/p-9a1fb6ca.entry.js.map +0 -1
  140. package/dist/pcm-agents/p-B2EtEi7v.js +0 -146
  141. package/dist/pcm-agents/p-B2EtEi7v.js.map +0 -1
  142. package/dist/pcm-agents/p-e21bc169.entry.js +0 -2
  143. package/dist/pcm-agents/p-e21bc169.entry.js.map +0 -1
  144. package/dist/pcm-agents/pcm-app-chat-modal.pcm-chat-message.pcm-mnms-modal.entry.esm.js.map +0 -1
  145. package/dist/pcm-agents/pcm-hr-chat-modal.entry.esm.js.map +0 -1
  146. package/dist/pcm-agents/pcm-video-chat-modal.entry.esm.js.map +0 -1
@@ -0,0 +1,330 @@
1
+ import { p as proxyCustomElement, H, c as createEvent, u as uploadFileToBackend, a as sendHttpRequest, h } from './index.js';
2
+ import { d as defineCustomElement$3 } from './p-BctfuDvG.js';
3
+ import { d as defineCustomElement$2 } from './p-LkDC0SN2.js';
4
+
5
+ const pcmZyghModalCss = ".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;z-index:1000}.fullscreen-overlay{background-color:rgba(0, 0, 0, 0.7)}.modal-container{background-color:#fff;border-radius:8px;box-shadow:0 4px 12px rgba(0, 0, 0, 0.15);width:90%;max-width:800px;max-height:90vh;display:flex;flex-direction:column;overflow:hidden}.fullscreen{width:100%;height:100%;max-width:100%;max-height:100%;border-radius:0}.pc-layout{width:90%;max-width:800px;max-height:90vh}.mobile-layout{width:100%;height:100%;max-width:100%;max-height:100%;border-radius:0}.modal-header{display:flex;justify-content:space-between;align-items:center;padding:16px 20px;border-bottom:1px solid #f0f0f0;background-color:#fff}.header-left{display:flex;align-items:center;font-size:16px;font-weight:600;color:#333}.header-icon{width:24px;height:24px;margin-right:8px;border-radius:4px}.close-button{background:none;border:none;font-size:20px;cursor:pointer;color:#999;display:flex;align-items:center;justify-content:center;width:32px;height:32px;border-radius:50%;transition:background-color 0.3s}.close-button:hover{background-color:#f5f5f5;color:#666}.input-container{padding:20px;overflow-y:auto;flex:1;display:flex;flex-direction:column;gap:20px}.plan-type-section{display:flex;flex-direction:column;gap:10px}.plan-type-section label{font-weight:600;color:#333;margin-bottom:8px}.plan-type-options{display:flex;gap:15px;flex-wrap:wrap}.plan-type-option{flex:1;min-width:120px;border:1px solid #e8e8e8;border-radius:8px;padding:15px;cursor:pointer;display:flex;flex-direction:column;align-items:center;transition:all 0.3s}.plan-type-option:hover{border-color:#1890ff;background-color:#f0f7ff}.plan-type-option.selected{border-color:#1890ff;background-color:#e6f7ff;box-shadow:0 2px 8px rgba(24, 144, 255, 0.2)}.option-icon{font-size:24px;margin-bottom:8px}.option-label{font-size:14px;font-weight:500;color:#333}.resume-upload-section{display:flex;flex-direction:column;gap:8px}.resume-upload-section label{font-weight:600;color:#333}.upload-area{border:2px dashed #d9d9d9;border-radius:4px;text-align:center;cursor:pointer;transition:border-color 0.3s, background-color 0.3s}.upload-area:hover{border-color:#1890ff;background-color:#f0f7ff}.upload-placeholder{display:flex;flex-direction:column;align-items:center;color:#666}.upload-placeholder svg{color:#1890ff;margin-bottom:8px}.upload-placeholder p{margin:4px 0}.upload-hint{font-size:12px;color:#999}.file-info{display:flex;align-items:center;justify-content:space-between;background-color:#f5f5f5;padding:8px 12px;border-radius:4px}.file-info span{flex:1;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;text-overflow:ellipsis;word-break:break-word;margin-right:8px;max-width:calc(100% - 32px);line-height:1.4}.remove-file{flex-shrink:0;background:none;border:none;color:#ff4d4f;cursor:pointer;font-size:16px;padding:4px 8px;border-radius:50%;transition:background-color 0.3s}.remove-file:hover{background-color:#fff1f0}.file-input{display:none}.submit-button{background-color:#1890ff;color:white;border:none;border-radius:4px;padding:12px 20px;font-size:16px;font-weight:500;cursor:pointer;transition:background-color 0.3s;margin-top:10px}.submit-button:hover{background-color:#40a9ff}.submit-button:disabled{background-color:#d9d9d9;cursor:not-allowed}.chat-modal-container{flex:1;display:flex;flex-direction:column;overflow:hidden}";
6
+
7
+ const globalCss = ".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;z-index:1000;overflow-y:auto;padding:20px}.fullscreen-overlay{padding:0;background-color:rgba(0, 0, 0, 0.7)}.modal-container{background-color:#fff;border-radius:8px;width:100%;display:flex;flex-direction:column;position:relative;margin:auto;transition:all 0.3s ease-out;overflow:hidden}.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}.pc-layout{width:80%;max-width:500px;min-width:320px}.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);margin-top:40px;height:calc(100% - 40px);max-height:calc(100% - 40px);border-radius:16px 16px 0 0}.modal-container.mobile-layout{width:100%;height:100vh;max-height:100vh;min-height:100vh;border-radius:0;margin:0;display:flex;flex-direction:column}}.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}.upload-area{border:2px dashed #ddd;border-radius:8px;cursor:pointer;transition:all 0.3s ease;margin-bottom:20px;width:100%}.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-placeholder svg{color:#1890ff;margin-bottom:8px}.upload-placeholder p{margin:4px 0}.upload-hint{font-size:0.8rem;color:#999;margin-top:0.5rem}.file-info{display:flex;align-items:center;justify-content:space-between;padding:8px;background:#f9f9f9;border:1px solid #e8e8e8;border-radius:4px}.file-info span{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}.file-input{display:none}.input-container{padding:20px;display:flex;flex-direction:column;height:calc(100% - 50px);overflow-y:auto}.input-container h3{margin-top:0;margin-bottom:20px;font-size:18px;color:#333;text-align:center}.jd-input-section{margin-bottom:20px}.jd-input-section label{display:block;margin-bottom:8px;font-weight:500;color:#333}.job-description-textarea{width:100%;border:1px solid #ddd;border-radius:4px;resize:vertical;font-family:inherit;font-size:14px;line-height:1.5;transition:border-color 0.3s}.job-description-textarea:focus{outline:none;border-color:#1890ff;box-shadow:0 0 0 2px rgba(24, 144, 255, 0.2)}.resume-upload-section{margin-bottom:20px;width:100%;display:flex;flex-direction:column;align-items:center}.resume-upload-section label{display:block;margin-bottom:8px;font-weight:500;color:#333;align-self:flex-start}.submit-button{margin-top:10px;padding:10px 30px;background:#1890ff;color:white;border:none;border-radius:4px;font-size:16px;cursor:pointer;transition:all 0.3s ease;width:100%;max-width:400px;align-self:center;}.submit-button:disabled{background:#ccc;cursor:not-allowed}.submit-button:hover:not(:disabled){background:#40a9ff}.chat-modal-container{position:absolute;top:0;left:0;right:0;bottom:0;display:flex;flex-direction:column}";
8
+
9
+ const ZyghModal = /*@__PURE__*/ proxyCustomElement(class ZyghModal extends H {
10
+ constructor() {
11
+ super();
12
+ this.__registerHost();
13
+ this.__attachShadow();
14
+ this.modalClosed = createEvent(this, "modalClosed");
15
+ this.uploadSuccess = createEvent(this, "uploadSuccess");
16
+ this.streamComplete = createEvent(this, "streamComplete");
17
+ this.conversationStart = createEvent(this, "conversationStart");
18
+ this.planningComplete = createEvent(this, "planningComplete");
19
+ this.apiKeyInvalid = createEvent(this, "apiKeyInvalid");
20
+ }
21
+ /**
22
+ * 模态框标题
23
+ */
24
+ modalTitle = '职业规划助手';
25
+ /**
26
+ * API鉴权密钥
27
+ */
28
+ token = '';
29
+ /**
30
+ * 是否显示聊天模态框
31
+ */
32
+ isOpen = false;
33
+ /**
34
+ * 当点击模态框关闭时触发
35
+ */
36
+ modalClosed;
37
+ /**
38
+ * 应用图标URL
39
+ */
40
+ icon;
41
+ /**
42
+ * 聊天框的页面层级
43
+ */
44
+ zIndex = 1000;
45
+ /**
46
+ * 是否展示顶部标题栏
47
+ */
48
+ isShowHeader = true;
49
+ /**
50
+ * 是否展示右上角的关闭按钮
51
+ */
52
+ isNeedClose = true;
53
+ /**
54
+ * 会话ID,传入继续对话,否则创建新会话
55
+ */
56
+ conversationId;
57
+ /**
58
+ * 默认查询文本
59
+ */
60
+ defaultQuery = '';
61
+ /**
62
+ * 是否以全屏模式打开,移动端建议设置为true
63
+ */
64
+ fullscreen = false;
65
+ /**
66
+ * 自定义输入参数
67
+ */
68
+ customInputs = {};
69
+ /**
70
+ * 上传成功事件
71
+ */
72
+ uploadSuccess;
73
+ /**
74
+ * 流式输出完成事件
75
+ */
76
+ streamComplete;
77
+ /**
78
+ * 新会话开始的回调,只会在一轮对话开始时触发一次
79
+ */
80
+ conversationStart;
81
+ /**
82
+ * 当聊天完成时触发
83
+ */
84
+ planningComplete;
85
+ /**
86
+ * API密钥验证失败事件
87
+ */
88
+ apiKeyInvalid;
89
+ selectedFile = null;
90
+ isUploading = false;
91
+ uploadedFileInfo = null;
92
+ showChatModal = false;
93
+ isSubmitting = false;
94
+ selectedPlanType = '长期规划';
95
+ // 添加新的状态来控制过渡动画
96
+ isTransitioning = false;
97
+ transitionTimer = null;
98
+ get hostElement() { return this; }
99
+ handleClose = () => {
100
+ this.isOpen = false;
101
+ this.modalClosed.emit();
102
+ };
103
+ handleFileChange = (event) => {
104
+ const input = event.target;
105
+ if (input.files && input.files.length > 0) {
106
+ this.selectedFile = input.files[0];
107
+ }
108
+ };
109
+ handleUploadClick = () => {
110
+ const fileInput = this.hostElement.shadowRoot?.querySelector('.file-input');
111
+ fileInput?.click();
112
+ };
113
+ clearSelectedFile = () => {
114
+ this.selectedFile = null;
115
+ this.uploadedFileInfo = null;
116
+ const fileInput = this.hostElement.shadowRoot?.querySelector('.file-input');
117
+ if (fileInput) {
118
+ fileInput.value = '';
119
+ }
120
+ };
121
+ handlePlanTypeChange = (type) => {
122
+ this.selectedPlanType = type;
123
+ };
124
+ async uploadFile() {
125
+ if (!this.selectedFile)
126
+ return;
127
+ this.isUploading = true;
128
+ try {
129
+ const result = await uploadFileToBackend(this.selectedFile, {
130
+ 'authorization': 'Bearer ' + this.token
131
+ });
132
+ this.uploadedFileInfo = result;
133
+ this.uploadSuccess.emit(result);
134
+ }
135
+ catch (error) {
136
+ console.error('文件上传错误:', error);
137
+ this.clearSelectedFile();
138
+ alert(error instanceof Error ? error.message : '文件上传失败,请重试');
139
+ }
140
+ finally {
141
+ this.isUploading = false;
142
+ }
143
+ }
144
+ handleStartPlanning = async () => {
145
+ if (!this.selectedFile) {
146
+ alert('请上传简历');
147
+ return;
148
+ }
149
+ this.isSubmitting = true;
150
+ try {
151
+ // 如果还没上传,先上传文件
152
+ if (!this.uploadedFileInfo) {
153
+ await this.uploadFile();
154
+ if (!this.uploadedFileInfo) {
155
+ this.isSubmitting = false;
156
+ return; // 上传失败
157
+ }
158
+ }
159
+ console.log('传递的customInputs:', {
160
+ ...this.customInputs,
161
+ file_url: this.uploadedFileInfo.cos_key,
162
+ plan_type: this.selectedPlanType
163
+ });
164
+ // 直接显示聊天模态框
165
+ this.showChatModal = true;
166
+ }
167
+ catch (error) {
168
+ console.error('开始规划时出错:', error);
169
+ alert('开始规划时出错,请重试');
170
+ }
171
+ finally {
172
+ this.isSubmitting = false;
173
+ }
174
+ };
175
+ handleIsOpenChange(newValue) {
176
+ if (!newValue) {
177
+ // 重置状态
178
+ this.clearSelectedFile();
179
+ this.showChatModal = false;
180
+ // 清除可能存在的计时器
181
+ if (this.transitionTimer) {
182
+ clearTimeout(this.transitionTimer);
183
+ this.transitionTimer = null;
184
+ }
185
+ }
186
+ else {
187
+ // 当模态框打开时,验证API密钥
188
+ this.verifyApiKey();
189
+ if (this.conversationId) {
190
+ // 如果有会话ID,直接显示聊天模态框
191
+ this.showChatModal = true;
192
+ }
193
+ }
194
+ }
195
+ /**
196
+ * 验证API密钥
197
+ */
198
+ async verifyApiKey() {
199
+ if (!this.token) {
200
+ this.apiKeyInvalid.emit();
201
+ return;
202
+ }
203
+ try {
204
+ const response = await sendHttpRequest({
205
+ url: '/sdk/v1/user',
206
+ method: 'GET',
207
+ headers: {
208
+ 'Authorization': `Bearer ${this.token}`
209
+ }
210
+ });
211
+ if (!response.success) {
212
+ throw new Error(response.message || 'API密钥验证失败');
213
+ }
214
+ // 验证成功,继续正常流程
215
+ }
216
+ catch (error) {
217
+ console.error('API密钥验证错误:', error);
218
+ // 通知父组件API密钥无效
219
+ this.apiKeyInvalid.emit();
220
+ }
221
+ }
222
+ componentWillLoad() {
223
+ // 检查 customInputs 中是否有 plan_type
224
+ if (this.customInputs && this.customInputs.plan_type) {
225
+ this.selectedPlanType = this.customInputs.plan_type;
226
+ }
227
+ }
228
+ // 处理流式输出完成事件
229
+ handleStreamComplete = (event) => {
230
+ // 将事件转发出去
231
+ this.streamComplete.emit(event.detail);
232
+ };
233
+ // 处理会话开始事件
234
+ handleConversationStart = (event) => {
235
+ this.conversationStart.emit(event.detail);
236
+ };
237
+ // 处理规划完成事件
238
+ handlePlanningComplete = (event) => {
239
+ this.planningComplete.emit({
240
+ ...event.detail,
241
+ plan_type: this.selectedPlanType
242
+ });
243
+ };
244
+ render() {
245
+ if (!this.isOpen)
246
+ return null;
247
+ const modalStyle = {
248
+ zIndex: String(this.zIndex)
249
+ };
250
+ const containerClass = {
251
+ 'modal-container': true,
252
+ 'fullscreen': this.fullscreen,
253
+ 'pc-layout': true,
254
+ };
255
+ const overlayClass = {
256
+ 'modal-overlay': true,
257
+ 'fullscreen-overlay': this.fullscreen
258
+ };
259
+ // 检查是否有会话ID,如果有则直接显示聊天模态框
260
+ if (this.conversationId && !this.showChatModal) {
261
+ this.showChatModal = true;
262
+ }
263
+ 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.showChatModal && !this.conversationId && (h("div", { class: "input-container" }, h("div", { class: "plan-type-section" }, h("label", null, "\u9009\u62E9\u89C4\u5212\u7C7B\u578B"), h("div", { class: "plan-type-options" }, h("div", { class: `plan-type-option ${this.selectedPlanType === '长期规划' ? 'selected' : ''}`, onClick: () => this.handlePlanTypeChange('长期规划') }, h("div", { class: "option-icon" }, "\uD83D\uDCC8"), h("div", { class: "option-label" }, "\u957F\u671F\u89C4\u5212")), h("div", { class: `plan-type-option ${this.selectedPlanType === '转行建议' ? 'selected' : ''}`, onClick: () => this.handlePlanTypeChange('转行建议') }, h("div", { class: "option-icon" }, "\uD83D\uDD04"), h("div", { class: "option-label" }, "\u8F6C\u884C\u5EFA\u8BAE")), h("div", { class: `plan-type-option ${this.selectedPlanType === '晋升路径' ? 'selected' : ''}`, onClick: () => this.handlePlanTypeChange('晋升路径') }, h("div", { class: "option-icon" }, "\uD83D\uDE80"), h("div", { class: "option-label" }, "\u664B\u5347\u8DEF\u5F84")))), h("div", { class: "resume-upload-section" }, h("label", null, "\u4E0A\u4F20\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) => {
264
+ e.stopPropagation();
265
+ this.clearSelectedFile();
266
+ } }, "\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\u3001markdown\u3001pdf\u3001docx\u3001md \u683C\u5F0F"))))), h("button", { class: "submit-button", disabled: !this.selectedFile || this.isUploading || this.isSubmitting, onClick: this.handleStartPlanning }, this.isUploading ? '上传中...' : this.isSubmitting ? '处理中...' : '开始规划'), h("input", { type: "file", class: "file-input", onChange: this.handleFileChange, accept: ".pdf,.doc,.docx,.txt,.md" }))), this.showChatModal && (h("div", { class: "chat-modal-container" }, h("pcm-app-chat-modal", { isOpen: true, modalTitle: this.modalTitle, icon: this.icon, token: this.token, isShowHeader: this.isShowHeader, isNeedClose: this.isShowHeader, zIndex: this.zIndex, botId: "3022316191018898", fullscreen: this.fullscreen, conversationId: this.conversationId, defaultQuery: this.defaultQuery, enableVoice: false, customInputs: this.conversationId ? undefined : {
267
+ ...this.customInputs,
268
+ file_url: this.uploadedFileInfo?.cos_key,
269
+ type: this.selectedPlanType
270
+ }, interviewMode: "text", onModalClosed: this.handleClose, onStreamComplete: this.handleStreamComplete, onConversationStart: this.handleConversationStart, onInterviewComplete: this.handlePlanningComplete }))))));
271
+ }
272
+ static get watchers() { return {
273
+ "isOpen": ["handleIsOpenChange"]
274
+ }; }
275
+ static get style() { return pcmZyghModalCss + globalCss; }
276
+ }, [1, "pcm-zygh-modal", {
277
+ "modalTitle": [1, "modal-title"],
278
+ "token": [1],
279
+ "isOpen": [1028, "is-open"],
280
+ "icon": [1],
281
+ "zIndex": [2, "z-index"],
282
+ "isShowHeader": [4, "is-show-header"],
283
+ "isNeedClose": [4, "is-need-close"],
284
+ "conversationId": [1025, "conversation-id"],
285
+ "defaultQuery": [1, "default-query"],
286
+ "fullscreen": [4],
287
+ "customInputs": [16],
288
+ "selectedFile": [32],
289
+ "isUploading": [32],
290
+ "uploadedFileInfo": [32],
291
+ "showChatModal": [32],
292
+ "isSubmitting": [32],
293
+ "selectedPlanType": [32],
294
+ "isTransitioning": [32],
295
+ "transitionTimer": [32]
296
+ }, undefined, {
297
+ "isOpen": ["handleIsOpenChange"]
298
+ }]);
299
+ function defineCustomElement$1() {
300
+ if (typeof customElements === "undefined") {
301
+ return;
302
+ }
303
+ const components = ["pcm-zygh-modal", "pcm-app-chat-modal", "pcm-chat-message"];
304
+ components.forEach(tagName => { switch (tagName) {
305
+ case "pcm-zygh-modal":
306
+ if (!customElements.get(tagName)) {
307
+ customElements.define(tagName, ZyghModal);
308
+ }
309
+ break;
310
+ case "pcm-app-chat-modal":
311
+ if (!customElements.get(tagName)) {
312
+ defineCustomElement$3();
313
+ }
314
+ break;
315
+ case "pcm-chat-message":
316
+ if (!customElements.get(tagName)) {
317
+ defineCustomElement$2();
318
+ }
319
+ break;
320
+ } });
321
+ }
322
+ defineCustomElement$1();
323
+
324
+ const PcmZyghModal = ZyghModal;
325
+ const defineCustomElement = defineCustomElement$1;
326
+
327
+ export { PcmZyghModal, defineCustomElement };
328
+ //# sourceMappingURL=pcm-zygh-modal.js.map
329
+
330
+ //# sourceMappingURL=pcm-zygh-modal.js.map
@@ -0,0 +1 @@
1
+ {"file":"pcm-zygh-modal.js","mappings":";;;;AAAA,MAAM,eAAe,GAAG,65GAA65G;;ACAr7G,MAAM,SAAS,GAAG,61HAA61H;;MCal2H,SAAS,iBAAAA,kBAAA,CAAA,MAAA,SAAA,SAAAC,CAAA,CAAA;;;;;;;;;;;;AAClB;;AAEG;IACK,UAAU,GAAW,QAAQ;AAErC;;AAEG;IAC2B,KAAK,GAAW,EAAE;AAEhD;;AAEG;IACsB,MAAM,GAAY,KAAK;AAEhD;;AAEG;AACM,IAAA,WAAW;AAEpB;;AAEG;AACK,IAAA,IAAI;AAEZ;;AAEG;IACK,MAAM,GAAY,IAAI;AAE9B;;AAEG;IACK,YAAY,GAAY,IAAI;AAEpC;;AAEG;IACK,WAAW,GAAY,IAAI;AAEnC;;AAEG;AAC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AI,CAAC,gBAAgB,EAC/B,MAAM,EAAC,0BAA0B,EAAA,CACnC,CACA,CACT,EAGA,IAAI,CAAC,aAAa,KACf,CAAK,CAAA,KAAA,EAAA,EAAA,KAAK,EAAC,sBAAsB,EAAA,EAC7B,CAAA,CAAA,oBAAA,EAAA,EACI,MAAM,EAAE,IAAI,EACZ,UAAU,EAAE,IAAI,CAAC,UAAU,EAC3B,IAAI,EAAE,IAAI,CAAC,IAAI,EACf,KAAK,EAAE,IAAI,CAAC,KAAK,EACjB,YAAY,EAAE,IAAI,CAAC,YAAY,EAC/B,WAAW,EAAE,IAAI,CAAC,YAAY,EAC9B,MAAM,EAAE,IAAI,CAAC,MAAM,EACnB,KAAK,EAAC,kBAAkB,EACxB,UAAU,EAAE,IAAI,CAAC,UAAU,EAC3B,cAAc,EAAE,IAAI,CAAC,cAAc,EACnC,YAAY,EAAE,IAAI,CAAC,YAAY,EAC/B,WAAW,EAAE,KAAK,EAClB,YAAY,EAAE,IAAI,CAAC,cAAc,GAAG,SAAS,GAAG;gBAC5C,GAAG,IAAI,CAAC,YAAY;AACpB,gBAAA,QAAQ,EAAE,IAAI,CAAC,gBAAgB,EAAE,OAAO;gBACxC,IAAI,EAAE,IAAI,CAAC;AACd,aAAA,EACD,aAAa,EAAC,MAAM,EACpB,aAAa,EAAE,IAAI,CAAC,WAAW,EAC/B,gBAAgB,EAAE,IAAI,CAAC,oBAAoB,EAC3C,mBAAmB,EAAE,IAAI,CAAC,uBAAuB,EACjD,mBAAmB,EAAE,IAAI,CAAC,sBAAsB,GAC9B,CACpB,CACT,CACC,CACJ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":["__stencil_proxyCustomElement","HTMLElement"],"sources":["src/components/pcm-zygh-modal/pcm-zygh-modal.css?tag=pcm-zygh-modal&encapsulation=shadow","src/global/global.css?tag=pcm-zygh-modal&encapsulation=shadow","src/components/pcm-zygh-modal/pcm-zygh-modal.tsx"],"sourcesContent":[".modal-overlay {\r\n position: fixed;\r\n top: 0;\r\n left: 0;\r\n right: 0;\r\n bottom: 0;\r\n background-color: rgba(0, 0, 0, 0.5);\r\n display: flex;\r\n justify-content: center;\r\n align-items: center;\r\n z-index: 1000;\r\n}\r\n\r\n.fullscreen-overlay {\r\n background-color: rgba(0, 0, 0, 0.7);\r\n}\r\n\r\n.modal-container {\r\n background-color: #fff;\r\n border-radius: 8px;\r\n box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);\r\n width: 90%;\r\n max-width: 800px;\r\n max-height: 90vh;\r\n display: flex;\r\n flex-direction: column;\r\n overflow: hidden;\r\n}\r\n\r\n.fullscreen {\r\n width: 100%;\r\n height: 100%;\r\n max-width: 100%;\r\n max-height: 100%;\r\n border-radius: 0;\r\n}\r\n\r\n.pc-layout {\r\n width: 90%;\r\n max-width: 800px;\r\n max-height: 90vh;\r\n}\r\n\r\n.mobile-layout {\r\n width: 100%;\r\n height: 100%;\r\n max-width: 100%;\r\n max-height: 100%;\r\n border-radius: 0;\r\n}\r\n\r\n.modal-header {\r\n display: flex;\r\n justify-content: space-between;\r\n align-items: center;\r\n padding: 16px 20px;\r\n border-bottom: 1px solid #f0f0f0;\r\n background-color: #fff;\r\n}\r\n\r\n.header-left {\r\n display: flex;\r\n align-items: center;\r\n font-size: 16px;\r\n font-weight: 600;\r\n color: #333;\r\n}\r\n\r\n.header-icon {\r\n width: 24px;\r\n height: 24px;\r\n margin-right: 8px;\r\n border-radius: 4px;\r\n}\r\n\r\n.close-button {\r\n background: none;\r\n border: none;\r\n font-size: 20px;\r\n cursor: pointer;\r\n color: #999;\r\n display: flex;\r\n align-items: center;\r\n justify-content: center;\r\n width: 32px;\r\n height: 32px;\r\n border-radius: 50%;\r\n transition: background-color 0.3s;\r\n}\r\n\r\n.close-button:hover {\r\n background-color: #f5f5f5;\r\n color: #666;\r\n}\r\n\r\n.input-container {\r\n padding: 20px;\r\n overflow-y: auto;\r\n flex: 1;\r\n display: flex;\r\n flex-direction: column;\r\n gap: 20px;\r\n}\r\n\r\n.plan-type-section {\r\n display: flex;\r\n flex-direction: column;\r\n gap: 10px;\r\n}\r\n\r\n.plan-type-section label {\r\n font-weight: 600;\r\n color: #333;\r\n margin-bottom: 8px;\r\n}\r\n\r\n.plan-type-options {\r\n display: flex;\r\n gap: 15px;\r\n flex-wrap: wrap;\r\n}\r\n\r\n.plan-type-option {\r\n flex: 1;\r\n min-width: 120px;\r\n border: 1px solid #e8e8e8;\r\n border-radius: 8px;\r\n padding: 15px;\r\n cursor: pointer;\r\n display: flex;\r\n flex-direction: column;\r\n align-items: center;\r\n transition: all 0.3s;\r\n}\r\n\r\n.plan-type-option:hover {\r\n border-color: #1890ff;\r\n background-color: #f0f7ff;\r\n}\r\n\r\n.plan-type-option.selected {\r\n border-color: #1890ff;\r\n background-color: #e6f7ff;\r\n box-shadow: 0 2px 8px rgba(24, 144, 255, 0.2);\r\n}\r\n\r\n.option-icon {\r\n font-size: 24px;\r\n margin-bottom: 8px;\r\n}\r\n\r\n.option-label {\r\n font-size: 14px;\r\n font-weight: 500;\r\n color: #333;\r\n}\r\n\r\n.resume-upload-section {\r\n display: flex;\r\n flex-direction: column;\r\n gap: 8px;\r\n}\r\n\r\n.resume-upload-section label {\r\n font-weight: 600;\r\n color: #333;\r\n}\r\n\r\n.upload-area {\r\n border: 2px dashed #d9d9d9;\r\n border-radius: 4px;\r\n text-align: center;\r\n cursor: pointer;\r\n transition: border-color 0.3s, background-color 0.3s;\r\n \r\n}\r\n\r\n.upload-area:hover {\r\n border-color: #1890ff;\r\n background-color: #f0f7ff;\r\n}\r\n\r\n.upload-placeholder {\r\n display: flex;\r\n flex-direction: column;\r\n align-items: center;\r\n color: #666;\r\n}\r\n\r\n.upload-placeholder svg {\r\n color: #1890ff;\r\n margin-bottom: 8px;\r\n}\r\n\r\n.upload-placeholder p {\r\n margin: 4px 0;\r\n}\r\n\r\n.upload-hint {\r\n font-size: 12px;\r\n color: #999;\r\n}\r\n\r\n.file-info {\r\n display: flex;\r\n align-items: center;\r\n justify-content: space-between;\r\n background-color: #f5f5f5;\r\n padding: 8px 12px;\r\n border-radius: 4px;\r\n}\r\n\r\n.file-info span {\r\n flex: 1;\r\n display: -webkit-box;\r\n -webkit-line-clamp: 2;\r\n -webkit-box-orient: vertical;\r\n overflow: hidden;\r\n text-overflow: ellipsis;\r\n word-break: break-word;\r\n margin-right: 8px;\r\n max-width: calc(100% - 32px);\r\n line-height: 1.4;\r\n}\r\n\r\n.remove-file {\r\n flex-shrink: 0;\r\n background: none;\r\n border: none;\r\n color: #ff4d4f;\r\n cursor: pointer;\r\n font-size: 16px;\r\n padding: 4px 8px;\r\n border-radius: 50%;\r\n transition: background-color 0.3s;\r\n}\r\n\r\n.remove-file:hover {\r\n background-color: #fff1f0;\r\n}\r\n\r\n.file-input {\r\n display: none;\r\n}\r\n\r\n.submit-button {\r\n background-color: #1890ff;\r\n color: white;\r\n border: none;\r\n border-radius: 4px;\r\n padding: 12px 20px;\r\n font-size: 16px;\r\n font-weight: 500;\r\n cursor: pointer;\r\n transition: background-color 0.3s;\r\n margin-top: 10px;\r\n}\r\n\r\n.submit-button:hover {\r\n background-color: #40a9ff;\r\n}\r\n\r\n.submit-button:disabled {\r\n background-color: #d9d9d9;\r\n cursor: not-allowed;\r\n}\r\n\r\n.chat-modal-container {\r\n flex: 1;\r\n display: flex;\r\n flex-direction: column;\r\n overflow: hidden;\r\n} ","/* 模态框基础样式 */\r\n.modal-overlay {\r\n position: fixed;\r\n top: 0;\r\n left: 0;\r\n right: 0;\r\n bottom: 0;\r\n background-color: rgba(0, 0, 0, 0.5);\r\n display: flex;\r\n justify-content: center;\r\n align-items: center;\r\n z-index: 1000;\r\n overflow-y: auto;\r\n padding: 20px;\r\n}\r\n\r\n/* 全屏模式下取消 padding */\r\n.fullscreen-overlay {\r\n padding: 0;\r\n background-color: rgba(0, 0, 0, 0.7);\r\n}\r\n\r\n.modal-container {\r\n background-color: #fff;\r\n border-radius: 8px;\r\n width: 100%;\r\n display: flex;\r\n flex-direction: column;\r\n position: relative;\r\n margin: auto;\r\n transition: all 0.3s ease-out;\r\n overflow: hidden;\r\n}\r\n\r\n/* 全屏模式样式 */\r\n.modal-container.fullscreen {\r\n width: 100vw;\r\n max-width: none;\r\n height: 100%;\r\n border-radius: 0;\r\n margin: 0;\r\n display: flex;\r\n flex-direction: column;\r\n height: 100vh;\r\n max-height: 100vh;\r\n}\r\n\r\n/* PC端布局 */\r\n.pc-layout {\r\n width: 80%;\r\n max-width: 500px;\r\n min-width: 320px;\r\n}\r\n\r\n/* 移动端布局 */\r\n.mobile-layout {\r\n width: 100%;\r\n height: 100%;\r\n border-radius: 0;\r\n}\r\n\r\n/* 响应式布局 */\r\n@media screen and (max-width: 768px) {\r\n .pc-layout {\r\n width: 95%;\r\n }\r\n\r\n .modal-overlay {\r\n padding: 0;\r\n }\r\n\r\n .modal-container.fullscreen {\r\n /* 支持 iOS Safari */\r\n height: -webkit-fill-available;\r\n max-height: -webkit-fill-available;\r\n /* 确保内容不会被顶部状态栏和底部工具栏遮挡 */\r\n padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);\r\n margin-top: 40px;\r\n height: calc(100% - 40px);\r\n max-height: calc(100% - 40px);\r\n border-radius: 16px 16px 0 0;\r\n }\r\n\r\n .modal-container.mobile-layout {\r\n width: 100%;\r\n height: 100vh;\r\n max-height: 100vh;\r\n min-height: 100vh;\r\n border-radius: 0;\r\n margin: 0;\r\n display: flex;\r\n flex-direction: column;\r\n }\r\n}\r\n\r\n/* 模态框头部样式 */\r\n.modal-header {\r\n display: flex;\r\n justify-content: space-between;\r\n align-items: center;\r\n padding: 4px 16px;\r\n height: 50px;\r\n border-bottom: 1px solid #e8e8e8;\r\n flex-shrink: 0;\r\n}\r\n\r\n.header-left {\r\n display: flex;\r\n align-items: center;\r\n gap: 8px;\r\n}\r\n\r\n.header-icon {\r\n width: 24px;\r\n height: 24px;\r\n}\r\n\r\n.close-button {\r\n background: transparent;\r\n border: none;\r\n cursor: pointer;\r\n padding: 8px;\r\n display: flex;\r\n align-items: center;\r\n justify-content: center;\r\n width: 32px;\r\n height: 32px;\r\n border-radius: 4px;\r\n}\r\n\r\n.close-button:hover {\r\n background-color: rgba(0, 0, 0, 0.04);\r\n}\r\n\r\n.close-button span {\r\n font-size: 24px;\r\n line-height: 1;\r\n color: #999;\r\n}\r\n\r\n.close-button:hover span {\r\n color: #666;\r\n}\r\n\r\n\r\n/* 文件上传区域通用样式 */\r\n.upload-area {\r\n border: 2px dashed #ddd;\r\n border-radius: 8px;\r\n cursor: pointer;\r\n transition: all 0.3s ease;\r\n margin-bottom: 20px;\r\n width: 100%;\r\n}\r\n\r\n.upload-area:hover {\r\n border-color: #1890ff;\r\n background-color: rgba(24, 144, 255, 0.05);\r\n}\r\n\r\n\r\n.upload-placeholder {\r\n display: flex;\r\n flex-direction: column;\r\n align-items: center;\r\n color: #666;\r\n}\r\n\r\n.upload-placeholder svg {\r\n color: #1890ff;\r\n margin-bottom: 8px;\r\n}\r\n\r\n.upload-placeholder p {\r\n margin: 4px 0;\r\n}\r\n\r\n.upload-hint {\r\n font-size: 0.8rem;\r\n color: #999;\r\n margin-top: 0.5rem;\r\n}\r\n\r\n.file-info {\r\n display: flex;\r\n align-items: center;\r\n justify-content: space-between;\r\n padding: 8px;\r\n background: #f9f9f9;\r\n border: 1px solid #e8e8e8;\r\n border-radius: 4px;\r\n}\r\n\r\n.file-info span {\r\n overflow: hidden;\r\n text-overflow: ellipsis;\r\n white-space: nowrap;\r\n max-width: calc(100% - 30px);\r\n}\r\n\r\n.remove-file {\r\n background: transparent;\r\n border: none;\r\n color: #999;\r\n cursor: pointer;\r\n padding: 4px 8px;\r\n font-size: 16px;\r\n line-height: 1;\r\n border-radius: 4px;\r\n transition: all 0.2s;\r\n}\r\n\r\n.remove-file:hover {\r\n background-color: #f0f0f0;\r\n color: #666;\r\n}\r\n\r\n.file-input {\r\n display: none;\r\n}\r\n\r\n\r\n\r\n/* 输入容器样式 */\r\n.input-container {\r\n padding: 20px;\r\n display: flex;\r\n flex-direction: column;\r\n height: calc(100% - 50px);\r\n /* 减去header高度 */\r\n overflow-y: auto;\r\n}\r\n\r\n.input-container h3 {\r\n margin-top: 0;\r\n margin-bottom: 20px;\r\n font-size: 18px;\r\n color: #333;\r\n text-align: center;\r\n}\r\n\r\n/* JD输入区域样式 */\r\n.jd-input-section {\r\n margin-bottom: 20px;\r\n}\r\n\r\n.jd-input-section label {\r\n display: block;\r\n margin-bottom: 8px;\r\n font-weight: 500;\r\n color: #333;\r\n}\r\n\r\n.job-description-textarea {\r\n width: 100%;\r\n border: 1px solid #ddd;\r\n border-radius: 4px;\r\n resize: vertical;\r\n font-family: inherit;\r\n font-size: 14px;\r\n line-height: 1.5;\r\n transition: border-color 0.3s;\r\n}\r\n\r\n.job-description-textarea:focus {\r\n outline: none;\r\n border-color: #1890ff;\r\n box-shadow: 0 0 0 2px rgba(24, 144, 255, 0.2);\r\n}\r\n\r\n/* 简历上传区域样式 */\r\n.resume-upload-section {\r\n margin-bottom: 20px;\r\n width: 100%;\r\n display: flex;\r\n flex-direction: column;\r\n align-items: center;\r\n}\r\n\r\n.resume-upload-section label {\r\n display: block;\r\n margin-bottom: 8px;\r\n font-weight: 500;\r\n color: #333;\r\n align-self: flex-start;\r\n}\r\n\r\n\r\n/* 提交按钮通用样式 */\r\n.submit-button {\r\n margin-top: 10px;\r\n padding: 10px 30px;\r\n background: #1890ff;\r\n color: white;\r\n border: none;\r\n border-radius: 4px;\r\n font-size: 16px;\r\n cursor: pointer;\r\n transition: all 0.3s ease;\r\n width: 100%;\r\n max-width: 400px;\r\n align-self: center;\r\n /* 确保按钮居中 */\r\n}\r\n\r\n.submit-button:disabled {\r\n background: #ccc;\r\n cursor: not-allowed;\r\n}\r\n\r\n.submit-button:hover:not(:disabled) {\r\n background: #40a9ff;\r\n}\r\n\r\n/* 聊天模态框容器 */\r\n.chat-modal-container {\r\n position: absolute;\r\n top: 0;\r\n left: 0;\r\n right: 0;\r\n bottom: 0;\r\n display: flex;\r\n flex-direction: column;\r\n}","import { Component, Prop, h, State, Element, Event, EventEmitter, Watch } from '@stencil/core';\r\nimport { uploadFileToBackend, FileUploadResponse, sendHttpRequest } from '../../utils/utils';\r\n\r\n/**\r\n * 职业规划类型枚举\r\n */\r\nexport type CareerPlanType = '长期规划' | '转行建议' | '晋升路径';\r\n\r\n@Component({\r\n tag: 'pcm-zygh-modal',\r\n styleUrls: ['pcm-zygh-modal.css','../../global/global.css'],\r\n shadow: true,\r\n})\r\nexport class ZyghModal {\r\n /**\r\n * 模态框标题\r\n */\r\n @Prop() modalTitle: string = '职业规划助手';\r\n\r\n /**\r\n * API鉴权密钥\r\n */\r\n @Prop({ attribute: 'token' }) token: string = '';\r\n\r\n /**\r\n * 是否显示聊天模态框\r\n */\r\n @Prop({ mutable: true }) isOpen: boolean = false;\r\n\r\n /**\r\n * 当点击模态框关闭时触发\r\n */\r\n @Event() modalClosed: EventEmitter<void>;\r\n\r\n /**\r\n * 应用图标URL\r\n */\r\n @Prop() icon?: string;\r\n\r\n /**\r\n * 聊天框的页面层级\r\n */\r\n @Prop() zIndex?: number = 1000;\r\n\r\n /**\r\n * 是否展示顶部标题栏\r\n */\r\n @Prop() isShowHeader: boolean = true;\r\n\r\n /**\r\n * 是否展示右上角的关闭按钮\r\n */\r\n @Prop() isNeedClose: boolean = true;\r\n\r\n /**\r\n * 会话ID,传入继续对话,否则创建新会话\r\n */\r\n @Prop({ mutable: true }) conversationId?: string;\r\n\r\n /**\r\n * 默认查询文本\r\n */\r\n @Prop() defaultQuery: string = '';\r\n\r\n /**\r\n * 是否以全屏模式打开,移动端建议设置为true\r\n */\r\n @Prop() fullscreen: boolean = false;\r\n\r\n\r\n /**\r\n * 自定义输入参数\r\n */\r\n @Prop() customInputs: { [key: string]: any } = {};\r\n\r\n /**\r\n * 上传成功事件\r\n */\r\n @Event() uploadSuccess: EventEmitter<FileUploadResponse>;\r\n\r\n /**\r\n * 流式输出完成事件\r\n */\r\n @Event() streamComplete: EventEmitter<{\r\n conversation_id: string;\r\n event: string;\r\n message_id: string;\r\n id: string;\r\n }>;\r\n\r\n /**\r\n * 新会话开始的回调,只会在一轮对话开始时触发一次\r\n */\r\n @Event() conversationStart: EventEmitter<{\r\n conversation_id: string;\r\n event: string;\r\n message_id: string;\r\n id: string;\r\n }>;\r\n\r\n /**\r\n * 当聊天完成时触发\r\n */\r\n @Event() planningComplete: EventEmitter<{\r\n conversation_id: string;\r\n plan_type: CareerPlanType;\r\n }>;\r\n\r\n /**\r\n * API密钥验证失败事件\r\n */\r\n @Event() apiKeyInvalid: EventEmitter<void>;\r\n\r\n @State() selectedFile: File | null = null;\r\n @State() isUploading: boolean = false;\r\n @State() uploadedFileInfo: FileUploadResponse | null = null;\r\n @State() showChatModal: boolean = false;\r\n @State() isSubmitting: boolean = false;\r\n @State() selectedPlanType: CareerPlanType = '长期规划';\r\n\r\n // 添加新的状态来控制过渡动画\r\n @State() isTransitioning: boolean = false;\r\n @State() transitionTimer: any = null;\r\n\r\n // 使用 @Element 装饰器获取组件的 host 元素\r\n @Element() hostElement: HTMLElement;\r\n\r\n private handleClose = () => {\r\n this.isOpen = false;\r\n this.modalClosed.emit();\r\n };\r\n\r\n private handleFileChange = (event: Event) => {\r\n const input = event.target as HTMLInputElement;\r\n if (input.files && input.files.length > 0) {\r\n this.selectedFile = input.files[0];\r\n }\r\n };\r\n\r\n private handleUploadClick = () => {\r\n const fileInput = this.hostElement.shadowRoot?.querySelector('.file-input') as HTMLInputElement;\r\n fileInput?.click();\r\n };\r\n\r\n private clearSelectedFile = () => {\r\n this.selectedFile = null;\r\n this.uploadedFileInfo = null;\r\n const fileInput = this.hostElement.shadowRoot?.querySelector('.file-input') as HTMLInputElement;\r\n if (fileInput) {\r\n fileInput.value = '';\r\n }\r\n };\r\n\r\n private handlePlanTypeChange = (type: CareerPlanType) => {\r\n this.selectedPlanType = type;\r\n };\r\n\r\n private async uploadFile() {\r\n if (!this.selectedFile) return;\r\n\r\n this.isUploading = true;\r\n\r\n try {\r\n const result = await uploadFileToBackend(this.selectedFile, {\r\n 'authorization': 'Bearer ' + this.token\r\n });\r\n \r\n this.uploadedFileInfo = result;\r\n this.uploadSuccess.emit(result);\r\n } catch (error) {\r\n console.error('文件上传错误:', error);\r\n this.clearSelectedFile();\r\n alert(error instanceof Error ? error.message : '文件上传失败,请重试');\r\n } finally {\r\n this.isUploading = false;\r\n }\r\n }\r\n\r\n private handleStartPlanning = async () => {\r\n if (!this.selectedFile) {\r\n alert('请上传简历');\r\n return;\r\n }\r\n\r\n this.isSubmitting = true;\r\n\r\n try {\r\n // 如果还没上传,先上传文件\r\n if (!this.uploadedFileInfo) {\r\n await this.uploadFile();\r\n if (!this.uploadedFileInfo) {\r\n this.isSubmitting = false;\r\n return; // 上传失败\r\n }\r\n }\r\n\r\n console.log('传递的customInputs:', {\r\n ...this.customInputs,\r\n file_url: this.uploadedFileInfo.cos_key,\r\n plan_type: this.selectedPlanType\r\n });\r\n\r\n // 直接显示聊天模态框\r\n this.showChatModal = true;\r\n } catch (error) {\r\n console.error('开始规划时出错:', error);\r\n alert('开始规划时出错,请重试');\r\n } finally {\r\n this.isSubmitting = false;\r\n }\r\n };\r\n\r\n @Watch('isOpen')\r\n handleIsOpenChange(newValue: boolean) {\r\n if (!newValue) {\r\n // 重置状态\r\n this.clearSelectedFile();\r\n this.showChatModal = false;\r\n \r\n // 清除可能存在的计时器\r\n if (this.transitionTimer) {\r\n clearTimeout(this.transitionTimer);\r\n this.transitionTimer = null;\r\n }\r\n } else {\r\n // 当模态框打开时,验证API密钥\r\n this.verifyApiKey();\r\n \r\n if (this.conversationId) {\r\n // 如果有会话ID,直接显示聊天模态框\r\n this.showChatModal = true;\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * 验证API密钥\r\n */\r\n private async verifyApiKey() {\r\n if (!this.token) {\r\n this.apiKeyInvalid.emit();\r\n return;\r\n }\r\n \r\n try {\r\n const response = await sendHttpRequest({\r\n url: '/sdk/v1/user',\r\n method: 'GET',\r\n headers: {\r\n 'Authorization': `Bearer ${this.token}`\r\n }\r\n });\r\n\r\n if (!response.success) {\r\n throw new Error(response.message || 'API密钥验证失败');\r\n }\r\n \r\n // 验证成功,继续正常流程\r\n } catch (error) {\r\n console.error('API密钥验证错误:', error);\r\n // 通知父组件API密钥无效\r\n this.apiKeyInvalid.emit();\r\n }\r\n }\r\n\r\n componentWillLoad() {\r\n // 检查 customInputs 中是否有 plan_type\r\n if (this.customInputs && this.customInputs.plan_type) {\r\n this.selectedPlanType = this.customInputs.plan_type;\r\n }\r\n }\r\n\r\n // 处理流式输出完成事件\r\n private handleStreamComplete = (event: CustomEvent) => {\r\n // 将事件转发出去\r\n this.streamComplete.emit(event.detail);\r\n };\r\n\r\n // 处理会话开始事件\r\n private handleConversationStart = (event: CustomEvent) => {\r\n this.conversationStart.emit(event.detail);\r\n };\r\n\r\n // 处理规划完成事件\r\n private handlePlanningComplete = (event: CustomEvent) => {\r\n this.planningComplete.emit({\r\n ...event.detail,\r\n plan_type: this.selectedPlanType\r\n });\r\n };\r\n\r\n render() {\r\n if (!this.isOpen) return null;\r\n\r\n const modalStyle = {\r\n zIndex: String(this.zIndex)\r\n };\r\n\r\n const containerClass = {\r\n 'modal-container': true,\r\n 'fullscreen': this.fullscreen,\r\n 'pc-layout': true,\r\n };\r\n \r\n const overlayClass = {\r\n 'modal-overlay': true,\r\n 'fullscreen-overlay': this.fullscreen\r\n };\r\n\r\n // 检查是否有会话ID,如果有则直接显示聊天模态框\r\n if (this.conversationId && !this.showChatModal) {\r\n this.showChatModal = true;\r\n }\r\n\r\n return (\r\n <div class={overlayClass} style={modalStyle}>\r\n <div class={containerClass}>\r\n {this.isShowHeader && (\r\n <div class=\"modal-header\">\r\n <div class=\"header-left\">\r\n {this.icon && <img src={this.icon} class=\"header-icon\" alt=\"应用图标\" />}\r\n <div>{this.modalTitle}</div>\r\n </div>\r\n {this.isNeedClose && (\r\n <button class=\"close-button\" onClick={this.handleClose}>\r\n <span>×</span>\r\n </button>\r\n )}\r\n </div>\r\n )}\r\n\r\n {/* 输入界面 - 仅在不显示聊天模态框且没有会话ID时显示 */}\r\n {!this.showChatModal && !this.conversationId && (\r\n <div class=\"input-container\">\r\n \r\n {/* 规划类型选择 */}\r\n <div class=\"plan-type-section\">\r\n <label>选择规划类型</label>\r\n <div class=\"plan-type-options\">\r\n <div \r\n class={`plan-type-option ${this.selectedPlanType === '长期规划' ? 'selected' : ''}`}\r\n onClick={() => this.handlePlanTypeChange('长期规划')}\r\n >\r\n <div class=\"option-icon\">📈</div>\r\n <div class=\"option-label\">长期规划</div>\r\n </div>\r\n <div \r\n class={`plan-type-option ${this.selectedPlanType === '转行建议' ? 'selected' : ''}`}\r\n onClick={() => this.handlePlanTypeChange('转行建议')}\r\n >\r\n <div class=\"option-icon\">🔄</div>\r\n <div class=\"option-label\">转行建议</div>\r\n </div>\r\n <div \r\n class={`plan-type-option ${this.selectedPlanType === '晋升路径' ? 'selected' : ''}`}\r\n onClick={() => this.handlePlanTypeChange('晋升路径')}\r\n >\r\n <div class=\"option-icon\">🚀</div>\r\n <div class=\"option-label\">晋升路径</div>\r\n </div>\r\n </div>\r\n </div>\r\n \r\n {/* 简历上传区域 */}\r\n <div class=\"resume-upload-section\">\r\n <label>上传简历</label>\r\n <div class=\"upload-area\" onClick={this.handleUploadClick}>\r\n {this.selectedFile ? (\r\n <div class=\"file-info\">\r\n <span>{this.selectedFile.name}</span>\r\n <button class=\"remove-file\" onClick={(e) => {\r\n e.stopPropagation();\r\n this.clearSelectedFile();\r\n }}>×</button>\r\n </div>\r\n ) : (\r\n <div class=\"upload-placeholder\">\r\n <svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" width=\"48\" height=\"48\">\r\n <path stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M12 4v16m0-16l-4 4m4-4l4 4\" />\r\n </svg>\r\n <p>点击上传简历</p>\r\n <p class=\"upload-hint\">支持 txt、markdown、pdf、docx、md 格式</p>\r\n </div>\r\n )}\r\n </div>\r\n </div>\r\n\r\n <button\r\n class=\"submit-button\"\r\n disabled={!this.selectedFile || this.isUploading || this.isSubmitting}\r\n onClick={this.handleStartPlanning}\r\n >\r\n {this.isUploading ? '上传中...' : this.isSubmitting ? '处理中...' : '开始规划'}\r\n </button>\r\n\r\n <input\r\n type=\"file\"\r\n class=\"file-input\"\r\n onChange={this.handleFileChange}\r\n accept=\".pdf,.doc,.docx,.txt,.md\"\r\n />\r\n </div>\r\n )}\r\n\r\n {/* 聊天界面 - 在显示聊天模态框时显示 */}\r\n {this.showChatModal && (\r\n <div class=\"chat-modal-container\">\r\n <pcm-app-chat-modal\r\n isOpen={true}\r\n modalTitle={this.modalTitle}\r\n icon={this.icon}\r\n token={this.token}\r\n isShowHeader={this.isShowHeader} \r\n isNeedClose={this.isShowHeader} \r\n zIndex={this.zIndex}\r\n botId=\"3022316191018898\"\r\n fullscreen={this.fullscreen}\r\n conversationId={this.conversationId}\r\n defaultQuery={this.defaultQuery}\r\n enableVoice={false}\r\n customInputs={this.conversationId ? undefined : {\r\n ...this.customInputs,\r\n file_url: this.uploadedFileInfo?.cos_key,\r\n type: this.selectedPlanType\r\n }}\r\n interviewMode=\"text\"\r\n onModalClosed={this.handleClose}\r\n onStreamComplete={this.handleStreamComplete}\r\n onConversationStart={this.handleConversationStart}\r\n onInterviewComplete={this.handlePlanningComplete}\r\n ></pcm-app-chat-modal>\r\n </div>\r\n )}\r\n </div>\r\n </div>\r\n );\r\n }\r\n} "],"version":3}
@@ -0,0 +1,189 @@
1
+ /**
2
+ * API域名配置
3
+ */
4
+ // export const API_DOMAIN = 'http://192.168.17.194:8000';
5
+ const API_DOMAIN = 'https://pcm_api.ylzhaopin.com';
6
+ function format(first, middle, last) {
7
+ return (first || '') + (middle ? ` ${middle}` : '') + (last ? ` ${last}` : '');
8
+ }
9
+ /**
10
+ * 发送 SSE 流式请求
11
+ * @param config 请求配置
12
+ * @returns Promise<void>
13
+ */
14
+ const sendSSERequest = async (config) => {
15
+ const { url, method, headers = {}, data, onMessage, onError, onComplete } = config;
16
+ try {
17
+ // 使用 API_DOMAIN 拼接完整的请求URL
18
+ const requestUrl = `${API_DOMAIN}${url}`;
19
+ const response = await fetch(requestUrl, {
20
+ method,
21
+ headers: {
22
+ 'Accept': 'text/event-stream',
23
+ 'Content-Type': 'application/json',
24
+ ...headers
25
+ },
26
+ body: data ? JSON.stringify(data) : undefined
27
+ });
28
+ if (!response.ok) {
29
+ throw new Error(`HTTP error! status: ${response.status}`);
30
+ }
31
+ const reader = response.body?.getReader();
32
+ if (!reader)
33
+ throw new Error('No reader available');
34
+ const decoder = new TextDecoder();
35
+ let buffer = '';
36
+ while (true) {
37
+ const { value, done } = await reader.read();
38
+ if (done)
39
+ break;
40
+ buffer += decoder.decode(value, { stream: true });
41
+ // 处理缓冲区中的完整消息
42
+ const lines = buffer.split('\n');
43
+ buffer = lines.pop() || ''; // 保留最后一个不完整的行
44
+ for (const line of lines) {
45
+ if (line.startsWith('data:')) {
46
+ try {
47
+ const jsonStr = line.substring(5).trim();
48
+ if (!jsonStr)
49
+ continue;
50
+ const data = JSON.parse(jsonStr);
51
+ onMessage?.(data);
52
+ }
53
+ catch (e) {
54
+ console.error('解析 SSE 数据错误:', e, '原始数据:', line);
55
+ }
56
+ }
57
+ }
58
+ }
59
+ onComplete?.();
60
+ }
61
+ catch (error) {
62
+ console.error('SSE 请求错误:', error);
63
+ onError?.(error);
64
+ }
65
+ };
66
+ /**
67
+ * 发送HTTP请求
68
+ * @param config 请求配置
69
+ * @returns Promise<HttpResponse>
70
+ */
71
+ const sendHttpRequest = async (config) => {
72
+ const { url, method = 'GET', headers = {}, params = {}, data, formData, onMessage } = config;
73
+ try {
74
+ // 构建URL和查询参数
75
+ const queryParams = new URLSearchParams();
76
+ Object.entries(params).forEach(([key, value]) => {
77
+ if (value !== undefined && value !== null) {
78
+ queryParams.append(key, String(value));
79
+ }
80
+ });
81
+ // 使用 API_DOMAIN 拼接完整的请求URL
82
+ let requestUrl = `${API_DOMAIN}${url}${queryParams.toString() ? `?${queryParams.toString()}` : ''}`;
83
+ // 创建请求配置对象
84
+ const requestConfig = {
85
+ method,
86
+ headers: formData ? { ...headers } : {
87
+ 'Content-Type': 'application/json',
88
+ ...headers
89
+ }
90
+ };
91
+ // 处理请求体
92
+ if (formData) {
93
+ // 如果提供了FormData,直接使用
94
+ requestConfig.body = formData;
95
+ }
96
+ else if (method !== 'GET' && method !== 'HEAD' && data) {
97
+ // 否则,如果是非GET/HEAD请求且有data,将其JSON序列化
98
+ requestConfig.body = JSON.stringify(data);
99
+ }
100
+ // 如果是 GET 方法且有 data,将其作为查询参数添加到 URL
101
+ if (method === 'GET' && data) {
102
+ const dataParams = new URLSearchParams();
103
+ Object.entries(data).forEach(([key, value]) => {
104
+ if (value !== undefined && value !== null) {
105
+ dataParams.append(key, String(value));
106
+ }
107
+ });
108
+ requestUrl += (queryParams.toString() ? '&' : '?') + dataParams.toString();
109
+ }
110
+ const response = await fetch(requestUrl, requestConfig);
111
+ const responseData = await response.json();
112
+ // 调用 onMessage 回调
113
+ if (onMessage) {
114
+ onMessage(responseData);
115
+ }
116
+ // 检查响应状态
117
+ if (!response.ok) {
118
+ console.error(`HTTP错误: ${response.status} ${response.statusText}`);
119
+ return {
120
+ success: false,
121
+ message: responseData.message || `HTTP错误: ${response.status}`,
122
+ error: responseData
123
+ };
124
+ }
125
+ // 检查业务状态码
126
+ if (responseData.code !== 0) {
127
+ console.error(`API错误: ${responseData.message}`);
128
+ return {
129
+ success: false,
130
+ message: responseData.message,
131
+ error: responseData
132
+ };
133
+ }
134
+ // 直接返回data
135
+ return {
136
+ success: true,
137
+ data: responseData.data
138
+ };
139
+ }
140
+ catch (error) {
141
+ console.error('HTTP请求错误:', error);
142
+ if (config.onError) {
143
+ config.onError(error);
144
+ }
145
+ return {
146
+ success: false,
147
+ error,
148
+ message: error instanceof Error ? error.message : '未知错误'
149
+ };
150
+ }
151
+ finally {
152
+ if (config.onComplete) {
153
+ config.onComplete();
154
+ }
155
+ }
156
+ };
157
+ /**
158
+ * 通过后端API上传文件
159
+ * @param file 要上传的文件
160
+ * @param headers 可选的请求头
161
+ * @returns Promise 包含上传结果
162
+ */
163
+ const uploadFileToBackend = async (file, headers) => {
164
+ const formData = new FormData();
165
+ formData.append('file', file);
166
+ try {
167
+ const response = await sendHttpRequest({
168
+ url: '/sdk/v1/files/upload',
169
+ method: 'POST',
170
+ headers: {
171
+ ...headers
172
+ },
173
+ formData
174
+ });
175
+ if (!response.success || !response.data) {
176
+ throw new Error(response.message || '文件上传失败');
177
+ }
178
+ return response.data;
179
+ }
180
+ catch (error) {
181
+ console.error('文件上传错误:', error);
182
+ throw error;
183
+ }
184
+ };
185
+
186
+ export { API_DOMAIN as A, sendSSERequest as a, format as f, sendHttpRequest as s, uploadFileToBackend as u };
187
+ //# sourceMappingURL=index-nVjZGfA8.js.map
188
+
189
+ //# sourceMappingURL=index-nVjZGfA8.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-nVjZGfA8.js","sources":["src/utils/utils.ts"],"sourcesContent":["/**\r\n * API域名配置\r\n */\r\n// export const API_DOMAIN = 'http://192.168.17.194:8000';\r\nexport const API_DOMAIN = 'https://pcm_api.ylzhaopin.com';\r\n\r\n\r\nexport function format(first?: string, middle?: string, last?: string): string {\r\n return (first || '') + (middle ? ` ${middle}` : '') + (last ? ` ${last}` : '');\r\n}\r\n\r\n// 添加类型定义\r\nexport interface UserInputMessageType {\r\n message: string;\r\n [key: string]: any;\r\n}\r\n\r\nexport interface WorkFlowNode {\r\n message_id?: string;\r\n conversation_id?: string;\r\n created_at?: string;\r\n event?: string;\r\n answer?: string;\r\n data?: {\r\n outputs?: {\r\n answer?: string;\r\n };\r\n status?: string;\r\n error?: any;\r\n };\r\n}\r\n\r\nexport interface MessageRound extends UserInputMessageType {\r\n id?: string;\r\n conversation_id?: string;\r\n created_at?: string;\r\n answer?: string;\r\n status?: string;\r\n error?: any;\r\n}\r\n\r\n/**\r\n * 将工作流节点转换为消息轮次\r\n * @param message_event 消息事件类型\r\n * @param inputMessage 用户输入消息\r\n * @param streamNode 工作流节点\r\n * @returns 消息轮次\r\n */\r\nexport const convertWorkflowStreamNodeToMessageRound = (\r\n message_event: string,\r\n inputMessage: UserInputMessageType,\r\n streamNode: WorkFlowNode,\r\n): MessageRound => {\r\n const messageRound: MessageRound = {\r\n ...inputMessage,\r\n };\r\n if (message_event === 'workflow_finished') messageRound.answer = streamNode.data?.outputs?.answer;\r\n if (message_event === 'agent_message' || message_event === 'message') messageRound.answer = streamNode?.answer;\r\n messageRound.id = streamNode.message_id;\r\n messageRound.conversation_id = streamNode.conversation_id;\r\n messageRound.created_at = streamNode.created_at;\r\n messageRound.status = streamNode.data?.status;\r\n messageRound.error = streamNode.data?.error;\r\n return messageRound;\r\n};\r\n\r\n/**\r\n * SSE 流式请求配置接口\r\n */\r\nexport interface SSERequestConfig {\r\n url: string;\r\n method: string;\r\n headers?: Record<string, string>;\r\n data?: any;\r\n onMessage?: (data: any) => void;\r\n onError?: (error: any) => void;\r\n onComplete?: () => void;\r\n}\r\n\r\n/**\r\n * 发送 SSE 流式请求\r\n * @param config 请求配置\r\n * @returns Promise<void>\r\n */\r\nexport const sendSSERequest = async (config: SSERequestConfig): Promise<void> => {\r\n const { url, method, headers = {}, data, onMessage, onError, onComplete } = config;\r\n \r\n try {\r\n // 使用 API_DOMAIN 拼接完整的请求URL\r\n const requestUrl = `${API_DOMAIN}${url}`;\r\n \r\n const response = await fetch(requestUrl, {\r\n method,\r\n headers: {\r\n 'Accept': 'text/event-stream',\r\n 'Content-Type': 'application/json',\r\n ...headers\r\n },\r\n body: data ? JSON.stringify(data) : undefined\r\n });\r\n\r\n if (!response.ok) {\r\n throw new Error(`HTTP error! status: ${response.status}`);\r\n }\r\n\r\n const reader = response.body?.getReader();\r\n if (!reader) throw new Error('No reader available');\r\n \r\n const decoder = new TextDecoder();\r\n let buffer = '';\r\n\r\n while (true) {\r\n const { value, done } = await reader.read();\r\n if (done) break;\r\n\r\n buffer += decoder.decode(value, { stream: true });\r\n\r\n // 处理缓冲区中的完整消息\r\n const lines = buffer.split('\\n');\r\n buffer = lines.pop() || ''; // 保留最后一个不完整的行\r\n\r\n for (const line of lines) {\r\n if (line.startsWith('data:')) {\r\n try {\r\n const jsonStr = line.substring(5).trim();\r\n if (!jsonStr) continue;\r\n \r\n const data = JSON.parse(jsonStr);\r\n onMessage?.(data);\r\n } catch (e) {\r\n console.error('解析 SSE 数据错误:', e, '原始数据:', line);\r\n }\r\n }\r\n }\r\n }\r\n \r\n onComplete?.();\r\n } catch (error) {\r\n console.error('SSE 请求错误:', error);\r\n onError?.(error);\r\n }\r\n};\r\n\r\n/**\r\n * HTTP请求配置接口\r\n */\r\nexport interface HttpRequestConfig {\r\n url: string;\r\n method?: string;\r\n headers?: Record<string, string>;\r\n params?: Record<string, any>;\r\n data?: any;\r\n formData?: FormData; // 添加FormData支持\r\n onMessage?: (data: any) => void;\r\n onError?: (error: any) => void;\r\n onComplete?: () => void;\r\n}\r\n\r\n/**\r\n * 统一的API响应接口\r\n */\r\nexport interface ApiResponse<T = any> {\r\n code: number;\r\n message: string;\r\n data?: T;\r\n}\r\n\r\n/**\r\n * HTTP响应接口\r\n */\r\nexport interface HttpResponse<T = any> {\r\n success: boolean;\r\n data?: T;\r\n error?: any;\r\n message?: string;\r\n}\r\n\r\n/**\r\n * 发送HTTP请求\r\n * @param config 请求配置\r\n * @returns Promise<HttpResponse>\r\n */\r\nexport const sendHttpRequest = async <T = any>(config: HttpRequestConfig): Promise<HttpResponse<T>> => {\r\n const { url, method = 'GET', headers = {}, params = {}, data, formData, onMessage } = config;\r\n \r\n try {\r\n // 构建URL和查询参数\r\n const queryParams = new URLSearchParams();\r\n Object.entries(params).forEach(([key, value]) => {\r\n if (value !== undefined && value !== null) {\r\n queryParams.append(key, String(value));\r\n }\r\n });\r\n \r\n // 使用 API_DOMAIN 拼接完整的请求URL\r\n let requestUrl = `${API_DOMAIN}${url}${queryParams.toString() ? `?${queryParams.toString()}` : ''}`;\r\n \r\n // 创建请求配置对象\r\n const requestConfig: RequestInit = {\r\n method,\r\n headers: formData ? { ...headers } : {\r\n 'Content-Type': 'application/json',\r\n ...headers\r\n }\r\n };\r\n\r\n // 处理请求体\r\n if (formData) {\r\n // 如果提供了FormData,直接使用\r\n requestConfig.body = formData;\r\n } else if (method !== 'GET' && method !== 'HEAD' && data) {\r\n // 否则,如果是非GET/HEAD请求且有data,将其JSON序列化\r\n requestConfig.body = JSON.stringify(data);\r\n }\r\n\r\n // 如果是 GET 方法且有 data,将其作为查询参数添加到 URL\r\n if (method === 'GET' && data) {\r\n const dataParams = new URLSearchParams();\r\n Object.entries(data).forEach(([key, value]) => {\r\n if (value !== undefined && value !== null) {\r\n dataParams.append(key, String(value));\r\n }\r\n });\r\n requestUrl += (queryParams.toString() ? '&' : '?') + dataParams.toString();\r\n }\r\n\r\n const response = await fetch(requestUrl, requestConfig);\r\n const responseData: ApiResponse<T> = await response.json();\r\n \r\n // 调用 onMessage 回调\r\n if (onMessage) {\r\n onMessage(responseData);\r\n }\r\n \r\n // 检查响应状态\r\n if (!response.ok) {\r\n console.error(`HTTP错误: ${response.status} ${response.statusText}`);\r\n return {\r\n success: false,\r\n message: responseData.message || `HTTP错误: ${response.status}`,\r\n error: responseData\r\n };\r\n }\r\n \r\n // 检查业务状态码\r\n if (responseData.code !== 0) {\r\n console.error(`API错误: ${responseData.message}`);\r\n return {\r\n success: false,\r\n message: responseData.message,\r\n error: responseData\r\n };\r\n }\r\n \r\n // 直接返回data\r\n return {\r\n success: true,\r\n data: responseData.data\r\n };\r\n } catch (error) {\r\n console.error('HTTP请求错误:', error);\r\n if (config.onError) {\r\n config.onError(error);\r\n }\r\n return {\r\n success: false,\r\n error,\r\n message: error instanceof Error ? error.message : '未知错误'\r\n };\r\n } finally {\r\n if (config.onComplete) {\r\n config.onComplete();\r\n }\r\n }\r\n};\r\n\r\n\r\n\r\n/**\r\n * 文件上传响应数据接口\r\n */\r\nexport interface FileUploadResponse {\r\n /** 文件在对象存储中的唯一标识符 */\r\n cos_key: string;\r\n /** 文件名称 */\r\n file_name: string;\r\n /** 文件大小(带单位的字符串,如 \"1.5MB\") */\r\n file_size: string;\r\n /** 文件的预签名URL */\r\n presigned_url: string;\r\n /** 文件扩展名 */\r\n ext: string;\r\n}\r\n\r\n/**\r\n * 通过后端API上传文件\r\n * @param file 要上传的文件\r\n * @param headers 可选的请求头\r\n * @returns Promise 包含上传结果\r\n */\r\nexport const uploadFileToBackend = async (\r\n file: File,\r\n headers?: Record<string, string>\r\n): Promise<FileUploadResponse> => {\r\n const formData = new FormData();\r\n formData.append('file', file);\r\n \r\n try {\r\n const response = await sendHttpRequest<{cos_key: string, file_name: string, file_size: string,presigned_url: string, ext: string}>({\r\n url: '/sdk/v1/files/upload',\r\n method: 'POST',\r\n headers: {\r\n ...headers\r\n },\r\n formData\r\n });\r\n \r\n if (!response.success || !response.data) {\r\n throw new Error(response.message || '文件上传失败');\r\n }\r\n \r\n return response.data;\r\n } catch (error) {\r\n console.error('文件上传错误:', error);\r\n throw error;\r\n }\r\n};\r\n"],"names":[],"mappings":"AAAA;;AAEG;AACH;AACO,MAAM,UAAU,GAAG;SAGV,MAAM,CAAC,KAAc,EAAE,MAAe,EAAE,IAAa,EAAA;AACnE,IAAA,OAAO,CAAC,KAAK,IAAI,EAAE,KAAK,MAAM,GAAG,CAAI,CAAA,EAAA,MAAM,EAAE,GAAG,EAAE,CAAC,IAAI,IAAI,GAAG,CAAI,CAAA,EAAA,IAAI,EAAE,GAAG,EAAE,CAAC;AAChF;AAsEA;;;;AAIG;MACU,cAAc,GAAG,OAAO,MAAwB,KAAmB;AAC9E,IAAA,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,GAAG,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,UA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