feat: drop reading view, keep chat enhancements and approval-shortcut settings

- remove reader tab, text-transform service and official reader slots

- keep a chat-only Better Chat settings section for approval shortcut recording

- rebuild lib/client.js (1.47MB -> ~53KB)
This commit is contained in:
QQ 2026-11-22 19:40:33 +08:00
parent 9c0ee58021
commit 3135e80085
5 changed files with 112 additions and 52487 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -33,7 +33,7 @@ export interface OpenPrefs {
}
export interface BetterDisplaySettingsInjected {
prefs: OpenPrefs;
prefs?: OpenPrefs;
chat?: ChatPrefs;
copy?: SettingsCopy;
languageTag?: string;
@ -59,16 +59,17 @@ function text(props: SettingsProps, copy: SettingsCopy, key: keyof SettingsCopy)
export function SettingsSection(props: SettingsProps) {
const copy = props.copy ?? settingsCopyFor(props.languageTag);
const prefs = props.prefs;
const snap = useSyncExternalStore(
props.prefs.subscribe,
() => props.prefs.getSnapshot() ?? ({} as ReaderPrefsSnapshot),
prefs?.subscribe ?? (() => () => {}),
() => prefs?.getSnapshot() ?? ({} as ReaderPrefsSnapshot),
() => ({} as ReaderPrefsSnapshot),
);
const mode = deliverableOpenModeOf(snap.deliverableOpenMode);
const glass = frostedGlassOf(snap);
const autoFold = snap.autoFold !== false && snap.foldIntensity !== 0;
const setMode = (value: DeliverableOpenMode) => {
props.prefs.actions.setDeliverableOpenMode(value);
prefs?.actions.setDeliverableOpenMode(value);
};
const on = mode === 'sidebar';
@ -126,6 +127,7 @@ export function SettingsSection(props: SettingsProps) {
return (
<div className={css.section} data-better-display-settings>
{prefs ? (<>
<div className={css.row}>
<div className={css.rowText}>
<div className={css.title}>{text(props, copy, 'openTitle')}</div>
@ -154,7 +156,7 @@ export function SettingsSection(props: SettingsProps) {
className={css.switch}
data-on={glass || undefined}
data-better-display-glass={glass ? 'on' : 'off'}
onClick={() => { props.prefs.actions.setFrostedGlass(!glass); }}
onClick={() => { prefs?.actions.setFrostedGlass(!glass); }}
/>
</div>
@ -171,11 +173,12 @@ export function SettingsSection(props: SettingsProps) {
data-on={autoFold || undefined}
data-better-display-auto-fold={autoFold ? 'on' : 'off'}
onClick={() => {
props.prefs.actions.setAutoFold?.(!autoFold);
props.prefs.actions.setFoldIntensity?.(!autoFold ? 1 : 0);
prefs?.actions.setAutoFold?.(!autoFold);
prefs?.actions.setFoldIntensity?.(!autoFold ? 1 : 0);
}}
/>
</div>
</>) : null}
{chat ? (
<section className={css.block} data-better-chat-shortcuts>

View File

@ -1,12 +1,12 @@
/**
* dsh-better-chat 客户端入口(合并后)。
* dsh-better-chat 客户端入口。
*
* 两个半场共用一个 client 产物:
* - 阅读视图(原 dsh-better-display):reader-plugin.tsx 及其整棵 React 源码树;
* - 聊天增强(原 dsh-better-chat):审批键盘/提示、权限 UI、商店更新按钮。
* 聊天增强(原 dsh-better-chat):审批键盘/提示、权限 UI、商店更新按钮。
* 阅读视图(原 dsh-better-display)已移除,不再注册“阅读”页签与文本变换服务;
* 另保留 Better Chat 设置页(仅审批快捷键录制)。
*
* 入口必须导出一个静态字符串 inject 数组(宿主 Cordis 服务注入),
* 并在这里统一 apply。审批快捷键的配置存在 dsh.better-chat.v1,由设置页写入。
* 并在这里统一 apply。审批快捷键的配置存在 dsh.better-chat.v1。
*/
import type { Context } from '@deepseek-ai/cordis'
import { install as installApprovalKeys } from './chat/approval-keys.js'
@ -14,11 +14,11 @@ import { createChatStore, currentBindings } from './chat/bindings-store.js'
import { installKeyHints } from './chat/key-hint.js'
import { installPermissionPolicy } from './chat/permission-policy.js'
import { storeUpdatePlugin } from './chat/store-update.js'
import { apply as applyReader, name as readerName } from './reader-plugin.js'
import { installBetterDisplaySettings } from './settings.js'
export const name = 'dsh-better-chat'
/** 阅读视图所需的宿主客户端服务;聊天增强不额外依赖服务。 */
/** 阅读视图已移除;这里保留宿主客户端服务注入,聊天增强本身不额外依赖。 */
export const inject = [
'slots',
'sessions',
@ -46,7 +46,6 @@ export function apply(ctx: Context): void {
// 子插件挂不上(旧宿主等)不影响主功能。
}
// 阅读视图:注册 slots、设置页(含快捷键配置)与文本变换服务。
applyReader(ctx, { chatPrefs })
void readerName
// Better Chat 设置页:仅保留审批快捷键录制(阅读视图已移除,不再有开/玻璃/折叠项)。
installBetterDisplaySettings(ctx, undefined, chatPrefs)
}

View File

@ -27,7 +27,7 @@ function languageTag(ctx: Context): string | undefined {
const SETTINGS_LOCALE_NS = 'better-chat'
const SETTINGS_SECTION_ID = 'better-chat'
export function installBetterDisplaySettings(ctx: Context, prefs: OpenPrefs, chat?: ChatPrefs): void {
export function installBetterDisplaySettings(ctx: Context, prefs?: OpenPrefs, chat?: ChatPrefs): void {
const locale = (ctx.get?.('locale') ?? (ctx as unknown as { locale?: LocaleFace }).locale) as LocaleFace | undefined;
if (locale?.register) {
ctx.effect(() => locale.register!(SETTINGS_LOCALE_NS, { zh, en }), 'dsh-better-chat: settings copy');