启动页 推送

This commit is contained in:
haomingming 2025-09-26 17:13:02 +08:00
parent df4d95993a
commit 053063dc88
23 changed files with 911 additions and 17 deletions

24
App.vue
View File

@ -36,10 +36,30 @@ export default {
/** 关闭启动画面,锁定竖屏 */
plus.navigator.closeSplashscreen();
plus.screen.lockOrientation("portrait-primary");
// #endif
// uni-apppushApp.vue
uni.getPushClientId({
success: (res) => {
let push_clientid = res.cid
uni.setStorageSync("push_clientid", push_clientid)
console.log('客户端推送标识cid:',push_clientid)
},
fail(err) {
console.error("unipush: ", err)
}
})
uni.onPushMessage((res)=>{
console.log("收到推送消息:", res)
uni.showModal({
title: res.data.title,
content: res.type,
showCancel: false
});
})
/** 设置语言 此处为了方便demo切换语言将其存到本地实际需根据业务情况设置*/
setLanguage(
uni.getStorageSync("switchToEnglishFlag") == "en" ? "en" : "zh"

3
androidPrivacy.json Normal file
View File

@ -0,0 +1,3 @@
{
"prompt": "template"
}

View File

@ -18,6 +18,10 @@ const my_api = {
checkVersion(data) {
return request('/expertAPI/checkVersion', data, 'post', true);
},
startpage() {
return request('/expertAPI/startpage', {}, 'post', true);
}
}

View File

@ -21,7 +21,8 @@
"Payment" : {},
"Share" : {},
"Webview-x5" : {},
"UIWebview" : {}
"UIWebview" : {},
"Push" : {}
},
/* */
"distribute" : {
@ -74,10 +75,29 @@
"UniversalLinks" : "https://doc.igandan.com/gdxzExpert/"
}
},
"speech" : {}
"speech" : {},
"push" : {
"unipush" : {
"version" : "2",
"offline" : false,
"hms" : {},
"oppo" : {},
"vivo" : {},
"mi" : {},
"meizu" : {},
"honor" : {},
"icons" : {
"small" : {
"xxhdpi" : "D:/haomi/Documents/WeChat Files/wxid_x5u4rycntnkq21/FileStorage/File/2025-09/专家版图标/专家版图标/72.png"
}
}
}
}
},
"splashscreen" : {
"androidStyle" : "common"
"androidStyle" : "common",
"useOriginalMsgbox" : true,
"iosStyle" : "common"
},
"icons" : {
"android" : {
@ -132,5 +152,7 @@
"vueVersion" : "3",
"uniStatistics" : {
"version" : "2"
}
},
"fallbackLocale" : "zh-Hans",
"locale" : "zh-Hans"
}

View File

@ -8,7 +8,18 @@
}
},
"pages": [{
"pages": [
{
"path" : "pages/ad/ad",
"style": {
"navigationBarTitleText": "",
"navigationStyle": "custom",
"app": {
"bounce": "none"
}
}
},
{
"path": "pages/index/index",
"style": {
"navigationBarTitleText": "",
@ -75,6 +86,7 @@
"enablePullDownRefresh": false
}
}
],
"subPackages": [
{
@ -1216,7 +1228,7 @@
"list": [
{
"name": "",
"path": "pages/index/index",
"path": "pages/ad/ad",
"query": ""
}
]

193
pages/ad/ad.vue Normal file
View File

@ -0,0 +1,193 @@
<template>
<view class="ad-container" v-if="adData.path">
<!-- 广告图片 -->
<image
class="ad-image"
:src="adData.path"
mode="aspectFill"
@click="handleAdClick"
></image>
<!-- 右上角倒计时跳过按钮 -->
<view class="skip-button" @click="skipAd">
<text class="skip-text">跳过 {{countdown}}s</text>
</view>
<!-- 底部点击跳转按钮 -->
<view class="bottom-button" v-if="adData.url" @click="handleAdClick">
<text class="button-text">点击查看详情</text>
</view>
</view>
<!-- 加载状态 -->
<view class="loading-container" v-else>
<text class="loading-text">加载中...</text>
</view>
</template>
<script setup>
import { ref, reactive, onMounted, nextTick, computed, onUnmounted } from 'vue';
import { onShow, onLoad, onPageScroll } from "@dcloudio/uni-app";
import my_api from '@/api/my_api.js'
import docUrl from "@/utils/docUrl.js";
// 广
const adData = ref({
path: '',
url: ''
});
//
const countdown = ref(5);
let timer = null;
//
onLoad(() => {
console.log('开屏广告页面加载');
getStartpage();
});
// 广
const getStartpage = () => {
my_api.startpage().then(res => {
console.log('开屏广告数据:', res);
if (res && res.data) {
adData.value = {
path: docUrl + res.data.path || '',
url: res.data.url || ''
};
// 广
if (res.data.path) {
startCountdown();
} else {
// 广
navigateToHome();
}
} else {
//
navigateToHome();
}
}).catch(err => {
console.error('获取开屏广告失败:', err);
//
navigateToHome();
});
}
//
const startCountdown = () => {
timer = setInterval(() => {
countdown.value--;
if (countdown.value <= 0) {
clearInterval(timer);
navigateToHome();
}
}, 1000);
}
// 广
const skipAd = () => {
clearInterval(timer);
navigateToHome();
}
// 广
const handleAdClick = () => {
if (adData.value.url) {
//
uni.navigateTo({
url: '/pages/webview/webview?url=' + adData.value.url
});
} else {
//
navigateToHome();
}
}
//
const navigateToHome = () => {
uni.redirectTo({
url: '/pages/index/index'
});
}
//
onUnmounted(() => {
if (timer) {
clearInterval(timer);
}
});
</script>
<style scoped>
.ad-container {
position: fixed;
top: 0;
left: 0;
width: 100vw;
height: 100vh;
background-color: #000;
z-index: 9999;
}
.ad-image {
width: 100%;
height: 100%;
object-fit: cover;
}
.skip-button {
position: absolute;
top: 60rpx;
right: 30rpx;
background-color: rgba(0, 0, 0, 0.6);
border-radius: 40rpx;
padding: 16rpx 24rpx;
z-index: 10000;
}
.skip-text {
color: #fff;
font-size: 28rpx;
font-weight: 500;
}
.bottom-button {
position: absolute;
bottom: 100rpx;
left: 50%;
transform: translateX(-50%);
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
border-radius: 50rpx;
padding: 24rpx 60rpx;
box-shadow: 0 8rpx 32rpx rgba(102, 126, 234, 0.3);
z-index: 10000;
}
.button-text {
color: #fff;
font-size: 32rpx;
font-weight: 600;
}
.loading-container {
position: fixed;
top: 0;
left: 0;
width: 100vw;
height: 100vh;
background-color: #f5f5f5;
display: flex;
align-items: center;
justify-content: center;
z-index: 9999;
}
.loading-text {
color: #666;
font-size: 32rpx;
}
</style>

View File

@ -144,9 +144,9 @@
<up-image :src="ghsjhImg" width="48rpx" height="48rpx"></up-image>
<text>更换手机号</text>
</view>
<view class="operation-item" @click="goToPage('notifications')">
<view class="operation-item" @click="switchPushPermissions">
<up-image :src="tzykImg" width="48rpx" height="48rpx"></up-image>
<text>通知已</text>
<text>通知已{{notice_on?'':'关'}}</text>
</view>
<view class="operation-item" @click="showVersion">
<up-image :src="versionImg" width="48rpx" height="48rpx"></up-image>
@ -269,6 +269,7 @@
const totalPoints = ref(0)
const sign_in = ref(0)
const honor_list = ref([])
const notice_on = ref(false)
// storage
const getUserInfoFromStorage = () => {
try {
@ -428,8 +429,9 @@
url="/pages_app/setting/setting"
break;
default:
const push_clientid = uni.getStorageSync("push_clientid")
uni.showToast({
title: '功能开发中',
title: 'push_clientid: '+push_clientid,
icon: 'none'
});
}
@ -438,6 +440,131 @@
})
};
//
const isNoticeOn = () => {
// #ifdef APP-PLUS
if (plus.os.name == "Android") {
var main = plus.android.runtimeMainActivity();
var NotificationManagerCompat = plus.android.importClass("android.support.v4.app.NotificationManagerCompat");
if (NotificationManagerCompat == null) {
NotificationManagerCompat = plus.android.importClass("androidx.core.app.NotificationManagerCompat");
}
var areNotificationsEnabled = NotificationManagerCompat.from(main).areNotificationsEnabled();
notice_on.value = areNotificationsEnabled
return areNotificationsEnabled;
} else if (plus.os.name == "iOS") {
var isIosOn = undefined;
var types = 0;
var app = plus.ios.invoke("UIApplication", "sharedApplication");
var settings = plus.ios.invoke(app, "currentUserNotificationSettings");
if (settings) {
types = settings.plusGetAttribute("types");
plus.ios.deleteObject(settings);
} else {
types = plus.ios.invoke(app, "enabledRemoteNotificationTypes");
}
plus.ios.deleteObject(app);
isIosOn = 0 != types;
notice_on.value = isIosOn
return isIosOn;
}
// #endif
}
//
const switchPushPermissions = () => {
const push_clientid = uni.getStorageSync("push_clientid")
// #ifdef APP-PLUS
let title = isNoticeOn() ? "通知权限关闭提醒" : "通知权限开启提醒";
let content = isNoticeOn()
? "通知权限已开启,是否前往设置关闭?"+push_clientid
: "您还没有开启通知权限,无法接受到消息通知,是否前往设置?"+push_clientid;
//
let openAndroidSetting = () => {
var main = plus.android.runtimeMainActivity();
var pkName = main.getPackageName();
var uid = main.getApplicationInfo().plusGetAttribute("uid");
var Intent = plus.android.importClass("android.content.Intent");
var Build = plus.android.importClass("android.os.Build");
//android 8.0
if (Build.VERSION.SDK_INT >= 26) {
var intent = new Intent("android.settings.APP_NOTIFICATION_SETTINGS");
intent.putExtra("android.provider.extra.APP_PACKAGE", pkName);
} else if (Build.VERSION.SDK_INT >= 21) {
//android 5.0-7.0
var intent = new Intent("android.settings.APP_NOTIFICATION_SETTINGS");
intent.putExtra("app_package", pkName);
intent.putExtra("app_uid", uid);
} else {
//(<21)--
intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
var uri = Uri.fromParts("package", mainActivity.getPackageName(), null);
intent.setData(uri);
}
//
main.startActivity(intent);
};
//
let openIOSSetting = () => {
var app = plus.ios.invoke("UIApplication", "sharedApplication");
var setting = plus.ios.invoke("NSURL", "URLWithString:", "app-settings:");
plus.ios.invoke(app, "openURL:", setting);
plus.ios.deleteObject(setting);
plus.ios.deleteObject(app);
// ios18
// 使uni.openAppAuthorizeSetting()https://uniapp.dcloud.net.cn/api/system/openappauthorizesetting.html
// AIiOS 18openURL:openURL:options:completionHandler:
// var app = plus.ios.invoke("UIApplication", "sharedApplication");
// var url;
// // URLiOS 8+
// if (plus.ios.invoke("UIApplication", "respondsToSelector:", "openSettingsURLString")) {
// var urlString = plus.ios.invoke("UIApplication", "openSettingsURLString");
// url = plus.ios.invoke("NSURL", "URLWithString:", urlString);
// } else {
// url = plus.ios.invoke("NSURL", "URLWithString:", "app-settings:");
// }
// // API iOS 10+
// var supportsNewAPI = plus.ios.invoke(app, "respondsToSelector:", "openURL:options:completionHandler:");
// if (supportsNewAPI) {
// var options = plus.ios.newObject("NSDictionary");
// var completion = plus.ios.newBlock(function(success) {
// console.log("" + success);
// if (!success) {
// plus.nativeUI.toast("");
// }
// }, "v@:B");
// plus.ios.invoke(app, "openURL:options:completionHandler:", url, options, completion);
// plus.ios.deleteObject(completion);
// } else {
// if (plus.ios.invoke(app, "canOpenURL:", url)) {
// plus.ios.invoke(app, "openURL:", url);
// } else {
// throw new Error("");
// }
// }
// plus.ios.deleteObject(url);
// plus.ios.deleteObject(app);
};
//
uni.showModal({
title: title,
content: content,
showCancel: true,
confirmColor: "#ff903f",
success: (res) => {
if (res.confirm) {
if (plus.os.name == "Android") {
openAndroidSetting();
} else if (plus.os.name == "iOS") {
openIOSSetting();
}
}
},
});
// #endif
}
const showYearSummary = () => {
console.log('显示年度总结');
uni.showToast({
@ -491,6 +618,7 @@
getUserInfoFromStorage() // storage
fetchMyInfo() // API
getIsBoundWechat()
isNoticeOn()
});
</script>

View File

@ -22,7 +22,7 @@
<view class="setting-item" @click="toggleNotification">
<text class="setting-text">消息通知</text>
<view class="setting-right">
<text class="setting-status">已开启</text>
<text class="setting-status">{{notice_on?'':'未'}}开启</text>
</view>
</view>
@ -73,7 +73,7 @@
<view class="setting-item" @click="clearCache">
<text class="setting-text">清除缓存</text>
<view class="setting-right">
<text class="cache-size">1.39MB</text>
<text class="cache-size">{{fileSizeString}}</text>
<uni-icons type="right" size="20" color="#999"></uni-icons>
</view>
</view>
@ -144,7 +144,13 @@
<script setup>
import { ref } from 'vue';
import {
onShow
} from "@dcloudio/uni-app";
import my_api from '@/api/my_api.js'
const notice_on = ref(false)
const fileSizeString = ref("0B")
//
const goBack = () => {
uni.navigateBack();
@ -159,6 +165,53 @@
});
};
const formatSize = () => {
plus.cache.calculate(function(size) {
let sizeCache = parseInt(size);
if (sizeCache == 0) {
fileSizeString.value = "0B";
} else if (sizeCache < 1024) {
fileSizeString.value = sizeCache + "B";
} else if (sizeCache < 1048576) {
fileSizeString.value = (sizeCache / 1024).toFixed(2) + "KB";
} else if (sizeCache < 1073741824) {
fileSizeString.value = (sizeCache / 1048576).toFixed(2) + "MB";
} else {
fileSizeString.value = (sizeCache / 1073741824).toFixed(2) + "GB";
}
});
}
const isNoticeOn = () => {
// #ifdef APP-PLUS
if (plus.os.name == "Android") {
var main = plus.android.runtimeMainActivity();
var NotificationManagerCompat = plus.android.importClass("android.support.v4.app.NotificationManagerCompat");
if (NotificationManagerCompat == null) {
NotificationManagerCompat = plus.android.importClass("androidx.core.app.NotificationManagerCompat");
}
var areNotificationsEnabled = NotificationManagerCompat.from(main).areNotificationsEnabled();
notice_on.value = areNotificationsEnabled
return areNotificationsEnabled;
} else if (plus.os.name == "iOS") {
var isIosOn = undefined;
var types = 0;
var app = plus.ios.invoke("UIApplication", "sharedApplication");
var settings = plus.ios.invoke(app, "currentUserNotificationSettings");
if (settings) {
types = settings.plusGetAttribute("types");
plus.ios.deleteObject(settings);
} else {
types = plus.ios.invoke(app, "enabledRemoteNotificationTypes");
}
plus.ios.deleteObject(app);
isIosOn = 0 != types;
notice_on.value = isIosOn
return isIosOn;
}
// #endif
}
const goToPage = (url) => {
uni.navigateTo({
url: '/pages/webview/webview?url=' + url
@ -417,10 +470,41 @@ const appdownLoad = (url) => {
content: '确定要清除缓存吗?',
success: (res) => {
if (res.confirm) {
let os = plus.os.name;
if (os == 'Android') {
let main = plus.android.runtimeMainActivity();
let sdRoot = main.getCacheDir();
let files = plus.android.invoke(sdRoot, "listFiles");
let len = files.length;
for (let i = 0; i < len; i++) {
let filePath = '' + files[i]; //
plus.io.resolveLocalFileSystemURL(filePath, function(entry) {
if (entry.isDirectory) {
entry.removeRecursively(function(entry) { //
uni.showToast({
title: '缓存已清除',
icon: 'none'
title: '缓存清理完成',
duration: 2000
});
formatSize(); //
}, function(e) {
console.log(e.message)
});
} else {
entry.remove();
}
}, function(e) {
console.log('文件路径读取失败')
});
}
} else { // ios
plus.cache.clear(function() {
uni.showToast({
title: '缓存清理完成',
duration: 2000
});
formatSize();
});
}
}
}
});
@ -473,6 +557,10 @@ const appdownLoad = (url) => {
}
});
};
onShow(() => {
isNoticeOn()
});
</script>
<style scoped>

View File

@ -0,0 +1,20 @@
// 简单的使用示例
'use strict';
const uniPush = uniCloud.getPushManager({
appId: "__UNI__89F511F"
})
exports.main = async (event) => {
let obj = JSON.parse(event.body)
const res = await uniPush.sendMessage({
"push_clientid": obj.cids, // 设备id支持多个以数组的形式指定多个设备如["cid-1","cid-2"]数组长度不大于1000
"title": obj.title, // 标题
"content": obj.content, // 内容
"settings": obj.settings, // 消息有效期
"payload": obj.payload, // 数据
"category": obj.category, // HarmonyOS NEXT系统纯血鸿蒙、非安卓鸿蒙的消息分类要给鸿蒙设备推送时才必传
"force_notification": true, //填写true客户端就会对在线消息自动创建“通知栏消息”不填写则需要客户端自己处理。
"request_id": obj.request_id ,//请求唯一标识号10-32位之间如果request_id重复会导致消息丢失
"options":obj.options //消息分类,没申请可以不传这个参数
})
return res;
};

View File

@ -0,0 +1,7 @@
{
"name": "commentPush",
"dependencies": {},
"extensions": {
"uni-cloud-push": {}
}
}

View File

@ -0,0 +1,40 @@
// 简单的使用示例
'use strict';
const uniPush = uniCloud.getPushManager({appId:"__UNI__89F511F"}) //注意这里需要传入你的应用appId
exports.main = async (event, context) => {
return await uniPush.sendMessage({
"push_clientid": "a297ac02dc531b7d43ff539f3163efcb", //填写上一步在uni-app客户端获取到的客户端推送标识push_clientid
"force_notification":true, //填写true客户端就会对在线消息自动创建“通知栏消息”。
"title": "通知栏显示的标题",
"content": "通知栏显示的内容",
"settings": {
//消息有效期设置,单位毫秒,-1表示不设离线。默认是 2 小时,取值范围:-1 3 * 24 * 3600 * 1000(3天)之间
"ttl":86400000
},
"payload": {
"text":"体验一下uni-push2.0"
},
"category": {
//HarmonyOS NEXT系统纯血鸿蒙、非安卓鸿蒙的消息分类要给鸿蒙设备推送时才必传
"harmony":"MARKETING"
},
"options":{
"HW": {
// 值为int 类型。1 表示华为测试消息华为每个应用每日可发送该测试消息500条。此 target_user_type 参数请勿发布至线上。
"/message/android/target_user_type":1
} ,
"HO": {
//值为int 类型。1 表示测试推送不填默认为0。荣耀每个应用每日可发送该测试消息1000条。此测试参数请勿发布至线上。
"/android/targetUserType": 1
} ,
"VV": {
//值为int 类型。0 表示正式推送1 表示测试推送不填默认为0。此 pushMode 参数请勿发布至线上。
"/pushMode":1
} ,
"XM": {
//新小米消息分类下私信公信id都必须要传否则请求小米厂商接口会被拦截
"/extra.channel_id": "填写小米平台申请的渠道id"
}
}
})
};

View File

@ -0,0 +1,7 @@
{
"name": "testPush2",
"dependencies": {},
"extensions": {
"uni-cloud-push": {}
}
}

View File

@ -0,0 +1,12 @@
// 本文件用于使用JQL语法操作项目关联的uniCloud空间的数据库方便开发调试和远程数据库管理
// 编写clientDB的js API也支持常规js语法比如var可以对云数据库进行增删改查操作。不支持uniCloud-db组件写法
// 可以全部运行也可以选中部分代码运行。点击工具栏上的运行按钮或者按下【F5】键运行代码
// 如果文档中存在多条JQL语句只有最后一条语句生效
// 如果混写了普通js最后一条语句需是数据库操作语句
// 此处代码运行不受DB Schema的权限控制移植代码到实际业务中注意在schema中配好permission
// 不支持clientDB的action
// 数据库查询有最大返回条数限制详见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();

View File

@ -0,0 +1,6 @@
## 0.0.32022-11-11
- 修复 config 方法获取根节点为数组格式配置时错误的转化为了对象的Bug
## 0.0.22021-04-16
- 修改插件package信息
## 0.0.12021-03-15
- 初始化项目

View File

@ -0,0 +1,81 @@
{
"id": "uni-config-center",
"displayName": "uni-config-center",
"version": "0.0.3",
"description": "uniCloud 配置中心",
"keywords": [
"配置",
"配置中心"
],
"repository": "",
"engines": {
"HBuilderX": "^3.1.0"
},
"dcloudext": {
"sale": {
"regular": {
"price": "0.00"
},
"sourcecode": {
"price": "0.00"
}
},
"contact": {
"qq": ""
},
"declaration": {
"ads": "无",
"data": "无",
"permissions": "无"
},
"npmurl": "",
"type": "unicloud-template-function"
},
"directories": {
"example": "../../../scripts/dist"
},
"uni_modules": {
"dependencies": [],
"encrypt": [],
"platforms": {
"cloud": {
"tcb": "y",
"aliyun": "y"
},
"client": {
"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"
},
"Vue": {
"vue2": "y",
"vue3": "u"
}
}
}
}
}

View File

@ -0,0 +1,93 @@
# 为什么使用uni-config-center
实际开发中很多插件需要配置文件才可以正常运行,如果每个插件都单独进行配置的话就会产生下面这样的目录结构
```bash
cloudfunctions
└─────common 公共模块
├─plugin-a // 插件A对应的目录
│ ├─index.js
│ ├─config.json // plugin-a对应的配置文件
│ └─other-file.cert // plugin-a依赖的其他文件
└─plugin-b // plugin-b对应的目录
├─index.js
└─config.json // plugin-b对应的配置文件
```
假设插件作者要发布一个项目模板,里面使用了很多需要配置的插件,无论是作者发布还是用户使用都是一个大麻烦。
uni-config-center就是用了统一管理这些配置文件的使用uni-config-center后的目录结构如下
```bash
cloudfunctions
└─────common 公共模块
├─plugin-a // 插件A对应的目录
│ └─index.js
├─plugin-b // plugin-b对应的目录
│ └─index.js
└─uni-config-center
├─index.js // config-center入口文件
├─plugin-a
│ ├─config.json // plugin-a对应的配置文件
│ └─other-file.cert // plugin-a依赖的其他文件
└─plugin-b
└─config.json // plugin-b对应的配置文件
```
使用uni-config-center后的优势
- 配置文件统一管理,分离插件主体和配置信息,更新插件更方便
- 支持对config.json设置schema插件使用者在HBuilderX内编写config.json文件时会有更好的提示后续HBuilderX会提供支持
# 用法
在要使用uni-config-center的公共模块或云函数内引入uni-config-center依赖请参考[使用公共模块](https://uniapp.dcloud.net.cn/uniCloud/cf-common)
```js
const createConfig = require('uni-config-center')
const uniIdConfig = createConfig({
pluginId: 'uni-id', // 插件id
defaultConfig: { // 默认配置
tokenExpiresIn: 7200,
tokenExpiresThreshold: 600,
},
customMerge: function(defaultConfig, userConfig) { // 自定义默认配置和用户配置的合并规则,不设置的情况侠会对默认配置和用户配置进行深度合并
// defaudltConfig 默认配置
// userConfig 用户配置
return Object.assign(defaultConfig, userConfig)
}
})
// 以如下配置为例
// {
// "tokenExpiresIn": 7200,
// "passwordErrorLimit": 6,
// "bindTokenToDevice": false,
// "passwordErrorRetryTime": 3600,
// "app-plus": {
// "tokenExpiresIn": 2592000
// },
// "service": {
// "sms": {
// "codeExpiresIn": 300
// }
// }
// }
// 获取配置
uniIdConfig.config() // 获取全部配置注意uni-config-center内不存在对应插件目录时会返回空对象
uniIdConfig.config('tokenExpiresIn') // 指定键值获取配置返回7200
uniIdConfig.config('service.sms.codeExpiresIn') // 指定键值获取配置返回300
uniIdConfig.config('tokenExpiresThreshold', 600) // 指定键值获取配置如果不存在则取传入的默认值返回600
// 获取文件绝对路径
uniIdConfig.resolve('custom-token.js') // 获取uni-config-center/uni-id/custom-token.js文件的路径
// 引用文件require
uniIDConfig.requireFile('custom-token.js') // 使用require方式引用uni-config-center/uni-id/custom-token.js文件。文件不存在时返回undefined文件内有其他错误导致require失败时会抛出错误。
// 判断是否包含某文件
uniIDConfig.hasFile('custom-token.js') // 配置目录是否包含某文件true: 文件存在false: 文件不存在
```

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,13 @@
{
"name": "uni-config-center",
"version": "0.0.3",
"description": "配置中心",
"main": "index.js",
"keywords": [],
"author": "DCloud",
"license": "Apache-2.0",
"origin-plugin-dev-name": "uni-config-center",
"origin-plugin-version": "0.0.3",
"plugin-dev-name": "uni-config-center",
"plugin-version": "0.0.3"
}

View File

@ -0,0 +1,36 @@
## 1.0.182024-07-08
- checkToken时如果传入的token为空则返回uni-id-check-token-failed错误码以便uniIdRouter能正常跳转
## 1.0.172024-04-26
- 兼容uni-app-x对客户端uniPlatform的调整uni-app-x内uniPlatform区分app-android、app-ios
## 1.0.162023-04-25
- 新增maxTokenLength配置用于限制数据库用户记录token数组的最大长度
## 1.0.152023-04-06
- 修复部分语言国际化出错的Bug
## 1.0.142023-03-07
- 修复 admin用户包含其他角色时未包含在token的Bug
## 1.0.132022-07-21
- 修复 创建token时未传角色权限信息生成的token不正确的bug
## 1.0.122022-07-15
- 提升与旧版本uni-id的兼容性补充读取配置文件时回退平台app-plus、h5但是仍推荐使用新平台名进行配置app、web
## 1.0.112022-07-14
- 修复 部分情况下报`read property 'reduce' of undefined`的错误
## 1.0.102022-07-11
- 将token存储在用户表的token字段内与旧版本uni-id保持一致
## 1.0.92022-07-01
- checkToken兼容token内未缓存角色权限的情况此时将查库获取角色权限
## 1.0.82022-07-01
- 修复clientDB默认依赖时部分情况下获取不到uni-id配置的Bug
## 1.0.72022-06-30
- 修复config文件不合法时未抛出具体错误的Bug
## 1.0.62022-06-28
- 移除插件内的数据表schema
## 1.0.52022-06-27
- 修复使用多应用配置时报`Cannot read property 'appId' of undefined`的Bug
## 1.0.42022-06-27
- 修复使用自定义token内容功能报错的Bug [详情](https://ask.dcloud.net.cn/question/147945)
## 1.0.22022-06-23
- 对齐旧版本uni-id默认配置
## 1.0.12022-06-22
- 补充对uni-config-center的依赖
## 1.0.02022-06-21
- 提供uni-id token创建、校验、刷新接口简化旧版uni-id公共模块

View File

@ -0,0 +1,84 @@
{
"id": "uni-id-common",
"displayName": "uni-id-common",
"version": "1.0.18",
"description": "包含uni-id token生成、校验、刷新功能的云函数公共模块",
"keywords": [
"uni-id-common",
"uniCloud",
"token",
"权限"
],
"repository": "https://gitcode.net/dcloud/uni-id-common",
"engines": {
},
"dcloudext": {
"sale": {
"regular": {
"price": 0
},
"sourcecode": {
"price": 0
}
},
"contact": {
"qq": ""
},
"declaration": {
"ads": "无",
"data": "无",
"permissions": "无"
},
"npmurl": "",
"type": "unicloud-template-function"
},
"uni_modules": {
"dependencies": ["uni-config-center"],
"encrypt": [],
"platforms": {
"cloud": {
"tcb": "y",
"aliyun": "y",
"alipay": "n"
},
"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"
}
}
}
}
}

View File

@ -0,0 +1,3 @@
# uni-id-common
文档请参考:[uni-id-common](https://uniapp.dcloud.net.cn/uniCloud/uni-id-common.html)

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,20 @@
{
"name": "uni-id-common",
"version": "1.0.18",
"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"
},
"origin-plugin-dev-name": "uni-id-common",
"origin-plugin-version": "1.0.18",
"plugin-dev-name": "uni-id-common",
"plugin-version": "1.0.18"
}