Skip to content

Commit 29dc9db

Browse files
committed
修复标签窗口bug,修复图标加载问题
1 parent cc64189 commit 29dc9db

6 files changed

Lines changed: 682 additions & 163 deletions

File tree

js/css/popup.css

Lines changed: 107 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -175,19 +175,36 @@
175175
.tag_search_result_list {
176176
padding: 8px;
177177
overflow-y: auto;
178-
max-height: 290px;
178+
flex: 1;
179+
height: 100%;
180+
box-sizing: border-box;
181+
scrollbar-width: thin;
182+
scrollbar-color: color-mix(in srgb, var(--p-button-text-secondary-color), transparent 50%) transparent;
183+
display: flex;
184+
flex-wrap: wrap;
185+
align-content: flex-start;
186+
gap: 4px;
187+
justify-content: flex-start;
179188
}
180189

181190
.search_result_tag_item {
182-
display: flex;
191+
display: inline-flex;
183192
align-items: center;
184193
padding: 6px 12px;
194+
border-radius: 16px;
185195
cursor: pointer;
186196
transition: all 0.2s ease;
197+
background-color: rgba(255, 255, 255, 0.1);
198+
border: 1px solid rgba(255, 255, 255, 0.2);
199+
flex-shrink: 0;
200+
white-space: nowrap;
201+
font-size: 13px;
187202
}
188203

189204
.search_result_tag_item:hover {
190-
background-color: rgba(255, 255, 255, 0.1);
205+
background-color: rgba(255, 255, 255, 0.2);
206+
border-color: rgba(255, 255, 255, 0.4);
207+
transform: translateY(-1px);
191208
}
192209

193210
.search_result_tag_item .tag_category_path {
@@ -198,10 +215,12 @@
198215

199216
.search_result_tag_item.used {
200217
background-color: rgba(40, 120, 40, 0.4);
218+
border-color: rgba(40, 120, 40, 0.6);
201219
}
202220

203221
.search_result_tag_item.used:hover {
204222
background-color: rgba(40, 120, 40, 0.6);
223+
border-color: rgba(40, 120, 40, 0.8);
205224
}
206225

207226
/* 弹窗操作按钮 */
@@ -806,20 +825,22 @@
806825
/* ---窗口大小调节功能样式--- */
807826
/* 窗口大小调节手柄 */
808827
.popup_resize_handle {
809-
position: absolute;
810-
right: 0;
811-
bottom: 0;
812-
width: 16px;
813-
height: 16px;
814-
cursor: nw-resize;
828+
position: absolute !important;
829+
right: 0 !important;
830+
bottom: 0 !important;
831+
width: 16px !important;
832+
height: 16px !important;
833+
cursor: nw-resize !important;
815834
border-radius: 0 0 8px 0;
816-
z-index: 1000;
835+
z-index: 1001 !important; /* 确保在最上层 */
817836
background: transparent;
818837
transition: opacity 0.2s ease;
819-
/* display: flex; */
838+
/* display: flex !important; */
820839
align-items: center;
821840
justify-content: center;
822841
color: color-mix(in srgb, var(--p-button-text-secondary-color), transparent 50%);
842+
opacity: 0.7;
843+
pointer-events: auto !important; /* 确保可以接收鼠标事件 */
823844
}
824845

825846
.popup_resize_handle::before {
@@ -828,20 +849,36 @@
828849
height: 100%;
829850
opacity: 0.7;
830851
transition: opacity 0.2s ease;
831-
852+
}
853+
854+
.popup_resize_handle:hover {
855+
opacity: 1 !important;
856+
color: var(--fg-color);
832857
}
833858

834859
.popup_resize_handle:hover::before {
835860
opacity: 1;
836861
color: var(--fg-color);
837862
}
838863

864+
/* 确保图标正确显示 */
865+
.popup_resize_handle .icon-resize-handle {
866+
width: 12px !important;
867+
height: 12px !important;
868+
display: block !important;
869+
pointer-events: none; /* 图标不接收事件,让父元素处理 */
870+
}
871+
839872
/* 窗口调节中的样式 */
840873
.popup_container.resizing {
841874
transition: none !important;
842875
user-select: none;
843876
}
844877

878+
.popup_container.resizing .popup_resize_handle {
879+
opacity: 1 !important;
880+
}
881+
845882
.popup_container.resizing .popup_resize_handle::before {
846883
opacity: 1;
847884
}
@@ -882,8 +919,63 @@
882919
}
883920

884921
.popup_container.tag_popup .tag_search_result_list {
885-
max-height: none;
922+
max-height: none !important;
886923
/* 移除固定高度限制 */
887-
height: calc(100% - 60px);
888-
/* 动态计算高度,减去标题栏高度 */
924+
height: 100% !important;
925+
/* 占满可用高度 */
926+
flex: 1 !important;
927+
display: flex !important;
928+
flex-direction: row !important;
929+
flex-wrap: wrap !important;
930+
align-content: flex-start !important;
931+
justify-content: flex-start !important;
932+
gap: 4px !important;
933+
position: relative !important;
934+
/* 为无匹配消息的绝对定位提供参考 */
935+
min-height: 300px !important;
936+
/* 确保有足够高度进行垂直居中 */
937+
margin: 0 !important;
938+
padding: 8px !important;
939+
}
940+
941+
/* 搜索结果列表的滚动条样式 */
942+
.tag_search_result_list::-webkit-scrollbar {
943+
width: 6px;
944+
}
945+
946+
.tag_search_result_list::-webkit-scrollbar-track {
947+
background: transparent;
948+
}
949+
950+
.tag_search_result_list::-webkit-scrollbar-thumb {
951+
background-color: color-mix(in srgb, var(--p-button-text-secondary-color), transparent 50%);
952+
border-radius: 3px;
953+
}
954+
955+
/* 搜索结果空消息样式 */
956+
.search_empty_message {
957+
position: absolute;
958+
top: 50%;
959+
left: 50%;
960+
transform: translate(-50%, -50%);
961+
text-align: center;
962+
color: var(--p-text-muted-color);
963+
font-size: 14px;
964+
width: 100%;
965+
pointer-events: none;
966+
user-select: none;
967+
}
968+
969+
/* 搜索状态下的特殊样式 */
970+
.popup_container.tag_popup:has(.tag_search_result_list) .popup_tabs_container,
971+
.popup_container.tag_popup:has(.tag_search_result_list) .tag_category_container {
972+
display: none !important;
973+
visibility: hidden !important;
974+
}
975+
976+
.popup_container.tag_popup .tag_search_result_list:empty::after {
977+
content: '';
978+
display: block;
979+
height: 100%;
980+
min-height: 300px;
889981
}

js/modules/PromptAssistant.js

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1031,7 +1031,7 @@ class PromptAssistant {
10311031
{
10321032
id: 'history',
10331033
title: '历史',
1034-
icon: 'icon-history.svg',
1034+
icon: 'icon-history',
10351035
onClick: (e, widget) => {
10361036
UIToolkit.handlePopupButtonClick(
10371037
e,
@@ -1047,7 +1047,7 @@ class PromptAssistant {
10471047
{
10481048
id: 'undo',
10491049
title: '撤销',
1050-
icon: 'icon-undo.svg',
1050+
icon: 'icon-undo',
10511051
onClick: (e, widget) => {
10521052
e.preventDefault();
10531053
e.stopPropagation();
@@ -1073,7 +1073,7 @@ class PromptAssistant {
10731073
{
10741074
id: 'redo',
10751075
title: '重做',
1076-
icon: 'icon-redo.svg',
1076+
icon: 'icon-redo',
10771077
onClick: (e, widget) => {
10781078
e.preventDefault();
10791079
e.stopPropagation();
@@ -1104,7 +1104,7 @@ class PromptAssistant {
11041104
{
11051105
id: 'tag',
11061106
title: '标签工具',
1107-
icon: 'icon-tag.svg',
1107+
icon: 'icon-tag',
11081108
onClick: (e, widget) => {
11091109
// 创建一个带有标签选择功能的显示函数
11101110
const showTagPopup = (options) => {
@@ -1151,7 +1151,7 @@ class PromptAssistant {
11511151
{
11521152
id: 'expand',
11531153
title: '扩写',
1154-
icon: 'icon-expand.svg',
1154+
icon: 'icon-expand',
11551155
onClick: async (e, widget) => {
11561156
logger.debug('按钮点击 | 动作: 扩写');
11571157

@@ -1237,7 +1237,7 @@ class PromptAssistant {
12371237
{
12381238
id: 'translate',
12391239
title: '翻译',
1240-
icon: 'icon-translate.svg',
1240+
icon: 'icon-translate',
12411241
onClick: async (e, widget) => {
12421242
logger.debug('按钮点击 | 动作: 翻译');
12431243

@@ -1414,7 +1414,8 @@ class PromptAssistant {
14141414
let otherButtons = [];
14151415
let divider = null;
14161416

1417-
buttonConfigs.forEach(config => {
1417+
// ---使用for...of循环支持异步操作---
1418+
for (const config of buttonConfigs) {
14181419
if (config.type === 'divider') {
14191420
// 创建分割线但暂不添加
14201421
divider = document.createElement('div');
@@ -1424,20 +1425,20 @@ class PromptAssistant {
14241425
if (config.id) {
14251426
widget.buttons[config.id] = divider;
14261427
}
1427-
return;
1428+
continue;
14281429
}
14291430

14301431
// 检查按钮是否可见
14311432
if (config.visible === false) {
14321433
// 区分节点类型和功能禁用的情况
14331434
const reason = (widget.nodeInfo?.isNoteNode && config.id !== 'translate') ? "Note节点限制" : "功能禁用";
14341435
// logger.debug(`按钮跳过 | 按钮: ${config.id || 'unknown'} | 原因: ${reason}`);
1435-
return;
1436+
continue;
14361437
}
14371438

1438-
// 创建按钮
1439+
// ---异步创建按钮---
14391440
const button = this.addButtonWithIcon(widget, config);
1440-
if (!button) return;
1441+
if (!button) continue;
14411442

14421443
// 设置初始状态
14431444
if (config.initialState) {
@@ -1452,7 +1453,7 @@ class PromptAssistant {
14521453
} else {
14531454
otherButtons.push(button);
14541455
}
1455-
});
1456+
}
14561457

14571458
// 添加按钮到DOM,并在需要时添加分割线
14581459
let addedButtonCount = 0;
@@ -1498,11 +1499,8 @@ class PromptAssistant {
14981499

14991500
// 添加图标
15001501
if (icon) {
1501-
// 创建图标元素
15021502
const iconElement = document.createElement('span');
1503-
// 使用icon.css中定义的类名
1504-
const iconClass = icon.replace('.svg', '');
1505-
iconElement.className = iconClass;
1503+
iconElement.className = icon;
15061504
iconElement.setAttribute('aria-hidden', 'true');
15071505
button.appendChild(iconElement);
15081506
}
@@ -1531,6 +1529,8 @@ class PromptAssistant {
15311529
return button;
15321530
}
15331531

1532+
1533+
15341534
/**
15351535
* 设置UI位置
15361536
* 使用绝对定位方式

0 commit comments

Comments
 (0)