refactor layout

This commit is contained in:
Timi
2026-10-17 12:01:28 +08:00
parent fe467e8781
commit 469c595a7c
134 changed files with 11493 additions and 4437 deletions
+124 -8
View File
@@ -1,4 +1,49 @@
<template>
<t-navbar
fixed
:z-index="20"
title="通知详情"
left-arrow
@left-click="$router.back()"
>
<template #right>
<div
v-if="pageNavBarRight.icon || pageNavBarRight.text"
class="nav-right-slot"
>
<t-badge
v-if="pageNavBarRight.icon && pageNavBarRight.badge !== undefined"
class="badge"
:count="pageNavBarRight.badge"
:max-count="99"
:show-zero="false"
>
<button class="button" type="button" :disabled="pageNavBarRight.disabled" @click="handlePageNavBarRightAction">
<t-icon :name="pageNavBarRight.icon" size="1.25rem" />
</button>
</t-badge>
<button
v-else-if="pageNavBarRight.icon"
class="button"
type="button"
:disabled="pageNavBarRight.disabled"
@click="handlePageNavBarRightAction"
>
<t-icon :name="pageNavBarRight.icon" size="1.25rem" />
</button>
<button
v-else
class="nav-text"
type="button"
:disabled="pageNavBarRight.disabled"
:style="{ color: pageNavBarRight.disabled ? 'var(--td-text-color-disabled)' : pageNavBarRight.textColor || 'var(--td-text-color-primary, #333)' }"
:class="{ clickable: !!pageNavBarRight.action, disabled: pageNavBarRight.disabled }"
@click="handlePageNavBarRightAction"
v-text="pageNavBarRight.text"
/>
</div>
</template>
</t-navbar>
<div v-can="corePermissionCodes.notify.read" class="notify-detail">
<notify-content
v-if="detail"
@@ -17,16 +62,46 @@
<script setup lang="ts">
import { NotifyAPI, type NotifyDetail } from "timi-web-api";
import { DialogPlugin } from "tdesign-mobile-vue";
import { useNavBarStore } from "@/store/navBarStore";
import { getErrorMessage } from "@/utils/error";
import { getAttachmentReadURL } from "@/utils/attachment";
import { corePermissionCodes } from "@/utils/permission";
import { Message } from "@/utils/message.ts";
import NotifyContent from "@/pages/notify/component/NotifyContent.vue";
const pageNavBarRight = reactive({
icon: "",
badge: undefined as number | undefined,
text: "",
textColor: "",
disabled: false,
action: undefined as (() => void | Promise<void>) | undefined
});
function setPageNavBarRightText(value?: string, color?: string, action?: () => void | Promise<void>): void {
pageNavBarRight.text = value || "";
pageNavBarRight.textColor = color || "";
pageNavBarRight.disabled = false;
pageNavBarRight.action = action;
if (value) {
pageNavBarRight.badge = undefined;
pageNavBarRight.icon = "";
}
}
function clearPageNavBarRight(): void {
Object.assign(pageNavBarRight, { icon: "", badge: undefined, text: "", textColor: "", disabled: false, action: undefined });
}
async function handlePageNavBarRightAction(): Promise<void> {
if (pageNavBarRight.disabled || !pageNavBarRight.action) {
return;
}
await pageNavBarRight.action();
}
import { getErrorMessage } from "@/utils/error";
const route = useRoute();
const router = useRouter();
const navBarStore = useNavBarStore();
defineOptions({
name: "UserNotifyDetail"
@@ -42,7 +117,7 @@ let loadToken = 0;
async function loadDetail(): Promise<void> {
const requestToken = loadToken + 1;
loadToken = requestToken;
navBarStore.clearRight();
clearPageNavBarRight();
const detailId = String(route.params.id || "");
if (!detailId) {
detail.value = undefined;
@@ -72,7 +147,7 @@ async function loadDetail(): Promise<void> {
function setDeleteAction(): void {
if (detail.value?.id) {
navBarStore.setRightText("删除", "var(--td-error-color)", confirmDelete);
setPageNavBarRightText("删除", "var(--td-error-color)", confirmDelete);
}
}
@@ -103,7 +178,7 @@ async function deleteDetail(detailId: string): Promise<void> {
}
isDeleting.value = true;
navBarStore.clearRight();
clearPageNavBarRight();
try {
await NotifyAPI.deleteInternal(detailId);
Message.success("通知已删除");
@@ -150,11 +225,11 @@ watch(() => route.params.id, async () => {
}, { immediate: true });
onMounted(() => {
navBarStore.clearRight();
clearPageNavBarRight();
});
onUnmounted(() => {
navBarStore.clearRight();
clearPageNavBarRight();
});
</script>
@@ -162,4 +237,45 @@ onUnmounted(() => {
.notify-detail {
padding: var(--app-nav-height) 0 1rem 0;
}
.nav-right-slot {
width: 6rem;
height: 100%;
display: flex;
align-items: center;
justify-content: flex-end;
.badge {
:deep(.t-badge__content) {
display: flex;
align-items: center;
}
}
.button,
.nav-text {
color: var(--td-text-color-primary, #333);
border: none;
padding: 0;
display: inline-flex;
background: transparent;
align-items: center;
justify-content: center;
}
.button {
&:disabled {
color: var(--td-text-color-disabled);
cursor: not-allowed;
}
}
.nav-text {
font: inherit;
cursor: default;
&.clickable { cursor: pointer; }
&.disabled { cursor: not-allowed; }
}
}
</style>