mirror of
https://github.com/olcubo/obsidian-cubox.git
synced 2026-07-22 05:43:25 +00:00
update manifest/ fix dateformat bug
This commit is contained in:
parent
e04949e75c
commit
439678748c
5 changed files with 25 additions and 25 deletions
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
27
src/main.ts
27
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;
|
||||
});
|
||||
|
|
|
|||
|
|
@ -80,10 +80,10 @@ If date is used on above templates, enter the format date.
|
|||
<div class="cubox-variables-container">
|
||||
<div class="cubox-variables-title">Available variables</div>
|
||||
<ul class="cubox-variables-list">
|
||||
<li>YYYY-MM-DD</li>
|
||||
<li>MM/DD/YYYY</li>
|
||||
<li>DD.MM.YYYY</li>
|
||||
<li>YYYY-MM-DD HH:MM:SS</li>
|
||||
<li>yyyy-MM-dd</li>
|
||||
<li>MM/dd/yyyy</li>
|
||||
<li>dd.MM.yyyy</li>
|
||||
<li>yyyy-MM-dd HH:mm:ss</li>
|
||||
</ul>
|
||||
<div class="cubox-reference">For more, refer to <a href="#" class="reference-link">reference</a>.</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Reference in a new issue