diff --git a/App.vue b/App.vue index 6445058..c6f6389 100644 --- a/App.vue +++ b/App.vue @@ -7,7 +7,7 @@ export default { onLaunch: function() { im.initIm('lmxuhwaglu76d') - return + // return //#ifdef APP-PLUS // 获取系统版本号 getVersions({ diff --git a/README.md b/README.md index 78f16ce..6d20a67 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,6 @@ # ZhHealth -ZH健康 \ No newline at end of file +ZH健康 + +## uni-icons图标组件 +[图标组件](https://hellouniapp.dcloud.net.cn/pages/extUI/icons/icons) \ No newline at end of file diff --git a/main.js b/main.js index 2940461..5b16def 100644 --- a/main.js +++ b/main.js @@ -10,15 +10,16 @@ import Vue from 'vue' import store from './store' import uView from 'uview-ui' import filters from './utils/filters.js' -import { - usqlite -} from '@/uni_modules/onemue-USQLite/js_sdk/usqlite.js' -import model from '@/utils/im/models.js' - import { router, RouterMount } from 'router' +import { + usqlite +} from '@/uni_modules/onemue-USQLite/js_sdk/usqlite.js' +import { + contactModel +} from '@/utils/im/models.js' Object.keys(filters).forEach(key => { Vue.filter(key, filters[key]) @@ -29,14 +30,22 @@ Vue.use(router) Vue.config.productionTip = false Vue.prototype.$store = store -uni.$sql = usqlite -uni.model = model - -uni.$sql.connect({ - name: 'zh-health',// 数据库名称 - path:'_doc/health.db', // 路径 -}) +usqlite.connect({ + name: 'zh-health', // 数据库名称 + path: '_doc/health.db', // 路径 +}, (err, res) => { + uni.getStorage({ + key: 'FIRST_RUN', + fail: () => { + contactModel.create((err, res) => { + console.error('SQLITE 创建表格', err, res) + uni.setStorageSync('FIRST_RUN', 'X') + }) + } + }) +}) + App.mpType = 'app' const app = new Vue({ store, diff --git a/manifest.json b/manifest.json index 162cdcd..f92dfdb 100644 --- a/manifest.json +++ b/manifest.json @@ -2,7 +2,7 @@ "name" : "ZH-HEALTH", "appid" : "__UNI__C29473D", "description" : "ZH-HEALTH,您手上的健康管理专家", - "versionName" : "1.0.17", + "versionName" : "1.0.20", "versionCode" : 100, "transformPx" : false, /* 5+App特有相关 */ @@ -89,7 +89,7 @@ "amap" : { "__platform__" : [ "android" ], "appkey_ios" : "", - "appkey_android" : "05b7f32ca9c897c8b63c505d92cd654b" + "appkey_android" : "1dfbe526a37dcb1f13263e0b5871ca4d" }, "system" : { "__platform__" : [ "android" ] @@ -98,41 +98,44 @@ "maps" : { "amap" : { "appkey_ios" : "", - "appkey_android" : "05b7f32ca9c897c8b63c505d92cd654b" + "appkey_android" : "1dfbe526a37dcb1f13263e0b5871ca4d" } } }, "icons" : { "android" : { - "hdpi" : "unpackage/res/icons/72x72.png", - "xhdpi" : "unpackage/res/icons/96x96.png", - "xxhdpi" : "unpackage/res/icons/144x144.png", - "xxxhdpi" : "unpackage/res/icons/192x192.png" + "hdpi" : "", + "xhdpi" : "", + "xxhdpi" : "", + "xxxhdpi" : "" }, "ios" : { - "appstore" : "unpackage/res/icons/1024x1024.png", + "appstore" : "", "ipad" : { - "app" : "unpackage/res/icons/76x76.png", - "app@2x" : "unpackage/res/icons/152x152.png", - "notification" : "unpackage/res/icons/20x20.png", - "notification@2x" : "unpackage/res/icons/40x40.png", - "proapp@2x" : "unpackage/res/icons/167x167.png", - "settings" : "unpackage/res/icons/29x29.png", - "settings@2x" : "unpackage/res/icons/58x58.png", - "spotlight" : "unpackage/res/icons/40x40.png", - "spotlight@2x" : "unpackage/res/icons/80x80.png" + "app" : "", + "app@2x" : "", + "notification" : "", + "notification@2x" : "", + "proapp@2x" : "", + "settings" : "", + "settings@2x" : "", + "spotlight" : "", + "spotlight@2x" : "" }, "iphone" : { - "app@2x" : "unpackage/res/icons/120x120.png", - "app@3x" : "unpackage/res/icons/180x180.png", - "notification@2x" : "unpackage/res/icons/40x40.png", - "notification@3x" : "unpackage/res/icons/60x60.png", - "settings@2x" : "unpackage/res/icons/58x58.png", - "settings@3x" : "unpackage/res/icons/87x87.png", - "spotlight@2x" : "unpackage/res/icons/80x80.png", - "spotlight@3x" : "unpackage/res/icons/120x120.png" + "app@2x" : "", + "app@3x" : "", + "notification@2x" : "", + "notification@3x" : "", + "settings@2x" : "", + "settings@3x" : "", + "spotlight@2x" : "", + "spotlight@3x" : "" } } + }, + "splashscreen" : { + "androidStyle" : "common" } }, "nativePlugins" : { diff --git a/pages/im/components/groupUserList.vue b/pages/im/components/groupUserList.vue index a4009aa..03d8e72 100644 --- a/pages/im/components/groupUserList.vue +++ b/pages/im/components/groupUserList.vue @@ -18,9 +18,8 @@ - - + + 查看更多群成员 diff --git a/pages/im/components/sent/sentPopups.vue b/pages/im/components/sent/sentPopups.vue index 5f7550d..d4824a0 100644 --- a/pages/im/components/sent/sentPopups.vue +++ b/pages/im/components/sent/sentPopups.vue @@ -103,16 +103,11 @@ this.callShow = true break; case 'location': - // uni.showToast({ - // icon: 'none', - // title: '功能正在开发中' - // }) - // uni.chooseLocation({ - // success: res => { - // console.log(res); - // // this.success() - // } - // }) + uni.chooseLocation({ + success: (c) => { + console.log(c); + } + }) break; case 'redpacket': uni.showToast({ diff --git a/pages/im/components/show/messageState.vue b/pages/im/components/show/messageState.vue index 0d9b6aa..7abab99 100644 --- a/pages/im/components/show/messageState.vue +++ b/pages/im/components/show/messageState.vue @@ -1,19 +1,13 @@ diff --git a/pages/im/components/show/showCall.vue b/pages/im/components/show/showCall.vue index 72078d1..b373326 100644 --- a/pages/im/components/show/showCall.vue +++ b/pages/im/components/show/showCall.vue @@ -1,9 +1,10 @@ @@ -68,7 +69,8 @@ font-size: 32rpx; color: $text-color; display: flex; - flex-direction: row; + flex-direction: row; + align-items: center; &.left { border-radius: 0 20rpx 20rpx 20rpx; @@ -80,8 +82,8 @@ background: $main-color; color: white; - .u-icon { - color: white; + .uni-icons { + color: white !important; } } } diff --git a/pages/im/friends/info.vue b/pages/im/friends/info.vue index 671796b..4032fc4 100644 --- a/pages/im/friends/info.vue +++ b/pages/im/friends/info.vue @@ -2,10 +2,10 @@ - + - {{ userInfo.name }} + {{ contact(targetId).name }} ({{ userInfo.name }}) 地址:{{ userInfo.address }} @@ -14,20 +14,16 @@ 保密 - - + + - + - - - - - + @@ -69,6 +65,14 @@ + + + + + + + @@ -83,12 +87,17 @@ } from '@/apis/interfaces/im.js' import * as RongIMLib from '@/uni_modules/RongCloud-IMWrapper/js_sdk/index' import * as CallLib from '@/uni_modules/RongCloud-CallWrapper/lib/index' + import imBase from '../mixins/imBase.js' + // friendship: '' 没有好友关系 // accepted 好友 // pending 申请中 // denied 拒绝 // blocked 黑名单 export default { + mixins: [ + imBase + ], data() { return { targetId: '', @@ -107,7 +116,9 @@ } ], callShow: false, - hasPeding: false + hasPeding: false, + modalShow: false, + contactRemark: '' } }, onLoad(e) { @@ -151,7 +162,26 @@ url: '/pages/im/private/chat?targetId=' + this.targetId }); }, + // 设置好友备注操作 setRemark() { + this.modalShow = true + this.contactRemark = this.$store.getters.contactInfo(this.targetId).name + }, + onHideModal() { + this.modalShow = false + }, + onChangeRemark() { + this.$store.dispatch('setContactRemark', { + targetId: this.targetId, + remark: this.contactRemark + }) + uni.showToast({ + icon: 'none', + title: '备注设置成功' + }) + this.onHideModal() + }, + setTag() { uni.showToast({ title: '开发中', icon: 'none' @@ -344,6 +374,10 @@ width: 200rpx; } + .uni-icons { + color: $text-gray-m !important; + } + .text { width: calc(100% - 200rpx); color: $text-gray-m; diff --git a/pages/im/group/chat.vue b/pages/im/group/chat.vue index 8b3b78b..9f1a5c1 100644 --- a/pages/im/group/chat.vue +++ b/pages/im/group/chat.vue @@ -99,7 +99,7 @@ }) // 清理聊天记录 uni.$once('cleanGroupMessage', this.getMessageList) - uni.$on('onRecallMessage_' + this.targetId, (message) => { + uni.$on('onRecallMessage_' + this.targetId, (message) => { this.messages = this.messages.map(item => { if (message.messageId == item.messageId) { return message diff --git a/pages/im/group/invite.vue b/pages/im/group/invite.vue index bab8744..a994fc2 100644 --- a/pages/im/group/invite.vue +++ b/pages/im/group/invite.vue @@ -26,7 +26,8 @@ - 完成{{`(${checkboxValue.length})` || ''}} + 添加中{{`(${checkboxValue.length})` || ''}} + 完成{{`(${checkboxValue.length})` || ''}} @@ -63,7 +64,8 @@ friends: [], orignalFriends: [], checkboxValue: [], - selectValue: [] + selectValue: [], + canInvite:false }; }, onLoad(e) { @@ -123,7 +125,8 @@ }, onInvite() { console.log(this.checkboxValue, 'userIds.....') - console.log(this.selectValue, 'userIds.....') + console.log(this.selectValue, 'userIds.....') + this.canInvite = true let userIds = [] this.checkboxValue.filter(item => { if (!utils.inArray(item, this.selectValue)) { @@ -136,9 +139,11 @@ delta: 1, animationType: 'pop-out', animationDuration: 200 - }); + }); + this.canInvite = false uni.$emit('groupInvitedUser') - }).catch(err => { + }).catch(err => { + this.canInvite = false uni.showToast({ icon: 'none', title: err.message diff --git a/pages/im/index.vue b/pages/im/index.vue index 097baf7..344ef48 100644 --- a/pages/im/index.vue +++ b/pages/im/index.vue @@ -106,7 +106,8 @@ code, conversations }) => { - if (code === 0) { + if (code === 0) { + console.log(conversations,',,,,,') this.conversations = conversations } }) diff --git a/pages/im/mixins/imBase.js b/pages/im/mixins/imBase.js index 959112d..faaf422 100644 --- a/pages/im/mixins/imBase.js +++ b/pages/im/mixins/imBase.js @@ -13,5 +13,10 @@ export default { sender() { return this.$store.getters.sender } + }, + methods: { + rpx2px(size) { + return utils.rpx2px(size) + } } } diff --git a/pages/im/mixins/messageActions.js b/pages/im/mixins/messageActions.js index 98ad50d..4c5db84 100644 --- a/pages/im/mixins/messageActions.js +++ b/pages/im/mixins/messageActions.js @@ -58,29 +58,28 @@ export default { } }) break; - case '撤回': - const pushContent = this.$store.getters.sender.name + '撤回了一条消息' - IMLib.recallMessage(msg.messageId, pushContent, - ({ - code, - message - }) => { - if (code === 0) { - uni.showToast({ - icon: 'none', - title: '消息撤回成功' - }) - IMLib.getMessage(msg.messageId, res => { - uni.$emit('onRecallMessage_' + msg.targetId, res.message) - }) - } else { - uni.showToast({ - icon: 'none', - title: '撤回失败' + code - }) - } - } - ) + case '撤回': + const pushContent = this.$store.getters.sender.name + '撤回了一条消息' + IMLib.recallMessage(msg.messageId, pushContent, + ({ + code, + message + }) => { + if (code === 0) { + uni.showToast({ + icon: 'none', + title: '消息撤回成功' + }) + msg.objectName = 'RC:RcNtf' + uni.$emit('onRecallMessage_' + msg.targetId, msg) + } else { + uni.showToast({ + icon: 'none', + title: '撤回失败' + code + }) + } + } + ) break; } this.hidePop() diff --git a/store/modules/im.js b/store/modules/im.js index 4dda8e8..10bfeac 100644 --- a/store/modules/im.js +++ b/store/modules/im.js @@ -1,4 +1,7 @@ import im from "@/utils/im/index.js" +import { + contactModel +} from '@/utils/im/models.js' export default { state: { @@ -9,12 +12,12 @@ export default { contacts(state) { return state.contacts }, - contactInfo: (state) => (targetId) => { + contactInfo: (state) => (targetId) => { if (state.contacts[targetId]) { - const info = state.contacts[targetId] - + const info = state.contacts[targetId] + return { - name: info.name, + name: info.remark ? info.remark : info.name, hash: info.hash, portraitUrl: info.localAvatar ? info.localAvatar : require('@/static/user/cover.png') } @@ -38,19 +41,41 @@ export default { updateContactInfo(state, contactInfo) { Vue.set(state.contacts, contactInfo.targetId, contactInfo) }, - setSenderInfo(state, contactInfo) { + setSenderInfo(state, contactInfo) { state.myInfo = { userId: contactInfo.targetId, name: contactInfo.name, portraitUrl: contactInfo.portraitUrl } +<<<<<<< HEAD } +======= + }, + setContactRemark(state, contactInfo) { + Vue.set(state.contacts, contactInfo.targetId, contactInfo) + } +>>>>>>> 013c030963aef06a00ac33d5f767cbd97ef2ceac }, actions: { + setContactRemark({ + commit + }, { + targetId, + remark + }) { + contactModel.find('targetId="' + targetId + '"', (err, result) => { + if (!err && result.length > 0) { + result[0].remark = remark + contactModel.update('targetId="' + targetId + '"', result[0], (err, res) => { + commit('setContactRemark', result[0]) + }) + } + }) + }, setSenderInfo({ commit }, contactInfo) { - commit('setSenderInfo', contactInfo) + commit('setSenderInfo', contactInfo) }, // 载入好友信息 launchContact({ @@ -63,8 +88,7 @@ export default { commit, dispatch }, contactInfo) { - const model = uni.model.contactModel - model.find('targetId="' + contactInfo.targetId + '"', (err, result) => { + contactModel.find('targetId="' + contactInfo.targetId + '"', (err, result) => { if (result.length == 0) { // 没有数据,直接新增一条 dispatch('initContact', contactInfo) @@ -75,13 +99,13 @@ export default { targetId: contactInfo.targetId, name: contactInfo.name, hash: contactInfo.hash, + type: contactInfo.type, portraitUrl: contactInfo.portraitUrl, - localAvatar: savedFilePath, - type: contactInfo.type + localAvatar: savedFilePath } - model.update('targetId="' + contactInfo.targetId + '"', info, (err, + contactModel.update('targetId="' + contactInfo.targetId + '"', info, (err, res) => { - console.log('UPDATE AVATAR, ERR', err, info); + console.log('UPDATE AVATAR, ERR', err, info) }) commit('updateContactInfo', info) }) @@ -90,17 +114,17 @@ export default { targetId: contactInfo.targetId, name: contactInfo.name, hash: contactInfo.hash, + type: contactInfo.type, portraitUrl: contactInfo.portraitUrl, - localAvatar: result[0].localAvatar, - type: contactInfo.type + localAvatar: result[0].localAvatar } - model.update('targetId="' + contactInfo.targetId + '"', info, (err, res) => { + contactModel.update('targetId="' + contactInfo.targetId + '"', info, (err, res) => { console.log('UPDATE NAME, ERR', err, info); }) commit('updateContactInfo', info) } } else { - console.log('updateContact, 无操作'); + console.log('updateContact, 无操作') } }) }, @@ -110,7 +134,6 @@ export default { }, contactInfo) { // 将好友信息保存到vuex的内存中,方便立即使用 commit('updateContactInfo', contactInfo) - const model = uni.model.contactModel // 用户头像,是否需要下载到本地 if (contactInfo.portraitUrl) { saveAvatar(contactInfo, (savedFilePath) => { @@ -118,11 +141,13 @@ export default { targetId: contactInfo.targetId, name: contactInfo.name, hash: contactInfo.hash, + type: contactInfo.type, portraitUrl: contactInfo.portraitUrl, - localAvatar: savedFilePath, - type: contactInfo.type + localAvatar: savedFilePath } - model.insert(info, (err, res) => {}) + contactModel.insert(info, (err, res) => { + console.error('保存头像', err, res) + }) // 保存头像后,更新信息 commit('updateContactInfo', info) }) @@ -132,11 +157,13 @@ export default { targetId: contactInfo.targetId, name: contactInfo.name, hash: contactInfo.hash, + type: contactInfo.type, portraitUrl: contactInfo.portraitUrl, - localAvatar: '', - type: contactInfo.type + localAvatar: '' } - model.insert(info, (err, res) => {}) + contactModel.insert(info, (err, res) => { + console.error('没保存头像', err, res) + }) } } } diff --git a/uni_modules/onemue-USQLite/.DS_Store b/uni_modules/onemue-USQLite/.DS_Store new file mode 100644 index 0000000..d610557 Binary files /dev/null and b/uni_modules/onemue-USQLite/.DS_Store differ diff --git a/uni_modules/onemue-USQLite/changelog.md b/uni_modules/onemue-USQLite/changelog.md index 1764a1f..ac8c1d3 100644 --- a/uni_modules/onemue-USQLite/changelog.md +++ b/uni_modules/onemue-USQLite/changelog.md @@ -1,7 +1,10 @@ -## 2.1.0(2022-01-14) -1. 新增了添加多个数据的事件选项(options, index)(感谢`@风扬`) -## 2.1.2(2022-01-14) -1. 新增了添加多个数据的事件选项(options, index)(感谢`@风扬`) +## 2.2.2(2022-02-18) +1. 解决了自增约束的部分bug +2. 解决了处理类型的问题 +## 2.2.0(2022-02-16) +1. 重新处理了判断类型的方法 +2. 解决了`no connect`的问题 +3. 新增了自增约束,需要为数字类型 ## 2.1.0(2022-01-14) 1. 新增了添加多个数据的事件选项(options, index)(感谢`@风扬`) ## 2.0.2(2022-01-05) diff --git a/uni_modules/onemue-USQLite/js_sdk/usqlite.js b/uni_modules/onemue-USQLite/js_sdk/usqlite.js index b71a836..ef24175 100644 --- a/uni_modules/onemue-USQLite/js_sdk/usqlite.js +++ b/uni_modules/onemue-USQLite/js_sdk/usqlite.js @@ -37,10 +37,13 @@ class Utils { } } } + Utils.log(primaryKeyArr.length); - if (primaryKeyArr.length>=1) { - sql = `CREATE TABLE '${name}' (${sqlArr.join(', ')}, PRIMARY KEY (${primaryKeyArr.join()}))`; - }else{ + if (primaryKeyArr.length>1) { + + sql = `CREATE TABLE '${name}' (${sqlArr.join(', ').replaceAll(' PRIMARY KEY','')}, PRIMARY KEY (${primaryKeyArr.join()}))`; + } + else{ sql = `CREATE TABLE '${name}' (${sqlArr.join(', ')})`; } Utils.log(`modelSql :${sql}`); @@ -59,6 +62,22 @@ class Utils { } restrainArray.push(Utils.toType(options.type)); + + // 主键 + if (options.primaryKey == true) { + if(options.autoIncrement != true){ + restrainArray.push('PRIMARY KEY'); + } + } + + // 自增 + if (Utils.isNumber(options.type)&&options.autoIncrement == true) { + restrainArray.pop(); + restrainArray.push('INTEGER'); + restrainArray.push('PRIMARY KEY'); + restrainArray.push('AUTOINCREMENT'); + } + // 非空 if (options.notNull == true) { restrainArray.push('NOT NULL'); @@ -74,10 +93,6 @@ class Utils { restrainArray.push('UNIQUE'); } - // 主键 - // if (options.primaryKey === true) { - // restrainArray.push('PRIMARY KEY'); - // } // 检查 if (options.check) { @@ -87,27 +102,44 @@ class Utils { return restrainArray.join(' '); } - // 联合主键 - static getUnionPrimaryKey() { - - } - static toType(jsType) { let sqliteType = ''; - if (jsType == Number) { + if (Utils.isNumber(jsType)) { sqliteType = 'numeric'; - } else if (jsType == Date) { + } else if (Utils.isDate(jsType)) { sqliteType = 'timestamp'; } else { sqliteType = 'varchar'; } return sqliteType; } + static log() { if (config.deBug) { console.log.apply(null, arguments); } } + + static warn() { + if (config.deBug) { + console.warn.apply(null, arguments); + } + } + + static error() { + console.error.apply(null, arguments); + } + + static isArray(value){ return Object.prototype.toString.call(value) === '[object Array]'} + static isObject(value){ return Object.prototype.toString.call(value) === '[object Object]'} + static isString(value){ return Object.prototype.toString.call(value) === '[object String]'} + static isFunction(value){ return (value === Function || Object.prototype.toString.call(value) === '[object Function]')} + static isNumber(value){ return (value === Number || Object.prototype.toString.call(value) === '[object Number]')} + static isNaN(value){ return (Object.prototype.toString.call(value) === '[object Number]' && isNaN(value))} + static isBoolean(value){ return Object.prototype.toString.call(value) === '[object Boolean]'} + static isUndefined(value){ return Object.prototype.toString.call(value) === '[object Undefined]'} + static isModel(value){ return Object.prototype.toString.call(value) === '[object Model]'} + static isDate(value){ return (value === Date||Object.prototype.toString.call(value) === '[object Date]')} } @@ -118,7 +150,7 @@ class Model { /** * @constructor * @param {String} name 数据库表名 - * @param {Object} options 数据表列对象 + * @param {} options 数据表列对象 * @returns */ constructor(name, options) { @@ -129,7 +161,10 @@ class Model { if (config.isConnect) { self.repair(); } else { - console.error('no connect'); + if(!config.name||!config.path){ + console.error('"config.name" or "config.path" is empty'); + } + usqlite.connect(config); } } @@ -138,21 +173,27 @@ class Model { * @param {String|Array} options * - String WHERE 内容 * - Array 需要查询的列 - * @param {*} callback + * @param {Function} callback * @returns */ find(options, callback) { let sql = ''; let self = this; self.repair(); - if (!callback) { + if(!(Utils.isString(options)||Utils.isArray(options)||Utils.isFunction(options))) { + Utils.error('The first parameter of Model.find should be "Array", "String" or "Function" (when there is only one parameter).') + } + if(!callback&&!(Utils.isFunction(options))) { + Utils.error('The second parameter of Model.find should be "Function".') + } + if (!callback&&Utils.isFunction(options)) { sql = `SELECT * FROM '${this.name}'`; // 查找全部 callback = options; - } else if (options.constructor == Array) { + } else if (Utils.isArray(options)) { sql = `SELECT ${options.join()} FROM '${this.name}'`; // 查找制定列 - } else if (options.constructor == String) { + } else if (Utils.isString(options)) { sql = `SELECT * FROM '${this.name}' WHERE ${options}`; // 制定条件查询 - }; + } Utils.log(`find: ${sql}`); @@ -180,7 +221,13 @@ class Model { let sql = ''; let self = this; self.repair(); - + if(!Utils.isObject(options)){ + Utils.error('The first parameter of Model.limit should be "Object".') + } + if(!Utils.isFunction(callback)){ + Utils.error('The second parameter of Model.limit should be "Function".') + } + if (!options.where) { // 不存在 where sql = @@ -215,12 +262,19 @@ class Model { let self = this; self.repair(); + if(!(Utils.isObject(options)||Util.isArray(options))){ + Utils.error('The first parameter of Model.insert should be "Object" or "Array".') + } + if(!Utils.isFunction(callback)){ + Utils.error('The second parameter of Model.insert should be "Function".') + } + if (config.isConnect) { - if (options.constructor == Array) { + if (Utils.isArray(options)) { for (var i = 0; i < options.length; i++) { this.insert(options[i], callback, i); } - } else if (options.constructor == Object) { + } else if (Utils.isObject(options)) { let keys = []; let values = []; let index = arguments[3]??null; @@ -255,7 +309,7 @@ class Model { /** * @description 更新数据 - * @param {Object} options:可选参数 更新条件 + * @param {String} options:可选参数 更新条件 * @param {Object} obj: 修改后的数据 * @param {Function} callback :(err,results)=>{} */ @@ -264,7 +318,14 @@ class Model { let self = this; let items = []; self.repair(); - + + if(!(Utils.isObject(options)||Utils.isString(options))){ + Utils.error('The first parameter of Model.update should be "Object" or "String".') + } + if(!(Utils.isObject(obj)||Utils.isFunction(obj))){ + Utils.error('The second parameter of Model.update should be "Objrct" or "Function".') + } + if (!callback) { // 不存在options callback = obj; @@ -298,13 +359,20 @@ class Model { /** * @description 删除数据 - * @param {Object} options :可选参数 删除条件 + * @param {String} options :可选参数 删除条件 * @param {Function} callback :(err,results)=>{} */ delete(options, callback) { var sql = ''; let self = this; self.repair(); + + if(!(Utils.isString(options)||Utils.isFunction(options))){ + Utils.error('The first parameter of Model.delete should be "Object" or "Function".') + } + if(callback&&!Utils.isFunction(callback)){ + Utils.error('The second parameter of Model.delete should be "Function".') + } if (!callback) { sql = `DELETE FROM '${this.name}'`; @@ -330,7 +398,7 @@ class Model { /** * @description 重命名或者新增列 - * @param {Object} options 参数 数组为新增多列 对象为新增单列{aa} 字符串重命名 + * @param {Object|Array|String} options 参数 数组为新增多列 对象为新增单列{aa} 字符串重命名 * @param {Function} callback :(err,results)=>{} * @return: */ @@ -338,12 +406,18 @@ class Model { let self = this; let sql = ''; self.repair(); - - if (options.constructor == Array) { // 新增多列 + if(!(Utils.isObject(options)||Utils.isArray(options)||Utils.isString(options))){ + Utils.error('The first parameter of Model.alter should be "Object", "Array" or "String".') + } + if(!Utils.isFunction(callback)){ + Utils.error('The second parameter of Model.alter should be "Function".') + } + + if (Utils.isArray(options)) { // 新增多列 for (let i = 0; i < options.length; i++) { self.alter(options[i], callback); } - } else if (options.constructor == Object) { // 新增单列 + } else if (Utils.isObject(options)) { // 新增单列 let column = Utils.restrain(options.name, options.option); sql = `ALTER TABLE '${this.name}' ADD COLUMN ${column}` } else if (options.constructor == String) { // 重命名 @@ -374,13 +448,13 @@ class Model { */ join(model, options, callback) { if (!model) { - console.error('"model" cannot be empty.'); + Utils.error('"model" cannot be empty.'); } - if (options.constructor != Object) { - console.error('The type of "options" is wrong, it should be "Object".'); + if (!Utils.isObject(options)) { + Utils.error('The type of "options" is wrong, it should be "Object".'); } if (!options.type || !options.predicate) { - console.error('Missing required parameters'); + Utils.error('Missing required parameters'); } let leftName = this.name; @@ -427,6 +501,13 @@ class Model { * @param {Function} callback :(err,results)=>{} */ sql(sql, callback) { + if (!Utils.isString(sql)) { + Utils.error('"The type of "sql" is wrong, it should be "String".'); + } + if (callback&&!Utils.isFunction(callback)) { + Utils.error('The type of "callback" is wrong, it should be "Function".'); + } + let self = this; self.repair(); @@ -449,6 +530,10 @@ class Model { * @param {Function} callback */ isExist(callback) { + if (callback&&!Utils.isFunction(callback)) { + Utils.error('The type of "callback" is wrong, it should be "Function".'); + } + let sql = `SELECT count(*) AS isExist FROM sqlite_master WHERE type='table' AND name='${this.name}'`; let self = this; Utils.log(`isExist: ${sql}`); @@ -470,6 +555,10 @@ class Model { * @param {Function} callback */ drop(callback) { + if (callback&&!Utils.isFunction(callback)) { + Utils.error('The type of "callback" is wrong, it should be "Function".'); + } + var sql = `DROP TABLE '${this.name}'`; let self = this; self.repair(); @@ -493,6 +582,10 @@ class Model { * @param {Function} callback */ create(callback) { + if (callback&&!Utils.isFunction(callback)) { + Utils.error('The type of "callback" is wrong, it should be "Function".'); + } + let self = this; let sql = Utils.modelSql(self.name, self.options); Utils.log(`create: ${sql}`); @@ -574,6 +667,7 @@ export class usqlite { } }); } + /** * @description 断开数据库 * @param {*} callback @@ -591,6 +685,19 @@ export class usqlite { } }); } + static closeAsync(options){ + plus.sqlite.closeDatabase({ + name: config.name, //数据库名称 + path: config.path, //数据库地址 + success(e) { + config.isConnect = false; + callback(null, e); + }, + fail(e) { + callback(e); + } + }); + } /** * @description 创建 Model 对象 * @example diff --git a/uni_modules/onemue-USQLite/js_sdk/usqlite.js.zip b/uni_modules/onemue-USQLite/js_sdk/usqlite.js.zip new file mode 100644 index 0000000..bf09d1c Binary files /dev/null and b/uni_modules/onemue-USQLite/js_sdk/usqlite.js.zip differ diff --git a/uni_modules/onemue-USQLite/package.json b/uni_modules/onemue-USQLite/package.json index 5965fcd..84c4ef9 100644 --- a/uni_modules/onemue-USQLite/package.json +++ b/uni_modules/onemue-USQLite/package.json @@ -1,7 +1,7 @@ { "id": "onemue-USQLite", "displayName": "u-SQLite V2", - "version": "2.1.0", + "version": "2.2.2", "description": "基于ORM技术,使用对象的方式来操作sqlite数据库,而无需编写任何sql语句.", "keywords": [ "USQLite,数据库操作,缓存,大数据缓存,sqlite,sql,orm" diff --git a/uni_modules/onemue-USQLite/readme.md b/uni_modules/onemue-USQLite/readme.md index 7e67594..582fb15 100644 --- a/uni_modules/onemue-USQLite/readme.md +++ b/uni_modules/onemue-USQLite/readme.md @@ -1,5 +1,6 @@ -

onemue-USQLite

+

onemue-USQLite

onemue-USQLite

+

没有特别说明,均为异步函数

> u-SQLite 交流群:643867519 > 如果觉的当前插件对你有帮助可以前往 [github](https://github.com/onemue/u-sqlite) 点 star! @@ -49,6 +50,7 @@ let studentModel = uni.$sql.model('student',{ - unique UNIQUE 不重复 - default DEFAULT 默认值 - notNull NOT NULL 非空 +- autoIncrement AUTOINCREMENT 非空 **联合主键** diff --git a/uni_modules/uni-icons/changelog.md b/uni_modules/uni-icons/changelog.md index 3c01efc..6449885 100644 --- a/uni_modules/uni-icons/changelog.md +++ b/uni_modules/uni-icons/changelog.md @@ -1,3 +1,9 @@ +## 1.3.5(2022-01-24) +- 优化 size 属性可以传入不带单位的字符串数值 +## 1.3.4(2022-01-24) +- 优化 size 支持其他单位 +## 1.3.3(2022-01-17) +- 修复 nvue 有些图标不显示的bug,兼容老版本图标 ## 1.3.2(2021-12-01) - 优化 示例可复制图标名称 ## 1.3.1(2021-11-23) diff --git a/uni_modules/uni-icons/components/uni-icons/icons.js b/uni_modules/uni-icons/components/uni-icons/icons.js index d189737..7889936 100644 --- a/uni_modules/uni-icons/components/uni-icons/icons.js +++ b/uni_modules/uni-icons/components/uni-icons/icons.js @@ -173,6 +173,13 @@ export default { "unicode": "e6bb", "unicode_decimal": 59067 }, + { + "icon_id": "24923353", + "name": "arrowthinright", + "font_class": "arrowthinright", + "unicode": "e6bb", + "unicode_decimal": 59067 + }, { "icon_id": "24923354", "name": "arrowthinleft", @@ -180,6 +187,13 @@ export default { "unicode": "e6bc", "unicode_decimal": 59068 }, + { + "icon_id": "24923354", + "name": "arrowthinleft", + "font_class": "arrowthinleft", + "unicode": "e6bc", + "unicode_decimal": 59068 + }, { "icon_id": "24923355", "name": "arrowthinup", @@ -187,12 +201,25 @@ export default { "unicode": "e6bd", "unicode_decimal": 59069 }, + { + "icon_id": "24923355", + "name": "arrowthinup", + "font_class": "arrowthinup", + "unicode": "e6bd", + "unicode_decimal": 59069 + }, { "icon_id": "24923356", "name": "arrowthindown", "font_class": "arrow-down", "unicode": "e6be", "unicode_decimal": 59070 + },{ + "icon_id": "24923356", + "name": "arrowthindown", + "font_class": "arrowthindown", + "unicode": "e6be", + "unicode_decimal": 59070 }, { "icon_id": "24923349", @@ -200,6 +227,12 @@ export default { "font_class": "bottom", "unicode": "e6b8", "unicode_decimal": 59064 + },{ + "icon_id": "24923349", + "name": "arrowdown", + "font_class": "arrowdown", + "unicode": "e6b8", + "unicode_decimal": 59064 }, { "icon_id": "24923346", @@ -208,6 +241,13 @@ export default { "unicode": "e6b5", "unicode_decimal": 59061 }, + { + "icon_id": "24923346", + "name": "arrowright", + "font_class": "arrowright", + "unicode": "e6b5", + "unicode_decimal": 59061 + }, { "icon_id": "24923347", "name": "arrowup", @@ -215,6 +255,13 @@ export default { "unicode": "e6b6", "unicode_decimal": 59062 }, + { + "icon_id": "24923347", + "name": "arrowup", + "font_class": "arrowup", + "unicode": "e6b6", + "unicode_decimal": 59062 + }, { "icon_id": "24923348", "name": "arrowleft", @@ -222,6 +269,13 @@ export default { "unicode": "e6b7", "unicode_decimal": 59063 }, + { + "icon_id": "24923348", + "name": "arrowleft", + "font_class": "arrowleft", + "unicode": "e6b7", + "unicode_decimal": 59063 + }, { "icon_id": "24923334", "name": "eye", diff --git a/uni_modules/uni-icons/components/uni-icons/uni-icons.vue b/uni_modules/uni-icons/components/uni-icons/uni-icons.vue index a9f271d..a87f68e 100644 --- a/uni_modules/uni-icons/components/uni-icons/uni-icons.vue +++ b/uni_modules/uni-icons/components/uni-icons/uni-icons.vue @@ -1,14 +1,18 @@