diff --git a/ldcake-ui/index.js b/ldcake-ui/index.js index 650ac6363fc905bb4416c8c991375eb9b710b3e4..7015704c789343e7752cc1083f7611a8da8bda09 100644 --- a/ldcake-ui/index.js +++ b/ldcake-ui/index.js @@ -1,10 +1,12 @@ import color from './libs/config/color.js' import common from './libs/utils/common.js' +import clipboard from './libs/utils/clipboard.js' import cache from './libs/utils/cache.js' import storage from './libs/utils/storage.js' const $c = { color, ...common, + ...clipboard, ...storage, ...cache, } diff --git a/ldcake-ui/libs/config/index.js b/ldcake-ui/libs/config/index.js index 5150b8e47f919044c13f3927da088a2cee622cc1..02fcf903d15edc39bb2567f457ca1b4423cdda05 100644 --- a/ldcake-ui/libs/config/index.js +++ b/ldcake-ui/libs/config/index.js @@ -1,4 +1,4 @@ -let version = '1.0.6'; +let version = '1.0.13'; export default { name: 'ldcake', diff --git a/ldcake-ui/libs/utils/cache.js b/ldcake-ui/libs/utils/cache.js index f31e73cc463dafcf752bc2e14d73f54e5d144be9..17b10f8a2c92504a6720ebde86e4818e907a01c2 100644 --- a/ldcake-ui/libs/utils/cache.js +++ b/ldcake-ui/libs/utils/cache.js @@ -16,9 +16,9 @@ let dtime = '_deadtime' export const setCache = (k, v, t) => { const key = getCacheKey(k) setStorage(key, v) - var seconds = parseInt(t) + let seconds = parseInt(t) if (seconds > 0) { - var timestamp = Date.parse(new Date()) + let timestamp = Date.parse(new Date()) timestamp = timestamp / 1000 + seconds setStorage(`${key}${dtime}`.toUpperCase(), `${timestamp}`) } else { @@ -56,7 +56,7 @@ export const getCache = (k, def) => { export const removeCache = (k) => { const key = getCacheKey(k) removeStorage(key) - removeStorage(`${key}dtime`.toUpperCase()) + removeStorage(`${key}${dtime}`.toUpperCase()) } // 清除cache diff --git a/ldcake-ui/libs/utils/clipboard.js b/ldcake-ui/libs/utils/clipboard.js new file mode 100644 index 0000000000000000000000000000000000000000..6e0ca20432d0c176d112f605578ec825c7f4a4ff --- /dev/null +++ b/ldcake-ui/libs/utils/clipboard.js @@ -0,0 +1,31 @@ +export const setClipboardData = (content) => { + // #ifdef H5 + try{ + let textarea = document.createElement("textarea") + textarea.value = content + textarea.readOnly = "readOnly" + document.body.appendChild(textarea) + textarea.select() // 选择对象 + textarea.setSelectionRange(0, content.length) //核心 + let result = document.execCommand("Copy") // 执行浏览器复制命令 + textarea.remove() + uni.showToast({ + title: '内容已复制', + icon: 'none', + duration: 2000 + }); + return result + }catch(e){ + return null + } + // #endif + // #ifndef H5 + uni.setClipboardData({ + data: content + }); + // #endif +} + +export default { + setClipboardData +} \ No newline at end of file diff --git a/ldcake-ui/libs/utils/storage.js b/ldcake-ui/libs/utils/storage.js index d88cf238a7d44f606f6db12bf3606259a3e1e8fc..40436a177973773c425ecbe489c678d4adbe75cb 100644 --- a/ldcake-ui/libs/utils/storage.js +++ b/ldcake-ui/libs/utils/storage.js @@ -1,4 +1,4 @@ -const config = require('../config/index') +import config from '../config/index' export const getStorageInfo = () => { return uni.getStorageInfoSync() @@ -14,8 +14,9 @@ export const getStorage = (k) => { return uni.getStorageSync(key) } -export const removeStorage = () => { - return uni.removeStorageSync() +export const removeStorage = (k) => { + const key = getStorageKey(k) + return uni.removeStorageSync(key) } export const clearStorage = () => { diff --git a/ldcake-ui/package.json b/ldcake-ui/package.json index 9d5b2db13bce97548784cca5ebb5cfb5b1ae7b66..aebd4278161e3dff153f9d751436142d3ccd3c4e 100644 --- a/ldcake-ui/package.json +++ b/ldcake-ui/package.json @@ -1,6 +1,6 @@ { "name": "ldcake-ui", - "version": "1.0.11", + "version": "1.0.13", "description": "基于uni-app的UI组件库", "main": "index.js", "scripts": { diff --git a/pages.json b/pages.json index 8cac2bef9722a3cb422cf933530e2e642975b75f..e36e6de36b906d97ede5ba965ed843d42334e6dc 100644 --- a/pages.json +++ b/pages.json @@ -2,63 +2,51 @@ "easycom": { "^c-(.*)": "@/ldcake-ui/components/c-$1/c-$1.vue" }, - "pages": [ - { - "path": "pages/index/index", - "style": { - "navigationBarTitleText": "绿豆糕组件库" - } + "pages": [{ + "path": "pages/index/index", + "style": { + "navigationBarTitleText": "绿豆糕组件库" } - ,{ - "path" : "pages/components/date-picker/date-picker", - "style" : - { - "navigationBarTitleText": "日期选择器(date-picker)", - "enablePullDownRefresh": false - } - - } - ,{ - "path" : "pages/components/spin/spin", - "style" : - { - "navigationBarTitleText": "Spin(加载中)", - "enablePullDownRefresh": false - } - - } - ,{ - "path" : "pages/components/fabutton/fabutton", - "style" : - { - "navigationBarTitleText": "悬浮按钮(fabutton)", - "enablePullDownRefresh": false - } - - } - ,{ - "path" : "pages/components/mp-tips/mp-tips", - "style" : - { - "navigationBarTitleText": "右上角引导(mp-tips)", - "enablePullDownRefresh": false - } - - } - ,{ - "path" : "pages/components/captcha/captcha", - "style" : - { - "navigationBarTitleText": "获取验证码(captcha)", - "enablePullDownRefresh": false - } - - } - ], + }, { + "path": "pages/components/date-picker/date-picker", + "style": { + "navigationBarTitleText": "日期选择器(date-picker)", + "enablePullDownRefresh": false + } + + }, { + "path": "pages/components/spin/spin", + "style": { + "navigationBarTitleText": "Spin(加载中)", + "enablePullDownRefresh": false + } + + }, { + "path": "pages/components/fabutton/fabutton", + "style": { + "navigationBarTitleText": "悬浮按钮(fabutton)", + "enablePullDownRefresh": false + } + + }, { + "path": "pages/components/mp-tips/mp-tips", + "style": { + "navigationBarTitleText": "右上角引导(mp-tips)", + "enablePullDownRefresh": false + } + + }, { + "path": "pages/components/captcha/captcha", + "style": { + "navigationBarTitleText": "获取验证码(captcha)", + "enablePullDownRefresh": false + } + + }], "globalStyle": { "navigationBarTextStyle": "black", "navigationBarTitleText": "绿豆糕组件库", - "navigationBarBackgroundColor": "#F8F8F8", - "backgroundColor": "#F8F8F8" + "navigationBarBackgroundColor": "#FFFFFF", + "backgroundColor": "#FFFFFF" } } diff --git a/pages/components/date-picker/date-picker.vue b/pages/components/date-picker/date-picker.vue index de65f831ad8882523acabb18bceb9ceee470dc64..2c1a7aab1fa6684d5275675402b338e01ebeabea 100644 --- a/pages/components/date-picker/date-picker.vue +++ b/pages/components/date-picker/date-picker.vue @@ -6,7 +6,7 @@ date-picker值:{{ result[0]||'' }} {{ result[1]||'' }} - + @@ -14,7 +14,7 @@ export default { data() { return { - result: [], + result: ['2021-01-01', '2021-02-01'], isShow: false, } },