Skip to content

Commit b76e91b

Browse files
authored
Merge pull request ZToolsCenter#648 from LowProfile666/plugin/code-snippets
Update plugin 代码模板 v1.2.1
2 parents 5197822 + 44bd954 commit b76e91b

6 files changed

Lines changed: 39 additions & 16 deletions

File tree

‎plugins/code-snippets/CHANGELOG.md‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
本文件记录「代码模板」插件每次版本更新的内容。
44

5+
## 1.2.1 - 2026-10-10
6+
7+
### 优化
8+
9+
- 优化左侧列表布局:置顶 / 复制 / 删除按钮改为 hover 时悬浮在列表项右侧,不再占用布局宽度,模板名称与描述可完整展示(此前按钮即使隐藏也占据约 90px 宽度,导致标题被截断而右侧仍显空旷)
10+
511
## 1.2.0 - 2026-08-14
612

713
### 新增

‎plugins/code-snippets/README.md‎

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,16 @@ ZTools 插件 —— 保存和管理常用代码模板,支持一键复制、
66

77
## 更新日志
88

9+
### v1.2.1
10+
11+
- 优化左侧列表布局:操作按钮改为 hover 悬浮显示,模板名称不再被截断
12+
913
### v1.2.0
1014

1115
- 新增变量占位符插值:模板支持 `${1}`、`${2:默认值}`,复制时填参自动替换
1216
- 新增模板置顶功能
1317
- 新增直接搜索:在 ZTools 直接输入关键词即可搜索模板
1418

15-
### v1.1.1
16-
17-
- 优化模板列表显示方式:语言和复制次数改为标签形式显示,标题不再被遮挡
18-
19-
### v1.1.0
20-
21-
- 新增快捷键 `Alt+1~5` 快速复制前 5 个模板
22-
- 新增快捷键 `Alt+Insert` 快速新增模板(自动填入剪贴板内容)
23-
- 模板列表显示快捷键提示,搜索框下方显示快捷键帮助栏
24-
2519
## 使用场景
2620

2721
- **刷题/竞赛**:保存常用算法模板(快排、并查集、线段树等),比赛时一键复制

‎plugins/code-snippets/package-lock.json‎

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

‎plugins/code-snippets/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "code-snippets",
3-
"version": "1.2.0",
3+
"version": "1.2.1",
44
"description": "保存和管理常用代码模板,支持一键复制、搜索过滤、按使用频率排序、导入导出 JSON 文件。",
55
"type": "module",
66
"scripts": {

‎plugins/code-snippets/public/plugin.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"description": "保存和管理常用代码模板,支持一键复制、搜索过滤、按使用频率排序、导入导出 JSON 文件。",
66
"author": "咖啡八杯",
77
"categories": ["development", "productivity"],
8-
"version": "1.2.0",
8+
"version": "1.2.1",
99
"main": "index.html",
1010
"preload": "preload/services.js",
1111
"logo": "logo.png",

‎plugins/code-snippets/src/Snippets/index.vue‎

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -885,6 +885,16 @@ watch(() => props.enterAction, (action) => {
885885
display: flex;
886886
height: 100vh;
887887
overflow: hidden;
888+
/* 悬浮操作按钮的背景色,需与列表项 hover / 选中时的底色一致,避免遮挡文字时露底 */
889+
--list-item-hover-bg: #e4ecf4;
890+
--list-item-active-bg: #d5e4f4;
891+
}
892+
893+
@media (prefers-color-scheme: dark) {
894+
.snippets {
895+
--list-item-hover-bg: #343c44;
896+
--list-item-active-bg: #384758;
897+
}
888898
}
889899
890900
.sidebar {
@@ -921,9 +931,9 @@ watch(() => props.enterAction, (action) => {
921931
}
922932
923933
.template-item {
934+
position: relative;
924935
display: flex;
925936
align-items: center;
926-
justify-content: space-between;
927937
padding: 8px 10px;
928938
border-radius: 6px;
929939
cursor: pointer;
@@ -1014,15 +1024,28 @@ watch(() => props.enterAction, (action) => {
10141024
}
10151025
10161026
.template-actions {
1027+
/* 绝对定位悬浮在列表项右侧,不占用布局宽度,模板名可占满整行 */
1028+
position: absolute;
1029+
right: 6px;
1030+
top: 50%;
1031+
transform: translateY(-50%);
10171032
display: flex;
10181033
gap: 4px;
1019-
margin-left: 8px;
1034+
padding-left: 20px;
1035+
background: linear-gradient(to right, transparent, var(--list-item-hover-bg) 18px);
10201036
opacity: 0;
1037+
pointer-events: none;
10211038
transition: opacity 0.15s;
10221039
}
10231040
10241041
.template-item:hover .template-actions {
10251042
opacity: 1;
1043+
pointer-events: auto;
1044+
}
1045+
1046+
/* 选中项被 hover 时以选中底色作遮罩,避免与列表项背景不一致 */
1047+
.template-item.active .template-actions {
1048+
background: linear-gradient(to right, transparent, var(--list-item-active-bg) 18px);
10261049
}
10271050
10281051
.editor {

0 commit comments

Comments
 (0)