From d01b74a5b86c097278420ac19d8a73ff05b86e04 Mon Sep 17 00:00:00 2001
From: dap <15891557205@163.com>
Date: Tue, 24 Sep 2024 20:52:31 +0800
Subject: [PATCH] chore: mitt demo
---
apps/web-antd/src/views/system/dict/data/index.vue | 10 ++++++++++
apps/web-antd/src/views/system/dict/mitt.ts | 10 ++++++++++
apps/web-antd/src/views/system/dict/type/index.vue | 10 ++++++++++
3 files changed, 30 insertions(+)
create mode 100644 apps/web-antd/src/views/system/dict/mitt.ts
diff --git a/apps/web-antd/src/views/system/dict/data/index.vue b/apps/web-antd/src/views/system/dict/data/index.vue
index fd46e518..7447562f 100644
--- a/apps/web-antd/src/views/system/dict/data/index.vue
+++ b/apps/web-antd/src/views/system/dict/data/index.vue
@@ -1,4 +1,6 @@
@@ -48,6 +57,7 @@ const [QueryForm] = useVbenForm({
{{ $t('pages.common.add') }}
+ {{ testValue }}
diff --git a/apps/web-antd/src/views/system/dict/mitt.ts b/apps/web-antd/src/views/system/dict/mitt.ts
new file mode 100644
index 00000000..f81c6f55
--- /dev/null
+++ b/apps/web-antd/src/views/system/dict/mitt.ts
@@ -0,0 +1,10 @@
+import { mitt } from '@vben/utils';
+
+/**
+ * dictType: string
+ */
+type Events = {
+ rowClick: string;
+};
+
+export const emitter = mitt();
diff --git a/apps/web-antd/src/views/system/dict/type/index.vue b/apps/web-antd/src/views/system/dict/type/index.vue
index fac92dd3..1b169781 100644
--- a/apps/web-antd/src/views/system/dict/type/index.vue
+++ b/apps/web-antd/src/views/system/dict/type/index.vue
@@ -3,9 +3,11 @@ import { useVbenModal } from '@vben/common-ui';
import { $t } from '@vben/locales';
import { Card } from 'ant-design-vue';
+import { uniqueId } from 'lodash-es';
import { useVbenForm } from '#/adapter';
+import { emitter } from '../mitt';
import { querySchema } from './data';
import dictTypeModel from './dict-type-model.vue';
@@ -38,6 +40,10 @@ const [QueryForm] = useVbenForm({
},
wrapperClass: 'grid-cols-1 md:grid-cols-2',
});
+
+function handleRowClickTest() {
+ emitter.emit('rowClick', uniqueId('mitt-'));
+}
@@ -50,6 +56,10 @@ const [QueryForm] = useVbenForm({
{{ $t('pages.common.add') }}
+
+ 测试mitt
+ 左侧向右侧传值
+