You've already forked guangan-mp
1.0.0
This commit is contained in:
19
uni_modules/uni-fav/changelog.md
Normal file
19
uni_modules/uni-fav/changelog.md
Normal file
@ -0,0 +1,19 @@
|
||||
## 1.2.1(2022-05-30)
|
||||
- 新增 stat 属性 ,是否开启uni统计功能
|
||||
## 1.2.0(2021-11-19)
|
||||
- 优化 组件UI,并提供设计资源,详见:[https://uniapp.dcloud.io/component/uniui/resource](https://uniapp.dcloud.io/component/uniui/resource)
|
||||
- 文档迁移,详见:[https://uniapp.dcloud.io/component/uniui/uni-fav](https://uniapp.dcloud.io/component/uniui/uni-fav)
|
||||
## 1.1.1(2021-08-24)
|
||||
- 新增 支持国际化
|
||||
## 1.1.0(2021-07-13)
|
||||
- 组件兼容 vue3,如何创建vue3项目,详见 [uni-app 项目支持 vue3 介绍](https://ask.dcloud.net.cn/article/37834)
|
||||
## 1.0.6(2021-05-12)
|
||||
- 新增 组件示例地址
|
||||
## 1.0.5(2021-04-21)
|
||||
- 优化 添加依赖 uni-icons, 导入后自动下载依赖
|
||||
## 1.0.4(2021-02-05)
|
||||
- 优化 组件引用关系,通过uni_modules引用组件
|
||||
## 1.0.3(2021-02-05)
|
||||
- 优化 组件引用关系,通过uni_modules引用组件
|
||||
## 1.0.2(2021-02-05)
|
||||
- 调整为uni_modules目录规范
|
4
uni_modules/uni-fav/components/uni-fav/i18n/en.json
Normal file
4
uni_modules/uni-fav/components/uni-fav/i18n/en.json
Normal file
@ -0,0 +1,4 @@
|
||||
{
|
||||
"uni-fav.collect": "collect",
|
||||
"uni-fav.collected": "collected"
|
||||
}
|
8
uni_modules/uni-fav/components/uni-fav/i18n/index.js
Normal file
8
uni_modules/uni-fav/components/uni-fav/i18n/index.js
Normal file
@ -0,0 +1,8 @@
|
||||
import en from './en.json'
|
||||
import zhHans from './zh-Hans.json'
|
||||
import zhHant from './zh-Hant.json'
|
||||
export default {
|
||||
en,
|
||||
'zh-Hans': zhHans,
|
||||
'zh-Hant': zhHant
|
||||
}
|
4
uni_modules/uni-fav/components/uni-fav/i18n/zh-Hans.json
Normal file
4
uni_modules/uni-fav/components/uni-fav/i18n/zh-Hans.json
Normal file
@ -0,0 +1,4 @@
|
||||
{
|
||||
"uni-fav.collect": "收藏",
|
||||
"uni-fav.collected": "已收藏"
|
||||
}
|
4
uni_modules/uni-fav/components/uni-fav/i18n/zh-Hant.json
Normal file
4
uni_modules/uni-fav/components/uni-fav/i18n/zh-Hant.json
Normal file
@ -0,0 +1,4 @@
|
||||
{
|
||||
"uni-fav.collect": "收藏",
|
||||
"uni-fav.collected": "已收藏"
|
||||
}
|
161
uni_modules/uni-fav/components/uni-fav/uni-fav.vue
Normal file
161
uni_modules/uni-fav/components/uni-fav/uni-fav.vue
Normal file
@ -0,0 +1,161 @@
|
||||
<template>
|
||||
<view :class="[circle === true || circle === 'true' ? 'uni-fav--circle' : '']" :style="[{ backgroundColor: checked ? bgColorChecked : bgColor }]"
|
||||
@click="onClick" class="uni-fav">
|
||||
<!-- #ifdef MP-ALIPAY -->
|
||||
<view class="uni-fav-star" v-if="!checked && (star === true || star === 'true')">
|
||||
<uni-icons :color="fgColor" :style="{color: checked ? fgColorChecked : fgColor}" size="14" type="star-filled" />
|
||||
</view>
|
||||
<!-- #endif -->
|
||||
<!-- #ifndef MP-ALIPAY -->
|
||||
<uni-icons :color="fgColor" :style="{color: checked ? fgColorChecked : fgColor}" class="uni-fav-star" size="14" type="star-filled"
|
||||
v-if="!checked && (star === true || star === 'true')" />
|
||||
<!-- #endif -->
|
||||
<text :style="{color: checked ? fgColorChecked : fgColor}" class="uni-fav-text">{{ checked ? contentFav : contentDefault }}</text>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
||||
/**
|
||||
* Fav 收藏按钮
|
||||
* @description 用于收藏功能,可点击切换选中、不选中的状态
|
||||
* @tutorial https://ext.dcloud.net.cn/plugin?id=864
|
||||
* @property {Boolean} star = [true|false] 按钮是否带星星
|
||||
* @property {String} bgColor 未收藏时的背景色
|
||||
* @property {String} bgColorChecked 已收藏时的背景色
|
||||
* @property {String} fgColor 未收藏时的文字颜色
|
||||
* @property {String} fgColorChecked 已收藏时的文字颜色
|
||||
* @property {Boolean} circle = [true|false] 是否为圆角
|
||||
* @property {Boolean} checked = [true|false] 是否为已收藏
|
||||
* @property {Object} contentText = [true|false] 收藏按钮文字
|
||||
* @property {Boolean} stat 是否开启统计功能
|
||||
* @event {Function} click 点击 fav按钮触发事件
|
||||
* @example <uni-fav :checked="true"/>
|
||||
*/
|
||||
|
||||
import {
|
||||
initVueI18n
|
||||
} from '@dcloudio/uni-i18n'
|
||||
import messages from './i18n/index.js'
|
||||
const { t } = initVueI18n(messages)
|
||||
|
||||
export default {
|
||||
name: "UniFav",
|
||||
// TODO 兼容 vue3,需要注册事件
|
||||
emits: ['click'],
|
||||
props: {
|
||||
star: {
|
||||
type: [Boolean, String],
|
||||
default: true
|
||||
},
|
||||
bgColor: {
|
||||
type: String,
|
||||
default: "#eeeeee"
|
||||
},
|
||||
fgColor: {
|
||||
type: String,
|
||||
default: "#666666"
|
||||
},
|
||||
bgColorChecked: {
|
||||
type: String,
|
||||
default: "#007aff"
|
||||
},
|
||||
fgColorChecked: {
|
||||
type: String,
|
||||
default: "#FFFFFF"
|
||||
},
|
||||
circle: {
|
||||
type: [Boolean, String],
|
||||
default: false
|
||||
},
|
||||
checked: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
contentText: {
|
||||
type: Object,
|
||||
default () {
|
||||
return {
|
||||
contentDefault: "",
|
||||
contentFav: ""
|
||||
};
|
||||
}
|
||||
},
|
||||
stat:{
|
||||
type: Boolean,
|
||||
default: false
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
contentDefault() {
|
||||
return this.contentText.contentDefault || t("uni-fav.collect")
|
||||
},
|
||||
contentFav() {
|
||||
return this.contentText.contentFav || t("uni-fav.collected")
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
checked() {
|
||||
if (uni.report && this.stat) {
|
||||
if (this.checked) {
|
||||
uni.report("收藏", "收藏");
|
||||
} else {
|
||||
uni.report("取消收藏", "取消收藏");
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
onClick() {
|
||||
this.$emit("click");
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" >
|
||||
$fav-height: 25px;
|
||||
|
||||
.uni-fav {
|
||||
/* #ifndef APP-NVUE */
|
||||
display: flex;
|
||||
/* #endif */
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 60px;
|
||||
height: $fav-height;
|
||||
line-height: $fav-height;
|
||||
text-align: center;
|
||||
border-radius: 3px;
|
||||
/* #ifdef H5 */
|
||||
cursor: pointer;
|
||||
/* #endif */
|
||||
}
|
||||
|
||||
.uni-fav--circle {
|
||||
border-radius: 30px;
|
||||
}
|
||||
|
||||
.uni-fav-star {
|
||||
/* #ifndef APP-NVUE */
|
||||
display: flex;
|
||||
/* #endif */
|
||||
height: $fav-height;
|
||||
line-height: 24px;
|
||||
margin-right: 3px;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.uni-fav-text {
|
||||
/* #ifndef APP-NVUE */
|
||||
display: flex;
|
||||
/* #endif */
|
||||
height: $fav-height;
|
||||
line-height: $fav-height;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: 12px;
|
||||
}
|
||||
</style>
|
89
uni_modules/uni-fav/package.json
Normal file
89
uni_modules/uni-fav/package.json
Normal file
@ -0,0 +1,89 @@
|
||||
{
|
||||
"id": "uni-fav",
|
||||
"displayName": "uni-fav 收藏按钮",
|
||||
"version": "1.2.1",
|
||||
"description": " Fav 收藏组件,可自定义颜色、大小。",
|
||||
"keywords": [
|
||||
"fav",
|
||||
"uni-ui",
|
||||
"uniui",
|
||||
"收藏"
|
||||
],
|
||||
"repository": "https://github.com/dcloudio/uni-ui",
|
||||
"engines": {
|
||||
"HBuilderX": ""
|
||||
},
|
||||
"directories": {
|
||||
"example": "../../temps/example_temps"
|
||||
},
|
||||
"dcloudext": {
|
||||
"category": [
|
||||
"前端组件",
|
||||
"通用组件"
|
||||
],
|
||||
"sale": {
|
||||
"regular": {
|
||||
"price": "0.00"
|
||||
},
|
||||
"sourcecode": {
|
||||
"price": "0.00"
|
||||
}
|
||||
},
|
||||
"contact": {
|
||||
"qq": ""
|
||||
},
|
||||
"declaration": {
|
||||
"ads": "无",
|
||||
"data": "无",
|
||||
"permissions": "无"
|
||||
},
|
||||
"npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui"
|
||||
},
|
||||
"uni_modules": {
|
||||
"dependencies": [
|
||||
"uni-scss",
|
||||
"uni-icons"
|
||||
],
|
||||
"encrypt": [],
|
||||
"platforms": {
|
||||
"cloud": {
|
||||
"tcb": "y",
|
||||
"aliyun": "y"
|
||||
},
|
||||
"client": {
|
||||
"App": {
|
||||
"app-vue": "y",
|
||||
"app-nvue": "y"
|
||||
},
|
||||
"H5-mobile": {
|
||||
"Safari": "y",
|
||||
"Android Browser": "y",
|
||||
"微信浏览器(Android)": "y",
|
||||
"QQ浏览器(Android)": "y"
|
||||
},
|
||||
"H5-pc": {
|
||||
"Chrome": "y",
|
||||
"IE": "y",
|
||||
"Edge": "y",
|
||||
"Firefox": "y",
|
||||
"Safari": "y"
|
||||
},
|
||||
"小程序": {
|
||||
"微信": "y",
|
||||
"阿里": "y",
|
||||
"百度": "y",
|
||||
"字节跳动": "y",
|
||||
"QQ": "y"
|
||||
},
|
||||
"快应用": {
|
||||
"华为": "u",
|
||||
"联盟": "u"
|
||||
},
|
||||
"Vue": {
|
||||
"vue2": "y",
|
||||
"vue3": "y"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
10
uni_modules/uni-fav/readme.md
Normal file
10
uni_modules/uni-fav/readme.md
Normal file
@ -0,0 +1,10 @@
|
||||
|
||||
|
||||
## Fav 收藏按钮
|
||||
> **组件名:uni-fav**
|
||||
> 代码块: `uFav`
|
||||
|
||||
用于收藏功能,可点击切换选中、不选中的状态。
|
||||
|
||||
### [查看文档](https://uniapp.dcloud.io/component/uniui/uni-fav)
|
||||
#### 如使用过程中有任何问题,或者您对uni-ui有一些好的建议,欢迎加入 uni-ui 交流群:871950839
|
Reference in New Issue
Block a user