fix
This commit is contained in:
parent
4ecf26f4b2
commit
4e21a8ee92
11 changed files with 97 additions and 53 deletions
26
package-lock.json
generated
26
package-lock.json
generated
|
@ -1,12 +1,12 @@
|
||||||
{
|
{
|
||||||
"name": "houhou",
|
"name": "houhou",
|
||||||
"version": "0.0.0",
|
"version": "0.1.0",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "houhou",
|
"name": "houhou",
|
||||||
"version": "0.0.0",
|
"version": "0.1.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@chakra-ui/react": "^2.7.0",
|
"@chakra-ui/react": "^2.7.0",
|
||||||
"@emotion/react": "^11.11.1",
|
"@emotion/react": "^11.11.1",
|
||||||
|
@ -29,6 +29,7 @@
|
||||||
"@vitejs/plugin-react": "^3.0.0",
|
"@vitejs/plugin-react": "^3.0.0",
|
||||||
"autoprefixer": "^10.4.14",
|
"autoprefixer": "^10.4.14",
|
||||||
"postcss": "^8.4.24",
|
"postcss": "^8.4.24",
|
||||||
|
"prettier": "^2.8.8",
|
||||||
"sass": "^1.62.1",
|
"sass": "^1.62.1",
|
||||||
"tailwindcss": "^3.3.2",
|
"tailwindcss": "^3.3.2",
|
||||||
"typescript": "^4.9.5",
|
"typescript": "^4.9.5",
|
||||||
|
@ -3289,6 +3290,21 @@
|
||||||
"integrity": "sha512-1NNCs6uurfkVbeXG4S8JFT9t19m45ICnif8zWLd5oPSZ50QnwMfK+H3jv408d4jw/7Bttv5axS5IiHoLaVNHeQ==",
|
"integrity": "sha512-1NNCs6uurfkVbeXG4S8JFT9t19m45ICnif8zWLd5oPSZ50QnwMfK+H3jv408d4jw/7Bttv5axS5IiHoLaVNHeQ==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"node_modules/prettier": {
|
||||||
|
"version": "2.8.8",
|
||||||
|
"resolved": "https://registry.npmjs.org/prettier/-/prettier-2.8.8.tgz",
|
||||||
|
"integrity": "sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q==",
|
||||||
|
"dev": true,
|
||||||
|
"bin": {
|
||||||
|
"prettier": "bin-prettier.js"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=10.13.0"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/prettier/prettier?sponsor=1"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/prop-types": {
|
"node_modules/prop-types": {
|
||||||
"version": "15.8.1",
|
"version": "15.8.1",
|
||||||
"resolved": "https://registry.npmjs.org/prop-types/-/prop-types-15.8.1.tgz",
|
"resolved": "https://registry.npmjs.org/prop-types/-/prop-types-15.8.1.tgz",
|
||||||
|
@ -6355,6 +6371,12 @@
|
||||||
"integrity": "sha512-1NNCs6uurfkVbeXG4S8JFT9t19m45ICnif8zWLd5oPSZ50QnwMfK+H3jv408d4jw/7Bttv5axS5IiHoLaVNHeQ==",
|
"integrity": "sha512-1NNCs6uurfkVbeXG4S8JFT9t19m45ICnif8zWLd5oPSZ50QnwMfK+H3jv408d4jw/7Bttv5axS5IiHoLaVNHeQ==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"prettier": {
|
||||||
|
"version": "2.8.8",
|
||||||
|
"resolved": "https://registry.npmjs.org/prettier/-/prettier-2.8.8.tgz",
|
||||||
|
"integrity": "sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
"prop-types": {
|
"prop-types": {
|
||||||
"version": "15.8.1",
|
"version": "15.8.1",
|
||||||
"resolved": "https://registry.npmjs.org/prop-types/-/prop-types-15.8.1.tgz",
|
"resolved": "https://registry.npmjs.org/prop-types/-/prop-types-15.8.1.tgz",
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"name": "houhou",
|
"name": "houhou",
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "0.0.0",
|
"version": "0.1.0",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite",
|
"dev": "vite",
|
||||||
|
@ -31,6 +31,7 @@
|
||||||
"@vitejs/plugin-react": "^3.0.0",
|
"@vitejs/plugin-react": "^3.0.0",
|
||||||
"autoprefixer": "^10.4.14",
|
"autoprefixer": "^10.4.14",
|
||||||
"postcss": "^8.4.24",
|
"postcss": "^8.4.24",
|
||||||
|
"prettier": "^2.8.8",
|
||||||
"sass": "^1.62.1",
|
"sass": "^1.62.1",
|
||||||
"tailwindcss": "^3.3.2",
|
"tailwindcss": "^3.3.2",
|
||||||
"typescript": "^4.9.5",
|
"typescript": "^4.9.5",
|
||||||
|
|
2
src-tauri/Cargo.lock
generated
2
src-tauri/Cargo.lock
generated
|
@ -1376,7 +1376,7 @@ checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "houhou"
|
name = "houhou"
|
||||||
version = "0.0.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"clap",
|
"clap",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "houhou"
|
name = "houhou"
|
||||||
version = "0.0.0"
|
version = "0.1.0"
|
||||||
description = "A Tauri App"
|
description = "A Tauri App"
|
||||||
authors = ["you"]
|
authors = ["you"]
|
||||||
license = ""
|
license = ""
|
||||||
|
|
|
@ -24,14 +24,16 @@ pub struct GetKanjiResult {
|
||||||
kanji: Vec<Kanji>,
|
kanji: Vec<Kanji>,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn build_kanji(row: SqliteRow) -> Kanji {
|
impl Kanji {
|
||||||
let character = row.get("Character");
|
fn from_sqlite_row(row: SqliteRow) -> Self {
|
||||||
let meaning = row.get("Meaning");
|
let character = row.get("Character");
|
||||||
let most_used_rank = row.get("MostUsedRank");
|
let meaning = row.get("Meaning");
|
||||||
Kanji {
|
let most_used_rank = row.get("MostUsedRank");
|
||||||
character,
|
Kanji {
|
||||||
meaning,
|
character,
|
||||||
most_used_rank,
|
meaning,
|
||||||
|
most_used_rank,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,7 +59,7 @@ pub async fn get_kanji(
|
||||||
.await
|
.await
|
||||||
.map_err(|_| ())?;
|
.map_err(|_| ())?;
|
||||||
|
|
||||||
let kanji = result.into_iter().map(build_kanji).collect();
|
let kanji = result.into_iter().map(Kanji::from_sqlite_row).collect();
|
||||||
|
|
||||||
let count = sqlx::query("SELECT COUNT(*) FROM KanjiSet")
|
let count = sqlx::query("SELECT COUNT(*) FROM KanjiSet")
|
||||||
.fetch_one(&db.0)
|
.fetch_one(&db.0)
|
||||||
|
@ -79,7 +81,7 @@ pub async fn get_single_kanji(
|
||||||
LEFT JOIN KanjiMeaningSet ON KanjiSet.ID = KanjiMeaningSet.Kanji_ID
|
LEFT JOIN KanjiMeaningSet ON KanjiSet.ID = KanjiMeaningSet.Kanji_ID
|
||||||
GROUP BY KanjiSet.ID
|
GROUP BY KanjiSet.ID
|
||||||
HAVING MostUsedRank IS NOT NULL
|
HAVING MostUsedRank IS NOT NULL
|
||||||
AND Kanji.Character = ?
|
AND KanjiSet.Character = ?
|
||||||
"#,
|
"#,
|
||||||
)
|
)
|
||||||
.bind(character)
|
.bind(character)
|
||||||
|
@ -87,5 +89,7 @@ pub async fn get_single_kanji(
|
||||||
.await
|
.await
|
||||||
.map_err(|_| ())?;
|
.map_err(|_| ())?;
|
||||||
|
|
||||||
Ok(Some(build_kanji(result)))
|
let kanji = Kanji::from_sqlite_row(result);
|
||||||
|
|
||||||
|
Ok(Some(kanji))
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,10 +11,7 @@ mod kanji;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
|
|
||||||
use anyhow::{Context, Result};
|
use anyhow::{Context, Result};
|
||||||
use sqlx::{
|
use sqlx::sqlite::{SqliteConnectOptions, SqlitePoolOptions};
|
||||||
sqlite::{SqliteConnectOptions, SqlitePoolOptions},
|
|
||||||
SqlitePool,
|
|
||||||
};
|
|
||||||
use tauri::SystemTray;
|
use tauri::SystemTray;
|
||||||
|
|
||||||
use crate::kanji::KanjiDb;
|
use crate::kanji::KanjiDb;
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
},
|
},
|
||||||
"package": {
|
"package": {
|
||||||
"productName": "houhou",
|
"productName": "houhou",
|
||||||
"version": "0.0.0"
|
"version": "0.1.0"
|
||||||
},
|
},
|
||||||
"tauri": {
|
"tauri": {
|
||||||
"allowlist": {
|
"allowlist": {
|
||||||
|
|
|
@ -4,28 +4,28 @@ import { Kanji } from "../types/Kanji";
|
||||||
import styles from "./KanjiDisplay.module.scss";
|
import styles from "./KanjiDisplay.module.scss";
|
||||||
import useSWR from "swr";
|
import useSWR from "swr";
|
||||||
|
|
||||||
|
type GetSingleKanjiResult = Kanji;
|
||||||
|
|
||||||
interface KanjiDisplayProps {
|
interface KanjiDisplayProps {
|
||||||
kanjiCharacter: string;
|
kanjiCharacter: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function KanjiDisplay({ kanjiCharacter }: KanjiDisplayProps) {
|
export default function KanjiDisplay({ kanjiCharacter }: KanjiDisplayProps) {
|
||||||
const { data, error, isLoading } = useSWR(["get_single_kanji", kanjiCharacter], ([command, character]) => invoke<GetKanjiResult>(command, { character }));
|
const {
|
||||||
|
data: kanji,
|
||||||
|
error,
|
||||||
|
isLoading,
|
||||||
|
} = useSWR(["get_single_kanji", kanjiCharacter], ([command, character]) =>
|
||||||
|
invoke<GetSingleKanjiResult>(command, { character }),
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!kanji) return <>Loading...</>;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div className={styles.display}>{kanjiCharacter}</div>
|
<div className={styles.display}>{kanji.character}</div>
|
||||||
|
|
||||||
{JSON.stringify(isLoading)}
|
{kanji.meaning}
|
||||||
|
|
||||||
<p>
|
|
||||||
data:
|
|
||||||
{JSON.stringify(data)}
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
error:
|
|
||||||
{JSON.stringify(error)}
|
|
||||||
</p>
|
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,3 +8,10 @@
|
||||||
padding: 4px 8px;
|
padding: 4px 8px;
|
||||||
border: 1px solid lightgray;
|
border: 1px solid lightgray;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.kanji-list-scroll {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 4px;
|
||||||
|
overflow-y: scroll;
|
||||||
|
}
|
||||||
|
|
|
@ -20,22 +20,27 @@ interface KanjiListProps {
|
||||||
function KanjiList({ data, selectedCharacter }: KanjiListProps) {
|
function KanjiList({ data, selectedCharacter }: KanjiListProps) {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
Displaying {data.kanji.length} of {data.count} results.
|
<small>
|
||||||
{data.kanji.map((kanji) => (
|
Displaying {data.kanji.length} of {data.count} results.
|
||||||
<Link
|
</small>
|
||||||
key={kanji.character}
|
|
||||||
className={styles["kanji-link"]}
|
<div className={styles["kanji-list-scroll"]}>
|
||||||
to={`/kanji/${kanji.character}`}
|
{data.kanji.map((kanji) => (
|
||||||
>
|
<Link
|
||||||
<Grid templateRows="repeat(2, 1fr)" templateColumns="1fr 3fr">
|
key={kanji.character}
|
||||||
<GridItem rowSpan={2} style={{ fontSize: "24px", textAlign: "center" }}>
|
className={styles["kanji-link"]}
|
||||||
{kanji.character}
|
to={`/kanji/${kanji.character}`}
|
||||||
</GridItem>
|
>
|
||||||
<GridItem>{kanji.meaning}</GridItem>
|
<Grid templateRows="repeat(2, 1fr)" templateColumns="1fr 3fr">
|
||||||
<GridItem>#{kanji.most_used_rank} most used</GridItem>
|
<GridItem rowSpan={2} style={{ fontSize: "24px", textAlign: "center" }}>
|
||||||
</Grid>
|
{kanji.character}
|
||||||
</Link>
|
</GridItem>
|
||||||
))}
|
<GridItem>{kanji.meaning}</GridItem>
|
||||||
|
<GridItem>#{kanji.most_used_rank} most used</GridItem>
|
||||||
|
</Grid>
|
||||||
|
</Link>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -46,9 +51,6 @@ export default function KanjiPane() {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{JSON.stringify(error)}
|
|
||||||
{JSON.stringify(selectedKanji)}
|
|
||||||
|
|
||||||
<Stack spacing={7} direction="row">
|
<Stack spacing={7} direction="row">
|
||||||
<Box p={2} className={styles["kanji-list"]}>
|
<Box p={2} className={styles["kanji-list"]}>
|
||||||
{data && <KanjiList data={data} selectedCharacter={selectedKanji} />}
|
{data && <KanjiList data={data} selectedCharacter={selectedKanji} />}
|
||||||
|
|
|
@ -1,3 +1,14 @@
|
||||||
@tailwind base;
|
@tailwind base;
|
||||||
@tailwind components;
|
@tailwind components;
|
||||||
@tailwind utilities;
|
@tailwind utilities;
|
||||||
|
|
||||||
|
html,
|
||||||
|
body {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
body {
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue