From aeb13079e16b830ba0d2ba0450bd90e4698cb3ec Mon Sep 17 00:00:00 2001 From: Vanessa Date: Tue, 21 Mar 2023 19:35:33 +0800 Subject: [PATCH] :art: https://github.com/siyuan-note/siyuan/issues/7695 --- app/src/config/AI.ts | 8 +++---- app/src/config/card.ts | 48 ++++++++++++++++++++++++++++++---------- app/src/types/index.d.ts | 7 ++++++ 3 files changed, 47 insertions(+), 16 deletions(-) diff --git a/app/src/config/AI.ts b/app/src/config/AI.ts index 968ad6e89..38686915b 100644 --- a/app/src/config/AI.ts +++ b/app/src/config/AI.ts @@ -58,11 +58,11 @@ export const AI = { item.addEventListener("change", () => { fetchPost("/api/setting/setAI", { openAI: { - apiBaseURL: (AI.element.querySelector("#apiBaseURL") as HTMLInputElement).checked, + apiBaseURL: (AI.element.querySelector("#apiBaseURL") as HTMLInputElement).value, apiKey: (AI.element.querySelector("#apiKey") as HTMLInputElement).value, - apiMaxTokens: (AI.element.querySelector("#apiMaxTokens") as HTMLInputElement).value, - apiProxy: (AI.element.querySelector("#apiProxy") as HTMLInputElement).checked, - apiTimeout: (AI.element.querySelector("#apiTimeout") as HTMLInputElement).checked, + apiMaxTokens: parseInt((AI.element.querySelector("#apiMaxTokens") as HTMLInputElement).value), + apiProxy: (AI.element.querySelector("#apiProxy") as HTMLInputElement).value, + apiTimeout: parseInt((AI.element.querySelector("#apiTimeout") as HTMLInputElement).value), } }, response => { window.siyuan.config.ai = response.data; diff --git a/app/src/config/card.ts b/app/src/config/card.ts index 416e8a052..66016fef9 100644 --- a/app/src/config/card.ts +++ b/app/src/config/card.ts @@ -5,32 +5,56 @@ export const card = { genHTML: () => { return ` + + +`; }, bindEvent: () => { card.element.querySelectorAll("input").forEach((item) => { item.addEventListener("change", () => { fetchPost("/api/setting/setFlashcard", { - apiBaseURL: (card.element.querySelector("#apiBaseURL") as HTMLInputElement).checked, - apiKey: (card.element.querySelector("#apiKey") as HTMLInputElement).value, - apiMaxTokens: (card.element.querySelector("#apiMaxTokens") as HTMLInputElement).value, - apiProxy: (card.element.querySelector("#apiProxy") as HTMLInputElement).checked, - apiTimeout: (card.element.querySelector("#apiTimeout") as HTMLInputElement).checked, + dailyNewCardLimit: parseInt((card.element.querySelector("#dailyNewCardLimit") as HTMLInputElement).value), + dailyReviewCardLimit: parseInt((card.element.querySelector("#dailyReviewCardLimit") as HTMLInputElement).value), + list: (card.element.querySelector("#list") as HTMLInputElement).checked, + superBlock: (card.element.querySelector("#superBlock") as HTMLInputElement).checked, + deck: (card.element.querySelector("#deck") as HTMLInputElement).checked, }, response => { - window.siyuan.config.ai = response.data; + window.siyuan.config.flashcard = response.data; }); }); }); diff --git a/app/src/types/index.d.ts b/app/src/types/index.d.ts index a18373a27..62ec63615 100644 --- a/app/src/types/index.d.ts +++ b/app/src/types/index.d.ts @@ -392,6 +392,13 @@ declare interface IConfig { repo: { key: string }, + flashcard: { + dailyNewCardLimit: number + dailyReviewCardLimit: number + list: boolean + superBlock: boolean + deck: boolean + } ai: { openAI: { apiBaseURL: string