extract image assets for yomitan zip

This commit is contained in:
polv committed 2026-03-21 12:46:54 +07:00
1 parent 79deaf9372
commit 52c25992ab
11 files changed
+114 -52

No files matched your search

Binary file not shown.

Before

Width:  |  Height:  |  Size: 254 B

+17 -11
View File
@@ -2,10 +2,12 @@ import { createElement as h } from "react";
export default function Glossary({
glossary,
yomitanURL,
maxLength,
onTermClicked,
}: {
glossary: any;
yomitanURL: string;
maxLength?: number;
onTermClicked: (t: string) => void;
}) {
@@ -29,7 +31,7 @@ export default function Glossary({
// GlossaryImage
if ("type" in glossary && glossary.type === "image") {
return <GlossaryImage {...glossary} />;
return <GlossaryImage img={glossary} yomitanURL={yomitanURL} />;
}
// GlossaryStructuredContent
@@ -38,8 +40,7 @@ export default function Glossary({
return (
<StructuredContent
node={sc.content}
maxLength={maxLength}
onTermClicked={onTermClicked}
{...{ yomitanURL, maxLength, onTermClicked }}
/>
);
}
@@ -53,10 +54,10 @@ export default function Glossary({
return null;
}
function GlossaryImage(img: any) {
function GlossaryImage({ img, yomitanURL }: { img: any; yomitanURL: string }) {
return (
<img
src={img.path}
src={`${yomitanURL || ""}/${img.path}`}
width={img.width}
height={img.height}
title={img.title}
@@ -72,10 +73,12 @@ function GlossaryImage(img: any) {
function StructuredContent({
node,
yomitanURL,
maxLength,
onTermClicked,
}: {
node: any;
yomitanURL: string;
maxLength?: number;
onTermClicked: (t: string) => void;
}): any {
@@ -100,8 +103,7 @@ function StructuredContent({
<StructuredContent
key={i}
node={n}
maxLength={maxLength}
onTermClicked={onTermClicked}
{...{ yomitanURL, maxLength, onTermClicked }}
/>
))}
</>
@@ -118,7 +120,7 @@ function StructuredContent({
// Image
if (tag === "img") {
return <GlossaryImage {...node} />;
return <GlossaryImage img={node} yomitanURL={yomitanURL} />;
}
// Link
@@ -145,8 +147,7 @@ function StructuredContent({
{content ? (
<StructuredContent
node={content}
maxLength={maxLength}
onTermClicked={onTermClicked}
{...{ yomitanURL, maxLength, onTermClicked }}
/>
) : null}
</a>
@@ -159,6 +160,11 @@ function StructuredContent({
return h(
tag,
{ style: block.style, title: block.title, open: block.open },
StructuredContent({ node: block.content, maxLength, onTermClicked }),
StructuredContent({
node: block.content,
yomitanURL,
maxLength,
onTermClicked,
}),
);
}
+4 -4
View File
@@ -79,9 +79,9 @@ function LoadingDialog() {
const dicts: YomitanDownloadDictEntry[] = [];
if (lang === "ja") {
const filename = "Pixiv.zip";
const filepath = `yomitan/${lang}/${filename}`;
const existing = existing_dicts.find((d) => d.bundle_name === filename);
var filename = "PixivLight.zip";
var filepath = `yomitan/${lang}/${filename}`;
var existing = existing_dicts.find((d) => d.bundle_name === filename);
if (!existing) {
// Maybe check revision update
dicts.push({
@@ -89,7 +89,7 @@ function LoadingDialog() {
url:
(await ghLatestReleaseURL(
"MarvNC/pixiv-yomitan",
/^Pixiv_.+\.zip$/,
/^PixivLight_.+\.zip$/,
).catch((e) => {
console.error(e);
return "";
+13 -2
View File
@@ -18,7 +18,8 @@ import {
Stack,
Switch,
} from "@chakra-ui/react";
import { invoke } from "@tauri-apps/api/core";
import { convertFileSrc, invoke } from "@tauri-apps/api/core";
import { appDataDir, join } from "@tauri-apps/api/path";
import { readText } from "@tauri-apps/plugin-clipboard-manager";
import Glossary from "../components/Glossary";
@@ -54,6 +55,13 @@ function SearchPage() {
const [furigana, set_furigana] = useState("");
const [isAutoKana, set_isAutoKana] = useState(true);
const [isScrollEnd, set_isScrollEnd] = useState(false);
const [yomitanURL, set_yomitanURL] = useState("");
useEffect(() => {
(async () => {
set_yomitanURL(convertFileSrc(await join(await appDataDir(), "yomitan")));
})();
});
const nSearch = useRef(0);
const searchboxRef = useRef<HTMLInputElement | null>(null);
@@ -69,6 +77,9 @@ function SearchPage() {
const intervalId = setInterval(async () => {
const newText = (await readText()).replace(/ /g, "");
if (!/[\p{sc=Han}\p{scx=Hiragana}\p{scx=Katakana}〆]/u.test(newText)) {
return;
}
set_clipboardText((clipboardText) => {
if (clipboardText !== newText) {
@@ -411,7 +422,7 @@ function SearchPage() {
<Glossary
key={i}
glossary={g}
onTermClicked={onTermClicked}
{...{ yomitanURL, onTermClicked }}
/>
))}
</div>