Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion plugins/jet-plugin/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@

node_modules
package-lock.json
.codebuddy
.codebuddy
# 源仓库中已跟踪不受影响;publish 复制到 fork 后,git add 据此排除,避免内部协作指引进入插件中心 PR
AGENTS.md
6 changes: 6 additions & 0 deletions plugins/jet-plugin/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## 1.2.3 - 2026-12-02

### 优化

- IDE 扫描缓存过期后不再同步全量扫描阻塞列表首屏:改为先用旧缓存立即渲染、后台刷新供下次使用(stale-while-revalidate)。Windows 注册表兜底扫描可达秒级,此前过期后首次进入会明显等待;新装 IDE 最晚下次进入时出现

## 1.2.2 - 2026-09-18

### 修复
Expand Down
2 changes: 1 addition & 1 deletion plugins/jet-plugin/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jet-plugin",
"version": "1.2.2",
"version": "1.2.3",
"description": "扫描本机已安装的 JetBrains IDE,聚合各 IDE 最近打开的项目,支持模糊搜索与一键启动",
"author": "zl",
"type": "commonjs",
Expand Down
2 changes: 1 addition & 1 deletion plugins/jet-plugin/plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"title": "jet plugin",
"description": "扫描本机已安装的 JetBrains IDE,聚合各 IDE 最近打开的项目,支持模糊搜索与一键启动",
"author": "zl",
"version": "1.2.2",
"version": "1.2.3",
"platform": ["darwin", "win32"],
"preload": "preload.js",
"logo": "logo.png",
Expand Down
29 changes: 22 additions & 7 deletions plugins/jet-plugin/service/init_service.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const XML_PARSER = new XMLParser({
});

// IDE 扫描结果缓存(ZTools dbStorage):避免每次进入插件都全量扫描
// - 缓存超过 TTL:同步全量扫描
// - 缓存已过期:先用旧缓存渲染,后台全量扫描供下次使用(stale-while-revalidate)
// - 缓存未过期但已较旧:先用缓存渲染,再后台刷新供下次使用
// v2:通道信息新增 Windows 安装目录/启动命令来源,且需让旧版本写入的空结果立即失效
const CHANNELS_CACHE_KEY = "channels.v2";
Expand Down Expand Up @@ -80,6 +80,14 @@ class InitService {
}
return;
}
// 过期缓存也先用于渲染(stale-while-revalidate):扫描可能秒级(Windows 注册表兜底),
// 不能让它阻塞列表首屏;新装 IDE 最晚下次进入时出现
const stale = readRawChannelsCache();
if (stale) {
this.channels = stale.channels;
refreshChannelsCacheInBackground();
return;
}
this.channels = await scanChannels();
writeChannelsCache(this.channels);
}
Expand Down Expand Up @@ -133,18 +141,25 @@ async function scanChannels() {
* @returns { scannedAt: number, channels: object } | null;无缓存/已过期/宿主不支持时返回 null
*/
function readChannelsCache() {
const cached = readRawChannelsCache();
if (!cached || Date.now() - cached.scannedAt > CHANNELS_CACHE_TTL) {
return null;
}
return cached;
}

/**
* 读取原始 channels 缓存(只做结构校验,不判断新鲜度;过期缓存供 stale-while-revalidate 使用)
* @returns { scannedAt: number, channels: object } | null;无缓存/结构无效/宿主不支持时返回 null
*/
function readRawChannelsCache() {
const dbStorage = getDbStorage();
if (!dbStorage) {
return null;
}
try {
const cached = dbStorage.getItem(CHANNELS_CACHE_KEY);
if (
!cached ||
!cached.channels ||
!cached.scannedAt ||
Date.now() - cached.scannedAt > CHANNELS_CACHE_TTL
) {
if (!cached || !cached.channels || !cached.scannedAt) {
return null;
}
return cached;
Expand Down
Loading