@skyfox2000/webui 1.4.23 → 1.4.25

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skyfox2000/webui",
3
- "version": "1.4.23",
3
+ "version": "1.4.25",
4
4
  "description": "后台前端通用组件定义",
5
5
  "type": "module",
6
6
  "keywords": [],
@@ -32,6 +32,8 @@ import Toolbar from './toolbar/index.vue';
32
32
  export { Toolbar };
33
33
  import Icontool from './toolbar/icontool.vue';
34
34
  export { Icontool };
35
+ import GroupTools from './toolbar/groupTools.vue';
36
+ export { GroupTools };
35
37
 
36
38
  import Tree from './tree/index.vue';
37
39
  export { Tree };
@@ -0,0 +1,115 @@
1
+ <script setup lang="ts" generic="T">
2
+ import { Button, ToolIcon } from '../../common';
3
+ import type { ButtonTool } from '@/typings/tools.d';
4
+
5
+ /**
6
+ * 工具组类型定义
7
+ */
8
+ export type GroupType = 'tools' | 'split' | 'space';
9
+
10
+ /**
11
+ * 扩展的工具定义,支持自定义组件
12
+ */
13
+ export interface ExtendedButtonTool extends ButtonTool {
14
+ /**
15
+ * 自定义组件
16
+ */
17
+ component?: any;
18
+ /**
19
+ * 组件属性
20
+ */
21
+ props?: Record<string, any>;
22
+ }
23
+
24
+ /**
25
+ * 工具组定义
26
+ */
27
+ export interface ToolGroup {
28
+ /**
29
+ * 组类型
30
+ * - tools: 工具组
31
+ * - split: 竖线分割
32
+ * - space: 空白区域
33
+ */
34
+ type: GroupType;
35
+ /**
36
+ * 工具列表,当type为tools时有效
37
+ */
38
+ tools?: ExtendedButtonTool[];
39
+ /**
40
+ * 空白区域宽度,当type为space时有效
41
+ */
42
+ width?: string;
43
+ }
44
+
45
+ defineProps<{
46
+ /**
47
+ * 分组工具配置
48
+ */
49
+ groupTools: ToolGroup[];
50
+ }>();
51
+
52
+ /**
53
+ * 处理工具点击事件
54
+ */
55
+ const onToolClick = (tool: ExtendedButtonTool) => {
56
+ if (tool.click) {
57
+ // 传入必要的参数,这里使用空对象作为占位符,实际使用时由外部传入
58
+ tool.click({} as any, undefined as any, undefined as any);
59
+ }
60
+ };
61
+
62
+ /**
63
+ * 判断工具是否可见
64
+ */
65
+ const isToolVisible = (tool: ExtendedButtonTool): boolean => {
66
+ if (typeof tool.visible === 'boolean') return tool.visible;
67
+ if (typeof tool.visible === 'function') return tool.visible({} as any);
68
+ return true;
69
+ };
70
+
71
+ /**
72
+ * 判断工具是否禁用
73
+ */
74
+ const isToolDisabled = (tool: ExtendedButtonTool): boolean => {
75
+ if (typeof tool.disabled === 'boolean') return tool.disabled;
76
+ if (typeof tool.disabled === 'function') return tool.disabled({} as any);
77
+ return false;
78
+ };
79
+ </script>
80
+
81
+ <template>
82
+ <div class="flex items-center">
83
+ <template v-for="(group, groupIndex) in groupTools" :key="groupIndex">
84
+ <!-- 工具组 -->
85
+ <div v-if="group.type === 'tools'" class="inline-flex [&>button]:ml-[-1px] first:[&>button]:ml-0">
86
+ <template v-for="(tool, toolIndex) in group.tools" :key="tool.key">
87
+ <Button v-if="isToolVisible(tool) && !tool.children" :class="[
88
+ 'px-[8px] py-[2px] relative border-[#ccc] bg-[#fcfcfc] rounded-none text-[#666] hover:z-10',
89
+ toolIndex === 0 ? 'rounded-l-[5px]' : '',
90
+ toolIndex === (group.tools?.length || 0) - 1 ? 'rounded-r-[5px]' : '',
91
+ tool.class || ''
92
+ ]" :type="tool.type" :danger="tool.danger" :disabled="isToolDisabled(tool)" :tiptext="tool.label"
93
+ @click="onToolClick(tool)">
94
+ <template v-if="tool.icon">
95
+ <ToolIcon :icon="tool.icon" class="w-[18px] h-[18.5px]" clickable />
96
+ </template>
97
+ <template v-if="tool.label">
98
+ {{ tool.label }}
99
+ </template>
100
+ </Button>
101
+
102
+ <!-- 自定义组件 -->
103
+ <component v-else-if="tool.component" :is="tool.component" v-bind="tool.props"
104
+ @click="onToolClick(tool)" />
105
+ </template>
106
+ </div>
107
+
108
+ <!-- 竖线分割 -->
109
+ <div v-else-if="group.type === 'split'" class="w-[1px] h-[16px] bg-[#d9d9d9] mx-[8px]"></div>
110
+
111
+ <!-- 空白区域 -->
112
+ <div v-else-if="group.type === 'space'" :class="group.width ? group.width : 'flex-1'"></div>
113
+ </template>
114
+ </div>
115
+ </template>
@@ -0,0 +1,11 @@
1
+ /**
2
+ * 工具栏组件导出
3
+ */
4
+ export { default as GroupTools } from './groupTools.vue';
5
+ export { default as IconTool } from './icontool.vue';
6
+ export { default as Toolbar } from './index.vue';
7
+
8
+ /**
9
+ * 工具栏相关类型定义
10
+ */
11
+ export type { ToolGroup } from './groupTools.vue';
@@ -27,6 +27,7 @@ export {
27
27
  TableOperate,
28
28
  Toolbar,
29
29
  Icontool,
30
+ GroupTools,
30
31
  Tree,
31
32
  } from './content';
32
33
 
package/src/index.ts CHANGED
@@ -249,6 +249,7 @@ export {
249
249
  TableOperate,
250
250
  Toolbar,
251
251
  Icontool,
252
+ GroupTools,
252
253
  Tree,
253
254
  AutoComplete,
254
255
  Cascader,