Skip to content

Commit

Permalink
fix: 拖拽规则导入
Browse files Browse the repository at this point in the history
  • Loading branch information
aooiuu committed Jun 4, 2024
1 parent 008f0ed commit 1cbd431
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion packages/vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"displayName": "any-reader",
"description": "摸鱼,自定义规则多站点聚合搜索阅读小说、漫画。包含JS规则解析库和VSCode插件。支持本地小说 TXT、EPUB",
"icon": "resources/icon.png",
"version": "1.5.1",
"version": "1.5.2",
"publisher": "aooiu",
"qna": "https://github.com/aooiuu/any-reader/issues",
"bugs": {
Expand Down
2 changes: 1 addition & 1 deletion packages/web/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "any-reader-web",
"version": "1.0.0-dev.15",
"version": "1.0.0-dev.16",
"private": true,
"scripts": {
"dev": "cross-env VITE_APP_PLATFORM=browser vite",
Expand Down
8 changes: 6 additions & 2 deletions packages/web/src/hooks/useDropRules.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createRule } from '@/api';
import { createRule, importRules } from '@/api';
import { readFile } from '@/utils/file';
import { isRule } from '@/utils/rule';
import { useRulesStore } from '@/stores/rules';
Expand All @@ -22,7 +22,11 @@ export function useDropRules(cb: { ({ count }: { count: any }): void; (arg0: { c
const rules = await readFile(file);
for (const rule of rules) {
if (isRule(rule)) {
await createRule(rule);
if (typeof rule === 'string') {
await importRules({ url: rule });
} else {
await createRule(rule);
}
count++;
}
}
Expand Down

0 comments on commit 1cbd431

Please sign in to comment.