This commit is contained in:
Devon22 2026-06-13 23:12:01 +08:00
parent 271447e535
commit 31ed5ff304
4 changed files with 29 additions and 6 deletions

View file

@ -1,7 +1,7 @@
{
"id": "gridexplorer",
"name": "GridExplorer",
"version": "3.4.3",
"version": "3.4.4",
"minAppVersion": "1.8.7",
"description": "Browse note files in a grid view.",
"author": "Devon22",

4
package-lock.json generated
View file

@ -1,12 +1,12 @@
{
"name": "gridexplorer",
"version": "3.4.3",
"version": "3.4.4",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "gridexplorer",
"version": "3.4.3",
"version": "3.4.4",
"license": "MIT",
"dependencies": {
"jszip": "^3.10.1"

View file

@ -1,6 +1,6 @@
{
"name": "gridexplorer",
"version": "3.4.3",
"version": "3.4.4",
"description": "Browse note files in a grid view.",
"main": "main.js",
"scripts": {

View file

@ -43,6 +43,15 @@ export default class GridExplorerPlugin extends Plugin {
settings: GallerySettings = DEFAULT_SETTINGS;
statusBarItem: HTMLElement | null = null;
async getThumbnail(zipPath: string): Promise<string | null> {
const file = this.app.vault.getAbstractFileByPath(zipPath);
if (file instanceof TFile && file.extension.toLowerCase() === 'zip') {
const { getFirstImageFromZip } = await import('./utils/mediaUtils');
return await getFirstImageFromZip(this.app, file);
}
return null;
}
async onload() {
await this.loadSettings();
@ -63,7 +72,11 @@ export default class GridExplorerPlugin extends Plugin {
VIEW_TYPE_ZIP,
(leaf) => new ZipView(leaf)
);
this.registerExtensions(["zip"], VIEW_TYPE_ZIP);
try {
this.registerExtensions(["zip"], VIEW_TYPE_ZIP);
} catch (e) {
console.warn("Grid Explorer: Could not register 'zip' extension.", e);
}
// 註冊設定頁面
this.addSettingTab(new GridExplorerSettingTab(this.app, this));
@ -502,9 +515,19 @@ export default class GridExplorerPlugin extends Plugin {
}, true); // 使用 capture 階段以確保優先處理
// 設定 Canvas 拖曳處理
// 註冊版面拖曳處理
this.setupCanvasDropHandlers();
// 暴露 API 供其他外掛使用
const appWithPlugins = this.app as {
plugins?: {
plugins?: Record<string, unknown>;
};
};
if (appWithPlugins.plugins?.plugins) {
appWithPlugins.plugins.plugins['obsidian-gridexplorer'] = this;
}
// Override new tab behavior (for useQuickAccessAsNewTabMode setting)
const { workspace } = this.app;