Files
gao-customer-h5/src/pages/setting/About.vue
T
2026-11-02 23:12:05 +08:00

217 lines
4.5 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<template>
<div class="tui-page-layout tui-navbar">
<t-navbar
fixed
:z-index="20"
title="关于"
left-arrow
@left-click="$router.back()"
/>
<main class="tui-page-content scroll column">
<div class="about-page">
<section class="brand" v-entrance-transition>
<logo @click="handleLogoClick" />
<h1 v-text="appName" />
<p v-text="appDescription" />
</section>
<t-cell-group v-if="agreementItemList.length" theme="card" v-entrance-transition>
<t-cell
v-for="item in agreementItemList"
:key="item.id"
:title="item.title"
arrow
hover
@click="openAgreement(item)"
>
<template #leftIcon>
<t-icon :name="item.icon" size="1.75rem" />
</template>
</t-cell>
</t-cell-group>
<t-empty
v-else
:description="isLoading ? '正在加载协议配置' : '暂无可用协议'"
/>
<footer class="footer" v-entrance-transition>
<p>技术支持:夜雨</p>
<p>联系技术:imyeyu@qq.com</p>
<p>短信服务支持:广州易保网络科技有限公司</p>
<p>Copyright © 2026 imyeyu.com</p>
</footer>
</div>
</main>
</div>
</template>
<script setup lang="ts">
import { SettingAPI } from "timi-web-api";
import Logo from "@/pages/user/component/Logo.vue";
import { getErrorMessage } from "@/utils/error";
import { Message } from "@/utils/message";
import { toggleVConsole } from "@/utils/vConsole";
type AgreementItem = {
icon: string;
id: string;
title: string;
};
defineOptions({
name: "About"
});
const appName = "糕店客户管理";
const appDescription = "面向门店的客户、登记、积分与经营管理工具";
const router = useRouter();
const agreementItemList = ref<AgreementItem[]>([]);
const isLoading = ref(false);
let debugClickCount = 0;
let debugClickTimer: number | undefined;
async function handleLogoClick(): Promise<void> {
debugClickCount++;
if (debugClickTimer !== undefined) {
window.clearTimeout(debugClickTimer);
}
debugClickTimer = window.setTimeout(() => {
debugClickCount = 0;
debugClickTimer = undefined;
}, 1_500);
if (debugClickCount < 5) {
return;
}
debugClickCount = 0;
window.clearTimeout(debugClickTimer);
debugClickTimer = undefined;
await toggleVConsole();
}
async function openAgreement(item: AgreementItem): Promise<void> {
await router.push({
name: "Agreement",
params: {
id: item.id
}
});
}
function normalizeAgreementItem(value: unknown): AgreementItem | undefined {
if (!value || typeof value !== "object") {
return undefined;
}
const source = value as Record<string, unknown>;
const id = typeof source.id === "string" ? source.id.trim() : "";
const title = typeof source.title === "string" ? source.title.trim() : "";
const icon = typeof source.icon === "string" ? source.icon.trim() : "";
if (!id || !title) {
return undefined;
}
return {
id,
title,
icon: icon || "file-attachment"
};
}
function parseAgreementList(value?: string): AgreementItem[] {
if (!value?.trim()) {
return [];
}
try {
const sourceList: unknown = JSON.parse(value);
if (!Array.isArray(sourceList)) {
return [];
}
return sourceList
.map(item => normalizeAgreementItem(item))
.filter((item): item is AgreementItem => !!item);
} catch {
Message.error("协议配置格式错误");
return [];
}
}
async function loadSettings(): Promise<void> {
isLoading.value = true;
try {
const settingMap = await SettingAPI.map("GAO_SYSTEM", undefined, ["AGREEMENT"]);
agreementItemList.value = parseAgreementList(settingMap.AGREEMENT?.value);
} catch (error) {
Message.error(getErrorMessage(error, "协议配置加载失败"));
} finally {
isLoading.value = false;
}
}
onMounted(async () => {
await loadSettings();
});
</script>
<style scoped lang="less">
.about-page {
gap: 1rem;
display: flex;
padding: 0 0 5rem;
flex-direction: column;
.brand {
padding: 1rem;
text-align: center;
.logo {
margin: 0 auto;
}
h1 {
margin: .875rem 0 .5rem;
color: #0f172a;
font-size: 1.5rem;
font-weight: 700;
}
p {
margin: 0;
color: #52607a;
font-size: .875rem;
line-height: 1.7;
}
}
.footer {
padding: 1.25rem 1rem calc(1rem + env(safe-area-inset-bottom, 0));
text-align: center;
p {
margin: 0;
color: #52607a;
font-size: .8125rem;
line-height: 1.8;
}
}
}
:global(html.theme-dark) {
.about-page {
.brand {
h1 {
color: #e2e8f0;
}
p {
color: #94a3b8;
}
}
.footer p {
color: #94a3b8;
}
}
}
</style>