@peng_kai/kit 0.3.0-beta.36 → 0.3.0-beta.38

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.
@@ -5,6 +5,7 @@ import { computed, toRef } from 'vue';
5
5
  import dayjs from '../../../../libs/dayjs';
6
6
  import { type ItemSchema, useAntdForm } from '../../../../antd';
7
7
  import { PictureCardUpload } from '../../../components/upload';
8
+ import InputNumberRange from '../../../../antd/components/InputNumberRange.vue';
8
9
 
9
10
  export interface IConfigDetail {
10
11
  category_id: number
@@ -43,6 +44,8 @@ export enum FormTypes {
43
44
  SINGLE_DATE_PICKER = 13,
44
45
  /** 日期范围选择器 */
45
46
  RANGE_DATE_PICKER = 14,
47
+ /** 数字范围输入框 */
48
+ NUMBER_RANGE = 15,
46
49
  }
47
50
 
48
51
  const antdPropsResolvers: Record<number, (config: IConfigDetail) => IConfigDetail> = {
@@ -122,6 +125,12 @@ const antdPropsResolvers: Record<number, (config: IConfigDetail) => IConfigDetai
122
125
 
123
126
  return config;
124
127
  },
128
+ [FormTypes.NUMBER_RANGE](config) {
129
+ config.value = config.value === '' ? undefined : config.value.split(',');
130
+ const [min, max] = config.options?.split(',') || [];
131
+ config.options = { min: Number(min), max: Number(max) };
132
+ return config;
133
+ },
125
134
  };
126
135
 
127
136
  const antdValueResolvers: Record<number, (value: any) => any> = {
@@ -154,6 +163,11 @@ const antdValueResolvers: Record<number, (value: any) => any> = {
154
163
 
155
164
  return value;
156
165
  },
166
+ [FormTypes.NUMBER_RANGE](value) {
167
+ if (Array.isArray(value))
168
+ return value.join(',');
169
+ return value;
170
+ },
157
171
  };
158
172
  </script>
159
173
 
@@ -291,6 +305,10 @@ defineExpose({ reset, validate });
291
305
  <RangePicker v-model:value="settingForm.state[item.key]" v-bind="item.options" />
292
306
  </slot>
293
307
 
308
+ <slot v-else-if="item.form_type === FormTypes.NUMBER_RANGE" :name="FormTypes.NUMBER_RANGE">
309
+ <InputNumberRange v-model:value="settingForm.state[item.key]" v-bind="item.options" />
310
+ </slot>
311
+
294
312
  <span v-else class="text-red">没有找到预设 form_type:{{ item.form_type }},可以通过 {{ item.key }} 插槽自定义</span>
295
313
  </template>
296
314
  </FormItem>
@@ -2,7 +2,7 @@
2
2
  import { useEventListener, useIntervalFn } from '@vueuse/core';
3
3
  import { Empty, Dropdown, Badge, Menu, MenuItem } from 'ant-design-vue';
4
4
  import { type UseQueryReturnType } from '@tanstack/vue-query'
5
- import { watch, ref, computed } from 'vue'
5
+ import { watch, ref, computed, customRef } from 'vue'
6
6
  import dayjs from '../../../libs/dayjs';
7
7
  import { useRouter } from 'vue-router';
8
8
  import audioURL from './y682.mp3?url';
@@ -12,6 +12,14 @@ noticeAudio.muted = true;
12
12
  noticeAudio.src = audioURL;
13
13
  document.body.append(noticeAudio);
14
14
 
15
+ export const audioMuted = customRef<boolean>((tracker) => ({
16
+ get: () => noticeAudio.muted,
17
+ set: (val) => {
18
+ noticeAudio.muted = val;
19
+ tracker();
20
+ }
21
+ }));
22
+
15
23
  const faviconEle = document.querySelector('link[rel="icon"]');
16
24
  const logoFaviconHref = document.querySelector('link[rel="icon"]')?.getAttribute('href')!;
17
25
  const numCanvas = document.createElement('canvas') as (HTMLCanvasElement & { num: number, dataURL: string });
@@ -52,7 +60,8 @@ function operate(notice: TNotice) {
52
60
  // num > oldNum && noticeAudio.play();
53
61
  // }, { immediate: true });
54
62
  useEventListener(document, 'click', () => {
55
- noticeAudio.muted = false;
63
+ // noticeAudio.muted = false;
64
+ audioMuted.value = false;
56
65
  });
57
66
 
58
67
  useIntervalFn(() => {
@@ -100,7 +109,8 @@ useIntervalFn(() => {
100
109
  <i class="i-ri:notification-4-line block text-5" :class="{ shake: !!noticeNum }" />
101
110
  </div>
102
111
  <template #overlay>
103
- <Menu v-if="noticeNum" @click="visible = false" class="max-h-100 overflow-y-auto">
112
+ <div v-if="noticeNum">
113
+ <Menu @click="visible = false" class="max-h-100 overflow-y-auto">
104
114
  <MenuItem v-for="(item, i) of noticeList" :key="i" @click="operate(item)">
105
115
  <div class="min-w-50">
106
116
  <div>{{ item.title }}</div>
@@ -110,6 +120,9 @@ useIntervalFn(() => {
110
120
  </div>
111
121
  </MenuItem>
112
122
  </Menu>
123
+ 123
124
+ </div>
125
+
113
126
  <div v-else class="h-40 min-w-50 flex items-center justify-center rounded-2 bg-$antd-colorBgElevated shadow"
114
127
  @click="visible = false">
115
128
  <Empty description="暂无通知" :image="Empty.PRESENTED_IMAGE_SIMPLE" />
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@peng_kai/kit",
3
3
  "type": "module",
4
- "version": "0.3.0-beta.36",
4
+ "version": "0.3.0-beta.38",
5
5
  "description": "",
6
6
  "author": "",
7
7
  "license": "ISC",