javdict 1.3.1 → 1.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/ci.yml +35 -0
- package/.github/workflows/release.yml +46 -0
- package/LICENSE +21 -21
- package/index.js +93 -93
- package/lib/cache.js +81 -81
- package/lib/display.js +61 -61
- package/lib/fetcher.js +366 -366
- package/lib/i18n.js +175 -175
- package/package.json +30 -30
- package/test/cache.test.js +81 -81
- package/test/display.test.js +54 -54
- package/test/fetcher.test.js +102 -102
package/lib/i18n.js
CHANGED
|
@@ -1,176 +1,176 @@
|
|
|
1
|
-
export const messages = {
|
|
2
|
-
zh: {
|
|
3
|
-
actress: '女优',
|
|
4
|
-
actor: '男优',
|
|
5
|
-
releaseDate: '发售日期',
|
|
6
|
-
duration: '时长',
|
|
7
|
-
studio: '制作商',
|
|
8
|
-
label: '发行商',
|
|
9
|
-
director: '导演',
|
|
10
|
-
series: '系列',
|
|
11
|
-
rating: '评分',
|
|
12
|
-
wishlist: '想看',
|
|
13
|
-
tags: '类别',
|
|
14
|
-
cover: '封面',
|
|
15
|
-
source: '数据来源',
|
|
16
|
-
searching: '正在查询',
|
|
17
|
-
notFound: '未找到番号',
|
|
18
|
-
queryFailed: '查询失败',
|
|
19
|
-
cacheCleared: '缓存已清空',
|
|
20
|
-
cacheClearFailed: '清空缓存失败',
|
|
21
|
-
cachePath: '缓存路径',
|
|
22
|
-
fc2Detected: '识别为FC2格式的车牌号',
|
|
23
|
-
windowsHint: '温馨提示: 此番号需要JAVDB数据源,Windows暂不支持~',
|
|
24
|
-
setupTitle: '配置 JAVDB Cookie(可选)',
|
|
25
|
-
setupDesc: '不配置也可以正常使用,配置后覆盖率更高。',
|
|
26
|
-
setupSteps: '获取步骤:',
|
|
27
|
-
setupStep1: 'Chrome 打开 https://javdb.com 并登录账号',
|
|
28
|
-
setupStep2: '安装插件 "Get cookies.txt LOCALLY"',
|
|
29
|
-
setupStep3: '导出 Cookie 文件,找到 _jdb_session 那行',
|
|
30
|
-
setupStep4: '复制最后一列的值粘贴到下面',
|
|
31
|
-
setupPrompt: '请粘贴 _jdb_session 的值(直接回车跳过): ',
|
|
32
|
-
setupSkipped: '已跳过,使用 JAVBUS + JavLibrary 作为数据源。',
|
|
33
|
-
setupSuccess: '配置保存成功!',
|
|
34
|
-
setupSavePath: '保存位置: ~/.config/javinfo/config.json',
|
|
35
|
-
},
|
|
36
|
-
en: {
|
|
37
|
-
actress: 'Actress',
|
|
38
|
-
actor: 'Actor',
|
|
39
|
-
releaseDate: 'Released',
|
|
40
|
-
duration: 'Duration',
|
|
41
|
-
studio: 'Studio',
|
|
42
|
-
label: 'Label',
|
|
43
|
-
director: 'Director',
|
|
44
|
-
series: 'Series',
|
|
45
|
-
rating: 'Rating',
|
|
46
|
-
wishlist: 'Wishlist',
|
|
47
|
-
tags: 'Tags',
|
|
48
|
-
cover: 'Cover',
|
|
49
|
-
source: 'Source',
|
|
50
|
-
searching: 'Searching',
|
|
51
|
-
notFound: 'Title not found',
|
|
52
|
-
queryFailed: 'Query failed',
|
|
53
|
-
cacheCleared: 'Cache cleared',
|
|
54
|
-
cacheClearFailed: 'Failed to clear cache',
|
|
55
|
-
cachePath: 'Cache path',
|
|
56
|
-
fc2Detected: 'FC2 format detected',
|
|
57
|
-
windowsHint: 'Note: This title requires JAVDB, which is unavailable on Windows.',
|
|
58
|
-
setupTitle: 'Setup JAVDB Cookie (Optional)',
|
|
59
|
-
setupDesc: 'You can use without configuration, but adding it improves coverage.',
|
|
60
|
-
setupSteps: 'Steps to get cookie:',
|
|
61
|
-
setupStep1: 'Open https://javdb.com in Chrome and log in',
|
|
62
|
-
setupStep2: 'Install extension "Get cookies.txt LOCALLY"',
|
|
63
|
-
setupStep3: 'Export cookies and find the _jdb_session line',
|
|
64
|
-
setupStep4: 'Copy the last column value and paste below',
|
|
65
|
-
setupPrompt: 'Paste the value of _jdb_session (press Enter to skip): ',
|
|
66
|
-
setupSkipped: 'Skipped. Using JAVBUS + JavLibrary as data sources.',
|
|
67
|
-
setupSuccess: 'Configuration saved successfully!',
|
|
68
|
-
setupSavePath: 'Saved to: ~/.config/javinfo/config.json',
|
|
69
|
-
},
|
|
70
|
-
jp: {
|
|
71
|
-
actress: '女優',
|
|
72
|
-
actor: '男優',
|
|
73
|
-
releaseDate: '発売日',
|
|
74
|
-
duration: '時間',
|
|
75
|
-
studio: 'メーカー',
|
|
76
|
-
label: 'レーベル',
|
|
77
|
-
director: '監督',
|
|
78
|
-
series: 'シリーズ',
|
|
79
|
-
rating: '評価',
|
|
80
|
-
wishlist: '観たい',
|
|
81
|
-
tags: 'カテゴリ',
|
|
82
|
-
cover: 'カバー',
|
|
83
|
-
source: 'データソース',
|
|
84
|
-
searching: '検索中',
|
|
85
|
-
notFound: '番号が見つかりません',
|
|
86
|
-
queryFailed: '検索失敗',
|
|
87
|
-
cacheCleared: 'キャッシュを削除しました',
|
|
88
|
-
cacheClearFailed: 'キャッシュの削除に失敗しました',
|
|
89
|
-
cachePath: 'キャッシュパス',
|
|
90
|
-
fc2Detected: 'FC2番号を検出しました',
|
|
91
|
-
windowsHint: '注意: この番号はJAVDBが必要ですが、WindowsではJAVDBが利用できません。',
|
|
92
|
-
setupTitle: 'JAVDB Cookieの設定(オプション)',
|
|
93
|
-
setupDesc: '設定しなくても使用できますが、設定すると検索範囲が広がります。',
|
|
94
|
-
setupSteps: '取得手順:',
|
|
95
|
-
setupStep1: 'Chromeで https://javdb.com を開いてログイン',
|
|
96
|
-
setupStep2: '拡張機能 "Get cookies.txt LOCALLY" をインストール',
|
|
97
|
-
setupStep3: 'Cookieをエクスポートし、_jdb_session の行を探す',
|
|
98
|
-
setupStep4: '最後の列の値をコピーして以下に貼り付け',
|
|
99
|
-
setupPrompt: '_jdb_session の値を貼り付けてください(Enterでスキップ): ',
|
|
100
|
-
setupSkipped: 'スキップしました。JAVBUS + JavLibrary をデータソースとして使用します。',
|
|
101
|
-
setupSuccess: '設定を保存しました!',
|
|
102
|
-
setupSavePath: '保存場所: ~/.config/javinfo/config.json',
|
|
103
|
-
},
|
|
104
|
-
kr: {
|
|
105
|
-
actress: '여배우',
|
|
106
|
-
actor: '남배우',
|
|
107
|
-
releaseDate: '발매일',
|
|
108
|
-
duration: '시간',
|
|
109
|
-
studio: '제작사',
|
|
110
|
-
label: '레이블',
|
|
111
|
-
director: '감독',
|
|
112
|
-
series: '시리즈',
|
|
113
|
-
rating: '평점',
|
|
114
|
-
wishlist: '보고싶어요',
|
|
115
|
-
tags: '카테고리',
|
|
116
|
-
cover: '커버',
|
|
117
|
-
source: '데이터 출처',
|
|
118
|
-
searching: '검색 중',
|
|
119
|
-
notFound: '번호를 찾을 수 없습니다',
|
|
120
|
-
queryFailed: '검색 실패',
|
|
121
|
-
cacheCleared: '캐시가 삭제되었습니다',
|
|
122
|
-
cacheClearFailed: '캐시 삭제 실패',
|
|
123
|
-
cachePath: '캐시 경로',
|
|
124
|
-
fc2Detected: 'FC2 형식 감지됨',
|
|
125
|
-
windowsHint: '알림: 이 번호는 JAVDB가 필요하지만 Windows에서는 사용할 수 없습니다.',
|
|
126
|
-
setupTitle: 'JAVDB Cookie 설정 (선택사항)',
|
|
127
|
-
setupDesc: '설정하지 않아도 사용할 수 있지만, 설정하면 검색 범위가 넓어집니다.',
|
|
128
|
-
setupSteps: '획득 단계:',
|
|
129
|
-
setupStep1: 'Chrome에서 https://javdb.com 을 열고 로그인',
|
|
130
|
-
setupStep2: '확장 프로그램 "Get cookies.txt LOCALLY" 설치',
|
|
131
|
-
setupStep3: '쿠키를 내보내고 _jdb_session 줄을 찾기',
|
|
132
|
-
setupStep4: '마지막 열의 값을 복사하여 아래에 붙여넣기',
|
|
133
|
-
setupPrompt: '_jdb_session 값을 붙여넣어주세요 (Enter로 건너뛰기): ',
|
|
134
|
-
setupSkipped: '건너뛰었습니다. JAVBUS + JavLibrary를 데이터 소스로 사용합니다.',
|
|
135
|
-
setupSuccess: '설정이 성공적으로 저장되었습니다!',
|
|
136
|
-
setupSavePath: '저장 위치: ~/.config/javinfo/config.json',
|
|
137
|
-
},
|
|
138
|
-
de: {
|
|
139
|
-
actress: 'Darstellerin',
|
|
140
|
-
actor: 'Darsteller',
|
|
141
|
-
releaseDate: 'Erscheinungsdatum',
|
|
142
|
-
duration: 'Laufzeit',
|
|
143
|
-
studio: 'Studio',
|
|
144
|
-
label: 'Label',
|
|
145
|
-
director: 'Regisseur',
|
|
146
|
-
series: 'Serie',
|
|
147
|
-
rating: 'Bewertung',
|
|
148
|
-
wishlist: 'Merkliste',
|
|
149
|
-
tags: 'Kategorien',
|
|
150
|
-
cover: 'Cover',
|
|
151
|
-
source: 'Datenquelle',
|
|
152
|
-
searching: 'Suche läuft',
|
|
153
|
-
notFound: 'Titel nicht gefunden',
|
|
154
|
-
queryFailed: 'Suche fehlgeschlagen',
|
|
155
|
-
cacheCleared: 'Cache geleert',
|
|
156
|
-
cacheClearFailed: 'Cache konnte nicht geleert werden',
|
|
157
|
-
cachePath: 'Cache-Pfad',
|
|
158
|
-
fc2Detected: 'FC2-Format erkannt',
|
|
159
|
-
windowsHint: 'Hinweis: Dieser Titel benötigt JAVDB, das unter Windows nicht verfügbar ist.',
|
|
160
|
-
setupTitle: 'JAVDB Cookie einrichten (optional)',
|
|
161
|
-
setupDesc: 'Ohne Konfiguration funktioniert es auch, aber mit Cookie ist die Abdeckung besser.',
|
|
162
|
-
setupSteps: 'Schritte zum Abrufen:',
|
|
163
|
-
setupStep1: 'Chrome öffnen, https://javdb.com aufrufen und anmelden',
|
|
164
|
-
setupStep2: 'Erweiterung "Get cookies.txt LOCALLY" installieren',
|
|
165
|
-
setupStep3: 'Cookies exportieren und die _jdb_session Zeile finden',
|
|
166
|
-
setupStep4: 'Den Wert der letzten Spalte kopieren und unten einfügen',
|
|
167
|
-
setupPrompt: 'Wert von _jdb_session einfügen (Enter zum Überspringen): ',
|
|
168
|
-
setupSkipped: 'Übersprungen. JAVBUS + JavLibrary werden als Datenquellen verwendet.',
|
|
169
|
-
setupSuccess: 'Konfiguration erfolgreich gespeichert!',
|
|
170
|
-
setupSavePath: 'Gespeichert unter: ~/.config/javinfo/config.json',
|
|
171
|
-
},
|
|
172
|
-
};
|
|
173
|
-
|
|
174
|
-
export function getLang(lang) {
|
|
175
|
-
return messages[lang] || messages.zh; // 默认中文
|
|
1
|
+
export const messages = {
|
|
2
|
+
zh: {
|
|
3
|
+
actress: '女优',
|
|
4
|
+
actor: '男优',
|
|
5
|
+
releaseDate: '发售日期',
|
|
6
|
+
duration: '时长',
|
|
7
|
+
studio: '制作商',
|
|
8
|
+
label: '发行商',
|
|
9
|
+
director: '导演',
|
|
10
|
+
series: '系列',
|
|
11
|
+
rating: '评分',
|
|
12
|
+
wishlist: '想看',
|
|
13
|
+
tags: '类别',
|
|
14
|
+
cover: '封面',
|
|
15
|
+
source: '数据来源',
|
|
16
|
+
searching: '正在查询',
|
|
17
|
+
notFound: '未找到番号',
|
|
18
|
+
queryFailed: '查询失败',
|
|
19
|
+
cacheCleared: '缓存已清空',
|
|
20
|
+
cacheClearFailed: '清空缓存失败',
|
|
21
|
+
cachePath: '缓存路径',
|
|
22
|
+
fc2Detected: '识别为FC2格式的车牌号',
|
|
23
|
+
windowsHint: '温馨提示: 此番号需要JAVDB数据源,Windows暂不支持~',
|
|
24
|
+
setupTitle: '配置 JAVDB Cookie(可选)',
|
|
25
|
+
setupDesc: '不配置也可以正常使用,配置后覆盖率更高。',
|
|
26
|
+
setupSteps: '获取步骤:',
|
|
27
|
+
setupStep1: 'Chrome 打开 https://javdb.com 并登录账号',
|
|
28
|
+
setupStep2: '安装插件 "Get cookies.txt LOCALLY"',
|
|
29
|
+
setupStep3: '导出 Cookie 文件,找到 _jdb_session 那行',
|
|
30
|
+
setupStep4: '复制最后一列的值粘贴到下面',
|
|
31
|
+
setupPrompt: '请粘贴 _jdb_session 的值(直接回车跳过): ',
|
|
32
|
+
setupSkipped: '已跳过,使用 JAVBUS + JavLibrary 作为数据源。',
|
|
33
|
+
setupSuccess: '配置保存成功!',
|
|
34
|
+
setupSavePath: '保存位置: ~/.config/javinfo/config.json',
|
|
35
|
+
},
|
|
36
|
+
en: {
|
|
37
|
+
actress: 'Actress',
|
|
38
|
+
actor: 'Actor',
|
|
39
|
+
releaseDate: 'Released',
|
|
40
|
+
duration: 'Duration',
|
|
41
|
+
studio: 'Studio',
|
|
42
|
+
label: 'Label',
|
|
43
|
+
director: 'Director',
|
|
44
|
+
series: 'Series',
|
|
45
|
+
rating: 'Rating',
|
|
46
|
+
wishlist: 'Wishlist',
|
|
47
|
+
tags: 'Tags',
|
|
48
|
+
cover: 'Cover',
|
|
49
|
+
source: 'Source',
|
|
50
|
+
searching: 'Searching',
|
|
51
|
+
notFound: 'Title not found',
|
|
52
|
+
queryFailed: 'Query failed',
|
|
53
|
+
cacheCleared: 'Cache cleared',
|
|
54
|
+
cacheClearFailed: 'Failed to clear cache',
|
|
55
|
+
cachePath: 'Cache path',
|
|
56
|
+
fc2Detected: 'FC2 format detected',
|
|
57
|
+
windowsHint: 'Note: This title requires JAVDB, which is unavailable on Windows.',
|
|
58
|
+
setupTitle: 'Setup JAVDB Cookie (Optional)',
|
|
59
|
+
setupDesc: 'You can use without configuration, but adding it improves coverage.',
|
|
60
|
+
setupSteps: 'Steps to get cookie:',
|
|
61
|
+
setupStep1: 'Open https://javdb.com in Chrome and log in',
|
|
62
|
+
setupStep2: 'Install extension "Get cookies.txt LOCALLY"',
|
|
63
|
+
setupStep3: 'Export cookies and find the _jdb_session line',
|
|
64
|
+
setupStep4: 'Copy the last column value and paste below',
|
|
65
|
+
setupPrompt: 'Paste the value of _jdb_session (press Enter to skip): ',
|
|
66
|
+
setupSkipped: 'Skipped. Using JAVBUS + JavLibrary as data sources.',
|
|
67
|
+
setupSuccess: 'Configuration saved successfully!',
|
|
68
|
+
setupSavePath: 'Saved to: ~/.config/javinfo/config.json',
|
|
69
|
+
},
|
|
70
|
+
jp: {
|
|
71
|
+
actress: '女優',
|
|
72
|
+
actor: '男優',
|
|
73
|
+
releaseDate: '発売日',
|
|
74
|
+
duration: '時間',
|
|
75
|
+
studio: 'メーカー',
|
|
76
|
+
label: 'レーベル',
|
|
77
|
+
director: '監督',
|
|
78
|
+
series: 'シリーズ',
|
|
79
|
+
rating: '評価',
|
|
80
|
+
wishlist: '観たい',
|
|
81
|
+
tags: 'カテゴリ',
|
|
82
|
+
cover: 'カバー',
|
|
83
|
+
source: 'データソース',
|
|
84
|
+
searching: '検索中',
|
|
85
|
+
notFound: '番号が見つかりません',
|
|
86
|
+
queryFailed: '検索失敗',
|
|
87
|
+
cacheCleared: 'キャッシュを削除しました',
|
|
88
|
+
cacheClearFailed: 'キャッシュの削除に失敗しました',
|
|
89
|
+
cachePath: 'キャッシュパス',
|
|
90
|
+
fc2Detected: 'FC2番号を検出しました',
|
|
91
|
+
windowsHint: '注意: この番号はJAVDBが必要ですが、WindowsではJAVDBが利用できません。',
|
|
92
|
+
setupTitle: 'JAVDB Cookieの設定(オプション)',
|
|
93
|
+
setupDesc: '設定しなくても使用できますが、設定すると検索範囲が広がります。',
|
|
94
|
+
setupSteps: '取得手順:',
|
|
95
|
+
setupStep1: 'Chromeで https://javdb.com を開いてログイン',
|
|
96
|
+
setupStep2: '拡張機能 "Get cookies.txt LOCALLY" をインストール',
|
|
97
|
+
setupStep3: 'Cookieをエクスポートし、_jdb_session の行を探す',
|
|
98
|
+
setupStep4: '最後の列の値をコピーして以下に貼り付け',
|
|
99
|
+
setupPrompt: '_jdb_session の値を貼り付けてください(Enterでスキップ): ',
|
|
100
|
+
setupSkipped: 'スキップしました。JAVBUS + JavLibrary をデータソースとして使用します。',
|
|
101
|
+
setupSuccess: '設定を保存しました!',
|
|
102
|
+
setupSavePath: '保存場所: ~/.config/javinfo/config.json',
|
|
103
|
+
},
|
|
104
|
+
kr: {
|
|
105
|
+
actress: '여배우',
|
|
106
|
+
actor: '남배우',
|
|
107
|
+
releaseDate: '발매일',
|
|
108
|
+
duration: '시간',
|
|
109
|
+
studio: '제작사',
|
|
110
|
+
label: '레이블',
|
|
111
|
+
director: '감독',
|
|
112
|
+
series: '시리즈',
|
|
113
|
+
rating: '평점',
|
|
114
|
+
wishlist: '보고싶어요',
|
|
115
|
+
tags: '카테고리',
|
|
116
|
+
cover: '커버',
|
|
117
|
+
source: '데이터 출처',
|
|
118
|
+
searching: '검색 중',
|
|
119
|
+
notFound: '번호를 찾을 수 없습니다',
|
|
120
|
+
queryFailed: '검색 실패',
|
|
121
|
+
cacheCleared: '캐시가 삭제되었습니다',
|
|
122
|
+
cacheClearFailed: '캐시 삭제 실패',
|
|
123
|
+
cachePath: '캐시 경로',
|
|
124
|
+
fc2Detected: 'FC2 형식 감지됨',
|
|
125
|
+
windowsHint: '알림: 이 번호는 JAVDB가 필요하지만 Windows에서는 사용할 수 없습니다.',
|
|
126
|
+
setupTitle: 'JAVDB Cookie 설정 (선택사항)',
|
|
127
|
+
setupDesc: '설정하지 않아도 사용할 수 있지만, 설정하면 검색 범위가 넓어집니다.',
|
|
128
|
+
setupSteps: '획득 단계:',
|
|
129
|
+
setupStep1: 'Chrome에서 https://javdb.com 을 열고 로그인',
|
|
130
|
+
setupStep2: '확장 프로그램 "Get cookies.txt LOCALLY" 설치',
|
|
131
|
+
setupStep3: '쿠키를 내보내고 _jdb_session 줄을 찾기',
|
|
132
|
+
setupStep4: '마지막 열의 값을 복사하여 아래에 붙여넣기',
|
|
133
|
+
setupPrompt: '_jdb_session 값을 붙여넣어주세요 (Enter로 건너뛰기): ',
|
|
134
|
+
setupSkipped: '건너뛰었습니다. JAVBUS + JavLibrary를 데이터 소스로 사용합니다.',
|
|
135
|
+
setupSuccess: '설정이 성공적으로 저장되었습니다!',
|
|
136
|
+
setupSavePath: '저장 위치: ~/.config/javinfo/config.json',
|
|
137
|
+
},
|
|
138
|
+
de: {
|
|
139
|
+
actress: 'Darstellerin',
|
|
140
|
+
actor: 'Darsteller',
|
|
141
|
+
releaseDate: 'Erscheinungsdatum',
|
|
142
|
+
duration: 'Laufzeit',
|
|
143
|
+
studio: 'Studio',
|
|
144
|
+
label: 'Label',
|
|
145
|
+
director: 'Regisseur',
|
|
146
|
+
series: 'Serie',
|
|
147
|
+
rating: 'Bewertung',
|
|
148
|
+
wishlist: 'Merkliste',
|
|
149
|
+
tags: 'Kategorien',
|
|
150
|
+
cover: 'Cover',
|
|
151
|
+
source: 'Datenquelle',
|
|
152
|
+
searching: 'Suche läuft',
|
|
153
|
+
notFound: 'Titel nicht gefunden',
|
|
154
|
+
queryFailed: 'Suche fehlgeschlagen',
|
|
155
|
+
cacheCleared: 'Cache geleert',
|
|
156
|
+
cacheClearFailed: 'Cache konnte nicht geleert werden',
|
|
157
|
+
cachePath: 'Cache-Pfad',
|
|
158
|
+
fc2Detected: 'FC2-Format erkannt',
|
|
159
|
+
windowsHint: 'Hinweis: Dieser Titel benötigt JAVDB, das unter Windows nicht verfügbar ist.',
|
|
160
|
+
setupTitle: 'JAVDB Cookie einrichten (optional)',
|
|
161
|
+
setupDesc: 'Ohne Konfiguration funktioniert es auch, aber mit Cookie ist die Abdeckung besser.',
|
|
162
|
+
setupSteps: 'Schritte zum Abrufen:',
|
|
163
|
+
setupStep1: 'Chrome öffnen, https://javdb.com aufrufen und anmelden',
|
|
164
|
+
setupStep2: 'Erweiterung "Get cookies.txt LOCALLY" installieren',
|
|
165
|
+
setupStep3: 'Cookies exportieren und die _jdb_session Zeile finden',
|
|
166
|
+
setupStep4: 'Den Wert der letzten Spalte kopieren und unten einfügen',
|
|
167
|
+
setupPrompt: 'Wert von _jdb_session einfügen (Enter zum Überspringen): ',
|
|
168
|
+
setupSkipped: 'Übersprungen. JAVBUS + JavLibrary werden als Datenquellen verwendet.',
|
|
169
|
+
setupSuccess: 'Konfiguration erfolgreich gespeichert!',
|
|
170
|
+
setupSavePath: 'Gespeichert unter: ~/.config/javinfo/config.json',
|
|
171
|
+
},
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
export function getLang(lang) {
|
|
175
|
+
return messages[lang] || messages.zh; // 默认中文
|
|
176
176
|
}
|
package/package.json
CHANGED
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "javdict",
|
|
3
|
-
"version": "1.3.
|
|
4
|
-
"description": "AV番号命令行查询工具",
|
|
5
|
-
"main": "./index.js",
|
|
6
|
-
"type": "module",
|
|
7
|
-
"scripts": {
|
|
8
|
-
"start": "node index.js",
|
|
9
|
-
"test": "vitest run",
|
|
10
|
-
"test:watch": "vitest",
|
|
11
|
-
"test:coverage": "vitest run --coverage"
|
|
12
|
-
},
|
|
13
|
-
"bin": {
|
|
14
|
-
"jav": "./index.js"
|
|
15
|
-
},
|
|
16
|
-
"dependencies": {
|
|
17
|
-
"axios": "^1.6.0",
|
|
18
|
-
"chalk": "^5.3.0",
|
|
19
|
-
"cheerio": "^1.0.0",
|
|
20
|
-
"commander": "^12.0.0",
|
|
21
|
-
"ora": "^8.0.1"
|
|
22
|
-
},
|
|
23
|
-
"devDependencies": {
|
|
24
|
-
"@vitest/coverage-v8": "^1.0.0",
|
|
25
|
-
"vitest": "^1.0.0"
|
|
26
|
-
},
|
|
27
|
-
"engines": {
|
|
28
|
-
"node": ">=18.0.0"
|
|
29
|
-
},
|
|
30
|
-
"license": "MIT"
|
|
1
|
+
{
|
|
2
|
+
"name": "javdict",
|
|
3
|
+
"version": "1.3.2",
|
|
4
|
+
"description": "AV番号命令行查询工具",
|
|
5
|
+
"main": "./index.js",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"start": "node index.js",
|
|
9
|
+
"test": "vitest run",
|
|
10
|
+
"test:watch": "vitest",
|
|
11
|
+
"test:coverage": "vitest run --coverage"
|
|
12
|
+
},
|
|
13
|
+
"bin": {
|
|
14
|
+
"jav": "./index.js"
|
|
15
|
+
},
|
|
16
|
+
"dependencies": {
|
|
17
|
+
"axios": "^1.6.0",
|
|
18
|
+
"chalk": "^5.3.0",
|
|
19
|
+
"cheerio": "^1.0.0",
|
|
20
|
+
"commander": "^12.0.0",
|
|
21
|
+
"ora": "^8.0.1"
|
|
22
|
+
},
|
|
23
|
+
"devDependencies": {
|
|
24
|
+
"@vitest/coverage-v8": "^1.0.0",
|
|
25
|
+
"vitest": "^1.0.0"
|
|
26
|
+
},
|
|
27
|
+
"engines": {
|
|
28
|
+
"node": ">=18.0.0"
|
|
29
|
+
},
|
|
30
|
+
"license": "MIT"
|
|
31
31
|
}
|
package/test/cache.test.js
CHANGED
|
@@ -1,82 +1,82 @@
|
|
|
1
|
-
import { describe, it, expect, beforeEach, afterEach } from 'vitest';
|
|
2
|
-
import { existsSync, rmSync, mkdirSync } from 'fs';
|
|
3
|
-
import { join } from 'path';
|
|
4
|
-
import { homedir } from 'os';
|
|
5
|
-
|
|
6
|
-
// 每次测试前后清理真实缓存文件,避免污染
|
|
7
|
-
const CACHE_FILE = join(homedir(), '.config', 'javinfo', 'cache.json');
|
|
8
|
-
|
|
9
|
-
// 动态 import 保证每次拿到最新模块
|
|
10
|
-
async function importCache() {
|
|
11
|
-
return await import('../lib/cache.js');
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
describe('cache.js', () => {
|
|
15
|
-
beforeEach(() => {
|
|
16
|
-
// 清空缓存文件,保证每个测试独立
|
|
17
|
-
if (existsSync(CACHE_FILE)) {
|
|
18
|
-
rmSync(CACHE_FILE);
|
|
19
|
-
}
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
afterEach(() => {
|
|
23
|
-
if (existsSync(CACHE_FILE)) {
|
|
24
|
-
rmSync(CACHE_FILE);
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
it('getCache:缓存不存在时返回 null', async () => {
|
|
29
|
-
const { getCache } = await importCache();
|
|
30
|
-
const result = getCache('SSIS-001');
|
|
31
|
-
expect(result).toBeNull();
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
it('setCache + getCache:写入后能正确读取', async () => {
|
|
35
|
-
const { getCache, setCache } = await importCache();
|
|
36
|
-
const mockData = { id: 'SSIS-001', title: '测试标题', actresses: ['女优A'] };
|
|
37
|
-
|
|
38
|
-
setCache('SSIS-001', mockData);
|
|
39
|
-
const result = getCache('SSIS-001');
|
|
40
|
-
|
|
41
|
-
expect(result).toEqual(mockData);
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
it('getCache:缓存过期后返回 null', async () => {
|
|
45
|
-
const { getCache, setCache } = await importCache();
|
|
46
|
-
const mockData = { id: 'ABW-001', title: '过期测试' };
|
|
47
|
-
|
|
48
|
-
setCache('ABW-001', mockData);
|
|
49
|
-
|
|
50
|
-
// 手动篡改缓存时间为 8 天前,模拟过期
|
|
51
|
-
const { readFileSync, writeFileSync } = await import('fs');
|
|
52
|
-
const raw = JSON.parse(readFileSync(CACHE_FILE, 'utf-8'));
|
|
53
|
-
raw['ABW-001'].cachedAt = Date.now() - 8 * 24 * 60 * 60 * 1000;
|
|
54
|
-
writeFileSync(CACHE_FILE, JSON.stringify(raw), 'utf-8');
|
|
55
|
-
|
|
56
|
-
const result = getCache('ABW-001');
|
|
57
|
-
expect(result).toBeNull();
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
it('setCache:不同番号互不干扰', async () => {
|
|
61
|
-
const { getCache, setCache } = await importCache();
|
|
62
|
-
const dataA = { id: 'SSIS-001', title: 'A' };
|
|
63
|
-
const dataB = { id: 'IPX-001', title: 'B' };
|
|
64
|
-
|
|
65
|
-
setCache('SSIS-001', dataA);
|
|
66
|
-
setCache('IPX-001', dataB);
|
|
67
|
-
|
|
68
|
-
expect(getCache('SSIS-001')).toEqual(dataA);
|
|
69
|
-
expect(getCache('IPX-001')).toEqual(dataB);
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
it('clearCache:清空后所有缓存消失', async () => {
|
|
73
|
-
const { getCache, setCache, clearCache } = await importCache();
|
|
74
|
-
setCache('SSIS-001', { id: 'SSIS-001' });
|
|
75
|
-
setCache('IPX-001', { id: 'IPX-001' });
|
|
76
|
-
|
|
77
|
-
clearCache();
|
|
78
|
-
|
|
79
|
-
expect(getCache('SSIS-001')).toBeNull();
|
|
80
|
-
expect(getCache('IPX-001')).toBeNull();
|
|
81
|
-
});
|
|
1
|
+
import { describe, it, expect, beforeEach, afterEach } from 'vitest';
|
|
2
|
+
import { existsSync, rmSync, mkdirSync } from 'fs';
|
|
3
|
+
import { join } from 'path';
|
|
4
|
+
import { homedir } from 'os';
|
|
5
|
+
|
|
6
|
+
// 每次测试前后清理真实缓存文件,避免污染
|
|
7
|
+
const CACHE_FILE = join(homedir(), '.config', 'javinfo', 'cache.json');
|
|
8
|
+
|
|
9
|
+
// 动态 import 保证每次拿到最新模块
|
|
10
|
+
async function importCache() {
|
|
11
|
+
return await import('../lib/cache.js');
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
describe('cache.js', () => {
|
|
15
|
+
beforeEach(() => {
|
|
16
|
+
// 清空缓存文件,保证每个测试独立
|
|
17
|
+
if (existsSync(CACHE_FILE)) {
|
|
18
|
+
rmSync(CACHE_FILE);
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
afterEach(() => {
|
|
23
|
+
if (existsSync(CACHE_FILE)) {
|
|
24
|
+
rmSync(CACHE_FILE);
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it('getCache:缓存不存在时返回 null', async () => {
|
|
29
|
+
const { getCache } = await importCache();
|
|
30
|
+
const result = getCache('SSIS-001');
|
|
31
|
+
expect(result).toBeNull();
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it('setCache + getCache:写入后能正确读取', async () => {
|
|
35
|
+
const { getCache, setCache } = await importCache();
|
|
36
|
+
const mockData = { id: 'SSIS-001', title: '测试标题', actresses: ['女优A'] };
|
|
37
|
+
|
|
38
|
+
setCache('SSIS-001', mockData);
|
|
39
|
+
const result = getCache('SSIS-001');
|
|
40
|
+
|
|
41
|
+
expect(result).toEqual(mockData);
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it('getCache:缓存过期后返回 null', async () => {
|
|
45
|
+
const { getCache, setCache } = await importCache();
|
|
46
|
+
const mockData = { id: 'ABW-001', title: '过期测试' };
|
|
47
|
+
|
|
48
|
+
setCache('ABW-001', mockData);
|
|
49
|
+
|
|
50
|
+
// 手动篡改缓存时间为 8 天前,模拟过期
|
|
51
|
+
const { readFileSync, writeFileSync } = await import('fs');
|
|
52
|
+
const raw = JSON.parse(readFileSync(CACHE_FILE, 'utf-8'));
|
|
53
|
+
raw['ABW-001'].cachedAt = Date.now() - 8 * 24 * 60 * 60 * 1000;
|
|
54
|
+
writeFileSync(CACHE_FILE, JSON.stringify(raw), 'utf-8');
|
|
55
|
+
|
|
56
|
+
const result = getCache('ABW-001');
|
|
57
|
+
expect(result).toBeNull();
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
it('setCache:不同番号互不干扰', async () => {
|
|
61
|
+
const { getCache, setCache } = await importCache();
|
|
62
|
+
const dataA = { id: 'SSIS-001', title: 'A' };
|
|
63
|
+
const dataB = { id: 'IPX-001', title: 'B' };
|
|
64
|
+
|
|
65
|
+
setCache('SSIS-001', dataA);
|
|
66
|
+
setCache('IPX-001', dataB);
|
|
67
|
+
|
|
68
|
+
expect(getCache('SSIS-001')).toEqual(dataA);
|
|
69
|
+
expect(getCache('IPX-001')).toEqual(dataB);
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
it('clearCache:清空后所有缓存消失', async () => {
|
|
73
|
+
const { getCache, setCache, clearCache } = await importCache();
|
|
74
|
+
setCache('SSIS-001', { id: 'SSIS-001' });
|
|
75
|
+
setCache('IPX-001', { id: 'IPX-001' });
|
|
76
|
+
|
|
77
|
+
clearCache();
|
|
78
|
+
|
|
79
|
+
expect(getCache('SSIS-001')).toBeNull();
|
|
80
|
+
expect(getCache('IPX-001')).toBeNull();
|
|
81
|
+
});
|
|
82
82
|
});
|