support tablet

This commit is contained in:
Timi
2026-11-02 23:12:05 +08:00
parent c48b19bed5
commit d3879c9c77
123 changed files with 4153 additions and 2673 deletions
+2 -2
View File
@@ -389,7 +389,7 @@ onMounted(async () => {
<style scoped lang="less">
.notify-management-create {
min-height: 100%;
padding-top: var(--app-nav-height);
padding-top: var(--tui-nav-height);
.form {
margin: 0;
@@ -448,7 +448,7 @@ onMounted(async () => {
width: 100%;
min-width: 0;
max-width: 100%;
top: var(--app-nav-height);
top: var(--tui-nav-height);
z-index: 10;
position: sticky;
}
+38 -5
View File
@@ -1,11 +1,11 @@
<template>
<div class="page-layout navbar">
<div class="tui-page-layout tui-navbar">
<t-navbar
fixed
:z-index="20"
title="通知详情"
left-arrow
@left-click="$router.back()"
@left-click="goBack"
>
<template #right>
<t-button
@@ -18,7 +18,7 @@
/>
</template>
</t-navbar>
<main class="page-content scroll column">
<main class="tui-page-content scroll column">
<div v-can="corePermissionCodes.notify.read" class="notify-detail">
<t-empty
v-if="!detail"
@@ -73,6 +73,7 @@ import NotifyContent from "@/pages/notify/component/NotifyContent.vue";
import { corePermissionCodes } from "@/utils/permission";
import { useExpandToMaster, usePane } from "timi-tdesign-mobile";
type NotifyTagTheme = "default" | "success" | "warning" | "primary" | "danger";
type RecipientFilter = "all" | "unread" | "read";
@@ -81,8 +82,36 @@ defineOptions({
name: "NotifyDetail"
});
const props = withDefaults(defineProps<{
/** 指定通知 ID 时忽略路由参数,用于平板主从分栏的内联渲染。 */
notifyId?: string;
}>(), {
notifyId: ""
});
const route = useRoute();
const router = useRouter();
function resolveId(): string {
return props.notifyId || String(route.params.id || "");
}
// 竖屏整页进来后转成横屏:回到列表页并恢复右栏选中,而不是继续停在整页详情
useExpandToMaster({
path: "/management/notifications",
id: () => resolveId()
});
/** 非空说明当前被内联在主从分栏的右栏里 */
const pane = usePane();
function goBack(): void {
if (pane) {
pane.close();
return;
}
void router.back();
}
const userStore = useUserStore();
const canDeleteNotify = computed(() => userStore.hasPermissions(corePermissionCodes.notify.delete));
const canCancelNotify = computed(() => userStore.hasPermissions(corePermissionCodes.notify.cancel));
@@ -133,7 +162,7 @@ async function loadDetail(): Promise<void> {
const requestToken = loadToken + 1;
loadToken = requestToken;
detail.value = undefined;
const notifyId = String(route.params.id || "");
const notifyId = resolveId();
if (!notifyId) {
return;
}
@@ -209,6 +238,10 @@ async function confirmDelete(): Promise<void> {
try {
await NotifyAPI.managementDelete(notifyId);
Message.success("通知已删除");
if (pane) {
pane.close();
return;
}
await router.replace({ name: "NotifyList" });
} catch (error) {
Message.error(getErrorMessage(error, "通知删除失败"));
@@ -269,7 +302,7 @@ async function openRecipientListByFilter(filter: RecipientFilter): Promise<void>
// ---------- 生命周期 ----------
watch(() => route.params.id, async () => {
watch(() => [props.notifyId, route.params.id], async () => {
await loadDetail();
}, { immediate: true });
+80 -64
View File
@@ -1,5 +1,5 @@
<template>
<div class="page-layout navbar notify-management">
<div class="tui-page-layout tui-navbar notify-management">
<t-navbar
fixed
:z-index="20"
@@ -18,64 +18,78 @@
/>
</template>
</t-navbar>
<main v-can="corePermissionCodes.notify.read" class="page-content scroll column list">
<t-pull-down-refresh
class="pull-refresh"
v-model="isRefreshing"
:refresh-timeout="30000"
@refresh="refresh"
@scrolltolower="loadMore"
>
<t-cell-group
v-if="pageResult.list.length"
class="items fix-last-cell-line"
theme="card"
<master-detail-page
v-can="corePermissionCodes.notify.read"
class="list"
:split="isWide"
:selected="!!selectedId"
:direction="paneDirection"
>
<template #master>
<t-pull-down-refresh
class="pull-refresh"
v-model="isRefreshing"
:refresh-timeout="30000"
@refresh="refresh"
@scrolltolower="loadMore"
>
<t-swipe-cell
v-for="item in pageResult.list"
:key="item.id"
class="item"
v-entrance-transition="{ step: 30 }"
<t-cell-group
v-if="pageResult.list.length"
class="items fix-last-cell-line"
theme="card"
>
<t-cell arrow @click="toDetail(item)">
<template #leftIcon>
<div class="icon" :class="{ scheduled: isScheduled(item) }">
<t-icon :name="isScheduled(item) ? 'time' : 'notification'" size="1.25rem" />
</div>
<t-swipe-cell
v-for="item in pageResult.list"
:key="item.id"
class="item"
v-entrance-transition="{ step: 30 }"
>
<t-cell arrow @click="toDetail(item)">
<template #leftIcon>
<div class="icon" :class="{ scheduled: isScheduled(item) }">
<t-icon :name="isScheduled(item) ? 'time' : 'notification'" size="1.25rem" />
</div>
</template>
<template #title>
<div class="title">
<span v-text="getSubject(item)" />
</div>
</template>
<template #description>
<span v-if="isScheduled(item)" v-text="`定时 ${Time.toDateTime(item.sendAt)}`" />
<time-label v-else :timestamp="item.sendAt || item.createdAt" underline />
</template>
<template #note>
<t-tag size="small" :theme="getStatusTheme(item)" :content="getStatusText(item)" />
</template>
</t-cell>
<template #right>
<t-button
v-if="canCancel(item)"
class="cancel"
theme="primary"
@click.stop="confirmCancel(item)"
>取消</t-button>
<t-button
v-if="canDeleteNotify"
class="delete"
theme="danger"
@click.stop="confirmDelete(item)"
>删除</t-button>
</template>
<template #title>
<div class="title">
<span v-text="getSubject(item)" />
</div>
</template>
<template #description>
<span v-if="isScheduled(item)" v-text="`定时 ${Time.toDateTime(item.sendAt)}`" />
<time-label v-else :timestamp="item.sendAt || item.createdAt" underline />
</template>
<template #note>
<t-tag size="small" :theme="getStatusTheme(item)" :content="getStatusText(item)" />
</template>
</t-cell>
<template #right>
<t-button
v-if="canCancel(item)"
class="cancel"
theme="primary"
@click.stop="confirmCancel(item)"
>取消</t-button>
<t-button
v-if="canDeleteNotify"
class="delete"
theme="danger"
@click.stop="confirmDelete(item)"
>删除</t-button>
</template>
</t-swipe-cell>
</t-cell-group>
<t-empty v-else-if="!isLoading" description="暂无已发送通知" />
<center-tips :content="loadStateText" />
</t-pull-down-refresh>
</main>
</t-swipe-cell>
</t-cell-group>
<t-empty v-else-if="!isLoading" description="暂无已发送通知" />
<center-tips :content="loadStateText" />
</t-pull-down-refresh>
</template>
<template #detail>
<notify-detail
:key="`detail-${selectedId}`"
:notify-id="selectedId"
/>
</template>
</master-detail-page>
</div>
</template>
@@ -91,6 +105,8 @@ import { getErrorMessage } from "@/utils/error";
import { corePermissionCodes } from "@/utils/permission";
import { MasterDetailPage, useMasterDetailPane } from "timi-tdesign-mobile";
import NotifyDetail from "@/pages/notify/NotifyDetail.vue";
type NotifyTagTheme = "default" | "success" | "warning" | "primary" | "danger";
@@ -99,6 +115,12 @@ defineOptions({
});
const pageSize = 20;
// 选中项、切换方向、关闭逻辑、转屏、query 同步都在这里;通知没有内联编辑视图
const { selectedId, paneDirection, isWide, openDetail } = useMasterDetailPane({
path: "/management/notifications",
detail: id => `/management/notifications/${id}`
});
const router = useRouter();
const userStore = useUserStore();
const canReadNotify = computed(() => userStore.hasPermissions(corePermissionCodes.notify.read));
@@ -211,13 +233,7 @@ async function refresh(): Promise<void> {
}
async function toDetail(item: NotifyManagementItem): Promise<void> {
if (!item.id) {
return;
}
await router.push({
name: "NotifyDetail",
params: { id: item.id }
});
openDetail(item.id || "");
}
async function toCreate(): Promise<void> {
@@ -292,7 +308,7 @@ onMounted(async () => {
<style scoped lang="less">
.notify-management {
min-height: 100%;
padding: calc(var(--app-nav-height) + 1rem) 0 1rem;
padding: calc(var(--tui-nav-height) + 1rem) 0 1rem;
.items {
overflow: hidden;
+2 -2
View File
@@ -1,5 +1,5 @@
<template>
<div class="page-layout navbar">
<div class="tui-page-layout tui-navbar">
<t-navbar
fixed
:z-index="20"
@@ -7,7 +7,7 @@
left-arrow
@left-click="$router.back()"
/>
<main class="page-content scroll column list">
<main class="tui-page-content scroll column list">
<div class="pull-refresh">
<div v-can="corePermissionCodes.notify.read" class="notify-recipient-list">
<template v-if="detail">
+38 -5
View File
@@ -1,11 +1,11 @@
<template>
<div class="page-layout navbar">
<div class="tui-page-layout tui-navbar">
<t-navbar
fixed
:z-index="20"
title="通知详情"
left-arrow
@left-click="$router.back()"
@left-click="goBack"
>
<template #right>
<t-button
@@ -18,7 +18,7 @@
/>
</template>
</t-navbar>
<main class="page-content scroll column bg-white">
<main class="tui-page-content scroll column bg-white">
<div v-can="corePermissionCodes.notify.read" class="notify-detail">
<notify-content
v-if="detail"
@@ -42,6 +42,7 @@ import { DialogPlugin } from "tdesign-mobile-vue";
import { getAttachmentReadURL } from "@/utils/attachment";
import { corePermissionCodes } from "@/utils/permission";
import { Message } from "@/utils/message.ts";
import { useExpandToMaster, usePane } from "timi-tdesign-mobile";
import NotifyContent from "@/pages/notify/component/NotifyContent.vue";
@@ -50,9 +51,37 @@ import NotifyContent from "@/pages/notify/component/NotifyContent.vue";
import { getErrorMessage } from "@/utils/error";
const props = withDefaults(defineProps<{
/** 指定通知 ID 时忽略路由参数,用于平板主从分栏的内联渲染。 */
notifyId?: string;
}>(), {
notifyId: ""
});
const route = useRoute();
const router = useRouter();
function resolveId(): string {
return props.notifyId || String(route.params.id || "");
}
// 竖屏整页进来后转成横屏:回到列表页并恢复右栏选中,而不是继续停在整页详情
useExpandToMaster({
path: "/notify",
id: () => resolveId()
});
/** 非空说明当前被内联在主从分栏的右栏里 */
const pane = usePane();
function goBack(): void {
if (pane) {
pane.close();
return;
}
void router.back();
}
defineOptions({
name: "UserNotifyDetail"
});
@@ -67,7 +96,7 @@ let loadToken = 0;
async function loadDetail(): Promise<void> {
const requestToken = loadToken + 1;
loadToken = requestToken;
const detailId = String(route.params.id || "");
const detailId = resolveId();
if (!detailId) {
detail.value = undefined;
return;
@@ -124,6 +153,10 @@ async function deleteDetail(detailId: string): Promise<void> {
try {
await NotifyAPI.deleteInternal(detailId);
Message.success("通知已删除");
if (pane) {
pane.close();
return;
}
await router.replace({ name: "UserNotifyList" });
} catch (error) {
Message.error(getErrorMessage(error, "通知删除失败"));
@@ -161,7 +194,7 @@ function resolveAttachmentUrl(attachmentId: string): string {
// ---------- 生命周期 ----------
watch(() => route.params.id, async () => {
watch(() => [props.notifyId, route.params.id], async () => {
await loadDetail();
}, { immediate: true });
+87 -72
View File
@@ -1,5 +1,5 @@
<template>
<div class="page-layout navbar notify-list">
<div class="tui-page-layout tui-navbar notify-list">
<t-navbar
fixed
:z-index="20"
@@ -18,71 +18,85 @@
/>
</template>
</t-navbar>
<main v-can="corePermissionCodes.notify.read" class="page-content scroll column list">
<t-pull-down-refresh
class="pull-refresh"
v-model="isRefreshing"
:refresh-timeout="30000"
@refresh="refresh"
@scrolltolower="loadMore"
>
<t-segmented
v-model="filterMode"
class="filter"
block
:options="filterOptions"
@change="switchFilter"
v-entrance-transition
/>
<t-cell-group v-if="pageResult.list.length" class="items fix-last-cell-line" theme="card">
<t-swipe-cell
v-for="item in pageResult.list"
:key="item.id"
class="item"
v-entrance-transition="{ step: 30 }"
>
<t-cell arrow hover @click="toDetail(item)">
<template #leftIcon>
<div class="icon" :class="{ unread: isUnread(item) }">
<t-icon name="notification" size="1.25rem" />
</div>
</template>
<template #title>
<div class="title">
<span v-text="getSubject(item)" />
</div>
</template>
<template #description>
<time-label :timestamp="item.sendAt" underline />
</template>
<template #note>
<t-tag
v-if="filterMode === 'all' && isUnread(item)"
class="unread-label"
<master-detail-page
v-can="corePermissionCodes.notify.read"
class="list"
:split="isWide"
:selected="!!selectedId"
:direction="paneDirection"
>
<template #master>
<t-pull-down-refresh
class="pull-refresh"
v-model="isRefreshing"
:refresh-timeout="30000"
@refresh="refresh"
@scrolltolower="loadMore"
>
<t-segmented
v-model="filterMode"
class="filter"
block
:options="filterOptions"
@change="switchFilter"
v-entrance-transition
/>
<t-cell-group v-if="pageResult.list.length" class="items fix-last-cell-line" theme="card">
<t-swipe-cell
v-for="item in pageResult.list"
:key="item.id"
class="item"
v-entrance-transition="{ step: 30 }"
>
<t-cell arrow hover @click="toDetail(item)">
<template #leftIcon>
<div class="icon" :class="{ unread: isUnread(item) }">
<t-icon name="notification" size="1.25rem" />
</div>
</template>
<template #title>
<div class="title">
<span v-text="getSubject(item)" />
</div>
</template>
<template #description>
<time-label :timestamp="item.sendAt" underline />
</template>
<template #note>
<t-tag
v-if="filterMode === 'all' && isUnread(item)"
class="unread-label"
theme="danger"
size="small"
>未读</t-tag>
</template>
</t-cell>
<template #right>
<t-button
class="delete"
theme="danger"
size="small"
>未读</t-tag>
:loading="deletingId === item.id"
@click.stop="confirmDelete(item)"
>
删除
</t-button>
</template>
</t-cell>
<template #right>
<t-button
class="delete"
theme="danger"
:loading="deletingId === item.id"
@click.stop="confirmDelete(item)"
>
删除
</t-button>
</template>
</t-swipe-cell>
</t-cell-group>
<t-empty
v-else-if="!isLoading"
description="暂无站内通知"
</t-swipe-cell>
</t-cell-group>
<t-empty
v-else-if="!isLoading"
description="暂无站内通知"
/>
<center-tips :content="loadStateText" />
</t-pull-down-refresh>
</template>
<template #detail>
<user-notify-detail
:key="`detail-${selectedId}`"
:notify-id="selectedId"
/>
<center-tips :content="loadStateText" />
</t-pull-down-refresh>
</main>
</template>
</master-detail-page>
</div>
</template>
@@ -92,6 +106,8 @@ import { NotifyAPI, type NotifyDetail, type Page, type PageResult, useUserStore
import { DialogPlugin } from "tdesign-mobile-vue";
import { Message } from "@/utils/message";
import { corePermissionCodes } from "@/utils/permission";
import { MasterDetailPage, useMasterDetailPane } from "timi-tdesign-mobile";
import UserNotifyDetail from "@/pages/notify/UserNotifyDetail.vue";
@@ -106,7 +122,12 @@ defineOptions({
});
const pageSize = 20;
const router = useRouter();
// 选中项、切换方向、关闭逻辑、转屏、query 同步都在这里;站内通知没有内联编辑视图
const { selectedId, paneDirection, isWide, openDetail } = useMasterDetailPane({
path: "/notify",
detail: id => `/notify/${id}`
});
const userStore = useUserStore();
const canReadNotify = computed(() => userStore.hasPermissions(corePermissionCodes.notify.read));
@@ -305,13 +326,7 @@ function getSubject(item: NotifyDetail): string {
}
async function toDetail(item: NotifyDetail): Promise<void> {
if (!item.id) {
return;
}
await router.push({
name: "UserNotifyDetail",
params: { id: item.id }
});
openDetail(item.id || "");
}
// ---------- 生命周期 ----------
@@ -334,7 +349,7 @@ onMounted(async () => {
<style scoped lang="less">
.notify-list {
display: flex;
padding: calc(var(--app-nav-height) + 1rem) 0 1rem 0;
padding: calc(var(--tui-nav-height) + 1rem) 0 1rem 0;
min-height: 100%;
flex-direction: column;