Skip to content
This repository has been archived by the owner on Nov 11, 2024. It is now read-only.

Commit

Permalink
modified: package-lock.json
Browse files Browse the repository at this point in the history
	modified:   package.json
	modified:   src/main.ts
	modified:   src/sve/GetMeaning.svelte
  • Loading branch information
xvyv99 committed May 26, 2024
1 parent 60b818a commit 60b2b2d
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 18 deletions.
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"svelte": "^4.2.8",
"svelte-preprocess": "^5.1.3",
"tslib": "2.4.0",
"typescript": "^5.3.3"
"typescript": "^5.4.5"
},
"dependencies": {
"tsc": "^2.0.4"
Expand Down
2 changes: 1 addition & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ export class GetMeaning extends Modal {
props: {
Vault: vault,
Sel: this.Selection,
Path: DataPath
Path: DataPath,
}
});
}
Expand Down
27 changes: 18 additions & 9 deletions src/sve/GetMeaning.svelte
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<script lang="ts">
import {Notice} from "obsidian";
export let Vault;
export let Path: string; //数据文件的路径
export let Sel: string; //需要查找的词语
Expand All @@ -7,32 +8,40 @@
[key: string] : { [key: string]: string }
}; //词语存储类型
let SenseMap: Map<string, string> = new Map();
let Sense: Map<string, string>; //TODO:没办法删掉这行代码.
let Data: WordObject;
let WordExist: boolean;
let WordHit = new Map();
const { adapter } = Vault; //读写接口
init();
$: SenseMap = SenseMap
$: Sense = Sense //TODO:没办法删掉这行代码.
$: WordHit = WordHit
async function init() {
Data = JSON.parse(await adapter.read(Path));
WordExist = Sel in Data;
if (WordExist) {
SenseMap = new Map(Object.entries(Data[Sel]));
Sense = new Map(); //TODO:没办法删掉这行代码.
for (let key in Data) {
if (key.toLowerCase() == Sel.toLowerCase()) {
WordHit.set(key,Object.entries(Data[key]));
}
}
}
</script>

<h2>The Meaning of the Word "<span class="highlight">{Sel}</span>"</h2>

{#if !WordExist}
{#if WordHit.size==0}
Not found.
{:else}
<ul>
{#each SenseMap as [key, value], i}
<li>Sense{i + 1} {value} {key}</li>
{#each WordHit.keys() as key,i}
<li>Hit{i + 1} {key}</li>
<ul>
{#each WordHit.get(key) as [meaning, type],j}
<li>Sense{j + 1} {type} {meaning}</li>
{/each}
</ul>
{/each}
</ul>
{/if}
Expand Down

0 comments on commit 60b2b2d

Please sign in to comment.