refactor: 全面重构移动端架构与规范落地
页面迁移至 subPages 分包,路由改用 definePage 宏驱动;抽取 usePagedList/useActionSheet/useSmsCode 组合式函数;统一 API 命名、toast 与主题色变量;登录页视觉收敛并清理无效字段及废弃依赖
This commit is contained in:
1 parent
907b07f552
commit
e0cff93f0b
102 files changed
+2044
-4584
No files matched your search
@@ -0,0 +1,172 @@
|
||||
<template>
|
||||
<view>
|
||||
<view class="network__tip">
|
||||
<text class="network__tip-text">
|
||||
温馨提示:点击下方「开始测试」按钮,即可自动检测当前网络延迟。
|
||||
</text>
|
||||
</view>
|
||||
|
||||
<view class="network__action">
|
||||
<wd-button block plain @click="startTest">开始测试</wd-button>
|
||||
</view>
|
||||
|
||||
<view v-if="isTesting" class="network__loading">
|
||||
<wd-loading color="var(--wot-color-theme)" />
|
||||
<text class="network__loading-text">正在测试中...</text>
|
||||
</view>
|
||||
|
||||
<view v-if="result !== null" class="network__result">
|
||||
<view class="result-card">
|
||||
<view class="result-card__header">测试结果</view>
|
||||
<view class="result-card__row">
|
||||
<text style="color: var(--color-text-secondary)">网络延迟</text>
|
||||
<text :class="['network__delay', statusColor]">{{ result }}ms</text>
|
||||
</view>
|
||||
<view class="result-card__row">
|
||||
<text style="color: var(--color-text-secondary)">网络状态</text>
|
||||
<text :class="['network__status', statusColor]">{{ statusText }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { onLoad } from "@dcloudio/uni-app";
|
||||
|
||||
definePage({
|
||||
name: "network",
|
||||
style: { navigationBarTitleText: "网络测试" },
|
||||
});
|
||||
|
||||
const result = ref<number | null>(null);
|
||||
const isTesting = ref(false);
|
||||
|
||||
const statusText = computed(() => {
|
||||
if (result.value == null) return "";
|
||||
if (result.value < 100) return "优秀";
|
||||
if (result.value < 300) return "良好";
|
||||
if (result.value < 500) return "一般";
|
||||
return "较差";
|
||||
});
|
||||
|
||||
const statusColor = computed(() => {
|
||||
if (result.value == null) return "";
|
||||
if (result.value < 100) return "color-success";
|
||||
if (result.value < 300) return "color-primary";
|
||||
if (result.value < 500) return "color-warning";
|
||||
return "color-danger";
|
||||
});
|
||||
|
||||
const startTest = async () => {
|
||||
isTesting.value = true;
|
||||
result.value = null;
|
||||
try {
|
||||
const startTime = Date.now();
|
||||
// #ifdef MP-WEIXIN
|
||||
await new Promise<void>((resolve) => {
|
||||
wx.request({
|
||||
url: "https://www.baidu.com",
|
||||
method: "GET",
|
||||
success: () => resolve(),
|
||||
fail: () => resolve(),
|
||||
});
|
||||
});
|
||||
// #endif
|
||||
// #ifdef H5
|
||||
await fetch("https://www.baidu.com", { mode: "no-cors" });
|
||||
// #endif
|
||||
result.value = Date.now() - startTime;
|
||||
} catch {
|
||||
result.value = 9999;
|
||||
} finally {
|
||||
isTesting.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
onLoad(() => {
|
||||
uni.setNavigationBarTitle({ title: "网络测试" });
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.result-card {
|
||||
overflow: hidden;
|
||||
background: var(--color-bg);
|
||||
border: 1rpx solid var(--color-border);
|
||||
border-radius: 16rpx;
|
||||
|
||||
&__header {
|
||||
padding: 24rpx;
|
||||
font-size: 32rpx;
|
||||
font-weight: 600;
|
||||
border-bottom: 1rpx solid var(--color-border);
|
||||
}
|
||||
|
||||
&__row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 24rpx;
|
||||
|
||||
& + & {
|
||||
border-top: 1rpx solid var(--color-border-light);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.network__tip {
|
||||
padding: 24rpx 32rpx;
|
||||
}
|
||||
|
||||
.network__tip-text {
|
||||
font-size: 24rpx;
|
||||
color: var(--color-text-placeholder);
|
||||
}
|
||||
|
||||
.network__action {
|
||||
padding: 0 32rpx;
|
||||
}
|
||||
|
||||
.network__loading {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
padding: 40rpx 0;
|
||||
}
|
||||
|
||||
.network__loading-text {
|
||||
margin-top: 16rpx;
|
||||
font-size: 24rpx;
|
||||
color: var(--color-text-secondary);
|
||||
}
|
||||
|
||||
.network__result {
|
||||
padding: 0 32rpx;
|
||||
}
|
||||
|
||||
.network__delay {
|
||||
font-size: 36rpx;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.network__status {
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.color-success {
|
||||
color: var(--color-success);
|
||||
}
|
||||
|
||||
.color-primary {
|
||||
color: var(--color-primary);
|
||||
}
|
||||
|
||||
.color-warning {
|
||||
color: var(--color-warning);
|
||||
}
|
||||
|
||||
.color-danger {
|
||||
color: var(--color-danger);
|
||||
}
|
||||
</style>
|
||||
Reference in new issue
Block a user