@astrolimit/vue3-web-hooks 25.10.10 → 25.11.1
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/dist/index.d.ts +23 -11
- package/dist/index.js +3 -47
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as vue0 from "vue";
|
|
2
|
-
import { Ref, VNode } from "vue";
|
|
2
|
+
import { DefineComponent, FunctionalComponent, Ref, VNode } from "vue";
|
|
3
3
|
import * as _vueuse_core0 from "@vueuse/core";
|
|
4
4
|
import mitt from "mitt";
|
|
5
5
|
import * as _vue_reactivity0 from "@vue/reactivity";
|
|
@@ -41,8 +41,8 @@ type AnyRecord$1 = Record<string, any>;
|
|
|
41
41
|
type R<T extends AnyRecord$1> = ReturnType<typeof mitt<T>> & {
|
|
42
42
|
stop(key: keyof T): void;
|
|
43
43
|
pause(key: keyof T): void;
|
|
44
|
-
subscribe<P extends keyof T>(key: P, cb: (data: T[P]) => void): void;
|
|
45
|
-
once<P extends keyof T>(key: P, cb: (data: T[P]) => void): void;
|
|
44
|
+
subscribe<P$1 extends keyof T>(key: P$1, cb: (data: T[P$1]) => void): void;
|
|
45
|
+
once<P$1 extends keyof T>(key: P$1, cb: (data: T[P$1]) => void): void;
|
|
46
46
|
};
|
|
47
47
|
/**
|
|
48
48
|
* 在父祖组件中使用
|
|
@@ -122,13 +122,6 @@ declare const useSortable: <T extends AnyRecord>(params: {
|
|
|
122
122
|
isSorting: Ref<boolean, boolean>;
|
|
123
123
|
};
|
|
124
124
|
//#endregion
|
|
125
|
-
//#region src/hooks/useTitle.d.ts
|
|
126
|
-
declare const setGlobalAppTitle: (title: string) => void;
|
|
127
|
-
declare const setI18nTransFunc: (t: (val: string) => string) => void;
|
|
128
|
-
declare const getGlobalAppTitle: () => string | undefined;
|
|
129
|
-
declare const getI18nTransFunc: () => ((...args: any[]) => any) | undefined;
|
|
130
|
-
declare const useTitle: (newTitle?: string | Ref<string>) => Ref<string, string>;
|
|
131
|
-
//#endregion
|
|
132
125
|
//#region src/hooks/useViewRefresh.d.ts
|
|
133
126
|
type PlaceholderProps = {
|
|
134
127
|
children?: VNode | VNode[] | null | (() => VNode | VNode[] | null);
|
|
@@ -175,4 +168,23 @@ declare function useWatermark(opts?: {
|
|
|
175
168
|
clear: () => void;
|
|
176
169
|
};
|
|
177
170
|
//#endregion
|
|
178
|
-
|
|
171
|
+
//#region src/ivue/index.d.ts
|
|
172
|
+
/**
|
|
173
|
+
* 提取函数第一个参数的类型
|
|
174
|
+
*/
|
|
175
|
+
type ExtractFirstParam<T> = T extends ((first: infer U, ...args: any[]) => any) ? U : never;
|
|
176
|
+
/**
|
|
177
|
+
* Vue 组件类型
|
|
178
|
+
*/
|
|
179
|
+
type IVueComponent = DefineComponent<any, any, any, any> | (new (...args: any[]) => any) | FunctionalComponent<any>;
|
|
180
|
+
type ExtractComponentProps<C> = C extends (new (...args: any[]) => {
|
|
181
|
+
$props: infer P;
|
|
182
|
+
}) ? P : C extends {
|
|
183
|
+
new (...args: any[]): any;
|
|
184
|
+
} ? InstanceType<C>['$props'] : C extends DefineComponent<any, any, any, any> ? InstanceType<C>['$props'] : C extends FunctionalComponent<infer P> ? P : never;
|
|
185
|
+
/**
|
|
186
|
+
* 提取 Vue 组件的 props 类型
|
|
187
|
+
*/
|
|
188
|
+
type IVueProps<T> = Partial<ExtractComponentProps<T>>;
|
|
189
|
+
//#endregion
|
|
190
|
+
export { type ExtractFirstParam, type IVueComponent, type IVueProps, useDivSize, useDrawerWidth, useInjectMitt, useNetwork, useNewMitt, useNow, useSortable, useStyleSheetLink, useViewRefresh, useVueInterval, useWatermark };
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import _, { cloneDeep } from "lodash";
|
|
2
|
-
import { computed, createElementVNode, defineComponent,
|
|
2
|
+
import { computed, createElementVNode, defineComponent, inject, isRef, nextTick, onBeforeUnmount, onMounted, onUnmounted, provide, reactive, ref, toRefs, unref, watch } from "vue";
|
|
3
3
|
import { tryOnMounted, tryOnUnmounted, useDebounceFn, useWindowSize } from "@vueuse/core";
|
|
4
4
|
import mitt from "mitt";
|
|
5
|
-
import { get, isInteger, isNil
|
|
5
|
+
import { get, isInteger, isNil } from "lodash-es";
|
|
6
6
|
import dayjs from "dayjs";
|
|
7
7
|
import Sortable from "sortablejs";
|
|
8
8
|
|
|
@@ -329,50 +329,6 @@ const useSortable = (params) => {
|
|
|
329
329
|
};
|
|
330
330
|
};
|
|
331
331
|
|
|
332
|
-
//#endregion
|
|
333
|
-
//#region src/hooks/useTitle.ts
|
|
334
|
-
const setGlobalAppTitle = (title) => {
|
|
335
|
-
const app = getCurrentInstance();
|
|
336
|
-
if (_.isNil(app)) return;
|
|
337
|
-
app.appContext.app.config.globalProperties.$appTitle = `${title}`;
|
|
338
|
-
};
|
|
339
|
-
const setI18nTransFunc = (t) => {
|
|
340
|
-
const app = getCurrentInstance();
|
|
341
|
-
if (_.isNil(app)) return;
|
|
342
|
-
if (!_.isFunction(t)) return;
|
|
343
|
-
app.appContext.app.config.globalProperties.$t = t;
|
|
344
|
-
};
|
|
345
|
-
const getGlobalAppTitle = () => {
|
|
346
|
-
const app = getCurrentInstance();
|
|
347
|
-
if (_.isNil(app)) return;
|
|
348
|
-
if (!_.isString(app.appContext.app.config.globalProperties.$appTitle)) return;
|
|
349
|
-
return app.appContext.app.config.globalProperties.$appTitle;
|
|
350
|
-
};
|
|
351
|
-
const getI18nTransFunc = () => {
|
|
352
|
-
const app = getCurrentInstance();
|
|
353
|
-
if (_.isNil(app)) return;
|
|
354
|
-
if (!_.isFunction(app.appContext.app.config.globalProperties.$t)) return;
|
|
355
|
-
return app.appContext.app.config.globalProperties.$t;
|
|
356
|
-
};
|
|
357
|
-
const useTitle = (newTitle) => {
|
|
358
|
-
const _props = {
|
|
359
|
-
get t() {
|
|
360
|
-
return getI18nTransFunc() || ((val) => val);
|
|
361
|
-
},
|
|
362
|
-
get appTitle() {
|
|
363
|
-
return getGlobalAppTitle() || "";
|
|
364
|
-
}
|
|
365
|
-
};
|
|
366
|
-
const title = ref("");
|
|
367
|
-
watch(() => `${_props.appTitle}-${unref(newTitle)}`, (n, o) => {
|
|
368
|
-
if (isString(n) && n !== o && document) {
|
|
369
|
-
title.value = newTitle ? `${_props.appTitle} - ${_props.t(newTitle)}` : _props.appTitle;
|
|
370
|
-
document.title = title.value;
|
|
371
|
-
}
|
|
372
|
-
}, { immediate: true });
|
|
373
|
-
return title;
|
|
374
|
-
};
|
|
375
|
-
|
|
376
332
|
//#endregion
|
|
377
333
|
//#region src/hooks/useViewRefresh.ts
|
|
378
334
|
/**
|
|
@@ -512,4 +468,4 @@ function useWatermark(opts) {
|
|
|
512
468
|
}
|
|
513
469
|
|
|
514
470
|
//#endregion
|
|
515
|
-
export {
|
|
471
|
+
export { useDivSize, useDrawerWidth, useInjectMitt, useNetwork, useNewMitt, useNow, useSortable, useStyleSheetLink, useViewRefresh, useVueInterval, useWatermark };
|