启动页 推送
This commit is contained in:
parent
df4d95993a
commit
053063dc88
24
App.vue
24
App.vue
@ -36,9 +36,29 @@ export default {
|
||||
/** 关闭启动画面,锁定竖屏 */
|
||||
plus.navigator.closeSplashscreen();
|
||||
plus.screen.lockOrientation("portrait-primary");
|
||||
|
||||
|
||||
// #endif
|
||||
|
||||
// uni-app客户端获取push客户端标记,代码可以实现在App.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(
|
||||
|
||||
3
androidPrivacy.json
Normal file
3
androidPrivacy.json
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"prompt": "template"
|
||||
}
|
||||
@ -18,6 +18,10 @@ const my_api = {
|
||||
|
||||
checkVersion(data) {
|
||||
return request('/expertAPI/checkVersion', data, 'post', true);
|
||||
},
|
||||
|
||||
startpage() {
|
||||
return request('/expertAPI/startpage', {}, 'post', true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -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"
|
||||
}
|
||||
|
||||
16
pages.json
16
pages.json
@ -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
193
pages/ad/ad.vue
Normal 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>
|
||||
134
pages/my/my.vue
134
pages/my/my.vue
@ -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
|
||||
// 方案二:待验证,AI生成;来源评论区:iOS 18以后,openURL:完全被弃用,需要用openURL:options:completionHandler:替代。
|
||||
// var app = plus.ios.invoke("UIApplication", "sharedApplication");
|
||||
// var url;
|
||||
// // 获取安全 URL(iOS 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>
|
||||
|
||||
|
||||
@ -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) {
|
||||
uni.showToast({
|
||||
title: '缓存已清除',
|
||||
icon: 'none'
|
||||
});
|
||||
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: '缓存清理完成',
|
||||
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>
|
||||
|
||||
20
uniCloud-aliyun/cloudfunctions/commentPush/index.js
Normal file
20
uniCloud-aliyun/cloudfunctions/commentPush/index.js
Normal 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;
|
||||
};
|
||||
7
uniCloud-aliyun/cloudfunctions/commentPush/package.json
Normal file
7
uniCloud-aliyun/cloudfunctions/commentPush/package.json
Normal file
@ -0,0 +1,7 @@
|
||||
{
|
||||
"name": "commentPush",
|
||||
"dependencies": {},
|
||||
"extensions": {
|
||||
"uni-cloud-push": {}
|
||||
}
|
||||
}
|
||||
40
uniCloud-aliyun/cloudfunctions/testPush2/index.js
Normal file
40
uniCloud-aliyun/cloudfunctions/testPush2/index.js
Normal 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"
|
||||
}
|
||||
}
|
||||
})
|
||||
};
|
||||
7
uniCloud-aliyun/cloudfunctions/testPush2/package.json
Normal file
7
uniCloud-aliyun/cloudfunctions/testPush2/package.json
Normal file
@ -0,0 +1,7 @@
|
||||
{
|
||||
"name": "testPush2",
|
||||
"dependencies": {},
|
||||
"extensions": {
|
||||
"uni-cloud-push": {}
|
||||
}
|
||||
}
|
||||
12
uniCloud-aliyun/database/JQL查询.jql
Normal file
12
uniCloud-aliyun/database/JQL查询.jql
Normal 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();
|
||||
6
uni_modules/uni-config-center/changelog.md
Normal file
6
uni_modules/uni-config-center/changelog.md
Normal file
@ -0,0 +1,6 @@
|
||||
## 0.0.3(2022-11-11)
|
||||
- 修复 config 方法获取根节点为数组格式配置时错误的转化为了对象的Bug
|
||||
## 0.0.2(2021-04-16)
|
||||
- 修改插件package信息
|
||||
## 0.0.1(2021-03-15)
|
||||
- 初始化项目
|
||||
81
uni_modules/uni-config-center/package.json
Normal file
81
uni_modules/uni-config-center/package.json
Normal 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"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
93
uni_modules/uni-config-center/readme.md
Normal file
93
uni_modules/uni-config-center/readme.md
Normal 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
@ -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"
|
||||
}
|
||||
36
uni_modules/uni-id-common/changelog.md
Normal file
36
uni_modules/uni-id-common/changelog.md
Normal file
@ -0,0 +1,36 @@
|
||||
## 1.0.18(2024-07-08)
|
||||
- checkToken时如果传入的token为空则返回uni-id-check-token-failed错误码以便uniIdRouter能正常跳转
|
||||
## 1.0.17(2024-04-26)
|
||||
- 兼容uni-app-x对客户端uniPlatform的调整(uni-app-x内uniPlatform区分app-android、app-ios)
|
||||
## 1.0.16(2023-04-25)
|
||||
- 新增maxTokenLength配置,用于限制数据库用户记录token数组的最大长度
|
||||
## 1.0.15(2023-04-06)
|
||||
- 修复部分语言国际化出错的Bug
|
||||
## 1.0.14(2023-03-07)
|
||||
- 修复 admin用户包含其他角色时未包含在token的Bug
|
||||
## 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公共模块
|
||||
84
uni_modules/uni-id-common/package.json
Normal file
84
uni_modules/uni-id-common/package.json
Normal 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"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
3
uni_modules/uni-id-common/readme.md
Normal file
3
uni_modules/uni-id-common/readme.md
Normal 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
@ -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"
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user