Skip to content

Commit

Permalink
feat: code
Browse files Browse the repository at this point in the history
  • Loading branch information
qq3603643 committed Nov 23, 2024
1 parent 28eda8d commit 98d4686
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 17 deletions.
10 changes: 3 additions & 7 deletions src/IweaverView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,10 @@ export class IweaverBotView extends ItemView {
let src = `${hostName}/dialogue?token=${apiKey}${
ifEn ? "&i18n=en" : ""
}${isDarkTheme ? "" : "&background_img=0"}`;
iframe.classList.add("iweaver_iframe");
if (isDarkTheme) {
iframe.style.filter = "grayscale(100%) invert(100%)";
iframe.classList.add("dark");
}
iframe.style.width = "100%";
iframe.style.height = "99%";
iframe.style.border = "none";

const file = this.app.workspace.getActiveFile();
if (!file) {
Expand Down Expand Up @@ -69,8 +67,6 @@ export class IweaverPreviewView extends ItemView {
container.empty();
const iframe = container.createEl("iframe");
iframe.src = this.getState().SourceURL as string;
iframe.style.width = "100%";
iframe.style.height = "99%";
iframe.style.border = "none";
iframe.classList.add("iweaver_iframe");
}
}
2 changes: 1 addition & 1 deletion src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export const getArticles = async (
apiKey: string,
limit = 200,
page = 1,
url = API_URLS.DOMESTIC
url: string = API_URLS.DOMESTIC
): Promise<GetArticlesResponse> => {
const urlWithSource = `${url}?source=iframe_sdk`;
const response = await fetch(urlWithSource, {
Expand Down
7 changes: 2 additions & 5 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,6 @@ export default class IweaverPlugin extends Plugin {
clearInterval(this.syncIntervalId);
this.syncIntervalId = null;
}

// 关闭所有视图
this.app.workspace.detachLeavesOfType(IWEAVER_BOT_VIEW);
}

private getFolderPath(create_time: string, tags: any[]): string {
Expand Down Expand Up @@ -227,7 +224,7 @@ export default class IweaverPlugin extends Plugin {
apiKey,
15,
page,
this.settings.fetchUrl as any
this.settings.fetchUrl
);

if (firstResponse.code !== 0) {
Expand All @@ -245,7 +242,7 @@ export default class IweaverPlugin extends Plugin {
apiKey,
15,
page,
this.settings.fetchUrl as any
this.settings.fetchUrl
);
const { code, data } = response;
if (code !== 0) {
Expand Down
20 changes: 16 additions & 4 deletions styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,22 @@ If your plugin does not need CSS, delete this file.
*/

.workspace-leaf-content[data-type="iweaver-view"] {
padding: 0;
.workspace-leaf-content[data-type="iweaver-view"],
.workspace-leaf-content[data-type="iweaver-preview-view"] {
padding: 0;
}

.workspace-leaf-content[data-type="iweaver-view"] .view-content {
padding: 0;
.workspace-leaf-content[data-type="iweaver-view"] .view-content,
.workspace-leaf-content[data-type="iweaver-preview-view"] .view-content {
padding: 0;
}

.iweaver_iframe {
width: 100%;
height: 99%;
border: 0 none;
}

.iweaver_iframe.dark {
filter: grayscale(100%) invert(100%);
}

0 comments on commit 98d4686

Please sign in to comment.