@ecolovo/uniapp-components 1.0.8 → 1.0.9
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.
- package/README.md +1 -8
- package/components/button/button.vue +4 -0
- package/components/checkbox/checkbox.vue +17 -3
- package/components/dialog/dialog-content.vue +10 -6
- package/components/dialog/dialog.vue +21 -13
- package/components/page/page-body.vue +7 -2
- package/components/page/page-header.vue +23 -7
- package/components/page/page.vue +6 -6
- package/configs/index.d.ts +22 -0
- package/configs/index.js +30 -4
- package/init.d.ts +19 -0
- package/init.js +4 -1
- package/package.json +2 -1
- package/styles/utils/css-var.scss +7 -2
- package/styles/var/component.scss +5 -2
- package/utils/windowInfo.js +0 -4
package/README.md
CHANGED
|
@@ -89,6 +89,7 @@ module.exports = hot((pagesJson) => {
|
|
|
89
89
|
/* src/styles/prepend.scss */
|
|
90
90
|
|
|
91
91
|
@forward '@ecolovo/uniapp-components/styles/var/theme' with (
|
|
92
|
+
$component-prefix: 'ui', // 推荐修改为与组件前缀一致
|
|
92
93
|
$themes: (
|
|
93
94
|
primary: #d92e20,
|
|
94
95
|
)
|
|
@@ -114,11 +115,3 @@ module.exports = {
|
|
|
114
115
|
// other configs...
|
|
115
116
|
};
|
|
116
117
|
```
|
|
117
|
-
|
|
118
|
-
## Components
|
|
119
|
-
|
|
120
|
-
### Aspect
|
|
121
|
-
|
|
122
|
-
#### 属性
|
|
123
|
-
|
|
124
|
-
- ratio: `string | number` 纵横比,默认为 `1` ,即宽高相等
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<view :class="componentClassNames" @click="toggle()">
|
|
3
3
|
<icon-cpn
|
|
4
|
-
v-if="
|
|
4
|
+
v-if="hasIcon"
|
|
5
5
|
:icon="usingIcon || ''"
|
|
6
6
|
tap-size="50rpx"
|
|
7
7
|
:class="[$style['Checkbox--icon'], { [$style['Checkbox--checked']]: isChecked }]"
|
|
@@ -39,7 +39,7 @@ export default {
|
|
|
39
39
|
/** checkbox-group 组件的 props 对象,用于读取 radio 和图标 */
|
|
40
40
|
checkboxGroupProps: {
|
|
41
41
|
from: 'checkboxGroupProps',
|
|
42
|
-
default: {},
|
|
42
|
+
default: { icon: true, radio: false },
|
|
43
43
|
},
|
|
44
44
|
},
|
|
45
45
|
props: {
|
|
@@ -53,6 +53,16 @@ export default {
|
|
|
53
53
|
type: Boolean,
|
|
54
54
|
default: false,
|
|
55
55
|
},
|
|
56
|
+
/** 类型 */
|
|
57
|
+
radio: {
|
|
58
|
+
type: [Boolean, null],
|
|
59
|
+
default: null,
|
|
60
|
+
},
|
|
61
|
+
/** 是否显示勾选图标 */
|
|
62
|
+
icon: {
|
|
63
|
+
type: [Boolean, null],
|
|
64
|
+
default: null,
|
|
65
|
+
},
|
|
56
66
|
/** 选中时的图标 */
|
|
57
67
|
checkedIcon: {
|
|
58
68
|
type: String,
|
|
@@ -78,9 +88,13 @@ export default {
|
|
|
78
88
|
isInGroup() {
|
|
79
89
|
return !!this.checkboxGroupData;
|
|
80
90
|
},
|
|
91
|
+
/** 是否显示勾选图标 */
|
|
92
|
+
hasIcon() {
|
|
93
|
+
return this.icon === null ? this.checkboxGroupProps.icon : this.icon;
|
|
94
|
+
},
|
|
81
95
|
/** 是否为单选 */
|
|
82
96
|
isRadio() {
|
|
83
|
-
return
|
|
97
|
+
return this.radio === null ? this.checkboxGroupProps.radio : this.radio;
|
|
84
98
|
},
|
|
85
99
|
/** checkbox-group 的值 */
|
|
86
100
|
groupCheckedValue() {
|
|
@@ -29,14 +29,18 @@
|
|
|
29
29
|
<slot v-if="$slots.footer" name="footer"></slot>
|
|
30
30
|
<view v-else-if="cancel || confirm" :class="$style['DialogContent--footer']">
|
|
31
31
|
<view v-if="cancel" :class="$style['DialogContent--button']">
|
|
32
|
-
<
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
<slot name="cancel">
|
|
33
|
+
<button-cpn plain @click="$emit('cancel')">
|
|
34
|
+
{{ cancel }}
|
|
35
|
+
</button-cpn>
|
|
36
|
+
</slot>
|
|
35
37
|
</view>
|
|
36
38
|
<view v-if="confirm" :class="$style['DialogContent--button']">
|
|
37
|
-
<
|
|
38
|
-
|
|
39
|
-
|
|
39
|
+
<slot name="confirm">
|
|
40
|
+
<button-cpn @click="$emit('confirm')">
|
|
41
|
+
{{ confirm }}
|
|
42
|
+
</button-cpn>
|
|
43
|
+
</slot>
|
|
40
44
|
</view>
|
|
41
45
|
</view>
|
|
42
46
|
</template>
|
|
@@ -8,19 +8,21 @@
|
|
|
8
8
|
@close="$emit('close')"
|
|
9
9
|
@closed="$emit('closed')"
|
|
10
10
|
>
|
|
11
|
-
<
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
11
|
+
<slot name="content">
|
|
12
|
+
<dialog-content-cpn
|
|
13
|
+
:loading="isLoading"
|
|
14
|
+
:title="title"
|
|
15
|
+
:center-title="centerTitle"
|
|
16
|
+
:show-close="showClose"
|
|
17
|
+
:cancel="cancel"
|
|
18
|
+
:confirm="confirm"
|
|
19
|
+
@close="onClose()"
|
|
20
|
+
@cancel="onCancel()"
|
|
21
|
+
@confirm="onConfirm()"
|
|
22
|
+
>
|
|
23
|
+
<slot></slot>
|
|
24
|
+
</dialog-content-cpn>
|
|
25
|
+
</slot>
|
|
24
26
|
</popover-mask-cpn>
|
|
25
27
|
</view>
|
|
26
28
|
</template>
|
|
@@ -116,6 +118,12 @@ export default {
|
|
|
116
118
|
|
|
117
119
|
this.close();
|
|
118
120
|
},
|
|
121
|
+
onCancel() {
|
|
122
|
+
this.onButton('cancel', this.closeOnCancel);
|
|
123
|
+
},
|
|
124
|
+
onConfirm() {
|
|
125
|
+
this.onButton('confirm', this.closeOnConfirm);
|
|
126
|
+
},
|
|
119
127
|
/** 点击取消或确认按钮
|
|
120
128
|
* @param {'cancel' | 'confirm'} btnType 按钮类型
|
|
121
129
|
* @param {boolean} shouldClose 是否自动关闭对话框
|
|
@@ -214,14 +214,19 @@ $component-vars: $page-body;
|
|
|
214
214
|
position: relative;
|
|
215
215
|
width: 100%;
|
|
216
216
|
min-height: 100%;
|
|
217
|
-
padding: UTILS__LOCAL_VAR(padding-
|
|
217
|
+
padding: UTILS__LOCAL_VAR(padding-top, UTILS__LOCAL_VAR(padding))
|
|
218
|
+
UTILS__LOCAL_VAR(padding-right, UTILS__LOCAL_VAR(padding))
|
|
219
|
+
UTILS__LOCAL_VAR(padding-bottom, UTILS__LOCAL_VAR(padding))
|
|
220
|
+
UTILS__LOCAL_VAR(padding-left, UTILS__LOCAL_VAR(padding));
|
|
218
221
|
box-sizing: border-box;
|
|
219
222
|
|
|
220
223
|
flex: 1;
|
|
221
224
|
display: flex;
|
|
222
225
|
flex-direction: column;
|
|
223
226
|
.PageBody--scroll-body & {
|
|
224
|
-
padding-bottom: calc(
|
|
227
|
+
padding-bottom: calc(
|
|
228
|
+
#{UTILS__LOCAL_VAR(padding-bottom, UTILS__LOCAL_VAR(padding))} + var(--bottom-safe-height)
|
|
229
|
+
);
|
|
225
230
|
}
|
|
226
231
|
}
|
|
227
232
|
</style>
|
|
@@ -57,6 +57,7 @@
|
|
|
57
57
|
import componentName from '../../mixins/componentName';
|
|
58
58
|
import windowInfoMixin from '../../mixins/windowInfo';
|
|
59
59
|
import IconCpn from '../icon/icon.vue';
|
|
60
|
+
import { homePath } from '../../configs';
|
|
60
61
|
|
|
61
62
|
export default {
|
|
62
63
|
name: 'PageHeader',
|
|
@@ -84,27 +85,42 @@ export default {
|
|
|
84
85
|
},
|
|
85
86
|
/** 导航按钮类型: 0 = 不显示,1 = 返回,2 = 首页,3 = 返回|首页 */
|
|
86
87
|
navType: {
|
|
87
|
-
type: Number,
|
|
88
|
-
default:
|
|
88
|
+
type: [Number, null],
|
|
89
|
+
default: null,
|
|
89
90
|
},
|
|
90
91
|
},
|
|
91
92
|
computed: {
|
|
92
93
|
/** 首页路径 */
|
|
93
94
|
homePageUrl() {
|
|
94
|
-
|
|
95
|
-
return process.env.VUE_APP_HOME_PATH;
|
|
95
|
+
return homePath;
|
|
96
96
|
},
|
|
97
97
|
/** 是否显示返回按钮 */
|
|
98
98
|
hasBack() {
|
|
99
|
-
|
|
99
|
+
// 如果指定了导航按钮类型,则根据类型判断
|
|
100
|
+
if (this.navType !== null) return !!(this.navType & 1);
|
|
101
|
+
const pages = getCurrentPages();
|
|
102
|
+
// 在首页不显示返回按钮
|
|
103
|
+
if (this.homePageUrl === '/' + pages[0].route) return false;
|
|
104
|
+
// 页面栈只有一个时不显示返回按钮
|
|
105
|
+
if (pages.length === 1) return false;
|
|
106
|
+
// 其他情况均显示返回按钮
|
|
107
|
+
return true;
|
|
100
108
|
},
|
|
101
109
|
/** 是否显示首页按钮 */
|
|
102
110
|
hasHome() {
|
|
103
|
-
|
|
111
|
+
// 如果指定了导航按钮类型,则根据类型判断
|
|
112
|
+
if (this.navType !== null) return !!(this.navType & 2);
|
|
113
|
+
const pages = getCurrentPages();
|
|
114
|
+
// 在首页不显示返回首页按钮
|
|
115
|
+
if (this.homePageUrl === '/' + pages[0].route) return false;
|
|
116
|
+
// 页面栈只有一个时显示返回按钮
|
|
117
|
+
if (pages.length === 1) return true;
|
|
118
|
+
// 其他情况均不显示返回按钮
|
|
119
|
+
return false;
|
|
104
120
|
},
|
|
105
121
|
/** 导航按钮个数 */
|
|
106
122
|
iconCount() {
|
|
107
|
-
return
|
|
123
|
+
return (this.hasBack ? 1 : 0) + (this.hasHome ? 1 : 0);
|
|
108
124
|
},
|
|
109
125
|
styleStr() {
|
|
110
126
|
return [
|
package/components/page/page.vue
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
:has-custom-nav="custom"
|
|
12
12
|
:has-footer="hasFooter && $slots.footer"
|
|
13
13
|
:use-scroll="useScroll"
|
|
14
|
-
:is-tab-page="
|
|
14
|
+
:is-tab-page="tabbar"
|
|
15
15
|
:enable-refresh="enableRefresh"
|
|
16
16
|
:refreshing="refreshing"
|
|
17
17
|
@scroll="$emit('scroll', $event)"
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
<slot></slot>
|
|
22
22
|
</page-body-cpn>
|
|
23
23
|
|
|
24
|
-
<page-footer-cpn v-if="hasFooter && $slots.footer" :is-tab-page="
|
|
24
|
+
<page-footer-cpn v-if="hasFooter && $slots.footer" :is-tab-page="tabbar">
|
|
25
25
|
<slot name="footer"></slot>
|
|
26
26
|
</page-footer-cpn>
|
|
27
27
|
|
|
@@ -95,10 +95,10 @@ export default {
|
|
|
95
95
|
type: String,
|
|
96
96
|
default: 'light',
|
|
97
97
|
},
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
98
|
+
/** 是否是 tabbar 页面,且 tabbar 未隐藏 */
|
|
99
|
+
tabbar: {
|
|
100
|
+
type: Boolean,
|
|
101
|
+
default: false,
|
|
102
102
|
},
|
|
103
103
|
},
|
|
104
104
|
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/** 组件前缀 */
|
|
2
|
+
declare let componentPrefix: string;
|
|
3
|
+
/** 首页路径 */
|
|
4
|
+
declare let homePath: string;
|
|
5
|
+
/** 设置组件前缀 */
|
|
6
|
+
declare const setComponentPrefix: (prefix: string) => void;
|
|
7
|
+
/** 设置首页路径 */
|
|
8
|
+
declare const setHomePath: (path: string) => void;
|
|
9
|
+
/** iconfont 图标 map */
|
|
10
|
+
declare let iconMap: Map<string, { fontFamily: string; prefix: string; name: string }>;
|
|
11
|
+
interface IconFontJson {
|
|
12
|
+
font_family: string;
|
|
13
|
+
css_prefix_text: string;
|
|
14
|
+
glyphs: { font_class: string }[];
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* 添加一组图标,传入 iconfont.json 文件内容
|
|
18
|
+
* @param iconJson iconfont.json 文件内容
|
|
19
|
+
*/
|
|
20
|
+
declare const addIcons: (iconJson: IconFontJson) => void;
|
|
21
|
+
|
|
22
|
+
export { componentPrefix, homePath, IconFontJson, setComponentPrefix, setHomePath, iconMap, addIcons };
|
package/configs/index.js
CHANGED
|
@@ -1,15 +1,33 @@
|
|
|
1
1
|
/** 组件前缀 */
|
|
2
2
|
let componentPrefix = 'app';
|
|
3
|
+
/** 首页路径 */
|
|
4
|
+
let homePath = '/pages/index/index';
|
|
3
5
|
|
|
4
|
-
/**
|
|
6
|
+
/**
|
|
7
|
+
* 设置组件前缀
|
|
8
|
+
* @param {string} prefix 组件前缀
|
|
9
|
+
*/
|
|
5
10
|
function setComponentPrefix(prefix) {
|
|
6
11
|
componentPrefix = prefix;
|
|
7
12
|
}
|
|
8
13
|
|
|
14
|
+
/**
|
|
15
|
+
* 设置首页路径
|
|
16
|
+
* @param {string} path 首页路径
|
|
17
|
+
*/
|
|
18
|
+
function setHomePath(path) {
|
|
19
|
+
homePath = path;
|
|
20
|
+
}
|
|
21
|
+
|
|
9
22
|
/** iconfont 图标 map */
|
|
10
23
|
const iconMap = new Map();
|
|
11
24
|
|
|
12
|
-
/**
|
|
25
|
+
/**
|
|
26
|
+
* 添加单个图标
|
|
27
|
+
* @param {string} fontFamily 字体文件名
|
|
28
|
+
* @param {string} prefix 图标前缀
|
|
29
|
+
* @param {string} name 图标名称
|
|
30
|
+
*/
|
|
13
31
|
function addIconToMap(fontFamily, prefix, name) {
|
|
14
32
|
if (iconMap.has(name)) {
|
|
15
33
|
// eslint-disable-next-line no-console
|
|
@@ -27,7 +45,14 @@ function addIconToMap(fontFamily, prefix, name) {
|
|
|
27
45
|
});
|
|
28
46
|
}
|
|
29
47
|
|
|
30
|
-
/**
|
|
48
|
+
/**
|
|
49
|
+
* 添加一组图标,传入 iconfont.json 文件内容
|
|
50
|
+
* @param {object} iconJson iconfont.json 文件内容
|
|
51
|
+
* @param {string} iconJson.font_family
|
|
52
|
+
* @param {string} iconJson.css_prefix_text
|
|
53
|
+
* @param {object[]} iconJson.glyphs
|
|
54
|
+
* @param {string} iconJson.glyphs.font_class
|
|
55
|
+
*/
|
|
31
56
|
function addIcons(iconJson) {
|
|
32
57
|
const fontFamily = iconJson.font_family;
|
|
33
58
|
const prefix = iconJson.css_prefix_text;
|
|
@@ -37,6 +62,7 @@ function addIcons(iconJson) {
|
|
|
37
62
|
});
|
|
38
63
|
}
|
|
39
64
|
|
|
65
|
+
// 添加内部图标库
|
|
40
66
|
addIcons(require('../resources/iconfont/uniapp_ui_icon/iconfont.json'));
|
|
41
67
|
|
|
42
|
-
export { componentPrefix, setComponentPrefix, iconMap, addIcons };
|
|
68
|
+
export { componentPrefix, homePath, setComponentPrefix, setHomePath, iconMap, addIcons };
|
package/init.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { IconFontJson } from './configs';
|
|
2
|
+
|
|
3
|
+
/** 组件库初始化配置 */
|
|
4
|
+
interface InitOptions {
|
|
5
|
+
/** 组件前缀 */
|
|
6
|
+
componentPrefix?: string;
|
|
7
|
+
/** 首页路径 */
|
|
8
|
+
homePath?: string;
|
|
9
|
+
/** iconfont 图标 json 文件 */
|
|
10
|
+
iconfont?: IconFontJson | IconFontJson[];
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* 初始化组件库
|
|
15
|
+
* @param {InitOptions} options 组件库初始化配置
|
|
16
|
+
*/
|
|
17
|
+
declare const init: (options: InitOptions) => void;
|
|
18
|
+
|
|
19
|
+
export default init;
|
package/init.js
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
const { setComponentPrefix, addIcons } = require('./configs');
|
|
1
|
+
const { setComponentPrefix, setHomePath, addIcons } = require('./configs');
|
|
2
2
|
|
|
3
3
|
/** 组件库初始化方法,在 main.js 中调用 */
|
|
4
4
|
function init(options = {}) {
|
|
5
5
|
if (options.componentPrefix) {
|
|
6
6
|
setComponentPrefix(options.componentPrefix);
|
|
7
7
|
}
|
|
8
|
+
if (options.homePath) {
|
|
9
|
+
setHomePath(options.homePath);
|
|
10
|
+
}
|
|
8
11
|
if (options.iconfont) {
|
|
9
12
|
if (Array.isArray(options.iconfont)) {
|
|
10
13
|
options.iconfont.forEach(addIcons);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ecolovo/uniapp-components",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.9",
|
|
4
4
|
"description": "Ecolovo UniApp 组件库",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"lint": "eslint . --fix"
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
"lodash-es": "4.17.21"
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|
|
19
|
+
"@dcloudio/types": "^3.4.30",
|
|
19
20
|
"@eslint/js": "^10.0.1",
|
|
20
21
|
"eslint": "^10.0.3",
|
|
21
22
|
"eslint-config-prettier": "^10.1.8",
|
|
@@ -12,8 +12,13 @@ $component-vars: null !default;
|
|
|
12
12
|
@return string.unquote('--#{$component-prefix}-#{$component}--#{$name}');
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
//
|
|
16
|
-
@mixin UTILS__SET_VAR($component, $
|
|
15
|
+
// 设置组件单个外部变量值
|
|
16
|
+
@mixin UTILS__SET_VAR($component, $name, $value) {
|
|
17
|
+
#{UTILS__VAR_NAME($name, $component)}: $value;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// 设置组件一组外部变量值
|
|
21
|
+
@mixin UTILS__SET_VAR_LIST($component, $values) {
|
|
17
22
|
@each $name, $value in $values {
|
|
18
23
|
#{UTILS__VAR_NAME($name, $component)}: $value;
|
|
19
24
|
}
|
|
@@ -39,8 +39,11 @@ $page-body: () !default;
|
|
|
39
39
|
$page-body-default: (
|
|
40
40
|
// 可视区域背景
|
|
41
41
|
background: transparent,
|
|
42
|
-
padding
|
|
43
|
-
padding-
|
|
42
|
+
padding: 20rpx,
|
|
43
|
+
padding-top: null,
|
|
44
|
+
padding-right: null,
|
|
45
|
+
padding-bottom: null,
|
|
46
|
+
padding-left: null
|
|
44
47
|
);
|
|
45
48
|
$page-body: map.merge($page-body-default, $page-body);
|
|
46
49
|
|
package/utils/windowInfo.js
CHANGED