diff --git a/.gitignore b/.gitignore index 78df13555fa2898860ecf3ca7fd7762a11bace49..ba04d33b4b5754f3fb805ecf941c2e6cfe1ae5f5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,8 @@ +.DS_Store unpackage/ .hbuilderx node_modules -.DS_Store +.vite/ uni_modules_tools/copy -package-lock.json \ No newline at end of file +package-lock.json +/uni_modules/uni-config-center/uniCloud/cloudfunctions/common/uni-config-center/uni-id/config.json \ No newline at end of file diff --git a/App.vue b/App.vue index 9967daa3a0adf48e6c5e25c0153247178c99f8fe..0682c7d72b392374b1d7480740507a3952db6ff0 100644 --- a/App.vue +++ b/App.vue @@ -1,6 +1,9 @@ - - diff --git a/components/uni-bindMobileByMpWeixin/uni-bindMobileByMpWeixin.vue b/components/uni-bindMobileByMpWeixin/uni-bindMobileByMpWeixin.vue deleted file mode 100644 index d36b9c38c91e93099939fdb1d4c5daa83b3a05eb..0000000000000000000000000000000000000000 --- a/components/uni-bindMobileByMpWeixin/uni-bindMobileByMpWeixin.vue +++ /dev/null @@ -1,193 +0,0 @@ - - - - - diff --git a/components/uni-quick-login/i18n/en.json b/components/uni-quick-login/i18n/en.json deleted file mode 100644 index f4f3dfa984c54d88eb82ffc504eaf892a37faa73..0000000000000000000000000000000000000000 --- a/components/uni-quick-login/i18n/en.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "accountLogin": "Account", - "SMSLogin": "SMS", - "wechatLogin": "wechat", - "appleLogin": "Apple", - "oneClickLogin": "One click login", - "QQLogin": "QQ", - "xiaomiLogin": "Xiaomi", - "getProviderFail": "Failed to get service provider", - "loginErr": "Login service initialization error", - "chooseOtherLogin": "Click the third-party login", - "weibo":"weibo", - "noAgree": "You have not agreed to the privacy policy agreement", - "gotIt": "got it" -} diff --git a/components/uni-quick-login/i18n/index.js b/components/uni-quick-login/i18n/index.js deleted file mode 100644 index 5d5703a2c6113fd63367695a6a4c1d4c9cc005be..0000000000000000000000000000000000000000 --- a/components/uni-quick-login/i18n/index.js +++ /dev/null @@ -1,6 +0,0 @@ -import en from './en.json' -import zhHans from './zh-Hans.json' -export default { - en, - 'zh-Hans': zhHans -} diff --git a/components/uni-quick-login/i18n/zh-Hans.json b/components/uni-quick-login/i18n/zh-Hans.json deleted file mode 100644 index 91dacb419c2493510e0a83c6ed6d6aa797daefef..0000000000000000000000000000000000000000 --- a/components/uni-quick-login/i18n/zh-Hans.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "accountLogin": "账号登录", - "SMSLogin": "短信验证码", - "wechatLogin": "微信登录", - "appleLogin": "苹果登录", - "oneClickLogin": "一键登录", - "QQLogin": "QQ登录", - "xiaomiLogin": "小米登录", - "getProviderFail": "获取服务供应商失败", - "loginErr": "登录服务初始化错误", - "chooseOtherLogin": "点击了第三方登录", - "weibo": "微博", - "noAgree": "你未同意隐私政策协议", - "gotIt": "知道了" -} diff --git a/components/uni-quick-login/uni-quick-login.vue b/components/uni-quick-login/uni-quick-login.vue deleted file mode 100644 index 1dc4204f7adb547e9c0b0a4aef0ba2a655b137cc..0000000000000000000000000000000000000000 --- a/components/uni-quick-login/uni-quick-login.vue +++ /dev/null @@ -1,379 +0,0 @@ - - - - diff --git a/components/uni-send-sms-code/uni-send-sms-code.vue b/components/uni-send-sms-code/uni-send-sms-code.vue deleted file mode 100644 index 3b32c79da11de3d66d0c8d31b3e82254442ab67a..0000000000000000000000000000000000000000 --- a/components/uni-send-sms-code/uni-send-sms-code.vue +++ /dev/null @@ -1,144 +0,0 @@ - - - - - diff --git a/main.js b/main.js index 10c0fc2f9da22582a48625cff891eab79a67beab..dc60f268d26411f50c490210f771fc419c1541b9 100644 --- a/main.js +++ b/main.js @@ -1,16 +1,13 @@ import App from './App' -import store from './store' import i18n from './lang/i18n' // #ifndef VUE3 import Vue from 'vue' Vue.config.productionTip = false -Vue.prototype.$store = store App.mpType = 'app' const app = new Vue({ i18n, - store, ...App }) app.$mount() @@ -23,7 +20,6 @@ import {createSSRApp} from 'vue' export function createApp() { const app = createSSRApp(App) app.use(i18n) - app.use(store) return {app} } // #endif diff --git a/manifest.json b/manifest.json index 8f82c59dd129eeb7205440cc020029c818a7a27f..27e5549d8d50cb084c3331c6a18800196451e7aa 100644 --- a/manifest.json +++ b/manifest.json @@ -1,11 +1,10 @@ { "name" : "uni-starter", - "appid" : "__UNI__EC87F46", + "appid" : "__UNI__07F7150", "description" : "", "versionName" : "1.0.0", "versionCode" : "100", "transformPx" : false, - /* 5+App特有相关 */ "app-plus" : { "usingComponents" : true, "nvueStyleCompiler" : "uni-app", @@ -16,11 +15,8 @@ "autoclose" : true, "delay" : 0 }, - /* 模块配置 */ "modules" : {}, - /* 应用发布信息 */ "distribute" : { - /* android打包配置 */ "android" : { "permissions" : [ "", @@ -40,15 +36,11 @@ "" ] }, - /* ios打包配置 */ "ios" : {}, - /* SDK配置 */ "sdkConfigs" : {} } }, - /* 快应用特有相关 */ "quickapp" : {}, - /* 小程序特有相关 */ "mp-weixin" : { "appid" : "", "setting" : { diff --git a/package.json b/package.json index 965e57888c111c9c37509c7cf703efef8157d23d..b19828b0f4024885de7843f8557abe784155c475 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "id": "uni-starter", "displayName": "uni-starter", - "version": "1.2.5", + "version": "1.2.7", "description": "云端一体应用快速开发基本项目模版", "keywords": [ "login", @@ -36,8 +36,7 @@ }, "uni_modules": { "dependencies": [ - "uni-id-cf", - "uni-captcha" + "uni-id-pages" ], "encrypt": [], "platforms": { diff --git a/pages.json b/pages.json index bcb5ccbe8e440fa7ca1a87763c28db0dba0b6514..a5070a2b2915e484b4e0a57e6ab7116592a12560 100644 --- a/pages.json +++ b/pages.json @@ -1,12 +1,11 @@ { - "pages": [ - { + "pages": [{ "path": "pages/list/list", - "style": { - // #ifndef APP-PLUS - "enablePullDownRefresh": true, + "style": { + // #ifndef APP-PLUS + "enablePullDownRefresh": true, // #endif - "navigationStyle": "custom" + "navigationStyle": "custom" } }, { @@ -16,19 +15,10 @@ "navigationStyle": "custom" //#endif } - }, { - "path": "pages/ucenter/login-page/index/index", - "style": { - "navigationBarTitleText": "", - "app-plus": { - "animationType": "none", - "popGesture": "none" - } - } }, { "path": "pages/list/search/search", - "style": { - "navigationBarTitleText":"搜索" + "style": { + "navigationBarTitleText": "搜索" } }, { "path": "pages/list/detail", @@ -48,11 +38,6 @@ }, "navigationBarTitleText": "文章详情" } - }, { - "path": "pages/ucenter/userinfo/bind-mobile/bind-mobile", - "style": { - "navigationBarTitleText": "绑定手机号码" - } }, { "path": "pages/ucenter/ucenter", @@ -106,82 +91,106 @@ } }, { - "path": "pages/ucenter/userinfo/userinfo", + "path": "pages/common/webview/webview", "style": { - "navigationBarTitleText": "个人资料" + "navigationBarTitleText": "", + "enablePullDownRefresh": false + } + + }, + { + "path": "pages/ucenter/read-news-log/read-news-log", + "style": { + "navigationBarTitleText": "阅读记录", + "enablePullDownRefresh": true } }, { - "path": "pages/ucenter/userinfo/cropImage", + "path": "pages/ucenter/invite/invite", "style": { - "navigationStyle": "custom" + "navigationStyle": "custom", + "enablePullDownRefresh": false } + }, { - "path": "pages/ucenter/login-page/pwd-login/pwd-login", + "path": "uni_modules/uni-feedback/pages/opendb-feedback/opendb-feedback", "style": { - "navigationBarTitleText": "" + "navigationBarTitleText": "意见反馈", + "enablePullDownRefresh": false } }, { - "path": "pages/ucenter/login-page/pwd-retrieve/pwd-retrieve", + "path": "uni_modules/uni-id-pages/pages/userinfo/deactivate/deactivate", "style": { - "navigationBarTitleText": "重置密码" + "navigationBarTitleText": "注销账号" + } + }, { + "path": "uni_modules/uni-id-pages/pages/userinfo/userinfo", + "style": { + "navigationBarTitleText": "个人资料" + } + }, { + "path": "uni_modules/uni-id-pages/pages/userinfo/bind-mobile/bind-mobile", + "style": { + "navigationBarTitleText": "绑定手机号码" } }, { - "path": "pages/ucenter/login-page/phone-code/phone-code", + "path": "uni_modules/uni-id-pages/pages/userinfo/cropImage/cropImage", "style": { "navigationBarTitleText": "" } - }, { - "path": "pages/common/webview/webview", + "path": "uni_modules/uni-id-pages/pages/login/login-withoutpwd", "style": { - "navigationBarTitleText": "", - "enablePullDownRefresh": false + "navigationBarTitleText": "" } - }, { - "path": "pages/ucenter/login-page/register/register", + "path": "uni_modules/uni-id-pages/pages/login/login-withpwd", "style": { - "navigationBarTitleText": "注册", - "enablePullDownRefresh": false + "navigationBarTitleText": "" } - }, - { - "path": "pages/ucenter/read-news-log/read-news-log", + }, { + "path": "uni_modules/uni-id-pages/pages/login/login-smscode", "style": { - "navigationBarTitleText": "阅读记录", - "enablePullDownRefresh": true + "navigationBarTitleText": "手机验证码登录" } }, { - "path": "pages/ucenter/invite/invite", + "path": "uni_modules/uni-id-pages/pages/register/register", "style": { - "navigationStyle": "custom", - "enablePullDownRefresh": false + "navigationBarTitleText": "注册" } - }, { - "path": "pages/ucenter/settings/deactivate/deactivate", + "path": "uni_modules/uni-id-pages/pages/retrieve/retrieve", "style": { - "navigationBarTitleText": "注销提醒", - "enablePullDownRefresh": false + "navigationBarTitleText": "重置密码" } }, { - "path": "uni_modules/uni-feedback/pages/opendb-feedback/opendb-feedback", + "path": "uni_modules/uni-id-pages/pages/common/webview/webview", "style": { - "navigationBarTitleText": "意见反馈", - "enablePullDownRefresh": false + "enablePullDownRefresh": false, + "navigationBarTitleText": "" + } + }, { + "path": "uni_modules/uni-id-pages/pages/userinfo/change_pwd/change_pwd", + "style": { + "enablePullDownRefresh": false, + "navigationBarTitleText": "修改密码" } } - ], - "globalStyle": { + ], + "globalStyle": { + // #ifdef H5 + "h5": { + "titleNView":false + }, + // #endif "navigationBarTextStyle": "black", "navigationBarTitleText": "uni-starter", "navigationBarBackgroundColor": "#FFFFFF", "backgroundColor": "#F8F8F8", - "enablePullDownRefresh": false, - // "maxWidth":375, - "rpxCalcMaxDeviceWidth":375, - "rpxCalcBaseDeviceWidth":375 - // "rpxCalcIncludeWidth":0 + "enablePullDownRefresh": false, + // "maxWidth":375, + "rpxCalcMaxDeviceWidth": 375, + "rpxCalcBaseDeviceWidth": 375 + // "rpxCalcIncludeWidth":0 }, "condition": { "list": [{ @@ -189,11 +198,6 @@ }, { "path": "pages/list/list" }, - { - "path": "pages/ucenter/login-page/index/index" - }, { - "path": "pages/ucenter/userinfo/userinfo" - }, { "path": "pages/ucenter/settings/settings" } @@ -215,12 +219,18 @@ "iconPath": "static/tabbar/grid.png", "selectedIconPath": "static/tabbar/grid_active.png", "text": "宫格" - } - , { + }, { "pagePath": "pages/ucenter/ucenter", "iconPath": "static/tabbar/me.png", "selectedIconPath": "static/tabbar/me_active.png", "text": "我的" }] + }, + "uniIdRouter": { + "loginPage": "uni_modules/uni-id-pages/pages/login/login-withoutpwd", + "needLogin": [ + "/uni_modules/uni-id-pages/pages/userinfo/userinfo" + ], + "resToLogin": true } } diff --git a/pages/grid/grid.vue b/pages/grid/grid.vue index 55a04b76fc31a492a8195f73fc112e02563944fb..601821a7e05397aa8f05ec09d8333b815db6b1ce 100644 --- a/pages/grid/grid.vue +++ b/pages/grid/grid.vue @@ -24,14 +24,15 @@ - + - - diff --git a/pages/ucenter/login-page/phone-code/phone-code.vue b/pages/ucenter/login-page/phone-code/phone-code.vue deleted file mode 100644 index 687b67d31ca99dd9c3aef07981775b823dd67a6f..0000000000000000000000000000000000000000 --- a/pages/ucenter/login-page/phone-code/phone-code.vue +++ /dev/null @@ -1,82 +0,0 @@ - - - \ No newline at end of file diff --git a/pages/ucenter/login-page/pwd-retrieve/pwd-retrieve.vue b/pages/ucenter/login-page/pwd-retrieve/pwd-retrieve.vue deleted file mode 100644 index 2a5ae57bf38df0e08c6f555ac2059c5bf9976732..0000000000000000000000000000000000000000 --- a/pages/ucenter/login-page/pwd-retrieve/pwd-retrieve.vue +++ /dev/null @@ -1,179 +0,0 @@ - - - - - diff --git a/pages/ucenter/login-page/register/validator.js b/pages/ucenter/login-page/register/validator.js deleted file mode 100644 index d5b4c27c569cd62b36610ddafe97f7f8bfc84b88..0000000000000000000000000000000000000000 --- a/pages/ucenter/login-page/register/validator.js +++ /dev/null @@ -1,61 +0,0 @@ -export default { - "username": { - "rules": [{ - required: true, - errorMessage: '请输入用户名', - }, - { - minLength: 3, - maxLength: 32, - errorMessage: '用户名长度在 {minLength} 到 {maxLength} 个字符', - }, - { - validateFunction:function(rule,value,data,callback){ - console.log(value); - if(/^1\d{10}$/.test(value) || /^(\w-*\.*)+@(\w-?)+(\.\w{2,})+$/.test(value)){ - callback('用户名不能是:手机号或邮箱') - }; - return true - } - } - ], - "label": "用户名" - }, - "password":{ - "rules": [{ - required: true, - errorMessage: '请输入密码', - }, - { - minLength: 6, - maxLength: 20, - errorMessage: '密码长度在 {minLength} 到 {maxLength} 个字符', - } - ], - "label": "密码" - }, - "pwd2":{ - "rules": [{ - - required: true, - errorMessage: '再次输入密码', - - }, - { - minLength: 6, - maxLength: 20, - errorMessage: '密码长度在 {minLength} 到 {maxLength} 个字符', - }, - { - validateFunction:function(rule,value,data,callback){ - console.log(value); - if(value!=data.password){ - callback('两次输入密码不一致') - }; - return true - } - } - ], - "label": "确认密码" - } -} \ No newline at end of file diff --git a/pages/ucenter/settings/deactivate/deactivate.vue b/pages/ucenter/settings/deactivate/deactivate.vue deleted file mode 100644 index 09de453b9c40d440f0b7fe15984055eed339ac82..0000000000000000000000000000000000000000 --- a/pages/ucenter/settings/deactivate/deactivate.vue +++ /dev/null @@ -1,124 +0,0 @@ - - - - - diff --git a/pages/ucenter/settings/settings.vue b/pages/ucenter/settings/settings.vue index d0c44b4a1057bcdc9fd579e6cf9a300202202ca5..2ffa6c004810df9445d3b73d4504288e29663883 100644 --- a/pages/ucenter/settings/settings.vue +++ b/pages/ucenter/settings/settings.vue @@ -2,7 +2,7 @@ - + @@ -32,25 +32,20 @@ - - diff --git a/pages/ucenter/userinfo/userinfo.vue b/pages/ucenter/userinfo/userinfo.vue deleted file mode 100644 index 7c38f725b3a4182d120bfae25383900e1634ec2b..0000000000000000000000000000000000000000 --- a/pages/ucenter/userinfo/userinfo.vue +++ /dev/null @@ -1,284 +0,0 @@ - - - diff --git a/static/grid/c1.png b/static/grid/c1.png deleted file mode 100644 index 9d38fdc45f54393919608143278902961ebfc03e..0000000000000000000000000000000000000000 Binary files a/static/grid/c1.png and /dev/null differ diff --git a/static/grid/c2.png b/static/grid/c2.png deleted file mode 100644 index ce956d76c7547cc90469647a2a1f6cd34731dbb7..0000000000000000000000000000000000000000 Binary files a/static/grid/c2.png and /dev/null differ diff --git a/static/grid/c3.png b/static/grid/c3.png deleted file mode 100644 index 216202ad01c5d093a15c247cf791bf66759cf54d..0000000000000000000000000000000000000000 Binary files a/static/grid/c3.png and /dev/null differ diff --git a/static/grid/c4.png b/static/grid/c4.png deleted file mode 100644 index fb8b4770c323cc87544a502c4efcd9792ec6047a..0000000000000000000000000000000000000000 Binary files a/static/grid/c4.png and /dev/null differ diff --git a/static/grid/c5.png b/static/grid/c5.png deleted file mode 100644 index 310bfb123ba811240a23883c589557cced22af97..0000000000000000000000000000000000000000 Binary files a/static/grid/c5.png and /dev/null differ diff --git a/static/grid/c6.png b/static/grid/c6.png deleted file mode 100644 index c3c45d8814b2657a1c603b1a44c8207da134cb40..0000000000000000000000000000000000000000 Binary files a/static/grid/c6.png and /dev/null differ diff --git a/static/grid/c7.png b/static/grid/c7.png deleted file mode 100644 index a1e73908c282c8ce053a037a9b0d0ff2bcdb5f28..0000000000000000000000000000000000000000 Binary files a/static/grid/c7.png and /dev/null differ diff --git a/static/grid/c8.png b/static/grid/c8.png deleted file mode 100644 index c32633c0b399d119fe940b19fb48ee0efd986ca1..0000000000000000000000000000000000000000 Binary files a/static/grid/c8.png and /dev/null differ diff --git a/static/grid/c9.png b/static/grid/c9.png deleted file mode 100644 index 51bcf6a1b39ff986d5e347f16a34c8d3e5dfccec..0000000000000000000000000000000000000000 Binary files a/static/grid/c9.png and /dev/null differ diff --git a/static/grid/empty.png b/static/grid/empty.png deleted file mode 100644 index c836ffa48680ae45bd5a125f2ca5cd66f5799774..0000000000000000000000000000000000000000 Binary files a/static/grid/empty.png and /dev/null differ diff --git a/store/index.js b/store/index.js deleted file mode 100644 index efbd986d90fd99dc02b3bf10d6e539a20bfda5aa..0000000000000000000000000000000000000000 --- a/store/index.js +++ /dev/null @@ -1,24 +0,0 @@ -import user from '@/store/modules/user.js' - -// #ifndef VUE3 -import Vue from 'vue' -import Vuex from 'vuex' -Vue.use(Vuex) -const store = new Vuex.Store({ - modules: { - user - }, - strict: true -}) -// #endif - -// #ifdef VUE3 -import {createStore} from 'vuex' -const store = createStore({ - modules: { - user - } -}) -// #endif - -export default store \ No newline at end of file diff --git a/store/modules/user.js b/store/modules/user.js deleted file mode 100644 index e71aefacc3d188621ab63b86ef6d2d09ea70eeb0..0000000000000000000000000000000000000000 --- a/store/modules/user.js +++ /dev/null @@ -1,66 +0,0 @@ -// 上次启动时的用户信息 -let userInfoHistory = uni.getStorageSync('userInfo') || {}; -let state = { - //是否已经登录 - hasLogin: Boolean(Object.keys(userInfoHistory).length), - //用户信息 - info: userInfoHistory - }, - getters = { - info(state) { - return state.info; - }, - hasLogin(state){ - return state.hasLogin; - } - }, - mutations = { - login(state, info) { //登录成功后的操作 - //原有的结合传来的参数 - let _info = state.info; - state.info = Object.assign({}, _info, info); - //设置为已经登录 - state.hasLogin = true; - console.log('state.info',state.info); - //存储最新的用户数据到本地持久化存储 - uni.setStorageSync('userInfo', state.info); - if(info.token){ - uni.setStorage({ - key: 'uni_id_token', - data: state.info.token, - complete(e){ - // console.log('setStorage-------',e); - } - }); - uni.setStorageSync('uni_id_token_expired', state.info.tokenExpired) - } - }, - logout(state) { - state.info = {}; - state.hasLogin = false; - uni.setStorageSync('userInfo', {}); - uni.removeStorageSync('uni_id_token'); - uni.setStorageSync('uni_id_token_expired', 0) - } - }, - actions = { - logout(context){ - uni.showLoading({mask:true}) - uniCloud.callFunction({ - name:'uni-id-cf', - data:{action:'logout'}, - complete: (e) => { - console.log(e); - context.commit('logout') - uni.hideLoading() - } - }) - } - } -export default { - namespaced: true, - state, - getters, - mutations, - actions -} \ No newline at end of file diff --git a/uni-starter.config.js b/uni-starter.config.js index b133c59274ebbd4fbb31d48eb755987525f53470..ca6ad87b0e326dda4fccd695079d973e1cd38f0d 100644 --- a/uni-starter.config.js +++ b/uni-starter.config.js @@ -5,14 +5,14 @@ export default { "h5": { "url": "https://uni-starter.dcloud.net.cn", // 前端网页托管的域名 // 在h5端全局悬浮引导用户下载app的功能 更多自定义要求在/common/openApp.js中修改 - // "openApp": { //如不需要本功能直接移除本节点即可 - // //点击悬浮下载栏后打开的网页链接 - // "openUrl": '/#/pages/ucenter/invite/invite', - // //左侧显示的应用名称 - // "appname": 'uni-starter', - // //应用的图标 - // "logo": './static/logo.png', - // } + "openApp": { //如不需要本功能直接移除本节点即可 + // //点击悬浮下载栏后打开的网页链接 + // "openUrl": '/#/pages/ucenter/invite/invite', + // //左侧显示的应用名称 + // "appname": 'uni-starter', + // //应用的图标 + // "logo": './static/logo.png', + } }, "mp": { "weixin": { @@ -20,38 +20,6 @@ export default { "id": "gh_33446d7f7a26" } }, - "router": { - /* - 名词解释:“强制登录页” - 在打开定义的需强制登录的页面之前会自动检查(前端校验)uni_id_token的值是否有效, - 如果无效会自动跳转到登录页面 - 两种模式: - 1.needLogin:黑名单模式。枚举游客不可访问的页面。 - 2.visitor:白名单模式。枚举游客可访问的页面。 - * 注意:黑名单与白名单模式二选一 - */ - // "needLogin" : [ - // {pattern:/^\/pages\/list.*/}, //支持正则表达式 - // "/uni_modules/uni-news-favorite/pages/uni-news-favorite/list", - // "/uni_modules/uni-feedback/pages/uni-feedback/add" - // ], - "visitor" : [ - "/",//注意入口页必须直接写 "/" - {"pattern":/^\/pages\/list.*/}, //支持正则表达式 - {"pattern":/^\/pages\/ucenter\/login-page.*/}, - "/pages/common/webview/webview", - "/pages/grid/grid", - "/pages/ucenter/ucenter", - "/pages/ucenter/about/about", - "/pages/ucenter/settings/settings" - ], - /* - login:配置登录类型与优先级 - 未列举到的,或设备环境不支持的选项,将被隐藏。如果你需要在不同平台有不同的配置,直接用条件编译即可 - 根据数组的第0项,决定登录方式的第一优先级。 - */ - "login": ["weixin","univerify","username", "smsCode", "apple"] - }, //关于应用 "about": { //应用名称 @@ -62,16 +30,6 @@ export default { "company": "北京xx网络技术有限公司", //口号 "slogan": "云端一体应用快速开发模版", - //政策协议 - "agreements": [{ - "title": "用户服务协议", //如果开启了多语言国际化,本配置将失效。请在 lang/en.js 和 lang/zh-Hans.js中配置 - "url": "请填写用户服务协议链接" //对应的网络链接 - }, - { - "title": "隐私政策", //如果开启了多语言国际化,本配置将失效。请在 lang/en.js 和 lang/zh-Hans.js中配置 - "url": "请填写隐私政策链接" //对应的网络链接 - } - ], //应用的链接,用于分享到第三方平台和生成关于我们页的二维码 "download": "", //version diff --git a/uniCloud-aliyun/database/default.jql b/uniCloud-aliyun/database/default.jql index 465356a46dcc688b3da922ce65ae05b56a04cc45..35d21de2a42fb399679c59fe2dda8b267029c726 100644 --- a/uniCloud-aliyun/database/default.jql +++ b/uniCloud-aliyun/database/default.jql @@ -5,8 +5,8 @@ // 如果混写了普通js,最后一条语句需是数据库操作语句 // 此处代码运行不受DB Schema的权限控制,移植代码到实际业务中注意在schema中配好permission // 不支持clientDB的action -// 数据库查询有最大返回条数限制,详见:https://uniapp.dcloud.net.cn/uniCloud/cf-database?id=limit -// 详细JQL语法,请参考 https://uniapp.dcloud.net.cn/uniCloud/clientdb?id=jsquery +// 数据库查询有最大返回条数限制,详见:https://uniapp.dcloud.net.cn/uniCloud/cf-database.html#limit +// 详细JQL语法,请参考:https://uniapp.dcloud.net.cn/uniCloud/jql.html // 下面示例查询uni-id-users表的所有数据 db.collection('uni-id-users').get(); diff --git a/uni_modules.config.json b/uni_modules.config.json deleted file mode 100644 index c1bde5147caf39d306fe6f52a02ab90fc23c88fe..0000000000000000000000000000000000000000 --- a/uni_modules.config.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "scripts": { - // "preupload": "node uni_modules_tools/main.js change", - // "postupload": "node uni_modules_tools/main.js recovery" - } -} \ No newline at end of file diff --git a/uni_modules/json-gps/js_sdk/gps.js b/uni_modules/json-gps/js_sdk/gps.js index 2b99ead5a9aed1d5acdd5b76d62f5b88aaa3951a..031ffd4992272371941b97a106151dcce1d9b7e9 100644 --- a/uni_modules/json-gps/js_sdk/gps.js +++ b/uni_modules/json-gps/js_sdk/gps.js @@ -33,7 +33,6 @@ class Gps { // #ifdef APP-PLUS await this.checkGpsIsOpen() // #endif - // #ifdef MP-WEIXIN if (err.errMsg == 'getLocation:fail auth deny') { @@ -67,7 +66,7 @@ class Gps { // #ifdef APP-PLUS async checkGpsIsOpen() { this.lock = true //加锁防止重复的请求 - console.log('检查定位设置开启问题', permision.checkSystemEnableLocation()); + // console.log('检查定位设置开启问题', permision.checkSystemEnableLocation()); if (!permision.checkSystemEnableLocation()) { plus.nativeUI.confirm("手机定位权限没有开启,是否去开启?", (e) => { this.lock = false @@ -96,7 +95,7 @@ class Gps { return false } let checkAppGpsRes = await this.checkAppGps() - console.log(checkAppGpsRes, 'checkAppGpsRes'); + // console.log(checkAppGpsRes, 'checkAppGpsRes'); if (!checkAppGpsRes) { plus.nativeUI.confirm("应用定位权限没有开启,是否去开启?", (e) => { this.lock = false diff --git a/uni_modules/json-gps/js_sdk/wa-permission/permission.js b/uni_modules/json-gps/js_sdk/wa-permission/permission.js index 185dfae680144379771cbd964b063361d44a5512..51207bc74579b5b350e376b115110221d3dbffd3 100644 --- a/uni_modules/json-gps/js_sdk/wa-permission/permission.js +++ b/uni_modules/json-gps/js_sdk/wa-permission/permission.js @@ -45,7 +45,7 @@ function judgeIosPermissionLocation() { var cllocationManger = plus.ios.import("CLLocationManager"); var status = cllocationManger.authorizationStatus(); result = (status != 2) - console.log("定位权限开启:" + result); + // console.log("定位权限开启:" + result); // 以下代码判断了手机设备的定位是否关闭,推荐另行使用方法 checkSystemEnableLocation /* var enable = cllocationManger.locationServicesEnabled(); var status = cllocationManger.authorizationStatus(); @@ -250,7 +250,7 @@ function checkSystemEnableLocation() { var result = false; var cllocationManger = plus.ios.import("CLLocationManager"); var result = cllocationManger.locationServicesEnabled(); - console.log("系统定位开启:" + result); + // console.log("系统定位开启:" + result); plus.ios.deleteObject(cllocationManger); return result; } else { diff --git a/uni_modules/uni-captcha/changelog.md b/uni_modules/uni-captcha/changelog.md index 703a268752ab4ae27973fe597e1e6bc75eff543d..496672f1814afdb4628fe1350de3be4eecb43ac0 100644 --- a/uni_modules/uni-captcha/changelog.md +++ b/uni_modules/uni-captcha/changelog.md @@ -1,3 +1,5 @@ +## 0.6.1(2022-06-23) +- 修复:部分返回值,不符合响应体规范的问题 ## 0.6.0(2022-05-27) - 新增:支持在`uni-config-center`中根据场景值配置 - 修复:弹窗式验证码,输入内容后点击取消,重新打开验证码的值仍然存在的问题 diff --git a/uni_modules/uni-captcha/package.json b/uni_modules/uni-captcha/package.json index 9ba9206eb1b073ef79aed65d5ead3dbce8cf4ff6..cf586043e7397b09ac6835558dd011fb30a5cdc7 100644 --- a/uni_modules/uni-captcha/package.json +++ b/uni_modules/uni-captcha/package.json @@ -1,14 +1,14 @@ { "id": "uni-captcha", "displayName": "uni-captcha", - "version": "0.6.0", + "version": "0.6.1", "description": "云端一体图形验证码组件", "keywords": [ - "uniCloud", "captcha", - "验证码", "图形验证码", - "人机验证" + "人机验证", + "防刷", + "防脚本" ], "repository": "https://gitee.com/dcloud/uni-captcha", "engines": { diff --git a/uni_modules/uni-captcha/uniCloud/cloudfunctions/common/uni-captcha/index.js b/uni_modules/uni-captcha/uniCloud/cloudfunctions/common/uni-captcha/index.js index fe2692aed61362fefaeb8814e032f8a1e3fabeb6..b170e625aa27e334380c7eb1b4718ae8902d8f95 100644 --- a/uni_modules/uni-captcha/uniCloud/cloudfunctions/common/uni-captcha/index.js +++ b/uni_modules/uni-captcha/uniCloud/cloudfunctions/common/uni-captcha/index.js @@ -1 +1 @@ -"use strict";var e=require("assert"),t=require("path");function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var o=n(e),s=n(t);function r(e){const t=.2*Math.random()-.1;switch(e.type){case"M":case"L":e.x+=t,e.y+=t;break;case"Q":case"C":e.x+=t,e.y+=t,e.x1+=t,e.y1+=t}return e}function a(e,t,n,o,s,r,a){let i,l,c,u,p,h;if(e<=0||e>=1)throw RangeError("spliteCurveAt requires position > 0 && position < 1");return u=[],p=0,i={},l={},c={},i.x=t,i.y=n,l.x=o,l.y=s,c.x=r,c.y=a,h=e,u[p++]=i.x,u[p++]=i.y,u[p++]=i.x+=(l.x-i.x)*h,u[p++]=i.y+=(l.y-i.y)*h,l.x+=(c.x-l.x)*h,l.y+=(c.y-l.y)*h,u[p++]=i.x+(l.x-i.x)*h,u[p++]=i.y+(l.y-i.y)*h,u[p++]=l.x,u[p++]=l.y,u[p++]=c.x,u[p++]=c.y,u}function i(e,t){return Math.random()*(t-e)+e}var l=function(e,t){const n=e[0];o.default(n,"expect a string");const s=t.fontSize,l=s/t.font.unitsPerEm,c=t.font.charToGlyph(n),u=c.advanceWidth?c.advanceWidth*l:0,p=t.x-u/2,h=(t.ascender+t.descender)*l,f=t.y+h/2,d=c.getPath(p,f,s);d.commands.forEach(r),d.commands=function(e,t){const n=[];for(let o=0;ot.truncateLineProbability){const e=i(-.1,.1);n.push(s),n.push({type:"L",x:(s.x+r.x)/2+e,y:(s.y+r.y)/2+e})}else n.push(s)}else if("Q"===s.type&&o>=1){const r=e[o-1];if(("L"===r.type||"M"===r.type)&&Math.random()>t.truncateCurveProbability){const e=r.x,o=r.y,l=i(-.1,.1),c=s.x1+l,u=s.y1+l,p=s.x+l,h=s.y+l,f=a(i(t.truncateCurvePositionMin,t.truncateCurvePositionMax),e,o,c,u,p,h),d={type:"Q",x1:f[2],y1:f[3],x:f[4],y:f[5]},g={type:"L",x:f[4],y:f[5]},m={type:"Q",x1:f[6],y1:f[7],x:f[8],y:f[9]},y={type:"L",x:f[8],y:f[9]};n.push(d),n.push(g),n.push(m),n.push(y)}}else n.push(s)}return n}(d.commands,t);return d.toPathData()};function c(){this.table=new Uint16Array(16),this.trans=new Uint16Array(288)}function u(e,t){this.source=e,this.sourceIndex=0,this.tag=0,this.bitcount=0,this.dest=t,this.destLen=0,this.ltree=new c,this.dtree=new c}var p=new c,h=new c,f=new Uint8Array(30),d=new Uint16Array(30),g=new Uint8Array(30),m=new Uint16Array(30),y=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),v=new c,b=new Uint8Array(320);function S(e,t,n,o){var s,r;for(s=0;s>>=1,t}function E(e,t,n){if(!t)return n;for(;e.bitcount<24;)e.tag|=e.source[e.sourceIndex++]<>>16-t;return e.tag>>>=t,e.bitcount-=t,o+n}function O(e,t){for(;e.bitcount<24;)e.tag|=e.source[e.sourceIndex++]<>>=1,++s,n+=t.table[s],o-=t.table[s]}while(o>=0);return e.tag=r,e.bitcount-=s,t.trans[n+o]}function w(e,t,n){var o,s,r,a,i,l;for(o=E(e,5,257),s=E(e,5,1),r=E(e,4,4),a=0;a<19;++a)b[a]=0;for(a=0;a8;)e.sourceIndex--,e.bitcount-=8;if((t=256*(t=e.source[e.sourceIndex+1])+e.source[e.sourceIndex])!==(65535&~(256*e.source[e.sourceIndex+3]+e.source[e.sourceIndex+2])))return-3;for(e.sourceIndex+=4,n=t;n;--n)e.dest[e.destLen++]=e.source[e.sourceIndex++];return e.bitcount=0,0}!function(e,t){var n;for(n=0;n<7;++n)e.table[n]=0;for(e.table[7]=24,e.table[8]=152,e.table[9]=112,n=0;n<24;++n)e.trans[n]=256+n;for(n=0;n<144;++n)e.trans[24+n]=n;for(n=0;n<8;++n)e.trans[168+n]=280+n;for(n=0;n<112;++n)e.trans[176+n]=144+n;for(n=0;n<5;++n)t.table[n]=0;for(t.table[5]=32,n=0;n<32;++n)t.trans[n]=n}(p,h),S(f,d,4,3),S(g,m,2,1),f[28]=0,d[28]=258;var D=function(e,t){var n,o,s=new u(e,t);do{switch(n=T(s),E(s,2,0)){case 0:o=R(s);break;case 1:o=k(s,p,h);break;case 2:w(s,s.ltree,s.dtree),o=k(s,s.ltree,s.dtree);break;default:o=-3}if(0!==o)throw new Error("Data error")}while(!n);return s.destLenthis.x2&&(this.x2=e)),"number"==typeof t&&((isNaN(this.y1)||isNaN(this.y2))&&(this.y1=t,this.y2=t),tthis.y2&&(this.y2=t))},L.prototype.addX=function(e){this.addPoint(e,null)},L.prototype.addY=function(e){this.addPoint(null,e)},L.prototype.addBezier=function(e,t,n,o,s,r,a,i){const l=[e,t],c=[n,o],u=[s,r],p=[a,i];this.addPoint(e,t),this.addPoint(a,i);for(let e=0;e<=1;e++){const t=6*l[e]-12*c[e]+6*u[e],n=-3*l[e]+9*c[e]-9*u[e]+3*p[e],o=3*c[e]-3*l[e];if(0===n){if(0===t)continue;const n=-o/t;0=0&&n>0&&(e+=" "),e+=t(o)}return e}e=void 0!==e?e:2;let o="";for(let e=0;e=0&&e<=255,"Byte value should be between 0 and 255."),[e]},A.BYTE=F(1),P.CHAR=function(e){return[e.charCodeAt(0)]},A.CHAR=F(1),P.CHARARRAY=function(e){const t=[];for(let n=0;n>8&255,255&e]},A.USHORT=F(2),P.SHORT=function(e){return e>=32768&&(e=-(65536-e)),[e>>8&255,255&e]},A.SHORT=F(2),P.UINT24=function(e){return[e>>16&255,e>>8&255,255&e]},A.UINT24=F(3),P.ULONG=function(e){return[e>>24&255,e>>16&255,e>>8&255,255&e]},A.ULONG=F(4),P.LONG=function(e){return e>=2147483648&&(e=-(4294967296-e)),[e>>24&255,e>>16&255,e>>8&255,255&e]},A.LONG=F(4),P.FIXED=P.ULONG,A.FIXED=A.ULONG,P.FWORD=P.SHORT,A.FWORD=A.SHORT,P.UFWORD=P.USHORT,A.UFWORD=A.USHORT,P.LONGDATETIME=function(e){return[0,0,0,0,e>>24&255,e>>16&255,e>>8&255,255&e]},A.LONGDATETIME=F(8),P.TAG=function(e){return G.argument(4===e.length,"Tag should be exactly 4 ASCII characters."),[e.charCodeAt(0),e.charCodeAt(1),e.charCodeAt(2),e.charCodeAt(3)]},A.TAG=F(4),P.Card8=P.BYTE,A.Card8=A.BYTE,P.Card16=P.USHORT,A.Card16=A.USHORT,P.OffSize=P.BYTE,A.OffSize=A.BYTE,P.SID=P.USHORT,A.SID=A.USHORT,P.NUMBER=function(e){return e>=-107&&e<=107?[e+139]:e>=108&&e<=1131?[247+((e-=108)>>8),255&e]:e>=-1131&&e<=-108?[251+((e=-e-108)>>8),255&e]:e>=-32768&&e<=32767?P.NUMBER16(e):P.NUMBER32(e)},A.NUMBER=function(e){return P.NUMBER(e).length},P.NUMBER16=function(e){return[28,e>>8&255,255&e]},A.NUMBER16=F(3),P.NUMBER32=function(e){return[29,e>>24&255,e>>16&255,e>>8&255,255&e]},A.NUMBER32=F(5),P.REAL=function(e){let t=e.toString();const n=/\.(\d*?)(?:9{5,20}|0{5,20})\d{0,2}(?:e(.+)|$)/.exec(t);if(n){const o=parseFloat("1e"+((n[2]?+n[2]:0)+n[1].length));t=(Math.round(e*o)/o).toString()}let o="";for(let e=0,n=t.length;e>8&255,t[t.length]=255&o}return t},A.UTF16=function(e){return 2*e.length};const H={"x-mac-croatian":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®Š™´¨≠ŽØ∞±≤≥∆µ∂∑∏š∫ªºΩžø¿¡¬√ƒ≈Ć«Č… ÀÃÕŒœĐ—“”‘’÷◊©⁄€‹›Æ»–·‚„‰ÂćÁčÈÍÎÏÌÓÔđÒÚÛÙıˆ˜¯πË˚¸Êæˇ","x-mac-cyrillic":"АБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯ†°Ґ£§•¶І®©™Ђђ≠Ѓѓ∞±≤≥іµґЈЄєЇїЉљЊњјЅ¬√ƒ≈∆«»… ЋћЌќѕ–—“”‘’÷„ЎўЏџ№Ёёяабвгдежзийклмнопрстуфхцчшщъыьэю","x-mac-gaelic":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®©™´¨≠ÆØḂ±≤≥ḃĊċḊḋḞḟĠġṀæøṁṖṗɼƒſṠ«»… ÀÃÕŒœ–—“”‘’ṡẛÿŸṪ€‹›Ŷŷṫ·Ỳỳ⁊ÂÊÁËÈÍÎÏÌÓÔ♣ÒÚÛÙıÝýŴŵẄẅẀẁẂẃ","x-mac-greek":"Ĺ²É³ÖÜ΅àâä΄¨çéèê룙î‰ôö¦€ùûü†ΓΔΘΛΞΠß®©ΣΪ§≠°·Α±≤≥¥ΒΕΖΗΙΚΜΦΫΨΩάΝ¬ΟΡ≈Τ«»… ΥΧΆΈœ–―“”‘’÷ΉΊΌΎέήίόΏύαβψδεφγηιξκλμνοπώρστθωςχυζϊϋΐΰ­","x-mac-icelandic":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûüÝ°¢£§•¶ß®©™´¨≠ÆØ∞±≤≥¥µ∂∑∏π∫ªºΩæø¿¡¬√ƒ≈∆«»… ÀÃÕŒœ–—“”‘’÷◊ÿŸ⁄€ÐðÞþý·‚„‰ÂÊÁËÈÍÎÏÌÓÔÒÚÛÙıˆ˜¯˘˙˚¸˝˛ˇ","x-mac-inuit":"ᐃᐄᐅᐆᐊᐋᐱᐲᐳᐴᐸᐹᑉᑎᑏᑐᑑᑕᑖᑦᑭᑮᑯᑰᑲᑳᒃᒋᒌᒍᒎᒐᒑ°ᒡᒥᒦ•¶ᒧ®©™ᒨᒪᒫᒻᓂᓃᓄᓅᓇᓈᓐᓯᓰᓱᓲᓴᓵᔅᓕᓖᓗᓘᓚᓛᓪᔨᔩᔪᔫᔭ… ᔮᔾᕕᕖᕗ–—“”‘’ᕘᕙᕚᕝᕆᕇᕈᕉᕋᕌᕐᕿᖀᖁᖂᖃᖄᖅᖏᖐᖑᖒᖓᖔᖕᙱᙲᙳᙴᙵᙶᖖᖠᖡᖢᖣᖤᖥᖦᕼŁł","x-mac-ce":"ÄĀāÉĄÖÜáąČäčĆć鏟ĎíďĒēĖóėôöõúĚěü†°Ę£§•¶ß®©™ę¨≠ģĮįĪ≤≥īĶ∂∑łĻļĽľĹĺŅņѬ√ńŇ∆«»… ňŐÕőŌ–—“”‘’÷◊ōŔŕŘ‹›řŖŗŠ‚„šŚśÁŤťÍŽžŪÓÔūŮÚůŰűŲųÝýķŻŁżĢˇ",macintosh:"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®©™´¨≠ÆØ∞±≤≥¥µ∂∑∏π∫ªºΩæø¿¡¬√ƒ≈∆«»… ÀÃÕŒœ–—“”‘’÷◊ÿŸ⁄€‹›fifl‡·‚„‰ÂÊÁËÈÍÎÏÌÓÔÒÚÛÙıˆ˜¯˘˙˚¸˝˛ˇ","x-mac-romanian":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®©™´¨≠ĂȘ∞±≤≥¥µ∂∑∏π∫ªºΩăș¿¡¬√ƒ≈∆«»… ÀÃÕŒœ–—“”‘’÷◊ÿŸ⁄€‹›Țț‡·‚„‰ÂÊÁËÈÍÎÏÌÓÔÒÚÛÙıˆ˜¯˘˙˚¸˝˛ˇ","x-mac-turkish":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®©™´¨≠ÆØ∞±≤≥¥µ∂∑∏π∫ªºΩæø¿¡¬√ƒ≈∆«»… ÀÃÕŒœ–—“”‘’÷◊ÿŸĞğİıŞş‡·‚„‰ÂÊÁËÈÍÎÏÌÓÔÒÚÛÙˆ˜¯˘˙˚¸˝˛ˇ"};N.MACSTRING=function(e,t,n,o){const s=H[o];if(void 0===s)return;let r="";for(let o=0;o=-128&&e<=127}function q(e,t,n){let o=0;const s=e.length;for(;t>8&255,t+256&255)}return r}P.MACSTRING=function(e,t){const n=function(e){if(!W){W={};for(let e in H)W[e]=new String(e)}const t=W[e];if(void 0===t)return;if(z){const e=z.get(t);if(void 0!==e)return e}const n=H[e];if(void 0===n)return;const o={};for(let e=0;e=128&&(s=n[s],void 0===s))return;o[t]=s}return o},A.MACSTRING=function(e,t){const n=P.MACSTRING(e,t);return void 0!==n?n.length:0},P.VARDELTAS=function(e){let t=0;const n=[];for(;t=-128&&o<=127?X(e,t,n):V(e,t,n)}return n},P.INDEX=function(e){let t=1;const n=[t],o=[];for(let s=0;s>8,t[r+1]=255&a,t=t.concat(o[n])}return t},A.TABLE=function(e){let t=0;const n=e.fields.length;for(let o=0;o0)return new le(this.data,this.offset+t).parseStruct(e)},le.prototype.parseListOfLists=function(e){const t=this.parseOffset16List(),n=t.length,o=this.relativeOffset,s=new Array(n);for(let o=0;o=0;s-=1){const n=ue.getUShort(e,t+4+8*s),r=ue.getUShort(e,t+4+8*s+2);if(3===n&&(0===r||1===r||10===r)){o=ue.getULong(e,t+4+8*s+4);break}}if(-1===o)throw new Error("No valid cmap sub-tables found.");const s=new ue.Parser(e,t+o);if(n.format=s.parseUShort(),12===n.format)!function(e,t){let n;t.parseUShort(),e.length=t.parseULong(),e.language=t.parseULong(),e.groupCount=n=t.parseULong(),e.glyphIndexMap={};for(let o=0;o>1,t.skip("uShort",3),e.glyphIndexMap={};const a=new ue.Parser(n,o+s+14),i=new ue.Parser(n,o+s+16+2*r),l=new ue.Parser(n,o+s+16+4*r),c=new ue.Parser(n,o+s+16+6*r);let u=o+s+16+8*r;for(let t=0;t0?(r=e.parseByte(),0==(t&s)&&(r=-r),r=n+r):r=(t&s)>0?n:n+e.parseShort(),r}function Te(e,t,n){const o=new ue.Parser(t,n);let s,r;if(e.numberOfContours=o.parseShort(),e._xMin=o.parseShort(),e._yMin=o.parseShort(),e._xMax=o.parseShort(),e._yMax=o.parseShort(),e.numberOfContours>0){const t=e.endPointIndices=[];for(let n=0;n0){const t=o.parseByte();for(let n=0;n0){const a=[];let i;if(n>0){for(let e=0;e=0,a.push(i);let e=0;for(let t=0;t0?(2&s)>0?(n.dx=o.parseShort(),n.dy=o.parseShort()):n.matchedPoints=[o.parseUShort(),o.parseUShort()]:(2&s)>0?(n.dx=o.parseChar(),n.dy=o.parseChar()):n.matchedPoints=[o.parseByte(),o.parseByte()],(8&s)>0?n.xScale=n.yScale=o.parseF2Dot14():(64&s)>0?(n.xScale=o.parseF2Dot14(),n.yScale=o.parseF2Dot14()):(128&s)>0&&(n.xScale=o.parseF2Dot14(),n.scale01=o.parseF2Dot14(),n.scale10=o.parseF2Dot14(),n.yScale=o.parseF2Dot14()),e.components.push(n),t=!!(32&s)}if(256&s){e.instructionLength=o.parseUShort(),e.instructions=[];for(let t=0;tt.points.length-1||o.matchedPoints[1]>s.points.length-1)throw Error("Matched points out of range in "+t.name);const n=t.points[o.matchedPoints[0]];let r=s.points[o.matchedPoints[1]];const a={xScale:o.xScale,scale01:o.scale01,scale10:o.scale10,yScale:o.yScale,dx:0,dy:0};r=Ee([r],a)[0],a.dx=n.x-r.x,a.dy=n.y-r.y,e=Ee(s.points,a)}t.points=t.points.concat(e)}}return Oe(t.points)}var ke={getPath:Oe,parse:function(e,t,n,o){const s=new Le.GlyphSet(o);for(let r=0;r>4,r=15&o;if(15===s)break;if(t+=n[s],15===r)break;t+=n[r]}return parseFloat(t)}(e);if(t>=32&&t<=246)return t-139;if(t>=247&&t<=250)return n=e.parseByte(),256*(t-247)+n+108;if(t>=251&&t<=254)return n=e.parseByte(),256*-(t-251)-n-108;throw new Error("Invalid b0 "+t)}function Ne(e,t,n){t=void 0!==t?t:0;const o=new ue.Parser(e,t),s=[];let r=[];for(n=void 0!==n?n:e.length;o.relativeOffset>1,l.length=0,d=!0}return function n(p){let x,U,T,E,O,w,k,R,D,C,L,I,M=0;for(;M1&&!d&&(v=l.shift()+h,d=!0),y+=l.pop(),b(m,y);break;case 5:for(;l.length>0;)m+=l.shift(),y+=l.shift(),i.lineTo(m,y);break;case 6:for(;l.length>0&&(m+=l.shift(),i.lineTo(m,y),0!==l.length);)y+=l.shift(),i.lineTo(m,y);break;case 7:for(;l.length>0&&(y+=l.shift(),i.lineTo(m,y),0!==l.length);)m+=l.shift(),i.lineTo(m,y);break;case 8:for(;l.length>0;)o=m+l.shift(),s=y+l.shift(),r=o+l.shift(),a=s+l.shift(),m=r+l.shift(),y=a+l.shift(),i.curveTo(o,s,r,a,m,y);break;case 10:O=l.pop()+u,w=c[O],w&&n(w);break;case 11:return;case 12:switch(B=p[M],M+=1,B){case 35:o=m+l.shift(),s=y+l.shift(),r=o+l.shift(),a=s+l.shift(),k=r+l.shift(),R=a+l.shift(),D=k+l.shift(),C=R+l.shift(),L=D+l.shift(),I=C+l.shift(),m=L+l.shift(),y=I+l.shift(),l.shift(),i.curveTo(o,s,r,a,k,R),i.curveTo(D,C,L,I,m,y);break;case 34:o=m+l.shift(),s=y,r=o+l.shift(),a=s+l.shift(),k=r+l.shift(),R=a,D=k+l.shift(),C=a,L=D+l.shift(),I=y,m=L+l.shift(),i.curveTo(o,s,r,a,k,R),i.curveTo(D,C,L,I,m,y);break;case 36:o=m+l.shift(),s=y+l.shift(),r=o+l.shift(),a=s+l.shift(),k=r+l.shift(),R=a,D=k+l.shift(),C=a,L=D+l.shift(),I=C+l.shift(),m=L+l.shift(),i.curveTo(o,s,r,a,k,R),i.curveTo(D,C,L,I,m,y);break;case 37:o=m+l.shift(),s=y+l.shift(),r=o+l.shift(),a=s+l.shift(),k=r+l.shift(),R=a+l.shift(),D=k+l.shift(),C=R+l.shift(),L=D+l.shift(),I=C+l.shift(),Math.abs(L-m)>Math.abs(I-y)?m=L+l.shift():y=I+l.shift(),i.curveTo(o,s,r,a,k,R),i.curveTo(D,C,L,I,m,y);break;default:console.log("Glyph "+t.index+": unknown operator 1200"+B),l.length=0}break;case 14:l.length>0&&!d&&(v=l.shift()+h,d=!0),g&&(i.closePath(),g=!1);break;case 18:S();break;case 19:case 20:S(),M+=f+7>>3;break;case 21:l.length>2&&!d&&(v=l.shift()+h,d=!0),y+=l.pop(),m+=l.pop(),b(m,y);break;case 22:l.length>1&&!d&&(v=l.shift()+h,d=!0),m+=l.pop(),b(m,y);break;case 23:S();break;case 24:for(;l.length>2;)o=m+l.shift(),s=y+l.shift(),r=o+l.shift(),a=s+l.shift(),m=r+l.shift(),y=a+l.shift(),i.curveTo(o,s,r,a,m,y);m+=l.shift(),y+=l.shift(),i.lineTo(m,y);break;case 25:for(;l.length>6;)m+=l.shift(),y+=l.shift(),i.lineTo(m,y);o=m+l.shift(),s=y+l.shift(),r=o+l.shift(),a=s+l.shift(),m=r+l.shift(),y=a+l.shift(),i.curveTo(o,s,r,a,m,y);break;case 26:for(l.length%2&&(m+=l.shift());l.length>0;)o=m,s=y+l.shift(),r=o+l.shift(),a=s+l.shift(),m=r,y=a+l.shift(),i.curveTo(o,s,r,a,m,y);break;case 27:for(l.length%2&&(y+=l.shift());l.length>0;)o=m+l.shift(),s=y,r=o+l.shift(),a=s+l.shift(),m=r+l.shift(),y=a,i.curveTo(o,s,r,a,m,y);break;case 28:x=p[M],U=p[M+1],l.push((x<<24|U<<16)>>16),M+=2;break;case 29:O=l.pop()+e.gsubrsBias,w=e.gsubrs[O],w&&n(w);break;case 30:for(;l.length>0&&(o=m,s=y+l.shift(),r=o+l.shift(),a=s+l.shift(),m=r+l.shift(),y=a+(1===l.length?l.shift():0),i.curveTo(o,s,r,a,m,y),0!==l.length);)o=m+l.shift(),s=y,r=o+l.shift(),a=s+l.shift(),y=a+l.shift(),m=r+(1===l.length?l.shift():0),i.curveTo(o,s,r,a,m,y);break;case 31:for(;l.length>0&&(o=m+l.shift(),s=y,r=o+l.shift(),a=s+l.shift(),y=a+l.shift(),m=r+(1===l.length?l.shift():0),i.curveTo(o,s,r,a,m,y),0!==l.length);)o=m,s=y+l.shift(),r=o+l.shift(),a=s+l.shift(),m=r+l.shift(),y=a+(1===l.length?l.shift():0),i.curveTo(o,s,r,a,m,y);break;default:B<32?console.log("Glyph "+t.index+": unknown operator "+B):B<247?l.push(B-139):B<251?(x=p[M],M+=1,l.push(256*(B-247)+x+108)):B<255?(x=p[M],M+=1,l.push(256*-(B-251)-x-108)):(x=p[M],U=p[M+1],T=p[M+2],E=p[M+3],M+=4,l.push((x<<24|U<<16|T<<8|E)/65536))}}}(n),t.advanceWidth=v,i}function Xe(e,t){let n,o=fe.indexOf(e);return o>=0&&(n=o),o=t.indexOf(e),o>=0?n=o+fe.length:(n=fe.length+t.length,t.push(e)),n}function Ve(e,t,n){const o={};for(let s=0;s=o)throw new Error("CFF table CID Font FDSelect has bad FD index value "+r+" (FD count "+o+")");s.push(r)}else{if(3!==i)throw new Error("CFF Table CID Font FDSelect table has unsupported format "+i);{const e=a.parseCard16();let t,i=a.parseCard16();if(0!==i)throw new Error("CFF Table CID Font FDSelect format 3 range has bad initial GID "+i);for(let l=0;l=o)throw new Error("CFF table CID Font FDSelect has bad FD index value "+r+" (FD count "+o+")");if(t>n)throw new Error("CFF Table CID Font FDSelect format 3 range has bad GID "+t);for(;i=1&&(n.ulCodePageRange1=o.parseULong(),n.ulCodePageRange2=o.parseULong()),n.version>=2&&(n.sxHeight=o.parseShort(),n.sCapHeight=o.parseShort(),n.usDefaultChar=o.parseUShort(),n.usBreakChar=o.parseUShort(),n.usMaxContent=o.parseUShort()),n},make:function(e){return new ne.Table("OS/2",[{name:"version",type:"USHORT",value:3},{name:"xAvgCharWidth",type:"SHORT",value:0},{name:"usWeightClass",type:"USHORT",value:0},{name:"usWidthClass",type:"USHORT",value:0},{name:"fsType",type:"USHORT",value:0},{name:"ySubscriptXSize",type:"SHORT",value:650},{name:"ySubscriptYSize",type:"SHORT",value:699},{name:"ySubscriptXOffset",type:"SHORT",value:0},{name:"ySubscriptYOffset",type:"SHORT",value:140},{name:"ySuperscriptXSize",type:"SHORT",value:650},{name:"ySuperscriptYSize",type:"SHORT",value:699},{name:"ySuperscriptXOffset",type:"SHORT",value:0},{name:"ySuperscriptYOffset",type:"SHORT",value:479},{name:"yStrikeoutSize",type:"SHORT",value:49},{name:"yStrikeoutPosition",type:"SHORT",value:258},{name:"sFamilyClass",type:"SHORT",value:0},{name:"bFamilyType",type:"BYTE",value:0},{name:"bSerifStyle",type:"BYTE",value:0},{name:"bWeight",type:"BYTE",value:0},{name:"bProportion",type:"BYTE",value:0},{name:"bContrast",type:"BYTE",value:0},{name:"bStrokeVariation",type:"BYTE",value:0},{name:"bArmStyle",type:"BYTE",value:0},{name:"bLetterform",type:"BYTE",value:0},{name:"bMidline",type:"BYTE",value:0},{name:"bXHeight",type:"BYTE",value:0},{name:"ulUnicodeRange1",type:"ULONG",value:0},{name:"ulUnicodeRange2",type:"ULONG",value:0},{name:"ulUnicodeRange3",type:"ULONG",value:0},{name:"ulUnicodeRange4",type:"ULONG",value:0},{name:"achVendID",type:"CHARARRAY",value:"XXXX"},{name:"fsSelection",type:"USHORT",value:0},{name:"usFirstCharIndex",type:"USHORT",value:0},{name:"usLastCharIndex",type:"USHORT",value:0},{name:"sTypoAscender",type:"SHORT",value:0},{name:"sTypoDescender",type:"SHORT",value:0},{name:"sTypoLineGap",type:"SHORT",value:0},{name:"usWinAscent",type:"USHORT",value:0},{name:"usWinDescent",type:"USHORT",value:0},{name:"ulCodePageRange1",type:"ULONG",value:0},{name:"ulCodePageRange2",type:"ULONG",value:0},{name:"sxHeight",type:"SHORT",value:0},{name:"sCapHeight",type:"SHORT",value:0},{name:"usDefaultChar",type:"USHORT",value:0},{name:"usBreakChar",type:"USHORT",value:0},{name:"usMaxContext",type:"USHORT",value:0}],e)},unicodeRanges:dt,getUnicodeRange:function(e){for(let t=0;t=n.begin&&e=me.length){const e=o.parseChar();n.names.push(o.parseString(e))}break;case 2.5:n.numberOfGlyphs=o.parseUShort(),n.offset=new Array(n.numberOfGlyphs);for(let e=0;et.value.tag?1:-1})),t.fields=t.fields.concat(o),t.fields=t.fields.concat(s),t}function wt(e,t,n){for(let n=0;n0){return e.glyphs.get(o).getMetrics()}}return n}function kt(e){let t=0;for(let n=0;nm||void 0===l)&&m>0&&(l=m),c 123 are reserved for internal usage");f|=1<0?et.make(w):void 0,D=mt.make(),C=Qe.make(e.glyphs,{version:e.getEnglishName("version"),fullName:T,familyName:x,weightName:U,postScriptName:E,unitsPerEm:e.unitsPerEm,fontBBox:[0,d.yMin,d.ascender,d.advanceWidthMax]}),L=e.metas&&Object.keys(e.metas).length>0?xt.make(e.metas):void 0,I=[g,m,y,v,k,S,D,C,b];R&&I.push(R),e.tables.gsub&&I.push(St.make(e.tables.gsub)),L&&I.push(L);const M=Ot(I),B=Tt(M.encode()),G=M.fields;let N=!1;for(let e=0;e>>1,r=e[s].tag;if(r===t)return s;r>>1,r=e[s];if(r===t)return s;r=0)return o[s].script;if(t){const t={tag:e,script:{defaultLangSys:{reserved:0,reqFeatureIndex:65535,featureIndexes:[]},langSysRecords:[]}};return o.splice(-1-s,0,t),t.script}}},getLangSysTable:function(e,t,n){const o=this.getScriptTable(e,n);if(o){if(!t||"dflt"===t||"DFLT"===t)return o.defaultLangSys;const e=Dt(o.langSysRecords,t);if(e>=0)return o.langSysRecords[e].langSys;if(n){const n={tag:t,langSys:{reserved:0,reqFeatureIndex:65535,featureIndexes:[]}};return o.langSysRecords.splice(-1-e,0,n),n.langSys}}},getFeatureTable:function(e,t,n,o){const s=this.getLangSysTable(e,t,o);if(s){let e;const t=s.featureIndexes,r=this.font.tables[this.tableName].features;for(let o=0;o=r[o-1].tag,"Features must be added in alphabetical order."),e={tag:n,feature:{params:0,lookupListIndexes:[]}},r.push(e),t.push(o),e.feature}}},getLookupTables:function(e,t,n,o,s){const r=this.getFeatureTable(e,t,n,s),a=[];if(r){let e;const t=r.lookupListIndexes,n=this.font.tables[this.tableName].lookups;for(let s=0;s=0){const e=r.ligatureSets[c];for(let t=0;t0&&e<0?n:o<0&&e>0?-n:e*o},Yt={x:1,y:0,axis:"x",distance:function(e,t,n,o){return(n?e.xo:e.x)-(o?t.xo:t.x)},interpolate:function(e,t,n,o){let s,r,a,i,l,c,u;if(!o||o===this)return s=e.xo-t.xo,r=e.xo-n.xo,l=t.x-t.xo,c=n.x-n.xo,a=Math.abs(s),i=Math.abs(r),u=a+i,0===u?void(e.x=e.xo+(l+c)/2):void(e.x=e.xo+(l*i+c*a)/u);s=o.distance(e,t,!0,!0),r=o.distance(e,n,!0,!0),l=o.distance(t,t,!1,!0),c=o.distance(n,n,!1,!0),a=Math.abs(s),i=Math.abs(r),u=a+i,0!==u?Yt.setRelative(e,e,(l*i+c*a)/u,o,!0):Yt.setRelative(e,e,(l+c)/2,o,!0)},normalSlope:Number.NEGATIVE_INFINITY,setRelative:function(e,t,n,o,s){if(!o||o===this)return void(e.x=(s?t.xo:t.x)+n);const r=s?t.xo:t.x,a=s?t.yo:t.y,i=r+n*o.x,l=a+n*o.y;e.x=i+(e.y-l)/o.normalSlope},slope:0,touch:function(e){e.xTouched=!0},touched:function(e){return e.xTouched},untouch:function(e){e.xTouched=!1}},Zt={x:0,y:1,axis:"y",distance:function(e,t,n,o){return(n?e.yo:e.y)-(o?t.yo:t.y)},interpolate:function(e,t,n,o){let s,r,a,i,l,c,u;if(!o||o===this)return s=e.yo-t.yo,r=e.yo-n.yo,l=t.y-t.yo,c=n.y-n.yo,a=Math.abs(s),i=Math.abs(r),u=a+i,0===u?void(e.y=e.yo+(l+c)/2):void(e.y=e.yo+(l*i+c*a)/u);s=o.distance(e,t,!0,!0),r=o.distance(e,n,!0,!0),l=o.distance(t,t,!1,!0),c=o.distance(n,n,!1,!0),a=Math.abs(s),i=Math.abs(r),u=a+i,0!==u?Zt.setRelative(e,e,(l*i+c*a)/u,o,!0):Zt.setRelative(e,e,(l+c)/2,o,!0)},normalSlope:0,setRelative:function(e,t,n,o,s){if(!o||o===this)return void(e.y=(s?t.yo:t.y)+n);const r=s?t.xo:t.x,a=s?t.yo:t.y,i=r+n*o.x,l=a+n*o.y;e.y=l+o.normalSlope*(e.x-i)},slope:Number.POSITIVE_INFINITY,touch:function(e){e.yTouched=!0},touched:function(e){return e.yTouched},untouch:function(e){e.yTouched=!1}};function Qt(e,t){this.x=e,this.y=t,this.axis=void 0,this.slope=t/e,this.normalSlope=-e/t,Object.freeze(this)}function $t(e,t){const n=Math.sqrt(e*e+t*t);return t/=n,1===(e/=n)&&0===t?Yt:0===e&&1===t?Zt:new Qt(e,t)}function Kt(e,t,n,o){this.x=this.xo=Math.round(64*e)/64,this.y=this.yo=Math.round(64*t)/64,this.lastPointOfContour=n,this.onCurve=o,this.prevPointOnContour=void 0,this.nextPointOnContour=void 0,this.xTouched=!1,this.yTouched=!1,Object.preventExtensions(this)}Object.freeze(Yt),Object.freeze(Zt),Qt.prototype.distance=function(e,t,n,o){return this.x*Yt.distance(e,t,n,o)+this.y*Zt.distance(e,t,n,o)},Qt.prototype.interpolate=function(e,t,n,o){let s,r,a,i,l,c,u;a=o.distance(e,t,!0,!0),i=o.distance(e,n,!0,!0),s=o.distance(t,t,!1,!0),r=o.distance(n,n,!1,!0),l=Math.abs(a),c=Math.abs(i),u=l+c,0!==u?this.setRelative(e,e,(s*c+r*l)/u,o,!0):this.setRelative(e,e,(s+r)/2,o,!0)},Qt.prototype.setRelative=function(e,t,n,o,s){o=o||this;const r=s?t.xo:t.x,a=s?t.yo:t.y,i=r+n*o.x,l=a+n*o.y,c=o.normalSlope,u=this.slope,p=e.x,h=e.y;e.x=(u*p-c*i+l-h)/(u-c),e.y=u*(e.x-p)+h},Qt.prototype.touch=function(e){e.xTouched=!0,e.yTouched=!0},Kt.prototype.nextTouched=function(e){let t=this.nextPointOnContour;for(;!e.touched(t)&&t!==this;)t=t.nextPointOnContour;return t},Kt.prototype.prevTouched=function(e){let t=this.prevPointOnContour;for(;!e.touched(t)&&t!==this;)t=t.prevPointOnContour;return t};const Jt=Object.freeze(new Kt(0,0)),en={cvCutIn:17/16,deltaBase:9,deltaShift:.125,loop:1,minDis:1,autoFlip:!0};function tn(e,t){switch(this.env=e,this.stack=[],this.prog=t,e){case"glyf":this.zp0=this.zp1=this.zp2=1,this.rp0=this.rp1=this.rp2=0;case"prep":this.fv=this.pv=this.dpv=Yt,this.round=Wt}}function nn(e){const t=e.tZone=new Array(e.gZone.length);for(let e=0;e=176&&o<=183)s+=o-176+1;else if(o>=184&&o<=191)s+=2*(o-184+1);else if(t&&1===r&&27===o)break}while(r>0);e.ip=s}function sn(e,t){exports.DEBUG&&console.log(t.step,"SVTCA["+e.axis+"]"),t.fv=t.pv=t.dpv=e}function rn(e,t){exports.DEBUG&&console.log(t.step,"SPVTCA["+e.axis+"]"),t.pv=t.dpv=e}function an(e,t){exports.DEBUG&&console.log(t.step,"SFVTCA["+e.axis+"]"),t.fv=e}function ln(e,t){const n=t.stack,o=n.pop(),s=n.pop(),r=t.z2[o],a=t.z1[s];let i,l;exports.DEBUG&&console.log("SPVTL["+e+"]",o,s),e?(i=r.y-a.y,l=a.x-r.x):(i=a.x-r.x,l=a.y-r.y),t.pv=t.dpv=$t(i,l)}function cn(e,t){const n=t.stack,o=n.pop(),s=n.pop(),r=t.z2[o],a=t.z1[s];let i,l;exports.DEBUG&&console.log("SFVTL["+e+"]",o,s),e?(i=r.y-a.y,l=a.x-r.x):(i=a.x-r.x,l=a.y-r.y),t.fv=$t(i,l)}function un(e){exports.DEBUG&&console.log(e.step,"POP[]"),e.stack.pop()}function pn(e,t){const n=t.stack.pop(),o=t.z0[n],s=t.fv,r=t.pv;exports.DEBUG&&console.log(t.step,"MDAP["+e+"]",n);let a=r.distance(o,Jt);e&&(a=t.round(a)),s.setRelative(o,Jt,a,r),s.touch(o),t.rp0=t.rp1=n}function hn(e,t){const n=t.z2,o=n.length-2;let s,r,a;exports.DEBUG&&console.log(t.step,"IUP["+e.axis+"]");for(let t=0;t1?"loop "+(t.loop-i)+": ":"")+"SHP["+(e?"rp1":"rp2")+"]",o)}t.loop=1}function dn(e,t){const n=t.stack,o=e?t.rp1:t.rp2,s=(e?t.z0:t.z1)[o],r=t.fv,a=t.pv,i=n.pop(),l=t.z2[t.contours[i]];let c=l;exports.DEBUG&&console.log(t.step,"SHC["+e+"]",i);const u=a.distance(s,s,!1,!0);do{c!==s&&r.setRelative(c,c,u,a),c=c.nextPointOnContour}while(c!==l)}function gn(e,t){const n=t.stack,o=e?t.rp1:t.rp2,s=(e?t.z0:t.z1)[o],r=t.fv,a=t.pv,i=n.pop();let l,c;switch(exports.DEBUG&&console.log(t.step,"SHZ["+e+"]",i),i){case 0:l=t.tZone;break;case 1:l=t.gZone;break;default:throw new Error("Invalid zone")}const u=a.distance(s,s,!1,!0),p=l.length-2;for(let e=0;e",i),t.stack.push(Math.round(64*i))}function Sn(e,t){const n=t.stack,o=n.pop(),s=t.fv,r=t.pv,a=t.ppem,i=t.deltaBase+16*(e-1),l=t.deltaShift,c=t.z0;exports.DEBUG&&console.log(t.step,"DELTAP["+e+"]",o,n);for(let e=0;e>4)!==a)continue;let u=(15&o)-8;u>=0&&u++,exports.DEBUG&&console.log(t.step,"DELTAPFIX",e,"by",u*l);const p=c[e];s.setRelative(p,p,u*l,r)}}function xn(e,t){const n=t.stack,o=n.pop();exports.DEBUG&&console.log(t.step,"ROUND[]"),n.push(64*t.round(o/64))}function Un(e,t){const n=t.stack,o=n.pop(),s=t.ppem,r=t.deltaBase+16*(e-1),a=t.deltaShift;exports.DEBUG&&console.log(t.step,"DELTAC["+e+"]",o,n);for(let e=0;e>4)!==s)continue;let i=(15&o)-8;i>=0&&i++;const l=i*a;exports.DEBUG&&console.log(t.step,"DELTACFIX",e,"by",l),t.cvt[e]+=l}}function Tn(e,t){const n=t.stack,o=n.pop(),s=n.pop(),r=t.z2[o],a=t.z1[s];let i,l;exports.DEBUG&&console.log("SDPVTL["+e+"]",o,s),e?(i=r.y-a.y,l=a.x-r.x):(i=a.x-r.x,l=a.y-r.y),t.dpv=$t(i,l)}function En(e,t){const n=t.stack,o=t.prog;let s=t.ip;exports.DEBUG&&console.log(t.step,"PUSHB["+e+"]");for(let t=0;t=0?1:-1,m=Math.abs(m),e&&(v=r.cvt[i],o&&Math.abs(m-v)":"_")+(o?"R":"_")+(0===s?"Gr":1===s?"Bl":2===s?"Wh":"")+"]",e?i+"("+r.cvt[i]+","+v+")":"",l,"(d =",g,"->",y*m,")"),r.rp1=r.rp0,r.rp2=l,t&&(r.rp0=l)}function kn(e){(e=e||{}).empty||(Gt(e.familyName,"When creating a new Font object, familyName is required."),Gt(e.styleName,"When creating a new Font object, styleName is required."),Gt(e.unitsPerEm,"When creating a new Font object, unitsPerEm is required."),Gt(e.ascender,"When creating a new Font object, ascender is required."),Gt(e.descender,"When creating a new Font object, descender is required."),Gt(e.descender<0,"Descender should be negative (e.g. -512)."),this.names={fontFamily:{en:e.familyName||" "},fontSubfamily:{en:e.styleName||" "},fullName:{en:e.fullName||e.familyName+" "+e.styleName},postScriptName:{en:e.postScriptName||e.familyName+e.styleName},designer:{en:e.designer||" "},designerURL:{en:e.designerURL||" "},manufacturer:{en:e.manufacturer||" "},manufacturerURL:{en:e.manufacturerURL||" "},license:{en:e.license||" "},licenseURL:{en:e.licenseURL||" "},version:{en:e.version||"Version 0.1"},description:{en:e.description||" "},copyright:{en:e.copyright||" "},trademark:{en:e.trademark||" "}},this.unitsPerEm=e.unitsPerEm||1e3,this.ascender=e.ascender,this.descender=e.descender,this.createdTimestamp=e.createdTimestamp,this.tables={os2:{usWeightClass:e.weightClass||this.usWeightClasses.MEDIUM,usWidthClass:e.widthClass||this.usWidthClasses.MEDIUM,fsSelection:e.fsSelection||this.fsSelectionValues.REGULAR}}),this.supported=!0,this.glyphs=new Le.GlyphSet(this,e.glyphs||[]),this.encoding=new ye(this),this.substitution=new Lt(this),this.tables=this.tables||{},Object.defineProperty(this,"hinting",{get:function(){return this._hinting?this._hinting:"truetype"===this.outlinesFormat?this._hinting=new Ht(this):void 0}})}function Rn(e,t){const n=JSON.stringify(e);let o=256;for(let e in t){let s=parseInt(e);if(s&&!(s<256)){if(JSON.stringify(t[e])===n)return s;o<=s&&(o=s+1)}}return t[o]=e,o}function Dn(e,t,n){const o=Rn(t.name,n);return[{name:"tag_"+e,type:"TAG",value:t.tag},{name:"minValue_"+e,type:"FIXED",value:t.minValue<<16},{name:"defaultValue_"+e,type:"FIXED",value:t.defaultValue<<16},{name:"maxValue_"+e,type:"FIXED",value:t.maxValue<<16},{name:"flags_"+e,type:"USHORT",value:0},{name:"nameID_"+e,type:"USHORT",value:o}]}function Cn(e,t,n){const o={},s=new ue.Parser(e,t);return o.tag=s.parseTag(),o.minValue=s.parseFixed(),o.defaultValue=s.parseFixed(),o.maxValue=s.parseFixed(),s.skip("uShort",1),o.name=n[s.parseUShort()]||{},o}function Ln(e,t,n,o){const s=[{name:"nameID_"+e,type:"USHORT",value:Rn(t.name,o)},{name:"flags_"+e,type:"USHORT",value:0}];for(let o=0;o2)return;const n=this.font;let o=this._prepState;if(!o||o.ppem!==t){let e=this._fpgmState;if(!e){tn.prototype=en,e=this._fpgmState=new tn("fpgm",n.tables.fpgm),e.funcs=[],e.font=n,exports.DEBUG&&(console.log("---EXEC FPGM---"),e.step=-1);try{Pt(e)}catch(e){return console.log("Hinting error in FPGM:"+e),void(this._errorState=3)}}tn.prototype=e,o=this._prepState=new tn("prep",n.tables.prep),o.ppem=t;const s=n.tables.cvt;if(s){const e=o.cvt=new Array(s.length),r=t/n.unitsPerEm;for(let t=0;t1))try{return At(e,o)}catch(e){return this._errorState<1&&(console.log("Hinting error:"+e),console.log("Note: further hinting errors are silenced")),void(this._errorState=1)}},At=function(e,t){const n=t.ppem/t.font.unitsPerEm,o=n;let s,r,a,i=e.components;if(tn.prototype=t,i){const l=t.font;r=[],s=[];for(let e=0;e1?"loop "+(e.loop-n)+": ":"")+"SHPIX[]",a,s),o.setRelative(i,i,s),o.touch(i)}e.loop=1},function(e){const t=e.stack,n=e.rp1,o=e.rp2;let s=e.loop;const r=e.z0[n],a=e.z1[o],i=e.fv,l=e.dpv,c=e.z2;for(;s--;){const u=t.pop(),p=c[u];exports.DEBUG&&console.log(e.step,(e.loop>1?"loop "+(e.loop-s)+": ":"")+"IP[]",u,n,"<->",o),i.interpolate(p,r,a,l),i.touch(p)}e.loop=1},mn.bind(void 0,0),mn.bind(void 0,1),function(e){const t=e.stack,n=e.rp0,o=e.z0[n];let s=e.loop;const r=e.fv,a=e.pv,i=e.z1;for(;s--;){const n=t.pop(),l=i[n];exports.DEBUG&&console.log(e.step,(e.loop>1?"loop "+(e.loop-s)+": ":"")+"ALIGNRP[]",n),r.setRelative(l,o,0,a),r.touch(l)}e.loop=1},function(e){exports.DEBUG&&console.log(e.step,"RTDG[]"),e.round=_t},yn.bind(void 0,0),yn.bind(void 0,1),function(e){const t=e.prog;let n=e.ip;const o=e.stack,s=t[++n];exports.DEBUG&&console.log(e.step,"NPUSHB[]",s);for(let e=0;en?1:0)},function(e){const t=e.stack,n=t.pop(),o=t.pop();exports.DEBUG&&console.log(e.step,"GTEQ[]",n,o),t.push(o>=n?1:0)},function(e){const t=e.stack,n=t.pop(),o=t.pop();exports.DEBUG&&console.log(e.step,"EQ[]",n,o),t.push(n===o?1:0)},function(e){const t=e.stack,n=t.pop(),o=t.pop();exports.DEBUG&&console.log(e.step,"NEQ[]",n,o),t.push(n!==o?1:0)},function(e){const t=e.stack,n=t.pop();exports.DEBUG&&console.log(e.step,"ODD[]",n),t.push(Math.trunc(n)%2?1:0)},function(e){const t=e.stack,n=t.pop();exports.DEBUG&&console.log(e.step,"EVEN[]",n),t.push(Math.trunc(n)%2?0:1)},function(e){let t=e.stack.pop();exports.DEBUG&&console.log(e.step,"IF[]",t),t||(on(e,!0),exports.DEBUG&&console.log(e.step,"EIF[]"))},function(e){exports.DEBUG&&console.log(e.step,"EIF[]")},function(e){const t=e.stack,n=t.pop(),o=t.pop();exports.DEBUG&&console.log(e.step,"AND[]",n,o),t.push(n&&o?1:0)},function(e){const t=e.stack,n=t.pop(),o=t.pop();exports.DEBUG&&console.log(e.step,"OR[]",n,o),t.push(n||o?1:0)},function(e){const t=e.stack,n=t.pop();exports.DEBUG&&console.log(e.step,"NOT[]",n),t.push(n?0:1)},Sn.bind(void 0,1),function(e){const t=e.stack.pop();exports.DEBUG&&console.log(e.step,"SDB[]",t),e.deltaBase=t},function(e){const t=e.stack.pop();exports.DEBUG&&console.log(e.step,"SDS[]",t),e.deltaShift=Math.pow(.5,t)},function(e){const t=e.stack,n=t.pop(),o=t.pop();exports.DEBUG&&console.log(e.step,"ADD[]",n,o),t.push(o+n)},function(e){const t=e.stack,n=t.pop(),o=t.pop();exports.DEBUG&&console.log(e.step,"SUB[]",n,o),t.push(o-n)},function(e){const t=e.stack,n=t.pop(),o=t.pop();exports.DEBUG&&console.log(e.step,"DIV[]",n,o),t.push(64*o/n)},function(e){const t=e.stack,n=t.pop(),o=t.pop();exports.DEBUG&&console.log(e.step,"MUL[]",n,o),t.push(o*n/64)},function(e){const t=e.stack,n=t.pop();exports.DEBUG&&console.log(e.step,"ABS[]",n),t.push(Math.abs(n))},function(e){const t=e.stack;let n=t.pop();exports.DEBUG&&console.log(e.step,"NEG[]",n),t.push(-n)},function(e){const t=e.stack,n=t.pop();exports.DEBUG&&console.log(e.step,"FLOOR[]",n),t.push(64*Math.floor(n/64))},function(e){const t=e.stack,n=t.pop();exports.DEBUG&&console.log(e.step,"CEILING[]",n),t.push(64*Math.ceil(n/64))},xn.bind(void 0,0),xn.bind(void 0,1),xn.bind(void 0,2),xn.bind(void 0,3),void 0,void 0,void 0,void 0,function(e){const t=e.stack,n=t.pop(),o=t.pop();exports.DEBUG&&console.log(e.step,"WCVTF[]",n,o),e.cvt[o]=n*e.ppem/e.font.unitsPerEm},Sn.bind(void 0,2),Sn.bind(void 0,3),Un.bind(void 0,1),Un.bind(void 0,2),Un.bind(void 0,3),function(e){let t,n=e.stack.pop();switch(exports.DEBUG&&console.log(e.step,"SROUND[]",n),e.round=jt,192&n){case 0:t=.5;break;case 64:t=1;break;case 128:t=2;break;default:throw new Error("invalid SROUND value")}switch(e.srPeriod=t,48&n){case 0:e.srPhase=0;break;case 16:e.srPhase=.25*t;break;case 32:e.srPhase=.5*t;break;case 48:e.srPhase=.75*t;break;default:throw new Error("invalid SROUND value")}n&=15,e.srThreshold=0===n?0:(n/8-.5)*t},function(e){let t,n=e.stack.pop();switch(exports.DEBUG&&console.log(e.step,"S45ROUND[]",n),e.round=jt,192&n){case 0:t=Math.sqrt(2)/2;break;case 64:t=Math.sqrt(2);break;case 128:t=2*Math.sqrt(2);break;default:throw new Error("invalid S45ROUND value")}switch(e.srPeriod=t,48&n){case 0:e.srPhase=0;break;case 16:e.srPhase=.25*t;break;case 32:e.srPhase=.5*t;break;case 48:e.srPhase=.75*t;break;default:throw new Error("invalid S45ROUND value")}n&=15,e.srThreshold=0===n?0:(n/8-.5)*t},void 0,void 0,function(e){exports.DEBUG&&console.log(e.step,"ROFF[]"),e.round=zt},void 0,function(e){exports.DEBUG&&console.log(e.step,"RUTG[]"),e.round=Xt},function(e){exports.DEBUG&&console.log(e.step,"RDTG[]"),e.round=Vt},un,un,void 0,void 0,void 0,void 0,void 0,function(e){const t=e.stack.pop();exports.DEBUG&&console.log(e.step,"SCANCTRL[]",t)},Tn.bind(void 0,0),Tn.bind(void 0,1),function(e){const t=e.stack,n=t.pop();let o=0;exports.DEBUG&&console.log(e.step,"GETINFO[]",n),1&n&&(o=35),32&n&&(o|=4096),t.push(o)},void 0,function(e){const t=e.stack,n=t.pop(),o=t.pop(),s=t.pop();exports.DEBUG&&console.log(e.step,"ROLL[]"),t.push(o),t.push(n),t.push(s)},function(e){const t=e.stack,n=t.pop(),o=t.pop();exports.DEBUG&&console.log(e.step,"MAX[]",n,o),t.push(Math.max(o,n))},function(e){const t=e.stack,n=t.pop(),o=t.pop();exports.DEBUG&&console.log(e.step,"MIN[]",n,o),t.push(Math.min(o,n))},function(e){const t=e.stack.pop();exports.DEBUG&&console.log(e.step,"SCANTYPE[]",t)},function(e){const t=e.stack.pop();let n=e.stack.pop();switch(exports.DEBUG&&console.log(e.step,"INSTCTRL[]",t,n),t){case 1:return void(e.inhibitGridFit=!!n);case 2:return void(e.ignoreCvt=!!n);default:throw new Error("invalid INSTCTRL[] selector")}},void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,En.bind(void 0,1),En.bind(void 0,2),En.bind(void 0,3),En.bind(void 0,4),En.bind(void 0,5),En.bind(void 0,6),En.bind(void 0,7),En.bind(void 0,8),On.bind(void 0,1),On.bind(void 0,2),On.bind(void 0,3),On.bind(void 0,4),On.bind(void 0,5),On.bind(void 0,6),On.bind(void 0,7),On.bind(void 0,8),wn.bind(void 0,0,0,0,0,0),wn.bind(void 0,0,0,0,0,1),wn.bind(void 0,0,0,0,0,2),wn.bind(void 0,0,0,0,0,3),wn.bind(void 0,0,0,0,1,0),wn.bind(void 0,0,0,0,1,1),wn.bind(void 0,0,0,0,1,2),wn.bind(void 0,0,0,0,1,3),wn.bind(void 0,0,0,1,0,0),wn.bind(void 0,0,0,1,0,1),wn.bind(void 0,0,0,1,0,2),wn.bind(void 0,0,0,1,0,3),wn.bind(void 0,0,0,1,1,0),wn.bind(void 0,0,0,1,1,1),wn.bind(void 0,0,0,1,1,2),wn.bind(void 0,0,0,1,1,3),wn.bind(void 0,0,1,0,0,0),wn.bind(void 0,0,1,0,0,1),wn.bind(void 0,0,1,0,0,2),wn.bind(void 0,0,1,0,0,3),wn.bind(void 0,0,1,0,1,0),wn.bind(void 0,0,1,0,1,1),wn.bind(void 0,0,1,0,1,2),wn.bind(void 0,0,1,0,1,3),wn.bind(void 0,0,1,1,0,0),wn.bind(void 0,0,1,1,0,1),wn.bind(void 0,0,1,1,0,2),wn.bind(void 0,0,1,1,0,3),wn.bind(void 0,0,1,1,1,0),wn.bind(void 0,0,1,1,1,1),wn.bind(void 0,0,1,1,1,2),wn.bind(void 0,0,1,1,1,3),wn.bind(void 0,1,0,0,0,0),wn.bind(void 0,1,0,0,0,1),wn.bind(void 0,1,0,0,0,2),wn.bind(void 0,1,0,0,0,3),wn.bind(void 0,1,0,0,1,0),wn.bind(void 0,1,0,0,1,1),wn.bind(void 0,1,0,0,1,2),wn.bind(void 0,1,0,0,1,3),wn.bind(void 0,1,0,1,0,0),wn.bind(void 0,1,0,1,0,1),wn.bind(void 0,1,0,1,0,2),wn.bind(void 0,1,0,1,0,3),wn.bind(void 0,1,0,1,1,0),wn.bind(void 0,1,0,1,1,1),wn.bind(void 0,1,0,1,1,2),wn.bind(void 0,1,0,1,1,3),wn.bind(void 0,1,1,0,0,0),wn.bind(void 0,1,1,0,0,1),wn.bind(void 0,1,1,0,0,2),wn.bind(void 0,1,1,0,0,3),wn.bind(void 0,1,1,0,1,0),wn.bind(void 0,1,1,0,1,1),wn.bind(void 0,1,1,0,1,2),wn.bind(void 0,1,1,0,1,3),wn.bind(void 0,1,1,1,0,0),wn.bind(void 0,1,1,1,0,1),wn.bind(void 0,1,1,1,0,2),wn.bind(void 0,1,1,1,0,3),wn.bind(void 0,1,1,1,1,0),wn.bind(void 0,1,1,1,1,1),wn.bind(void 0,1,1,1,1,2),wn.bind(void 0,1,1,1,1,3)],kn.prototype.hasChar=function(e){return null!==this.encoding.charToGlyphIndex(e)},kn.prototype.charToGlyphIndex=function(e){return this.encoding.charToGlyphIndex(e)},kn.prototype.charToGlyph=function(e){const t=this.charToGlyphIndex(e);let n=this.glyphs.get(t);return n||(n=this.glyphs.get(0)),n},kn.prototype.stringToGlyphs=function(e,t){t=t||this.defaultRenderOptions;const n=[];for(let t=0;t>1;e1&&console.warn("Only the first kern subtable is supported."),e.skip("uLong");const n=255&e.parseUShort();if(e.skip("uShort"),0===n){const n=e.parseUShort();e.skip("uShort",3);for(let o=0;o{const t=Vn.loadSync(e);Zn.font=t,Zn.ascender=t.ascender,Zn.descender=t.descender}};const $n=Qn.options,Kn=function(e,t){return Math.round(e+Math.random()*(t-e))};const Jn=function(e,t){return{text:(e+t).toString(),equation:e+"+"+t}},eo=function(e,t){return{text:(e-t).toString(),equation:e+"-"+t}};function to(e,t,n){return 6*(n=(n+1)%1)<1?e+(t-e)*n*6:2*n<1?t:3*n<2?e+(t-e)*(2/3-n)*6:e}var no={int:Kn,greyColor:function(e,t){const n=Kn(e=e||1,t=t||9).toString(16);return`#${n}${n}${n}`},captchaText:function(e){"number"==typeof e&&(e={size:e});const t=(e=e||{}).size||4,n=e.ignoreChars||"";let o=-1,s="",r=e.charPreset||$n.charPreset;n&&(r=function(e,t){return e.split("").filter(e=>-1===t.indexOf(e))}(r,n));const a=r.length-1;for(;++o>16,o=t>>8&255,s=255&t,r=Math.max(n,o,s),a=Math.min(n,o,s);return(r+a)/510}(e):1;let s,r;o>=.5?(s=Math.round(100*o)-45,r=Math.round(100*o)-25):(s=Math.round(100*o)+25,r=Math.round(100*o)+45);const a=Kn(s,r)/100,i=a<.5?a*(a+n):a+n-a*n,l=2*a-i,c=Math.floor(255*to(l,i,t+1/3)),u=Math.floor(255*to(l,i,t));return"#"+(Math.floor(255*to(l,i,t-1/3))|u<<8|c<<16|1<<24).toString(16).slice(1)}};const oo=Qn.options,so=function(e,t){e=e||no.captchaText();const n=(t=Object.assign({},oo,t)).width,o=t.height,s=t.background||t.backgroundColor;s&&(t.color=!0);const r=s?``:"",a=[].concat(function(e,t,n){const o=n.color,s=[],r=n.inverse?7:1,a=n.inverse?15:9;let i=-1;for(;++i`)}return s}(n,o,t)).concat(function(e,t,n,o,s){const r=e.length,a=(t-2)/(r+1),i=o.inverse?10:0,c=o.inverse?14:4;let u=-1;const p=[],h=s||o.color?no.color(o.background):no.greyColor(i,c);for(;++u`)}return p}(e,n,o,t)).sort(()=>Math.random()-.5).join("");return`${``}${r}${a}`};var ro=so,ao=no.captchaText,io=function(e){const t=e.text||no.captchaText(e);return{text:t,data:so(t,e)}},lo=function(e){const t=no.mathExpr(e.mathMin,e.mathMax,e.mathOperator);return{text:t.text,data:so(t.equation,e)}},co=oo,uo=Qn.loadFont;ro.randomText=ao,ro.create=io,ro.createMathExpr=lo,ro.options=co,ro.loadFont=uo;var po=ro;const ho=Object.prototype.toString;function fo(e){return"[object Object]"===ho.call(e)}function go(){"development"===process.env.NODE_ENV&&console.log(...arguments)}const mo=async function(){};function yo(e){return mo.constructor===e.constructor?async function(){const t=await e.apply(this,arguments);return fo(t)&&(t.msg&&(t.message=t.msg,t.errMsg=t.msg),t.errCode=t.code),t}:function(){const t=e.apply(this,arguments);return fo(t)&&(t.msg&&(t.message=t.msg,t.errMsg=t.msg),t.errCode=t.code),t}}const vo=uniCloud.database().collection("opendb-verify-codes");class bo{async setVerifyCode({deviceId:e,code:t,expiresDate:n,scene:o}){if(!e)return{code:10101,msg:"deviceId不可为空"};if(!t)return{code:10102,msg:"验证码不可为空"};n||(n=180);const s=Date.now(),r={deviceId:e,scene:o,code:t.toLocaleLowerCase(),state:0,ip:__ctx__.CLIENTIP,created_date:s,expired_date:s+1e3*n};return go("addRes",await vo.add(r)),{code:0,deviceId:e}}async verifyCode({deviceId:e,code:t,scene:n}){if(!e)return{code:10101,msg:"deviceId不可为空"};if(!t)return{code:10102,msg:"验证码不可为空"};const o=Date.now(),s={deviceId:e,scene:n,code:t.toLocaleLowerCase(),state:0},r=await vo.where(s).orderBy("created_date","desc").limit(1).get();if(go("verifyRecord:",r),r&&r.data&&r.data.length>0){const e=r.data[0];if(e.expired_date{e.scene&&delete e.scene,this.pluginConfig.scene[n]=Object.assign({},t,e[n])})}}}{constructor(){super(),this.DEVICEID2opts={}}mergeConfig(e){const t=fo(this.pluginConfig.scene)?this.pluginConfig.scene[e.scene]:e.scene;return Object.assign({},fo(t)?t:this.pluginConfig,e)}async create(e={}){if(!e.scene)throw new Error("scene验证码场景不可为空");e=this.mergeConfig(e);let{scene:t,expiresDate:n,deviceId:o,...s}=e;if(o=o||__ctx__.DEVICEID,!o)throw new Error("deviceId不可为空");const r=new bo;try{const{text:a,base64:i}=function(e={}){const{uniPlatform:t=""}=e;let n;n=e.mathExpr?po.createMathExpr(e):po.create(e);let o="data:image/svg+xml;utf8,"+n.data.replace(/#/g,"%23");return(!t||"string"==typeof t&&-1===t.indexOf("mp-"))&&(o=o.replace(/"/g,"'").replace(//g,"%3E")),{text:n.text,base64:o}}(s),l=await r.setVerifyCode({deviceId:o,code:a,expiresDate:n,scene:t});return l.code>0?{...l,code:10001}:(this.DEVICEID2opts[o]=e,{code:0,msg:"验证码获取成功",captchaBase64:i})}catch(e){return{code:10001,msg:"验证码生成失败:"+e.message}}}async verify({deviceId:e,captcha:t,scene:n}){if(!(e=e||__ctx__.DEVICEID))throw new Error("deviceId不可为空");if(!n)throw new Error("scene验证码场景不可为空");const o=new bo;try{const s=await o.verifyCode({deviceId:e,code:t,scene:n});return s.code>0?s:{code:0,msg:"验证码通过"}}catch(e){return{code:10002,msg:"验证码校验失败:"+e.message}}}async refresh(e={}){let{scene:t,expiresDate:n,deviceId:o,...s}=e;if(o=o||__ctx__.DEVICEID,!o)throw new Error("deviceId不可为空");if(!t)throw new Error("scene验证码场景不可为空");const r=await vo.where({deviceId:o,scene:t}).orderBy("created_date","desc").limit(1).get();if(r&&r.data&&r.data.length>0){const e=r.data[0];await vo.doc(e._id).update({state:2}),Object.keys(s).length>0&&(this.DEVICEID2opts[o]=Object.assign({},this.DEVICEID2opts[o],s));let a={};try{a=await this.create(Object.assign({},this.DEVICEID2opts[o],{deviceId:o,scene:t,expiresDate:n}))}catch(e){return{code:50403,msg:e.message}}return a.code>0?{...a,code:10003}:{code:0,msg:"验证码刷新成功",captchaBase64:a.captchaBase64}}return{code:10003,msg:`验证码刷新失败:无此设备在 ${t} 场景信息,请重新获取`}}}const Uo=new bo;Object.keys(Uo).forEach(e=>{xo.prototype[e]=yo(Uo[e])});const To=new xo,Eo=new Proxy(To,{get(e,t){if(t in e)return"function"==typeof e[t]?yo(e[t]).bind(Eo):e[t]}});module.exports=Eo; +"use strict";var e=require("assert"),t=require("path");function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var o=n(e),r=n(t);const s={10001:"uni-captcha-create-fail",10002:"uni-captcha-verify-fail",10003:"uni-captcha-refresh-fail",10101:"uni-captcha-deviceId-empty",10102:"uni-captcha-text-required",10103:"uni-captcha-verify-overdue",10104:"uni-captcha-verify-fail",50403:"uni-captcha-interior-fail"};function a(e){const t=.2*Math.random()-.1;switch(e.type){case"M":case"L":e.x+=t,e.y+=t;break;case"Q":case"C":e.x+=t,e.y+=t,e.x1+=t,e.y1+=t}return e}function i(e,t,n,o,r,s,a){let i,l,c,u,p,h;if(e<=0||e>=1)throw RangeError("spliteCurveAt requires position > 0 && position < 1");return u=[],p=0,i={},l={},c={},i.x=t,i.y=n,l.x=o,l.y=r,c.x=s,c.y=a,h=e,u[p++]=i.x,u[p++]=i.y,u[p++]=i.x+=(l.x-i.x)*h,u[p++]=i.y+=(l.y-i.y)*h,l.x+=(c.x-l.x)*h,l.y+=(c.y-l.y)*h,u[p++]=i.x+(l.x-i.x)*h,u[p++]=i.y+(l.y-i.y)*h,u[p++]=l.x,u[p++]=l.y,u[p++]=c.x,u[p++]=c.y,u}function l(e,t){return Math.random()*(t-e)+e}var c=function(e,t){const n=e[0];o.default(n,"expect a string");const r=t.fontSize,s=r/t.font.unitsPerEm,c=t.font.charToGlyph(n),u=c.advanceWidth?c.advanceWidth*s:0,p=t.x-u/2,h=(t.ascender+t.descender)*s,f=t.y+h/2,d=c.getPath(p,f,r);d.commands.forEach(a),d.commands=function(e,t){const n=[];for(let o=0;ot.truncateLineProbability){const e=l(-.1,.1);n.push(r),n.push({type:"L",x:(r.x+s.x)/2+e,y:(r.y+s.y)/2+e})}else n.push(r)}else if("Q"===r.type&&o>=1){const s=e[o-1];if(("L"===s.type||"M"===s.type)&&Math.random()>t.truncateCurveProbability){const e=s.x,o=s.y,a=l(-.1,.1),c=r.x1+a,u=r.y1+a,p=r.x+a,h=r.y+a,f=i(l(t.truncateCurvePositionMin,t.truncateCurvePositionMax),e,o,c,u,p,h),d={type:"Q",x1:f[2],y1:f[3],x:f[4],y:f[5]},g={type:"L",x:f[4],y:f[5]},m={type:"Q",x1:f[6],y1:f[7],x:f[8],y:f[9]},y={type:"L",x:f[8],y:f[9]};n.push(d),n.push(g),n.push(m),n.push(y)}}else n.push(r)}return n}(d.commands,t);return d.toPathData()};function u(){this.table=new Uint16Array(16),this.trans=new Uint16Array(288)}function p(e,t){this.source=e,this.sourceIndex=0,this.tag=0,this.bitcount=0,this.dest=t,this.destLen=0,this.ltree=new u,this.dtree=new u}var h=new u,f=new u,d=new Uint8Array(30),g=new Uint16Array(30),m=new Uint8Array(30),y=new Uint16Array(30),v=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),b=new u,S=new Uint8Array(320);function x(e,t,n,o){var r,s;for(r=0;r>>=1,t}function O(e,t,n){if(!t)return n;for(;e.bitcount<24;)e.tag|=e.source[e.sourceIndex++]<>>16-t;return e.tag>>>=t,e.bitcount-=t,o+n}function w(e,t){for(;e.bitcount<24;)e.tag|=e.source[e.sourceIndex++]<>>=1,++r,n+=t.table[r],o-=t.table[r]}while(o>=0);return e.tag=s,e.bitcount-=r,t.trans[n+o]}function k(e,t,n){var o,r,s,a,i,l;for(o=O(e,5,257),r=O(e,5,1),s=O(e,4,4),a=0;a<19;++a)S[a]=0;for(a=0;a8;)e.sourceIndex--,e.bitcount-=8;if((t=256*(t=e.source[e.sourceIndex+1])+e.source[e.sourceIndex])!==(65535&~(256*e.source[e.sourceIndex+3]+e.source[e.sourceIndex+2])))return-3;for(e.sourceIndex+=4,n=t;n;--n)e.dest[e.destLen++]=e.source[e.sourceIndex++];return e.bitcount=0,0}!function(e,t){var n;for(n=0;n<7;++n)e.table[n]=0;for(e.table[7]=24,e.table[8]=152,e.table[9]=112,n=0;n<24;++n)e.trans[n]=256+n;for(n=0;n<144;++n)e.trans[24+n]=n;for(n=0;n<8;++n)e.trans[168+n]=280+n;for(n=0;n<112;++n)e.trans[176+n]=144+n;for(n=0;n<5;++n)t.table[n]=0;for(t.table[5]=32,n=0;n<32;++n)t.trans[n]=n}(h,f),x(d,g,4,3),x(m,y,2,1),d[28]=0,g[28]=258;var C=function(e,t){var n,o,r=new p(e,t);do{switch(n=E(r),O(r,2,0)){case 0:o=D(r);break;case 1:o=R(r,h,f);break;case 2:k(r,r.ltree,r.dtree),o=R(r,r.ltree,r.dtree);break;default:o=-3}if(0!==o)throw new Error("Data error")}while(!n);return r.destLenthis.x2&&(this.x2=e)),"number"==typeof t&&((isNaN(this.y1)||isNaN(this.y2))&&(this.y1=t,this.y2=t),tthis.y2&&(this.y2=t))},I.prototype.addX=function(e){this.addPoint(e,null)},I.prototype.addY=function(e){this.addPoint(null,e)},I.prototype.addBezier=function(e,t,n,o,r,s,a,i){const l=[e,t],c=[n,o],u=[r,s],p=[a,i];this.addPoint(e,t),this.addPoint(a,i);for(let e=0;e<=1;e++){const t=6*l[e]-12*c[e]+6*u[e],n=-3*l[e]+9*c[e]-9*u[e]+3*p[e],o=3*c[e]-3*l[e];if(0===n){if(0===t)continue;const n=-o/t;0=0&&n>0&&(e+=" "),e+=t(o)}return e}e=void 0!==e?e:2;let o="";for(let e=0;e=0&&e<=255,"Byte value should be between 0 and 255."),[e]},F.BYTE=H(1),A.CHAR=function(e){return[e.charCodeAt(0)]},F.CHAR=H(1),A.CHARARRAY=function(e){const t=[];for(let n=0;n>8&255,255&e]},F.USHORT=H(2),A.SHORT=function(e){return e>=32768&&(e=-(65536-e)),[e>>8&255,255&e]},F.SHORT=H(2),A.UINT24=function(e){return[e>>16&255,e>>8&255,255&e]},F.UINT24=H(3),A.ULONG=function(e){return[e>>24&255,e>>16&255,e>>8&255,255&e]},F.ULONG=H(4),A.LONG=function(e){return e>=2147483648&&(e=-(4294967296-e)),[e>>24&255,e>>16&255,e>>8&255,255&e]},F.LONG=H(4),A.FIXED=A.ULONG,F.FIXED=F.ULONG,A.FWORD=A.SHORT,F.FWORD=F.SHORT,A.UFWORD=A.USHORT,F.UFWORD=F.USHORT,A.LONGDATETIME=function(e){return[0,0,0,0,e>>24&255,e>>16&255,e>>8&255,255&e]},F.LONGDATETIME=H(8),A.TAG=function(e){return N.argument(4===e.length,"Tag should be exactly 4 ASCII characters."),[e.charCodeAt(0),e.charCodeAt(1),e.charCodeAt(2),e.charCodeAt(3)]},F.TAG=H(4),A.Card8=A.BYTE,F.Card8=F.BYTE,A.Card16=A.USHORT,F.Card16=F.USHORT,A.OffSize=A.BYTE,F.OffSize=F.BYTE,A.SID=A.USHORT,F.SID=F.USHORT,A.NUMBER=function(e){return e>=-107&&e<=107?[e+139]:e>=108&&e<=1131?[247+((e-=108)>>8),255&e]:e>=-1131&&e<=-108?[251+((e=-e-108)>>8),255&e]:e>=-32768&&e<=32767?A.NUMBER16(e):A.NUMBER32(e)},F.NUMBER=function(e){return A.NUMBER(e).length},A.NUMBER16=function(e){return[28,e>>8&255,255&e]},F.NUMBER16=H(3),A.NUMBER32=function(e){return[29,e>>24&255,e>>16&255,e>>8&255,255&e]},F.NUMBER32=H(5),A.REAL=function(e){let t=e.toString();const n=/\.(\d*?)(?:9{5,20}|0{5,20})\d{0,2}(?:e(.+)|$)/.exec(t);if(n){const o=parseFloat("1e"+((n[2]?+n[2]:0)+n[1].length));t=(Math.round(e*o)/o).toString()}let o="";for(let e=0,n=t.length;e>8&255,t[t.length]=255&o}return t},F.UTF16=function(e){return 2*e.length};const z={"x-mac-croatian":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®Š™´¨≠ŽØ∞±≤≥∆µ∂∑∏š∫ªºΩžø¿¡¬√ƒ≈Ć«Č… ÀÃÕŒœĐ—“”‘’÷◊©⁄€‹›Æ»–·‚„‰ÂćÁčÈÍÎÏÌÓÔđÒÚÛÙıˆ˜¯πË˚¸Êæˇ","x-mac-cyrillic":"АБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯ†°Ґ£§•¶І®©™Ђђ≠Ѓѓ∞±≤≥іµґЈЄєЇїЉљЊњјЅ¬√ƒ≈∆«»… ЋћЌќѕ–—“”‘’÷„ЎўЏџ№Ёёяабвгдежзийклмнопрстуфхцчшщъыьэю","x-mac-gaelic":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®©™´¨≠ÆØḂ±≤≥ḃĊċḊḋḞḟĠġṀæøṁṖṗɼƒſṠ«»… ÀÃÕŒœ–—“”‘’ṡẛÿŸṪ€‹›Ŷŷṫ·Ỳỳ⁊ÂÊÁËÈÍÎÏÌÓÔ♣ÒÚÛÙıÝýŴŵẄẅẀẁẂẃ","x-mac-greek":"Ĺ²É³ÖÜ΅àâä΄¨çéèê룙î‰ôö¦€ùûü†ΓΔΘΛΞΠß®©ΣΪ§≠°·Α±≤≥¥ΒΕΖΗΙΚΜΦΫΨΩάΝ¬ΟΡ≈Τ«»… ΥΧΆΈœ–―“”‘’÷ΉΊΌΎέήίόΏύαβψδεφγηιξκλμνοπώρστθωςχυζϊϋΐΰ­","x-mac-icelandic":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûüÝ°¢£§•¶ß®©™´¨≠ÆØ∞±≤≥¥µ∂∑∏π∫ªºΩæø¿¡¬√ƒ≈∆«»… ÀÃÕŒœ–—“”‘’÷◊ÿŸ⁄€ÐðÞþý·‚„‰ÂÊÁËÈÍÎÏÌÓÔÒÚÛÙıˆ˜¯˘˙˚¸˝˛ˇ","x-mac-inuit":"ᐃᐄᐅᐆᐊᐋᐱᐲᐳᐴᐸᐹᑉᑎᑏᑐᑑᑕᑖᑦᑭᑮᑯᑰᑲᑳᒃᒋᒌᒍᒎᒐᒑ°ᒡᒥᒦ•¶ᒧ®©™ᒨᒪᒫᒻᓂᓃᓄᓅᓇᓈᓐᓯᓰᓱᓲᓴᓵᔅᓕᓖᓗᓘᓚᓛᓪᔨᔩᔪᔫᔭ… ᔮᔾᕕᕖᕗ–—“”‘’ᕘᕙᕚᕝᕆᕇᕈᕉᕋᕌᕐᕿᖀᖁᖂᖃᖄᖅᖏᖐᖑᖒᖓᖔᖕᙱᙲᙳᙴᙵᙶᖖᖠᖡᖢᖣᖤᖥᖦᕼŁł","x-mac-ce":"ÄĀāÉĄÖÜáąČäčĆć鏟ĎíďĒēĖóėôöõúĚěü†°Ę£§•¶ß®©™ę¨≠ģĮįĪ≤≥īĶ∂∑łĻļĽľĹĺŅņѬ√ńŇ∆«»… ňŐÕőŌ–—“”‘’÷◊ōŔŕŘ‹›řŖŗŠ‚„šŚśÁŤťÍŽžŪÓÔūŮÚůŰűŲųÝýķŻŁżĢˇ",macintosh:"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®©™´¨≠ÆØ∞±≤≥¥µ∂∑∏π∫ªºΩæø¿¡¬√ƒ≈∆«»… ÀÃÕŒœ–—“”‘’÷◊ÿŸ⁄€‹›fifl‡·‚„‰ÂÊÁËÈÍÎÏÌÓÔÒÚÛÙıˆ˜¯˘˙˚¸˝˛ˇ","x-mac-romanian":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®©™´¨≠ĂȘ∞±≤≥¥µ∂∑∏π∫ªºΩăș¿¡¬√ƒ≈∆«»… ÀÃÕŒœ–—“”‘’÷◊ÿŸ⁄€‹›Țț‡·‚„‰ÂÊÁËÈÍÎÏÌÓÔÒÚÛÙıˆ˜¯˘˙˚¸˝˛ˇ","x-mac-turkish":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®©™´¨≠ÆØ∞±≤≥¥µ∂∑∏π∫ªºΩæø¿¡¬√ƒ≈∆«»… ÀÃÕŒœ–—“”‘’÷◊ÿŸĞğİıŞş‡·‚„‰ÂÊÁËÈÍÎÏÌÓÔÒÚÛÙˆ˜¯˘˙˚¸˝˛ˇ"};P.MACSTRING=function(e,t,n,o){const r=z[o];if(void 0===r)return;let s="";for(let o=0;o=-128&&e<=127}function X(e,t,n){let o=0;const r=e.length;for(;t>8&255,t+256&255)}return s}A.MACSTRING=function(e,t){const n=function(e){if(!_){_={};for(let e in z)_[e]=new String(e)}const t=_[e];if(void 0===t)return;if(W){const e=W.get(t);if(void 0!==e)return e}const n=z[e];if(void 0===n)return;const o={};for(let e=0;e=128&&(r=n[r],void 0===r))return;o[t]=r}return o},F.MACSTRING=function(e,t){const n=A.MACSTRING(e,t);return void 0!==n?n.length:0},A.VARDELTAS=function(e){let t=0;const n=[];for(;t=-128&&o<=127?V(e,t,n):j(e,t,n)}return n},A.INDEX=function(e){let t=1;const n=[t],o=[];for(let r=0;r>8,t[s+1]=255&a,t=t.concat(o[n])}return t},F.TABLE=function(e){let t=0;const n=e.fields.length;for(let o=0;o0)return new ce(this.data,this.offset+t).parseStruct(e)},ce.prototype.parseListOfLists=function(e){const t=this.parseOffset16List(),n=t.length,o=this.relativeOffset,r=new Array(n);for(let o=0;o=0;r-=1){const n=pe.getUShort(e,t+4+8*r),s=pe.getUShort(e,t+4+8*r+2);if(3===n&&(0===s||1===s||10===s)){o=pe.getULong(e,t+4+8*r+4);break}}if(-1===o)throw new Error("No valid cmap sub-tables found.");const r=new pe.Parser(e,t+o);if(n.format=r.parseUShort(),12===n.format)!function(e,t){let n;t.parseUShort(),e.length=t.parseULong(),e.language=t.parseULong(),e.groupCount=n=t.parseULong(),e.glyphIndexMap={};for(let o=0;o>1,t.skip("uShort",3),e.glyphIndexMap={};const a=new pe.Parser(n,o+r+14),i=new pe.Parser(n,o+r+16+2*s),l=new pe.Parser(n,o+r+16+4*s),c=new pe.Parser(n,o+r+16+6*s);let u=o+r+16+8*s;for(let t=0;t0?(s=e.parseByte(),0==(t&r)&&(s=-s),s=n+s):s=(t&r)>0?n:n+e.parseShort(),s}function Ee(e,t,n){const o=new pe.Parser(t,n);let r,s;if(e.numberOfContours=o.parseShort(),e._xMin=o.parseShort(),e._yMin=o.parseShort(),e._xMax=o.parseShort(),e._yMax=o.parseShort(),e.numberOfContours>0){const t=e.endPointIndices=[];for(let n=0;n0){const t=o.parseByte();for(let n=0;n0){const a=[];let i;if(n>0){for(let e=0;e=0,a.push(i);let e=0;for(let t=0;t0?(2&r)>0?(n.dx=o.parseShort(),n.dy=o.parseShort()):n.matchedPoints=[o.parseUShort(),o.parseUShort()]:(2&r)>0?(n.dx=o.parseChar(),n.dy=o.parseChar()):n.matchedPoints=[o.parseByte(),o.parseByte()],(8&r)>0?n.xScale=n.yScale=o.parseF2Dot14():(64&r)>0?(n.xScale=o.parseF2Dot14(),n.yScale=o.parseF2Dot14()):(128&r)>0&&(n.xScale=o.parseF2Dot14(),n.scale01=o.parseF2Dot14(),n.scale10=o.parseF2Dot14(),n.yScale=o.parseF2Dot14()),e.components.push(n),t=!!(32&r)}if(256&r){e.instructionLength=o.parseUShort(),e.instructions=[];for(let t=0;tt.points.length-1||o.matchedPoints[1]>r.points.length-1)throw Error("Matched points out of range in "+t.name);const n=t.points[o.matchedPoints[0]];let s=r.points[o.matchedPoints[1]];const a={xScale:o.xScale,scale01:o.scale01,scale10:o.scale10,yScale:o.yScale,dx:0,dy:0};s=Oe([s],a)[0],a.dx=n.x-s.x,a.dy=n.y-s.y,e=Oe(r.points,a)}t.points=t.points.concat(e)}}return we(t.points)}var Re={getPath:we,parse:function(e,t,n,o){const r=new Ie.GlyphSet(o);for(let s=0;s>4,s=15&o;if(15===r)break;if(t+=n[r],15===s)break;t+=n[s]}return parseFloat(t)}(e);if(t>=32&&t<=246)return t-139;if(t>=247&&t<=250)return n=e.parseByte(),256*(t-247)+n+108;if(t>=251&&t<=254)return n=e.parseByte(),256*-(t-251)-n-108;throw new Error("Invalid b0 "+t)}function Pe(e,t,n){t=void 0!==t?t:0;const o=new pe.Parser(e,t),r=[];let s=[];for(n=void 0!==n?n:e.length;o.relativeOffset>1,l.length=0,d=!0}return function n(p){let x,U,T,E,O,w,k,R,D,C,L,I,M=0;for(;M1&&!d&&(v=l.shift()+h,d=!0),y+=l.pop(),b(m,y);break;case 5:for(;l.length>0;)m+=l.shift(),y+=l.shift(),i.lineTo(m,y);break;case 6:for(;l.length>0&&(m+=l.shift(),i.lineTo(m,y),0!==l.length);)y+=l.shift(),i.lineTo(m,y);break;case 7:for(;l.length>0&&(y+=l.shift(),i.lineTo(m,y),0!==l.length);)m+=l.shift(),i.lineTo(m,y);break;case 8:for(;l.length>0;)o=m+l.shift(),r=y+l.shift(),s=o+l.shift(),a=r+l.shift(),m=s+l.shift(),y=a+l.shift(),i.curveTo(o,r,s,a,m,y);break;case 10:O=l.pop()+u,w=c[O],w&&n(w);break;case 11:return;case 12:switch(B=p[M],M+=1,B){case 35:o=m+l.shift(),r=y+l.shift(),s=o+l.shift(),a=r+l.shift(),k=s+l.shift(),R=a+l.shift(),D=k+l.shift(),C=R+l.shift(),L=D+l.shift(),I=C+l.shift(),m=L+l.shift(),y=I+l.shift(),l.shift(),i.curveTo(o,r,s,a,k,R),i.curveTo(D,C,L,I,m,y);break;case 34:o=m+l.shift(),r=y,s=o+l.shift(),a=r+l.shift(),k=s+l.shift(),R=a,D=k+l.shift(),C=a,L=D+l.shift(),I=y,m=L+l.shift(),i.curveTo(o,r,s,a,k,R),i.curveTo(D,C,L,I,m,y);break;case 36:o=m+l.shift(),r=y+l.shift(),s=o+l.shift(),a=r+l.shift(),k=s+l.shift(),R=a,D=k+l.shift(),C=a,L=D+l.shift(),I=C+l.shift(),m=L+l.shift(),i.curveTo(o,r,s,a,k,R),i.curveTo(D,C,L,I,m,y);break;case 37:o=m+l.shift(),r=y+l.shift(),s=o+l.shift(),a=r+l.shift(),k=s+l.shift(),R=a+l.shift(),D=k+l.shift(),C=R+l.shift(),L=D+l.shift(),I=C+l.shift(),Math.abs(L-m)>Math.abs(I-y)?m=L+l.shift():y=I+l.shift(),i.curveTo(o,r,s,a,k,R),i.curveTo(D,C,L,I,m,y);break;default:console.log("Glyph "+t.index+": unknown operator 1200"+B),l.length=0}break;case 14:l.length>0&&!d&&(v=l.shift()+h,d=!0),g&&(i.closePath(),g=!1);break;case 18:S();break;case 19:case 20:S(),M+=f+7>>3;break;case 21:l.length>2&&!d&&(v=l.shift()+h,d=!0),y+=l.pop(),m+=l.pop(),b(m,y);break;case 22:l.length>1&&!d&&(v=l.shift()+h,d=!0),m+=l.pop(),b(m,y);break;case 23:S();break;case 24:for(;l.length>2;)o=m+l.shift(),r=y+l.shift(),s=o+l.shift(),a=r+l.shift(),m=s+l.shift(),y=a+l.shift(),i.curveTo(o,r,s,a,m,y);m+=l.shift(),y+=l.shift(),i.lineTo(m,y);break;case 25:for(;l.length>6;)m+=l.shift(),y+=l.shift(),i.lineTo(m,y);o=m+l.shift(),r=y+l.shift(),s=o+l.shift(),a=r+l.shift(),m=s+l.shift(),y=a+l.shift(),i.curveTo(o,r,s,a,m,y);break;case 26:for(l.length%2&&(m+=l.shift());l.length>0;)o=m,r=y+l.shift(),s=o+l.shift(),a=r+l.shift(),m=s,y=a+l.shift(),i.curveTo(o,r,s,a,m,y);break;case 27:for(l.length%2&&(y+=l.shift());l.length>0;)o=m+l.shift(),r=y,s=o+l.shift(),a=r+l.shift(),m=s+l.shift(),y=a,i.curveTo(o,r,s,a,m,y);break;case 28:x=p[M],U=p[M+1],l.push((x<<24|U<<16)>>16),M+=2;break;case 29:O=l.pop()+e.gsubrsBias,w=e.gsubrs[O],w&&n(w);break;case 30:for(;l.length>0&&(o=m,r=y+l.shift(),s=o+l.shift(),a=r+l.shift(),m=s+l.shift(),y=a+(1===l.length?l.shift():0),i.curveTo(o,r,s,a,m,y),0!==l.length);)o=m+l.shift(),r=y,s=o+l.shift(),a=r+l.shift(),y=a+l.shift(),m=s+(1===l.length?l.shift():0),i.curveTo(o,r,s,a,m,y);break;case 31:for(;l.length>0&&(o=m+l.shift(),r=y,s=o+l.shift(),a=r+l.shift(),y=a+l.shift(),m=s+(1===l.length?l.shift():0),i.curveTo(o,r,s,a,m,y),0!==l.length);)o=m,r=y+l.shift(),s=o+l.shift(),a=r+l.shift(),m=s+l.shift(),y=a+(1===l.length?l.shift():0),i.curveTo(o,r,s,a,m,y);break;default:B<32?console.log("Glyph "+t.index+": unknown operator "+B):B<247?l.push(B-139):B<251?(x=p[M],M+=1,l.push(256*(B-247)+x+108)):B<255?(x=p[M],M+=1,l.push(256*-(B-251)-x-108)):(x=p[M],U=p[M+1],T=p[M+2],E=p[M+3],M+=4,l.push((x<<24|U<<16|T<<8|E)/65536))}}}(n),t.advanceWidth=v,i}function Ve(e,t){let n,o=de.indexOf(e);return o>=0&&(n=o),o=t.indexOf(e),o>=0?n=o+de.length:(n=de.length+t.length,t.push(e)),n}function je(e,t,n){const o={};for(let r=0;r=o)throw new Error("CFF table CID Font FDSelect has bad FD index value "+s+" (FD count "+o+")");r.push(s)}else{if(3!==i)throw new Error("CFF Table CID Font FDSelect table has unsupported format "+i);{const e=a.parseCard16();let t,i=a.parseCard16();if(0!==i)throw new Error("CFF Table CID Font FDSelect format 3 range has bad initial GID "+i);for(let l=0;l=o)throw new Error("CFF table CID Font FDSelect has bad FD index value "+s+" (FD count "+o+")");if(t>n)throw new Error("CFF Table CID Font FDSelect format 3 range has bad GID "+t);for(;i=1&&(n.ulCodePageRange1=o.parseULong(),n.ulCodePageRange2=o.parseULong()),n.version>=2&&(n.sxHeight=o.parseShort(),n.sCapHeight=o.parseShort(),n.usDefaultChar=o.parseUShort(),n.usBreakChar=o.parseUShort(),n.usMaxContent=o.parseUShort()),n},make:function(e){return new oe.Table("OS/2",[{name:"version",type:"USHORT",value:3},{name:"xAvgCharWidth",type:"SHORT",value:0},{name:"usWeightClass",type:"USHORT",value:0},{name:"usWidthClass",type:"USHORT",value:0},{name:"fsType",type:"USHORT",value:0},{name:"ySubscriptXSize",type:"SHORT",value:650},{name:"ySubscriptYSize",type:"SHORT",value:699},{name:"ySubscriptXOffset",type:"SHORT",value:0},{name:"ySubscriptYOffset",type:"SHORT",value:140},{name:"ySuperscriptXSize",type:"SHORT",value:650},{name:"ySuperscriptYSize",type:"SHORT",value:699},{name:"ySuperscriptXOffset",type:"SHORT",value:0},{name:"ySuperscriptYOffset",type:"SHORT",value:479},{name:"yStrikeoutSize",type:"SHORT",value:49},{name:"yStrikeoutPosition",type:"SHORT",value:258},{name:"sFamilyClass",type:"SHORT",value:0},{name:"bFamilyType",type:"BYTE",value:0},{name:"bSerifStyle",type:"BYTE",value:0},{name:"bWeight",type:"BYTE",value:0},{name:"bProportion",type:"BYTE",value:0},{name:"bContrast",type:"BYTE",value:0},{name:"bStrokeVariation",type:"BYTE",value:0},{name:"bArmStyle",type:"BYTE",value:0},{name:"bLetterform",type:"BYTE",value:0},{name:"bMidline",type:"BYTE",value:0},{name:"bXHeight",type:"BYTE",value:0},{name:"ulUnicodeRange1",type:"ULONG",value:0},{name:"ulUnicodeRange2",type:"ULONG",value:0},{name:"ulUnicodeRange3",type:"ULONG",value:0},{name:"ulUnicodeRange4",type:"ULONG",value:0},{name:"achVendID",type:"CHARARRAY",value:"XXXX"},{name:"fsSelection",type:"USHORT",value:0},{name:"usFirstCharIndex",type:"USHORT",value:0},{name:"usLastCharIndex",type:"USHORT",value:0},{name:"sTypoAscender",type:"SHORT",value:0},{name:"sTypoDescender",type:"SHORT",value:0},{name:"sTypoLineGap",type:"SHORT",value:0},{name:"usWinAscent",type:"USHORT",value:0},{name:"usWinDescent",type:"USHORT",value:0},{name:"ulCodePageRange1",type:"ULONG",value:0},{name:"ulCodePageRange2",type:"ULONG",value:0},{name:"sxHeight",type:"SHORT",value:0},{name:"sCapHeight",type:"SHORT",value:0},{name:"usDefaultChar",type:"USHORT",value:0},{name:"usBreakChar",type:"USHORT",value:0},{name:"usMaxContext",type:"USHORT",value:0}],e)},unicodeRanges:gt,getUnicodeRange:function(e){for(let t=0;t=n.begin&&e=ye.length){const e=o.parseChar();n.names.push(o.parseString(e))}break;case 2.5:n.numberOfGlyphs=o.parseUShort(),n.offset=new Array(n.numberOfGlyphs);for(let e=0;et.value.tag?1:-1})),t.fields=t.fields.concat(o),t.fields=t.fields.concat(r),t}function kt(e,t,n){for(let n=0;n0){return e.glyphs.get(o).getMetrics()}}return n}function Rt(e){let t=0;for(let n=0;nm||void 0===l)&&m>0&&(l=m),c 123 are reserved for internal usage");f|=1<0?tt.make(w):void 0,D=yt.make(),C=$e.make(e.glyphs,{version:e.getEnglishName("version"),fullName:T,familyName:x,weightName:U,postScriptName:E,unitsPerEm:e.unitsPerEm,fontBBox:[0,d.yMin,d.ascender,d.advanceWidthMax]}),L=e.metas&&Object.keys(e.metas).length>0?Ut.make(e.metas):void 0,I=[g,m,y,v,k,S,D,C,b];R&&I.push(R),e.tables.gsub&&I.push(xt.make(e.tables.gsub)),L&&I.push(L);const M=wt(I),B=Et(M.encode()),G=M.fields;let N=!1;for(let e=0;e>>1,s=e[r].tag;if(s===t)return r;s>>1,s=e[r];if(s===t)return r;s=0)return o[r].script;if(t){const t={tag:e,script:{defaultLangSys:{reserved:0,reqFeatureIndex:65535,featureIndexes:[]},langSysRecords:[]}};return o.splice(-1-r,0,t),t.script}}},getLangSysTable:function(e,t,n){const o=this.getScriptTable(e,n);if(o){if(!t||"dflt"===t||"DFLT"===t)return o.defaultLangSys;const e=Ct(o.langSysRecords,t);if(e>=0)return o.langSysRecords[e].langSys;if(n){const n={tag:t,langSys:{reserved:0,reqFeatureIndex:65535,featureIndexes:[]}};return o.langSysRecords.splice(-1-e,0,n),n.langSys}}},getFeatureTable:function(e,t,n,o){const r=this.getLangSysTable(e,t,o);if(r){let e;const t=r.featureIndexes,s=this.font.tables[this.tableName].features;for(let o=0;o=s[o-1].tag,"Features must be added in alphabetical order."),e={tag:n,feature:{params:0,lookupListIndexes:[]}},s.push(e),t.push(o),e.feature}}},getLookupTables:function(e,t,n,o,r){const s=this.getFeatureTable(e,t,n,r),a=[];if(s){let e;const t=s.lookupListIndexes,n=this.font.tables[this.tableName].lookups;for(let r=0;r=0){const e=s.ligatureSets[c];for(let t=0;t0&&e<0?n:o<0&&e>0?-n:e*o},Zt={x:1,y:0,axis:"x",distance:function(e,t,n,o){return(n?e.xo:e.x)-(o?t.xo:t.x)},interpolate:function(e,t,n,o){let r,s,a,i,l,c,u;if(!o||o===this)return r=e.xo-t.xo,s=e.xo-n.xo,l=t.x-t.xo,c=n.x-n.xo,a=Math.abs(r),i=Math.abs(s),u=a+i,0===u?void(e.x=e.xo+(l+c)/2):void(e.x=e.xo+(l*i+c*a)/u);r=o.distance(e,t,!0,!0),s=o.distance(e,n,!0,!0),l=o.distance(t,t,!1,!0),c=o.distance(n,n,!1,!0),a=Math.abs(r),i=Math.abs(s),u=a+i,0!==u?Zt.setRelative(e,e,(l*i+c*a)/u,o,!0):Zt.setRelative(e,e,(l+c)/2,o,!0)},normalSlope:Number.NEGATIVE_INFINITY,setRelative:function(e,t,n,o,r){if(!o||o===this)return void(e.x=(r?t.xo:t.x)+n);const s=r?t.xo:t.x,a=r?t.yo:t.y,i=s+n*o.x,l=a+n*o.y;e.x=i+(e.y-l)/o.normalSlope},slope:0,touch:function(e){e.xTouched=!0},touched:function(e){return e.xTouched},untouch:function(e){e.xTouched=!1}},Qt={x:0,y:1,axis:"y",distance:function(e,t,n,o){return(n?e.yo:e.y)-(o?t.yo:t.y)},interpolate:function(e,t,n,o){let r,s,a,i,l,c,u;if(!o||o===this)return r=e.yo-t.yo,s=e.yo-n.yo,l=t.y-t.yo,c=n.y-n.yo,a=Math.abs(r),i=Math.abs(s),u=a+i,0===u?void(e.y=e.yo+(l+c)/2):void(e.y=e.yo+(l*i+c*a)/u);r=o.distance(e,t,!0,!0),s=o.distance(e,n,!0,!0),l=o.distance(t,t,!1,!0),c=o.distance(n,n,!1,!0),a=Math.abs(r),i=Math.abs(s),u=a+i,0!==u?Qt.setRelative(e,e,(l*i+c*a)/u,o,!0):Qt.setRelative(e,e,(l+c)/2,o,!0)},normalSlope:0,setRelative:function(e,t,n,o,r){if(!o||o===this)return void(e.y=(r?t.yo:t.y)+n);const s=r?t.xo:t.x,a=r?t.yo:t.y,i=s+n*o.x,l=a+n*o.y;e.y=l+o.normalSlope*(e.x-i)},slope:Number.POSITIVE_INFINITY,touch:function(e){e.yTouched=!0},touched:function(e){return e.yTouched},untouch:function(e){e.yTouched=!1}};function $t(e,t){this.x=e,this.y=t,this.axis=void 0,this.slope=t/e,this.normalSlope=-e/t,Object.freeze(this)}function Kt(e,t){const n=Math.sqrt(e*e+t*t);return t/=n,1===(e/=n)&&0===t?Zt:0===e&&1===t?Qt:new $t(e,t)}function Jt(e,t,n,o){this.x=this.xo=Math.round(64*e)/64,this.y=this.yo=Math.round(64*t)/64,this.lastPointOfContour=n,this.onCurve=o,this.prevPointOnContour=void 0,this.nextPointOnContour=void 0,this.xTouched=!1,this.yTouched=!1,Object.preventExtensions(this)}Object.freeze(Zt),Object.freeze(Qt),$t.prototype.distance=function(e,t,n,o){return this.x*Zt.distance(e,t,n,o)+this.y*Qt.distance(e,t,n,o)},$t.prototype.interpolate=function(e,t,n,o){let r,s,a,i,l,c,u;a=o.distance(e,t,!0,!0),i=o.distance(e,n,!0,!0),r=o.distance(t,t,!1,!0),s=o.distance(n,n,!1,!0),l=Math.abs(a),c=Math.abs(i),u=l+c,0!==u?this.setRelative(e,e,(r*c+s*l)/u,o,!0):this.setRelative(e,e,(r+s)/2,o,!0)},$t.prototype.setRelative=function(e,t,n,o,r){o=o||this;const s=r?t.xo:t.x,a=r?t.yo:t.y,i=s+n*o.x,l=a+n*o.y,c=o.normalSlope,u=this.slope,p=e.x,h=e.y;e.x=(u*p-c*i+l-h)/(u-c),e.y=u*(e.x-p)+h},$t.prototype.touch=function(e){e.xTouched=!0,e.yTouched=!0},Jt.prototype.nextTouched=function(e){let t=this.nextPointOnContour;for(;!e.touched(t)&&t!==this;)t=t.nextPointOnContour;return t},Jt.prototype.prevTouched=function(e){let t=this.prevPointOnContour;for(;!e.touched(t)&&t!==this;)t=t.prevPointOnContour;return t};const en=Object.freeze(new Jt(0,0)),tn={cvCutIn:17/16,deltaBase:9,deltaShift:.125,loop:1,minDis:1,autoFlip:!0};function nn(e,t){switch(this.env=e,this.stack=[],this.prog=t,e){case"glyf":this.zp0=this.zp1=this.zp2=1,this.rp0=this.rp1=this.rp2=0;case"prep":this.fv=this.pv=this.dpv=Zt,this.round=_t}}function on(e){const t=e.tZone=new Array(e.gZone.length);for(let e=0;e=176&&o<=183)r+=o-176+1;else if(o>=184&&o<=191)r+=2*(o-184+1);else if(t&&1===s&&27===o)break}while(s>0);e.ip=r}function sn(e,t){exports.DEBUG&&console.log(t.step,"SVTCA["+e.axis+"]"),t.fv=t.pv=t.dpv=e}function an(e,t){exports.DEBUG&&console.log(t.step,"SPVTCA["+e.axis+"]"),t.pv=t.dpv=e}function ln(e,t){exports.DEBUG&&console.log(t.step,"SFVTCA["+e.axis+"]"),t.fv=e}function cn(e,t){const n=t.stack,o=n.pop(),r=n.pop(),s=t.z2[o],a=t.z1[r];let i,l;exports.DEBUG&&console.log("SPVTL["+e+"]",o,r),e?(i=s.y-a.y,l=a.x-s.x):(i=a.x-s.x,l=a.y-s.y),t.pv=t.dpv=Kt(i,l)}function un(e,t){const n=t.stack,o=n.pop(),r=n.pop(),s=t.z2[o],a=t.z1[r];let i,l;exports.DEBUG&&console.log("SFVTL["+e+"]",o,r),e?(i=s.y-a.y,l=a.x-s.x):(i=a.x-s.x,l=a.y-s.y),t.fv=Kt(i,l)}function pn(e){exports.DEBUG&&console.log(e.step,"POP[]"),e.stack.pop()}function hn(e,t){const n=t.stack.pop(),o=t.z0[n],r=t.fv,s=t.pv;exports.DEBUG&&console.log(t.step,"MDAP["+e+"]",n);let a=s.distance(o,en);e&&(a=t.round(a)),r.setRelative(o,en,a,s),r.touch(o),t.rp0=t.rp1=n}function fn(e,t){const n=t.z2,o=n.length-2;let r,s,a;exports.DEBUG&&console.log(t.step,"IUP["+e.axis+"]");for(let t=0;t1?"loop "+(t.loop-i)+": ":"")+"SHP["+(e?"rp1":"rp2")+"]",o)}t.loop=1}function gn(e,t){const n=t.stack,o=e?t.rp1:t.rp2,r=(e?t.z0:t.z1)[o],s=t.fv,a=t.pv,i=n.pop(),l=t.z2[t.contours[i]];let c=l;exports.DEBUG&&console.log(t.step,"SHC["+e+"]",i);const u=a.distance(r,r,!1,!0);do{c!==r&&s.setRelative(c,c,u,a),c=c.nextPointOnContour}while(c!==l)}function mn(e,t){const n=t.stack,o=e?t.rp1:t.rp2,r=(e?t.z0:t.z1)[o],s=t.fv,a=t.pv,i=n.pop();let l,c;switch(exports.DEBUG&&console.log(t.step,"SHZ["+e+"]",i),i){case 0:l=t.tZone;break;case 1:l=t.gZone;break;default:throw new Error("Invalid zone")}const u=a.distance(r,r,!1,!0),p=l.length-2;for(let e=0;e",i),t.stack.push(Math.round(64*i))}function xn(e,t){const n=t.stack,o=n.pop(),r=t.fv,s=t.pv,a=t.ppem,i=t.deltaBase+16*(e-1),l=t.deltaShift,c=t.z0;exports.DEBUG&&console.log(t.step,"DELTAP["+e+"]",o,n);for(let e=0;e>4)!==a)continue;let u=(15&o)-8;u>=0&&u++,exports.DEBUG&&console.log(t.step,"DELTAPFIX",e,"by",u*l);const p=c[e];r.setRelative(p,p,u*l,s)}}function Un(e,t){const n=t.stack,o=n.pop();exports.DEBUG&&console.log(t.step,"ROUND[]"),n.push(64*t.round(o/64))}function Tn(e,t){const n=t.stack,o=n.pop(),r=t.ppem,s=t.deltaBase+16*(e-1),a=t.deltaShift;exports.DEBUG&&console.log(t.step,"DELTAC["+e+"]",o,n);for(let e=0;e>4)!==r)continue;let i=(15&o)-8;i>=0&&i++;const l=i*a;exports.DEBUG&&console.log(t.step,"DELTACFIX",e,"by",l),t.cvt[e]+=l}}function En(e,t){const n=t.stack,o=n.pop(),r=n.pop(),s=t.z2[o],a=t.z1[r];let i,l;exports.DEBUG&&console.log("SDPVTL["+e+"]",o,r),e?(i=s.y-a.y,l=a.x-s.x):(i=a.x-s.x,l=a.y-s.y),t.dpv=Kt(i,l)}function On(e,t){const n=t.stack,o=t.prog;let r=t.ip;exports.DEBUG&&console.log(t.step,"PUSHB["+e+"]");for(let t=0;t=0?1:-1,m=Math.abs(m),e&&(v=s.cvt[i],o&&Math.abs(m-v)":"_")+(o?"R":"_")+(0===r?"Gr":1===r?"Bl":2===r?"Wh":"")+"]",e?i+"("+s.cvt[i]+","+v+")":"",l,"(d =",g,"->",y*m,")"),s.rp1=s.rp0,s.rp2=l,t&&(s.rp0=l)}function Rn(e){(e=e||{}).empty||(Nt(e.familyName,"When creating a new Font object, familyName is required."),Nt(e.styleName,"When creating a new Font object, styleName is required."),Nt(e.unitsPerEm,"When creating a new Font object, unitsPerEm is required."),Nt(e.ascender,"When creating a new Font object, ascender is required."),Nt(e.descender,"When creating a new Font object, descender is required."),Nt(e.descender<0,"Descender should be negative (e.g. -512)."),this.names={fontFamily:{en:e.familyName||" "},fontSubfamily:{en:e.styleName||" "},fullName:{en:e.fullName||e.familyName+" "+e.styleName},postScriptName:{en:e.postScriptName||e.familyName+e.styleName},designer:{en:e.designer||" "},designerURL:{en:e.designerURL||" "},manufacturer:{en:e.manufacturer||" "},manufacturerURL:{en:e.manufacturerURL||" "},license:{en:e.license||" "},licenseURL:{en:e.licenseURL||" "},version:{en:e.version||"Version 0.1"},description:{en:e.description||" "},copyright:{en:e.copyright||" "},trademark:{en:e.trademark||" "}},this.unitsPerEm=e.unitsPerEm||1e3,this.ascender=e.ascender,this.descender=e.descender,this.createdTimestamp=e.createdTimestamp,this.tables={os2:{usWeightClass:e.weightClass||this.usWeightClasses.MEDIUM,usWidthClass:e.widthClass||this.usWidthClasses.MEDIUM,fsSelection:e.fsSelection||this.fsSelectionValues.REGULAR}}),this.supported=!0,this.glyphs=new Ie.GlyphSet(this,e.glyphs||[]),this.encoding=new ve(this),this.substitution=new It(this),this.tables=this.tables||{},Object.defineProperty(this,"hinting",{get:function(){return this._hinting?this._hinting:"truetype"===this.outlinesFormat?this._hinting=new zt(this):void 0}})}function Dn(e,t){const n=JSON.stringify(e);let o=256;for(let e in t){let r=parseInt(e);if(r&&!(r<256)){if(JSON.stringify(t[e])===n)return r;o<=r&&(o=r+1)}}return t[o]=e,o}function Cn(e,t,n){const o=Dn(t.name,n);return[{name:"tag_"+e,type:"TAG",value:t.tag},{name:"minValue_"+e,type:"FIXED",value:t.minValue<<16},{name:"defaultValue_"+e,type:"FIXED",value:t.defaultValue<<16},{name:"maxValue_"+e,type:"FIXED",value:t.maxValue<<16},{name:"flags_"+e,type:"USHORT",value:0},{name:"nameID_"+e,type:"USHORT",value:o}]}function Ln(e,t,n){const o={},r=new pe.Parser(e,t);return o.tag=r.parseTag(),o.minValue=r.parseFixed(),o.defaultValue=r.parseFixed(),o.maxValue=r.parseFixed(),r.skip("uShort",1),o.name=n[r.parseUShort()]||{},o}function In(e,t,n,o){const r=[{name:"nameID_"+e,type:"USHORT",value:Dn(t.name,o)},{name:"flags_"+e,type:"USHORT",value:0}];for(let o=0;o2)return;const n=this.font;let o=this._prepState;if(!o||o.ppem!==t){let e=this._fpgmState;if(!e){nn.prototype=tn,e=this._fpgmState=new nn("fpgm",n.tables.fpgm),e.funcs=[],e.font=n,exports.DEBUG&&(console.log("---EXEC FPGM---"),e.step=-1);try{At(e)}catch(e){return console.log("Hinting error in FPGM:"+e),void(this._errorState=3)}}nn.prototype=e,o=this._prepState=new nn("prep",n.tables.prep),o.ppem=t;const r=n.tables.cvt;if(r){const e=o.cvt=new Array(r.length),s=t/n.unitsPerEm;for(let t=0;t1))try{return Ft(e,o)}catch(e){return this._errorState<1&&(console.log("Hinting error:"+e),console.log("Note: further hinting errors are silenced")),void(this._errorState=1)}},Ft=function(e,t){const n=t.ppem/t.font.unitsPerEm,o=n;let r,s,a,i=e.components;if(nn.prototype=t,i){const l=t.font;s=[],r=[];for(let e=0;e1?"loop "+(e.loop-n)+": ":"")+"SHPIX[]",a,r),o.setRelative(i,i,r),o.touch(i)}e.loop=1},function(e){const t=e.stack,n=e.rp1,o=e.rp2;let r=e.loop;const s=e.z0[n],a=e.z1[o],i=e.fv,l=e.dpv,c=e.z2;for(;r--;){const u=t.pop(),p=c[u];exports.DEBUG&&console.log(e.step,(e.loop>1?"loop "+(e.loop-r)+": ":"")+"IP[]",u,n,"<->",o),i.interpolate(p,s,a,l),i.touch(p)}e.loop=1},yn.bind(void 0,0),yn.bind(void 0,1),function(e){const t=e.stack,n=e.rp0,o=e.z0[n];let r=e.loop;const s=e.fv,a=e.pv,i=e.z1;for(;r--;){const n=t.pop(),l=i[n];exports.DEBUG&&console.log(e.step,(e.loop>1?"loop "+(e.loop-r)+": ":"")+"ALIGNRP[]",n),s.setRelative(l,o,0,a),s.touch(l)}e.loop=1},function(e){exports.DEBUG&&console.log(e.step,"RTDG[]"),e.round=qt},vn.bind(void 0,0),vn.bind(void 0,1),function(e){const t=e.prog;let n=e.ip;const o=e.stack,r=t[++n];exports.DEBUG&&console.log(e.step,"NPUSHB[]",r);for(let e=0;en?1:0)},function(e){const t=e.stack,n=t.pop(),o=t.pop();exports.DEBUG&&console.log(e.step,"GTEQ[]",n,o),t.push(o>=n?1:0)},function(e){const t=e.stack,n=t.pop(),o=t.pop();exports.DEBUG&&console.log(e.step,"EQ[]",n,o),t.push(n===o?1:0)},function(e){const t=e.stack,n=t.pop(),o=t.pop();exports.DEBUG&&console.log(e.step,"NEQ[]",n,o),t.push(n!==o?1:0)},function(e){const t=e.stack,n=t.pop();exports.DEBUG&&console.log(e.step,"ODD[]",n),t.push(Math.trunc(n)%2?1:0)},function(e){const t=e.stack,n=t.pop();exports.DEBUG&&console.log(e.step,"EVEN[]",n),t.push(Math.trunc(n)%2?0:1)},function(e){let t=e.stack.pop();exports.DEBUG&&console.log(e.step,"IF[]",t),t||(rn(e,!0),exports.DEBUG&&console.log(e.step,"EIF[]"))},function(e){exports.DEBUG&&console.log(e.step,"EIF[]")},function(e){const t=e.stack,n=t.pop(),o=t.pop();exports.DEBUG&&console.log(e.step,"AND[]",n,o),t.push(n&&o?1:0)},function(e){const t=e.stack,n=t.pop(),o=t.pop();exports.DEBUG&&console.log(e.step,"OR[]",n,o),t.push(n||o?1:0)},function(e){const t=e.stack,n=t.pop();exports.DEBUG&&console.log(e.step,"NOT[]",n),t.push(n?0:1)},xn.bind(void 0,1),function(e){const t=e.stack.pop();exports.DEBUG&&console.log(e.step,"SDB[]",t),e.deltaBase=t},function(e){const t=e.stack.pop();exports.DEBUG&&console.log(e.step,"SDS[]",t),e.deltaShift=Math.pow(.5,t)},function(e){const t=e.stack,n=t.pop(),o=t.pop();exports.DEBUG&&console.log(e.step,"ADD[]",n,o),t.push(o+n)},function(e){const t=e.stack,n=t.pop(),o=t.pop();exports.DEBUG&&console.log(e.step,"SUB[]",n,o),t.push(o-n)},function(e){const t=e.stack,n=t.pop(),o=t.pop();exports.DEBUG&&console.log(e.step,"DIV[]",n,o),t.push(64*o/n)},function(e){const t=e.stack,n=t.pop(),o=t.pop();exports.DEBUG&&console.log(e.step,"MUL[]",n,o),t.push(o*n/64)},function(e){const t=e.stack,n=t.pop();exports.DEBUG&&console.log(e.step,"ABS[]",n),t.push(Math.abs(n))},function(e){const t=e.stack;let n=t.pop();exports.DEBUG&&console.log(e.step,"NEG[]",n),t.push(-n)},function(e){const t=e.stack,n=t.pop();exports.DEBUG&&console.log(e.step,"FLOOR[]",n),t.push(64*Math.floor(n/64))},function(e){const t=e.stack,n=t.pop();exports.DEBUG&&console.log(e.step,"CEILING[]",n),t.push(64*Math.ceil(n/64))},Un.bind(void 0,0),Un.bind(void 0,1),Un.bind(void 0,2),Un.bind(void 0,3),void 0,void 0,void 0,void 0,function(e){const t=e.stack,n=t.pop(),o=t.pop();exports.DEBUG&&console.log(e.step,"WCVTF[]",n,o),e.cvt[o]=n*e.ppem/e.font.unitsPerEm},xn.bind(void 0,2),xn.bind(void 0,3),Tn.bind(void 0,1),Tn.bind(void 0,2),Tn.bind(void 0,3),function(e){let t,n=e.stack.pop();switch(exports.DEBUG&&console.log(e.step,"SROUND[]",n),e.round=Yt,192&n){case 0:t=.5;break;case 64:t=1;break;case 128:t=2;break;default:throw new Error("invalid SROUND value")}switch(e.srPeriod=t,48&n){case 0:e.srPhase=0;break;case 16:e.srPhase=.25*t;break;case 32:e.srPhase=.5*t;break;case 48:e.srPhase=.75*t;break;default:throw new Error("invalid SROUND value")}n&=15,e.srThreshold=0===n?0:(n/8-.5)*t},function(e){let t,n=e.stack.pop();switch(exports.DEBUG&&console.log(e.step,"S45ROUND[]",n),e.round=Yt,192&n){case 0:t=Math.sqrt(2)/2;break;case 64:t=Math.sqrt(2);break;case 128:t=2*Math.sqrt(2);break;default:throw new Error("invalid S45ROUND value")}switch(e.srPeriod=t,48&n){case 0:e.srPhase=0;break;case 16:e.srPhase=.25*t;break;case 32:e.srPhase=.5*t;break;case 48:e.srPhase=.75*t;break;default:throw new Error("invalid S45ROUND value")}n&=15,e.srThreshold=0===n?0:(n/8-.5)*t},void 0,void 0,function(e){exports.DEBUG&&console.log(e.step,"ROFF[]"),e.round=Wt},void 0,function(e){exports.DEBUG&&console.log(e.step,"RUTG[]"),e.round=Vt},function(e){exports.DEBUG&&console.log(e.step,"RDTG[]"),e.round=jt},pn,pn,void 0,void 0,void 0,void 0,void 0,function(e){const t=e.stack.pop();exports.DEBUG&&console.log(e.step,"SCANCTRL[]",t)},En.bind(void 0,0),En.bind(void 0,1),function(e){const t=e.stack,n=t.pop();let o=0;exports.DEBUG&&console.log(e.step,"GETINFO[]",n),1&n&&(o=35),32&n&&(o|=4096),t.push(o)},void 0,function(e){const t=e.stack,n=t.pop(),o=t.pop(),r=t.pop();exports.DEBUG&&console.log(e.step,"ROLL[]"),t.push(o),t.push(n),t.push(r)},function(e){const t=e.stack,n=t.pop(),o=t.pop();exports.DEBUG&&console.log(e.step,"MAX[]",n,o),t.push(Math.max(o,n))},function(e){const t=e.stack,n=t.pop(),o=t.pop();exports.DEBUG&&console.log(e.step,"MIN[]",n,o),t.push(Math.min(o,n))},function(e){const t=e.stack.pop();exports.DEBUG&&console.log(e.step,"SCANTYPE[]",t)},function(e){const t=e.stack.pop();let n=e.stack.pop();switch(exports.DEBUG&&console.log(e.step,"INSTCTRL[]",t,n),t){case 1:return void(e.inhibitGridFit=!!n);case 2:return void(e.ignoreCvt=!!n);default:throw new Error("invalid INSTCTRL[] selector")}},void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,On.bind(void 0,1),On.bind(void 0,2),On.bind(void 0,3),On.bind(void 0,4),On.bind(void 0,5),On.bind(void 0,6),On.bind(void 0,7),On.bind(void 0,8),wn.bind(void 0,1),wn.bind(void 0,2),wn.bind(void 0,3),wn.bind(void 0,4),wn.bind(void 0,5),wn.bind(void 0,6),wn.bind(void 0,7),wn.bind(void 0,8),kn.bind(void 0,0,0,0,0,0),kn.bind(void 0,0,0,0,0,1),kn.bind(void 0,0,0,0,0,2),kn.bind(void 0,0,0,0,0,3),kn.bind(void 0,0,0,0,1,0),kn.bind(void 0,0,0,0,1,1),kn.bind(void 0,0,0,0,1,2),kn.bind(void 0,0,0,0,1,3),kn.bind(void 0,0,0,1,0,0),kn.bind(void 0,0,0,1,0,1),kn.bind(void 0,0,0,1,0,2),kn.bind(void 0,0,0,1,0,3),kn.bind(void 0,0,0,1,1,0),kn.bind(void 0,0,0,1,1,1),kn.bind(void 0,0,0,1,1,2),kn.bind(void 0,0,0,1,1,3),kn.bind(void 0,0,1,0,0,0),kn.bind(void 0,0,1,0,0,1),kn.bind(void 0,0,1,0,0,2),kn.bind(void 0,0,1,0,0,3),kn.bind(void 0,0,1,0,1,0),kn.bind(void 0,0,1,0,1,1),kn.bind(void 0,0,1,0,1,2),kn.bind(void 0,0,1,0,1,3),kn.bind(void 0,0,1,1,0,0),kn.bind(void 0,0,1,1,0,1),kn.bind(void 0,0,1,1,0,2),kn.bind(void 0,0,1,1,0,3),kn.bind(void 0,0,1,1,1,0),kn.bind(void 0,0,1,1,1,1),kn.bind(void 0,0,1,1,1,2),kn.bind(void 0,0,1,1,1,3),kn.bind(void 0,1,0,0,0,0),kn.bind(void 0,1,0,0,0,1),kn.bind(void 0,1,0,0,0,2),kn.bind(void 0,1,0,0,0,3),kn.bind(void 0,1,0,0,1,0),kn.bind(void 0,1,0,0,1,1),kn.bind(void 0,1,0,0,1,2),kn.bind(void 0,1,0,0,1,3),kn.bind(void 0,1,0,1,0,0),kn.bind(void 0,1,0,1,0,1),kn.bind(void 0,1,0,1,0,2),kn.bind(void 0,1,0,1,0,3),kn.bind(void 0,1,0,1,1,0),kn.bind(void 0,1,0,1,1,1),kn.bind(void 0,1,0,1,1,2),kn.bind(void 0,1,0,1,1,3),kn.bind(void 0,1,1,0,0,0),kn.bind(void 0,1,1,0,0,1),kn.bind(void 0,1,1,0,0,2),kn.bind(void 0,1,1,0,0,3),kn.bind(void 0,1,1,0,1,0),kn.bind(void 0,1,1,0,1,1),kn.bind(void 0,1,1,0,1,2),kn.bind(void 0,1,1,0,1,3),kn.bind(void 0,1,1,1,0,0),kn.bind(void 0,1,1,1,0,1),kn.bind(void 0,1,1,1,0,2),kn.bind(void 0,1,1,1,0,3),kn.bind(void 0,1,1,1,1,0),kn.bind(void 0,1,1,1,1,1),kn.bind(void 0,1,1,1,1,2),kn.bind(void 0,1,1,1,1,3)],Rn.prototype.hasChar=function(e){return null!==this.encoding.charToGlyphIndex(e)},Rn.prototype.charToGlyphIndex=function(e){return this.encoding.charToGlyphIndex(e)},Rn.prototype.charToGlyph=function(e){const t=this.charToGlyphIndex(e);let n=this.glyphs.get(t);return n||(n=this.glyphs.get(0)),n},Rn.prototype.stringToGlyphs=function(e,t){t=t||this.defaultRenderOptions;const n=[];for(let t=0;t>1;e1&&console.warn("Only the first kern subtable is supported."),e.skip("uLong");const n=255&e.parseUShort();if(e.skip("uShort"),0===n){const n=e.parseUShort();e.skip("uShort",3);for(let o=0;o{const t=jn.loadSync(e);Qn.font=t,Qn.ascender=t.ascender,Qn.descender=t.descender}};const Kn=$n.options,Jn=function(e,t){return Math.round(e+Math.random()*(t-e))};const eo=function(e,t){return{text:(e+t).toString(),equation:e+"+"+t}},to=function(e,t){return{text:(e-t).toString(),equation:e+"-"+t}};function no(e,t,n){return 6*(n=(n+1)%1)<1?e+(t-e)*n*6:2*n<1?t:3*n<2?e+(t-e)*(2/3-n)*6:e}var oo={int:Jn,greyColor:function(e,t){const n=Jn(e=e||1,t=t||9).toString(16);return`#${n}${n}${n}`},captchaText:function(e){"number"==typeof e&&(e={size:e});const t=(e=e||{}).size||4,n=e.ignoreChars||"";let o=-1,r="",s=e.charPreset||Kn.charPreset;n&&(s=function(e,t){return e.split("").filter(e=>-1===t.indexOf(e))}(s,n));const a=s.length-1;for(;++o>16,o=t>>8&255,r=255&t,s=Math.max(n,o,r),a=Math.min(n,o,r);return(s+a)/510}(e):1;let r,s;o>=.5?(r=Math.round(100*o)-45,s=Math.round(100*o)-25):(r=Math.round(100*o)+25,s=Math.round(100*o)+45);const a=Jn(r,s)/100,i=a<.5?a*(a+n):a+n-a*n,l=2*a-i,c=Math.floor(255*no(l,i,t+1/3)),u=Math.floor(255*no(l,i,t));return"#"+(Math.floor(255*no(l,i,t-1/3))|u<<8|c<<16|1<<24).toString(16).slice(1)}};const ro=$n.options,so=function(e,t){e=e||oo.captchaText();const n=(t=Object.assign({},ro,t)).width,o=t.height,r=t.background||t.backgroundColor;r&&(t.color=!0);const s=r?``:"",a=[].concat(function(e,t,n){const o=n.color,r=[],s=n.inverse?7:1,a=n.inverse?15:9;let i=-1;for(;++i`)}return r}(n,o,t)).concat(function(e,t,n,o,r){const s=e.length,a=(t-2)/(s+1),i=o.inverse?10:0,l=o.inverse?14:4;let u=-1;const p=[],h=r||o.color?oo.color(o.background):oo.greyColor(i,l);for(;++u`)}return p}(e,n,o,t)).sort(()=>Math.random()-.5).join("");return`${``}${s}${a}`};var ao=so,io=oo.captchaText,lo=function(e){const t=e.text||oo.captchaText(e);return{text:t,data:so(t,e)}},co=function(e){const t=oo.mathExpr(e.mathMin,e.mathMax,e.mathOperator);return{text:t.text,data:so(t.equation,e)}},uo=ro,po=$n.loadFont;ao.randomText=io,ao.create=lo,ao.createMathExpr=co,ao.options=uo,ao.loadFont=po;var ho=ao;const fo=Object.prototype.toString;function go(e){return"[object Object]"===fo.call(e)}function mo(){"development"===process.env.NODE_ENV&&console.log(...arguments)}const yo=async function(){};function vo(e){return yo.constructor===e.constructor?async function(){const t=await e.apply(this,arguments);return go(t)&&(t.msg&&(t.message=t.msg,t.errMsg=t.msg),0===t.code?t.errCode=t.code:t.errCode=s[t.code]||t.code),t}:function(){const t=e.apply(this,arguments);return go(t)&&(t.msg&&(t.message=t.msg,t.errMsg=t.msg),0===t.code?t.errCode=t.code:t.errCode=s[t.code]||t.code),t}}const bo=uniCloud.database().collection("opendb-verify-codes");class So{async setVerifyCode({deviceId:e,code:t,expiresDate:n,scene:o}){if(!e)return{code:10101,msg:"deviceId不可为空"};if(!t)return{code:10102,msg:"验证码不可为空"};n||(n=180);const r=Date.now(),s={deviceId:e,scene:o,code:t.toLocaleLowerCase(),state:0,ip:__ctx__.CLIENTIP,created_date:r,expired_date:r+1e3*n};return mo("addRes",await bo.add(s)),{code:0,deviceId:e}}async verifyCode({deviceId:e,code:t,scene:n}){if(!e)return{code:10101,msg:"deviceId不可为空"};if(!t)return{code:10102,msg:"验证码不可为空"};const o=Date.now(),r={deviceId:e,scene:n,code:t.toLocaleLowerCase(),state:0},s=await bo.where(r).orderBy("created_date","desc").limit(1).get();if(mo("verifyRecord:",s),s&&s.data&&s.data.length>0){const e=s.data[0];if(e.expired_date{e.scene&&delete e.scene,this.pluginConfig.scene[n]=Object.assign({},t,e[n])})}}}{constructor(){super(),this.DEVICEID2opts={}}mergeConfig(e){const t=go(this.pluginConfig.scene)?this.pluginConfig.scene[e.scene]:e.scene;return Object.assign({},go(t)?t:this.pluginConfig,e)}async create(e={}){if(!e.scene)throw new Error("scene验证码场景不可为空");e=this.mergeConfig(e);let{scene:t,expiresDate:n,deviceId:o,...r}=e;if(o=o||__ctx__.DEVICEID,!o)throw new Error("deviceId不可为空");const s=new So;try{const{text:a,base64:i}=function(e={}){const{uniPlatform:t=""}=e;let n;n=e.mathExpr?ho.createMathExpr(e):ho.create(e);let o="data:image/svg+xml;utf8,"+n.data.replace(/#/g,"%23");return(!t||"string"==typeof t&&-1===t.indexOf("mp-"))&&(o=o.replace(/"/g,"'").replace(//g,"%3E")),{text:n.text,base64:o}}(r),l=await s.setVerifyCode({deviceId:o,code:a,expiresDate:n,scene:t});return l.code>0?{...l,code:10001}:(this.DEVICEID2opts[o]=e,{code:0,msg:"验证码获取成功",captchaBase64:i})}catch(e){return{code:10001,msg:"验证码生成失败:"+e.message}}}async verify({deviceId:e,captcha:t,scene:n}){if(!(e=e||__ctx__.DEVICEID))throw new Error("deviceId不可为空");if(!n)throw new Error("scene验证码场景不可为空");const o=new So;try{const r=await o.verifyCode({deviceId:e,code:t,scene:n});return r.code>0?r:{code:0,msg:"验证码通过"}}catch(e){return{code:10002,msg:"验证码校验失败:"+e.message}}}async refresh(e={}){let{scene:t,expiresDate:n,deviceId:o,...r}=e;if(o=o||__ctx__.DEVICEID,!o)throw new Error("deviceId不可为空");if(!t)throw new Error("scene验证码场景不可为空");const s=await bo.where({deviceId:o,scene:t}).orderBy("created_date","desc").limit(1).get();if(s&&s.data&&s.data.length>0){const e=s.data[0];await bo.doc(e._id).update({state:2}),Object.keys(r).length>0&&(this.DEVICEID2opts[o]=Object.assign({},this.DEVICEID2opts[o],r));let a={};try{a=await this.create(Object.assign({},this.DEVICEID2opts[o],{deviceId:o,scene:t,expiresDate:n}))}catch(e){return{code:50403,msg:e.message}}return a.code>0?{...a,code:50403}:{code:0,msg:"验证码刷新成功",captchaBase64:a.captchaBase64}}return{code:10003,msg:`验证码刷新失败:无此设备在 ${t} 场景信息,请重新获取`}}}const To=new So;Object.keys(To).forEach(e=>{Uo.prototype[e]=vo(To[e])});const Eo=new Uo,Oo=new Proxy(Eo,{get(e,t){if(t in e)return"function"==typeof e[t]?vo(e[t]).bind(Oo):e[t]}});module.exports=Oo; diff --git a/uni_modules/uni-config-center/uniCloud/cloudfunctions/common/uni-config-center/uni-id/config.json b/uni_modules/uni-config-center/uniCloud/cloudfunctions/common/uni-config-center/uni-id/config.json index 0ca24756223dd772d40482b3359b64242551fa64..c845533061f84d8eeaea9753aeee3dbf61f65f7f 100644 --- a/uni_modules/uni-config-center/uniCloud/cloudfunctions/common/uni-config-center/uni-id/config.json +++ b/uni_modules/uni-config-center/uniCloud/cloudfunctions/common/uni-config-center/uni-id/config.json @@ -1,53 +1,53 @@ -{ - "passwordSecret": "passwordSecret-demo", - "tokenSecret": "tokenSecret-demo", - "tokenExpiresIn": 7200, - "tokenExpiresThreshold": 600, - "passwordErrorLimit": 6, - "bindTokenToDevice": false, - "passwordErrorRetryTime": 3600, - "autoSetInviteCode": false, - "forceInviteCode": false, - "preferedAppPlatform": "app", - "app": { - "tokenExpiresIn": 2592000, - "oauth": { - "weixin": { - "appid": "填写来源微信开放平台https://open.weixin.qq.com/创建的应用的appid", - "appsecret": "填写来源微信开放平台https://open.weixin.qq.com/创建的应用的appsecret" - }, - "apple": { - "bundleId": "苹果开发者后台获取的bundleId" - } - } - }, - "mp-weixin": { - "oauth": { - "weixin": { - "appid": "微信小程序登录所用的appid、appsecret需要在对应的小程序管理控制台获取", - "appsecret": "微信小程序后台获取的appsecret" - } - } - }, - "mp-alipay": { - "oauth": { - "alipay": { - "appid": "支付宝小程序登录用到的appid、privateKey请参考支付宝小程序的文档进行设置或者获取,https://opendocs.alipay.com/open/291/105971#LDsXr", - "privateKey": "支付宝小程序登录用到的appid、privateKey请参考支付宝小程序的文档进行设置或者获取,https://opendocs.alipay.com/open/291/105971#LDsXr" - } - } - }, - "service": { - "sms": { - "name": "应用名称,对应短信模版的name", - "codeExpiresIn": 300, - "smsKey": "短信密钥key,开通短信服务处可以看到", - "smsSecret": "短信密钥secret,开通短信服务处可以看到" - }, - "univerify": { - "appid": "当前应用的appid,使用云函数URL化,此项必须配置", - "apiKey": "apiKey 和 apiSecret 在开发者中心获取,开发者中心:https://dev.dcloud.net.cn/uniLogin/index?type=0,文档:https://ask.dcloud.net.cn/article/37965", - "apiSecret": "" - } - } +{ + "passwordSecret": "passwordSecret-demo", + "tokenSecret": "tokenSecret-demo", + "tokenExpiresIn": 7200, + "tokenExpiresThreshold": 600, + "passwordErrorLimit": 6, + "bindTokenToDevice": false, + "passwordErrorRetryTime": 3600, + "autoSetInviteCode": true, + "forceInviteCode": false, + "preferedAppPlatform": "app", + "app": { + "tokenExpiresIn": 2592000, + "oauth": { + "weixin": { + "appid": "填写来源微信开放平台https://open.weixin.qq.com/创建的应用的appid", + "appsecret": "填写来源微信开放平台https://open.weixin.qq.com/创建的应用的appsecret" + }, + "apple": { + "bundleId": "苹果开发者后台获取的bundleId" + } + } + }, + "mp-weixin": { + "oauth": { + "weixin": { + "appid": "微信小程序登录所用的appid、appsecret需要在对应的小程序管理控制台获取", + "appsecret": "微信小程序后台获取的appsecret" + } + } + }, + "mp-alipay": { + "oauth": { + "alipay": { + "appid": "支付宝小程序登录用到的appid、privateKey请参考支付宝小程序的文档进行设置或者获取,https://opendocs.alipay.com/open/291/105971#LDsXr", + "privateKey": "支付宝小程序登录用到的appid、privateKey请参考支付宝小程序的文档进行设置或者获取,https://opendocs.alipay.com/open/291/105971#LDsXr" + } + } + }, + "service": { + "sms": { + "name": "应用名称,对应短信模版的name", + "codeExpiresIn": 300, + "smsKey": "短信密钥key,开通短信服务处可以看到", + "smsSecret": "短信密钥secret,开通短信服务处可以看到" + }, + "univerify": { + "appid": "当前应用的appid,使用云函数URL化,此项必须配置", + "apiKey": "apiKey 和 apiSecret 在开发者中心获取,开发者中心:https://dev.dcloud.net.cn/uniLogin/index?type=0,文档:https://ask.dcloud.net.cn/article/37965", + "apiSecret": "" + } + } } \ No newline at end of file diff --git a/uni_modules/uni-data-checkbox/changelog.md b/uni_modules/uni-data-checkbox/changelog.md index d8f420b9a6cfec68b7fd755ab516f26f8f2dfd39..dbc517a30f8049120442d0c9e1eb0034b04fa940 100644 --- a/uni_modules/uni-data-checkbox/changelog.md +++ b/uni_modules/uni-data-checkbox/changelog.md @@ -1,3 +1,5 @@ +## 1.0.2(2022-06-30) +- 优化 在 uni-forms 中的依赖注入方式 ## 1.0.1(2022-02-07) - 修复 multiple 为 true 时,v-model 的值为 null 报错的 bug ## 1.0.0(2021-11-19) diff --git a/uni_modules/uni-data-checkbox/components/uni-data-checkbox/uni-data-checkbox.vue b/uni_modules/uni-data-checkbox/components/uni-data-checkbox/uni-data-checkbox.vue index 300cb5fe6e7e31a60b2bc2c9a15b48dc15ac4315..eb3ae3f8d5962cbe8e28cff0afc75e167fc46680 100644 --- a/uni_modules/uni-data-checkbox/components/uni-data-checkbox/uni-data-checkbox.vue +++ b/uni_modules/uni-data-checkbox/components/uni-data-checkbox/uni-data-checkbox.vue @@ -155,17 +155,17 @@ value(newVal) { this.dataList = this.getDataList(newVal) // fix by mehaotian is_reset 在 uni-forms 中定义 - if(!this.is_reset){ - this.is_reset = false - this.formItem && this.formItem.setValue(newVal) - } + // if(!this.is_reset){ + // this.is_reset = false + // this.formItem && this.formItem.setValue(newVal) + // } }, modelValue(newVal) { this.dataList = this.getDataList(newVal); - if(!this.is_reset){ - this.is_reset = false - this.formItem && this.formItem.setValue(newVal) - } + // if(!this.is_reset){ + // this.is_reset = false + // this.formItem && this.formItem.setValue(newVal) + // } } }, data() { @@ -193,22 +193,22 @@ } }, created() { - this.form = this.getForm('uniForms') - this.formItem = this.getForm('uniFormsItem') + // this.form = this.getForm('uniForms') + // this.formItem = this.getForm('uniFormsItem') // this.formItem && this.formItem.setValue(this.value) - if (this.formItem) { - this.isTop = 6 - if (this.formItem.name) { - // 如果存在name添加默认值,否则formData 中不存在这个字段不校验 - if(!this.is_reset){ - this.is_reset = false - this.formItem.setValue(this.dataValue) - } - this.rename = this.formItem.name - this.form.inputChildrens.push(this) - } - } + // if (this.formItem) { + // this.isTop = 6 + // if (this.formItem.name) { + // // 如果存在name添加默认值,否则formData 中不存在这个字段不校验 + // if(!this.is_reset){ + // this.is_reset = false + // this.formItem.setValue(this.dataValue) + // } + // this.rename = this.formItem.name + // this.form.inputChildrens.push(this) + // } + // } if (this.localdata && this.localdata.length !== 0) { this.isLocal = true @@ -273,7 +273,7 @@ } } } - this.formItem && this.formItem.setValue(detail.value) + // this.formItem && this.formItem.setValue(detail.value) // TODO 兼容 vue2 this.$emit('input', detail.value); // // TOTO 兼容 vue3 @@ -375,7 +375,7 @@ selectedArr.push(item[this.map.value]) } }) - return this.dataValue && this.dataValue.length > 0 ? this.dataValue : selectedArr + return this.dataValue.length > 0 ? this.dataValue : selectedArr }, /** diff --git a/uni_modules/uni-data-checkbox/package.json b/uni_modules/uni-data-checkbox/package.json index 64131e75f154b001c2135463a93f064a194c564a..51470a956872d2e6bd39c02d79f11d51f8f577ae 100644 --- a/uni_modules/uni-data-checkbox/package.json +++ b/uni_modules/uni-data-checkbox/package.json @@ -1,7 +1,7 @@ { "id": "uni-data-checkbox", "displayName": "uni-data-checkbox 数据选择器", - "version": "1.0.1", + "version": "1.0.2", "description": "通过数据驱动的单选框和复选框", "keywords": [ "uni-ui", diff --git a/uni_modules/uni-easyinput/changelog.md b/uni_modules/uni-easyinput/changelog.md index 030162eefb426a38de2ecc78ef3988b78f0c522c..1e8c6f91be4e19a739cd4935c8615387bd746db6 100644 --- a/uni_modules/uni-easyinput/changelog.md +++ b/uni_modules/uni-easyinput/changelog.md @@ -1,31 +1,47 @@ +## 1.1.0(2022-06-30) +- 新增 在 uni-forms 1.4.0 中使用可以在 blur 时校验内容 +- 新增 clear 事件,点击右侧叉号图标触发 +- 新增 change 事件 ,仅在输入框失去焦点或用户按下回车时触发 +- 优化 组件样式,组件获取焦点时高亮显示,图标颜色调整等 +- +## 1.0.5(2022-06-07) +- 优化 clearable 显示策略 +## 1.0.4(2022-06-07) +- 优化 clearable 显示策略 +## 1.0.3(2022-05-20) +- 修复 关闭图标某些情况下无法取消的bug +## 1.0.2(2022-04-12) +- 修复 默认值不生效的bug +## 1.0.1(2022-04-02) +- 修复 value不能为0的bug ## 1.0.0(2021-11-19) - 优化 组件UI,并提供设计资源,详见:[https://uniapp.dcloud.io/component/uniui/resource](https://uniapp.dcloud.io/component/uniui/resource) - 文档迁移,详见:[https://uniapp.dcloud.io/component/uniui/uni-easyinput](https://uniapp.dcloud.io/component/uniui/uni-easyinput) -## 0.1.4(2021-08-20) -- 修复 在 uni-forms 的动态表单中默认值校验不通过的 bug -## 0.1.3(2021-08-11) -- 修复 在 uni-forms 中重置表单,错误信息无法清除的问题 -## 0.1.2(2021-07-30) -- 优化 vue3下事件警告的问题 -## 0.1.1 -- 优化 errorMessage 属性支持 Boolean 类型 -## 0.1.0(2021-07-13) -- 组件兼容 vue3,如何创建vue3项目,详见 [uni-app 项目支持 vue3 介绍](https://ask.dcloud.net.cn/article/37834) -## 0.0.16(2021-06-29) -- 修复 confirmType 属性(仅 type="text" 生效)导致多行文本框无法换行的 bug -## 0.0.15(2021-06-21) -- 修复 passwordIcon 属性拼写错误的 bug -## 0.0.14(2021-06-18) -- 新增 passwordIcon 属性,当type=password时是否显示小眼睛图标 -- 修复 confirmType 属性不生效的问题 -## 0.0.13(2021-06-04) -- 修复 disabled 状态可清出内容的 bug -## 0.0.12(2021-05-12) -- 新增 组件示例地址 -## 0.0.11(2021-05-07) -- 修复 input-border 属性不生效的问题 -## 0.0.10(2021-04-30) -- 修复 ios 遮挡文字、显示一半的问题 -## 0.0.9(2021-02-05) -- 调整为uni_modules目录规范 -- 优化 兼容 nvue 页面 +## 0.1.4(2021-08-20) +- 修复 在 uni-forms 的动态表单中默认值校验不通过的 bug +## 0.1.3(2021-08-11) +- 修复 在 uni-forms 中重置表单,错误信息无法清除的问题 +## 0.1.2(2021-07-30) +- 优化 vue3下事件警告的问题 +## 0.1.1 +- 优化 errorMessage 属性支持 Boolean 类型 +## 0.1.0(2021-07-13) +- 组件兼容 vue3,如何创建vue3项目,详见 [uni-app 项目支持 vue3 介绍](https://ask.dcloud.net.cn/article/37834) +## 0.0.16(2021-06-29) +- 修复 confirmType 属性(仅 type="text" 生效)导致多行文本框无法换行的 bug +## 0.0.15(2021-06-21) +- 修复 passwordIcon 属性拼写错误的 bug +## 0.0.14(2021-06-18) +- 新增 passwordIcon 属性,当type=password时是否显示小眼睛图标 +- 修复 confirmType 属性不生效的问题 +## 0.0.13(2021-06-04) +- 修复 disabled 状态可清出内容的 bug +## 0.0.12(2021-05-12) +- 新增 组件示例地址 +## 0.0.11(2021-05-07) +- 修复 input-border 属性不生效的问题 +## 0.0.10(2021-04-30) +- 修复 ios 遮挡文字、显示一半的问题 +## 0.0.9(2021-02-05) +- 调整为uni_modules目录规范 +- 优化 兼容 nvue 页面 diff --git a/uni_modules/uni-easyinput/components/uni-easyinput/uni-easyinput.vue b/uni_modules/uni-easyinput/components/uni-easyinput/uni-easyinput.vue index bf25b7bb4fd46ecf3ce8255aa37233ebfbdffef2..d129ce15b9d366ee17004cbab51964cb5437c752 100644 --- a/uni_modules/uni-easyinput/components/uni-easyinput/uni-easyinput.vue +++ b/uni_modules/uni-easyinput/components/uni-easyinput/uni-easyinput.vue @@ -1,40 +1,41 @@ - - diff --git a/uni_modules/uni-easyinput/package.json b/uni_modules/uni-easyinput/package.json index 912b837571bfbb2c09c1e064b74b8165e9793ca4..3cc793e6132002e2fd4aceb5567e2ca34d54c58d 100644 --- a/uni_modules/uni-easyinput/package.json +++ b/uni_modules/uni-easyinput/package.json @@ -1,90 +1,90 @@ -{ - "id": "uni-easyinput", - "displayName": "uni-easyinput 增强输入框", - "version": "1.0.0", - "description": "Easyinput 组件是对原生input组件的增强", - "keywords": [ - "uni-ui", - "uniui", - "input", - "uni-easyinput", - "输入框" -], - "repository": "https://github.com/dcloudio/uni-ui", - "engines": { - "HBuilderX": "" - }, - "directories": { - "example": "../../temps/example_temps" - }, - "dcloudext": { - "category": [ - "前端组件", - "通用组件" - ], - "sale": { - "regular": { - "price": "0.00" - }, - "sourcecode": { - "price": "0.00" - } - }, - "contact": { - "qq": "" - }, - "declaration": { - "ads": "无", - "data": "无", - "permissions": "无" - }, - "npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui" - }, - "uni_modules": { +{ + "id": "uni-easyinput", + "displayName": "uni-easyinput 增强输入框", + "version": "1.1.0", + "description": "Easyinput 组件是对原生input组件的增强", + "keywords": [ + "uni-ui", + "uniui", + "input", + "uni-easyinput", + "输入框" +], + "repository": "https://github.com/dcloudio/uni-ui", + "engines": { + "HBuilderX": "" + }, + "directories": { + "example": "../../temps/example_temps" + }, + "dcloudext": { + "category": [ + "前端组件", + "通用组件" + ], + "sale": { + "regular": { + "price": "0.00" + }, + "sourcecode": { + "price": "0.00" + } + }, + "contact": { + "qq": "" + }, + "declaration": { + "ads": "无", + "data": "无", + "permissions": "无" + }, + "npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui" + }, + "uni_modules": { "dependencies": [ - "uni-scss", - "uni-icons" - ], - "encrypt": [], - "platforms": { - "cloud": { - "tcb": "y", - "aliyun": "y" - }, - "client": { - "App": { - "app-vue": "y", - "app-nvue": "y" - }, - "H5-mobile": { - "Safari": "y", - "Android Browser": "y", - "微信浏览器(Android)": "y", - "QQ浏览器(Android)": "y" - }, - "H5-pc": { - "Chrome": "y", - "IE": "y", - "Edge": "y", - "Firefox": "y", - "Safari": "y" - }, - "小程序": { - "微信": "y", - "阿里": "y", - "百度": "y", - "字节跳动": "y", - "QQ": "y" - }, - "快应用": { - "华为": "u", - "联盟": "u" - }, - "Vue": { - "vue2": "y", - "vue3": "y" - } - } - } - } + "uni-scss", + "uni-icons" + ], + "encrypt": [], + "platforms": { + "cloud": { + "tcb": "y", + "aliyun": "y" + }, + "client": { + "App": { + "app-vue": "y", + "app-nvue": "y" + }, + "H5-mobile": { + "Safari": "y", + "Android Browser": "y", + "微信浏览器(Android)": "y", + "QQ浏览器(Android)": "y" + }, + "H5-pc": { + "Chrome": "y", + "IE": "y", + "Edge": "y", + "Firefox": "y", + "Safari": "y" + }, + "小程序": { + "微信": "y", + "阿里": "y", + "百度": "y", + "字节跳动": "y", + "QQ": "y" + }, + "快应用": { + "华为": "u", + "联盟": "u" + }, + "Vue": { + "vue2": "y", + "vue3": "y" + } + } + } + } } \ No newline at end of file diff --git a/uni_modules/uni-forms/changelog.md b/uni_modules/uni-forms/changelog.md index 26e120b5c0878e5d3bc2916063da30603f3c87a7..c358a21abbe9d9c871febe80fb8b141f23561e1d 100644 --- a/uni_modules/uni-forms/changelog.md +++ b/uni_modules/uni-forms/changelog.md @@ -1,3 +1,33 @@ +## 1.4.8(2022-08-23) +- 优化 根据 rules 自动添加 required 的问题 +## 1.4.7(2022-08-22) +- 修复 item 未设置 require 属性,rules 设置 require 后,星号也显示的 bug,详见:[https://ask.dcloud.net.cn/question/151540](https://ask.dcloud.net.cn/question/151540) +## 1.4.6(2022-07-13) +- 修复 model 需要校验的值没有声明对应字段时,导致第一次不触发校验的bug +## 1.4.5(2022-07-05) +- 新增 更多表单示例 +- 优化 子表单组件过期提示的问题 +- 优化 子表单组件uni-datetime-picker、uni-data-select、uni-data-picker的显示样式 +## 1.4.4(2022-07-04) +- 更新 删除组件日志 +## 1.4.3(2022-07-04) +- 修复 由 1.4.0 引发的 label 插槽不生效的bug +## 1.4.2(2022-07-04) +- 修复 子组件找不到 setValue 报错的bug +## 1.4.1(2022-07-04) +- 修复 uni-data-picker 在 uni-forms-item 中报错的bug +- 修复 uni-data-picker 在 uni-forms-item 中宽度不正确的bug +## 1.4.0(2022-06-30) +- 【重要】组件逻辑重构,部分用法用旧版本不兼容,请注意兼容问题 +- 【重要】组件使用 Provide/Inject 方式注入依赖,提供了自定义表单组件调用 uni-forms 校验表单的能力 +- 新增 model 属性,等同于原 value/modelValue 属性,旧属性即将废弃 +- 新增 validateTrigger 属性的 blur 值,仅 uni-easyinput 生效 +- 新增 onFieldChange 方法,可以对子表单进行校验,可替代binddata方法 +- 新增 子表单的 setRules 方法,配合自定义校验函数使用 +- 新增 uni-forms-item 的 setRules 方法,配置动态表单使用可动态更新校验规则 +- 优化 动态表单校验方式,废弃拼接name的方式 +## 1.3.3(2022-06-22) +- 修复 表单校验顺序无序问题 ## 1.3.2(2021-12-09) - ## 1.3.1(2021-11-19) diff --git a/uni_modules/uni-forms/components/uni-forms-item/uni-forms-item.vue b/uni_modules/uni-forms/components/uni-forms-item/uni-forms-item.vue index 679b12f9349692459f9fcce0932668a43a5dfa90..349ee7012350798a177b7ec94a5b9be3bfd4ef42 100644 --- a/uni_modules/uni-forms/components/uni-forms-item/uni-forms-item.vue +++ b/uni_modules/uni-forms/components/uni-forms-item/uni-forms-item.vue @@ -1,213 +1,325 @@ - diff --git a/uni_modules/uni-forms/components/uni-forms/uni-forms.vue b/uni_modules/uni-forms/components/uni-forms/uni-forms.vue index dff823bb09d7681708bfe3f1be932dcdfb09efe0..21aee1a4605ef58b757af2c66645ae16164b098f 100644 --- a/uni_modules/uni-forms/components/uni-forms/uni-forms.vue +++ b/uni_modules/uni-forms/components/uni-forms/uni-forms.vue @@ -1,13 +1,27 @@ - + diff --git a/uni_modules/uni-forms/components/uni-forms/utils.js b/uni_modules/uni-forms/components/uni-forms/utils.js new file mode 100644 index 0000000000000000000000000000000000000000..31d57f41031ee6b5ebd01d0a091a17611ae270c3 --- /dev/null +++ b/uni_modules/uni-forms/components/uni-forms/utils.js @@ -0,0 +1,293 @@ +/** + * 简单处理对象拷贝 + * @param {Obejct} 被拷贝对象 + * @@return {Object} 拷贝对象 + */ +export const deepCopy = (val) => { + return JSON.parse(JSON.stringify(val)) +} +/** + * 过滤数字类型 + * @param {String} format 数字类型 + * @@return {Boolean} 返回是否为数字类型 + */ +export const typeFilter = (format) => { + return format === 'int' || format === 'double' || format === 'number' || format === 'timestamp'; +} + +/** + * 把 value 转换成指定的类型,用于处理初始值,原因是初始值需要入库不能为 undefined + * @param {String} key 字段名 + * @param {any} value 字段值 + * @param {Object} rules 表单校验规则 + */ +export const getValue = (key, value, rules) => { + const isRuleNumType = rules.find(val => val.format && typeFilter(val.format)); + const isRuleBoolType = rules.find(val => (val.format && val.format === 'boolean') || val.format === 'bool'); + // 输入类型为 number + if (!!isRuleNumType) { + if (!value && value !== 0) { + value = null + } else { + value = isNumber(Number(value)) ? Number(value) : value + } + } + + // 输入类型为 boolean + if (!!isRuleBoolType) { + value = isBoolean(value) ? value : false + } + + return value; +} + +/** + * 获取表单数据 + * @param {String|Array} name 真实名称,需要使用 realName 获取 + * @param {Object} data 原始数据 + * @param {any} value 需要设置的值 + */ +export const setDataValue = (field, formdata, value) => { + formdata[field] = value + return value || '' +} + +/** + * 获取表单数据 + * @param {String|Array} field 真实名称,需要使用 realName 获取 + * @param {Object} data 原始数据 + */ +export const getDataValue = (field, data) => { + return objGet(data, field) +} + +/** + * 获取表单类型 + * @param {String|Array} field 真实名称,需要使用 realName 获取 + */ +export const getDataValueType = (field, data) => { + const value = getDataValue(field, data) + return { + type: type(value), + value + } +} + +/** + * 获取表单可用的真实name + * @param {String|Array} name 表单name + * @@return {String} 表单可用的真实name + */ +export const realName = (name, data = {}) => { + const base_name = _basePath(name) + if (typeof base_name === 'object' && Array.isArray(base_name) && base_name.length > 1) { + const realname = base_name.reduce((a, b) => a += `#${b}`, '_formdata_') + return realname + } + return base_name[0] || name +} + +/** + * 判断是否表单可用的真实name + * @param {String|Array} name 表单name + * @@return {String} 表单可用的真实name + */ +export const isRealName = (name) => { + const reg = /^_formdata_#*/ + return reg.test(name) +} + +/** + * 获取表单数据的原始格式 + * @@return {Object|Array} object 需要解析的数据 + */ +export const rawData = (object = {}, name) => { + let newData = JSON.parse(JSON.stringify(object)) + let formData = {} + for(let i in newData){ + let path = name2arr(i) + objSet(formData,path,newData[i]) + } + return formData +} + +/** + * 真实name还原为 array + * @param {*} name + */ +export const name2arr = (name) => { + let field = name.replace('_formdata_#', '') + field = field.split('#').map(v => (isNumber(v) ? Number(v) : v)) + return field +} + +/** + * 对象中设置值 + * @param {Object|Array} object 源数据 + * @param {String| Array} path 'a.b.c' 或 ['a',0,'b','c'] + * @param {String} value 需要设置的值 + */ +export const objSet = (object, path, value) => { + if (typeof object !== 'object') return object; + _basePath(path).reduce((o, k, i, _) => { + if (i === _.length - 1) { + // 若遍历结束直接赋值 + o[k] = value + return null + } else if (k in o) { + // 若存在对应路径,则返回找到的对象,进行下一次遍历 + return o[k] + } else { + // 若不存在对应路径,则创建对应对象,若下一路径是数字,新对象赋值为空数组,否则赋值为空对象 + o[k] = /^[0-9]{1,}$/.test(_[i + 1]) ? [] : {} + return o[k] + } + }, object) + // 返回object + return object; +} + +// 处理 path, path有三种形式:'a[0].b.c'、'a.0.b.c' 和 ['a','0','b','c'],需要统一处理成数组,便于后续使用 +function _basePath(path) { + // 若是数组,则直接返回 + if (Array.isArray(path)) return path + // 若有 '[',']',则替换成将 '[' 替换成 '.',去掉 ']' + return path.replace(/\[/g, '.').replace(/\]/g, '').split('.') +} + +/** + * 从对象中获取值 + * @param {Object|Array} object 源数据 + * @param {String| Array} path 'a.b.c' 或 ['a',0,'b','c'] + * @param {String} defaultVal 如果无法从调用链中获取值的默认值 + */ +export const objGet = (object, path, defaultVal = 'undefined') => { + // 先将path处理成统一格式 + let newPath = _basePath(path) + // 递归处理,返回最后结果 + let val = newPath.reduce((o, k) => { + return (o || {})[k] + }, object); + return !val || val !== undefined ? val : defaultVal +} + + +/** + * 是否为 number 类型 + * @param {any} num 需要判断的值 + * @return {Boolean} 是否为 number + */ +export const isNumber = (num) => { + return !isNaN(Number(num)) +} + +/** + * 是否为 boolean 类型 + * @param {any} bool 需要判断的值 + * @return {Boolean} 是否为 boolean + */ +export const isBoolean = (bool) => { + return (typeof bool === 'boolean') +} +/** + * 是否有必填字段 + * @param {Object} rules 规则 + * @return {Boolean} 是否有必填字段 + */ +export const isRequiredField = (rules) => { + let isNoField = false; + for (let i = 0; i < rules.length; i++) { + const ruleData = rules[i]; + if (ruleData.required) { + isNoField = true; + break; + } + } + return isNoField; +} + + +/** + * 获取数据类型 + * @param {Any} obj 需要获取数据类型的值 + */ +export const type = (obj) => { + var class2type = {}; + + // 生成class2type映射 + "Boolean Number String Function Array Date RegExp Object Error".split(" ").map(function(item, index) { + class2type["[object " + item + "]"] = item.toLowerCase(); + }) + if (obj == null) { + return obj + ""; + } + return typeof obj === "object" || typeof obj === "function" ? + class2type[Object.prototype.toString.call(obj)] || "object" : + typeof obj; +} + +/** + * 判断两个值是否相等 + * @param {any} a 值 + * @param {any} b 值 + * @return {Boolean} 是否相等 + */ +export const isEqual = (a, b) => { + //如果a和b本来就全等 + if (a === b) { + //判断是否为0和-0 + return a !== 0 || 1 / a === 1 / b; + } + //判断是否为null和undefined + if (a == null || b == null) { + return a === b; + } + //接下来判断a和b的数据类型 + var classNameA = toString.call(a), + classNameB = toString.call(b); + //如果数据类型不相等,则返回false + if (classNameA !== classNameB) { + return false; + } + //如果数据类型相等,再根据不同数据类型分别判断 + switch (classNameA) { + case '[object RegExp]': + case '[object String]': + //进行字符串转换比较 + return '' + a === '' + b; + case '[object Number]': + //进行数字转换比较,判断是否为NaN + if (+a !== +a) { + return +b !== +b; + } + //判断是否为0或-0 + return +a === 0 ? 1 / +a === 1 / b : +a === +b; + case '[object Date]': + case '[object Boolean]': + return +a === +b; + } + //如果是对象类型 + if (classNameA == '[object Object]') { + //获取a和b的属性长度 + var propsA = Object.getOwnPropertyNames(a), + propsB = Object.getOwnPropertyNames(b); + if (propsA.length != propsB.length) { + return false; + } + for (var i = 0; i < propsA.length; i++) { + var propName = propsA[i]; + //如果对应属性对应值不相等,则返回false + if (a[propName] !== b[propName]) { + return false; + } + } + return true; + } + //如果是数组类型 + if (classNameA == '[object Array]') { + if (a.toString() == b.toString()) { + return true; + } + return false; + } +} diff --git a/uni_modules/uni-forms/package.json b/uni_modules/uni-forms/package.json index dfa7af4c459063564c2ad3942a96a79503e6a905..e3736c45357f4a5f8061a1d0aeea79e89c7f6a1e 100644 --- a/uni_modules/uni-forms/package.json +++ b/uni_modules/uni-forms/package.json @@ -1,7 +1,7 @@ { "id": "uni-forms", "displayName": "uni-forms 表单", - "version": "1.3.2", + "version": "1.4.8", "description": "由输入框、选择器、单选框、多选框等控件组成,用以收集、校验、提交数据", "keywords": [ "uni-ui", @@ -17,11 +17,7 @@ "directories": { "example": "../../temps/example_temps" }, - "dcloudext": { - "category": [ - "前端组件", - "通用组件" - ], +"dcloudext": { "sale": { "regular": { "price": "0.00" @@ -38,7 +34,8 @@ "data": "无", "permissions": "无" }, - "npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui" + "npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui", + "type": "component-vue" }, "uni_modules": { "dependencies": [ @@ -74,7 +71,8 @@ "阿里": "y", "百度": "y", "字节跳动": "y", - "QQ": "y" + "QQ": "y", + "京东": "u" }, "快应用": { "华为": "u", diff --git a/uni_modules/uni-id-cf/uniCloud/cloudfunctions/uni-id-cf/index.js b/uni_modules/uni-id-cf/uniCloud/cloudfunctions/uni-id-cf/index.js deleted file mode 100644 index 393afb2bc0c6beca1c4dba1767416173d7a05115..0000000000000000000000000000000000000000 --- a/uni_modules/uni-id-cf/uniCloud/cloudfunctions/uni-id-cf/index.js +++ /dev/null @@ -1,766 +0,0 @@ -'use strict'; -let uniID = require('uni-id') -const uniCaptcha = require('uni-captcha') -const createConfig = require('uni-config-center') -const uniIdConfig = createConfig({ - pluginId: 'uni-id' -}).config() -const db = uniCloud.database() -const dbCmd = db.command -const usersDB = db.collection('uni-id-users') -const deviceDB = db.collection('uni-id-device') -exports.main = async (event, context) => { - console.log({ - context - }); - //UNI_WYQ:这里的uniID换成新的,保证多人访问不会冲突 - uniID = uniID.createInstance({ - context - }) - console.log('event : ' + JSON.stringify(event)) - /* - 1.event为客户端 uniCloud.callFunction填写的data的值,这里介绍一下其中的属性 - action:表示要执行的任务名称、比如:登录login、退出登录 logout等 - params:业务数据内容 - uniIdToken:系统自动传递的token,数据来源客户端的 uni.getStorageSync('uni_id_token') - */ - const { - action, - uniIdToken, - inviteCode - } = event; - const deviceInfo = event.deviceInfo || {}; - let params = event.params || {}, - tokenExpired,needCaptcha; - /* - 2.在某些操作之前我们要对用户对身份进行校验(也就是要检查用户的token)再将得到的uid写入params.uid - 校验用到的方法是uniID.checkToken 详情:https://uniapp.dcloud.io/uniCloud/uni-id?id=checktoken - 讨论,我们假设一个这样的场景,代码如下。 - 如: - uniCloud.callFunction({ - name:"xxx", - data:{ - "params":{ - uid:"通过某种方式获取来的别人的uid" - } - } - }) - 用户就这样轻易地伪造了他人的uid传递给服务端,有一句话叫:前端传来的数据都是不可信任的 - 所以这里我们需要将uniID.checkToken返回的uid写入到params.uid - */ - let noCheckAction = ['register', 'checkToken', 'login', 'logout', 'sendSmsCode', 'getNeedCaptcha', - 'createCaptcha', 'verifyCaptcha', 'refreshCaptcha', 'inviteLogin', 'loginByWeixin', - 'loginByUniverify', 'loginByApple', 'loginBySms', 'resetPwdBySmsCode', 'registerAdmin' - ] - if (!noCheckAction.includes(action)) { - if (!uniIdToken) { - return { - code: 403, - msg: '缺少token' - } - } - let payload = await uniID.checkToken(uniIdToken) - if (payload.code && payload.code > 0) { - return payload - } - params.uid = payload.uid - tokenExpired = payload.tokenExpired - } - - //禁止前台用户传递角色 - if (action.slice(0, 7) == "loginBy") { - if (params.role) { - return { - code: 403, - msg: '禁止前台用户传递角色' - } - } - } - - // 3.注册成功后触发。 - async function registerSuccess(res) { - //用户接受邀请 - if (inviteCode) { - await uniID.acceptInvite({ - inviteCode, - uid - }); - } - //添加当前用户设备信息 - await addDeviceInfo(res) - } - //4.记录成功登录的日志方法 - const uniIdLog = async (res = {}) => { - const now = Date.now() - const uniIdLogCollection = db.collection('uni-id-log') - let logData = { - deviceId: context.DEVICEID, - ip: context.CLIENTIP, - type: res.type, - ua: context.CLIENTUA, - create_date: now, - action - }; - - if (res.code === 0) { - logData.user_id = res.uid - logData.state = 1 - if (res.userInfo && res.userInfo.password) { - delete res.userInfo.password - } - if (res.type == 'register') { - await registerSuccess(res) - } - if (res.type == 'login') { - if (Object.keys(deviceInfo).length) { - console.log(context.DEVICEID); - //避免重复新增设备信息,先判断是否已存在 - let getDeviceRes = await deviceDB.where({ - "device_id": context.DEVICEID - }).get() - if (getDeviceRes.data.length == 0) { - await addDeviceInfo(res) - } else { - await deviceDB.where({ - "device_id": context.DEVICEID, - }).update({ - ...deviceInfo, - "tokenExpired": res.tokenExpired, - "user_id": res.uid, - "device_id": context.DEVICEID, - "ua": context.CLIENTUA, - "platform": context.PLATFORM, - "create_date": Date.now(), - "last_active_date": Date.now(), - "last_active_ip": context.CLIENTIP - }) - } - } - } - } else { - logData.state = 0 - } - return await uniIdLogCollection.add(logData) - } - - async function addDeviceInfo({ - uid, - tokenExpired - }) { - return await deviceDB.add({ - ...deviceInfo, - tokenExpired, - "user_id": uid, - "device_id": context.DEVICEID, - "ua": context.CLIENTUA, - "platform": context.PLATFORM, - "create_date": Date.now(), - "last_active_date": Date.now(), - "last_active_ip": context.CLIENTIP - }) - } - - //5.防止恶意破解操作,连续操作失败一定次数后,需要用户提供验证码 - const isNeedCaptcha = async () => { - //当用户最近“2小时内(recordDate)”操作失败达到2次(recordSize)时。要求用户提交验证码 - const now = Date.now(), - recordDate = 120 * 60 * 1000, - recordSize = 2; - const uniIdLogCollection = db.collection('uni-id-log') - let recentRecord = await uniIdLogCollection.where({ - ip: context.CLIENTIP, - create_date: dbCmd.gt(now - recordDate), - action - }) - .orderBy('create_date', 'desc') - .limit(recordSize) - .get(); - return recentRecord.data.filter(item => item.state === 0).length === recordSize; - } - - let res = {} - switch (action) { //根据action的值执行对应的操作 - case 'renewDeviceTokenExpired': - return await deviceDB.where({ - "user_id": params.uid, - "device_id": context.DEVICEID - }).update({ - "user_id": params.uid, - "push_clientid": params.push_clientid, - tokenExpired - }) - break; - case 'refreshSessionKey': - let getSessionKey = await uniID.code2SessionWeixin({ - code: params.code - }); - if (getSessionKey.code) { - return getSessionKey - } - res = await uniID.updateUser({ - uid: params.uid, - sessionKey: getSessionKey.sessionKey - }) - console.log(res); - break; - case 'bindMobileByMpWeixin': - console.log(params); - let getSessionKeyRes = await uniID.getUserInfo({ - uid: params.uid, - field: ['sessionKey'] - }) - if (getSessionKeyRes.code) { - return getSessionKeyRes - } - let sessionKey = getSessionKeyRes.userInfo.sessionKey - console.log(getSessionKeyRes); - res = await uniID.wxBizDataCrypt({ - ...params, - sessionKey - }) - console.log(res); - if (res.code) { - return res - } - res = await uniID.bindMobile({ - uid: params.uid, - mobile: res.purePhoneNumber - }) - console.log(res); - break; - case 'bindMobileByUniverify': - let { - appid, apiKey, apiSecret - } = uniIdConfig.service.univerify - let univerifyRes = await uniCloud.getPhoneNumber({ - provider: 'univerify', - appid, - apiKey, - apiSecret, - access_token: params.access_token, - openid: params.openid - }) - if (univerifyRes.code === 0) { - res = await uniID.bindMobile({ - uid: params.uid, - mobile: univerifyRes.phoneNumber - }) - res.mobile = univerifyRes.phoneNumber - } - break; - case 'bindMobileBySms': - if(!(/^1\d{10}$/.test(params.mobile))){ - return { - code: 401, - msg: '手机号格式错误' - } - } - if(!params.code){ - return { - code: 401, - msg: '短信验证码不能为空' - } - } - needCaptcha = await isNeedCaptcha() - console.log(needCaptcha) - if(needCaptcha){ - let {captcha} = params - if(!captcha){ - return { - errCode: 'CAPTCHA_REQUIRED', - errMsg: '操作失败达到2次,请提交验证码' - } - } - res = await uniCaptcha.verify({ - captcha, - scene: action - }) - console.log(8956,res); - if(res.code != 0){ - console.log(res,action); - return res - } - } - - res = await uniID.bindMobile({ - uid: params.uid, - mobile: params.mobile, - code: params.code - }) - uniIdLog(res) - console.log(res); - break; - case 'register': - var { - username, password, nickname,captcha - } = params - if (/^1\d{10}$/.test(username)) { - return { - code: 401, - msg: '用户名不能是手机号' - } - }; - if (/^(\w-*\.*)+@(\w-?)+(\.\w{2,})+$/.test(username)) { - return { - code: 401, - msg: '用户名不能是邮箱' - } - } - if(!captcha){ - return { - code: 401, - msg: '图形验证码不能为空' - } - } - res = await uniCaptcha.verify({ - captcha, - scene: action - }) - if(res.code != 0){ - return res - } - res = await uniID.register({ - username, - password, - nickname, - inviteCode - }); - if (res.code === 0) { - await registerSuccess(res) - } - break; - case 'getNeedCaptcha': { - const needCaptcha = await isNeedCaptcha() - res.needCaptcha = needCaptcha - break; - } - case 'login': - let passed = false; - needCaptcha = await isNeedCaptcha(); - console.log('needCaptcha', needCaptcha); - if (needCaptcha) { - res = await uniCaptcha.verify({ - ...params, - scene: 'login' - }) - if (res.code === 0) passed = true; - } - - if (!needCaptcha || passed) { - res = await uniID.login({ - ...params, - queryField: ['username', 'email', 'mobile'] - }); - res.type = 'login' - await uniIdLog(res); - needCaptcha = await isNeedCaptcha(); - } - - res.needCaptcha = needCaptcha; - break; - case 'loginByWeixin': - let loginRes = await uniID.loginByWeixin(params); - if (loginRes.code === 0) { - //用户完善资料(昵称、头像) - if (context.PLATFORM == "app-plus" && !loginRes.userInfo.nickname) { - let { - accessToken: access_token, - openid - } = loginRes, { - appid, - appsecret: secret - } = uniIdConfig['app-plus'].oauth.weixin; - let wxRes = await uniCloud.httpclient.request( - `https://api.weixin.qq.com/sns/userinfo?access_token=${access_token}&openid=${openid}&scope=snsapi_userinfo&appid=${appid}&secret=${secret}`, { - method: 'POST', - contentType: 'json', // 指定以application/json发送data内的数据 - dataType: 'json' // 指定返回值为json格式,自动进行parse - }) - if (wxRes.status == 200) { - let { - nickname, - headimgurl - } = wxRes.data; - let headimgurlFile = {}, - cloudPath = loginRes.uid + '/' + Date.now() + "headimgurl.jpg"; - let getImgBuffer = await uniCloud.httpclient.request(headimgurl) - if (getImgBuffer.status == 200) { - let { - fileID - } = await uniCloud.uploadFile({ - cloudPath, - fileContent: getImgBuffer.data - }); - headimgurlFile = { - name: cloudPath, - extname: "jpg", - url: fileID - } - } else { - return getImgBuffer - } - await uniID.updateUser({ - uid: loginRes.uid, - nickname, - avatar_file: headimgurlFile - }) - loginRes.userInfo.nickname = nickname; - loginRes.userInfo.avatar_file = headimgurlFile; - } else { - return wxRes - } - } - if (context.PLATFORM == "mp-weixin") { - let resUpdateUser = await uniID.updateUser({ - uid: loginRes.uid, - sessionKey: loginRes.sessionKey - }) - console.log(resUpdateUser); - } - delete loginRes.openid - delete loginRes.sessionKey - delete loginRes.accessToken - delete loginRes.refreshToken - } - await uniIdLog(loginRes) - return loginRes - break; - case 'loginByUniverify': - console.error(params) - res = await uniID.loginByUniverify(params) - console.log(999999999,res) - await uniIdLog(res) - break; - case 'loginByApple': - res = await uniID.loginByApple(params) - await uniIdLog(res) - break; - case 'checkToken': - res = await uniID.checkToken(uniIdToken); - break; - case 'logout': - res = await uniID.logout(uniIdToken) - await deviceDB.where({ - "device_id": context.DEVICEID, - }).update({ - "tokenExpired": Date.now() - }) - break; - case 'sendSmsCode': - /* -开始- 测试期间,为节约资源。统一虚拟短信验证码为: 123456;开启以下代码块即可 */ - res = uniID.setVerifyCode({ - mobile: params.mobile, - code: '123456', - type: params.type - }) - return { - ...res, - code: 40000, - msg: - "已启动测试模式,直接使用:123456作为短信验证码即可。正式项目,请配置/common/uni-config-center/uni-id/config.json(service->sm中的密钥信息)并在uni-id-cf完成配置 " - } - /* -结束- */ - - // 简单限制一下客户端调用频率 - const ipLimit = await db.collection('opendb-verify-codes').where({ - ip: context.CLIENTIP, - created_at: dbCmd.gt(Date.now() - 60000) - }).get() - if (ipLimit.data.length > 0) { - return { - code: 429, - msg: '请求过于频繁' - } - } - const templateId = '11753' // 替换为自己申请的模板id - if (!templateId) { - return { - code: 500, - msg: 'sendSmsCode需要传入自己的templateId,参考https://uniapp.dcloud.net.cn/uniCloud/uni-id?id=sendsmscode' - } - } - const randomStr = '00000' + Math.floor(Math.random() * 1000000) - const code = randomStr.substring(randomStr.length - 6) - res = await uniID.sendSmsCode({ - mobile: params.mobile, - code, - type: params.type, - templateId - }) - break; - case 'loginBySms': - needCaptcha = await isNeedCaptcha() - if(needCaptcha){ - let {captcha} = params - if(!captcha){ - return { - errCode: 'CAPTCHA_REQUIRED', - errMsg: '操作失败达到2次,请提交验证码' - } - } - res = await uniCaptcha.verify({ - captcha, - scene: action - }) - if(res.code != 0){ - console.log(res,action); - return res - } - } - if (!params.code) { - return { - code: 500, - msg: '请填写验证码' - } - } - if (!/^1\d{10}$/.test(params.mobile)) { - return { - code: 500, - msg: '手机号码填写错误' - } - } - res = await uniID.loginBySms(params) - await uniIdLog(res) - break; - case 'resetPwdBySmsCode': - if (!params.code) { - return { - code: 500, - msg: '请填写验证码' - } - } - if (!/^1\d{10}$/.test(params.mobile)) { - return { - code: 500, - msg: '手机号码填写错误' - } - } - params.type = 'login' - let loginBySmsRes = await uniID.loginBySms(params) - // console.log(loginBySmsRes); - if (loginBySmsRes.code === 0) { - res = await uniID.resetPwd({ - password: params.password, - "uid": loginBySmsRes.uid - }) - } else { - return loginBySmsRes - } - break; - case 'getInviteCode': - res = await uniID.getUserInfo({ - uid: params.uid, - field: ['my_invite_code'] - }) - if (res.code === 0) { - res.myInviteCode = res.userInfo.my_invite_code - delete res.userInfo - } - break; - case 'getInvitedUser': - res = await uniID.getInvitedUser(params) - break; - case 'updatePwd': - res = await uniID.updatePwd(params) - break; - case 'createCaptcha': - res = await uniCaptcha.create(params) - break; - case 'refreshCaptcha': - res = await uniCaptcha.refresh(params) - break; - case 'getUserInviteCode': - res = await uniID.getUserInfo({ - uid: params.uid, - field: ['my_invite_code'] - }) - if (!res.userInfo.my_invite_code) { - res = await uniID.setUserInviteCode({ - uid: params.uid - }) - } - break; - case 'closeAccount': - console.log(params.uid, '-----------------------'); - res = await uniID.closeAccount({ - uid: params.uid - }); - break; - - // =========================== admin api start ========================= - case 'registerAdmin': { - var { - username, - password - } = params - let { - total - } = await db.collection('uni-id-users').where({ - role: 'admin' - }).count() - if (total) { - return { - code: 10001, - message: '超级管理员已存在,请登录...' - } - } - const appid = params.appid - const appName = params.appName - delete params.appid - delete params.appName - res = await uniID.register({ - username, - password, - role: ["admin"] - }) - if (res.code === 0) { - const app = await db.collection('opendb-app-list').where({ - appid - }).count() - if (!app.total) { - await db.collection('opendb-app-list').add({ - appid, - name: appName, - description: "admin 管理后台", - create_date: Date.now() - }) - } - - } - break; - } - case 'registerUser': { - const { - userInfo - } = await uniID.getUserInfo({ - uid: params.uid - }) - if (userInfo.role.indexOf('admin') === -1) { - res = { - code: 403, - message: '非法访问, 无权限注册超级管理员', - } - } else { - // 过滤 dcloud_appid,注册用户成功后再提交 - const dcloudAppidList = params.dcloud_appid - delete params.dcloud_appid - delete params.uid - res = await uniID.register({ - autoSetDcloudAppid: false, - ...params - }) - if (res.code === 0) { - delete res.token - delete res.tokenExpired - await uniID.setAuthorizedAppLogin({ - uid: res.uid, - dcloudAppidList - }) - } - } - break; - } - case 'updateUser': { - const { - userInfo - } = await uniID.getUserInfo({ - uid: params.uid - }) - if (userInfo.role.indexOf('admin') === -1) { - res = { - code: 403, - message: '非法访问, 无权限注册超级管理员', - } - } else { - // 过滤 dcloud_appid,注册用户成功后再提交 - const dcloudAppidList = params.dcloud_appid - delete params.dcloud_appid - - // 过滤 password,注册用户成功后再提交 - const password = params.password - delete params.password - - // 过滤 uid、id - const id = params.id - delete params.id - delete params.uid - - - res = await uniID.updateUser({ - uid: id, - ...params - }) - if (res.code === 0) { - if (password) { - await uniID.resetPwd({ - uid: id, - password - }) - } - await uniID.setAuthorizedAppLogin({ - uid: id, - dcloudAppidList - }) - } - } - break; - } - case 'getCurrentUserInfo': - res = await uniID.getUserInfo({ - uid: params.uid, - ...params - }) - break; - case 'managerMultiTag': { - const { - userInfo - } = await uniID.getUserInfo({ - uid: params.uid - }) - // 限制只有 admin 角色的用户可管理标签,如需非 admin 角色需自行实现 - if (userInfo.role.indexOf('admin') === -1) { - res = { - code: 403, - message: '非法访问, 无权限修改用户标签', - } - return - } - let { - ids, - type, - value - } = params - if (type === 'add') { - res = await db.collection('uni-id-users').where({ - _id: dbCmd.in(ids) - }).update({ - tags: dbCmd.addToSet({ - $each: value - }) - }) - } else if (type === 'del') { - res = await db.collection('uni-id-users').where({ - _id: dbCmd.in(ids) - }).update({ - tags: dbCmd.pull(dbCmd.in(value)) - }) - } else { - res = { - code: 403, - msg: '无效操作' - } - return - } - break; - } - // =========================== admin api end ========================= - default: - res = { - code: 403, - msg: '非法访问' - } - break; - } - //返回数据给客户端 - return res -} diff --git a/uni_modules/uni-id-common/changelog.md b/uni_modules/uni-id-common/changelog.md new file mode 100644 index 0000000000000000000000000000000000000000..6a3d19b9b76f4eae843d9c269477548b9616ee4e --- /dev/null +++ b/uni_modules/uni-id-common/changelog.md @@ -0,0 +1,26 @@ +## 1.0.13(2022-07-21) +- 修复 创建token时未传角色权限信息生成的token不正确的bug +## 1.0.12(2022-07-15) +- 提升与旧版本uni-id的兼容性(补充读取配置文件时回退平台app-plus、h5),但是仍推荐使用新平台名进行配置(app、web) +## 1.0.11(2022-07-14) +- 修复 部分情况下报`read property 'reduce' of undefined`的错误 +## 1.0.10(2022-07-11) +- 将token存储在用户表的token字段内,与旧版本uni-id保持一致 +## 1.0.9(2022-07-01) +- checkToken兼容token内未缓存角色权限的情况,此时将查库获取角色权限 +## 1.0.8(2022-07-01) +- 修复clientDB默认依赖时部分情况下获取不到uni-id配置的Bug +## 1.0.7(2022-06-30) +- 修复config文件不合法时未抛出具体错误的Bug +## 1.0.6(2022-06-28) +- 移除插件内的数据表schema +## 1.0.5(2022-06-27) +- 修复使用多应用配置时报`Cannot read property 'appId' of undefined`的Bug +## 1.0.4(2022-06-27) +- 修复使用自定义token内容功能报错的Bug [详情](https://ask.dcloud.net.cn/question/147945) +## 1.0.2(2022-06-23) +- 对齐旧版本uni-id默认配置 +## 1.0.1(2022-06-22) +- 补充对uni-config-center的依赖 +## 1.0.0(2022-06-21) +- 提供uni-id token创建、校验、刷新接口,简化旧版uni-id公共模块 diff --git a/uni_modules/uni-id-common/package.json b/uni_modules/uni-id-common/package.json new file mode 100644 index 0000000000000000000000000000000000000000..0aed93272e5aca43c34b284807fcae231c9b5dd8 --- /dev/null +++ b/uni_modules/uni-id-common/package.json @@ -0,0 +1,87 @@ +{ + "id": "uni-id-common", + "displayName": "uni-id-common", + "version": "1.0.13", + "description": "包含uni-id token生成、校验、刷新功能的云函数公共模块", + "keywords": [ + "uni-id-common", + "uniCloud", + "token", + "权限" + ], + "repository": "https://gitcode.net/dcloud/uni-id-common", + "engines": { + "HBuilderX": "^3.1.0" + }, + "dcloudext": { + "category": [ + "uniCloud", + "云函数模板" + ], + "sale": { + "regular": { + "price": "0.00" + }, + "sourcecode": { + "price": "0.00" + } + }, + "contact": { + "qq": "" + }, + "declaration": { + "ads": "无", + "data": "无", + "permissions": "无" + }, + "npmurl": "" + }, + "uni_modules": { + "dependencies": ["uni-config-center"], + "encrypt": [], + "platforms": { + "cloud": { + "tcb": "y", + "aliyun": "y" + }, + "client": { + "Vue": { + "vue2": "u", + "vue3": "u" + }, + "App": { + "app-vue": "u", + "app-nvue": "u" + }, + "H5-mobile": { + "Safari": "u", + "Android Browser": "u", + "微信浏览器(Android)": "u", + "QQ浏览器(Android)": "u" + }, + "H5-pc": { + "Chrome": "u", + "IE": "u", + "Edge": "u", + "Firefox": "u", + "Safari": "u" + }, + "小程序": { + "微信": "u", + "阿里": "u", + "百度": "u", + "字节跳动": "u", + "QQ": "u", + "钉钉": "u", + "快手": "u", + "飞书": "u", + "京东": "u" + }, + "快应用": { + "华为": "u", + "联盟": "u" + } + } + } + } +} diff --git a/uni_modules/uni-id-common/readme.md b/uni_modules/uni-id-common/readme.md new file mode 100644 index 0000000000000000000000000000000000000000..91b3aaa811950cb82e592587f13993b517d52b9e --- /dev/null +++ b/uni_modules/uni-id-common/readme.md @@ -0,0 +1,3 @@ +# uni-id-common + +文档请参考:[uni-id-common](https://uniapp.dcloud.net.cn/uniCloud/uni-id-common.html) \ No newline at end of file diff --git a/uni_modules/uni-id-common/uniCloud/cloudfunctions/common/uni-id-common/index.js b/uni_modules/uni-id-common/uniCloud/cloudfunctions/common/uni-id-common/index.js new file mode 100644 index 0000000000000000000000000000000000000000..c51a148471f8346cf389c70e479b119026fc4fee --- /dev/null +++ b/uni_modules/uni-id-common/uniCloud/cloudfunctions/common/uni-id-common/index.js @@ -0,0 +1 @@ +"use strict";var e,t=(e=require("crypto"))&&"object"==typeof e&&"default"in e?e.default:e;const n={TOKEN_EXPIRED:"uni-id-token-expired",CHECK_TOKEN_FAILED:"uni-id-check-token-failed",PARAM_REQUIRED:"uni-id-param-required",ACCOUNT_EXISTS:"uni-id-account-exists",ACCOUNT_NOT_EXISTS:"uni-id-account-not-exists",ACCOUNT_CONFLICT:"uni-id-account-conflict",ACCOUNT_BANNED:"uni-id-account-banned",ACCOUNT_AUDITING:"uni-id-account-auditing",ACCOUNT_AUDIT_FAILED:"uni-id-account-audit-failed",ACCOUNT_CLOSED:"uni-id-account-closed"};function i(e){return!!e&&("object"==typeof e||"function"==typeof e)&&"function"==typeof e.then}function r(e){if(!e)return;const t=e.match(/^(\d+).(\d+).(\d+)/);return t?t.slice(1,4).map(e=>parseInt(e)):void 0}function o(e,t){const n=r(e),i=r(t);return n?i?function(e,t){const n=Math.max(e.length,t.length);for(let i=0;ir)return 1;if(ne)throw new Error("Config error, tokenExpiresThreshold should be less than tokenExpiresIn")}get customToken(){return this.uniId.interceptorMap.get("customToken")}isTokenInDb(e){return o(e,"1.0.10")>=0}async getUserRecord(){if(this.userRecord)return this.userRecord;const e=await C.doc(this.uid).get();if(this.userRecord=e.data[0],!this.userRecord)throw{errCode:n.ACCOUNT_NOT_EXISTS};switch(this.userRecord.status){case void 0:case 0:break;case 1:throw{errCode:n.ACCOUNT_BANNED};case 2:throw{errCode:n.ACCOUNT_AUDITING};case 3:throw{errCode:n.ACCOUNT_AUDIT_FAILED};case 4:throw{errCode:n.ACCOUNT_CLOSED}}if(this.oldTokenPayload){if(this.isTokenInDb(this.oldTokenPayload.uniIdVersion)){if(-1===(this.userRecord.token||[]).indexOf(this.oldToken))throw{errCode:n.CHECK_TOKEN_FAILED}}if(this.userRecord.valid_token_date&&this.userRecord.valid_token_date>1e3*this.oldTokenPayload.iat)throw{errCode:n.TOKEN_EXPIRED}}return this.userRecord}async updateUserRecord(e){await C.doc(this.uid).update(e)}async getUserPermission(){if(this.userPermission)return this.userPermission;const e=(await this.getUserRecord()).role||[];if(0===e.length)return this.userPermission={role:[],permission:[]},this.userPermission;if(e.includes("admin"))return this.userPermission={role:["admin"],permission:[]},this.userPermission;const t=await m.where({role_id:_.in(e)}).get(),n=(i=t.data.reduce((e,t)=>(t.permission&&e.push(...t.permission),e),[]),Array.from(new Set(i)));var i;return this.userPermission={role:e,permission:n},this.userPermission}async _createToken({uid:e,role:t,permission:i}={}){if(!t||!i){const e=await this.getUserPermission();t=e.role,i=e.permission}let r={uid:e,role:t,permission:i};if(this.uniId.interceptorMap.has("customToken")){const n=this.uniId.interceptorMap.get("customToken");if("function"!=typeof n)throw new Error("Invalid custom token file");r=await n({uid:e,role:t,permission:i})}const o=Date.now(),{tokenSecret:s,tokenExpiresIn:c}=this.config,a=g({...r,uniIdVersion:"1.0.13"},s,{expiresIn:c}),u=await this.getUserRecord(),d=(u.token||[]).filter(e=>{try{const t=this._checkToken(e);if(u.valid_token_date&&u.valid_token_date>1e3*t.iat)return!1}catch(e){if(e.errCode===n.TOKEN_EXPIRED)return!1}return!0});return d.push(a),await this.updateUserRecord({last_login_ip:this.clientInfo.clientIP,last_login_date:o,token:d}),{token:a,tokenExpired:o+1e3*c}}async createToken({uid:e,role:t,permission:i}={}){if(!e)throw{errCode:n.PARAM_REQUIRED,errMsgValue:{param:"uid"}};this.uid=e;const{token:r,tokenExpired:o}=await this._createToken({uid:e,role:t,permission:i});return{errCode:0,token:r,tokenExpired:o}}async refreshToken({token:e}={}){if(!e)throw{errCode:n.PARAM_REQUIRED,errMsgValue:{param:"token"}};this.oldToken=e;const t=this._checkToken(e);this.uid=t.uid,this.oldTokenPayload=t;const{uid:i}=t,{role:r,permission:o}=await this.getUserPermission(),{token:s,tokenExpired:c}=await this._createToken({uid:i,role:r,permission:o});return{errCode:0,token:s,tokenExpired:c}}_checkToken(e){const{tokenSecret:t}=this.config;let i;try{i=k(e,t)}catch(e){if("TokenExpiredError"===e.name)throw{errCode:n.TOKEN_EXPIRED};throw{errCode:n.CHECK_TOKEN_FAILED}}return i}async checkToken(e,{autoRefresh:t=!0}={}){if(!e)throw{errCode:n.PARAM_REQUIRED,errMsgValue:{param:"token"}};this.oldToken=e;const i=this._checkToken(e);this.uid=i.uid,this.oldTokenPayload=i;const{tokenExpiresThreshold:r}=this.config,{uid:o,role:s,permission:c}=i,a={role:s,permission:c};if(!s&&!c){const{role:e,permission:t}=await this.getUserPermission();a.role=e,a.permission=t}if(!r||!t){const e={code:0,errCode:0,...i,...a};return delete e.uniIdVersion,e}const u=Date.now();let d={};1e3*i.exp-u<1e3*r&&(d=await this._createToken({uid:o}));const l={code:0,errCode:0,...i,...a,...d};return delete l.uniIdVersion,l}}var E=Object.freeze({__proto__:null,checkToken:async function(e,{autoRefresh:t=!0}={}){return new T({uniId:this}).checkToken(e,{autoRefresh:t})},createToken:async function({uid:e,role:t,permission:n}={}){return new T({uniId:this}).createToken({uid:e,role:t,permission:n})},refreshToken:async function({token:e}={}){return new T({uniId:this}).refreshToken({token:e})}});const w=require("uni-config-center")({pluginId:"uni-id"});class A{constructor({context:e,clientInfo:t,config:n}={}){this._clientInfo=e?function(e){return{appId:e.APPID,platform:e.PLATFORM,locale:e.LOCALE,clientIP:e.CLIENTIP,deviceId:e.DEVICEID}}(e):t,this.config=n||this._getOriginConfig(),this.interceptorMap=new Map,w.hasFile("custom-token.js")&&this.setInterceptor("customToken",require(w.resolve("custom-token.js"))),this._i18n=uniCloud.initI18n({locale:this._clientInfo.locale,fallbackLocale:"zh-Hans",messages:d})}setInterceptor(e,t){this.interceptorMap.set(e,t)}_t(...e){return this._i18n.t(...e)}_parseOriginConfig(e){return Array.isArray(e)?e:e[0]?Object.values(e):e}_getOriginConfig(){if(w.hasFile("config.json")){let e;try{e=w.config()}catch(e){throw new Error("Invalid uni-id config file\n"+e.message)}return this._parseOriginConfig(e)}try{return this._parseOriginConfig(require("uni-id/config.json"))}catch(e){throw new Error("Invalid uni-id config file")}}_getAppConfig(){const e=this._getOriginConfig();return Array.isArray(e)?e.find(e=>e.dcloudAppid===this._clientInfo.appId)||e.find(e=>e.isDefaultConfig):e}_getPlatformConfig(){const e=this._getAppConfig();if(!e)throw new Error(`Config for current app (${this._clientInfo.appId}) was not found, please check your config file or client appId`);let t;switch("app-plus"===this._clientInfo.platform&&(this._clientInfo.platform="app"),"h5"===this._clientInfo.platform&&(this._clientInfo.platform="web"),this._clientInfo.platform){case"web":t="h5";break;case"app":t="app-plus"}const n=[{tokenExpiresIn:7200,tokenExpiresThreshold:1200,passwordErrorLimit:6,passwordErrorRetryTime:3600},e];t&&e[t]&&n.push(e[t]),n.push(e[this._clientInfo.platform]);const i=Object.assign(...n);return["tokenSecret","tokenExpiresIn"].forEach(e=>{if(!i||!i[e])throw new Error(`Config parameter missing, ${e} is required`)}),i}_getConfig(){return this._getPlatformConfig()}}for(const e in E)A.prototype[e]=E[e];function y(e){const t=new A(e);return new Proxy(t,{get(e,t){if(t in e&&0!==t.indexOf("_")){if("function"==typeof e[t])return(n=e[t],function(){let e;try{e=n.apply(this,arguments)}catch(e){if(a(e))return c.call(this,e),e;throw e}return i(e)?e.then(e=>(a(e)&&c.call(this,e),e),e=>{if(a(e))return c.call(this,e),e;throw e}):(a(e)&&c.call(this,e),e)}).bind(e);if("context"!==t&&"config"!==t)return e[t]}var n}})}A.prototype.createInstance=y;const x={createInstance:y};module.exports=x; diff --git a/uni_modules/uni-id-common/uniCloud/cloudfunctions/common/uni-id-common/package.json b/uni_modules/uni-id-common/uniCloud/cloudfunctions/common/uni-id-common/package.json new file mode 100644 index 0000000000000000000000000000000000000000..f330c28eb94422990eb791aa045df0adf0056c1a --- /dev/null +++ b/uni_modules/uni-id-common/uniCloud/cloudfunctions/common/uni-id-common/package.json @@ -0,0 +1,16 @@ +{ + "name": "uni-id-common", + "version": "1.0.13", + "description": "uni-id token生成、校验、刷新", + "main": "index.js", + "homepage": "https://uniapp.dcloud.io/uniCloud/uni-id-common.html", + "repository": { + "type": "git", + "url": "git+https://gitee.com/dcloud/uni-id-common.git" + }, + "author": "DCloud", + "license": "Apache-2.0", + "dependencies": { + "uni-config-center": "file:../../../../../uni-config-center/uniCloud/cloudfunctions/common/uni-config-center" + } +} \ No newline at end of file diff --git a/uni_modules/uni-id-pages/changelog.md b/uni_modules/uni-id-pages/changelog.md new file mode 100644 index 0000000000000000000000000000000000000000..9d10c85bd89fa777f09f042e8991eb902b60f05d --- /dev/null +++ b/uni_modules/uni-id-pages/changelog.md @@ -0,0 +1,30 @@ +## 1.0.10(2022-08-25) +- 修复 导入uni-id-pages插件时未自动导入uni-open-bridge-common的Bug +## 1.0.9(2022-08-23) +- 修复 uni-id-co 缺失uni-open-bridge-common依赖的Bug +## 1.0.8(2022-08-23) +- 新增 H5端支持微信登录(含微信公众号内的网页授权登录 和 普通浏览器内网页生成二维码,实现手机微信扫码登录)[详情](https://uniapp.dcloud.net.cn/uniCloud/uni-id-pages.html#weixinlogin) +- 新增 登录成功(全局)回调事件:`uni-id-pages-login-success`,支持通过[uni.$on](https://uniapp.dcloud.net.cn/api/window/communication.html#on)监听; +- 新增 密码强度(是否必须包含大小写字母、数字和特殊符号以及长度)配置 [详情](https://uniapp.dcloud.net.cn/uniCloud/uni-id-pages.html#config) +- 调整 uni-id-co 密码规则调整,废除之前的简单校验,允许配置密码强度 [详情](https://uniapp.dcloud.net.cn/uniCloud/uni-id-summary.html#password-strength) +- 调整 uni-id-co 存储用户 openid 时同时以客户端 AppId 为 Key 的副本,参考:[微信登录](https://uniapp.dcloud.net.cn/uniCloud/uni-id-pages.html#login-by-weixin)、[QQ登录](https://uniapp.dcloud.net.cn/uniCloud/uni-id-pages.html#login-by-qq) +- 调整 uni-id-co 依赖 uni-open-bridge-common 存储用户 session_key、access_token 等信息 [详情](https://uniapp.dcloud.net.cn/uniCloud/uni-id-summary.html#save-user-token) +- 新增 uni-id-co 增加 beforeRegister 钩子用户在注册前向用户记录内添加一些数据 [详情](https://uniapp.dcloud.net.cn/uniCloud/uni-id-summary.html#before-register) +## 1.0.7(2022-07-19) +- 修复 uni-id-co接口 logout时没有删除token的Bug +## 1.0.6(2022-07-13) +- 新增 允许覆盖内置校验规则 [详情](https://uniapp.dcloud.net.cn/uniCloud/uni-id-pages.html#custom-validator) +- 修复 app端clientInfo.appVersionCode为数字导致校验无法通过的Bug +## 1.0.5(2022-07-11) +修复 微信小程序调用uni-id-co接口报错的Bug [详情](https://ask.dcloud.net.cn/question/148877) +## 1.0.4(2022-07-06) +- uni-id-co增加clientInfo字段类型校验 +- 监听token更新时机,同步客户端push_clientid至uni-id-device表,改为:同步客户端push_clientid至uni-id-device表和opendb-device表 +## 1.0.3(2022-07-05) +新增监听token更新时机,同步客户端push_clientid至uni-id-device表 +## 1.0.2(2022-07-04) +修复微信小程序登录时无unionid报错的Bug [详情](https://ask.dcloud.net.cn/question/148016) +## 1.0.1(2022-06-28) +添加相关uni-id表 +## 1.0.0(2022-06-23) +正式版 diff --git a/uni_modules/uni-id-pages/common/login-page.mixin.js b/uni_modules/uni-id-pages/common/login-page.mixin.js new file mode 100644 index 0000000000000000000000000000000000000000..6a3cab9c8d8bde41975b520079ba2ed7364c834c --- /dev/null +++ b/uni_modules/uni-id-pages/common/login-page.mixin.js @@ -0,0 +1,77 @@ +import loginSuccess from './loginSuccess.js'; +import config from '@/uni_modules/uni-id-pages/config.js' +let mixin = { + data() { + return { + config, + isMounted: false + } + }, + onUnload() { + // #ifdef H5 + document.onkeydown = false + // #endif + }, + mounted() { + this.isMounted = true; + }, + onLoad(e) { + if (e.is_weixin_redirect) { + uni.showLoading({ + mask: true + }) + + if( window.location.href.includes('#') ){ + // 将url通过 ? 分割获取后面的参数字符串 再通过 & 将每一个参数单独分割出来 + let paramsArr = window.location.href.split('?')[1].split('&') + paramsArr.forEach(item=>{ + let arr = item.split('=') + if(arr[0] == 'code'){ + e.code = arr[1] + } + }) + } + this.$nextTick(n => { + console.log(this.$refs.uniFabLogin); + this.$refs.uniFabLogin.login({ + code:e.code + }, 'weixin') + }) + } + }, + computed: { + needAgreements() { + if (this.isMounted) { + if (this.$refs.agreements) { + return this.$refs.agreements.needAgreements + } else { + return false + } + } + }, + agree: { + get() { + if (this.isMounted) { + if (this.$refs.agreements) { + return this.$refs.agreements.isAgree + } else { + return true + } + } + }, + set(agree) { + if (this.$refs.agreements) { + this.$refs.agreements.isAgree = agree + } else { + console.log('不存在 隐私政策协议组件'); + } + } + } + }, + methods: { + loginSuccess(e) { + loginSuccess(e) + } + } +} +export default mixin diff --git a/uni_modules/uni-id-pages/common/login-page.scss b/uni_modules/uni-id-pages/common/login-page.scss new file mode 100644 index 0000000000000000000000000000000000000000..257f67bc87e557fc46dcc83497fda8bfa4b3ab87 --- /dev/null +++ b/uni_modules/uni-id-pages/common/login-page.scss @@ -0,0 +1,72 @@ +.uni-content { + padding: 0 60rpx; +} + +/* #ifndef APP-NVUE */ +@media screen and (min-width: 690px) { + .uni-content { + padding: 0; + max-width: 400px; + margin-left: calc(50% - 200px); + } +} + +.uni-content view { + box-sizing: border-box; +} + +/* #endif */ +.title { + /* #ifndef APP-NVUE */ + display: flex; + /* #endif */ + padding: 18px 0; + font-weight: 800; + flex-direction: column; +} + +.tip { + /* #ifndef APP-NVUE */ + display: flex; + /* #endif */ + color: #BDBDC0; + font-size: 11px; + margin: 6px 0; +} + +.input-box { + padding: 4px; + background-color: #F8F8F8; + border-radius: 0; + font-size: 14px; + /* #ifndef APP-NVUE */ + display: flex; + /* #endif */ + flex: 1; +} + +.link { + color: #04498c; + cursor: pointer; +} + +.uni-content ::v-deep .uni-forms-item__inner { + padding-bottom: 8px; +} + +.uni-btn { + text-align: center; + height: 40px; + line-height: 40px; + margin: 15px 0 0 0; + color: #FFF !important; + border-radius: 5px; +} +/* +.uni-btn::after{ + display: none; +} +.uni-btn[disabled]{ + background-color: $uni-color-primary !important; + opacity: 0.3; +}*/ \ No newline at end of file diff --git a/uni_modules/uni-id-pages/common/loginSuccess.js b/uni_modules/uni-id-pages/common/loginSuccess.js new file mode 100644 index 0000000000000000000000000000000000000000..17df975216c645d49054b94b08894d79e41c9820 --- /dev/null +++ b/uni_modules/uni-id-pages/common/loginSuccess.js @@ -0,0 +1,37 @@ +export default function(e = {}) { + const { + showToast = true, toastText = '登录成功', autoBack = true + } = e + console.log({ + toastText, + autoBack + }); + if (showToast) { + uni.showToast({ + title: toastText, + icon: 'none' + }); + } + if (autoBack) { + let delta = 0; //判断需要返回几层 + let pages = getCurrentPages(); + uni.$emit('uni-id-pages-login-success',pages) + console.log(pages); + pages.forEach((page, index) => { + if (pages[pages.length - index - 1].route.split('/')[3] == 'login') { + delta++ + } + }) + console.log('判断需要返回几层:',pages, delta); + // #ifdef H5 + if(e.loginType == 'weixin'){ + console.log('window.history',window.history); + return window.history.go(-3) + } + // #endif + + uni.navigateBack({ + delta + }) + } +} diff --git a/uni_modules/uni-id-pages/common/password.js b/uni_modules/uni-id-pages/common/password.js new file mode 100644 index 0000000000000000000000000000000000000000..e3f57b3b15ade519a5954c955812335e597d61e0 --- /dev/null +++ b/uni_modules/uni-id-pages/common/password.js @@ -0,0 +1,113 @@ +// 导入配置 +import config from '@/uni_modules/uni-id-pages/config.js' + +const passwordLength = config.password.length +const passwordStrength = config.password.strength + +let minPasswordLength = 6 +let maxPasswordLength = 20 +if (passwordLength) { + if (passwordLength[0]) { + minPasswordLength = passwordLength[0] + } + if (passwordLength[1]) { + maxPasswordLength = passwordLength[1] + } +} +// 密码强度表达式 +const passwordRules = { + // 密码必须包含大小写字母、数字和特殊符号 + super: /^(?=.*[0-9])(?=.*[a-z])(?=.*[A-Z])(?=.*[~!@#$%^&*_\-+=`|\\(){}[\]:;"'<>,.?/])[0-9a-zA-Z~!@#$%^&*_\-+=`|\\(){}[\]:;"'<>,.?/]{8,16}$/, + // 密码必须包含字母、数字和特殊符号 + strong: /^(?=.*[0-9])(?=.*[a-zA-Z])(?=.*[~!@#$%^&*_\-+=`|\\(){}[\]:;"'<>,.?/])[0-9a-zA-Z~!@#$%^&*_\-+=`|\\(){}[\]:;"'<>,.?/]{8,16}$/, + // 密码必须为字母、数字和特殊符号任意两种的组合 + medium: /^(?![0-9]+$)(?![a-zA-Z]+$)(?![~!@#$%^&*_\-+=`|\\(){}[\]:;"'<>,.?/]+$)[0-9a-zA-Z~!@#$%^&*_\-+=`|\\(){}[\]:;"'<>,.?/]{8,16}$/, + // 密码必须包含字母和数字 + weak: /^(?=.*[0-9])(?=.*[a-zA-Z])[0-9a-zA-Z~!@#$%^&*_\-+=`|\\(){}[\]:;"'<>,.?/]{6,16}$/ +} + +const ERROR = { + normal: { + noPwd: '请输入密码', + noRePwd: '再次输入密码', + rePwdErr: '两次输入密码不一致' + }, + passwordStrengthError: { + superstrong: '密码必须包含大小写字母、数字和特殊符号', + strong: '密码必须包含字母、数字和特殊符号', + medium: '密码必须为字母、数字和特殊符号任意两种的组合', + weak: '密码必须包含字母' + }, + passwordLengthError: { + normal: '密码长度必须在' + minPasswordLength + '-' + maxPasswordLength + '位之间', + minLimit: '密码长度不得少于' + minPasswordLength + '位', + maxLimit: '密码长度不得超过' + maxPasswordLength + '位' + } +} + +function validPwd(password) { + //强度校验 + if (passwordStrength && passwordRules[passwordStrength]) { + if (!new RegExp(passwordRules[passwordStrength]).test(password)) { + return ERROR.passwordStrengthError[passwordStrength] + } + } + //长度校验 + if (passwordLength) { + if (passwordLength[0] && password.length < passwordLength[0]) { + return ERROR.passwordLengthError.minLimit + } + if (passwordLength[1] && password.length > passwordLength[1]) { + return ERROR.passwordLengthError.maxLimit + } + } + + return true +} + +function getPwdRules(pwdName = 'password', rePwdName = 'password2') { + const rules = {} + rules[pwdName] = { + rules: [{ + required: true, + errorMessage: ERROR.normal.noPwd, + }, + { + validateFunction: function(rule, value, data, callback) { + const checkRes = validPwd(value) + if (checkRes !== true) { + callback(checkRes) + } + return true + } + } + ] + } + + if (rePwdName) { + rules[rePwdName] = { + rules: [{ + required: true, + errorMessage: ERROR.normal.noRePwd, + }, + { + validateFunction: function(rule, value, data, callback) { + if (value != data.password) { + callback(ERROR.normal.rePwdErr) + } + return true + } + } + ] + } + } + return rules +} + +export default { + ERROR, + minPasswordLength, + maxPasswordLength, + validPwd, + getPwdRules +} diff --git a/components/cloud-image/cloud-image.vue b/uni_modules/uni-id-pages/components/cloud-image/cloud-image.vue similarity index 67% rename from components/cloud-image/cloud-image.vue rename to uni_modules/uni-id-pages/components/cloud-image/cloud-image.vue index 2279eb81f6d3880be8c68e5942e1750d9b6ed312..f36bb91a7097a973d5c7d7597ecb0828c0ff08df 100644 --- a/components/cloud-image/cloud-image.vue +++ b/uni_modules/uni-id-pages/components/cloud-image/cloud-image.vue @@ -4,10 +4,19 @@ - + + diff --git a/uni_modules/uni-id-pages/components/uni-id-pages-avatar/uni-id-pages-avatar.vue b/uni_modules/uni-id-pages/components/uni-id-pages-avatar/uni-id-pages-avatar.vue new file mode 100644 index 0000000000000000000000000000000000000000..898bbaaa84f5246de6bb263c54a0f3675a7fc9f1 --- /dev/null +++ b/uni_modules/uni-id-pages/components/uni-id-pages-avatar/uni-id-pages-avatar.vue @@ -0,0 +1,188 @@ + + + + + diff --git a/uni_modules/uni-id-pages/components/uni-id-pages-bind-mobile/uni-id-pages-bind-mobile.vue b/uni_modules/uni-id-pages/components/uni-id-pages-bind-mobile/uni-id-pages-bind-mobile.vue new file mode 100644 index 0000000000000000000000000000000000000000..770cb74a33958b70686fe2a399de7765c6af1e47 --- /dev/null +++ b/uni_modules/uni-id-pages/components/uni-id-pages-bind-mobile/uni-id-pages-bind-mobile.vue @@ -0,0 +1,165 @@ + + + + + diff --git a/uni_modules/uni-id-pages/components/uni-id-pages-fab-login/uni-id-pages-fab-login.vue b/uni_modules/uni-id-pages/components/uni-id-pages-fab-login/uni-id-pages-fab-login.vue new file mode 100644 index 0000000000000000000000000000000000000000..daddb7fc67fde53c09b77d71d55993dbab338144 --- /dev/null +++ b/uni_modules/uni-id-pages/components/uni-id-pages-fab-login/uni-id-pages-fab-login.vue @@ -0,0 +1,554 @@ + + + + diff --git a/uni_modules/uni-id-pages/components/uni-id-pages-sms-form/uni-id-pages-sms-form.vue b/uni_modules/uni-id-pages/components/uni-id-pages-sms-form/uni-id-pages-sms-form.vue new file mode 100644 index 0000000000000000000000000000000000000000..81b2292cc9dbef5324274cf7634cee75a85f1709 --- /dev/null +++ b/uni_modules/uni-id-pages/components/uni-id-pages-sms-form/uni-id-pages-sms-form.vue @@ -0,0 +1,241 @@ + + + + + diff --git a/components/uni-user-profile/uni-user-profile.vue b/uni_modules/uni-id-pages/components/uni-id-pages-user-profile/uni-id-pages-user-profile.vue similarity index 81% rename from components/uni-user-profile/uni-user-profile.vue rename to uni_modules/uni-id-pages/components/uni-id-pages-user-profile/uni-id-pages-user-profile.vue index 62beb86485fa39557e91887f8408d0d1cd5b3d2f..703f4845d1dde3f6c809583f6add63c233840d51 100644 --- a/components/uni-user-profile/uni-user-profile.vue +++ b/uni_modules/uni-id-pages/components/uni-id-pages-user-profile/uni-id-pages-user-profile.vue @@ -5,35 +5,22 @@ 获取你的微信头像和昵称,完善你的个人资料 关闭 - + diff --git a/uni_modules/uni-id-pages/pages/login/login-smscode.vue b/uni_modules/uni-id-pages/pages/login/login-smscode.vue new file mode 100644 index 0000000000000000000000000000000000000000..b0ca3d0f0f47167dfa65cf52d0279583e08be449 --- /dev/null +++ b/uni_modules/uni-id-pages/pages/login/login-smscode.vue @@ -0,0 +1,118 @@ + + + + diff --git a/uni_modules/uni-id-pages/pages/login/login-withoutpwd.vue b/uni_modules/uni-id-pages/pages/login/login-withoutpwd.vue new file mode 100644 index 0000000000000000000000000000000000000000..256a99e7548b6d2cba7c7047f8eb14b5e466949f --- /dev/null +++ b/uni_modules/uni-id-pages/pages/login/login-withoutpwd.vue @@ -0,0 +1,196 @@ + + + + + + diff --git a/uni_modules/uni-id-pages/pages/login/login-withpwd.vue b/uni_modules/uni-id-pages/pages/login/login-withpwd.vue new file mode 100644 index 0000000000000000000000000000000000000000..049ebac71c6e95e6457d17194c293962d98ca332 --- /dev/null +++ b/uni_modules/uni-id-pages/pages/login/login-withpwd.vue @@ -0,0 +1,156 @@ + + + + + + diff --git a/uni_modules/uni-id-pages/pages/register/register.vue b/uni_modules/uni-id-pages/pages/register/register.vue new file mode 100644 index 0000000000000000000000000000000000000000..5ceaa25fda084bb1a9a0f781b4fe71526cdc1088 --- /dev/null +++ b/uni_modules/uni-id-pages/pages/register/register.vue @@ -0,0 +1,132 @@ + + + + + + diff --git a/uni_modules/uni-id-pages/pages/register/validator.js b/uni_modules/uni-id-pages/pages/register/validator.js new file mode 100644 index 0000000000000000000000000000000000000000..907f901070ff7838b1907572d9a1381b387a850f --- /dev/null +++ b/uni_modules/uni-id-pages/pages/register/validator.js @@ -0,0 +1,56 @@ +import passwordMod from '@/uni_modules/uni-id-pages/common/password.js' +export default { + "username": { + "rules": [{ + required: true, + errorMessage: '请输入用户名', + }, + { + minLength: 3, + maxLength: 32, + errorMessage: '用户名长度在 {minLength} 到 {maxLength} 个字符', + }, + { + validateFunction: function(rule, value, data, callback) { + // console.log(value); + if (/^1\d{10}$/.test(value) || /^(\w-*\.*)+@(\w-?)+(\.\w{2,})+$/.test(value)) { + callback('用户名不能是:手机号或邮箱') + }; + if (/^\d+$/.test(value)) { + callback('用户名不能为纯数字') + }; + if(/[\u4E00-\u9FA5\uF900-\uFA2D]{1,}/.test(value)){ + callback('用户名不能包含中文') + } + return true + } + } + ], + "label": "用户名" + }, + "nickname": { + "rules": [{ + minLength: 3, + maxLength: 32, + errorMessage: '昵称长度在 {minLength} 到 {maxLength} 个字符', + }, + { + validateFunction: function(rule, value, data, callback) { + // console.log(value); + if (/^1\d{10}$/.test(value) || /^(\w-*\.*)+@(\w-?)+(\.\w{2,})+$/.test(value)) { + callback('昵称不能是:手机号或邮箱') + }; + if (/^\d+$/.test(value)) { + callback('昵称不能为纯数字') + }; + if(/[\u4E00-\u9FA5\uF900-\uFA2D]{1,}/.test(value)){ + callback('昵称不能包含中文') + } + return true + } + } + ], + "label": "昵称" + }, + ...passwordMod.getPwdRules() +} diff --git a/uni_modules/uni-id-pages/pages/retrieve/retrieve.vue b/uni_modules/uni-id-pages/pages/retrieve/retrieve.vue new file mode 100644 index 0000000000000000000000000000000000000000..0b7a14bef43f2cdcbf841a9ffb63370bdbf8ec18 --- /dev/null +++ b/uni_modules/uni-id-pages/pages/retrieve/retrieve.vue @@ -0,0 +1,201 @@ + + + + + + diff --git a/uni_modules/uni-id-pages/pages/userinfo/bind-mobile/bind-mobile.vue b/uni_modules/uni-id-pages/pages/userinfo/bind-mobile/bind-mobile.vue new file mode 100644 index 0000000000000000000000000000000000000000..351c32b3b7fcba2c5d834fe8223973036275411d --- /dev/null +++ b/uni_modules/uni-id-pages/pages/userinfo/bind-mobile/bind-mobile.vue @@ -0,0 +1,111 @@ + + + + + diff --git a/uni_modules/uni-id-pages/pages/userinfo/change_pwd/change_pwd.vue b/uni_modules/uni-id-pages/pages/userinfo/change_pwd/change_pwd.vue new file mode 100644 index 0000000000000000000000000000000000000000..724e47bbe2e063436f7c3cb6bfc383cfe9993eda --- /dev/null +++ b/uni_modules/uni-id-pages/pages/userinfo/change_pwd/change_pwd.vue @@ -0,0 +1,146 @@ + + + + + + diff --git a/pages/ucenter/userinfo/cropImage.vue b/uni_modules/uni-id-pages/pages/userinfo/cropImage/cropImage.vue similarity index 96% rename from pages/ucenter/userinfo/cropImage.vue rename to uni_modules/uni-id-pages/pages/userinfo/cropImage/cropImage.vue index dbec54d65615aba78c4eb62417606835da945ea6..0a9e701768d2739362c88b7364b3a74f3b5c872d 100644 --- a/pages/ucenter/userinfo/cropImage.vue +++ b/uni_modules/uni-id-pages/pages/userinfo/cropImage/cropImage.vue @@ -1,3 +1,4 @@ +