feat: 新增关于我们页面和功能

新增关于我们页面和功能
This commit is contained in:
Theo
2024-11-29 16:05:18 +08:00
parent 6a3ccd309b
commit 2e224a5093
8 changed files with 815 additions and 15 deletions

View File

@@ -26,6 +26,24 @@
"navigationBarTitleText": "我的"
}
},
{
"path": "pages/mine/about/index",
"style": {
"navigationBarTitleText": "关于我们"
}
},
{
"path": "pages/mine/privacy/index",
"style": {
"navigationBarTitleText": "隐私政策"
}
},
{
"path": "pages/mine/network-test/index",
"style": {
"navigationBarTitleText": "网络测试"
}
},
{
"path": "pages/login/index",
"style": {

View File

@@ -0,0 +1,200 @@
<template>
<view class="about-container">
<!-- 顶部 Logo 区域 -->
<view class="logo-section">
<image class="logo" src="/static/images/youlaiorg.png" mode="aspectFit" />
<text class="app-name">vue-uniapp-template</text>
<text class="version">版本 1.0.0</text>
</view>
<!-- 公司信息区域 -->
<view class="company-info">
<text class="company-name">有来开源组织</text>
<view class="divider" />
<text class="company-desc">专注于快速构建和高效开发的应用解决方案</text>
</view>
<!-- 信息列表 -->
<view class="info-list">
<view class="list-header">
<text class="header-title">优质项目</text>
</view>
<view class="info-item">
<view class="item-content">
<text class="item-label">vue-uniapp-template</text>
<text class="item-desc">
基于 uni-app + Vue 3 + TypeScript 的项目集成了 ESLintPrettierStylelintHusky
Commitlint 等工具确保代码规范与质量
</text>
</view>
</view>
<view class="info-item">
<view class="item-content">
<text class="item-label">vue3-element-admin</text>
<text class="item-desc">
基于 Vue3 + Vite5+ TypeScript5 + Element-Plus + Pinia
等主流技术栈构建的免费开源的中后台管理的前端模板
</text>
</view>
</view>
<view class="info-item">
<view class="item-content">
<text class="item-label">youlai-boot</text>
<text class="item-desc">
基于 JDK 17Spring Boot 3Spring Security 6JWTRedisMybatis-PlusKnife4jVue
3Element-Plus 构建的前后端分离单体权限管理系统
</text>
</view>
</view>
</view>
<!-- 底部版权信息 -->
<view class="copyright">
<text>Copyright © {{ getYear() }} 有来开源组织</text>
<text>All Rights Reserved</text>
</view>
</view>
</template>
<script>
export default {
name: "About",
methods: {
getYear() {
return new Date().getFullYear();
},
},
};
</script>
<style lang="scss" scoped>
.about-container {
min-height: 100vh;
padding: 20px;
background-color: #f5f5f5;
}
.logo-section {
display: flex;
flex-direction: column;
align-items: center;
padding: 30px 0;
.logo {
width: 80px;
height: 80px;
margin-bottom: 15px;
}
.app-name {
margin-bottom: 8px;
font-size: 20px;
font-weight: bold;
}
.version {
font-size: 14px;
color: #666;
}
}
.company-info {
padding: 30px;
margin: 20px 0;
text-align: center;
background-color: #fff;
border-radius: 8px;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
.company-name {
margin-bottom: 15px;
font-size: 20px;
font-weight: 600;
color: #333;
}
.divider {
width: 40px;
height: 2px;
margin: 15px auto;
background-color: #409eff;
}
.company-desc {
padding: 0 10px;
margin-top: 15px;
overflow: hidden;
font-size: 15px;
line-height: 1.6;
color: #666;
text-overflow: ellipsis;
white-space: nowrap;
}
}
.info-list {
margin: 20px 0;
background-color: #fff;
border-radius: 8px;
.list-header {
padding: 15px 20px;
border-bottom: 1px solid #eee;
.header-title {
font-size: 17px;
font-weight: 600;
color: #333;
}
}
.info-item {
display: flex;
align-items: center;
justify-content: space-between;
padding: 15px 20px;
border-bottom: 1px solid #eee;
&:last-child {
border-bottom: none;
}
.item-content {
flex: 1;
padding-right: 15px;
}
.item-label {
display: block;
margin-bottom: 4px;
font-size: 16px;
color: #333;
}
.item-desc {
display: block;
font-size: 13px;
line-height: 1.4;
color: #999;
}
.item-value {
font-size: 16px;
color: #999;
}
}
}
.copyright {
padding: 20px 0;
text-align: center;
text {
display: block;
font-size: 12px;
line-height: 1.5;
color: #999;
}
}
</style>

View File

@@ -10,14 +10,18 @@
<view class="ml-20rpx text-32rpx">
<text v-if="isLogin">{{ userInfo!.nickname }}</text>
<view v-else @click="goToLoginPage">
<text>您还未登录请先</text
><text class="cursor-pointer"> 登录 <wd-icon name="arrow-right" /> </text>
<text>您还未登录请先</text>
<text class="cursor-pointer">
登录
<wd-icon name="arrow-right" />
</text>
</view>
</view>
</view>
<view>
<text v-if="isLogin" class="cursor-pointer" @click="goToProfile">
个人信息 <wd-icon name="arrow-right" />
个人信息
<wd-icon name="arrow-right" />
</text>
</view>
</view>
@@ -32,25 +36,41 @@
<!-- 菜单列表 -->
<view class="mt50rpx">
<wd-cell-group border>
<wd-cell title="编辑资料" icon="setting" @click="goToEditProfile">
<wd-icon name="arrow-right" />
</wd-cell>
<wd-cell title="常见问题" icon="setting" @click="goToFAQ">
<wd-icon name="arrow-right" />
</wd-cell>
<wd-cell title="关于我们" icon="setting" @click="goToAbout">
<wd-cell title="关于我们" icon="setting" clickable @click="goToAbout">
<wd-icon name="arrow-right" />
</wd-cell>
<wd-cell title="隐私政策" icon="setting" clickable @click="goToPrivacy">
<wd-icon name="arrow-right" />
</wd-cell>
<wd-cell title="网络检测" icon="setting" clickable @click="goToNetworkTest">
<wd-icon name="arrow-right" />
</wd-cell>
<wd-cell
title="清除缓存"
icon="setting"
:value="cacheSize"
clickable
@click="handleClearCache"
/>
<wd-cell title="应用设置" icon="setting" clickable @click="goToSettings">
<wd-icon name="arrow-right" />
</wd-cell>
<wd-cell title="退出登录" icon="setting" clickable @click="handleLogout">
<wd-icon name="arrow-right" />
</wd-cell>
</wd-cell-group>
</view>
</view>
<!-- 全屏 loading -->
<view v-if="clearing" class="loading-mask">
<view class="loading-content">
<view class="loading-icon" />
<text class="loading-text">正在清理...</text>
</view>
</view>
</view>
</template>
@@ -72,24 +92,113 @@ const goToLoginPage = () => {
const goToProfile = () => {
uni.navigateTo({ url: "/pages/mine/profile/index" });
};
const goToEditProfile = () => {
uni.navigateTo({ url: "/pages/edit-profile/index" });
const goToPrivacy = () => {
uni.navigateTo({ url: "/pages/mine/privacy/index" });
};
const goToNetworkTest = () => {
uni.navigateTo({ url: "/pages/mine/network-test/index" });
};
const goToFAQ = () => {
uni.navigateTo({ url: "/pages/faq/index" });
};
const goToAbout = () => {
uni.navigateTo({ url: "/pages/about/index" });
uni.navigateTo({ url: "/pages/mine/about/index" });
};
const goToSettings = () => {
uni.navigateTo({ url: "/pages/settings/index" });
uni.showToast({
title: "建设中...",
icon: "none",
});
//uni.navigateTo({ url: "/pages/settings/index" });
};
const handleLogout = () => {
userStore.logout().then(() => {
uni.showToast({ title: "已退出登录", icon: "success" });
});
};
// 是否正在清理
const clearing = ref(false);
// 缓存大小
const cacheSize = ref<any>("计算中...");
// 获取缓存大小
const getCacheSize = async () => {
try {
// #ifdef MP-WEIXIN
const res = await uni.getStorageInfo();
cacheSize.value = formatSize(res.currentSize);
// #endif
// #ifdef H5
cacheSize.value = formatSize(
Object.keys(localStorage).reduce((size, key) => size + localStorage[key].length, 0)
);
// #endif
if (!cacheSize.value) {
cacheSize.value = "0B";
}
} catch (error) {
console.error("获取缓存大小失败:", error);
cacheSize.value = "获取失败";
}
};
// 格式化存储大小
const formatSize = (size: number) => {
if (size < 1024) {
return size + "B";
} else if (size < 1024 * 1024) {
return (size / 1024).toFixed(2) + "KB";
} else {
return (size / 1024 / 1024).toFixed(2) + "MB";
}
};
// 处理清除缓存
const handleClearCache = async () => {
if (cacheSize.value === "获取失败") {
uni.showToast({
title: "获取缓存信息失败,请稍后重试",
icon: "none",
duration: 2000,
});
return;
}
if (cacheSize.value === "0B") {
uni.showToast({
title: "暂无缓存需要清理",
icon: "none",
duration: 2000,
});
return;
}
if (clearing.value) {
return;
}
try {
clearing.value = true;
// 模拟清理过程
await new Promise((resolve) => setTimeout(resolve, 1500));
// 清除缓存
await uni.clearStorage();
// 更新缓存大小显示
await getCacheSize();
// 提示清理成功
uni.showToast({
title: "清理成功",
icon: "success",
});
} catch (error) {
uni.showToast({
title: "清理失败",
icon: "error",
});
} finally {
clearing.value = false;
}
};
onShow(() => {
getCacheSize();
});
</script>
<style lang="scss" scoped>
@@ -110,4 +219,49 @@ page {
background: linear-gradient(60deg, #165dff, #6aa1ff);
}
}
.loading-mask {
position: fixed;
top: 0;
right: 0;
bottom: 0;
left: 0;
z-index: 9999;
display: flex;
align-items: center;
justify-content: center;
background-color: rgba(0, 0, 0, 0.4);
.loading-content {
padding: 30rpx 40rpx;
text-align: center;
background-color: rgba(255, 255, 255, 0.95);
border-radius: 12rpx;
box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.15);
.loading-icon {
width: 60rpx;
height: 60rpx;
margin: 0 auto 20rpx;
border: 4rpx solid #f3f3f3;
border-top: 4rpx solid #409eff;
border-radius: 50%;
animation: spin 1s linear infinite;
}
.loading-text {
font-size: 28rpx;
font-weight: 500;
color: #333;
}
}
}
@keyframes spin {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
</style>

View File

@@ -0,0 +1,316 @@
<template>
<view class="network-test">
<!-- 网络状态展示 -->
<view class="status-card">
<view class="status-header">
<text class="title">网络状态</text>
<text :class="['status-badge', networkType ? 'online' : 'offline']">
{{ networkType ? "在线" : "离线" }}
</text>
</view>
<view class="status-info">
<view class="info-item">
<text class="label">网络类型</text>
<text class="value">{{ networkType || "未知" }}</text>
</view>
<view class="info-item">
<text class="label">网络强度</text>
<text class="value">{{ signalStrength }}</text>
</view>
</view>
</view>
<!-- 网络测试 -->
<view class="test-card">
<view class="test-header">
<text class="title">网络测试</text>
<text class="subtitle">测试服务器连接情况</text>
</view>
<view class="test-content">
<view class="test-item">
<text class="label">延迟</text>
<text class="value">{{ pingResult.delay }}ms</text>
<text :class="['status', getPingStatus]">{{ pingResult.status }}</text>
</view>
<view v-if="testing" class="progress-bar">
<view class="progress" :style="{ width: `${progress}%` }" />
</view>
<button class="test-btn" :disabled="testing" @click="startTest">
{{ testing ? "测试中..." : "开始测试" }}
</button>
</view>
</view>
</view>
</template>
<script lang="ts" setup>
interface PingResult {
delay: string | number;
status: string;
}
// 声明全局 wx 对象
declare const wx: any;
// 响应式状态
const networkType = ref("");
const signalStrength = ref("获取中...");
const testing = ref(false);
const progress = ref(0);
const pingResult = ref<PingResult>({
delay: "--",
status: "未测试",
});
const networkListener = ref<any>(null);
// 计算属性
const getPingStatus = computed(() => {
if (pingResult.value.delay === "--") return "";
// 将 delay 转换为数字进行比较
const delay = Number(pingResult.value.delay);
if (isNaN(delay)) return "";
if (delay < 100) return "good";
if (delay < 300) return "normal";
return "bad";
});
// 方法
const getNetworkType = async () => {
try {
const res = await uni.getNetworkType();
networkType.value = res.networkType;
// 微信小程序支持获取信号强度
// #ifdef MP-WEIXIN
if (wx?.getNetworkWeakness) {
const weaknessRes = await wx.getNetworkWeakness();
signalStrength.value = `${weaknessRes.weaknessLevel}%`;
} else {
signalStrength.value = "不支持";
}
// #endif
// H5环境
// #ifdef H5
signalStrength.value = (navigator as any).connection
? `${(navigator as any).connection.effectiveType || "未知"}`
: "不支持";
// #endif
} catch (error) {
networkType.value = "获取失败";
signalStrength.value = "获取失败";
}
};
// 监听网络状态变化
const listenNetworkStatus = () => {
// #ifdef MP-WEIXIN
networkListener.value = wx?.onNetworkStatusChange((res: any) => {
networkType.value = res.networkType;
getNetworkType();
});
// #endif
// #ifdef H5
window.addEventListener("online", getNetworkType);
window.addEventListener("offline", () => {
networkType.value = "";
signalStrength.value = "离线";
});
// #endif
};
// 开始网络测试
const startTest = async () => {
if (testing.value) return;
testing.value = true;
progress.value = 0;
pingResult.value.delay = "--";
pingResult.value.status = "测试中";
const progressTimer = setInterval(() => {
if (progress.value < 90) {
progress.value += 10;
}
}, 200);
try {
const startTime = Date.now();
await uni.request({
url: "/api/v1/auth/captcha",
timeout: 5000,
});
const endTime = Date.now();
const delay = endTime - startTime;
pingResult.value.delay = delay;
pingResult.value.status = delay < 300 ? "正常" : "较慢";
} catch (error) {
pingResult.value.delay = "--";
pingResult.value.status = "连接失败";
} finally {
clearInterval(progressTimer);
progress.value = 100;
setTimeout(() => {
testing.value = false;
progress.value = 0;
}, 500);
}
};
// 生命周期钩子
onMounted(() => {
getNetworkType();
listenNetworkStatus();
});
onBeforeUnmount(() => {
// #ifdef MP-WEIXIN
if (networkListener.value?.clear) {
networkListener.value.clear();
}
// #endif
// #ifdef H5
window.removeEventListener("online", getNetworkType);
window.removeEventListener("offline", getNetworkType);
// #endif
});
</script>
<style lang="scss" scoped>
.network-test {
min-height: 100vh;
padding: 20px;
background-color: #f5f5f5;
}
.status-card,
.test-card {
padding: 20px;
margin-bottom: 20px;
background-color: #fff;
border-radius: 8px;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}
.status-header,
.test-header {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 20px;
.title {
font-size: 18px;
font-weight: 600;
color: #333;
}
}
.status-badge {
padding: 4px 12px;
font-size: 14px;
border-radius: 12px;
&.online {
color: #4caf50;
background-color: #e8f5e9;
}
&.offline {
color: #f44336;
background-color: #ffebee;
}
}
.status-info,
.test-content {
.info-item,
.test-item {
display: flex;
align-items: center;
margin-bottom: 12px;
.label {
width: 100px;
font-size: 15px;
color: #666;
}
.value {
flex: 1;
font-size: 15px;
color: #333;
}
.status {
padding: 2px 8px;
font-size: 13px;
border-radius: 4px;
&.good {
color: #4caf50;
background-color: #e8f5e9;
}
&.normal {
color: #ff9800;
background-color: #fff3e0;
}
&.bad {
color: #f44336;
background-color: #ffebee;
}
}
}
}
.test-header {
.subtitle {
font-size: 14px;
color: #999;
}
}
.progress-bar {
height: 4px;
margin: 20px 0;
overflow: hidden;
background-color: #f5f5f5;
border-radius: 2px;
.progress {
height: 100%;
background-color: #409eff;
transition: width 0.2s ease-in-out;
}
}
.test-btn {
width: 100%;
height: 44px;
margin-top: 20px;
font-size: 16px;
line-height: 44px;
color: #fff;
text-align: center;
background-color: #409eff;
border: none;
border-radius: 22px;
&:active {
opacity: 0.9;
}
&[disabled] {
cursor: not-allowed;
background-color: #a0cfff;
}
}
</style>

View File

@@ -0,0 +1,110 @@
<template>
<view class="privacy-container">
<view class="privacy-header">
<text class="header-title">隐私政策</text>
<text class="header-date">更新日期2024年3月15日</text>
</view>
<view class="privacy-content">
<view v-for="(section, index) in privacyContent" :key="index" class="section">
<text class="section-title">{{ section.title }}</text>
<text class="section-text">{{ section.content }}</text>
</view>
</view>
</view>
</template>
<script>
export default {
name: "Privacy",
data() {
return {
privacyContent: [
{
title: "1. 信息收集",
content:
"我们可能收集您的基本信息(如设备信息、操作日志等)以提供更好的服务体验。我们承诺对这些信息进行严格保密,并只用于改善产品服务。",
},
{
title: "2. 信息使用",
content:
"收集的信息将用于:优化用户体验、提供客户支持、发送重要通知、保障账号安全等。未经您的同意,我们不会向第三方分享您的个人信息。",
},
{
title: "3. 信息安全",
content:
"我们采用业界标准的安全技术和程序来保护您的个人信息,防止未经授权的访问、使用或泄露。我们定期审查信息收集、存储和处理实践。",
},
{
title: "4. Cookie 使用",
content:
"我们使用 Cookie 和类似技术来提供、保护和改进我们的产品和服务。这些技术帮助我们了解用户行为,告诉我们哪些功能最受欢迎。",
},
{
title: "5. 第三方服务",
content:
"我们的应用可能包含第三方服务。这些第三方服务有自己的隐私政策,我们建议您查看这些政策。我们不对第三方的隐私实践负责。",
},
{
title: "6. 未成年人保护",
content:
"我们非常重视对未成年人个人信息的保护。若您是未成年人,请在监护人指导下使用我们的服务。如果您是监护人,当您对您所监护的未成年人的个人信息有疑问时,请联系我们。",
},
{
title: "7. 隐私政策更新",
content:
"我们可能会不时更新本隐私政策。当我们更新隐私政策时,我们会在本页面上发布更新后的版本并修改更新日期。建议您定期查看本页面。",
},
],
};
},
};
</script>
<style lang="scss" scoped>
.privacy-container {
min-height: 100vh;
padding: 20px;
background-color: #fff;
}
.privacy-header {
margin-bottom: 30px;
text-align: center;
.header-title {
display: block;
margin-bottom: 10px;
font-size: 22px;
font-weight: 600;
color: #333;
}
.header-date {
font-size: 14px;
color: #999;
}
}
.privacy-content {
.section {
margin-bottom: 25px;
.section-title {
display: block;
margin-bottom: 12px;
font-size: 17px;
font-weight: 500;
color: #333;
}
.section-text {
display: block;
font-size: 15px;
line-height: 1.6;
color: #666;
text-align: justify;
}
}
}
</style>

View File

@@ -59,7 +59,9 @@
</wd-row>
<template #footer>
<wd-button size="small" type="primary" @click="handleAction(item)">···</wd-button>
<wd-button size="small" plain type="primary" @click="handleAction(item)">
操作
</wd-button>
</template>
</wd-card>
</view>

View File

@@ -76,7 +76,7 @@
</wd-row>
<template #footer>
<wd-button size="small" type="primary" @click="handleAction(item)">···</wd-button>
<wd-button size="small" plain type="primary" @click="handleAction(item)">操作</wd-button>
</template>
</wd-card>
</view>

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.6 KiB