feat(home): 实现游客模式与登录流程优化

- 添加游客模式,展示公共内容无需强制登录
- 实现游客模块展示打卡、计划、关于我们等功能介绍
- 添加产品介绍页面显示学习成长工具详情
- 优化登录流程,添加用户协议和隐私政策同意选项
- 更新角色标签将老师改为管理员,学员改为成员
- 添加注销账号功能替代退出登录
- 实现webview页面域名白名单安全验证
- 添加隐私政策和用户协议页面
- 优化页面跳转逻辑和错误提示信息
- 统一项目名称从明缘进阶场改为明缘云道场
This commit is contained in:
王宏豪
2026-09-03 18:57:47 +08:00
parent d7fc8c8982
commit 1dd4fa3f41
20 changed files with 588 additions and 57 deletions

View File

@@ -1,8 +1,47 @@
const api = require('../../utils/api');
// 允许加载的域名白名单
const ALLOWED_HOSTS = ['m.muguaclub.cn', 'muguaclub.cn'];
function isAllowedUrl(url) {
if (!url) return false;
try {
// 简单解析 hostname
const match = url.match(/^https?:\/\/([^/:?#]+)/i);
if (!match) return false;
const host = match[1].toLowerCase();
return ALLOWED_HOSTS.some((h) => host === h || host.endsWith('.' + h));
} catch (e) {
return false;
}
}
Page({
data: { url: '' },
data: {
url: '',
invalid: false
},
onLoad(options) {
if (options.url) {
this.setData({ url: decodeURIComponent(options.url) });
if (!options.url) {
this.setData({ invalid: true });
return;
}
const url = decodeURIComponent(options.url);
if (!isAllowedUrl(url)) {
console.warn('[webview] blocked url:', url);
this.setData({ invalid: true, url: '' });
return;
}
this.setData({ url, invalid: false });
},
onRetry() {
if (this.data.url) {
// 触发重新加载
this.setData({ url: '' });
setTimeout(() => {
this.setData({ url: this.data._url || '' });
}, 50);
}
}
});
});

View File

@@ -1 +1,8 @@
<web-view src="{{url}}" wx:if="{{url}}"></web-view>
<view class="page">
<web-view src="{{url}}" wx:if="{{url && !invalid}}"></web-view>
<view class="error-page" wx:if="{{invalid}}">
<view class="error-icon">!</view>
<view class="error-title">无法加载该页面</view>
<view class="error-desc">该页面不在允许访问的域名范围内</view>
</view>
</view>

View File

@@ -0,0 +1,30 @@
.page {
min-height: 100vh;
background: #FDFBF7;
}
.error-page {
padding-top: 200rpx;
text-align: center;
}
.error-icon {
width: 120rpx;
height: 120rpx;
line-height: 120rpx;
margin: 0 auto 32rpx;
border-radius: 50%;
background: #fdecea;
color: #c0392b;
font-size: 64rpx;
font-weight: 700;
}
.error-title {
color: #2C1810;
font-size: 32rpx;
font-weight: 700;
margin-bottom: 16rpx;
}
.error-desc {
color: #8B7A6A;
font-size: 26rpx;
}