Skip to content

Commit

Permalink
chore: minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
ourongxing committed Sep 24, 2024
1 parent e4c7467 commit e7f885f
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 31 deletions.
2 changes: 1 addition & 1 deletion app/components/Log.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export function Log() {
if (logs.length === 0) {
return {
content: "",
score: <></>,
score: null,
}
}

Expand Down
5 changes: 4 additions & 1 deletion app/components/NavBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export function NavBar() {
return (
<div className="flex-gap-3 items-center flex-wrap flex">
<button
type="button"
className={c("px3 py1 text-base btn-action", previewLib.type === "base" && "btn-action-active")}
disabled={exportState.status === "running"}
onClick={() => {
Expand All @@ -25,6 +26,7 @@ export function NavBar() {
本地词库
</button>
<button
type="button"
className={c("px3 py1 text-base btn-action", previewLib.type === "cloud" && "btn-action-active")}
disabled={exportState.status === "running"}
onClick={() => {
Expand All @@ -43,14 +45,15 @@ export function NavBar() {
</button>
<a
href="/"
className="i-ri:refresh-line text-lg op50 hover:op75"
className="i-ph:arrow-clockwise-bold op50 hover:op75"
title="刷新"
/>
<ThemeToggle />
<a
href="https://github.com/busiyiworld/maimemo-export"
target="_blank"
className="i-carbon-logo-github text-lg op50 hover:op75"
rel="noreferrer noopener"
/>
</div>
)
Expand Down
4 changes: 2 additions & 2 deletions app/components/ThemeToggle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import { useDark } from "~/hooks/useDark"
export function ThemeToggle() {
const { toggleDark } = useDark()
return (
<button
<div
title="Toggle Dark Mode"
className="i-ph-sun-dim-duotone dark:i-ph-moon-stars-duotone text-lg op50 hover:op75"
className="i-ph-sun-dim-duotone dark:i-ph-moon-stars-duotone text-lg op50 hover:op75 cursor-pointer"
onClick={toggleDark}
/>
)
Expand Down
8 changes: 6 additions & 2 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,15 @@ import ourongxing from "@ourongxing/eslint-config"
export default ourongxing(
{
type: "app",
react: false,
react: true,
stylistic: {
curly: "off",
},
ignores: ["node_modules/**"],
overrides: { },
overrides: {
react: {
"react-hooks/exhaustive-deps": "off",
},
},
},
)
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
"dev": "vinxi dev",
"adb": "bash scripts/adb.sh",
"test": "vitest",
"lint": "pnpm eslint .",
"lint": "eslint .",
"genDoc": "tsx scripts/genDoc.ts",
"lint:fix": "pnpm eslint . --fix"
"lint:fix": "eslint . --fix"
},
"dependencies": {
"@tanstack/match-sorter-utils": "^8.19.4",
Expand Down
2 changes: 1 addition & 1 deletion src/export.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { getLibWords, getLibs, translateAll } from "./query"
import { checkDatabases, databases } from "./db"
import { transform } from "./transform"
import { ensureTargetFolders } from "./dir"
import type { ExportFnProps, ExportLog, Target, TrafficLights, Word } from "@/types"
import type { ExportFnProps, ExportLog, Target, TrafficLights } from "@/types"

export async function exportLib({ selected, range, type, options, fnEvery }: ExportFnProps & { fnEvery: (log: ExportLog) => Promise<boolean> }) {
checkDatabases()
Expand Down
43 changes: 21 additions & 22 deletions test/db.test.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,25 @@
import { it } from "vitest"
import { exportLib } from "../src/db"
import { checkDatabases, databases } from "src/db"
import { getLibWords, getLibs } from "src/query"
import { beforeAll, expect, it } from "vitest"

it.skip("db", async () => {
const r = {
status: "selected",
selected: [{ id: 76, name: "2012雅思词汇加强版" }],
type: "base",
options: {
target: ["word", "translation", "list"],
previewTarget: "word",
exculedMemorized: false,
folderName: "",
override: true,
},
}
await exportLib(r.status, r.selected, r.type, r.options, (info: string) => {
console.log(info)
return false
})
beforeAll(() => {
checkDatabases()
})

it("test", () => {
const date = new Date()
console.log(new Date(date.getTime() - date.getTimezoneOffset() * 60 * 1000))
it("db status", async () => {
expect(databases.ecdict?.status).toBe(true)
expect(databases.maimemo_base?.status).toBe(true)
expect(databases.maimemo_cloud?.status).toBe(true)
})

it("get libs", () => {
expect(getLibs("base").length).toBeGreaterThan(0)
expect(getLibs("cloud").length).toBeGreaterThan(0)
})

it("get lib words", () => {
const words = getLibWords({ id: 13110210, type: "base", exculedMemorized: false })
expect(words.length).toBeGreaterThan(0)
expect(getLibWords({ id: 13110210, type: "base", exculedMemorized: true }).length).toBeLessThan(words.length)
expect(getLibWords({ id: 458595, type: "cloud", exculedMemorized: false }).length).toBeGreaterThan(0)
})

0 comments on commit e7f885f

Please sign in to comment.