@peng_kai/kit 0.2.11 → 0.2.12
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.
|
@@ -85,15 +85,26 @@
|
|
|
85
85
|
}
|
|
86
86
|
|
|
87
87
|
// 使 Table 组件中的 Pagination 底部粘性
|
|
88
|
-
.ant-table-wrapper.antd-cover__table-sticky-pagination
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
88
|
+
.ant-table-wrapper.antd-cover__table-sticky-pagination {
|
|
89
|
+
// .ant-table-sticky-scroll {
|
|
90
|
+
// display: block;
|
|
91
|
+
// bottom: 64px !important;
|
|
92
|
+
// }
|
|
93
|
+
|
|
94
|
+
// .ant-table-body {
|
|
95
|
+
// overflow: hidden !important;
|
|
96
|
+
// }
|
|
97
|
+
|
|
98
|
+
.ant-table-pagination {
|
|
99
|
+
--pagination-bg-color: var(--antd-colorBgContainer);
|
|
100
|
+
|
|
101
|
+
position: sticky;
|
|
102
|
+
bottom: 16px;
|
|
103
|
+
z-index: 2;
|
|
104
|
+
margin-bottom: -9px !important;
|
|
105
|
+
background-color: var(--pagination-bg-color);
|
|
106
|
+
box-shadow: 0 0 0 16px var(--pagination-bg-color);
|
|
107
|
+
}
|
|
97
108
|
}
|
|
98
109
|
|
|
99
110
|
// 弹窗的基本款样式
|
package/package.json
CHANGED
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { computed, reactive, ref, toValue, watch } from 'vue';
|
|
3
|
+
import { type IProvide as INavManagerProvide, useNavManagerRouter } from './useNavManager';
|
|
4
|
+
|
|
5
|
+
function useHistory(initialValue: string[] = []) {
|
|
6
|
+
const history = ref([...initialValue]);
|
|
7
|
+
const current = computed(() => history.value[history.value.length - 1]);
|
|
8
|
+
const isFirst = computed(() => history.value.length === 1);
|
|
9
|
+
const lastOperation = ref<'to' | 'back' | 'replace'>('to');
|
|
10
|
+
|
|
11
|
+
const to = (name: string) => {
|
|
12
|
+
lastOperation.value = 'to';
|
|
13
|
+
history.value.push(name);
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const back = (index = -1) => {
|
|
17
|
+
if (index >= 0)
|
|
18
|
+
return;
|
|
19
|
+
|
|
20
|
+
lastOperation.value = 'back';
|
|
21
|
+
|
|
22
|
+
const len = history.value.length;
|
|
23
|
+
const firstEleLastIdx = (len - 1) * -1;
|
|
24
|
+
const endIdx = index === Number.NEGATIVE_INFINITY || index < firstEleLastIdx
|
|
25
|
+
? len + firstEleLastIdx
|
|
26
|
+
: len + index;
|
|
27
|
+
|
|
28
|
+
history.value = history.value.slice(0, endIdx);
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const replace = (name: string) => {
|
|
32
|
+
lastOperation.value = 'replace';
|
|
33
|
+
history.value[history.value.length - 1] = name;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
return reactive({ history, current, isFirst, lastOperation, to, back, replace });
|
|
37
|
+
}
|
|
38
|
+
</script>
|
|
39
|
+
|
|
40
|
+
<script setup lang="ts">
|
|
41
|
+
const props = withDefaults(defineProps<{
|
|
42
|
+
indexName?: string
|
|
43
|
+
viewClass?: string
|
|
44
|
+
}>(), {
|
|
45
|
+
indexName: 'index',
|
|
46
|
+
viewClass: '',
|
|
47
|
+
});
|
|
48
|
+
const emits = defineEmits<{
|
|
49
|
+
(e: 'close'): void
|
|
50
|
+
}>();
|
|
51
|
+
|
|
52
|
+
const viewMap = reactive<Record<string, Parameters<INavManagerProvide['addView']>[0]>>({});
|
|
53
|
+
const history = useHistory([props.indexName]);
|
|
54
|
+
const currentView = computed(() => viewMap[history.current]);
|
|
55
|
+
const transitionName = computed(() => `view-${history.lastOperation}`);
|
|
56
|
+
|
|
57
|
+
watch(currentView, (view, oldView) => {
|
|
58
|
+
oldView?.hide();
|
|
59
|
+
view?.show();
|
|
60
|
+
}, { immediate: true });
|
|
61
|
+
|
|
62
|
+
const navManager: INavManagerProvide = {
|
|
63
|
+
to: history.to,
|
|
64
|
+
back: history.back,
|
|
65
|
+
replace: history.replace,
|
|
66
|
+
close: () => emits('close'),
|
|
67
|
+
addView: info => viewMap[info.name] = info,
|
|
68
|
+
current: computed(() => history.current),
|
|
69
|
+
};
|
|
70
|
+
useNavManagerRouter(navManager);
|
|
71
|
+
</script>
|
|
72
|
+
|
|
73
|
+
<template>
|
|
74
|
+
<div class="tt-nav-manager box-border flex flex-col px-3 py-5">
|
|
75
|
+
<div class="nav-header mb-3 min-h6 flex items-center">
|
|
76
|
+
<Transition name="back-btn">
|
|
77
|
+
<div
|
|
78
|
+
v-if="!history.isFirst"
|
|
79
|
+
class="nav-back-btn mr-2 size-6 flex cursor-pointer items-center justify-center"
|
|
80
|
+
@click="navManager.back()"
|
|
81
|
+
>
|
|
82
|
+
<i class="i-ri:arrow-left-s-line text-6" />
|
|
83
|
+
</div>
|
|
84
|
+
</Transition>
|
|
85
|
+
|
|
86
|
+
<div class="nav-title flex-1">
|
|
87
|
+
{{ toValue(currentView?.title) }}
|
|
88
|
+
</div>
|
|
89
|
+
|
|
90
|
+
<div
|
|
91
|
+
class="nav-close-btn size-6 flex cursor-pointer items-center justify-center"
|
|
92
|
+
@click="navManager.close()"
|
|
93
|
+
>
|
|
94
|
+
<i class="i-ri:close-line text-6" />
|
|
95
|
+
</div>
|
|
96
|
+
</div>
|
|
97
|
+
|
|
98
|
+
<div class="relative flex-1 overflow-x-hidden">
|
|
99
|
+
<Transition :name="transitionName">
|
|
100
|
+
<div :key="currentView?.name" class="absolute left-0 top-0 h-full w-full overflow-x-hidden overflow-y-auto" :class="$props.viewClass">
|
|
101
|
+
<slot />
|
|
102
|
+
</div>
|
|
103
|
+
</Transition>
|
|
104
|
+
</div>
|
|
105
|
+
</div>
|
|
106
|
+
</template>
|
|
107
|
+
|
|
108
|
+
<style lang="scss" scoped>
|
|
109
|
+
/* 返回按钮动画 */
|
|
110
|
+
.back-btn-enter-active,
|
|
111
|
+
.back-btn-leave-active {
|
|
112
|
+
transition: width 0.2s ease-in-out, opacity 0.1s ease-in-out, margin 0.2s ease-in-out;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
.back-btn-enter-from,
|
|
116
|
+
.back-btn-leave-to {
|
|
117
|
+
width: 0;
|
|
118
|
+
margin: 0;
|
|
119
|
+
opacity: 0;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/* 视窗动画 */
|
|
123
|
+
.view-to-enter-active,
|
|
124
|
+
.view-to-leave-active,
|
|
125
|
+
.view-back-enter-active,
|
|
126
|
+
.view-back-leave-active,
|
|
127
|
+
.view-replace-enter-active,
|
|
128
|
+
.view-replace-leave-active {
|
|
129
|
+
overflow: hidden !important;
|
|
130
|
+
transition: transform 0.3s ease-in-out, opacity 0.2s ease-in-out;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
.view-to-enter-from {
|
|
134
|
+
opacity: 0;
|
|
135
|
+
transform: translate(100%);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
.view-to-leave-to {
|
|
139
|
+
opacity: 0;
|
|
140
|
+
transform: translate(-100%);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
.view-back-enter-from {
|
|
144
|
+
opacity: 0;
|
|
145
|
+
transform: translate(-100%);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
.view-back-leave-to {
|
|
149
|
+
opacity: 0;
|
|
150
|
+
transform: translate(100%);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
.view-replace-enter-from,
|
|
154
|
+
.view-replace-leave-to {
|
|
155
|
+
opacity: 0;
|
|
156
|
+
transform: scale(0.98)
|
|
157
|
+
}
|
|
158
|
+
</style>
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { computed, reactive, ref } from 'vue';
|
|
3
|
+
import { useNavManager } from './useNavManager';
|
|
4
|
+
|
|
5
|
+
const props = defineProps<{
|
|
6
|
+
name: string
|
|
7
|
+
title: string
|
|
8
|
+
}>();
|
|
9
|
+
|
|
10
|
+
const visible = ref(false);
|
|
11
|
+
const navManager = useNavManager();
|
|
12
|
+
|
|
13
|
+
navManager?.addView(reactive({
|
|
14
|
+
name: props.name,
|
|
15
|
+
title: computed(() => props.title),
|
|
16
|
+
show: () => visible.value = true,
|
|
17
|
+
hide: () => visible.value = false,
|
|
18
|
+
}));
|
|
19
|
+
</script>
|
|
20
|
+
|
|
21
|
+
<template>
|
|
22
|
+
<slot v-if="navManager?.current.value === $props.name" v-bind="{ to: navManager.to }" />
|
|
23
|
+
</template>
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { type Ref, inject, provide } from 'vue';
|
|
2
|
+
|
|
3
|
+
const NAV_MANAGER_KEY = Symbol('NAV_MANAGER');
|
|
4
|
+
|
|
5
|
+
export interface IProvide {
|
|
6
|
+
to: (name: string) => void
|
|
7
|
+
back: (index?: number) => void
|
|
8
|
+
replace: (name: string) => void
|
|
9
|
+
close: () => void
|
|
10
|
+
addView: (info: {
|
|
11
|
+
name: string
|
|
12
|
+
title: string
|
|
13
|
+
show: () => void
|
|
14
|
+
hide: () => void
|
|
15
|
+
}) => void
|
|
16
|
+
current: Ref<string>
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function useNavManagerRouter(value: IProvide) {
|
|
20
|
+
provide(NAV_MANAGER_KEY, value);
|
|
21
|
+
return value;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function useNavManager() {
|
|
25
|
+
return inject<IProvide>(NAV_MANAGER_KEY);
|
|
26
|
+
}
|