@templmf/temp-solf-lmf 0.0.54 → 0.0.55
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/guanwang/README.md +95 -0
- package/guanwang/docs/changelog.md +145 -0
- package/guanwang/docs/doc-maintenance.md +229 -0
- package/guanwang/docs/product.md +181 -0
- package/guanwang/docs/test-cases.md +395 -0
- package/guanwang/docs/usage.md +291 -0
- package/guanwang/env.example +27 -0
- package/guanwang/index.html +13 -0
- package/guanwang/package-lock.json +3825 -0
- package/guanwang/package.json +32 -0
- package/guanwang/public/favicon.svg +4 -0
- package/guanwang/public/react-runtime/babel.min.js +4 -0
- package/guanwang/public/react-runtime/react-dom.min.js +267 -0
- package/guanwang/public/react-runtime/react.min.js +31 -0
- package/guanwang/public/vue-repl-assets/compiler-sfc.esm-browser.js +50795 -0
- package/guanwang/public/vue-repl-assets/runtime-dom.esm-browser.js +12758 -0
- package/guanwang/public/vue-repl-assets/server-renderer.esm-browser.js +8600 -0
- package/guanwang/public/vue-repl-assets/vue.esm-browser.js +18672 -0
- package/guanwang/src/App.vue +61 -0
- package/guanwang/src/chat-sdk/core/components/ChatBox.vue +305 -0
- package/guanwang/src/chat-sdk/core/components/ChatSidebar.vue +84 -0
- package/guanwang/src/chat-sdk/core/components/InputBar.vue +354 -0
- package/guanwang/src/chat-sdk/core/components/MessageBubble.vue +703 -0
- package/guanwang/src/chat-sdk/core/useTheme.js +31 -0
- package/guanwang/src/chat-sdk/features/artifact/ArtifactCard.vue +172 -0
- package/guanwang/src/chat-sdk/features/artifact/ArtifactPanel.vue +963 -0
- package/guanwang/src/chat-sdk/features/artifact/index.js +13 -0
- package/guanwang/src/chat-sdk/features/artifact/useArtifactStore.js +275 -0
- package/guanwang/src/chat-sdk/features/codepreview/CodePreview.vue +523 -0
- package/guanwang/src/chat-sdk/features/codepreview/index.js +7 -0
- package/guanwang/src/chat-sdk/features/markdown/index.js +13 -0
- package/guanwang/src/chat-sdk/features/markdown/useMarkdown.js +724 -0
- package/guanwang/src/chat-sdk/features/mermaid/MermaidZoom.vue +254 -0
- package/guanwang/src/chat-sdk/features/upload/FileAttachment.vue +142 -0
- package/guanwang/src/chat-sdk/features/upload/index.js +17 -0
- package/guanwang/src/chat-sdk/features/upload/useFileHandler.js +336 -0
- package/guanwang/src/chat-sdk/headless/api/adapters/openai.js +76 -0
- package/guanwang/src/chat-sdk/headless/api/chatApi.js +126 -0
- package/guanwang/src/chat-sdk/headless/buildSystemPrompt.js +351 -0
- package/guanwang/src/chat-sdk/headless/index.js +15 -0
- package/guanwang/src/chat-sdk/headless/useChat.js +77 -0
- package/guanwang/src/chat-sdk/headless/useChatDB.js +147 -0
- package/guanwang/src/chat-sdk/headless/useChatStore.js +529 -0
- package/guanwang/src/chat-sdk/index.js +79 -0
- package/guanwang/src/chat-sdk/modes/architect.js +27 -0
- package/guanwang/src/chat-sdk/modes/ask.js +26 -0
- package/guanwang/src/chat-sdk/modes/code.js +25 -0
- package/guanwang/src/chat-sdk/modes/index.js +36 -0
- package/guanwang/src/chat-sdk/modes/requirements.js +175 -0
- package/guanwang/src/chat-sdk/settings/SettingsPanel.vue +170 -0
- package/guanwang/src/chat-sdk/settings/index.js +9 -0
- package/guanwang/src/chat-sdk/settings/useSettings.js +122 -0
- package/guanwang/src/chat-sdk/tools/defaults.js +89 -0
- package/guanwang/src/chat-sdk/tools/index.js +16 -0
- package/guanwang/src/chat-sdk/tools/parser.js +116 -0
- package/guanwang/src/components/CustomCursor.vue +69 -0
- package/guanwang/src/components/Footer.vue +24 -0
- package/guanwang/src/components/LoginModal.vue +109 -0
- package/guanwang/src/components/Navbar.vue +193 -0
- package/guanwang/src/components/ThemeToggle.vue +25 -0
- package/guanwang/src/composables/useArtifactStore.js +253 -0
- package/guanwang/src/composables/useAuth.js +88 -0
- package/guanwang/src/composables/useChatDB.js +147 -0
- package/guanwang/src/composables/useCountUp.js +24 -0
- package/guanwang/src/composables/useFileHandler.js +345 -0
- package/guanwang/src/composables/useTheme.js +31 -0
- package/guanwang/src/config/api.js +71 -0
- package/guanwang/src/main.js +23 -0
- package/guanwang/src/router/index.js +23 -0
- package/guanwang/src/services/authApi.js +27 -0
- package/guanwang/src/services/chatApi.js +66 -0
- package/guanwang/src/styles/global.css +478 -0
- package/guanwang/src/tracker/analyze.js +73 -0
- package/guanwang/src/tracker/config.js +82 -0
- package/guanwang/src/tracker/index.js +18 -0
- package/guanwang/src/tracker/service.js +102 -0
- package/guanwang/src/tracker/useChatTracker.js +179 -0
- package/guanwang/src/tracker/useTracker.js +45 -0
- package/guanwang/src/views/ChatView.vue +65 -0
- package/guanwang/src/views/HomeView.vue +156 -0
- package/guanwang/src/views/MarketView.vue +143 -0
- package/guanwang/src/views/PracticesView.vue +190 -0
- package/guanwang/src/views/SkillsView.vue +129 -0
- package/guanwang/temp +19 -0
- package/guanwang/vite.config.js +6 -0
- package/package.json +1 -1
- package/guanwang copy.zip +0 -0
|
@@ -0,0 +1,354 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div
|
|
3
|
+
class="input-wrap"
|
|
4
|
+
:class="{ 'is-dragging': isDragging }"
|
|
5
|
+
@dragover.prevent="isDragging = true"
|
|
6
|
+
@dragleave.prevent="isDragging = false"
|
|
7
|
+
@drop.prevent="onDrop"
|
|
8
|
+
>
|
|
9
|
+
<!-- 附件预览条 -->
|
|
10
|
+
<FileAttachment
|
|
11
|
+
:attachments="attachments"
|
|
12
|
+
@remove="removeAttachment"
|
|
13
|
+
/>
|
|
14
|
+
|
|
15
|
+
<!-- 拖拽提示遮罩 -->
|
|
16
|
+
<div v-if="isDragging" class="drop-overlay">
|
|
17
|
+
<Paperclip :size="28" />
|
|
18
|
+
<span>松开以添加附件</span>
|
|
19
|
+
</div>
|
|
20
|
+
|
|
21
|
+
<!-- 输入行 -->
|
|
22
|
+
<div class="input-row">
|
|
23
|
+
<!-- 上传按钮 -->
|
|
24
|
+
<el-tooltip content="添加附件(图片/PDF/代码/文档)" placement="top">
|
|
25
|
+
<el-button
|
|
26
|
+
text
|
|
27
|
+
circle
|
|
28
|
+
:disabled="isLoading"
|
|
29
|
+
class="upload-btn"
|
|
30
|
+
:class="{ 'has-files': attachments.length > 0 }"
|
|
31
|
+
@click="triggerFileInput"
|
|
32
|
+
>
|
|
33
|
+
<Paperclip :size="18" />
|
|
34
|
+
</el-button>
|
|
35
|
+
</el-tooltip>
|
|
36
|
+
|
|
37
|
+
<!-- 隐藏的 file input -->
|
|
38
|
+
<input
|
|
39
|
+
ref="fileInputRef"
|
|
40
|
+
type="file"
|
|
41
|
+
multiple
|
|
42
|
+
:accept="ACCEPT_TYPES"
|
|
43
|
+
style="display:none"
|
|
44
|
+
@change="onFileChange"
|
|
45
|
+
/>
|
|
46
|
+
|
|
47
|
+
<!-- 文字输入框 -->
|
|
48
|
+
<el-input
|
|
49
|
+
ref="inputRef"
|
|
50
|
+
v-model="input"
|
|
51
|
+
type="textarea"
|
|
52
|
+
:autosize="{ minRows: 1, maxRows: 4 }"
|
|
53
|
+
:placeholder="currentPlaceholder"
|
|
54
|
+
resize="none"
|
|
55
|
+
style="flex: 1;"
|
|
56
|
+
@keydown="onKey"
|
|
57
|
+
@paste="onPaste"
|
|
58
|
+
/>
|
|
59
|
+
|
|
60
|
+
<!-- 发送按钮 -->
|
|
61
|
+
<el-button
|
|
62
|
+
type="primary"
|
|
63
|
+
:disabled="!canSend"
|
|
64
|
+
:loading="isLoading"
|
|
65
|
+
class="send-btn"
|
|
66
|
+
@click="send"
|
|
67
|
+
>
|
|
68
|
+
<Send v-if="!isLoading" :size="18" />
|
|
69
|
+
</el-button>
|
|
70
|
+
</div>
|
|
71
|
+
|
|
72
|
+
<!-- 处理中提示 -->
|
|
73
|
+
<div v-if="processingFile" class="processing-bar">
|
|
74
|
+
<span class="processing-dot" />
|
|
75
|
+
正在处理附件:{{ processingFile }}...
|
|
76
|
+
</div>
|
|
77
|
+
|
|
78
|
+
<!-- 模型选择工具栏 -->
|
|
79
|
+
<!-- v-if="showModelSelector" -->
|
|
80
|
+
<div class="model-bar">
|
|
81
|
+
<span class="model-bar__label">模型</span>
|
|
82
|
+
<el-select
|
|
83
|
+
v-model="localSelectedId"
|
|
84
|
+
size="small"
|
|
85
|
+
class="model-select"
|
|
86
|
+
@change="id => emit('select-model', id)"
|
|
87
|
+
>
|
|
88
|
+
<el-option
|
|
89
|
+
v-for="m in availableModels"
|
|
90
|
+
:key="m.id"
|
|
91
|
+
:label="m.name"
|
|
92
|
+
:value="m.id"
|
|
93
|
+
/>
|
|
94
|
+
</el-select>
|
|
95
|
+
</div>
|
|
96
|
+
</div>
|
|
97
|
+
</template>
|
|
98
|
+
|
|
99
|
+
<script setup>
|
|
100
|
+
import { ref, computed, onMounted } from 'vue'
|
|
101
|
+
import { Send, Paperclip } from 'lucide-vue-next'
|
|
102
|
+
import { ElMessage } from 'element-plus'
|
|
103
|
+
import FileAttachment from '../../features/upload/FileAttachment.vue'
|
|
104
|
+
import { processFile, buildMessageContent, ACCEPT_TYPES, FILE_TYPE_HINT } from '../../features/upload/useFileHandler.js'
|
|
105
|
+
|
|
106
|
+
const props = defineProps({
|
|
107
|
+
isLoading: { type: Boolean, default: false },
|
|
108
|
+
placeholder: { type: String, default: '描述您的需求...' },
|
|
109
|
+
autoFocus: { type: Boolean, default: false },
|
|
110
|
+
// 模型相关(由 ChatBox 从 chatStore 传入)
|
|
111
|
+
availableModels: { type: Array, default: () => [] },
|
|
112
|
+
selectedModelId: { type: String, default: '' },
|
|
113
|
+
showModelSelector: { type: Boolean, default: false },
|
|
114
|
+
})
|
|
115
|
+
|
|
116
|
+
const emit = defineEmits(['send', 'select-model'])
|
|
117
|
+
|
|
118
|
+
const input = ref('')
|
|
119
|
+
const inputRef = ref(null)
|
|
120
|
+
const fileInputRef = ref(null)
|
|
121
|
+
const attachments = ref([])
|
|
122
|
+
const isDragging = ref(false)
|
|
123
|
+
const processingFile = ref('')
|
|
124
|
+
|
|
125
|
+
// 本地临时选中(用户在当次会话里临时切换,和 store 双向同步)
|
|
126
|
+
// selectedModelId 未传时自动取第一个可用模型,避免选择框空白
|
|
127
|
+
const localSelectedId = ref(props.selectedModelId || props.availableModels[0]?.id || '')
|
|
128
|
+
|
|
129
|
+
const canSend = computed(() =>
|
|
130
|
+
!props.isLoading && (input.value.trim().length > 0 || attachments.value.length > 0)
|
|
131
|
+
)
|
|
132
|
+
|
|
133
|
+
const currentPlaceholder = computed(() =>
|
|
134
|
+
attachments.value.length > 0 ? '描述一下你想对这些文件做什么...' : props.placeholder
|
|
135
|
+
)
|
|
136
|
+
|
|
137
|
+
onMounted(() => {
|
|
138
|
+
if (props.autoFocus) setTimeout(() => inputRef.value?.focus(), 100)
|
|
139
|
+
})
|
|
140
|
+
|
|
141
|
+
// ── 发送 ──────────────────────────────────────────────────────────
|
|
142
|
+
function send() {
|
|
143
|
+
if (!canSend.value) return
|
|
144
|
+
const text = input.value.trim()
|
|
145
|
+
const content = buildMessageContent(text, attachments.value)
|
|
146
|
+
|
|
147
|
+
emit('send', {
|
|
148
|
+
content,
|
|
149
|
+
displayText: text,
|
|
150
|
+
// 只有和 store 里的 selectedModelId 不同时才传 override
|
|
151
|
+
modelOverride: localSelectedId.value !== props.selectedModelId
|
|
152
|
+
? localSelectedId.value
|
|
153
|
+
: undefined,
|
|
154
|
+
attachments: attachments.value.map(a => ({
|
|
155
|
+
id: a.id,
|
|
156
|
+
fileName: a.fileName,
|
|
157
|
+
type: a.type,
|
|
158
|
+
preview: a.preview,
|
|
159
|
+
ext: a.ext,
|
|
160
|
+
})),
|
|
161
|
+
})
|
|
162
|
+
|
|
163
|
+
input.value = ''
|
|
164
|
+
attachments.value = []
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
function onKey(e) {
|
|
168
|
+
if (e.key === 'Enter' && !e.shiftKey) { e.preventDefault(); send() }
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
// ── 文件处理 ──────────────────────────────────────────────────────
|
|
172
|
+
function triggerFileInput() { fileInputRef.value?.click() }
|
|
173
|
+
|
|
174
|
+
async function onFileChange(e) {
|
|
175
|
+
const files = Array.from(e.target.files || [])
|
|
176
|
+
e.target.value = '' // 清空 input 以便同文件可重复选
|
|
177
|
+
await addFiles(files)
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
async function onDrop(e) {
|
|
181
|
+
isDragging.value = false
|
|
182
|
+
const files = Array.from(e.dataTransfer.files || [])
|
|
183
|
+
await addFiles(files)
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
// 粘贴图片(截图直接粘贴)
|
|
187
|
+
async function onPaste(e) {
|
|
188
|
+
const items = Array.from(e.clipboardData?.items || [])
|
|
189
|
+
// 修复:部分浏览器粘贴截图时 item.type 为空字符串,改为只要 kind==='file' 就尝试处理
|
|
190
|
+
const fileItems = items.filter(i => i.kind === 'file')
|
|
191
|
+
if (fileItems.length === 0) return
|
|
192
|
+
const files = fileItems.map(i => i.getAsFile()).filter(Boolean)
|
|
193
|
+
if (files.length === 0) return
|
|
194
|
+
e.preventDefault()
|
|
195
|
+
await addFiles(files)
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
async function addFiles(files) {
|
|
199
|
+
const MAX_ATTACHMENTS = 5
|
|
200
|
+
const remaining = MAX_ATTACHMENTS - attachments.value.length
|
|
201
|
+
if (remaining <= 0) {
|
|
202
|
+
ElMessage.warning(`最多同时上传 ${MAX_ATTACHMENTS} 个文件`)
|
|
203
|
+
return
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
for (const file of files.slice(0, remaining)) {
|
|
207
|
+
processingFile.value = file.name
|
|
208
|
+
try {
|
|
209
|
+
const att = await processFile(file)
|
|
210
|
+
attachments.value.push(att)
|
|
211
|
+
} catch (err) {
|
|
212
|
+
ElMessage.error(`${file.name}:${err.message}`)
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
processingFile.value = ''
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
function removeAttachment(id) {
|
|
219
|
+
attachments.value = attachments.value.filter(a => a.id !== id)
|
|
220
|
+
}
|
|
221
|
+
</script>
|
|
222
|
+
|
|
223
|
+
<style scoped>
|
|
224
|
+
.input-wrap {
|
|
225
|
+
position: relative;
|
|
226
|
+
border-radius: 14px;
|
|
227
|
+
border: 1px solid var(--border-default);
|
|
228
|
+
background: var(--bg-secondary);
|
|
229
|
+
transition: border-color 0.2s, box-shadow 0.2s;
|
|
230
|
+
overflow: hidden;
|
|
231
|
+
}
|
|
232
|
+
.input-wrap:focus-within {
|
|
233
|
+
border-color: rgba(26,111,196,0.6);
|
|
234
|
+
box-shadow: 0 0 0 3px rgba(26,111,196,0.08);
|
|
235
|
+
}
|
|
236
|
+
.input-wrap.is-dragging {
|
|
237
|
+
border-color: var(--brand-500);
|
|
238
|
+
box-shadow: 0 0 0 3px rgba(26,111,196,0.15);
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
/* 拖拽遮罩 */
|
|
242
|
+
.drop-overlay {
|
|
243
|
+
position: absolute; inset: 0; z-index: 10;
|
|
244
|
+
background: rgba(26,111,196,0.1);
|
|
245
|
+
display: flex; flex-direction: column;
|
|
246
|
+
align-items: center; justify-content: center;
|
|
247
|
+
gap: 8px; color: var(--brand-400);
|
|
248
|
+
font-size: 14px; font-family: Inter, 'Helvetica Neue', Helvetica, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', '微软雅黑', Arial, sans-serif;
|
|
249
|
+
pointer-events: none;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
/* 输入行 */
|
|
253
|
+
.input-row {
|
|
254
|
+
display: flex;
|
|
255
|
+
align-items: flex-end;
|
|
256
|
+
gap: 6px;
|
|
257
|
+
padding: 8px 8px 8px 6px;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
.upload-btn {
|
|
261
|
+
color: var(--text-muted) !important;
|
|
262
|
+
transition: color 0.15s !important;
|
|
263
|
+
flex-shrink: 0;
|
|
264
|
+
margin-bottom: 2px;
|
|
265
|
+
}
|
|
266
|
+
.upload-btn:hover { color: var(--brand-400) !important; }
|
|
267
|
+
.upload-btn.has-files { color: var(--brand-500) !important; }
|
|
268
|
+
|
|
269
|
+
.send-btn {
|
|
270
|
+
flex-shrink: 0;
|
|
271
|
+
width: 44px !important;
|
|
272
|
+
height: 44px !important;
|
|
273
|
+
border-radius: 10px !important;
|
|
274
|
+
padding: 0 !important;
|
|
275
|
+
margin-bottom: 2px;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
/* 去掉输入框自带边框(改由 .input-wrap 统一管理) */
|
|
279
|
+
:deep(.el-textarea__inner) {
|
|
280
|
+
border: none !important;
|
|
281
|
+
box-shadow: none !important;
|
|
282
|
+
background: transparent !important;
|
|
283
|
+
border-radius: 0 !important;
|
|
284
|
+
padding: 10px 6px !important;
|
|
285
|
+
font-size: 14px !important;
|
|
286
|
+
min-height: 44px !important;
|
|
287
|
+
line-height: 1.5 !important;
|
|
288
|
+
font-family: Inter, 'Helvetica Neue', Helvetica, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', '微软雅黑', Arial, sans-serif !important;
|
|
289
|
+
resize: none !important;
|
|
290
|
+
}
|
|
291
|
+
:deep(.el-textarea__inner:focus) {
|
|
292
|
+
box-shadow: none !important;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
/* 处理中提示 */
|
|
296
|
+
.processing-bar {
|
|
297
|
+
display: flex;
|
|
298
|
+
align-items: center;
|
|
299
|
+
gap: 7px;
|
|
300
|
+
padding: 6px 14px 8px;
|
|
301
|
+
font-size: 12px;
|
|
302
|
+
font-family: Inter, 'Helvetica Neue', Helvetica, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', '微软雅黑', Arial, sans-serif;
|
|
303
|
+
color: var(--text-muted);
|
|
304
|
+
border-top: 1px solid var(--border-subtle);
|
|
305
|
+
}
|
|
306
|
+
.processing-dot {
|
|
307
|
+
width: 6px; height: 6px; border-radius: 50%;
|
|
308
|
+
background: var(--brand-400);
|
|
309
|
+
animation: pulseSlow 1s ease infinite;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
/* ── 模型选择栏 ── */
|
|
313
|
+
.model-bar {
|
|
314
|
+
display: flex;
|
|
315
|
+
align-items: center;
|
|
316
|
+
gap: 8px;
|
|
317
|
+
padding: 5px 12px 7px;
|
|
318
|
+
border-top: 1px solid var(--border-subtle);
|
|
319
|
+
}
|
|
320
|
+
.model-bar__label {
|
|
321
|
+
font-size: 11px;
|
|
322
|
+
color: var(--text-muted);
|
|
323
|
+
flex-shrink: 0;
|
|
324
|
+
}
|
|
325
|
+
.model-select {
|
|
326
|
+
width: 200px;
|
|
327
|
+
}
|
|
328
|
+
:deep(.model-select .el-input__wrapper) {
|
|
329
|
+
background: transparent !important;
|
|
330
|
+
box-shadow: none !important;
|
|
331
|
+
border: 1px solid var(--border-default) !important;
|
|
332
|
+
border-radius: 6px !important;
|
|
333
|
+
padding: 0 8px !important;
|
|
334
|
+
height: 26px !important;
|
|
335
|
+
font-size: 11px !important;
|
|
336
|
+
font-family: 'Cascadia Code', 'Consolas', monospace !important;
|
|
337
|
+
transition: border-color 0.15s !important;
|
|
338
|
+
}
|
|
339
|
+
:deep(.model-select .el-input__wrapper:hover),
|
|
340
|
+
:deep(.model-select .el-input__wrapper.is-focus) {
|
|
341
|
+
border-color: var(--brand-500) !important;
|
|
342
|
+
}
|
|
343
|
+
:deep(.model-select .el-input__inner) {
|
|
344
|
+
font-size: 11px !important;
|
|
345
|
+
font-family: 'Cascadia Code', 'Consolas', monospace !important;
|
|
346
|
+
color: var(--text-secondary) !important;
|
|
347
|
+
height: 24px !important;
|
|
348
|
+
line-height: 24px !important;
|
|
349
|
+
}
|
|
350
|
+
:deep(.model-select .el-select__caret) {
|
|
351
|
+
color: var(--text-muted) !important;
|
|
352
|
+
font-size: 11px !important;
|
|
353
|
+
}
|
|
354
|
+
</style>
|