Skip to content

Commit 7736b85

Browse files
author
ruolishipian
committed
feat: 更新提示词和标签管理功能
- 更新 prompt_index.vue 和 tag_index.vue 组件 - 更新构建产物和样式文件 - 添加 tag_labels.json 标签数据文件 - 更新依赖锁定文件 🤖 Generated with CodeArts Agent
1 parent 62e4731 commit 7736b85

File tree

8 files changed

+209
-119
lines changed

8 files changed

+209
-119
lines changed

dist/javascript/main.entry.js

Lines changed: 101 additions & 96 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/javascript/main.entry.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/style.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js_node/weilin_prompt_ui_node.js

Lines changed: 33 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ app.registerExtension({
116116

117117
const thisNodeName = nodeData.name // 存储当前的节点名称
118118
let nodeTextAreaList = [] // 按顺序载入element,name="positive" || "lora_str" || "temp_str"
119+
let nodeWidgetList = [] // ✅ 新增:保存widget引用,用于同步更新widget.value
119120
const thisNodeSeed = generateUUID(); // 随机唯一种子ID
120121

121122
if (nodeData.name === "WeiLinPromptUI" || nodeData.name === "WeiLinPromptUIWithoutLora") {
@@ -133,22 +134,27 @@ app.registerExtension({
133134
let thisInputElement = widgetItem.element
134135
// thisInputElement.readOnly = true
135136
nodeTextAreaList[0] = thisInputElement
137+
nodeWidgetList[0] = widgetItem // ✅ 保存widget引用
136138
} else if (widgetItem.name == "lora_str") {
137139
let thisInputElement = widgetItem.element
138140
thisInputElement.readOnly = true
139141
nodeTextAreaList[1] = thisInputElement
142+
nodeWidgetList[1] = widgetItem // ✅ 保存widget引用
140143
} else if (widgetItem.name == "temp_str") {
141144
let thisInputElement = widgetItem.element
142145
thisInputElement.readOnly = true
143146
nodeTextAreaList[2] = thisInputElement
147+
nodeWidgetList[2] = widgetItem // ✅ 保存widget引用
144148
} else if (widgetItem.name == "temp_lora_str") {
145149
let thisInputElement = widgetItem.element
146150
thisInputElement.readOnly = true
147151
nodeTextAreaList[3] = thisInputElement
152+
nodeWidgetList[3] = widgetItem // ✅ 保存widget引用
148153
} else if (widgetItem.name == "random_template") {
149154
let thisInputElement = widgetItem.element
150155
thisInputElement.readOnly = true
151156
nodeTextAreaList[4] = thisInputElement
157+
nodeWidgetList[4] = widgetItem // ✅ 保存widget引用
152158
}
153159
}
154160

@@ -313,27 +319,35 @@ app.registerExtension({
313319
const jsonReponse = JSON.parse(event.data.data)
314320
// console.log(jsonReponse)
315321
nodeTextAreaList[0].value = jsonReponse.prompt;
322+
// ✅ 修复:同时更新widget.value,确保序列化时获取最新值
323+
if (nodeWidgetList[0]) nodeWidgetList[0].value = jsonReponse.prompt;
316324

317325
if (nodeData.name === "WeiLinPromptUI") {
318326
// console.log(jsonReponse.lora.length)
319327
if (jsonReponse.lora && jsonReponse.lora.length > 0 && jsonReponse.lora != "") {
320328
nodeTextAreaList[1].value = JSON.stringify(jsonReponse.lora);
329+
if (nodeWidgetList[1]) nodeWidgetList[1].value = JSON.stringify(jsonReponse.lora);
321330
} else {
322331
nodeTextAreaList[1].value = "";
332+
if (nodeWidgetList[1]) nodeWidgetList[1].value = "";
323333
}
324334
}
325335

326336
if (jsonReponse.temp_prompt && jsonReponse.temp_prompt != "") {
327337
nodeTextAreaList[2].value = JSON.stringify(jsonReponse.temp_prompt);
338+
if (nodeWidgetList[2]) nodeWidgetList[2].value = JSON.stringify(jsonReponse.temp_prompt);
328339
}else {
329340
nodeTextAreaList[2].value = "";
341+
if (nodeWidgetList[2]) nodeWidgetList[2].value = "";
330342
}
331343

332344
if (nodeData.name === "WeiLinPromptUI") {
333345
if (jsonReponse.temp_lora && jsonReponse.temp_lora != "") {
334346
nodeTextAreaList[3].value = JSON.stringify(jsonReponse.temp_lora);
347+
if (nodeWidgetList[3]) nodeWidgetList[3].value = JSON.stringify(jsonReponse.temp_lora);
335348
}else {
336349
nodeTextAreaList[3].value = "";
350+
if (nodeWidgetList[3]) nodeWidgetList[3].value = "";
337351
}
338352
}
339353

@@ -381,14 +395,18 @@ app.registerExtension({
381395
// console.log(jsonReponse.lora.length)
382396
if (jsonReponse.lora && jsonReponse.lora.length > 0 && jsonReponse.lora != "") {
383397
nodeTextAreaList[1].value = JSON.stringify(jsonReponse.lora);
398+
if (nodeWidgetList[1]) nodeWidgetList[1].value = JSON.stringify(jsonReponse.lora);
384399
} else {
385400
nodeTextAreaList[1].value = "";
401+
if (nodeWidgetList[1]) nodeWidgetList[1].value = "";
386402
}
387403

388404
if (jsonReponse.temp_lora && jsonReponse.temp_lora != "") {
389405
nodeTextAreaList[3].value = JSON.stringify(jsonReponse.temp_lora);
406+
if (nodeWidgetList[3]) nodeWidgetList[3].value = JSON.stringify(jsonReponse.temp_lora);
390407
}else{
391408
nodeTextAreaList[3].value = "";
409+
if (nodeWidgetList[3]) nodeWidgetList[3].value = "";
392410
}
393411

394412
if (nodeTextAreaList[3].value.length > 0) {
@@ -405,19 +423,24 @@ app.registerExtension({
405423
if (nodeData.name === "WeiLinPromptUIOnlyLoraStack") {
406424
if (jsonReponse.lora && jsonReponse.lora.length > 0 && jsonReponse.lora != "") {
407425
nodeTextAreaList[1].value = JSON.stringify(jsonReponse.lora);
426+
if (nodeWidgetList[1]) nodeWidgetList[1].value = JSON.stringify(jsonReponse.lora);
408427
} else {
409428
nodeTextAreaList[1].value = "";
429+
if (nodeWidgetList[1]) nodeWidgetList[1].value = "";
410430
}
411431
if (jsonReponse.temp_lora && jsonReponse.temp_lora != "") {
412432
nodeTextAreaList[3].value = JSON.stringify(jsonReponse.temp_lora);
433+
if (nodeWidgetList[3]) nodeWidgetList[3].value = JSON.stringify(jsonReponse.temp_lora);
413434
}else{
414435
nodeTextAreaList[3].value = "";
436+
if (nodeWidgetList[3]) nodeWidgetList[3].value = "";
415437
}
416438
}
417439
}else if (event.data.type === "weilin_prompt_ui_selectLora_stack_node_"+thisNodeSeed) {
418440
addLora(thisNodeSeed,event.data.lora)
419441
}else if (event.data.type === "weilin_prompt_ui_update_template_"+randomID) {
420442
nodeTextAreaList[4].value = event.data.data
443+
if (nodeWidgetList[4]) nodeWidgetList[4].value = event.data.data
421444
}else if (event.data.type === "weilin_prompt_ui_get_template_"+randomID) {
422445
window.parent.postMessage({ type: 'weilin_prompt_ui_get_template_response', id: randomID, data: nodeTextAreaList[4].value }, '*')
423446
}else if (event.data.type === "weilin_prompt_ui_get_template_go_random_"+randomID) {
@@ -433,14 +456,16 @@ app.registerExtension({
433456
const onExecuted = nodeType.prototype.onExecuted;
434457
nodeType.prototype.onExecuted = function (message) {
435458
onExecuted?.apply(this, arguments);
436-
const positiveWidget = this.widgets.find(w => w.name === "positive");
437-
if (positiveWidget && message.positive) {
438-
positiveWidget.element.value = message.positive;
439-
// 触发input事件以更新全局状态
440-
const event = new Event('input', { bubbles: true });
441-
positiveWidget.element.dispatchEvent(event);
442-
}
443-
// console.log(message.positive)
459+
// ✅ 修复:禁用 onExecuted 中的覆盖逻辑
460+
// 前端已经通过 postMessageToWindowsPrompt 同步数据到节点
461+
// 不再需要用后端返回的旧值覆盖前端
462+
// if (!message) return;
463+
// const positiveWidget = this.widgets.find(w => w.name === "positive");
464+
// if (positiveWidget && message.positive) {
465+
// positiveWidget.element.value = message.positive;
466+
// const event = new Event('input', { bubbles: true });
467+
// positiveWidget.element.dispatchEvent(event);
468+
// }
444469
};
445470
}
446471
},

src/package-lock.json

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/src/view/prompt_box/prompt_index.vue

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1858,10 +1858,11 @@ const processInput = async () => {
18581858
if (proceTimeout.value) {
18591859
clearTimeout(proceTimeout.value);
18601860
}
1861+
// ✅ 修复:减少延迟时间从1000ms到100ms
18611862
proceTimeout.value = setTimeout(() => {
18621863
// console.log('处理历史记录');
18631864
finishPromptPutItHistory();
1864-
}, 1000);
1865+
}, 100); // 从1000改为100
18651866
postMessageToWindowsPrompt();
18661867
18671868
// 处理翻译
@@ -3180,6 +3181,11 @@ const handleMessage = (event) => {
31803181
lastInputValue.value = inputText.value; // 更新上一次的输入内容
31813182
// 触发输入事件以更新词组
31823183
processInput()
3184+
3185+
// ✅ 修复:确保数据立即同步到节点
3186+
nextTick(() => {
3187+
finishPromptPutItHistory();
3188+
});
31833189
} else if (event.data.type === 'weilin_prompt_ui_user_history_tag') {
31843190
const tagText = event.data.tagText
31853191
tempInputText.value = tagText

src/src/view/tag_manager/tag_index.vue

Lines changed: 52 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040

4141
<!-- 高级设置 -->
4242
<div class="toolbar-bottom">
43-
<div class="group-edit-mode">
43+
<div class="auto-add-checkbox">
4444
<label>
4545
<input type="checkbox" v-model="isAutoAddSearchTag" :true-value="1" :false-value="0" />
4646
{{ t('tagManager.autoAddSearchTag') }}
@@ -1607,30 +1607,36 @@ const resetTabSizeConfig = () => {
16071607
.tag-manager {
16081608
display: flex;
16091609
flex-direction: column;
1610-
padding: 0 16px 16px 16px;
1610+
padding: 0;
16111611
background: var(--weilin-prompt-ui-primary-bg);
16121612
height: 100%;
16131613
box-sizing: border-box;
1614+
overflow-y: auto;
1615+
overflow-x: hidden;
16141616
}
16151617
16161618
.category-tabs {
16171619
display: flex;
16181620
flex-direction: column;
16191621
gap: 16px;
16201622
margin-bottom: 16px;
1623+
margin-top: 0;
1624+
flex-shrink: 0;
1625+
padding-top: 8px;
16211626
}
16221627
16231628
.tabs-wrapper {
16241629
position: relative;
16251630
border-bottom: 1px solid var(--weilin-prompt-ui-border-color);
1631+
margin-top: 0;
16261632
}
16271633
16281634
.tabs-scroll {
16291635
display: flex;
16301636
gap: 2px;
16311637
padding: 0 2px 2px;
16321638
flex-wrap: wrap;
1633-
align-items: flex-end;
1639+
align-items: center;
16341640
}
16351641
16361642
/* 自定义滚动条样式 */
@@ -2212,6 +2218,8 @@ const resetTabSizeConfig = () => {
22122218
.search-container {
22132219
position: relative;
22142220
z-index: 100;
2221+
flex: 1;
2222+
min-width: 0;
22152223
}
22162224
22172225
.search-input {
@@ -2222,6 +2230,13 @@ const resetTabSizeConfig = () => {
22222230
background: var(--weilin-prompt-ui-input-bg);
22232231
color: var(--weilin-prompt-ui-primary-text);
22242232
font-size: 14px;
2233+
height: 32px;
2234+
box-sizing: border-box;
2235+
}
2236+
2237+
.search-input::placeholder {
2238+
color: var(--weilin-prompt-ui-secondary-text);
2239+
opacity: 1;
22252240
}
22262241
22272242
.search-input:focus {
@@ -2232,9 +2247,6 @@ const resetTabSizeConfig = () => {
22322247
22332248
.search-results {
22342249
position: fixed;
2235-
top: 60px;
2236-
left: 0;
2237-
right: 0;
22382250
max-height: 300px;
22392251
overflow-y: auto;
22402252
background: var(--weilin-prompt-ui-primary-bg);
@@ -2301,8 +2313,14 @@ const resetTabSizeConfig = () => {
23012313
}
23022314
23032315
.toolbar {
2316+
display: flex;
23042317
flex-direction: column;
2305-
padding: 12px 16px;
2318+
padding: 0 0 12px 0;
2319+
flex-shrink: 0;
2320+
margin-bottom: 16px;
2321+
border-bottom: 1px solid var(--weilin-prompt-ui-border-color);
2322+
min-height: fit-content;
2323+
height: auto;
23062324
}
23072325
23082326
.toolbar .toolbar-top {
@@ -2335,10 +2353,6 @@ const resetTabSizeConfig = () => {
23352353
fill: var(--weilin-prompt-ui-primary-text);
23362354
}
23372355
2338-
.search-container {
2339-
flex: 1;
2340-
}
2341-
23422356
.tags-actions {
23432357
width: fit-content;
23442358
display: flex;
@@ -2362,7 +2376,29 @@ const resetTabSizeConfig = () => {
23622376
display: flex;
23632377
align-items: center;
23642378
gap: 12px;
2365-
margin-top: 5px;
2379+
margin-top: 8px;
2380+
padding-bottom: 8px;
2381+
}
2382+
2383+
.auto-add-checkbox {
2384+
display: inline-flex;
2385+
align-items: center;
2386+
gap: 8px;
2387+
font-size: 13px;
2388+
color: var(--weilin-prompt-ui-primary-text);
2389+
}
2390+
2391+
.auto-add-checkbox label {
2392+
display: flex;
2393+
align-items: center;
2394+
gap: 8px;
2395+
cursor: pointer;
2396+
}
2397+
2398+
.auto-add-checkbox input[type="checkbox"] {
2399+
width: 16px;
2400+
height: 16px;
2401+
cursor: pointer;
23662402
}
23672403
23682404
.group-edit-mode {
@@ -2410,6 +2446,10 @@ const resetTabSizeConfig = () => {
24102446
color: white;
24112447
cursor: pointer;
24122448
transition: all 0.3s ease;
2449+
height: 32px;
2450+
box-sizing: border-box;
2451+
white-space: nowrap;
2452+
flex-shrink: 0;
24132453
}
24142454
24152455
.import-btn:hover {

tag_labels.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"items": [],
3+
"settings": {
4+
"sortMode": "time",
5+
"sortTimeDesc": true,
6+
"sortNameAsc": true,
7+
"selectedId": null
8+
}
9+
}

0 commit comments

Comments
 (0)