diff --git a/options.html b/options.html
index b448f2a..18a2035 100644
--- a/options.html
+++ b/options.html
@@ -35,6 +35,7 @@
LexiBridge设置
示例文件: CET6单词下载
+
diff --git a/words.js b/words.js
index 289f444..3c9af2e 100644
--- a/words.js
+++ b/words.js
@@ -47,15 +47,23 @@
});
document.getElementById("import-btn").addEventListener("click", (e) => {
+ e.target.classList.add("is-loading");
e.preventDefault();
const files = document.querySelector("[name=source]").files;
for (const file of files) {
const reader = new FileReader();
- reader.onload = (e) => {
+ reader.onload = async(e) => {
const data = JSON.parse(e.target.result);
- chrome.storage.local.set({"words":data})
+ await chrome.storage.local.set({"words":data})
+ window.location.reload();
}
reader.readAsText(file);
}
});
+ document.getElementById("clear-btn").addEventListener("click", async(e) => {
+ e.target.classList.add("is-loading");
+ e.preventDefault();
+ await chrome.storage.local.set({"words":[]})
+ window.location.reload();
+ });
})();