mirror of
https://github.com/lossless-group/perplexed-plugin.git
synced 2026-07-22 06:49:50 +00:00
On branch fix/lmstudio Changes to be committed: modified: main.ts new file: main.ts.bak new file: src/core/PerplexedPlugin.ts modified: src/core/PerplexedPluginCore.ts modified: src/services/perplexityService.ts new file: src/settings/PerplexedSettingTab.ts modified: src/settings/PerplexedSettings.ts new file: src/settings/PerplexitySettings.ts
70 lines
2.3 KiB
TypeScript
70 lines
2.3 KiB
TypeScript
import { Plugin } from 'obsidian';
|
|
import { PerplexedSettings, DEFAULT_SETTINGS } from '../settings/PerplexedSettings';
|
|
import { PerplexedSettingTab } from '../settings/PerplexedSettingTab';
|
|
import { LMStudioSettings, DEFAULT_LMSTUDIO_SETTINGS } from '../settings/LMStudioSettings';
|
|
|
|
export class PerplexedPluginCore extends Plugin {
|
|
settings: PerplexedSettings = { ...DEFAULT_SETTINGS };
|
|
lmStudioSettings: LMStudioSettings = { ...DEFAULT_LMSTUDIO_SETTINGS };
|
|
|
|
async onload(): Promise<void> {
|
|
await this.loadSettings();
|
|
|
|
// Add settings tab
|
|
this.addSettingTab(new PerplexedSettingTab(this.app, this));
|
|
|
|
// Register commands and other plugin initialization
|
|
this.registerCommands();
|
|
}
|
|
|
|
async loadSettings(): Promise<void> {
|
|
try {
|
|
// Load main settings
|
|
const loadedSettings = await this.loadData();
|
|
if (loadedSettings) {
|
|
this.settings = { ...DEFAULT_SETTINGS, ...loadedSettings };
|
|
}
|
|
|
|
// Load LM Studio settings
|
|
const loadedLMStudioSettings = await this.loadData('lmstudio-settings');
|
|
if (loadedLMStudioSettings) {
|
|
this.lmStudioSettings = {
|
|
...DEFAULT_LMSTUDIO_SETTINGS,
|
|
...loadedLMStudioSettings
|
|
};
|
|
}
|
|
} catch (error) {
|
|
console.error('Error loading settings:', error);
|
|
}
|
|
}
|
|
|
|
async saveSettings(): Promise<void> {
|
|
try {
|
|
// Save main settings
|
|
await this.saveData(this.settings);
|
|
|
|
// Save LM Studio settings with a separate key
|
|
await this.saveData(this.lmStudioSettings, 'lmstudio-settings');
|
|
} catch (error) {
|
|
console.error('Error saving settings:', error);
|
|
}
|
|
}
|
|
|
|
protected registerCommands(): void {
|
|
// Base implementation - can be overridden by child classes
|
|
}
|
|
|
|
protected setupUI(): void {
|
|
// Base implementation - can be overridden by child classes
|
|
} private registerCommands() {
|
|
// Register your commands here
|
|
// Example:
|
|
this.addCommand({
|
|
id: 'perplexed-query',
|
|
name: 'Query Perplexed',
|
|
callback: () => {
|
|
// Command implementation
|
|
}
|
|
});
|
|
}
|
|
}
|