cc-viewer 1.4.26 → 1.4.28
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/dist/index.html
CHANGED
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
<title>Claude Code Viewer</title>
|
|
7
7
|
<link rel="icon" href="/favicon.ico?v=1">
|
|
8
8
|
<link rel="shortcut icon" href="/favicon.ico?v=1">
|
|
9
|
-
<script type="module" crossorigin src="/assets/index-
|
|
10
|
-
<link rel="stylesheet" crossorigin href="/assets/index-
|
|
9
|
+
<script type="module" crossorigin src="/assets/index-CEQ4SgLV.js"></script>
|
|
10
|
+
<link rel="stylesheet" crossorigin href="/assets/index-BTtdvNJL.css">
|
|
11
11
|
</head>
|
|
12
12
|
<body>
|
|
13
13
|
<div id="root"></div>
|
package/package.json
CHANGED
package/server.js
CHANGED
|
@@ -17,11 +17,10 @@ const PREFS_FILE = join(LOG_DIR, 'preferences.json');
|
|
|
17
17
|
const isCliMode = process.env.CCV_CLI_MODE === '1';
|
|
18
18
|
const isWorkspaceMode = process.env.CCV_WORKSPACE_MODE === '1';
|
|
19
19
|
|
|
20
|
-
//
|
|
20
|
+
// 统一的文件/目录忽略规则(仅隐藏系统和版本控制目录)
|
|
21
21
|
const IGNORED_PATTERNS = new Set([
|
|
22
|
-
'
|
|
23
|
-
'
|
|
24
|
-
'.cache', '.idea', '.vscode'
|
|
22
|
+
'.git', '.svn', '.hg', '.DS_Store',
|
|
23
|
+
'.idea', '.vscode'
|
|
25
24
|
]);
|
|
26
25
|
|
|
27
26
|
// 工作区模式:保存 Claude 额外参数,供 launch API 使用
|
|
@@ -723,14 +722,37 @@ async function handleRequest(req, res) {
|
|
|
723
722
|
try {
|
|
724
723
|
const entries = readdirSync(targetDir, { withFileTypes: true });
|
|
725
724
|
const items = entries
|
|
726
|
-
.filter(e => !
|
|
725
|
+
.filter(e => !IGNORED_PATTERNS.has(e.name))
|
|
727
726
|
.map(e => ({ name: e.name, type: e.isDirectory() ? 'directory' : 'file' }))
|
|
728
727
|
.sort((a, b) => {
|
|
729
728
|
if (a.type !== b.type) return a.type === 'directory' ? -1 : 1;
|
|
730
729
|
return a.name.localeCompare(b.name);
|
|
731
730
|
});
|
|
731
|
+
// 使用 git check-ignore 批量检测被 .gitignore 忽略的文件
|
|
732
|
+
let gitIgnoredSet = new Set();
|
|
733
|
+
try {
|
|
734
|
+
const names = items.map(i => {
|
|
735
|
+
const rel = reqPath === '.' ? i.name : `${reqPath}/${i.name}`;
|
|
736
|
+
return i.type === 'directory' ? `${rel}/` : rel;
|
|
737
|
+
});
|
|
738
|
+
if (names.length > 0) {
|
|
739
|
+
const result = execSync(`git check-ignore --stdin`, {
|
|
740
|
+
cwd,
|
|
741
|
+
input: names.join('\n'),
|
|
742
|
+
encoding: 'utf-8',
|
|
743
|
+
timeout: 3000,
|
|
744
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
745
|
+
});
|
|
746
|
+
result.split('\n').filter(Boolean).forEach(line => {
|
|
747
|
+
const name = line.endsWith('/') ? line.slice(0, -1) : line;
|
|
748
|
+
const baseName = name.includes('/') ? name.split('/').pop() : name;
|
|
749
|
+
gitIgnoredSet.add(baseName);
|
|
750
|
+
});
|
|
751
|
+
}
|
|
752
|
+
} catch { /* git 未安装或非 git 仓库,忽略 */ }
|
|
753
|
+
const result = items.map(i => gitIgnoredSet.has(i.name) ? { ...i, gitIgnored: true } : i);
|
|
732
754
|
res.writeHead(200, { 'Content-Type': 'application/json' });
|
|
733
|
-
res.end(JSON.stringify(
|
|
755
|
+
res.end(JSON.stringify(result));
|
|
734
756
|
} catch (err) {
|
|
735
757
|
res.writeHead(404, { 'Content-Type': 'application/json' });
|
|
736
758
|
res.end(JSON.stringify({ error: 'Directory not found' }));
|