diff --git a/manifest.json b/manifest.json index 8022243..5bcf447 100644 --- a/manifest.json +++ b/manifest.json @@ -1,10 +1,9 @@ { "id": "obsidian-cubox-sync", - "name": "Cubox Sync", + "name": "Cubox", "version": "1.0.0", "minAppVersion": "0.15.0", - "description": "同步 Cubox 文章和高亮内容到 Obsidian", - "author": "Your Name", - "authorUrl": "https://github.com/yourusername", + "description": "Sync your Cubox articles & annotation", + "author": "Cubox", "isDesktopOnly": false } diff --git a/src/cuboxApi.ts b/src/cuboxApi.ts index e9a23d9..39c18b1 100644 --- a/src/cuboxApi.ts +++ b/src/cuboxApi.ts @@ -219,7 +219,7 @@ export class CuboxApi { return response.data ?? []; } catch (error) { console.error('获取 Cubox 文件夹列表失败:', error); - new Notice('获取 Cubox 文件夹列表失败'); + new Notice('Failed to get Cubox folders'); throw error; } } @@ -235,7 +235,7 @@ export class CuboxApi { return response.data ?? []; } catch (error) { console.error('获取 Cubox 标签列表失败:', error); - new Notice('获取 Cubox 标签列表失败'); + new Notice('Failed to get Cubox tags'); throw error; } } diff --git a/src/main.ts b/src/main.ts index 0b07617..0fadaba 100644 --- a/src/main.ts +++ b/src/main.ts @@ -69,7 +69,7 @@ const DEFAULT_SETTINGS: CuboxSyncSettings = { frontMatterVariables: ['id', 'cubox_url', 'url', 'tags'], contentTemplate: DEFAULT_CONTENT_TEMPLATE, highlightInContent: true, - dateFormat: 'YYYY-MM-DD', + dateFormat: 'yyyy-MM-dd', lastSyncTime: 0, lastSyncCardId: null, lastCardUpdateTime: null, @@ -151,11 +151,9 @@ export default class CuboxSyncPlugin extends Plugin { // 如果频率大于0,设置新的定时器 if (this.settings.syncFrequency > 0) { - const frequency = Math.min(this.settings.syncFrequency, 1440); // 最大24小时 - this.syncIntervalId = window.setInterval( async () => await this.syncCubox(), - frequency * 60 * 1000 + this.settings.syncFrequency * 60 * 1000 ); this.registerInterval(this.syncIntervalId); } @@ -309,7 +307,7 @@ export default class CuboxSyncPlugin extends Plugin { formatLastSyncTime(): string { if (!this.settings.lastSyncTime) { - return '从未同步'; + return 'Never'; } // 使用新的格式化方法 @@ -430,7 +428,7 @@ class CuboxSyncSettingTab extends PluginSettingTab { .onClick(async () => { // 确保 API 已初始化 if (!this.plugin.settings.apiKey) { - new Notice('请先设置 API Key'); + new Notice('Please enter the API key first'); return; } @@ -456,7 +454,7 @@ class CuboxSyncSettingTab extends PluginSettingTab { modal.open(); } catch (error) { console.error('获取文件夹列表失败:', error); - new Notice('获取文件夹列表失败,请检查网络连接和 API Key'); + new Notice('Failed to get Cubox folders'); // 恢复按钮文本 button.setButtonText(this.getFolderFilterButtonText()); } @@ -473,7 +471,7 @@ class CuboxSyncSettingTab extends PluginSettingTab { .onClick(async () => { // 确保 API 已初始化 if (!this.plugin.settings.apiKey) { - new Notice('请先设置 API Key'); + new Notice('Please enter the API key first'); return; } @@ -499,7 +497,7 @@ class CuboxSyncSettingTab extends PluginSettingTab { modal.open(); } catch (error) { console.error('获取标签列表失败:', error); - new Notice('获取标签列表失败,请检查网络连接和 API Key'); + new Notice('Failed to get Cubox tags'); // 恢复按钮文本 button.setButtonText(this.getTagFilterButtonText()); } @@ -516,7 +514,7 @@ class CuboxSyncSettingTab extends PluginSettingTab { .onClick(async () => { // 确保 API 已初始化 if (!this.plugin.settings.apiKey) { - new Notice('请先设置 API Key'); + new Notice('Please enter the API key first'); return; } @@ -543,7 +541,7 @@ class CuboxSyncSettingTab extends PluginSettingTab { .onClick(async () => { // 确保 API 已初始化 if (!this.plugin.settings.apiKey) { - new Notice('请先设置 API Key'); + new Notice('Please enter the API key first'); return; } @@ -584,15 +582,18 @@ class CuboxSyncSettingTab extends PluginSettingTab { .setPlaceholder('Enter the interval') .setValue(String(this.plugin.settings.syncFrequency)) .onChange(async (value) => { - const frequency = parseInt(value) + let frequency = parseInt(value) if (isNaN(frequency)) { new Notice('Frequency must be a positive integer') return } - + frequency = Math.min(frequency, 9999); // 最大24小时 this.plugin.settings.syncFrequency = frequency; await this.plugin.saveSettings(); this.plugin.setupAutoSync(); + + // 将处理后的值回填到输入框 + text.setValue(String(frequency)); }); return textField; }); diff --git a/src/templateInstructions.ts b/src/templateInstructions.ts index bfaba41..748e406 100644 --- a/src/templateInstructions.ts +++ b/src/templateInstructions.ts @@ -80,10 +80,10 @@ If date is used on above templates, enter the format date.
Available variables
For more, refer to reference.
diff --git a/src/utils.ts b/src/utils.ts index b20e298..9c841ca 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -39,7 +39,7 @@ export const generateSafeFileArticleName = (title: string): string => { * @param format 输出格式,支持:YYYY(年), MM(月), DD(日), HH(时), mm(分), ss(秒) * @returns 格式化后的时间字符串 */ -export const formatDateTime = (dateString: string, format: string = 'YYYY-MM-DD HH:mm:ss'): string => { +export const formatDateTime = (dateString: string, format: string = 'yyyy-MM-dd HH:mm:ss'): string => { if (!dateString) return ''; try { @@ -47,7 +47,7 @@ export const formatDateTime = (dateString: string, format: string = 'YYYY-MM-DD let normalizedString = dateString; // 处理类似 2024-04-23T14:30:42:780+08:00 格式(秒与毫秒之间用冒号) normalizedString = normalizedString.replace(/(\d{2}):(\d{2}):(\d{2}):(\d{3})/, '$1:$2:$3.$4'); - return DateTime.fromISO(normalizedString).toFormat(format); + return DateTime.fromISO(normalizedString).toFormat(format); } catch (error) { console.error('Error formatting date:', error); return dateString;