agilebuilder-ui 1.1.13-tmp2 → 1.1.13-tmp4

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,197 @@
1
+ <template>
2
+ <el-scrollbar v-bind="mergedAttrs" ref="scrollbarRef">
3
+ <slot />
4
+ </el-scrollbar>
5
+ </template>
6
+
7
+ <script setup>
8
+ import { ElScrollbar } from 'element-plus';
9
+ // import { useStore } from 'vuex';
10
+ import store from '../../store';
11
+ import { toRefs, reactive, mergeProps, ref, onMounted, watch, useAttrs, computed, defineEmits, useSlots } from 'vue';
12
+
13
+ const slots = useSlots();
14
+
15
+ // const store = useStore();
16
+
17
+ store?.dispatch?.('startListeningToResize');
18
+
19
+ const scrollbarRef = ref(null);
20
+
21
+ const scrollToEmitValue = ref(undefined)
22
+
23
+ const emits = defineEmits(['scrollToTop', 'scrollToBottom']);
24
+
25
+ const resizeProps = computed(() => ({
26
+ // 宽度
27
+ windowWidth: store.getters.windowWidth,
28
+ // 高度
29
+ windowHeight: store.getters.windowHeight,
30
+ // 是否移动端
31
+ isMobileResize: store.getters.isMobileResize,
32
+ }));
33
+
34
+ // 定义初始化参数
35
+ const defaultAttrs = reactive({
36
+ always: false, // 滚动条是否总是显示
37
+ // wrapStyle: 'height: 100%', // 滚动区域的样式
38
+ });
39
+
40
+ const props = defineProps({
41
+ // 是否开启滚动距离阴影
42
+ showScrollShadow: {
43
+ type: Boolean,
44
+ default: true
45
+ },
46
+ triggerDistance: {
47
+ type: Number,
48
+ default: 0
49
+ },
50
+ // 动态计算 max-height
51
+ setMaxHeight: {
52
+ type: [Function, undefined],
53
+ default: () => undefined
54
+ },
55
+ // 动态计算 height
56
+ setHeight: {
57
+ type: [Function, undefined],
58
+ default: () => undefined
59
+ }
60
+ });
61
+
62
+ const { attrs } = useAttrs();
63
+
64
+ // 统一写入
65
+ const setHeightFun = (fun) => {
66
+ try {
67
+ return fun?.(resizeProps.value)
68
+ } catch (error) {
69
+ console.error(error)
70
+ }
71
+ return
72
+ }
73
+
74
+ // 合并初始化参数和传入的属性
75
+ const mergedAttrs = computed(() => {
76
+ const attrsData = mergeProps(defaultAttrs, attrs)
77
+ return {
78
+ ...({
79
+ // 绑定 setMaxHeight 事件 返回 最大高度
80
+ ...(props.setMaxHeight ? { maxHeight: setHeightFun(props.setMaxHeight) } : {}),
81
+ // 绑定 setHeight 事件 返回 高度
82
+ ...(props.setHeight ? { height: setHeightFun(props.setHeight) } : {}),
83
+ }),
84
+ ...attrsData
85
+ }
86
+ });
87
+
88
+ // 滚动距离回调事件
89
+ const scrollToEmits = (scrollElement) => {
90
+ if (!scrollElement) return
91
+ const isAtTop = scrollElement.scrollTop <= props.triggerDistance;
92
+ const isAtBottom = scrollElement.scrollTop + scrollElement.clientHeight >= (scrollElement.scrollHeight - props.triggerDistance);
93
+ if (isAtBottom) {
94
+ // scrollToEmitValue 校验确保只执行一次
95
+ // 底部事件
96
+ !['at-bottom'].includes(scrollToEmitValue.value) && emits('scrollToBottom');
97
+ scrollToEmitValue.value = 'at-bottom'
98
+ } else if (isAtTop) {
99
+ // 顶部事件
100
+ !['at-top'].includes(scrollToEmitValue.value) && emits('scrollToTop');
101
+ scrollToEmitValue.value = 'at-top'
102
+ } else {
103
+ scrollToEmitValue.value = undefined
104
+ }
105
+ }
106
+
107
+ // 滚动阴影事件
108
+ const handleScroll = () => {
109
+ const scrollElement = scrollbarRef.value?.$el.querySelector('.el-scrollbar__wrap');
110
+ if (scrollElement) {
111
+ const isAtTop = scrollElement.scrollTop === 0;
112
+ const isAtBottom = scrollElement.scrollTop + scrollElement.clientHeight === scrollElement.scrollHeight;
113
+ if (props.showScrollShadow) {
114
+ if (!isAtTop) {
115
+ scrollbarRef.value.$el.classList.add('scroll-top-shadow');
116
+ } else {
117
+ scrollbarRef.value.$el.classList.remove('scroll-top-shadow');
118
+ }
119
+ if (!isAtBottom) {
120
+ scrollbarRef.value.$el.classList.add('scroll-bottom-shadow');
121
+ } else {
122
+ scrollbarRef.value.$el.classList.remove('scroll-bottom-shadow');
123
+ }
124
+ } else {
125
+ scrollbarRef.value.$el.classList.remove('scroll-top-shadow', 'scroll-bottom-shadow');
126
+ }
127
+ scrollToEmits(scrollElement);
128
+ }
129
+ };
130
+
131
+ onMounted(() => {
132
+ const scrollElement = scrollbarRef.value.$el.querySelector('.el-scrollbar__wrap');
133
+ if (scrollElement) {
134
+ scrollElement.addEventListener('scroll', handleScroll);
135
+ handleScroll();
136
+ scrollToEmits(scrollElement);
137
+ }
138
+ });
139
+
140
+ watch(() => props.showScrollShadow, () => {
141
+ handleScroll();
142
+ });
143
+
144
+ watch(() => mergedAttrs?.maxHeight, () => {
145
+ setTimeout(handleScroll, 500);
146
+ });
147
+
148
+ watch(() => mergedAttrs?.height, () => {
149
+ setTimeout(handleScroll, 500);
150
+ });
151
+ watch(
152
+ () => slots.default?.(),
153
+ (newValue, oldValue) => {
154
+ if (newValue !== oldValue) {
155
+ setTimeout(handleScroll, 500);
156
+ }
157
+ },
158
+ { deep: true }
159
+ );
160
+ </script>
161
+
162
+ <style lang="scss" scoped>
163
+ .el-scrollbar ::v-deep {
164
+ position: relative;
165
+
166
+ &.scroll-top-shadow {
167
+ &::before {
168
+ content: ' ';
169
+ position: absolute;
170
+ top: 0;
171
+ left: 0;
172
+ right: 0;
173
+ height: 8px;
174
+ box-shadow: inset 0 8px 8px -8px rgba(0, 0, 0, 0.2);
175
+ z-index: 2;
176
+ }
177
+ }
178
+
179
+ &.scroll-bottom-shadow {
180
+ &::after {
181
+ content: ' ';
182
+ position: absolute;
183
+ bottom: 0;
184
+ left: 0;
185
+ right: 0;
186
+ height: 8px;
187
+ box-shadow: inset 0 -8px 8px -8px rgba(0, 0, 0, 0.2);
188
+ z-index: 2;
189
+ }
190
+ }
191
+
192
+ &>.el-scrollbar__wrap {
193
+ position: relative;
194
+ z-index: 1;
195
+ }
196
+ }
197
+ </style>
@@ -1,6 +1,9 @@
1
1
  const getters = {
2
2
  sidebar: (state) => state.app.sidebar,
3
3
  device: (state) => state.app.device,
4
+ windowWidth: (state) => state.app.windowWidth,
5
+ windowHeight: (state) => state.app.windowHeight,
6
+ isMobileResize: (state) => state.app.isMobileResize,
4
7
  token: (state) => state.user.token,
5
8
  name: (state) => state.user.name,
6
9
  // routers: state => state.permission.routers,
@@ -10,18 +10,16 @@ const app = {
10
10
  preventReclick: false,
11
11
  whiteList: [],
12
12
  systemWidth: [],
13
- windowWidth: window.innerWidth,
14
- windowHeight: window.innerHeight,
15
- targetDomWidth: 0,
16
- isModel: false,
13
+ windowWidth: null, // 网页宽度
14
+ windowHeight: null, // 网页高度
15
+ isMobileResize: false, // 是否移动端
17
16
  },
18
17
  mutations: {
18
+ // 写入网页 高度 宽度 是否移动端
19
19
  updateWindowSize(state, { width, height }) {
20
20
  state.windowWidth = width;
21
21
  state.windowHeight = height;
22
- },
23
- updateTargetDomWidth(state, width) {
24
- state.targetDomWidth = width;
22
+ state.isMobileResize = !!width && width <= 768
25
23
  },
26
24
  toggleSidebar: (state) => {
27
25
  if (state.sidebar.opened) {
@@ -50,17 +48,34 @@ const app = {
50
48
  },
51
49
  },
52
50
  actions: {
53
- startListeningToResize({ commit }) {
54
- const handleResize = () => {
55
- commit('updateWindowSize', {
56
- width: window.innerWidth,
57
- height: window.innerHeight
58
- });
59
- };
60
- window.addEventListener('resize', handleResize);
61
- return () => {
62
- window.removeEventListener('resize', handleResize);
63
- };
51
+ startListeningToResize({ state, commit }) {
52
+ const handleResize = (data) => {
53
+ commit('updateWindowSize', {
54
+ width: data?.width ?? window.innerWidth,
55
+ height: data?.height ?? window.innerHeight,
56
+ });
57
+ };
58
+ if (!state.windowWidth && !state.windowHeight) {
59
+ const element = document.querySelector('.amb-design-board');
60
+ if (element) {
61
+ handleResize({
62
+ width: element.clientWidth,
63
+ height: element.clientHeight,
64
+ });
65
+ const designObserver = new ResizeObserver(entries => {
66
+ for (const entry of entries) {
67
+ handleResize({
68
+ width: entry?.['target']?.clientWidth,
69
+ height: entry?.['target']?.clientHeight,
70
+ });
71
+ }
72
+ });
73
+ designObserver.observe(element);
74
+ } else {
75
+ window.addEventListener('resize', handleResize);
76
+ handleResize();
77
+ }
78
+ }
64
79
  },
65
80
  toggleSidebar: ({ commit }) => {
66
81
  commit('toggleSidebar')
@@ -97,6 +97,14 @@
97
97
  &[header-padding] {
98
98
  & > .el-card__header {
99
99
  padding: 0 !important;
100
+ overflow: hidden;
101
+ min-height: 50px;
102
+
103
+ & > .yx-flex-wrap {
104
+ gap: 10px;
105
+ height: 100%;
106
+ padding: 5px var(--el-card-padding);
107
+ }
100
108
  }
101
109
  }
102
110
  &[body-padding] {
@@ -107,6 +115,36 @@
107
115
  .el-card__header {
108
116
  & > .yx-flex-wrap {
109
117
  flex: 1 1 auto;
118
+
119
+ [layout-title] {
120
+ max-width: calc(100% - 40px);
121
+
122
+ a, div, span {
123
+ display: block !important;
124
+ }
125
+ .ellipsis {
126
+ width: auto !important;
127
+ text-align: left !important;
128
+ }
129
+ }
130
+ }
131
+ }
132
+ .yx-card-body {
133
+ padding: var(--el-card-padding);
134
+ }
135
+ @media (max-width: 450px) {
136
+ &[header-padding] {
137
+ & > .el-card__header {
138
+ & > .yx-flex-wrap {
139
+ padding: 5px 10px;
140
+ }
141
+ }
142
+ }
143
+ & > .el-card__footer {
144
+ padding: 5px 10px;
145
+ }
146
+ .yx-card-body {
147
+ padding: 10px;
110
148
  }
111
149
  }
112
150
  }
@@ -163,4 +201,63 @@
163
201
  height: 0px !important;
164
202
  overflow: hidden !important;
165
203
  }
166
- }
204
+ }
205
+
206
+ @media (max-width: 450px) {
207
+ // 该样式临时处理移动端展示结构问题,如果冲突请清理
208
+ .app-wrapper {
209
+ .tab-main-container {
210
+ & > .app-main {
211
+ padding: 10px 0;
212
+
213
+ & > [style*='min-height'] {
214
+ min-height: calc(100vh - 20px) !important;
215
+
216
+ & .app-container {
217
+ min-height: calc(100vh - 20px) !important;
218
+
219
+ & > [style*='padding'] {
220
+ padding: 0 !important;
221
+ }
222
+ }
223
+ }
224
+ }
225
+ }
226
+ }
227
+ }
228
+
229
+ .yx-drawer {
230
+ .el-drawer {
231
+ .el-drawer__header {
232
+ padding: var(--el-drawer-padding-primary);
233
+ margin: 0;
234
+ display: flex;
235
+ justify-content: space-between;
236
+ align-items: center;
237
+ gap: var(--el-drawer-padding-primary);
238
+ }
239
+
240
+ .el-drawer__body {
241
+ & > .yx-flex-wrap {
242
+ height: 100%;
243
+
244
+ }
245
+ & > .el-scrollbar {
246
+ height: 100%;
247
+ }
248
+ }
249
+ }
250
+
251
+ &.yx-scrollbar-body {
252
+ .el-drawer__body {
253
+ padding: 0;
254
+ & > .el-scrollbar {
255
+ & > .el-scrollbar__wrap {
256
+ & > .el-scrollbar__view {
257
+ padding: var(--el-drawer-padding-primary);
258
+ }
259
+ }
260
+ }
261
+ }
262
+ }
263
+ }
@@ -69,7 +69,7 @@ export default {
69
69
  </script>
70
70
 
71
71
  <style lang="scss" rel="stylesheet/scss" scoped>
72
- @import 'agilebuilder-ui/src/styles/mixin.scss';
72
+ @import '../../styles/mixin.scss';
73
73
  @include clearfix;
74
74
  .app-wrapper {
75
75
  position: relative;