jky-component-lib 0.0.24 → 0.0.36

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.
@@ -1,6 +1,7 @@
1
1
  import { MenuProps } from 'element-plus/es/components/menu';
2
2
  interface MenuItem {
3
- index: string;
3
+ id?: string;
4
+ index?: string;
4
5
  title?: string;
5
6
  icon?: string;
6
7
  disabled?: boolean;
@@ -51,11 +51,12 @@ const _sfc_main = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues({
51
51
  },
52
52
  setup(__props) {
53
53
  function renderMenuItem(item) {
54
+ var _a;
54
55
  return h(
55
56
  ElMenuItem,
56
57
  {
57
- index: item.index,
58
- disabled: item.disabled,
58
+ index: item.index || item.id || "",
59
+ disabled: (_a = item.disabled) != null ? _a : false,
59
60
  route: item.route
60
61
  },
61
62
  {
@@ -72,7 +73,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues({
72
73
  return h(
73
74
  ElSubMenu,
74
75
  {
75
- index: item.index,
76
+ index: item.index || item.id || "",
76
77
  disabled: (_a = item.disabled) != null ? _a : false,
77
78
  popperOffset: item.popperOffset
78
79
  },
@@ -28,8 +28,10 @@
28
28
 
29
29
  /* 2. 基础样式 */
30
30
  .jky-menu {
31
- background-color: var(--jky-menu-bg-color);
32
- color: var(--jky-menu-text-color);
31
+ .el-sub-menu.is-active {
32
+ }
33
+ .el-sub-menu__title {
34
+ }
33
35
  }
34
36
 
35
37
  /* 3. 菜单项容器样式 - 确保统一高度 */
@@ -53,18 +55,9 @@ li + li {
53
55
 
54
56
  /* 5. 菜单项标题样式 */
55
57
  .jky-menu-item__title {
56
- flex: 1;
57
- font-size: var(--jky-menu-item-font-size);
58
- color: var(--jky-menu-text-color);
59
- line-height: normal;
60
- overflow: hidden;
61
- text-overflow: ellipsis;
62
- white-space: nowrap;
63
58
  }
64
59
 
65
60
  /* 6. 禁用状态 */
66
61
  .jky-menu-item.is-disabled {
67
- opacity: var(--jky-menu-disabled-opacity);
68
- color: var(--jky-menu-disabled-text-color);
69
- cursor: not-allowed;
62
+ /* 禁用状态下的样式 */
70
63
  }
@@ -1,4 +1,4 @@
1
- const version = "0.0.24";
1
+ const version = "0.0.36";
2
2
  export {
3
3
  version
4
4
  };
@@ -1,3 +1,6 @@
1
+ import { ButtonType } from 'element-plus';
2
+ import { TooltipTriggerType } from 'element-plus/es/components/tooltip';
3
+ import { Arrayable } from 'element-plus/es/utils';
1
4
  type __VLS_Props = {
2
5
  logo?: string;
3
6
  title?: string;
@@ -7,7 +10,36 @@ type __VLS_Props = {
7
10
  statusIcons?: StatusIcon[];
8
11
  userName?: string;
9
12
  userAvatar?: string;
13
+ /**
14
+ * 最左侧菜单按钮弹出窗里的内容
15
+ */
16
+ popover?: {
17
+ menus?: PopoverMenuItem[];
18
+ buttonClass?: string;
19
+ elButtonClass?: string;
20
+ elButtonType?: ButtonType;
21
+ width?: number;
22
+ trigger?: Arrayable<TooltipTriggerType>;
23
+ highlightCurrent?: boolean;
24
+ };
25
+ showLogout?: boolean;
26
+ userDropdownItems?: UserDropdonItem[];
10
27
  };
28
+ interface PopoverMenuItem {
29
+ label: string;
30
+ value: string;
31
+ onClick?: () => void;
32
+ disabled?: boolean;
33
+ icon?: string;
34
+ elButtonClass?: string;
35
+ }
36
+ interface UserDropdonItem {
37
+ label: string;
38
+ value: string;
39
+ icon?: string;
40
+ disabled?: boolean;
41
+ divided?: boolean;
42
+ }
11
43
  interface StatusIcon {
12
44
  icon: string | object;
13
45
  label: string;
@@ -26,16 +58,15 @@ declare function __VLS_template(): {
26
58
  };
27
59
  type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
28
60
  declare const __VLS_component: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {} & {
61
+ command: (command: string) => any;
29
62
  logout: () => any;
30
- clearCache: () => any;
31
- profile: () => any;
32
63
  }, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{
64
+ onCommand?: ((command: string) => any) | undefined;
33
65
  onLogout?: (() => any) | undefined;
34
- onClearCache?: (() => any) | undefined;
35
- onProfile?: (() => any) | undefined;
36
66
  }>, {
37
67
  height: string | number;
38
68
  statusIcons: StatusIcon[];
69
+ userDropdownItems: UserDropdonItem[];
39
70
  }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, HTMLElement>;
40
71
  declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
41
72
  export default _default;
@@ -17,31 +17,37 @@ var __spreadValues = (a, b) => {
17
17
  return a;
18
18
  };
19
19
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
- import { defineComponent, computed, openBlock, createElementBlock, normalizeStyle, createElementVNode, createCommentVNode, toDisplayString, renderSlot, Fragment, renderList, normalizeClass, createBlock, unref, withCtx, resolveDynamicComponent, createVNode, createTextVNode } from "vue";
21
- import { ElIcon, ElDropdown, ElDropdownMenu, ElDropdownItem } from "element-plus";
20
+ import { defineComponent, computed, ref, openBlock, createElementBlock, normalizeStyle, createElementVNode, createVNode, unref, withCtx, Fragment, renderList, createBlock, normalizeClass, createCommentVNode, toDisplayString, renderSlot, resolveDynamicComponent, createTextVNode } from "vue";
21
+ import { ElPopover, ElButton, ElIcon, ElDropdown, ElDropdownMenu, ElDropdownItem } from "element-plus";
22
22
  const _hoisted_1 = { class: "jky-page-header__container" };
23
- const _hoisted_2 = { class: "jky-page-header__left" };
24
- const _hoisted_3 = ["src", "alt"];
25
- const _hoisted_4 = {
23
+ const _hoisted_2 = {
24
+ key: 0,
25
+ class: "jky-page-header__popover mr-2 h-full flex items-center text-white"
26
+ };
27
+ const _hoisted_3 = { class: "grid grid-cols-3 gap-2 p-2" };
28
+ const _hoisted_4 = { class: "text-sm text-center" };
29
+ const _hoisted_5 = { class: "jky-page-header__left" };
30
+ const _hoisted_6 = ["src", "alt"];
31
+ const _hoisted_7 = {
26
32
  key: 1,
27
33
  class: "jky-page-header__title"
28
34
  };
29
- const _hoisted_5 = { class: "jky-page-header__center" };
30
- const _hoisted_6 = { class: "jky-page-header__right" };
31
- const _hoisted_7 = { class: "jky-page-header__status-icons hidden md:flex" };
32
- const _hoisted_8 = {
35
+ const _hoisted_8 = { class: "jky-page-header__center" };
36
+ const _hoisted_9 = { class: "jky-page-header__right" };
37
+ const _hoisted_10 = { class: "jky-page-header__status-icons hidden md:flex" };
38
+ const _hoisted_11 = {
33
39
  xmlns: "http://www.w3.org/2000/svg",
34
40
  style: { "color": "white" },
35
41
  fill: "none",
36
42
  viewBox: "0 0 24 24",
37
43
  stroke: "currentColor"
38
44
  };
39
- const _hoisted_9 = { class: "jky-page-header__time hidden md:block" };
40
- const _hoisted_10 = { class: "jky-page-header__user" };
41
- const _hoisted_11 = ["src", "alt"];
42
- const _hoisted_12 = {
45
+ const _hoisted_12 = { class: "jky-page-header__time hidden md:block" };
46
+ const _hoisted_13 = { class: "jky-page-header__user" };
47
+ const _hoisted_14 = ["src", "alt"];
48
+ const _hoisted_15 = {
43
49
  key: 0,
44
- class: "jky-page-header__username hidden md:block"
50
+ class: "jky-page-header__username text-base hidden md:block"
45
51
  };
46
52
  const _sfc_main = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues({}, {
47
53
  name: "JkyPageHeader"
@@ -55,12 +61,38 @@ const _sfc_main = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues({
55
61
  backgroundImage: {},
56
62
  statusIcons: { default: () => [] },
57
63
  userName: {},
58
- userAvatar: {}
64
+ userAvatar: {},
65
+ popover: {},
66
+ showLogout: { type: Boolean },
67
+ userDropdownItems: { default: () => [
68
+ { label: "个人信息", value: "profile", icon: "icon-[heroicons--user]" },
69
+ { label: "清理缓存", value: "clear", icon: "icon-[heroicons--trash]" },
70
+ { label: "注销", value: "logout", icon: "icon-[heroicons--arrow-right-on-rectangle]" }
71
+ ] }
59
72
  },
60
- emits: ["logout", "clearCache", "profile"],
73
+ emits: ["logout", "command"],
61
74
  setup(__props, { emit: __emit }) {
62
75
  const props = __props;
63
76
  const emit = __emit;
77
+ const popover = computed(() => __spreadValues({
78
+ menus: [],
79
+ buttonClass: "w-20 h-20",
80
+ elButtonClass: "",
81
+ width: 400,
82
+ trigger: "click",
83
+ highlightCurrent: true
84
+ }, props.popover));
85
+ const popoverIndex = ref("");
86
+ function onPopoverButtonClick(item) {
87
+ var _a;
88
+ if (popover.value.highlightCurrent) {
89
+ popoverIndex.value = item.value;
90
+ }
91
+ (_a = item.onClick) == null ? void 0 : _a.call(item);
92
+ }
93
+ function handleCommand(command) {
94
+ emit("command", command);
95
+ }
64
96
  const heightValue = computed(() => {
65
97
  if (typeof props.height === "number") {
66
98
  return `${props.height}px`;
@@ -79,35 +111,67 @@ const _sfc_main = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues({
79
111
  }
80
112
  return style;
81
113
  });
82
- function handleLogout() {
83
- emit("logout");
84
- }
85
- function handleClearCache() {
86
- emit("clearCache");
87
- }
88
- function handleProfile() {
89
- emit("profile");
90
- }
91
114
  return (_ctx, _cache) => {
115
+ var _a;
92
116
  return openBlock(), createElementBlock("header", {
93
117
  class: "jky-page-header",
94
118
  style: normalizeStyle([backgroundStyle.value, { height: heightValue.value }])
95
119
  }, [
96
120
  createElementVNode("div", _hoisted_1, [
97
- createElementVNode("div", _hoisted_2, [
121
+ ((_a = popover.value.menus) == null ? void 0 : _a.length) ? (openBlock(), createElementBlock("div", _hoisted_2, [
122
+ createVNode(unref(ElPopover), {
123
+ title: "菜单",
124
+ placement: "bottom-start",
125
+ class: "h-full",
126
+ trigger: popover.value.trigger,
127
+ width: popover.value.width
128
+ }, {
129
+ reference: withCtx(() => [..._cache[1] || (_cache[1] = [
130
+ createElementVNode("span", { class: "icon-[ant-design--menu-fold-outlined] text-[white] text-2xl cursor-pointer hover:opacity-80" }, null, -1)
131
+ ])]),
132
+ default: withCtx(() => [
133
+ createElementVNode("div", _hoisted_3, [
134
+ (openBlock(true), createElementBlock(Fragment, null, renderList(popover.value.menus, (item) => {
135
+ return openBlock(), createBlock(unref(ElButton), {
136
+ key: item.value,
137
+ disabled: item.disabled,
138
+ class: normalizeClass(["w-fit! h-fit! ml-0!", [popover.value.elButtonClass, item.elButtonClass]]),
139
+ type: unref(popoverIndex) === item.value ? "primary" : popover.value.elButtonType || "default",
140
+ onClick: ($event) => onPopoverButtonClick(item)
141
+ }, {
142
+ default: withCtx(() => [
143
+ createElementVNode("div", {
144
+ class: normalizeClass(["jky-page-header__popover-inner flex flex-col justify-around items-center", popover.value.buttonClass])
145
+ }, [
146
+ item.icon ? (openBlock(), createElementBlock("span", {
147
+ key: 0,
148
+ class: normalizeClass(["text-xl mr-2", [item.icon]])
149
+ }, null, 2)) : createCommentVNode("", true),
150
+ createElementVNode("span", _hoisted_4, toDisplayString(item.label), 1)
151
+ ], 2)
152
+ ]),
153
+ _: 2
154
+ }, 1032, ["disabled", "class", "type", "onClick"]);
155
+ }), 128))
156
+ ])
157
+ ]),
158
+ _: 1
159
+ }, 8, ["trigger", "width"])
160
+ ])) : createCommentVNode("", true),
161
+ createElementVNode("div", _hoisted_5, [
98
162
  __props.logo ? (openBlock(), createElementBlock("img", {
99
163
  key: 0,
100
164
  src: __props.logo,
101
165
  alt: __props.title || "Logo",
102
166
  class: "jky-page-header__logo"
103
- }, null, 8, _hoisted_3)) : createCommentVNode("", true),
104
- __props.title ? (openBlock(), createElementBlock("span", _hoisted_4, toDisplayString(__props.title), 1)) : createCommentVNode("", true)
167
+ }, null, 8, _hoisted_6)) : createCommentVNode("", true),
168
+ __props.title ? (openBlock(), createElementBlock("span", _hoisted_7, toDisplayString(__props.title), 1)) : createCommentVNode("", true)
105
169
  ]),
106
- createElementVNode("div", _hoisted_5, [
170
+ createElementVNode("div", _hoisted_8, [
107
171
  renderSlot(_ctx.$slots, "center")
108
172
  ]),
109
- createElementVNode("div", _hoisted_6, [
110
- createElementVNode("div", _hoisted_7, [
173
+ createElementVNode("div", _hoisted_9, [
174
+ createElementVNode("div", _hoisted_10, [
111
175
  (openBlock(true), createElementBlock(Fragment, null, renderList(__props.statusIcons, (icon, index) => {
112
176
  return openBlock(), createElementBlock(Fragment, { key: index }, [
113
177
  typeof icon.icon === "string" ? (openBlock(), createElementBlock("span", {
@@ -171,7 +235,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues({
171
235
  class: "jky-page-header__status-icon text-white"
172
236
  }, {
173
237
  default: withCtx(() => [
174
- (openBlock(), createElementBlock("svg", _hoisted_8, [..._cache[0] || (_cache[0] = [
238
+ (openBlock(), createElementBlock("svg", _hoisted_11, [..._cache[2] || (_cache[2] = [
175
239
  createElementVNode("path", {
176
240
  "stroke-linecap": "round",
177
241
  "stroke-linejoin": "round",
@@ -185,45 +249,40 @@ const _sfc_main = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues({
185
249
  ]),
186
250
  _: 1
187
251
  })) : createCommentVNode("", true),
188
- createElementVNode("div", _hoisted_9, [
252
+ createElementVNode("div", _hoisted_12, [
189
253
  renderSlot(_ctx.$slots, "time", {}, () => [
190
254
  createElementVNode("span", null, toDisplayString((/* @__PURE__ */ new Date()).toLocaleString("zh-CN")), 1)
191
255
  ])
192
256
  ]),
193
- createVNode(unref(ElDropdown), { trigger: "click" }, {
257
+ createVNode(unref(ElDropdown), {
258
+ trigger: "hover",
259
+ onCommand: handleCommand
260
+ }, {
194
261
  dropdown: withCtx(() => [
195
262
  createVNode(unref(ElDropdownMenu), null, {
196
263
  default: withCtx(() => [
197
- createVNode(unref(ElDropdownItem), { onClick: handleProfile }, {
198
- default: withCtx(() => [..._cache[2] || (_cache[2] = [
199
- createElementVNode("span", { class: "icon-[heroicons--user]" }, null, -1),
200
- createTextVNode(" 个人信息 ", -1)
201
- ])]),
202
- _: 1
203
- }),
204
- createVNode(unref(ElDropdownItem), { onClick: handleClearCache }, {
205
- default: withCtx(() => [..._cache[3] || (_cache[3] = [
206
- createElementVNode("span", { class: "icon-[heroicons--trash]" }, null, -1),
207
- createTextVNode(" 清理缓存 ", -1)
208
- ])]),
209
- _: 1
210
- }),
211
- createVNode(unref(ElDropdownItem), {
212
- divided: "",
213
- onClick: handleLogout
214
- }, {
215
- default: withCtx(() => [..._cache[4] || (_cache[4] = [
216
- createElementVNode("span", { class: "icon-[heroicons--arrow-right-on-rectangle]" }, null, -1),
217
- createTextVNode(" 注销 ", -1)
218
- ])]),
219
- _: 1
220
- })
264
+ (openBlock(true), createElementBlock(Fragment, null, renderList(__props.userDropdownItems, (item) => {
265
+ return openBlock(), createBlock(unref(ElDropdownItem), {
266
+ key: item.value,
267
+ command: item.value,
268
+ disabled: item.disabled,
269
+ divided: item.divided
270
+ }, {
271
+ default: withCtx(() => [
272
+ createElementVNode("span", {
273
+ class: normalizeClass(["mr-2", item.icon])
274
+ }, null, 2),
275
+ createTextVNode(" " + toDisplayString(item.label), 1)
276
+ ]),
277
+ _: 2
278
+ }, 1032, ["command", "disabled", "divided"]);
279
+ }), 128))
221
280
  ]),
222
281
  _: 1
223
282
  })
224
283
  ]),
225
284
  default: withCtx(() => [
226
- createElementVNode("div", _hoisted_10, [
285
+ createElementVNode("div", _hoisted_13, [
227
286
  renderSlot(_ctx.$slots, "userIcon", {}, () => [
228
287
  __props.userAvatar ? (openBlock(), createBlock(unref(ElIcon), {
229
288
  key: 0,
@@ -235,7 +294,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues({
235
294
  src: __props.userAvatar,
236
295
  alt: __props.userName,
237
296
  class: "rounded-full"
238
- }, null, 8, _hoisted_11)
297
+ }, null, 8, _hoisted_14)
239
298
  ]),
240
299
  _: 1
241
300
  })) : (openBlock(), createBlock(unref(ElIcon), {
@@ -243,17 +302,25 @@ const _sfc_main = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues({
243
302
  size: 24,
244
303
  class: "jky-page-header__avatar"
245
304
  }, {
246
- default: withCtx(() => [..._cache[1] || (_cache[1] = [
305
+ default: withCtx(() => [..._cache[3] || (_cache[3] = [
247
306
  createElementVNode("span", { class: "icon-[heroicons--user]" }, null, -1)
248
307
  ])]),
249
308
  _: 1
250
309
  }))
251
310
  ]),
252
- __props.userName ? (openBlock(), createElementBlock("span", _hoisted_12, toDisplayString(__props.userName), 1)) : createCommentVNode("", true)
311
+ __props.userName ? (openBlock(), createElementBlock("span", _hoisted_15, toDisplayString(__props.userName), 1)) : createCommentVNode("", true)
253
312
  ])
254
313
  ]),
255
314
  _: 3
256
- })
315
+ }),
316
+ __props.showLogout ? (openBlock(), createElementBlock("div", {
317
+ key: 1,
318
+ class: "jky-page-header__logout h-full flex items-center text-white",
319
+ onClick: _cache[0] || (_cache[0] = ($event) => _ctx.$emit("logout"))
320
+ }, [..._cache[4] || (_cache[4] = [
321
+ createElementVNode("span", { class: "icon-[ri--logout-circle-line] mr-2" }, null, -1),
322
+ createElementVNode("span", null, "退出登录", -1)
323
+ ])])) : createCommentVNode("", true)
257
324
  ])
258
325
  ])
259
326
  ], 4);
@@ -22,7 +22,7 @@
22
22
  --jky-page-header-title-size-mobile: 16px;
23
23
  --jky-page-header-title-weight: 600;
24
24
  --jky-page-header-text-color: rgba(255, 255, 255, 0.85);
25
- --jky-page-header-text-size: 14px;
25
+ --jky-page-header-text-size: 16px;
26
26
 
27
27
  /* 图标 */
28
28
  --jky-page-header-icon-color: #ffffff;
@@ -123,6 +123,10 @@ img {
123
123
  color: var(--jky-page-header-text-color);
124
124
  white-space: nowrap;
125
125
  }
126
+ .jky-page-header__logout {
127
+ font-size: var(--jky-page-header-text-size);
128
+ color: var(--jky-page-header-text-color);
129
+ }
126
130
  /* 响应式设计 */
127
131
  @media (max-width: 768px) {
128
132
  .jky-page-header__container {