update at 2025-10-08 14:08:36

This commit is contained in:
douboer
2025-10-08 14:08:36 +08:00
parent 719021bc67
commit cbf32b3f0b
10 changed files with 899 additions and 57 deletions

View File

@@ -1,15 +1,17 @@
/* 文件xiaohongshu/preview-view.ts — 小红书预览视图组件:顶部工具栏、分页导航、底部切图按钮。 */
/* 文件xiaohongshu/xhs-preview.ts — 小红书预览视图组件:顶部工具栏、分页导航、底部切图按钮。 */
import { Notice, TFile } from 'obsidian';
import { NMPSettings } from '../settings';
import AssetsManager from '../assets';
import { paginateArticle, renderPage, PageInfo } from './paginator';
import { sliceCurrentPage, sliceAllPages } from './slice';
import { PlatformChooser } from '../platform-chooser';
import { Platform, IPlatformPreview } from '../types';
/**
*
*/
export class XiaohongshuPreviewView {
export class XiaohongshuPreviewView implements IPlatformPreview {
container: HTMLElement;
settings: NMPSettings;
assetsManager: AssetsManager;
@@ -37,7 +39,7 @@ export class XiaohongshuPreviewView {
// 回调函数
onRefreshCallback?: () => Promise<void>;
onPublishCallback?: () => Promise<void>;
onPlatformChangeCallback?: (platform: string) => Promise<void>;
onPlatformChangeCallback?: (platform: Platform) => Promise<void>;
constructor(container: HTMLElement, app: any) {
this.container = container;
@@ -412,4 +414,37 @@ export class XiaohongshuPreviewView {
new Notice('❌ 批量切图失败: ' + error.message);
}
}
/**
* IPlatformPreview
*/
public show(): void {
if (this.container) {
this.container.style.display = 'flex';
}
}
/**
* IPlatformPreview
*/
public hide(): void {
if (this.container) {
this.container.style.display = 'none';
}
}
/**
* IPlatformPreview
*/
public cleanup(): void {
// 清理回调
this.onRefreshCallback = undefined;
this.onPublishCallback = undefined;
this.onPlatformChangeCallback = undefined;
// 清理数据
this.pages = [];
this.currentFile = null;
this.articleHTML = '';
}
}