t-comm
Version:
专业、稳定、纯粹的工具库
57 lines (52 loc) • 1.34 kB
JavaScript
;
Object.defineProperty(exports, '__esModule', { value: true });
var morsePwd_morsePwd = require('../morse-pwd/morse-pwd.js');
/**
* 摩斯密码的 Vue mixin,方便实用
* @param {array} pwd 密钥
* @param {Function} cb 回到函数
* @returns 换入内容
* @example
* ```ts
* getMorsePwdMixin([1, 1, 1, 1, 1], function () {
* if (isInIFrame()) return;
* this.onShowLaunchApp();
* }),
* ```
*/
var getMorsePwdMixin = function getMorsePwdMixin(pwd, _cb) {
return {
data: function data() {
return {
morsePwd: null
};
},
mounted: function mounted() {
var _this = this;
var envType = 'MP';
this.morsePwd = morsePwd_morsePwd.MorsePwd.init({
pwd: pwd,
cb: function cb() {
if (typeof _cb === 'function') {
_cb.call(_this);
}
},
envType: envType
});
},
beforeDestroy: function beforeDestroy() {
this.morsePwd.clear();
},
methods: {
onMorsePwdLongPress: function onMorsePwdLongPress() {
this.morsePwd.longPress();
},
onMorsePwdClick: function onMorsePwdClick() {
this.morsePwd.click();
}
}
};
};
var morsePwdMixin = getMorsePwdMixin;
exports.getMorsePwdMixin = getMorsePwdMixin;
exports.morsePwdMixin = morsePwdMixin;