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",
|
||||
"version": "0.0.0",
|
||||
"version": "0.1.0",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "houhou",
|
||||
"version": "0.0.0",
|
||||
"version": "0.1.0",
|
||||
"dependencies": {
|
||||
"@chakra-ui/react": "^2.7.0",
|
||||
"@emotion/react": "^11.11.1",
|
||||
|
@ -29,6 +29,7 @@
|
|||
"@vitejs/plugin-react": "^3.0.0",
|
||||
"autoprefixer": "^10.4.14",
|
||||
"postcss": "^8.4.24",
|
||||
"prettier": "^2.8.8",
|
||||
"sass": "^1.62.1",
|
||||
"tailwindcss": "^3.3.2",
|
||||
"typescript": "^4.9.5",
|
||||
|
@ -3289,6 +3290,21 @@
|
|||
"integrity": "sha512-1NNCs6uurfkVbeXG4S8JFT9t19m45ICnif8zWLd5oPSZ50QnwMfK+H3jv408d4jw/7Bttv5axS5IiHoLaVNHeQ==",
|
||||
"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": {
|
||||
"version": "15.8.1",
|
||||
"resolved": "https://registry.npmjs.org/prop-types/-/prop-types-15.8.1.tgz",
|
||||
|
@ -6355,6 +6371,12 @@
|
|||
"integrity": "sha512-1NNCs6uurfkVbeXG4S8JFT9t19m45ICnif8zWLd5oPSZ50QnwMfK+H3jv408d4jw/7Bttv5axS5IiHoLaVNHeQ==",
|
||||
"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": {
|
||||
"version": "15.8.1",
|
||||
"resolved": "https://registry.npmjs.org/prop-types/-/prop-types-15.8.1.tgz",
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "houhou",
|
||||
"private": true,
|
||||
"version": "0.0.0",
|
||||
"version": "0.1.0",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
|
@ -31,6 +31,7 @@
|
|||
"@vitejs/plugin-react": "^3.0.0",
|
||||
"autoprefixer": "^10.4.14",
|
||||
"postcss": "^8.4.24",
|
||||
"prettier": "^2.8.8",
|
||||
"sass": "^1.62.1",
|
||||
"tailwindcss": "^3.3.2",
|
||||
"typescript": "^4.9.5",
|
||||
|
|
2
src-tauri/Cargo.lock
generated
2
src-tauri/Cargo.lock
generated
|
@ -1376,7 +1376,7 @@ checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70"
|
|||
|
||||
[[package]]
|
||||
name = "houhou"
|
||||
version = "0.0.0"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"clap",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "houhou"
|
||||
version = "0.0.0"
|
||||
version = "0.1.0"
|
||||
description = "A Tauri App"
|
||||
authors = ["you"]
|
||||
license = ""
|
||||
|
|
|
@ -24,7 +24,8 @@ pub struct GetKanjiResult {
|
|||
kanji: Vec<Kanji>,
|
||||
}
|
||||
|
||||
fn build_kanji(row: SqliteRow) -> Kanji {
|
||||
impl Kanji {
|
||||
fn from_sqlite_row(row: SqliteRow) -> Self {
|
||||
let character = row.get("Character");
|
||||
let meaning = row.get("Meaning");
|
||||
let most_used_rank = row.get("MostUsedRank");
|
||||
|
@ -34,6 +35,7 @@ fn build_kanji(row: SqliteRow) -> Kanji {
|
|||
most_used_rank,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn get_kanji(
|
||||
|
@ -57,7 +59,7 @@ pub async fn get_kanji(
|
|||
.await
|
||||
.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")
|
||||
.fetch_one(&db.0)
|
||||
|
@ -79,7 +81,7 @@ pub async fn get_single_kanji(
|
|||
LEFT JOIN KanjiMeaningSet ON KanjiSet.ID = KanjiMeaningSet.Kanji_ID
|
||||
GROUP BY KanjiSet.ID
|
||||
HAVING MostUsedRank IS NOT NULL
|
||||
AND Kanji.Character = ?
|
||||
AND KanjiSet.Character = ?
|
||||
"#,
|
||||
)
|
||||
.bind(character)
|
||||
|
@ -87,5 +89,7 @@ pub async fn get_single_kanji(
|
|||
.await
|
||||
.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 anyhow::{Context, Result};
|
||||
use sqlx::{
|
||||
sqlite::{SqliteConnectOptions, SqlitePoolOptions},
|
||||
SqlitePool,
|
||||
};
|
||||
use sqlx::sqlite::{SqliteConnectOptions, SqlitePoolOptions};
|
||||
use tauri::SystemTray;
|
||||
|
||||
use crate::kanji::KanjiDb;
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
},
|
||||
"package": {
|
||||
"productName": "houhou",
|
||||
"version": "0.0.0"
|
||||
"version": "0.1.0"
|
||||
},
|
||||
"tauri": {
|
||||
"allowlist": {
|
||||
|
|
|
@ -4,28 +4,28 @@ import { Kanji } from "../types/Kanji";
|
|||
import styles from "./KanjiDisplay.module.scss";
|
||||
import useSWR from "swr";
|
||||
|
||||
type GetSingleKanjiResult = Kanji;
|
||||
|
||||
interface KanjiDisplayProps {
|
||||
kanjiCharacter: string;
|
||||
}
|
||||
|
||||
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 (
|
||||
<>
|
||||
<div className={styles.display}>{kanjiCharacter}</div>
|
||||
<div className={styles.display}>{kanji.character}</div>
|
||||
|
||||
{JSON.stringify(isLoading)}
|
||||
|
||||
<p>
|
||||
data:
|
||||
{JSON.stringify(data)}
|
||||
</p>
|
||||
|
||||
<p>
|
||||
error:
|
||||
{JSON.stringify(error)}
|
||||
</p>
|
||||
{kanji.meaning}
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
|
|
@ -8,3 +8,10 @@
|
|||
padding: 4px 8px;
|
||||
border: 1px solid lightgray;
|
||||
}
|
||||
|
||||
.kanji-list-scroll {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
overflow-y: scroll;
|
||||
}
|
||||
|
|
|
@ -20,7 +20,11 @@ interface KanjiListProps {
|
|||
function KanjiList({ data, selectedCharacter }: KanjiListProps) {
|
||||
return (
|
||||
<>
|
||||
<small>
|
||||
Displaying {data.kanji.length} of {data.count} results.
|
||||
</small>
|
||||
|
||||
<div className={styles["kanji-list-scroll"]}>
|
||||
{data.kanji.map((kanji) => (
|
||||
<Link
|
||||
key={kanji.character}
|
||||
|
@ -36,6 +40,7 @@ function KanjiList({ data, selectedCharacter }: KanjiListProps) {
|
|||
</Grid>
|
||||
</Link>
|
||||
))}
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
@ -46,9 +51,6 @@ export default function KanjiPane() {
|
|||
|
||||
return (
|
||||
<>
|
||||
{JSON.stringify(error)}
|
||||
{JSON.stringify(selectedKanji)}
|
||||
|
||||
<Stack spacing={7} direction="row">
|
||||
<Box p={2} className={styles["kanji-list"]}>
|
||||
{data && <KanjiList data={data} selectedCharacter={selectedKanji} />}
|
||||
|
|
|
@ -1,3 +1,14 @@
|
|||
@tailwind base;
|
||||
@tailwind components;
|
||||
@tailwind utilities;
|
||||
|
||||
html,
|
||||
body {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
body {
|
||||
overflow: hidden;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue