npmapps 1.0.4 → 1.0.6

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.
@@ -0,0 +1,177 @@
1
+ export const holiday = [
2
+ // 春节
3
+ {
4
+ type: 'holiday',
5
+ name: '春节',
6
+ date: '2024-02-10',
7
+ lunarDate: '正月初一'
8
+ },
9
+ {
10
+ type: 'holiday',
11
+ name: '春节',
12
+ date: '2024-02-11',
13
+ lunarDate: '正月初二'
14
+ },
15
+ {
16
+ type: 'holiday',
17
+ name: '春节',
18
+ date: '2024-02-12',
19
+ lunarDate: '正月初三'
20
+ },
21
+ // 清明节
22
+ {
23
+ type: 'holiday',
24
+ name: '清明节',
25
+ date: '2024-04-04',
26
+ lunarDate: '二月廿五'
27
+ },
28
+ {
29
+ type: 'holiday',
30
+ name: '清明节',
31
+ date: '2024-04-05',
32
+ lunarDate: '二月廿六'
33
+ },
34
+ {
35
+ type: 'holiday',
36
+ name: '清明节',
37
+ date: '2024-04-06',
38
+ lunarDate: '二月廿七'
39
+ },
40
+ // 劳动节
41
+ {
42
+ type: 'holiday',
43
+ name: '劳动节',
44
+ date: '2024-05-01',
45
+ lunarDate: '三月廿三'
46
+ },
47
+ {
48
+ type: 'holiday',
49
+ name: '劳动节',
50
+ date: '2024-05-02',
51
+ lunarDate: '三月廿四'
52
+ },
53
+ {
54
+ type: 'holiday',
55
+ name: '劳动节',
56
+ date: '2024-05-03',
57
+ lunarDate: '三月廿五'
58
+ },
59
+ {
60
+ type: 'holiday',
61
+ name: '劳动节',
62
+ date: '2024-05-04',
63
+ lunarDate: '三月廿六'
64
+ },
65
+ {
66
+ type: 'holiday',
67
+ name: '劳动节',
68
+ date: '2024-05-05',
69
+ lunarDate: '三月廿七'
70
+ },
71
+ // 端午节
72
+ {
73
+ type: 'holiday',
74
+ name: '端午节',
75
+ date: '2024-06-10',
76
+ lunarDate: '五月初三'
77
+ },
78
+ // 中秋节
79
+ {
80
+ type: 'holiday',
81
+ name: '中秋节',
82
+ date: '2024-09-15',
83
+ lunarDate: '八月初二'
84
+ },
85
+ {
86
+ type: 'holiday',
87
+ name: '中秋节',
88
+ date: '2024-09-16',
89
+ lunarDate: '八月初三'
90
+ },
91
+ {
92
+ type: 'holiday',
93
+ name: '中秋节',
94
+ date: '2024-09-17',
95
+ lunarDate: '八月初四'
96
+ },
97
+ // 国庆节
98
+ {
99
+ type: 'holiday',
100
+ name: '国庆节',
101
+ date: '2024-10-01',
102
+ lunarDate: '八月十八'
103
+ },
104
+ {
105
+ type: 'holiday',
106
+ name: '国庆节',
107
+ date: '2024-10-02',
108
+ lunarDate: '八月十九'
109
+ },
110
+ {
111
+ type: 'holiday',
112
+ name: '国庆节',
113
+ date: '2024-10-03',
114
+ lunarDate: '八月二十'
115
+ },
116
+ {
117
+ type: 'holiday',
118
+ name: '国庆节',
119
+ date: '2024-10-04',
120
+ lunarDate: '八月廿一'
121
+ },
122
+ {
123
+ type: 'holiday',
124
+ name: '国庆节',
125
+ date: '2024-10-05',
126
+ lunarDate: '八月廿二'
127
+ },
128
+ {
129
+ type: 'holiday',
130
+ name: '国庆节',
131
+ date: '2024-10-06',
132
+ lunarDate: '八月廿三'
133
+ },
134
+ {
135
+ type: 'holiday',
136
+ name: '国庆节',
137
+ date: '2024-10-07',
138
+ lunarDate: '八月廿四'
139
+ },
140
+ // 普通周末
141
+ {
142
+ type: 'weekend',
143
+ name: '周末',
144
+ date: '2024-01-06',
145
+ lunarDate: '十一月廿五'
146
+ },
147
+ {
148
+ type: 'weekend',
149
+ name: '周末',
150
+ date: '2024-01-07',
151
+ lunarDate: '十一月廿六'
152
+ },
153
+ {
154
+ type: 'weekend',
155
+ name: '周末',
156
+ date: '2024-01-13',
157
+ lunarDate: '十二月初二'
158
+ },
159
+ {
160
+ type: 'weekend',
161
+ name: '周末',
162
+ date: '2024-01-14',
163
+ lunarDate: '十二月初三'
164
+ },
165
+ {
166
+ type: 'weekend',
167
+ name: '周末',
168
+ date: '2024-01-20',
169
+ lunarDate: '十二月初九'
170
+ },
171
+ {
172
+ type: 'weekend',
173
+ name: '周末',
174
+ date: '2024-01-21',
175
+ lunarDate: '十二月初十'
176
+ }
177
+ ]
@@ -0,0 +1,116 @@
1
+ <template>
2
+ <div class="calendar-container" style="margin-left: 120px;">
3
+ <div class="control-panel">
4
+
5
+ <el-date-picker v-model="year" type="year" placeholder="选择年" class="year-picker">
6
+ </el-date-picker>
7
+ <el-switch v-model="showButtonGroup" active-text="显示按钮组" inactive-text="隐藏按钮组" class="control-item"></el-switch>
8
+ <el-switch v-model="showWorkday" active-text="显示工作日" inactive-text="隐藏工作日" class="control-item"></el-switch>
9
+ <el-switch v-model="clickable" active-text="允许点击" inactive-text="禁止点击" class="control-item"></el-switch>
10
+ <!-- <el-switch v-model="showToday" active-text="显示今日标记" inactive-text="隐藏今日标记" class="control-item"></el-switch> -->
11
+ <el-switch v-model="isNextOrPrevClick" active-text="隔月点击时间" inactive-text="不可隔月点击时间" class="control-item"></el-switch>
12
+ </div>
13
+ <div :key="year+''" class="calendar-grid">
14
+ <div v-for="(item, index) in calendarDate" :key="index" class="calendar-item">
15
+ <customCalendar
16
+ @date-click="dataClick"
17
+ :holiday="holiday"
18
+ :date="item.date"
19
+ :showButtonGroup="showButtonGroup"
20
+ :showWorkday="showWorkday"
21
+ :clickable="clickable"
22
+ :showToday="showToday"
23
+ :isNextOrPrevClick="isNextOrPrevClick"
24
+ />
25
+ </div>
26
+ </div>
27
+ </div>
28
+ </template>
29
+
30
+ <style scoped>
31
+ .calendar-container {
32
+ padding: 20px;
33
+ }
34
+
35
+ .year-picker {
36
+ margin-bottom: 20px;
37
+ }
38
+
39
+ .control-panel {
40
+ display: flex;
41
+ flex-wrap: wrap;
42
+ gap: 20px;
43
+ margin-bottom: 20px;
44
+ }
45
+
46
+ .control-item {
47
+ flex: 1;
48
+ min-width: 200px;
49
+ }
50
+
51
+ .calendar-grid {
52
+ display: grid;
53
+ grid-template-columns: repeat(auto-fill, minmax(300px, 440px));
54
+ gap: 10px;
55
+ justify-content: space-between;
56
+ }
57
+
58
+ .calendar-item {
59
+ width: 100%;
60
+ background-color: #fff;
61
+ border-radius: 8px;
62
+ box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
63
+ transition: all 0.3s ease;
64
+ padding: 15px;
65
+ }
66
+
67
+ .calendar-item:hover {
68
+ transform: translateY(-5px);
69
+ box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
70
+ }
71
+ </style>
72
+ <script>
73
+ import customCalendar from "./customCalendar.vue";
74
+ import {holiday} from "./data";
75
+ export default {
76
+ components: {
77
+ customCalendar,
78
+ },
79
+ data() {
80
+ return {
81
+ year: new Date('2024'),
82
+ showButtonGroup: false,
83
+ showWorkday: true,
84
+ clickable: true,
85
+ showToday: true,
86
+ isNextOrPrevClick: false,
87
+ holiday
88
+ };
89
+ },
90
+ methods: {
91
+ dataClick(data) {
92
+ console.log(data, "data");
93
+ this.$message.success("日期选择成功:" + data.day);
94
+ }
95
+ },
96
+ computed: {
97
+ calendarDate: function () {
98
+ const selectedYear = this.year.getFullYear();
99
+ const list = Array.from({ length: 12 }, (_, index) => {
100
+ const month = String(index + 1).padStart(2, "0");
101
+ return {
102
+ month: month,
103
+ date: new Date(`${selectedYear}-${month}-01`),
104
+ };
105
+ });
106
+ console.log(list, "list");
107
+
108
+ return list;
109
+ },
110
+ },
111
+ mounted() {
112
+
113
+ },
114
+
115
+ };
116
+ </script>
@@ -0,0 +1,51 @@
1
+ <template>
2
+ <el-form ref="form" :model="formData" label-width="80px">
3
+ <el-form-item label="名称" prop="name">
4
+ <el-input
5
+ v-model="formData.name"
6
+ placeholder="请输入名称"
7
+ />
8
+ </el-form-item>
9
+ <el-form-item label="邮箱" prop="email">
10
+ <el-input
11
+ v-model="formData.email"
12
+ placeholder="请输入邮箱"
13
+ />
14
+ </el-form-item>
15
+ <el-form-item label="描述" prop="description">
16
+ <el-input
17
+ type="textarea"
18
+ v-model="formData.description"
19
+ placeholder="请输入描述"
20
+ :rows="3"
21
+ />
22
+ </el-form-item>
23
+ </el-form>
24
+ </template>
25
+
26
+ <script>
27
+ export default {
28
+ name: 'DialogForm',
29
+ data() {
30
+ return {
31
+ formData: {
32
+ name: '',
33
+ email: '',
34
+ description: ''
35
+ }
36
+ }
37
+ },
38
+ methods: {
39
+ getFormData() {
40
+ return this.formData
41
+ },
42
+ resetForm() {
43
+ this.formData = {
44
+ name: '',
45
+ email: '',
46
+ description: ''
47
+ }
48
+ }
49
+ }
50
+ }
51
+ </script>
@@ -0,0 +1,98 @@
1
+ # dialogFnJsx 组件文档
2
+
3
+ ## 组件介绍
4
+
5
+ `dialogFnJsx` 是一个基于 Element UI 的 Dialog 组件封装的函数式对话框组件,使用 JSX 语法实现。它提供了一种更灵活的方式来创建和管理对话框,支持动态内容渲染和自定义插槽。
6
+
7
+ ## 特性
8
+
9
+ - 函数式调用,无需在模板中声明
10
+ - 支持 JSX 语法
11
+ - 支持多个插槽(默认内容、标题、底部)
12
+ - 自动管理对话框的生命周期
13
+ - 支持所有 Element UI Dialog 的原生属性和事件
14
+
15
+ ## 基本用法
16
+
17
+ ```javascript
18
+ import { dialogFn } from './dialogFnJsx';
19
+
20
+ // 基础用法
21
+ const { dialog, close } = dialogFn({
22
+ slots: {
23
+ default: <div>对话框内容</div>,
24
+ title: <h3>标题</h3>,
25
+ footer: (
26
+ <div>
27
+ <el-button onClick={() => close()}>取消</el-button>
28
+ <el-button type="primary" onClick={() => {}}>确定</el-button>
29
+ </div>
30
+ )
31
+ },
32
+ props: {
33
+ title: '标题',
34
+ width: '500px',
35
+ destroyOnClose: true
36
+ },
37
+ on: {
38
+ close: () => {
39
+ console.log('关闭');
40
+ }
41
+ }
42
+ });
43
+ ```
44
+
45
+ ## 参数说明
46
+
47
+ ### options 配置对象
48
+
49
+ | 参数 | 类型 | 必填 | 说明 |
50
+ |------|------|------|------|
51
+ | slots | Object | 否 | 插槽内容配置对象 |
52
+ | props | Object | 否 | Dialog 组件的 props 配置 |
53
+ | on | Object | 否 | Dialog 组件的事件监听配置 |
54
+
55
+ ### slots 配置对象
56
+
57
+ | 属性 | 类型 | 说明 |
58
+ |------|------|------|
59
+ | default | JSX.Element | 默认插槽内容 |
60
+ | title | JSX.Element | 标题插槽内容 |
61
+ | footer | JSX.Element | 底部插槽内容 |
62
+
63
+ ### props 配置对象
64
+
65
+ 支持所有 Element UI Dialog 组件的 props 配置,常用的有:
66
+
67
+ | 属性 | 类型 | 说明 |
68
+ |------|------|------|
69
+ | title | String | 对话框标题 |
70
+ | width | String | 对话框宽度 |
71
+ | top | String | 对话框距离顶部的距离 |
72
+ | destroyOnClose | Boolean | 关闭时是否销毁内容 |
73
+ | beforeClose | Function | 关闭前的回调函数 |
74
+
75
+ ### on 配置对象
76
+
77
+ 支持所有 Element UI Dialog 组件的事件监听配置,常用的有:
78
+
79
+ | 事件名 | 说明 |
80
+ |--------|------|
81
+ | close | 对话框关闭时的回调函数 |
82
+ | open | 对话框打开时的回调函数 |
83
+
84
+ ## 注意事项
85
+
86
+ 1. 组件使用 JSX 语法,确保项目已配置好相关的 Babel 插件支持。
87
+ 2. 关闭对话框时会自动销毁组件实例,无需手动处理。
88
+ 3. 所有的 Element UI Dialog 原生属性都可以通过 props 传入。
89
+ 4. 事件监听器通过 on 对象进行配置。
90
+ 5. 返回的 close 方法可以用于手动关闭对话框。
91
+
92
+ ## 与普通 Vue 组件的区别
93
+
94
+ 1. 采用函数式调用而非组件式声明
95
+ 2. 使用 JSX 语法替代模板语法
96
+ 3. 自动管理组件的挂载和销毁
97
+ 4. 更灵活的插槽内容配置
98
+ 5. 无需在父组件中注册即可使用
@@ -0,0 +1,74 @@
1
+ <template>
2
+ <div>
3
+ {{ nameProps }}
4
+
5
+ <el-button type="primary" v-if="showBtn" @click="show">打开新弹窗</el-button>
6
+ <el-button v-if="showBtn" @click="close">关闭</el-button>
7
+ <el-button v-if="showBtn" @click="obj.a++">{{ obj.a }}</el-button>
8
+ <slot />
9
+ </div>
10
+ </template>
11
+ <script>
12
+ import { dialogFn } from "./index";
13
+ import com11 from "./com11.vue";
14
+ export default {
15
+ props: {
16
+ nameProps: {
17
+ type: String,
18
+ default: "111",
19
+ },
20
+ closeDialog: {
21
+ type: Function,
22
+ default: () => {
23
+ },
24
+ },
25
+ showBtn: {
26
+ type: Boolean,
27
+ default: false,
28
+ },
29
+ obj: {
30
+ type: Object,
31
+ default: () => {
32
+ return {};
33
+ },
34
+ },
35
+ },
36
+ created() {
37
+ console.log(this.nameProps, "nameProps");
38
+ },
39
+ methods: {
40
+ close() {
41
+ console.log(this.closeDialog, "dialog");
42
+ this.closeDialog();
43
+ },
44
+ beforeClose(d) {
45
+ d();
46
+ },
47
+ show() {
48
+
49
+ const { close } = dialogFn({
50
+ slots: {
51
+ default: (
52
+ <com11
53
+ nameProps="内部defaultSlot"
54
+ closeDialog={() => close()}
55
+ />
56
+ ),
57
+ },
58
+ props: {
59
+ title: "内部弹窗标题",
60
+ width: "300px",
61
+ top: "100px",
62
+ beforeClose: this.beforeClose,
63
+ appendToBody: true,
64
+ },
65
+ on: {
66
+ close: () => {
67
+ console.log("内部关闭");
68
+ },
69
+ },
70
+ });
71
+ },
72
+ },
73
+ };
74
+ </script>
@@ -0,0 +1,31 @@
1
+ <template>
2
+ <div>
3
+ {{ nameProps }}
4
+ <el-button type="" @click="close">关闭</el-button>
5
+ </div>
6
+ </template>
7
+ <script>
8
+ export default {
9
+ props: {
10
+ nameProps: {
11
+ type: String,
12
+ default: "111",
13
+ },
14
+ closeDialog: {
15
+ type: Function,
16
+ default: () => {
17
+ },
18
+ },
19
+ },
20
+ created() {
21
+ console.log(this.nameProps, "nameProps");
22
+ },
23
+ methods: {
24
+ close() {
25
+ console.log(this.closeDialog, "dialog");
26
+
27
+ this.closeDialog();
28
+ },
29
+ },
30
+ };
31
+ </script>