mirror of
https://github.com/woodchen-ink/obsidian-publish-to-discourse.git
synced 2025-07-16 21:03:33 +08:00
fix
This commit is contained in:
parent
5afe6a38b1
commit
b37e4bdcb5
2
.github/workflows/release.yml
vendored
2
.github/workflows/release.yml
vendored
@ -29,7 +29,7 @@ jobs:
|
|||||||
tag="${GITHUB_REF#refs/tags/}"
|
tag="${GITHUB_REF#refs/tags/}"
|
||||||
|
|
||||||
files=()
|
files=()
|
||||||
for file in main.js manifest.json; do
|
for file in main.js manifest.json style.css; do
|
||||||
if [ -f "$file" ]; then
|
if [ -f "$file" ]; then
|
||||||
files+=("$file")
|
files+=("$file")
|
||||||
else
|
else
|
||||||
|
66
src/main.ts
66
src/main.ts
@ -47,13 +47,13 @@ export default class DiscourseSyncPlugin extends Plugin {
|
|||||||
for (const ref of imageReferences) {
|
for (const ref of imageReferences) {
|
||||||
const filePath = this.app.metadataCache.getFirstLinkpathDest(ref, this.activeFile.name)?.path;
|
const filePath = this.app.metadataCache.getFirstLinkpathDest(ref, this.activeFile.name)?.path;
|
||||||
if (filePath) {
|
if (filePath) {
|
||||||
const file = this.app.vault.getAbstractFileByPath(filePath) as TFile;
|
const abstractFile = this.app.vault.getAbstractFileByPath(filePath);
|
||||||
if (file) {
|
if (abstractFile instanceof TFile) {
|
||||||
try {
|
try {
|
||||||
const imgfile = await this.app.vault.readBinary(file);
|
const imgfile = await this.app.vault.readBinary(abstractFile);
|
||||||
const boundary = genBoundary();
|
const boundary = genBoundary();
|
||||||
const sBoundary = '--' + boundary + '\r\n';
|
const sBoundary = '--' + boundary + '\r\n';
|
||||||
const imgForm = `${sBoundary}Content-Disposition: form-data; name="file"; filename="${file.name}"\r\nContent-Type: image/${file.extension}\r\n\r\n`;
|
const imgForm = `${sBoundary}Content-Disposition: form-data; name="file"; filename="${abstractFile.name}"\r\nContent-Type: image/${abstractFile.extension}\r\n\r\n`;
|
||||||
|
|
||||||
|
|
||||||
let body = '';
|
let body = '';
|
||||||
@ -277,59 +277,7 @@ export class SelectCategoryModal extends Modal {
|
|||||||
|
|
||||||
onOpen() {
|
onOpen() {
|
||||||
const { contentEl } = this;
|
const { contentEl } = this;
|
||||||
|
|
||||||
// 添加样式
|
|
||||||
contentEl.addClass('discourse-sync-modal');
|
contentEl.addClass('discourse-sync-modal');
|
||||||
const styleEl = document.head.createEl('style');
|
|
||||||
styleEl.textContent = `
|
|
||||||
.discourse-sync-modal {
|
|
||||||
padding: 20px;
|
|
||||||
}
|
|
||||||
.discourse-sync-modal h1 {
|
|
||||||
margin-bottom: 20px;
|
|
||||||
color: var(--text-normal);
|
|
||||||
}
|
|
||||||
.discourse-sync-modal .select-container {
|
|
||||||
margin-bottom: 24px;
|
|
||||||
}
|
|
||||||
.discourse-sync-modal select {
|
|
||||||
width: 100%;
|
|
||||||
padding: 8px 12px;
|
|
||||||
height: 42px;
|
|
||||||
line-height: 1.5;
|
|
||||||
border: 1px solid var(--background-modifier-border);
|
|
||||||
border-radius: 4px;
|
|
||||||
background-color: var(--background-primary);
|
|
||||||
color: var(--text-normal);
|
|
||||||
}
|
|
||||||
.discourse-sync-modal .submit-button {
|
|
||||||
width: 100%;
|
|
||||||
padding: 10px;
|
|
||||||
background-color: var(--interactive-accent);
|
|
||||||
color: var(--text-on-accent);
|
|
||||||
border: none;
|
|
||||||
border-radius: 4px;
|
|
||||||
cursor: pointer;
|
|
||||||
font-weight: 500;
|
|
||||||
}
|
|
||||||
.discourse-sync-modal .submit-button:hover {
|
|
||||||
background-color: var(--interactive-accent-hover);
|
|
||||||
}
|
|
||||||
.discourse-sync-modal .notice {
|
|
||||||
margin-top: 16px;
|
|
||||||
padding: 10px;
|
|
||||||
border-radius: 4px;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
.discourse-sync-modal .notice.success {
|
|
||||||
background-color: var(--background-modifier-success);
|
|
||||||
color: var(--text-success);
|
|
||||||
}
|
|
||||||
.discourse-sync-modal .notice.error {
|
|
||||||
background-color: var(--background-modifier-error);
|
|
||||||
color: var(--text-error);
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|
||||||
contentEl.createEl("h1", { text: '选择发布分类' });
|
contentEl.createEl("h1", { text: '选择发布分类' });
|
||||||
|
|
||||||
@ -354,7 +302,6 @@ export class SelectCategoryModal extends Modal {
|
|||||||
// 创建提示信息容器
|
// 创建提示信息容器
|
||||||
const noticeContainer = contentEl.createEl('div');
|
const noticeContainer = contentEl.createEl('div');
|
||||||
|
|
||||||
|
|
||||||
submitButton.onclick = async () => {
|
submitButton.onclick = async () => {
|
||||||
const selectedCategoryId = selectEl.value;
|
const selectedCategoryId = selectEl.value;
|
||||||
this.plugin.settings.category = parseInt(selectedCategoryId);
|
this.plugin.settings.category = parseInt(selectedCategoryId);
|
||||||
@ -391,10 +338,5 @@ export class SelectCategoryModal extends Modal {
|
|||||||
onClose() {
|
onClose() {
|
||||||
const { contentEl } = this;
|
const { contentEl } = this;
|
||||||
contentEl.empty();
|
contentEl.empty();
|
||||||
// 清理添加的样式
|
|
||||||
const styleEl = document.head.querySelector('style:last-child');
|
|
||||||
if (styleEl) {
|
|
||||||
styleEl.remove();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
56
styles.css
56
styles.css
@ -6,3 +6,59 @@ available in the app when your plugin is enabled.
|
|||||||
If your plugin does not need CSS, delete this file.
|
If your plugin does not need CSS, delete this file.
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
.discourse-sync-modal {
|
||||||
|
padding: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.discourse-sync-modal h1 {
|
||||||
|
margin-bottom: 20px;
|
||||||
|
color: var(--text-normal);
|
||||||
|
}
|
||||||
|
|
||||||
|
.discourse-sync-modal .select-container {
|
||||||
|
margin-bottom: 24px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.discourse-sync-modal select {
|
||||||
|
width: 100%;
|
||||||
|
padding: 8px 12px;
|
||||||
|
height: 42px;
|
||||||
|
line-height: 1.5;
|
||||||
|
border: 1px solid var(--background-modifier-border);
|
||||||
|
border-radius: 4px;
|
||||||
|
background-color: var(--background-primary);
|
||||||
|
color: var(--text-normal);
|
||||||
|
}
|
||||||
|
|
||||||
|
.discourse-sync-modal .submit-button {
|
||||||
|
width: 100%;
|
||||||
|
padding: 10px;
|
||||||
|
background-color: var(--interactive-accent);
|
||||||
|
color: var(--text-on-accent);
|
||||||
|
border: none;
|
||||||
|
border-radius: 4px;
|
||||||
|
cursor: pointer;
|
||||||
|
font-weight: 500;
|
||||||
|
}
|
||||||
|
|
||||||
|
.discourse-sync-modal .submit-button:hover {
|
||||||
|
background-color: var(--interactive-accent-hover);
|
||||||
|
}
|
||||||
|
|
||||||
|
.discourse-sync-modal .notice {
|
||||||
|
margin-top: 16px;
|
||||||
|
padding: 10px;
|
||||||
|
border-radius: 4px;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.discourse-sync-modal .notice.success {
|
||||||
|
background-color: var(--background-modifier-success);
|
||||||
|
color: var(--text-success);
|
||||||
|
}
|
||||||
|
|
||||||
|
.discourse-sync-modal .notice.error {
|
||||||
|
background-color: var(--background-modifier-error);
|
||||||
|
color: var(--text-error);
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user