generated from MuiseDestiny/zotero-addon-template
-
Notifications
You must be signed in to change notification settings - Fork 103
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9c8ecaa
commit 897e560
Showing
4 changed files
with
245 additions
and
121 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import Requests from "./requests"; | ||
|
||
const utils = { | ||
requests: new Requests(), | ||
wait(item: Zotero.Item, key: string) { | ||
switch (key) { | ||
case "publication": | ||
const publicationTitle = item.getField("publicationTitle") | ||
if (publicationTitle == "") { return } | ||
const data = ztoolkit.ExtraField.getExtraField(item, key) | ||
if (data) { return JSON.parse(data) } | ||
// 开启一个异步更新影响因子 | ||
window.setTimeout(async () => { | ||
const response = await this.requests.post( | ||
"https://easyscholar.cc/homeController/getQueryTable.ajax", | ||
{ | ||
page: "1", | ||
limit: "1", | ||
sourceName: publicationTitle | ||
} | ||
) | ||
if (response && response.data) { | ||
let data = response.data[0] | ||
if (data) { | ||
ztoolkit.ExtraField.setExtraField(item, key, JSON.stringify(data)) | ||
} | ||
} | ||
}) | ||
return | ||
default: | ||
break | ||
} | ||
|
||
} | ||
} | ||
|
||
export default utils |
Oops, something went wrong.