feat: 更新 utils4u 依赖至 2.18.1,并添加 PrimeVue 服务的全局类型声明
This commit is contained in:
4
auto-imports.d.ts
vendored
4
auto-imports.d.ts
vendored
@ -6,7 +6,10 @@
|
|||||||
// biome-ignore lint: disable
|
// biome-ignore lint: disable
|
||||||
export {}
|
export {}
|
||||||
declare global {
|
declare global {
|
||||||
|
const ConfirmationService: typeof import('utils4u/primevue')['ConfirmationService']
|
||||||
|
const DialogService: typeof import('utils4u/primevue')['DialogService']
|
||||||
const EffectScope: typeof import('vue')['EffectScope']
|
const EffectScope: typeof import('vue')['EffectScope']
|
||||||
|
const ToastService: typeof import('utils4u/primevue')['ToastService']
|
||||||
const acceptHMRUpdate: typeof import('pinia')['acceptHMRUpdate']
|
const acceptHMRUpdate: typeof import('pinia')['acceptHMRUpdate']
|
||||||
const asyncComputed: typeof import('@vueuse/core')['asyncComputed']
|
const asyncComputed: typeof import('@vueuse/core')['asyncComputed']
|
||||||
const autoResetRef: typeof import('@vueuse/core')['autoResetRef']
|
const autoResetRef: typeof import('@vueuse/core')['autoResetRef']
|
||||||
@ -242,6 +245,7 @@ declare global {
|
|||||||
const usePreferredLanguages: typeof import('@vueuse/core')['usePreferredLanguages']
|
const usePreferredLanguages: typeof import('@vueuse/core')['usePreferredLanguages']
|
||||||
const usePreferredReducedMotion: typeof import('@vueuse/core')['usePreferredReducedMotion']
|
const usePreferredReducedMotion: typeof import('@vueuse/core')['usePreferredReducedMotion']
|
||||||
const usePrevious: typeof import('@vueuse/core')['usePrevious']
|
const usePrevious: typeof import('@vueuse/core')['usePrevious']
|
||||||
|
const usePrimevueDialogRef: typeof import('utils4u/primevue')['usePrimevueDialogRef']
|
||||||
const useRafFn: typeof import('@vueuse/core')['useRafFn']
|
const useRafFn: typeof import('@vueuse/core')['useRafFn']
|
||||||
const useRefHistory: typeof import('@vueuse/core')['useRefHistory']
|
const useRefHistory: typeof import('@vueuse/core')['useRefHistory']
|
||||||
const useRefs: typeof import('utils4u/vue-use')['useRefs']
|
const useRefs: typeof import('utils4u/vue-use')['useRefs']
|
||||||
|
@ -54,7 +54,7 @@
|
|||||||
"taze": "^0.18.0",
|
"taze": "^0.18.0",
|
||||||
"tdesign-icons-vue-next": "^0.3.3",
|
"tdesign-icons-vue-next": "^0.3.3",
|
||||||
"ts-enum-util": "^4.1.0",
|
"ts-enum-util": "^4.1.0",
|
||||||
"utils4u": "^2.17.0",
|
"utils4u": "^2.18.1",
|
||||||
"vant": "^4.9.15",
|
"vant": "^4.9.15",
|
||||||
"vite-plugin-webfont-dl": "^3.10.3",
|
"vite-plugin-webfont-dl": "^3.10.3",
|
||||||
"vue": "^3.5.13",
|
"vue": "^3.5.13",
|
||||||
|
10
pnpm-lock.yaml
generated
10
pnpm-lock.yaml
generated
@ -83,8 +83,8 @@ importers:
|
|||||||
specifier: ^4.1.0
|
specifier: ^4.1.0
|
||||||
version: 4.1.0
|
version: 4.1.0
|
||||||
utils4u:
|
utils4u:
|
||||||
specifier: ^2.17.0
|
specifier: ^2.18.1
|
||||||
version: 2.17.0
|
version: 2.18.1
|
||||||
vant:
|
vant:
|
||||||
specifier: ^4.9.15
|
specifier: ^4.9.15
|
||||||
version: 4.9.15(vue@3.5.13(typescript@5.7.2))
|
version: 4.9.15(vue@3.5.13(typescript@5.7.2))
|
||||||
@ -4756,8 +4756,8 @@ packages:
|
|||||||
util-deprecate@1.0.2:
|
util-deprecate@1.0.2:
|
||||||
resolution: {integrity: sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==}
|
resolution: {integrity: sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==}
|
||||||
|
|
||||||
utils4u@2.17.0:
|
utils4u@2.18.1:
|
||||||
resolution: {integrity: sha512-66k6/FlZxSwauQGuFJARA3KleXi8ypSrtbHBAzWSETeMTarEFPoAWrfl2fWHC6wxWCg9oWK1zHjtPL9BQkKjqw==}
|
resolution: {integrity: sha512-FTKfiwFUZLxp5UMLLilcQFWF/WZq2pZpk0Dg/Q8LLDJEHHN0QlMOm+25p6+tI0lDArC6uG/zmA/d9SnlU720AA==}
|
||||||
|
|
||||||
uuid@3.3.2:
|
uuid@3.3.2:
|
||||||
resolution: {integrity: sha512-yXJmeNaw3DnnKAOKJE51sL/ZaYfWJRl1pK9dr19YFCu0ObS231AB1/LbqTKRAQ5kw8A90rA6fr4riOUpTZvQZA==}
|
resolution: {integrity: sha512-yXJmeNaw3DnnKAOKJE51sL/ZaYfWJRl1pK9dr19YFCu0ObS231AB1/LbqTKRAQ5kw8A90rA6fr4riOUpTZvQZA==}
|
||||||
@ -10108,7 +10108,7 @@ snapshots:
|
|||||||
|
|
||||||
util-deprecate@1.0.2: {}
|
util-deprecate@1.0.2: {}
|
||||||
|
|
||||||
utils4u@2.17.0: {}
|
utils4u@2.18.1: {}
|
||||||
|
|
||||||
uuid@3.3.2: {}
|
uuid@3.3.2: {}
|
||||||
|
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { useDialogRef } from '@/plugins/primevue';
|
const dialogRef = usePrimevueDialogRef();
|
||||||
|
|
||||||
const dialogRef = useDialogRef();
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
import { ConfirmationService, DialogService, ToastService, useDialogRef } from '@/plugins/primevue';
|
|
||||||
import dialogContent from './__dialog-content.vue';
|
import dialogContent from './__dialog-content.vue';
|
||||||
|
|
||||||
const dynamicComponent = defineComponent({
|
const dynamicComponent = defineComponent({
|
||||||
@ -9,7 +8,7 @@ const dynamicComponent = defineComponent({
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
setup(props, ctx) {
|
setup(props, ctx) {
|
||||||
const dialogRef = useDialogRef();
|
const dialogRef = usePrimevueDialogRef();
|
||||||
return () => (
|
return () => (
|
||||||
<div>
|
<div>
|
||||||
<button onClick={() => ctx.emit('close')}>emit('close')</button> <hr />
|
<button onClick={() => ctx.emit('close')}>emit('close')</button> <hr />
|
||||||
|
@ -8,81 +8,7 @@ import Aura from '@primevue/themes/aura';
|
|||||||
import zhCN from 'primelocale/zh-CN.json';
|
import zhCN from 'primelocale/zh-CN.json';
|
||||||
import PrimeVue from 'primevue/config';
|
import PrimeVue from 'primevue/config';
|
||||||
|
|
||||||
// ========================================================================
|
export function setupPrimeVue(app: import('vue').App) {
|
||||||
// ========================== ConfirmationService =========================
|
|
||||||
// ========================================================================
|
|
||||||
// @ts-expect-error - Ignore missing types
|
|
||||||
import ConfirmationEventBus from 'primevue/confirmationeventbus';
|
|
||||||
|
|
||||||
import type { ConfirmationOptions } from 'primevue/confirmationoptions';
|
|
||||||
interface HConfirmationOptions extends ConfirmationOptions {
|
|
||||||
rejectProps?: import('primevue/button').ButtonProps;
|
|
||||||
acceptProps?: import('primevue/button').ButtonProps;
|
|
||||||
}
|
|
||||||
const ConfirmationService = {
|
|
||||||
require: (options: HConfirmationOptions) => {
|
|
||||||
ConfirmationEventBus.emit('confirm', options);
|
|
||||||
},
|
|
||||||
close: () => {
|
|
||||||
ConfirmationEventBus.emit('close');
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
// ========================================================================
|
|
||||||
// ============================= ToastService =============================
|
|
||||||
// ========================================================================
|
|
||||||
// @ts-expect-error - Ignore missing types
|
|
||||||
import ToastEventBus from 'primevue/toasteventbus';
|
|
||||||
|
|
||||||
import type { ToastServiceMethods } from 'primevue/toastservice';
|
|
||||||
// https://github.com/primefaces/primevue/blob/61929eae7526015af0362fc5889f2af7527403d1/packages/primevue/src/toastservice/ToastService.js
|
|
||||||
const ToastService: ToastServiceMethods = {
|
|
||||||
add: (message) => {
|
|
||||||
ToastEventBus.emit('add', message);
|
|
||||||
},
|
|
||||||
remove: (message) => {
|
|
||||||
ToastEventBus.emit('remove', message);
|
|
||||||
},
|
|
||||||
removeGroup: (group) => {
|
|
||||||
ToastEventBus.emit('remove-group', group);
|
|
||||||
},
|
|
||||||
removeAllGroups: () => {
|
|
||||||
ToastEventBus.emit('remove-all-groups');
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
// ========================================================================
|
|
||||||
// ============================= DialogService ============================
|
|
||||||
// ========================================================================
|
|
||||||
// @ts-expect-error - Ignore missing types
|
|
||||||
import DynamicDialogEventBus from 'primevue/dynamicdialogeventbus';
|
|
||||||
|
|
||||||
import type { DialogServiceMethods } from 'primevue/dialogservice';
|
|
||||||
|
|
||||||
// https://github.com/primefaces/primevue/blob/18367429f624285ff32d0ef775c1825a43a02fb1/packages/primevue/src/dialogservice/DialogService.js#L7
|
|
||||||
const DialogService: DialogServiceMethods = {
|
|
||||||
open: (content, options) => {
|
|
||||||
const instance = {
|
|
||||||
content: content && markRaw(content),
|
|
||||||
options: options || {},
|
|
||||||
data: options && options.data,
|
|
||||||
close: (params: unknown) => {
|
|
||||||
DynamicDialogEventBus.emit('close', { instance, params });
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
DynamicDialogEventBus.emit('open', { instance });
|
|
||||||
|
|
||||||
return instance;
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
function useDialogRef() {
|
|
||||||
type DialogRef = ComputedRef<import('primevue/dynamicdialogoptions').DynamicDialogInstance>;
|
|
||||||
return inject<DialogRef>('dialogRef');
|
|
||||||
}
|
|
||||||
|
|
||||||
function setupPrimeVue(app: import('vue').App) {
|
|
||||||
app.use(PrimeVue, {
|
app.use(PrimeVue, {
|
||||||
locale: {
|
locale: {
|
||||||
...zhCN['zh-CN'],
|
...zhCN['zh-CN'],
|
||||||
@ -98,5 +24,3 @@ function setupPrimeVue(app: import('vue').App) {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export { ConfirmationService, DialogService, setupPrimeVue, ToastService, useDialogRef };
|
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import { DataLoaderPlugin } from 'unplugin-vue-router/data-loaders';
|
import { DataLoaderPlugin } from 'unplugin-vue-router/data-loaders';
|
||||||
import { createLogGuard, createProgressGuard, createStackGuard } from 'utils4u/vue-router';
|
|
||||||
import { createRouter, createWebHistory } from 'vue-router';
|
import { createRouter, createWebHistory } from 'vue-router';
|
||||||
import { handleHotUpdate, routes } from 'vue-router/auto-routes';
|
import { handleHotUpdate, routes } from 'vue-router/auto-routes';
|
||||||
|
|
||||||
@ -17,15 +16,16 @@ if ($__DEV__) Object.assign(window, { router });
|
|||||||
|
|
||||||
function setupRouter(app: import('vue').App) {
|
function setupRouter(app: import('vue').App) {
|
||||||
app
|
app
|
||||||
// Register the plugin before the router
|
.use(DataLoaderPlugin, { router }) // Register the plugin before the router
|
||||||
.use(DataLoaderPlugin, { router })
|
.use(router); // adding the router will trigger the initial navigation
|
||||||
// adding the router will trigger the initial navigation
|
}
|
||||||
.use(router);
|
export { router, setupRouter };
|
||||||
|
// ========================================================================
|
||||||
|
// =========================== Router Guards ==============================
|
||||||
|
// ========================================================================
|
||||||
|
{
|
||||||
// 警告:路由守卫的创建顺序会影响执行流程,请勿调整
|
// 警告:路由守卫的创建顺序会影响执行流程,请勿调整
|
||||||
createProgressGuard(router);
|
createNProgressGuard(router);
|
||||||
createLogGuard(router);
|
createLogGuard(router);
|
||||||
Object.assign(window, { stack: createStackGuard(router) });
|
Object.assign(window, { stack: createStackGuard(router) });
|
||||||
}
|
}
|
||||||
|
|
||||||
export { router, setupRouter };
|
|
||||||
|
@ -53,7 +53,7 @@ export function Plugins() {
|
|||||||
'@vueuse/core',
|
'@vueuse/core',
|
||||||
VueRouterAutoImports,
|
VueRouterAutoImports,
|
||||||
unheadVueComposablesImports,
|
unheadVueComposablesImports,
|
||||||
createUtils4uAutoImports(),
|
createUtils4uAutoImports(['primevue']),
|
||||||
'vue-i18n',
|
'vue-i18n',
|
||||||
],
|
],
|
||||||
}),
|
}),
|
||||||
|
Reference in New Issue
Block a user