* lint

* fix some lint error

* fix window hide error when size zero

* toast error when lookup failed

* resolve #239
This commit is contained in:
an-lee
2024-02-02 14:40:11 +08:00
committed by GitHub
parent 1868e27c0f
commit e1f52e609e
20 changed files with 35 additions and 29 deletions

View File

@@ -14,7 +14,7 @@ log.errorHandler.startCatching();
// Fix "getRandomValues() not supported"
global.crypto = crypto;
app.commandLine.appendSwitch('enable-features','SharedArrayBuffer')
app.commandLine.appendSwitch("enable-features", "SharedArrayBuffer");
// Handle creating/removing shortcuts on Windows when installing/uninstalling.
if (require("electron-squirrel-startup")) {
@@ -58,7 +58,7 @@ app.on("ready", async () => {
// for applications and their menu bar to stay active until the user quits
// explicitly with Cmd + Q.
app.on("window-all-closed", () => {
app.quit();
app.quit();
});
app.on("activate", () => {

View File

@@ -16,7 +16,7 @@ import {
} from "sequelize-typescript";
import { Recording, Speech, Transcription, Video } from "@main/db/models";
import settings from "@main/settings";
import { AudioFormats, VideoFormats } from "@/constants";
import { AudioFormats, VideoFormats , WEB_API_URL } from "@/constants";
import { hashFile } from "@/utils";
import path from "path";
import fs from "fs-extra";
@@ -26,7 +26,6 @@ import log from "electron-log/main";
import storage from "@main/storage";
import Ffmpeg from "@main/ffmpeg";
import { Client } from "@/api";
import { WEB_API_URL } from "@/constants";
import startCase from "lodash/startCase";
import { v5 as uuidv5 } from "uuid";

View File

@@ -16,7 +16,7 @@ import {
} from "sequelize-typescript";
import { Audio, Recording, Speech, Transcription } from "@main/db/models";
import settings from "@main/settings";
import { AudioFormats, VideoFormats } from "@/constants";
import { AudioFormats, VideoFormats , WEB_API_URL } from "@/constants";
import { hashFile } from "@/utils";
import path from "path";
import fs from "fs-extra";
@@ -26,7 +26,6 @@ import log from "electron-log/main";
import storage from "@main/storage";
import Ffmpeg from "@main/ffmpeg";
import { Client } from "@/api";
import { WEB_API_URL } from "@/constants";
import startCase from "lodash/startCase";
import { v5 as uuidv5 } from "uuid";

View File

@@ -9,7 +9,7 @@ import downloader from "@main/downloader";
import storage from "@main/storage";
import readdirp from "readdirp";
import { t } from "i18next";
import uniq from "lodash/uniq";
import uniq from "lodash/uniq";
const logger = log.scope("ffmpeg");
export default class FfmpegWrapper {

View File

@@ -5,7 +5,7 @@ import {
WHISPER_MODELS_OPTIONS,
PROCESS_TIMEOUT,
AI_WORKER_ENDPOINT,
} from "@/constants";
WEB_API_URL } from "@/constants";
import { exec } from "child_process";
import fs from "fs-extra";
import log from "electron-log/main";
@@ -14,7 +14,6 @@ import axios from "axios";
import { milisecondsToTimestamp } from "@/utils";
import { AzureSpeechSdk } from "@main/azure-speech-sdk";
import { Client } from "@/api";
import { WEB_API_URL } from "@/constants";
import take from "lodash/take";
import sortedUniqBy from "lodash/sortedUniqBy";

View File

@@ -225,6 +225,7 @@ main.init = () => {
const bounds = view.getBounds();
logger.debug("current view bounds", bounds);
if (bounds.width === 0 && bounds.height === 0) return;
view.setBounds({
x: -Math.round(bounds.width),

View File

@@ -1,6 +1,6 @@
import { useState, useEffect } from "react";
import { LoaderSpin, MeaningCard } from "@renderer/components";
import { Button } from "@renderer/components/ui";
import { Button, toast } from "@renderer/components/ui";
import { t } from "i18next";
import { XCircleIcon } from "lucide-react";
import { useAiCommand } from "@renderer/hooks";
@@ -36,6 +36,9 @@ export const LookupResult = (props: {
onResult && onResult(lookup.meaning);
}
})
.catch((error) => {
toast.error(error.message);
})
.finally(() => {
setLoading(false);
});

View File

@@ -319,7 +319,7 @@ export const MediaPlayerControls = (props: {
</div>
</div>
<Tooltip id="media-player-controls-tooltip" />
<Tooltip className="z-10" id="media-player-controls-tooltip" />
</div>
);
};

View File

@@ -25,7 +25,8 @@ export const PitchContour = (props: {
height: number;
id?: string;
}) => {
let { peaks, sampleRate, frequencies, height, id } = props;
const { peaks, sampleRate, height, id } = props;
let { frequencies } = props;
if (!frequencies) {
frequencies = extractFrequencies({ peaks, sampleRate });

View File

@@ -171,7 +171,7 @@ export const RecordingsList = (props: {
<div className="z-50 bottom-16 left-1/2 w-0 h-0 absolute flex items-center justify-center">
{referenceId !== undefined && Boolean(referenceText) && (
<RecordButton
disabled={referenceId == undefined || !Boolean(referenceText)}
disabled={referenceId == undefined || !referenceText}
onRecordEnd={createRecording}
/>
)}

View File

@@ -22,9 +22,9 @@ export const StoryContent = (props: { content: string }) => {
{paragraphs.map((sentences, i: number) => (
<p key={`paragraph-${i}`} className="">
{sentences.map((sentence, i: number) => {
if (sentence.text.match(/\!\[\]\(\S+\)/g)) {
const [img] = sentence.text.match(/\!\[\]\(\S+\)/g);
const src = img.replace(/\!\[\]\(/g, "").replace(/\)/g, "");
if (sentence.text.match(/!\[\]\(\S+\)/g)) {
const [img] = sentence.text.match(/!\[\]\(\S+\)/g);
const src = img.replace(/!\[\]\(/g, "").replace(/\)/g, "");
return (
<p key={`paragraph-${i}`}>
<img src={src} />

View File

@@ -54,7 +54,7 @@ export const StoryViewer = (props: {
const word = selection
.toString()
.trim()
.replace(/[.,\/#!$%\^&\*;:{}=\-_`~()]+$/, "");
.replace(/[.,/#!$%^&*;:{}=\-_`~()]+$/, "");
if (!word) return;
const position = {
@@ -152,9 +152,9 @@ export const StoryViewer = (props: {
{paragraphs.map((sentences, i: number) => (
<p key={`paragraph-${i}`} className="">
{sentences.map((sentence, j: number) => {
if (sentence.text.match(/\!\[\]\(\S+\)/g)) {
const [img] = sentence.text.match(/\!\[\]\(\S+\)/g);
const src = img.replace(/\!\[\]\(/g, "").replace(/\)/g, "");
if (sentence.text.match(/!\[\]\(\S+\)/g)) {
const [img] = sentence.text.match(/!\[\]\(\S+\)/g);
const src = img.replace(/!\[\]\(/g, "").replace(/\)/g, "");
return <img key={`paragraph-${i}-sentence-${j}`} src={src} />;
} else {
return (

View File

@@ -9,8 +9,6 @@ import {
translateCommand,
ipaCommand,
} from "@commands";
import { toast } from "@renderer/components/ui";
import { t } from "i18next";
import { md5 } from "js-md5";
export const useAiCommand = () => {

View File

@@ -9,7 +9,7 @@ import { ChatOpenAI } from "langchain/chat_models/openai";
import { ChatOllama } from "langchain/chat_models/ollama";
import { ChatGoogleGenerativeAI } from "@langchain/google-genai";
import { ChatPromptTemplate, MessagesPlaceholder } from "langchain/prompts";
import OpenAI, { type ClientOptions } from "openai";
import OpenAI from "openai";
import { type Generation } from "langchain/dist/schema";
import { v4 } from "uuid";
@@ -124,7 +124,7 @@ export const useConversation = () => {
const llm = pickLlm(conversation);
const chain = new ConversationChain({
// @ts-ignore
// @ts-expect-error
llm,
memory,
prompt,

View File

@@ -23,7 +23,7 @@ import { useConversation } from "@renderer/hooks";
export default () => {
const { id } = useParams<{ id: string }>();
const [searchParams, _] = useSearchParams();
const [searchParams] = useSearchParams();
const [editting, setEditting] = useState<boolean>(false);
const [conversation, setConversation] = useState<ConversationType>();
const { addDblistener, removeDbListener } = useContext(DbProviderContext);

View File

@@ -9,9 +9,7 @@ import {
} from "@renderer/components";
import { useState, useContext, useEffect } from "react";
import { useParams } from "react-router-dom";
import {
AppSettingsProviderContext,
} from "@renderer/context";
import { AppSettingsProviderContext } from "@renderer/context";
import { useAiCommand } from "@renderer/hooks";
import nlp from "compromise";
import paragraphs from "compromise-paragraphs";
@@ -67,7 +65,7 @@ export default () => {
const extractVocabulary = async () => {
if (!story) return;
let { words = [], idioms = [] } = story?.extraction || {};
const { words = [], idioms = [] } = story?.extraction || {};
if (story?.extracted && (words.length > 0 || idioms.length > 0)) return;
toast.promise(

View File

@@ -12,6 +12,8 @@ export const audiosReducer = (
return [...audios, action.record];
} else if (action.records) {
return [...audios, ...action.records];
} else {
return audios;
}
}
case "create": {

View File

@@ -12,6 +12,8 @@ export const messagesReducer = (
return [...messages, action.record];
} else if (action.records) {
return [...messages, ...action.records];
} else {
return messages;
}
}
case "create": {

View File

@@ -12,6 +12,8 @@ export const recordingsReducer = (
return [...recordings, action.record];
} else if (action.records) {
return [...recordings, ...action.records];
} else {
return recordings;
}
}
case "create": {

View File

@@ -12,6 +12,8 @@ export const videosReducer = (
return [...videos, action.record];
} else if (action.records) {
return [...videos, ...action.records];
} else {
return videos;
}
}
case "create": {