| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756 |
- import { AppNotificationService } from '../../../core/app-notification.service';
- import { NotificationSetupService } from '../../../core/notification-setup.service';
- import { isNativeApp } from '../../../core/api/platform-proxy.service';
- import { ChatService } from '../../../core/chat.service';
- import { ChangeDetectionStrategy, Component, computed, inject, signal } from '@angular/core';
- import { Router } from '@angular/router';
- import { CHAT_FONT_SIZES, ChatFontService, UI_SCALES, UI_SCALE_LABEL } from '../../../core/chat-font.service';
- import { DEFAULT_PALETTE, PALETTES, PaletteService } from '../../../core/palette.service';
- import { PaletteId } from '../../../core/api/models';
- import { SessionService } from '../../../core/session.service';
- import { ChatSessionService } from '../../../core/chat-session.service';
- import { ThemeService } from '../../../ui/theme/theme.service';
- import { MAppBarComponent } from '../../components/m-app-bar/m-app-bar';
- import { MAvatarComponent } from '../../components/m-avatar/m-avatar';
- import { MDrawerComponent } from '../../components/m-drawer/m-drawer';
- import { MConfirmComponent } from '../../components/m-confirm/m-confirm';
- import { AppUpdateService } from '../../../core/app-update.service';
- import { UpdateDialogComponent } from '../../components/m-update-dialog/m-update-dialog';
- /**
- * 我的 / 设置(Demo 16)
- *
- * 顺序:个人资料 / 通知(原生端)/ 外观 / 账号与 Token / 退出。
- *
- * 配色与深色直接复用既有服务(`PaletteService` / 底座 `ThemeService`),
- * 字号走 `ChatFontService`(写 `--ui-scale`),与桌面设置项**同一真源**,
- * 不另建一套偏好存储。
- */
- @Component({
- selector: 'app-mb-mine-page',
- changeDetection: ChangeDetectionStrategy.OnPush,
- imports: [MAppBarComponent, MAvatarComponent, MDrawerComponent, MConfirmComponent, UpdateDialogComponent],
- template: `
- <div class="m-page--scroll">
- <app-m-app-bar title="我的" [menu]="true" (menuTap)="drawerOpen.set(true)" />
- <div class="m-body">
- <section class="m-section">
- <div class="m-card m-profile">
- <app-m-avatar [name]="me()?.name || '未登录'" size="lg" tone="person" />
- <div class="m-profile-body">
- <div class="m-profile-name">{{ me()?.name || '未登录' }}</div>
- <div class="m-profile-sub">{{ me()?.mobile || '未设置手机号' }}@if (me()?.companyName) { · {{ me()?.companyName }} }</div>
- </div>
- </div>
- </section>
- <!--
- 通知(2026-11-15):把「开不开系统通知」这件事摆到明面上。
- 🔴 为什么要有这一项:Android 13+ 首次拒绝通知权限后,系统**不再弹窗**,
- 用户会一直以为「这个 App 就是不推送」,也不知道去哪改。
- 这里给一个明确入口 + 状态显示,点一下就去系统设置。
- -->
- @if (isNative()) {
- <section class="m-section">
- <h2 class="m-section-title">通知</h2>
- <div class="m-card">
- <button type="button" class="m-row" (click)="onNotificationRow()">
- <span class="m-row-body">
- <span class="m-row-t1">消息与任务通知</span>
- <span class="m-row-sub">{{ notifyStateText() }}</span>
- </span>
- <i class="fa-solid fa-chevron-right m-chev" aria-hidden="true"></i>
- </button>
- </div>
- </section>
- }
- <section class="m-section">
- <h2 class="m-section-title">外观</h2>
- <div class="m-card">
- <p class="m-label">整体配色</p>
- <div class="m-palette-grid">
- @for (p of palettes; track p.id) {
- <button
- type="button"
- class="m-palette"
- [class.on]="palette.palette() === p.id"
- [attr.aria-pressed]="palette.palette() === p.id"
- (click)="setPalette(p.id)"
- >
- <span class="m-swatch" [attr.data-preview-palette]="p.id" aria-hidden="true">
- <i></i><i></i><i></i>
- </span>
- {{ p.name }}
- </button>
- }
- </div>
- <div class="m-row m-row--plain">
- <span class="m-row-body">
- <span class="m-row-t1">深色模式</span>
- </span>
- <button
- type="button"
- class="m-switch"
- role="switch"
- [attr.aria-checked]="theme.isDark()"
- aria-label="深色模式"
- (click)="toggleDark()"
- ></button>
- </div>
- <!--
- 字号(2026-11-21 用户裁决):拆成「正文大小」和「界面大小」两项。
- 2026-11-23 重排:说明文字从控件之间挪到底部一句脚注,
- 预览去掉背景框 —— 用户反馈卡片中间松垮、间隔不舒服。
- -->
- <div class="m-font">
- <div class="m-font-head">
- <span class="m-row-t1">正文大小</span>
- <span class="m-font-val">{{ font.size() }}px</span>
- </div>
- <input
- class="m-slider"
- type="range"
- [min]="fontMin"
- [max]="fontMax"
- step="1"
- [value]="font.size()"
- aria-label="正文大小"
- aria-describedby="global-font-hint"
- (input)="onFont($event)"
- />
- <!-- 轻量预览:不加背景框,所见即所得 -->
- <p class="m-font-preview" [style.font-size.px]="font.size()" aria-hidden="true">
- 预览:对话正文效果
- </p>
- <div class="m-font-head m-font-head--ui">
- <span class="m-row-t1">界面大小</span>
- <span class="m-font-val">{{ uiScaleLabel() }}</span>
- </div>
- <div class="m-ui-scale" role="radiogroup" aria-label="界面大小">
- @for (opt of uiScaleOptions; track opt.value) {
- <button
- type="button"
- role="radio"
- [attr.aria-checked]="font.ui() === opt.value"
- [class.on]="font.ui() === opt.value"
- (click)="font.setUi(opt.value)"
- >
- {{ opt.label }}
- </button>
- }
- </div>
- <p id="global-font-hint" class="m-font-hint">
- 正文大小影响对话内容;界面大小影响导航与图标。
- </p>
- </div>
- </div>
- </section>
- <section class="m-section">
- <h2 class="m-section-title">账号</h2>
- <ul class="m-list">
- <!--
- 访问 Token(2026-11-04 对齐 PC):可显示/隐藏 + 复制。
- 默认脱敏,避免误拍屏泄漏;显示后可直接复制用于排障或换设备登录。
- -->
- <li class="m-token-row">
- <span class="m-row-body">
- <span class="m-row-t1">访问 Token</span>
- <span class="m-row-t2 m-token-value" [class.m-token--masked]="!tokenShown()">
- {{ tokenShown() ? tokenText() : maskToken() }}
- </span>
- </span>
- <button
- type="button"
- class="m-token-btn"
- [attr.aria-label]="tokenShown() ? '隐藏 Token' : '显示 Token'"
- (click)="tokenShown.set(!tokenShown())"
- >
- <i [class]="tokenShown() ? 'fa-solid fa-eye-slash' : 'fa-solid fa-eye'" aria-hidden="true"></i>
- </button>
- <button
- type="button"
- class="m-token-btn"
- aria-label="复制 Token"
- [disabled]="!tokenShown()"
- (click)="copyToken()"
- >
- <i [class]="copied() ? 'fa-solid fa-check' : 'fa-solid fa-copy'" aria-hidden="true"></i>
- </button>
- </li>
- <!--
- 关于与版本(2026-11-23 新增)
- 用户要求在「我的」页能看到版本号,并能点开查更新 ——
- 以前这里完全没有版本概念,装了什么版本自己都不知道。
- -->
- <li>
- <button type="button" class="m-row" (click)="checkUpdateNow()" [disabled]="updating()">
- <span class="m-row-body">
- <span class="m-row-t1">关于与版本</span>
- <span class="m-row-t2">
- @if (updating()) {
- 正在检查更新…
- } @else if (updateTip()) {
- {{ updateTip() }}
- } @else if (update.hasUpdate()) {
- 有新版本 {{ update.remote()?.version }} 可更新
- } @else {
- {{ versionText() }}
- }
- </span>
- </span>
- @if (update.hasUpdate()) {
- <span class="m-update-dot" aria-label="有新版本"></span>
- } @else {
- <i class="fa-solid fa-chevron-right m-chev" aria-hidden="true"></i>
- }
- </button>
- </li>
- <li>
- <button type="button" class="m-row" (click)="logoutOpen.set(true)">
- <span class="m-row-body">
- <span class="m-row-t1 m-danger">退出登录</span>
- </span>
- <i class="fa-solid fa-chevron-right m-chev" aria-hidden="true"></i>
- </button>
- </li>
- </ul>
- </section>
- <!-- 退出登录:独立成卡、居中红字(2026-11-23,微信/美团惯例) -->
- <section class="m-section">
- <button type="button" class="m-logout" (click)="logoutOpen.set(true)">退出登录</button>
- </section>
- </div>
- </div>
- <!-- 更新弹窗:有新版时自动弹出,也可由「关于与版本」手动唤起 -->
- <app-update-dialog />
- <app-m-drawer [activeSessionId]="activeSessionId()"
- [open]="drawerOpen()" (close)="drawerOpen.set(false)" (newChat)="newChat()" (newChatWithWs)="onNewChatIn($event)" />
- <!-- 确认弹窗换成业务组件:48px 按钮 + 危险红(2026-11-23) -->
- <app-m-confirm
- [(open)]="logoutOpen"
- title="退出登录"
- icon="fa-solid fa-arrow-right-from-bracket"
- [danger]="true"
- confirmText="退出登录"
- (confirm)="logout()"
- />
- `,
- styles: `
- :host {
- display: block;
- min-height: 100dvh;
- background: var(--canvas);
- }
- /* 固定外壳 + 内部滚动(2026-11-04):外层不能滚,只有内容区滚 */
- .m-page--scroll {
- display: flex;
- flex-direction: column;
- height: 100dvh;
- box-sizing: border-box;
- padding-bottom: calc(var(--mob-tabbar-h) + var(--mob-safe-bottom));
- }
- .m-body {
- flex: 1;
- min-height: 0;
- overflow-y: auto;
- -webkit-overflow-scrolling: touch;
- overscroll-behavior: contain;
- padding-bottom: var(--sp-6);
- }
- .m-section {
- padding: 0 var(--mob-gutter);
- }
- .m-section + .m-section {
- margin-top: var(--sp-6);
- }
- .m-section:first-of-type {
- margin-top: var(--sp-3);
- }
- .m-section-title {
- margin: 0 0 var(--sp-3);
- color: var(--muted);
- font-size: var(--fs-13);
- font-weight: 400;
- }
- .m-card {
- padding: var(--sp-4);
- border: 1px solid var(--edge);
- border-radius: var(--r-lg);
- background: var(--surface);
- box-shadow: none;
- }
- .m-profile {
- display: flex;
- align-items: center;
- gap: var(--sp-3);
- }
- .m-profile-body {
- min-width: 0;
- }
- .m-profile-name {
- color: var(--ink);
- font-size: var(--fs-17);
- font-weight: 600;
- }
- .m-profile-sub {
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
- color: var(--muted);
- font-size: var(--fs-13);
- }
- .m-list {
- margin: 0;
- padding: 0;
- list-style: none;
- border: 1px solid var(--edge);
- border-radius: var(--r-lg);
- background: var(--surface);
- overflow: hidden;
- }
- .m-list > li + li {
- border-top: 1px solid var(--edge);
- }
- .m-row {
- display: flex;
- align-items: center;
- gap: var(--sp-3);
- width: 100%;
- min-height: 56px;
- padding: var(--sp-3) var(--sp-4);
- box-sizing: border-box;
- border: 0;
- background: var(--surface);
- color: var(--ink);
- font: inherit;
- text-align: left;
- cursor: pointer;
- }
- .m-row--plain {
- min-height: 56px;
- padding: var(--sp-3) 0;
- margin-top: var(--sp-2);
- border-top: 1px solid var(--edge);
- cursor: default;
- }
- .m-row-body {
- flex: 1;
- min-width: 0;
- }
- .m-row-t1 {
- display: block;
- font-size: var(--fs-15);
- }
- .m-row-t2 {
- display: block;
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
- color: var(--muted);
- font-size: var(--fs-13);
- }
- .m-row-sub {
- display: block;
- margin-top: var(--sp-1);
- color: var(--muted);
- font-size: var(--fs-12);
- line-height: 1.5;
- overflow-wrap: anywhere;
- }
- .m-token-row {
- display: flex;
- align-items: center;
- gap: var(--sp-2);
- min-height: 56px;
- padding: var(--sp-3) var(--sp-4);
- background: var(--surface);
- }
- .m-token-value {
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
- }
- .m-token-btn {
- display: grid;
- place-items: center;
- flex: none;
- width: var(--touch-min);
- height: var(--touch-min);
- border: 0;
- border-radius: var(--r-sm);
- background: none;
- color: var(--muted);
- font-size: var(--fs-13);
- cursor: pointer;
- }
- .m-token-btn:active {
- background: var(--surface-hover);
- }
- .m-token-btn:disabled {
- opacity: 0.35;
- cursor: not-allowed;
- }
- .m-logout {
- width: 100%;
- min-height: 52px;
- border: 1px solid var(--edge);
- border-radius: var(--r-lg);
- background: var(--surface);
- color: var(--danger);
- font: inherit;
- font-size: var(--fs-15);
- font-weight: 600;
- cursor: pointer;
- }
- .m-logout:active {
- background: var(--surface-hover);
- }
- /*
- * 有新版本时的红点(2026-11-23)
- * 取代 chevron 的位置 —— 有红点时无需再提示「可进入」,
- * 点进去就是要更新,语义更聚焦。
- */
- .m-update-dot {
- flex: none;
- width: 8px;
- height: 8px;
- border-radius: 50%;
- background: #EF4444;
- box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.16);
- }
- .m-chev {
- color: var(--muted);
- font-size: var(--fs-12);
- }
- .m-label {
- margin: 0 0 var(--sp-3);
- color: var(--ink-2);
- font-size: var(--fs-13);
- }
- .m-palette-grid {
- display: grid;
- grid-template-columns: repeat(4, 1fr);
- gap: var(--sp-2);
- }
- .m-palette {
- min-width: 0;
- display: flex;
- flex-direction: column;
- align-items: center;
- gap: var(--sp-1);
- padding: var(--sp-2) var(--sp-1);
- border: 1.5px solid var(--edge);
- border-radius: var(--r-md);
- background: var(--surface);
- color: var(--ink-2);
- font: inherit;
- font-size: var(--fs-11);
- white-space: nowrap;
- cursor: pointer;
- }
- .m-palette.on {
- border-color: var(--primary);
- color: var(--primary);
- font-weight: 600;
- }
- .m-swatch {
- display: flex;
- width: 100%;
- height: 32px;
- border: 1px solid var(--edge);
- border-radius: var(--r-sm);
- overflow: hidden;
- }
- .m-swatch i {
- flex: 1;
- }
- .m-swatch i:nth-child(1) {
- background: var(--nav-surface);
- }
- .m-swatch i:nth-child(2) {
- background: var(--primary);
- }
- .m-swatch i:nth-child(3) {
- background: var(--surface-2);
- }
- /*
- * 配色缩略图:各自作用域内展示该套配色的导航 / 主色 / 表面色。
- *
- * 🔴 这里不再重复写色值 —— _palette.scss 早已定义
- * [data-preview-palette='xxx'] { --nav-surface / --primary / --surface-2 },
- * 本组件的 [attr.data-preview-palette] 直接命中那套规则。
- * 原先复制过来的 12 个色值是冗余副本,一旦调色就会与真源不一致。 */
- .m-switch {
- position: relative;
- flex: none;
- width: 48px;
- height: var(--touch-min);
- border: 0;
- border-radius: var(--r-tag);
- background: transparent;
- cursor: pointer;
- transition: background var(--motion-fast) var(--ease-standard);
- }
- .m-switch::before {
- content: '';
- position: absolute;
- inset: 8px 0;
- border-radius: var(--r-tag);
- background: var(--surface-active);
- }
- .m-switch::after {
- content: '';
- position: absolute;
- top: 11px;
- left: 3px;
- width: 22px;
- height: 22px;
- border-radius: var(--r-tag);
- background: var(--surface);
- box-shadow: var(--shadow-soft);
- transition: transform var(--motion-fast) var(--ease-standard);
- }
- .m-switch[aria-checked='true']::before {
- background: var(--primary);
- }
- .m-switch[aria-checked='true']::after {
- transform: translateX(20px);
- background: var(--primary-content);
- }
- .m-font {
- margin-top: var(--sp-2);
- padding-top: var(--sp-3);
- border-top: 1px solid var(--edge);
- }
- .m-font-head {
- display: flex;
- align-items: baseline;
- justify-content: space-between;
- }
- .m-font-val {
- color: var(--muted);
- font-size: var(--fs-13);
- }
- .m-font-head--ui {
- margin-top: var(--sp-3);
- }
- /* 轻量预览:无背景框,直接用当前档位渲染一行样例 */
- .m-font-preview {
- margin: var(--sp-1) 0 0;
- color: var(--muted);
- line-height: 1.5;
- }
- .m-font-hint {
- margin: var(--sp-3) 0 0;
- color: var(--faint);
- font-size: var(--fs-12);
- line-height: 1.5;
- }
- /* 界面大小:三档分段(与正文滑块区分开,避免两套控制混在一起) */
- .m-ui-scale {
- display: grid;
- grid-template-columns: repeat(3, 1fr);
- gap: var(--sp-1);
- margin-top: var(--sp-2);
- padding: 3px;
- border-radius: var(--r-md);
- background: var(--surface-2);
- }
- .m-ui-scale button {
- min-height: var(--touch-min);
- border: 0;
- border-radius: var(--r-sm);
- background: transparent;
- color: var(--ink-2);
- font: inherit;
- font-size: var(--fs-14);
- cursor: pointer;
- }
- .m-ui-scale button.on {
- background: var(--surface);
- color: var(--primary);
- font-weight: 600;
- box-shadow: var(--shadow-soft);
- }
- .m-slider {
- width: 100%;
- margin-top: var(--sp-2);
- min-height: var(--touch-min);
- accent-color: var(--primary);
- }
- `
- })
- export class MbMinePage {
- private readonly chat = inject(ChatService);
- /** 当前打开的会话(抽屉高亮用) */
- protected readonly activeSessionId = computed(() => this.chat.sessionId());
- private readonly router = inject(Router);
- private readonly session = inject(SessionService);
- private readonly sessionsSvc = inject(ChatSessionService);
- protected readonly palette = inject(PaletteService);
- protected readonly theme = inject(ThemeService);
- protected readonly font = inject(ChatFontService);
- protected readonly drawerOpen = signal(false);
- protected readonly logoutOpen = signal(false);
- /**
- * 版本与更新(2026-11-23 新增)
- *
- * 服务是 root 级单例,和弹窗组件共享同一个实例 ——
- * 这里点了检查,弹窗那边立刻能感知到 hasUpdate 变化。
- */
- protected readonly update = inject(AppUpdateService);
- protected readonly updating = this.update.checking;
- /** 版本文案:本机版本 + 包名,方便反馈问题时一眼看出装的是哪个包 */
- protected versionText(): string {
- const v = this.update.local();
- if (!v) return '未获取到版本信息';
- return `v${v.versionName} (${v.versionCode})`;
- }
- /** 手动检查更新:查完有新版就由弹窗接管显示 */
- protected async checkUpdateNow(): Promise<void> {
- await this.update.check();
- if (!this.update.hasUpdate() && !this.update.error()) {
- /*
- * 已是最新 —— 给个轻提示。
- * 不用弹窗(太重),直接在行内文案上体现就够了,
- * 用户点完看到「已是最新」自然明白。
- */
- this.updateTip.set('已是最新版本');
- setTimeout(() => this.updateTip.set(null), 2000);
- }
- }
- /** 「已是最新」的临时提示 */
- protected readonly updateTip = signal<string | null>(null);
- protected readonly palettes = PALETTES;
- protected readonly fontMin = Math.min(...CHAT_FONT_SIZES);
- protected readonly fontMax = Math.max(...CHAT_FONT_SIZES);
- /** 界面大小三档(与正文大小分开设置) */
- protected readonly uiScaleOptions = UI_SCALES.map((value) => ({ value, label: UI_SCALE_LABEL[value] }));
- protected readonly uiScaleLabel = computed(() => UI_SCALE_LABEL[this.font.ui()]);
- protected readonly me = this.session.me;
- constructor() {
- // 字号偏好按用户存储,进入设置页时载入(幂等)
- this.font.load();
- this.loadNotificationState();
- }
- /** Token 只展示尾部 4 位 —— 完整令牌不应出现在屏幕上 */
- protected readonly tokenShown = signal(false);
- protected readonly copied = signal(false);
- /** 完整 Token(仅在用户主动点「显示」后渲染到 DOM) */
- protected readonly tokenText = computed(() => this.session.token() ?? '—');
- protected async copyToken(): Promise<void> {
- try {
- await navigator.clipboard.writeText(this.session.token() ?? '');
- this.copied.set(true);
- setTimeout(() => this.copied.set(false), 1500);
- } catch {
- /* 非安全上下文:静默失败,用户可手动选中复制 */
- }
- }
- protected readonly maskToken = computed(() => {
- const t = this.session.token();
- if (!t) return '—';
- const visible = t.slice(-4);
- return `${t.startsWith('r:') ? 'r:' : ''}${'•'.repeat(12)}${visible}`;
- });
- protected setPalette(id: PaletteId): void {
- this.palette.set(id || DEFAULT_PALETTE);
- }
- protected toggleDark(): void {
- this.theme.toggleMode();
- }
- // ---------- 通知权限(2026-11-15) ----------
- private readonly notify = inject(AppNotificationService);
- private readonly notificationSetup = inject(NotificationSetupService);
- /** 通知权限状态:null = 未知/查询中,true = 已开,false = 未开 */
- /**
- * 通知权限状态:直接订阅 service 的 signal(2026-11-15)。
- * 原来的本地 signal 只在构造函数查一次,从系统设置返回后不会更新。
- */
- protected readonly notifyGranted = computed(() => this.notify.grantedState());
- /** 是否原生壳(浏览器里不显示「通知」入口 —— 浏览器没有这个系统权限) */
- protected readonly isNative = signal(isNativeApp());
- /** 进页面时查一次通知权限状态(构造函数里调用,不另开第二个 constructor) */
- private loadNotificationState(): void {
- /* 进页面时强制刷新一次:用户可能刚从系统设置回来 */
- void this.notify.refreshGranted();
- }
- protected notifyStateText(): string {
- const g = this.notifyGranted();
- if (g === null) return '检查中…';
- if (!g) return '未开启 · 点此设置';
- // 已开通知时进一步告知还有几项后台设置没配好,用户不用点进去才知道
- const left = this.notificationSetup.remaining();
- return left > 0 ? `系统通知已开启 · ${left} 项后台设置待处理` : '系统通知已开启 · 全部就绪';
- }
- /**
- * 点「通知」行:
- * · 已开 → 去系统设置(可关闭)
- * · 未开 → 先申请;被系统拒绝(不再弹窗)则引导去设置页
- */
- protected async onNotificationRow(): Promise<void> {
- this.notificationSetup.show();
- }
- /** 字号滑块:吸附到最近的档位(与桌面设置同一组档位) */
- protected onFont(e: Event): void {
- const v = Number((e.target as HTMLInputElement).value);
- const nearest = CHAT_FONT_SIZES.reduce((a, b) => (Math.abs(b - v) < Math.abs(a - v) ? b : a));
- this.font.set(nearest);
- }
- protected logout(): void {
- this.logoutOpen.set(false);
- this.session.logout();
- this.sessionsSvc.reset();
- void this.router.navigateByUrl('/login', { replaceUrl: true });
- }
- protected newChat(): void {
- this.drawerOpen.set(false);
- void this.router.navigateByUrl('/mobile/messages');
- }
- /**
- * 在指定工作区中新建对话。
- *
- * 这几页没有新建对话弹层,统一跳到会话列表页并带上工作区参数,
- * 由那里打开选择容器的弹层(避免每个页面各做一套)。
- */
- protected onNewChatIn(workspaceId: string): void {
- void this.router.navigateByUrl(`/mobile/messages?newIn=${encodeURIComponent(workspaceId)}`);
- }
- }
|