-
Notifications
You must be signed in to change notification settings - Fork 137
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
jry
committed
Aug 27, 2024
1 parent
0e77e00
commit 01dee26
Showing
27 changed files
with
1,673 additions
and
371 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* | ||
* @Author : LQ,jry | ||
* @Description : | ||
* @version : 3.0 | ||
* @Date : 2021-08-20 16:44:21 | ||
* @LastAuthor : jry | ||
* @lastTime : 2024-08-20 14:20:58 | ||
* @FilePath : /uview-plus/libs/config/props/link.js | ||
*/ | ||
import config from '../../libs/config/config' | ||
|
||
export default { | ||
// link超链接组件props参数 | ||
link: { | ||
color: config.getString('color.up-primary'), | ||
fontSize: '15px', | ||
underLine: false, | ||
href: '', | ||
mpTips: '链接已复制,请在浏览器打开', | ||
lineColor: '', | ||
text: '' | ||
} | ||
} as UTSJSONObject |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { defineMixin } from '../../libs/vue' | ||
import defProps from './link' | ||
let crtProp = defProps['link'] as UTSJSONObject | ||
|
||
export const propsLink = defineMixin({ | ||
props: { | ||
// 文字颜色 | ||
color: { | ||
type: String, | ||
default: crtProp['color'] | ||
}, | ||
// 字体大小,单位px | ||
fontSize: { | ||
type: [String], | ||
default: crtProp['fontSize'] | ||
}, | ||
// 是否显示下划线 | ||
underLine: { | ||
type: Boolean, | ||
default: crtProp['underLine'] | ||
}, | ||
// 要跳转的链接 | ||
href: { | ||
type: String, | ||
default: crtProp['href'] | ||
}, | ||
// 小程序中复制到粘贴板的提示语 | ||
mpTips: { | ||
type: String, | ||
default: crtProp['mpTips'] | ||
}, | ||
// 下划线颜色 | ||
lineColor: { | ||
type: String, | ||
default: crtProp['lineColor'] | ||
}, | ||
// 超链接的问题,不使用slot形式传入,是因为nvue下无法修改颜色 | ||
text: { | ||
type: String, | ||
default: crtProp['text'] | ||
} | ||
} | ||
}) |
89 changes: 89 additions & 0 deletions
89
src/uni_modules/uview-plus/components/up-link/up-link.uvue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
<template> | ||
<text | ||
class="up-link" | ||
@tap.stop="openLink" | ||
:style="[linkStyle, addStyle(customStyle)]" | ||
>{{text}}</text> | ||
</template> | ||
|
||
<script> | ||
import { propsLink } from './props'; | ||
import { mpMixin } from '../../libs/mixin/mpMixin'; | ||
import { mixin } from '../../libs/mixin/mixin'; | ||
import { addStyle, addUnit, getPx, toast } from '../../libs/function/index'; | ||
/** | ||
* link 超链接 | ||
* @description 该组件为超链接组件,在不同平台有不同表现形式:在APP平台会通过plus环境打开内置浏览器,在小程序中把链接复制到粘贴板,同时提示信息,在H5中通过window.open打开链接。 | ||
* @tutorial https://ijry.github.io/uview-plus/components/link.html | ||
* @property {String} color 文字颜色 (默认 color['up-primary'] ) | ||
* @property {String | Number} fontSize 字体大小,单位px (默认 15 ) | ||
* @property {Boolean} underLine 是否显示下划线 (默认 false ) | ||
* @property {String} href 跳转的链接,要带上http(s) | ||
* @property {String} mpTips 各个小程序平台把链接复制到粘贴板后的提示语(默认“链接已复制,请在浏览器打开”) | ||
* @property {String} lineColor 下划线颜色,默认同color参数颜色 | ||
* @property {String} text 超链接的问题,不使用slot形式传入,是因为nvue下无法修改颜色 | ||
* @property {Object} customStyle 定义需要用到的外部样式 | ||
* | ||
* @example <up-link href="http://www.uviewui.com">蜀道难,难于上青天</up-link> | ||
*/ | ||
export default { | ||
name: "up-link", | ||
mixins: [mpMixin, mixin, propsLink], | ||
computed: { | ||
linkStyle(): any{ | ||
const style = { | ||
color: this.color, | ||
fontSize: addUnit(this.fontSize), | ||
// line-height设置为比字体大小多2px | ||
lineHeight: addUnit(parseInt(getPx(this.fontSize)) + 2), | ||
textDecoration: this.underLine ? 'underline' : 'none' | ||
} | ||
// if (this.underLine) { | ||
// style.borderBottomColor = this.lineColor || this.color | ||
// style.borderBottomWidth = '1px' | ||
// } | ||
return style | ||
} | ||
}, | ||
emits: ["click"], | ||
methods: { | ||
addStyle(style: any): any { | ||
return addStyle(style) | ||
}, | ||
openLink(): void { | ||
// #ifdef APP | ||
// todo | ||
//plus.runtime.openURL(this.href) | ||
// #endif | ||
// #ifdef H5 | ||
window.open(this.href) | ||
// #endif | ||
// #ifdef MP | ||
// todo | ||
// uni.setClipboardData({ | ||
// data: this.href, | ||
// success: () => { | ||
// uni.hideToast(); | ||
// this.$nextTick(() => { | ||
// toast(this.mpTips); | ||
// }) | ||
// } | ||
// }); | ||
// #endif | ||
this.$emit('click') | ||
} | ||
} | ||
} | ||
</script> | ||
|
||
<style lang="scss" scoped> | ||
@import "../../libs/css/components.scss"; | ||
$up-link-line-height:1 !default; | ||
|
||
.up-link { | ||
line-height: $up-link-line-height; | ||
@include flex; | ||
flex-wrap: wrap; | ||
flex: 1; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
154 changes: 154 additions & 0 deletions
154
src/uni_modules/uview-plus/components/up-text/props.uts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,154 @@ | ||
import { defineMixin } from '../../libs/vue' | ||
import defProps from './text' | ||
let crtProp = defProps['text'] as UTSJSONObject | ||
|
||
export const propsText = defineMixin({ | ||
props: { | ||
// 主题颜色 | ||
type: { | ||
type: String, | ||
default: crtProp['type'] | ||
}, | ||
// 是否显示 | ||
show: { | ||
type: Boolean, | ||
default: crtProp['show'] | ||
}, | ||
// 显示的值 | ||
text: { | ||
type: [String, Number], | ||
default: crtProp['text'] | ||
}, | ||
// 前置图标 | ||
prefixIcon: { | ||
type: String, | ||
default: crtProp['prefixIcon'] | ||
}, | ||
// 后置图标 | ||
suffixIcon: { | ||
type: String, | ||
default: crtProp['suffixIcon'] | ||
}, | ||
// 文本处理的匹配模式 | ||
// text-普通文本,price-价格,phone-手机号,name-姓名,date-日期,link-超链接 | ||
mode: { | ||
type: String, | ||
default: crtProp['mode'] | ||
}, | ||
// mode=link下,配置的链接 | ||
href: { | ||
type: String, | ||
default: crtProp['href'] | ||
}, | ||
// 格式化规则 | ||
format: { | ||
type: [String, Function], | ||
default: crtProp['format'] | ||
}, | ||
// mode=phone时,点击文本是否拨打电话 | ||
call: { | ||
type: Boolean, | ||
default: crtProp['call'] | ||
}, | ||
// 小程序的打开方式 | ||
openType: { | ||
type: String, | ||
default: crtProp['openType'] | ||
}, | ||
// 是否粗体,默认normal | ||
bold: { | ||
type: Boolean, | ||
default: crtProp['bold'] | ||
}, | ||
// 是否块状 | ||
block: { | ||
type: Boolean, | ||
default: crtProp['block'] | ||
}, | ||
// 文本显示的行数,如果设置,超出此行数,将会显示省略号 | ||
lines: { | ||
type: [String, Number], | ||
default: crtProp['lines'] | ||
}, | ||
// 文本颜色 | ||
color: { | ||
type: String, | ||
default: crtProp['color'] | ||
}, | ||
// 字体大小 | ||
size: { | ||
type: [String, Number], | ||
default: crtProp['size'] | ||
}, | ||
// 图标的样式 | ||
iconStyle: { | ||
type: [Object, String], | ||
default: crtProp['iconStyle'] | ||
}, | ||
// 文字装饰,下划线,中划线等,可选值 none|underline|line-through | ||
decoration: { | ||
tepe: String, | ||
default: crtProp['decoration'] | ||
}, | ||
// 外边距,对象、字符串,数值形式均可 | ||
margin: { | ||
type: [Object, String, Number], | ||
default: crtProp['margin'] | ||
}, | ||
// 文本行高 | ||
lineHeight: { | ||
type: [String, Number], | ||
default: crtProp['lineHeight'] | ||
}, | ||
// 文本对齐方式,可选值left|center|right | ||
align: { | ||
type: String, | ||
default: crtProp['align'] | ||
}, | ||
// 文字换行,可选值break-word|normal|anywhere | ||
wordWrap: { | ||
type: String, | ||
default: crtProp['wordWrap'] | ||
}, | ||
// 指定返回用户信息的语言,zh_CN 简体中文,zh_TW 繁体中文,en 英文。只微信小程序有效 | ||
lang: { | ||
type: String, | ||
default: crtProp['lang'] | ||
}, | ||
// 会话来源,open-type="contact"时有效。只微信小程序有效 | ||
sessionFrom: { | ||
type: String, | ||
default: crtProp['sessionFrom'] | ||
}, | ||
// 会话内消息卡片标题,open-type="contact"时有效 | ||
// 默认当前标题,只微信小程序有效 | ||
sendMessageTitle: { | ||
type: String, | ||
default: crtProp['sendMessageTitle'] | ||
}, | ||
// 会话内消息卡片点击跳转小程序路径,open-type="contact"时有效 | ||
// 默认当前分享路径,只微信小程序有效 | ||
sendMessagePath: { | ||
type: String, | ||
default: crtProp['sendMessagePath'] | ||
}, | ||
// 会话内消息卡片图片,open-type="contact"时有效 | ||
// 默认当前页面截图,只微信小程序有效 | ||
sendMessageImg: { | ||
type: String, | ||
default: crtProp['sendMessageImg'] | ||
}, | ||
// 是否显示会话内消息卡片,设置此参数为 true,用户进入客服会话会在右下角显示"可能要发送的小程序"提示, | ||
// 用户点击后可以快速发送小程序消息,open-type="contact"时有效 | ||
showMessageCard: { | ||
type: Boolean, | ||
default: crtProp['showMessageCard'] | ||
}, | ||
// 打开 APP 时,向 APP 传递的参数,open-type=launchApp时有效 | ||
// 只微信小程序、QQ小程序有效 | ||
appParameter: { | ||
type: String, | ||
default: crtProp['appParameter'] | ||
}, | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.