Update manifest.json funding URL, remove unnecessary console logs, and clean up UI elements in DiscourseSyncPlugin.

This commit is contained in:
wood chen 2025-01-09 12:48:19 +08:00
parent 85bf0877ed
commit 59e287bce9
3 changed files with 1 additions and 18 deletions

View File

@ -6,6 +6,6 @@
"description": "Publish notes to the Discourse forum.", "description": "Publish notes to the Discourse forum.",
"author": "WoodChen", "author": "WoodChen",
"authorUrl": "https://woodchen.ink", "authorUrl": "https://woodchen.ink",
"fundingUrl": "https://woodchen.ink", "fundingUrl": "https://buymeacoffee.com/woodchen",
"isDesktopOnly": true "isDesktopOnly": true
} }

View File

@ -24,7 +24,6 @@ export class DiscourseSyncSettingsTab extends PluginSettingTab {
display(): void { display(): void {
const { containerEl } = this; const { containerEl } = this;
containerEl.empty(); containerEl.empty();
containerEl.createEl("h2", { text: "发布到 Discourse" });
new Setting(containerEl) new Setting(containerEl)
.setName("论坛地址") .setName("论坛地址")

View File

@ -38,7 +38,6 @@ export default class DiscourseSyncPlugin extends Plugin {
while ((match = regex.exec(content)) !== null) { while ((match = regex.exec(content)) !== null) {
matches.push(match[1]); matches.push(match[1]);
} }
console.log("matches:", matches);
return matches; return matches;
} }
@ -88,23 +87,18 @@ export default class DiscourseSyncPlugin extends Plugin {
if (response.status == 200) { if (response.status == 200) {
const jsonResponse = response.json; const jsonResponse = response.json;
console.log(`Upload Image jsonResponse: ${JSON.stringify(jsonResponse)}`);
imageUrls.push(jsonResponse.short_url); imageUrls.push(jsonResponse.short_url);
} else { } else {
new NotifyUser(this.app, `Error uploading image: ${response.status}`).open(); new NotifyUser(this.app, `Error uploading image: ${response.status}`).open();
console.error(`Error uploading image: ${JSON.stringify(response.json)}`);
} }
} catch (error) { } catch (error) {
new NotifyUser(this.app, `Exception while uploading image: ${error}`).open(); new NotifyUser(this.app, `Exception while uploading image: ${error}`).open();
console.error("Exception while uploading image:", error);
} }
} else { } else {
new NotifyUser(this.app, `File not found in vault: ${ref}`).open(); new NotifyUser(this.app, `File not found in vault: ${ref}`).open();
console.error(`File not found in vault: ${ref}`);
} }
} else { } else {
new NotifyUser(this.app, `Unable to resolve file path for: ${ref}`).open(); new NotifyUser(this.app, `Unable to resolve file path for: ${ref}`).open();
console.error(`Unable to resolve file path for: ${ref}`);
} }
} }
return imageUrls; return imageUrls;
@ -136,7 +130,6 @@ export default class DiscourseSyncPlugin extends Plugin {
raw: content, raw: content,
category: this.settings.category category: this.settings.category
}); });
console.log("POST Body:", body);
const response = await requestUrl({ const response = await requestUrl({
url: url, url: url,
@ -147,12 +140,8 @@ export default class DiscourseSyncPlugin extends Plugin {
}); });
if (response.status !== 200) { if (response.status !== 200) {
console.error("Error publishing to Discourse:", response.status);
console.error("Response body:", response.text);
if (response.status == 422) { if (response.status == 422) {
new NotifyUser(this.app, `There's an error with this post, could be a duplicate or the title is too short: ${response.status}`).open(); new NotifyUser(this.app, `There's an error with this post, could be a duplicate or the title is too short: ${response.status}`).open();
console.error("there's an error with this post, try making a longer title");
} }
return { message: "Error publishing to Discourse" }; return { message: "Error publishing to Discourse" };
} }
@ -190,7 +179,6 @@ export default class DiscourseSyncPlugin extends Plugin {
}); });
return allCategories; return allCategories;
} catch (error) { } catch (error) {
console.error("Error fetching categories:", error);
return []; return [];
} }
} }
@ -213,8 +201,6 @@ export default class DiscourseSyncPlugin extends Plugin {
const categories = await this.fetchCategories(); const categories = await this.fetchCategories();
if (categories.length > 0) { if (categories.length > 0) {
new SelectCategoryModal(this.app, this, categories).open(); new SelectCategoryModal(this.app, this, categories).open();
} else {
console.error("No categories");
} }
} }
@ -312,8 +298,6 @@ export class SelectCategoryModal extends Modal {
submitButton.textContent = '发布中...'; submitButton.textContent = '发布中...';
const reply = await this.plugin.postTopic(); const reply = await this.plugin.postTopic();
console.log(`postTopic message: ${reply.message}`);
console.log(`ID: ${selectedCategoryId}`);
// 显示提示信息 // 显示提示信息
noticeContainer.empty(); noticeContainer.empty();