Skip to content

Commit

Permalink
增加up-copy组件
Browse files Browse the repository at this point in the history
  • Loading branch information
jry committed Apr 7, 2024
1 parent 270651a commit 3ee730e
Show file tree
Hide file tree
Showing 9 changed files with 138 additions and 24 deletions.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@
"@rollup/plugin-commonjs": "^25.0.0",
"clipboard": "^2.0.11",
"dayjs": "^1.11.8",
"uview-plus": "^3.1.39",
"vue": "^3.2.45",
"vue-i18n": "^9.2.2",
"vuex": "^4.1.0"
Expand Down
8 changes: 5 additions & 3 deletions src/common/demo.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.u-block{
.u-block {
padding: 14px;
&__section{
&__section {
margin-bottom:10px;
}
&__title {
Expand All @@ -9,7 +9,7 @@
color: $u-content-color;
margin-bottom:10px;
}
&__flex{
&__flex {
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
Expand All @@ -26,6 +26,8 @@
.u-page {
padding: 15px 15px 40px 15px;
&__item {
flex: 1;
margin-bottom: 23px;
&__title {
font-size: 14px;
color: rgb(143, 156, 162);
Expand Down
2 changes: 1 addition & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import mixin from './common/mixin'
import { createSSRApp } from 'vue'
import { createI18n } from 'vue-i18n'
const i18n = createI18n(i18nConfig)
import {initRequest} from './util/request/index'
import { initRequest } from './util/request/index'
export function createApp() {
const app = createSSRApp(App)

Expand Down
18 changes: 13 additions & 5 deletions src/pages.json
Original file line number Diff line number Diff line change
Expand Up @@ -435,12 +435,20 @@
},
{
"root": "pages/componentsD",
"pages": [{
"path": "qrcode/qrcode",
"style": {
"navigationBarTitleText": "二维码"
"pages": [
{
"path": "qrcode/qrcode",
"style": {
"navigationBarTitleText": "二维码"
}
}
}]
,{
"path": "copy/copy",
"style": {
"navigationBarTitleText": "复制"
}
}
]
},
{
"root": "pages/template",
Expand Down
34 changes: 20 additions & 14 deletions src/pages/componentsA/cell/cell.nvue
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
<u-cell
title="uview-plus"
value="内容"
:isLink="true"
:isLink="true"
></u-cell>
<u-cell
title="利剑出鞘,一统江湖"
value="内容"
label="挣脱束缚,向往自由"
label="挣脱束缚,向往自由"
></u-cell>
</u-cell-group>
</view>
Expand Down Expand Up @@ -114,14 +114,14 @@
<u-cell
title="单元格"
isLink
>
<template #value>
<text
class="u-slot-value"
>99</text>
>
<template #value>
<text
class="u-slot-value"
>99</text>
</template>
<template #right-icon>
0
<template #right-icon>
0
</template>
</u-cell>
</u-cell-group>
Expand All @@ -145,6 +145,7 @@
<style lang="scss">
.cell-page {
padding-bottom: 20px;
background-color: #f3f4f6;
}

.cell-box {
Expand All @@ -156,26 +157,30 @@

&__block {
// background-color: #fff;
margin-top: 20px;
margin-top: 10px;
}
}

.u-page {
padding: 0;

&__item {
margin-bottom: 10px;

&__title {
color: $u-tips-color;
background-color: $u-bg-color;
padding: 15px;
padding: 10px 15px;
margin-bottom: 0px;
font-size: 15px;

&__slot-title {
color: $u-primary;
font-size: 14px;
}
}

:deep(.u-cell-group) {
background-color: #fff;
}
}
}

Expand All @@ -200,6 +205,7 @@
height: 17px;
color: #FFFFFF;
border-radius: 100px;
background-color: #f56c6c; margin-left: auto;
background-color: #f56c6c;
margin-left: auto;
}
</style>
23 changes: 23 additions & 0 deletions src/pages/componentsD/copy/copy.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<template>
<view class="u-page">
<view class="u-page__item">
<text class="u-page__item__title" style="margin-top: 0;">点击文字复制</text>
<view class="u-page__item__content">
<up-copy content="uview-plus is great !">
<text>点击复制</text>
</up-copy>
</view>
</view>
<view class="u-page__item">
<text class="u-page__item__title" style="margin-top: 0;">点击按钮复制</text>
<view class="u-page__item__content">
<up-copy content="uview-plus is great !">
<up-button type="primary">点击复制</up-button>
</up-copy>
</view>
</view>
</view>
</template>

<script setup>
</script>
6 changes: 6 additions & 0 deletions src/pages/example/components.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,12 @@ export default [{
icon: 'modal',
title: 'Modal 模态框',
title_en: 'Modal'
}
, {
path: '/pages/componentsD/copy/copy',
icon: 'copy',
title: 'copy 复制',
title_en: '复制'
}
// {
// path: '/pages/componentsA/fullScreen/fullScreen',
Expand Down
Binary file added src/static/uview/demo/copy.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
70 changes: 70 additions & 0 deletions src/uni_modules/uview-plus/components/u-copy/u-copy.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<template>
<view @click="handleClick">
<slot>复制</slot>
</view>
</template>
<script>
export default {
name: "xy-copy",
props: {
content: {
type: String,
default: ''
},
alertStyle: {
type: String,
default: 'toast'
},
notice: {
type: String,
default: '复制成功'
}
},
emits: ['success'],
methods: {
handleClick() {
let content = this.content;
if (!content) {
uni.showToast({
title: '暂无',
icon: 'none',
duration: 2000,
});
return false;
}
content = typeof content === 'string' ? content : content.toString() // 复制内容,必须字符串,数字需要转换为字符串
/**
* 小程序端 和 app端的复制逻辑
*/
let that = this;
uni.setClipboardData({
data: content,
success: function() {
if (that.alertStyle == 'modal') {
uni.showModal({
title: '提示',
content: that.notice
});
} else {
uni.showToast({
title: that.notice,
icon: 'none'
});
}
that.$emit('success');
},
fail:function(){
uni.showToast({
title: '复制失败',
icon: 'none',
duration:3000,
});
}
});
}
}
}
</script>

<style lang="scss" scoped>
</style>

0 comments on commit 3ee730e

Please sign in to comment.