mirror of
https://github.com/woodchen-ink/obsidian-publish-to-discourse.git
synced 2025-07-17 21:32:05 +08:00
移除版本更新通知功能及相关模态框,简化代码结构。更新国际化文件,删除与更新通知相关的文本。调整主文件导入内容,去除不再使用的功能。
This commit is contained in:
parent
e56a479a45
commit
167794ce4c
@ -88,11 +88,5 @@ export default {
|
||||
'USER_API_KEY_DESC': 'Current configured User-API-Key (read-only)',
|
||||
'USER_API_KEY_EMPTY': 'Please use the process below to obtain one',
|
||||
'COPY_API_KEY': 'Copy',
|
||||
'API_KEY_COPIED': '✅ API Key copied to clipboard',
|
||||
|
||||
// Version update notice
|
||||
'UPDATE_NOTICE_TITLE': '🔄 Plugin Updated - Reconfiguration Required',
|
||||
'UPDATE_NOTICE_MESSAGE': 'Due to major changes in authentication method, you need to reconfigure your User-API-Key. The old API Key and username method has been removed. Please go to settings to reconfigure.',
|
||||
'UPDATE_NOTICE_BUTTON': 'Go to Settings',
|
||||
'UPDATE_NOTICE_DISMISS': 'I understand'
|
||||
'API_KEY_COPIED': '✅ API Key copied to clipboard'
|
||||
}
|
@ -88,11 +88,5 @@ export default {
|
||||
'USER_API_KEY_DESC': '当前配置的 User-API-Key(只读)',
|
||||
'USER_API_KEY_EMPTY': '请使用下面的流程获取',
|
||||
'COPY_API_KEY': '复制',
|
||||
'API_KEY_COPIED': '✅ API Key 已复制到剪贴板',
|
||||
|
||||
// 版本更新提示
|
||||
'UPDATE_NOTICE_TITLE': '🔄 插件已更新 - 需要重新配置',
|
||||
'UPDATE_NOTICE_MESSAGE': '由于认证方式的重大变化,您需要重新配置 User-API-Key。旧的 API Key 和用户名方式已被移除,请前往设置页面重新配置。',
|
||||
'UPDATE_NOTICE_BUTTON': '前往设置',
|
||||
'UPDATE_NOTICE_DISMISS': '我知道了'
|
||||
'API_KEY_COPIED': '✅ API Key 已复制到剪贴板'
|
||||
}
|
28
src/main.ts
28
src/main.ts
@ -5,7 +5,7 @@ import { t, setLocale } from './i18n';
|
||||
import { expandEmbeds } from './expand-embeds';
|
||||
import { DiscourseAPI } from './api';
|
||||
import { EmbedHandler } from './embed-handler';
|
||||
import { SelectCategoryModal, CategoryConflictModal, UpdateNoticeModal } from './ui';
|
||||
import { SelectCategoryModal, CategoryConflictModal } from './ui';
|
||||
import { NotifyUser } from './notification';
|
||||
import { getFrontMatter, removeFrontMatter } from './utils';
|
||||
import { ActiveFile, PluginInterface } from './types';
|
||||
@ -30,9 +30,6 @@ export default class PublishToDiscourse extends Plugin implements PluginInterfac
|
||||
// 加载设置
|
||||
await this.loadSettings();
|
||||
|
||||
// 检查是否需要显示更新通知
|
||||
await this.checkForUpdateNotice();
|
||||
|
||||
// 初始化API和嵌入处理器
|
||||
this.api = new DiscourseAPI(this.app, this.settings);
|
||||
this.embedHandler = new EmbedHandler(this.app, this.api);
|
||||
@ -74,29 +71,6 @@ export default class PublishToDiscourse extends Plugin implements PluginInterfac
|
||||
await this.saveData(this.settings);
|
||||
}
|
||||
|
||||
// 检查是否需要显示更新通知
|
||||
private async checkForUpdateNotice() {
|
||||
const currentVersion = this.manifest.version;
|
||||
const lastNotifiedVersion = this.settings.lastNotifiedVersion;
|
||||
|
||||
// 如果是首次运行当前版本,显示更新通知
|
||||
if (lastNotifiedVersion !== currentVersion) {
|
||||
// 延迟显示,确保界面已完全加载
|
||||
setTimeout(() => {
|
||||
const modal = new UpdateNoticeModal(this.app, this, () => {
|
||||
// 打开设置页面
|
||||
(this.app as any).setting.open();
|
||||
(this.app as any).setting.openTabById(this.manifest.id);
|
||||
});
|
||||
modal.open();
|
||||
}, 1000);
|
||||
|
||||
// 更新记录的版本
|
||||
this.settings.lastNotifiedVersion = currentVersion;
|
||||
await this.saveSettings();
|
||||
}
|
||||
}
|
||||
|
||||
// 注册目录菜单
|
||||
registerDirMenu(menu: Menu, file: TFile) {
|
||||
const syncDiscourse = (item: MenuItem) => {
|
||||
|
58
src/ui.ts
58
src/ui.ts
@ -344,60 +344,4 @@ export class CategoryConflictModal extends Modal {
|
||||
this.resolve(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 版本更新通知模态框
|
||||
export class UpdateNoticeModal extends Modal {
|
||||
plugin: PluginInterface;
|
||||
onSettingsClick: () => void;
|
||||
|
||||
constructor(app: App, plugin: PluginInterface, onSettingsClick: () => void) {
|
||||
super(app);
|
||||
this.plugin = plugin;
|
||||
this.onSettingsClick = onSettingsClick;
|
||||
}
|
||||
|
||||
onOpen() {
|
||||
const { contentEl } = this;
|
||||
contentEl.empty();
|
||||
contentEl.addClass('discourse-update-notice-modal');
|
||||
|
||||
// 标题
|
||||
contentEl.createEl('h2', {
|
||||
text: t('UPDATE_NOTICE_TITLE'),
|
||||
cls: 'update-notice-title'
|
||||
});
|
||||
|
||||
// 消息内容
|
||||
const messageEl = contentEl.createEl('div', {
|
||||
cls: 'update-notice-message'
|
||||
});
|
||||
messageEl.createEl('p', { text: t('UPDATE_NOTICE_MESSAGE') });
|
||||
|
||||
// 按钮区域
|
||||
const buttonArea = contentEl.createEl('div', { cls: 'update-notice-buttons' });
|
||||
|
||||
// 前往设置按钮
|
||||
const settingsButton = buttonArea.createEl('button', {
|
||||
cls: 'mod-cta',
|
||||
text: t('UPDATE_NOTICE_BUTTON')
|
||||
});
|
||||
settingsButton.onclick = () => {
|
||||
this.close();
|
||||
this.onSettingsClick();
|
||||
};
|
||||
|
||||
// 我知道了按钮
|
||||
const dismissButton = buttonArea.createEl('button', {
|
||||
text: t('UPDATE_NOTICE_DISMISS')
|
||||
});
|
||||
dismissButton.onclick = () => {
|
||||
this.close();
|
||||
};
|
||||
}
|
||||
|
||||
onClose() {
|
||||
const { contentEl } = this;
|
||||
contentEl.empty();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user