Chrome 通過FTP,HTTP 調用 Everything 瀏覽和搜索本地文件系統

【提問1】

Chrome調用本地 everything.exe, everything 好像有本地 FTP 服務器?

【DeepSeek R1 回答】

是的,Everything 確實內置了 HTTP/FTP 服務器功能,這提供了一種相對安全的瀏覽器與本地應用交互的方式。以下是完整的實現方案:

通過 Everything 的 HTTP 服務器實現瀏覽器交互

Everything (v1.4+) 內置的 HTTP 服務器允許通過瀏覽器執行搜索操作:

  1. 啟用 Everything HTTP 服務器

    • 打開 Everything → 工具 → 選項 → HTTP 服務器
    • 啟用 HTTP 服務器(默認端口 8080)
    • 設置允許的訪問權限(推薦設置為 127.0.0.1 僅限本地訪問)
  2. HTML 頁面通過 AJAX 調用 Everything

<!DOCTYPE html>
<html>
<body><input type="text" id="searchInput" placeholder="搜索文件..."><button onclick="searchEverything()">搜索</button><div id="results"></div><script>async function searchEverything() {const query = document.getElementById('searchInput').value;const response = await fetch(`http://localhost:8080/?search=${encodeURIComponent(query)}&json=1`);const data = await response.json();let resultsHTML = "<h3>搜索結果:</h3><ul>";data.results.forEach(file => {resultsHTML += `<li><a href="file:///${file.path}" target="_blank">${file.name}</a></li>`;});resultsHTML += "</ul>";document.getElementById("results").innerHTML = resultsHTML;}</script>
</body>
</html>

通過 Everything 的 FTP 服務器訪問文件

Everything 也支持 FTP 服務器(需在設置中啟用):

// 在頁面中生成 FTP 鏈接
function generateFtpLink(path) {return `ftp://localhost:21/${encodeURI(path)}`;
}// 使用示例
document.getElementById('ftpLink').href = generateFtpLink("C:/Users/MyFile.txt");

進階方案:通過 Native Messaging 深度集成

若需要執行更復雜的本地操作(如啟動程序),需創建瀏覽器擴展:

  1. 創建擴展文件結構
everything-extension/
├── manifest.json
├── background.js
├── content.js
└── native-host/├── everything-host.bat└── everything-host.ps1
  1. manifest.json
{"manifest_version": 3,"name": "Everything 集成","version": "1.0","permissions": ["nativeMessaging"],"background": {"service_worker": "background.js"},"content_scripts": [{"matches": ["http://localhost/*"],"js": ["content.js"]}]
}
  1. 本地主機應用 (everything-host.ps1)
while ($true) {$input = [Console]::In.ReadLine()$command = $input | ConvertFrom-Json# 執行 Everything 命令if ($command.action -eq "launch") {Start-Process "C:\Path\To\Everything.exe" -ArgumentList "-search", $command.query[Console]::Out.WriteLine('{"status":"success"}')}
}
  1. 注冊本地主機(注冊表文件):
Windows Registry Editor Version 5.00[HKEY_LOCAL_MACHINE\SOFTWARE\Google\Chrome\NativeMessagingHosts\com.example.everything_host]
@="C:\\path\\to\\everything-host-manifest.json"
  1. 擴展通信腳本
// content.js
document.getElementById('launchBtn').addEventListener('click', () => {chrome.runtime.sendNativeMessage('com.example.everything_host', {action: "launch", query: "*.pdf"},response => console.log(response));
});

安全注意事項

  1. 限制 HTTP/FTP 服務器僅限本地訪問(127.0.0.1
  2. 對用戶輸入進行嚴格過濾,防止路徑遍歷攻擊
  3. 在擴展中使用最小權限原則
  4. 避免通過 FTP 傳輸敏感文件
  5. 所有本地主機腳本需進行代碼簽名

替代方案(無需 Everything)

若只需簡單命令執行,可用 PowerShell 作為后端:

// Node.js 服務器
const express = require('express');
const { exec } = require('child_process');
const app = express();app.get('/run', (req, res) => {const cmd = req.query.cmd;exec(cmd, (error, stdout) => {res.send(stdout || error.message);});
});app.listen(3000);

然后在 HTML 中調用:

fetch('http://localhost:3000/run?cmd=dir').then(response => response.text()).then(data => console.log(data));

總結:Everything 的 HTTP/FTP 服務器是最安全便捷的瀏覽器集成方案。對于需要深度系統集成的場景,Native Messaging 擴展方案雖然復雜但功能最強大。普通用戶推薦使用 HTTP 服務器方案即可滿足大部分需求。


【提問2】

通過 Everything 的 FTP 服務器訪問文件,這能出一個詳細解決方案嗎?chrome 能使用everything 搜索本地某目錄里某文件嗎

【DeepSeek R1 回答】

下面我將提供一個完整的詳細解決方案,通過 Chrome 瀏覽器利用 Everything 的 FTP 服務器訪問本地文件系統,并實現文件搜索功能。

完整解決方案:Chrome + Everything FTP 服務器集成

第一部分:Everything 配置

  1. 啟用 Everything FTP 服務器

    • 打開 Everything → 工具 → 選項 → FTP 服務器
    • 勾選 “啟用 FTP 服務器”
    • 配置設置:
      服務器名稱: MyLocalFTP
      監聽端口: 2121(避免使用 21 端口需要管理員權限)
      綁定到: 127.0.0.1(僅限本地訪問)
      用戶名: (留空表示匿名訪問)
      密碼: (留空)
      根目錄: C:\(或您想要搜索的特定目錄)
      
    • 保存設置
  2. 驗證 FTP 服務器

    • 打開文件資源管理器,輸入 ftp://127.0.0.1:2121
    • 應該能看到本地文件列表

第二部分:HTML/JavaScript 實現

<!DOCTYPE html>
<html lang="zh-CN">
<head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>Everything FTP 文件搜索器</title><style>body { font-family: 'Segoe UI', Arial, sans-serif; max-width: 800px; margin: 0 auto; padding: 20px; }.search-box { display: flex; margin-bottom: 20px; }#searchInput { flex: 1; padding: 10px; font-size: 16px; border: 1px solid #ddd; }#searchButton { padding: 10px 20px; background: #4285f4; color: white; border: none; cursor: pointer; }#results { list-style: none; padding: 0; }.file-item { padding: 10px; border-bottom: 1px solid #eee; }.file-item:hover { background-color: #f9f9f9; }.file-link { color: #1a73e8; text-decoration: none; }.file-link:hover { text-decoration: underline; }.file-info { font-size: 12px; color: #666; margin-top: 5px; }.loading { display: none; text-align: center; padding: 20px; }</style>
</head>
<body><h1>本地文件搜索器 (Everything FTP)</h1><div class="search-box"><input type="text" id="searchInput" placeholder="輸入文件名或擴展名 (如: *.pdf project.docx)"><button id="searchButton">搜索</button></div><div class="loading" id="loadingIndicator"><p>正在搜索中... <span id="resultCount">0</span> 個結果</p></div><ul id="results"></ul><script>// Everything FTP 配置const FTP_HOST = '127.0.0.1';const FTP_PORT = 2121;const FTP_URL = `ftp://${FTP_HOST}:${FTP_PORT}/`;// 搜索狀態let currentSearch = null;let resultCount = 0;// DOM 元素const searchInput = document.getElementById('searchInput');const searchButton = document.getElementById('searchButton');const resultsContainer = document.getElementById('results');const loadingIndicator = document.getElementById('loadingIndicator');const resultCountElement = document.getElementById('resultCount');// 初始化document.addEventListener('DOMContentLoaded', () => {searchButton.addEventListener('click', startSearch);searchInput.addEventListener('keyup', (e) => {if (e.key === 'Enter') startSearch();});});// 開始搜索function startSearch() {const query = searchInput.value.trim();if (!query) return;// 中止之前的搜索if (currentSearch) {currentSearch.abort();}// 重置結果resultsContainer.innerHTML = '';resultCount = 0;resultCountElement.textContent = '0';loadingIndicator.style.display = 'block';// 創建 Everything FTP 搜索 URLconst searchUrl = `${FTP_URL}?search=${encodeURIComponent(query)}`;// 創建 XMLHttpRequest 對象currentSearch = new XMLHttpRequest();currentSearch.open('GET', searchUrl, true);// 處理響應數據(流式處理)let buffer = '';currentSearch.onprogress = function(event) {const chunk = currentSearch.responseText.substring(buffer.length);buffer += chunk;// 處理接收到的數據processFTPResponse(buffer);resultCountElement.textContent = resultCount;};currentSearch.onload = function() {if (currentSearch.status === 200) {processFTPResponse(buffer);loadingIndicator.style.display = 'none';}};currentSearch.onerror = function() {loadingIndicator.style.display = 'none';resultsContainer.innerHTML = '<li class="file-item">連接FTP服務器失敗。請確保Everything正在運行且FTP服務器已啟用。</li>';};currentSearch.send();}// 處理FTP響應數據function processFTPResponse(data) {// 簡單解析FTP列表格式const lines = data.split('\r\n');for (const line of lines) {if (!line.trim()) continue;// 解析文件信息(簡化版,實際需要更復雜的解析)const parts = line.split(/\s+/);if (parts.length < 9) continue;const permissions = parts[0];const isDirectory = permissions[0] === 'd';const size = parts[4];const date = `${parts[5]} ${parts[6]} ${parts[7]}`;const filename = parts.slice(8).join(' ');const fullPath = filename;// 只顯示文件(過濾目錄)if (!isDirectory) {addFileResult(fullPath, size, date);}}}// 添加文件到結果列表function addFileResult(path, size, modifiedDate) {resultCount++;// 提取文件名和擴展名const filename = path.split('/').pop() || path;const extension = filename.split('.').pop() || '';// 創建文件鏈接const fileUrl = `${FTP_URL}${encodeURI(path)}`;const listItem = document.createElement('li');listItem.className = 'file-item';listItem.innerHTML = `<a href="${fileUrl}" class="file-link" download="${filename}">${filename}</a><div class="file-info">大小: ${formatFileSize(size)} | 修改日期: ${modifiedDate} | 類型: ${extension.toUpperCase()} 文件</div>`;resultsContainer.appendChild(listItem);}// 格式化文件大小function formatFileSize(bytes) {if (bytes < 1024) return bytes + ' B';if (bytes < 1048576) return (bytes / 1024).toFixed(1) + ' KB';return (bytes / 1048576).toFixed(1) + ' MB';}</script>
</body>
</html>

第三部分:使用說明

  1. 準備工作

    • 確保 Everything 正在運行且 FTP 服務器已啟用
    • 在 Chrome 中打開此 HTML 文件(直接雙擊或通過 file:// 路徑打開)
  2. 搜索功能

    • 在搜索框輸入查詢:
      • 使用 Everything 搜索語法:*.pdfproject.docx*.jpg width:1920 height:1080
      • 支持布爾運算符:ANDORNOT
    • 點擊搜索或按 Enter 鍵
    • 結果將實時加載顯示
  3. 文件操作

    • 點擊文件名將下載該文件
    • 鼠標懸停在文件項上可查看詳細信息

第四部分:安全增強配置

由于直接使用 FTP 存在安全風險,建議添加以下安全措施:

  1. Everything 設置

    ; Everything.ini 安全配置
    ftp_server_allow_anonymous=0
    ftp_server_username=chrome_user
    ftp_server_password=secure_password123
    ftp_server_root_path=C:\Users\Public\Share
    ftp_server_passive_mode=1
    
  2. HTML 身份驗證

    // 在搜索URL中添加憑據
    const FTP_AUTH = 'chrome_user:secure_password123';
    const searchUrl = `ftp://${FTP_AUTH}@${FTP_HOST}:${FTP_PORT}/?search=${query}`;
    
  3. 限制文件類型

    // 在 addFileResult 函數中添加
    const allowedExtensions = ['pdf', 'docx', 'jpg', 'png'];
    if (!allowedExtensions.includes(extension.toLowerCase())) return;
    

第五部分:替代方案(推薦)

由于現代瀏覽器對 FTP 支持有限(Chrome 88+ 已禁用 FTP),推薦使用 Everything 的 HTTP 服務器方案:

// 使用 HTTP 服務器替代 FTP
const HTTP_EVERYTHING_URL = 'http://localhost:8080/';async function searchEverything() {const response = await fetch(`${HTTP_EVERYTHING_URL}?search=${query}&json=1`);const data = await response.json();data.results.forEach(file => {// 創建本地文件鏈接const fileUrl = `file:///${file.path.replace(/\\/g, '/')}`;addFileResult(file.path, file.size, file.date_modified);});
}

注意事項

  1. 瀏覽器限制

    • Chrome 88+ 默認禁用 FTP 支持
    • 文件下載可能被瀏覽器安全策略阻止
    • 本地文件訪問需要用戶授權
  2. 安全警告

    • 僅在受信任的環境中使用
    • 不要將 FTP 服務器暴露在公共網絡
    • 設置強密碼或使用 HTTP 服務器替代
  3. 性能優化

    • 限制返回結果數量(在 URL 中添加 &offset=0&count=100
    • 添加防抖機制避免頻繁搜索
    • 使用 Web Workers 處理大型結果集
  4. 跨平臺支持

    • Windows:完整支持
    • macOS/Linux:需要 Wine 或 CrossOver 運行 Everything

這個解決方案讓您可以直接在 Chrome 瀏覽器中利用 Everything 的強大搜索功能訪問本地文件系統,同時通過 FTP 服務器提供文件訪問功能。對于現代瀏覽器,建議優先使用 Everything 的 HTTP 服務器方案以獲得更好的兼容性。


【提問3】

通過 Everything 的 HTTP 服務器訪問文件,這能出一個詳細解決方案嗎?chrome 能使用everything 搜索本地某目錄里某文件嗎

【DeepSeek R1 回答】

Everything HTTP 服務器集成解決方案

下面我將提供一個完整的解決方案,通過 Chrome 瀏覽器利用 Everything 的 HTTP 服務器實現本地文件搜索和訪問功能。

整體思路

  1. 配置 Everything 的 HTTP 服務器
  2. 創建 HTML 頁面調用 Everything API
  3. 實現搜索功能和結果展示
  4. 提供文件預覽和下載功能

完整解決方案

<!DOCTYPE html>
<html lang="zh-CN">
<head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>Everything 本地文件搜索器</title><style>:root {--primary-color: #4285f4;--secondary-color: #34a853;--background-color: #f8f9fa;--card-color: #ffffff;--text-color: #202124;--border-color: #dadce0;}* {box-sizing: border-box;margin: 0;padding: 0;}body {font-family: 'Segoe UI', 'Microsoft YaHei', sans-serif;background-color: var(--background-color);color: var(--text-color);line-height: 1.6;padding: 20px;max-width: 1200px;margin: 0 auto;}header {text-align: center;margin-bottom: 30px;padding: 20px 0;border-bottom: 1px solid var(--border-color);}h1 {color: var(--primary-color);font-size: 2.5rem;margin-bottom: 10px;}.subtitle {color: #5f6368;font-size: 1.1rem;max-width: 700px;margin: 0 auto;}.search-container {background-color: var(--card-color);border-radius: 8px;box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);padding: 25px;margin-bottom: 30px;}.search-box {display: flex;gap: 10px;margin-bottom: 20px;}#searchInput {flex: 1;padding: 15px;font-size: 16px;border: 1px solid var(--border-color);border-radius: 4px;transition: border-color 0.3s;}#searchInput:focus {outline: none;border-color: var(--primary-color);box-shadow: 0 0 0 2px rgba(66, 133, 244, 0.2);}#searchButton {padding: 15px 25px;background-color: var(--primary-color);color: white;border: none;border-radius: 4px;font-size: 16px;cursor: pointer;transition: background-color 0.3s;}#searchButton:hover {background-color: #3367d6;}.filters {display: flex;gap: 15px;flex-wrap: wrap;margin-bottom: 20px;}.filter-group {flex: 1;min-width: 200px;}.filter-group label {display: block;margin-bottom: 5px;font-weight: 500;}.filter-group select, .filter-group input {width: 100%;padding: 10px;border: 1px solid var(--border-color);border-radius: 4px;}.results-container {background-color: var(--card-color);border-radius: 8px;box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);overflow: hidden;}.results-header {padding: 15px 20px;background-color: #f5f5f5;border-bottom: 1px solid var(--border-color);display: flex;justify-content: space-between;align-items: center;}#resultCount {font-weight: 500;}#results {max-height: 500px;overflow-y: auto;}.result-item {padding: 15px 20px;border-bottom: 1px solid var(--border-color);display: flex;align-items: center;}.result-item:hover {background-color: #f8f9fa;}.file-icon {width: 32px;height: 32px;margin-right: 15px;display: flex;align-items: center;justify-content: center;color: #5f6368;}.file-icon img {max-width: 100%;max-height: 100%;}.file-info {flex: 1;min-width: 0;}.file-name {font-weight: 500;margin-bottom: 5px;white-space: nowrap;overflow: hidden;text-overflow: ellipsis;}.file-details {display: flex;gap: 15px;font-size: 0.85rem;color: #5f6368;}.file-actions {display: flex;gap: 10px;}.action-btn {padding: 8px 12px;background-color: #f1f3f4;border: none;border-radius: 4px;cursor: pointer;transition: background-color 0.3s;}.action-btn:hover {background-color: #e8eaed;}.preview-btn {background-color: #f8f9fa;color: var(--primary-color);}.download-btn {background-color: var(--secondary-color);color: white;}.loading-container {display: none;text-align: center;padding: 40px;}.loading-spinner {border: 4px solid rgba(0, 0, 0, 0.1);border-top: 4px solid var(--primary-color);border-radius: 50%;width: 40px;height: 40px;animation: spin 1s linear infinite;margin: 0 auto 20px;}@keyframes spin {0% { transform: rotate(0deg); }100% { transform: rotate(360deg); }}.no-results {text-align: center;padding: 40px;color: #5f6368;}.error-message {background-color: #fce8e6;color: #d93025;padding: 15px;border-radius: 4px;margin-top: 20px;display: none;}.preview-container {display: none;position: fixed;top: 0;left: 0;width: 100%;height: 100%;background-color: rgba(0,0,0,0.8);z-index: 1000;padding: 20px;}.preview-content {background-color: white;border-radius: 8px;max-width: 900px;max-height: 90vh;margin: 20px auto;overflow: auto;position: relative;}.preview-header {padding: 15px 20px;background-color: #f5f5f5;display: flex;justify-content: space-between;align-items: center;position: sticky;top: 0;z-index: 10;}.close-preview {background: none;border: none;font-size: 1.5rem;cursor: pointer;color: #5f6368;}.preview-body {padding: 20px;}.preview-body img, .preview-body video {max-width: 100%;display: block;margin: 0 auto;}.preview-body audio {width: 100%;}footer {text-align: center;margin-top: 40px;padding: 20px 0;color: #5f6368;font-size: 0.9rem;border-top: 1px solid var(--border-color);}@media (max-width: 768px) {.search-box {flex-direction: column;}.file-details {flex-wrap: wrap;gap: 8px;}.result-item {flex-direction: column;align-items: flex-start;}.file-actions {margin-top: 10px;width: 100%;}.action-btn {flex: 1;}}</style>
</head>
<body><header><h1>Everything 本地文件搜索器</h1><p class="subtitle">通過 Everything HTTP 服務器實現本地文件搜索、預覽和管理功能</p></header><main><section class="search-container"><div class="search-box"><input type="text" id="searchInput" placeholder="輸入文件名、擴展名或路徑 (如: *.pdf project.docx)" autofocus><button id="searchButton">搜索文件</button></div><div class="filters"><div class="filter-group"><label for="fileType">文件類型</label><select id="fileType"><option value="">所有文件類型</option><option value=".pdf">PDF 文檔</option><option value=".doc,.docx">Word 文檔</option><option value=".xls,.xlsx">Excel 表格</option><option value=".jpg,.jpeg,.png,.gif">圖片文件</option><option value=".mp4,.avi,.mov">視頻文件</option><option value=".mp3,.wav">音頻文件</option></select></div><div class="filter-group"><label for="searchPath">搜索路徑</label><input type="text" id="searchPath" placeholder="如: C:\Projects\ D:\Documents\"></div><div class="filter-group"><label for="sortBy">排序方式</label><select id="sortBy"><option value="date_modified:desc">最新修改</option><option value="date_modified:asc">最早修改</option><option value="size:desc">最大文件</option><option value="size:asc">最小文件</option><option value="name:asc">名稱 (A-Z)</option><option value="name:desc">名稱 (Z-A)</option></select></div></div><div class="error-message" id="errorMessage">無法連接到 Everything HTTP 服務器。請確保 Everything 正在運行且 HTTP 服務器已啟用。</div></section><section class="results-container"><div class="results-header"><h2>搜索結果</h2><div id="resultCount">0 個文件</div></div><div class="loading-container" id="loadingIndicator"><div class="loading-spinner"></div><p>正在搜索中...</p></div><div id="results"><div class="no-results"><p>輸入搜索條件并點擊"搜索文件"按鈕開始搜索</p></div></div></section></main><div class="preview-container" id="previewContainer"><div class="preview-content"><div class="preview-header"><h3 id="previewFileName">文件預覽</h3><button class="close-preview" id="closePreview">&times;</button></div><div class="preview-body" id="previewBody"></div></div></div><footer><p>Everything 本地文件搜索器 &copy; 2023 | 需要 Everything v1.4+ 和啟用的 HTTP 服務器</p></footer><script>// Everything HTTP 服務器配置const EVERYTHING_HTTP_URL = "http://localhost:8080";// DOM 元素const searchInput = document.getElementById('searchInput');const searchButton = document.getElementById('searchButton');const fileTypeSelect = document.getElementById('fileType');const searchPathInput = document.getElementById('searchPath');const sortBySelect = document.getElementById('sortBy');const resultsContainer = document.getElementById('results');const resultCountElement = document.getElementById('resultCount');const loadingIndicator = document.getElementById('loadingIndicator');const errorMessage = document.getElementById('errorMessage');const previewContainer = document.getElementById('previewContainer');const previewBody = document.getElementById('previewBody');const previewFileName = document.getElementById('previewFileName');const closePreview = document.getElementById('closePreview');// 文件圖標映射const fileIcons = {'folder': '📁','pdf': '📄','doc': '📝','docx': '📝','xls': '📊','xlsx': '📊','jpg': '🖼?','jpeg': '🖼?','png': '🖼?','gif': '🖼?','mp4': '🎬','avi': '🎬','mov': '🎬','mp3': '🎵','wav': '🎵','exe': '??','zip': '📦','rar': '📦','default': '📄'};// 初始化document.addEventListener('DOMContentLoaded', () => {searchButton.addEventListener('click', performSearch);searchInput.addEventListener('keyup', (e) => {if (e.key === 'Enter') performSearch();});closePreview.addEventListener('click', () => {previewContainer.style.display = 'none';});// 測試連接testEverythingConnection();});// 測試 Everything 連接async function testEverythingConnection() {try {const response = await fetch(`${EVERYTHING_HTTP_URL}/?json=1&search=test`);if (!response.ok) throw new Error('Connection failed');errorMessage.style.display = 'none';} catch (error) {errorMessage.style.display = 'block';console.error('Everything connection test failed:', error);}}// 執行搜索async function performSearch() {const query = searchInput.value.trim();if (!query) return;// 顯示加載狀態loadingIndicator.style.display = 'block';resultsContainer.innerHTML = '';try {// 構建搜索參數let searchParams = new URLSearchParams();searchParams.append('search', query);searchParams.append('json', '1');// 添加文件類型過濾const fileType = fileTypeSelect.value;if (fileType) {searchParams.append('ext', fileType);}// 添加路徑過濾const searchPath = searchPathInput.value.trim();if (searchPath) {searchParams.append('path', searchPath);}// 添加排序const [sortField, sortOrder] = sortBySelect.value.split(':');searchParams.append('sort', sortField);searchParams.append('ascending', sortOrder === 'asc' ? '1' : '0');// 限制結果數量searchParams.append('count', '100');// 調用 Everything APIconst response = await fetch(`${EVERYTHING_HTTP_URL}/?${searchParams.toString()}`);if (!response.ok) {throw new Error(`HTTP error! status: ${response.status}`);}const data = await response.json();displayResults(data);} catch (error) {console.error('搜索失敗:', error);resultsContainer.innerHTML = `<div class="no-results"><p>搜索失敗: ${error.message}</p><p>請確保 Everything 正在運行且 HTTP 服務器已啟用</p></div>`;errorMessage.style.display = 'block';} finally {loadingIndicator.style.display = 'none';}}// 顯示搜索結果function displayResults(data) {if (!data || !data.results || data.results.length === 0) {resultsContainer.innerHTML = `<div class="no-results"><p>沒有找到匹配的文件</p><p>嘗試不同的搜索關鍵詞或調整篩選條件</p></div>`;resultCountElement.textContent = '0 個文件';return;}resultCountElement.textContent = `${data.results.length} 個文件`;let resultsHTML = '';data.results.forEach(file => {const fileExt = getFileExtension(file.name);const icon = fileIcons[fileExt] || fileIcons.default;resultsHTML += `<div class="result-item"><div class="file-icon">${icon}</div><div class="file-info"><div class="file-name" title="${file.path}">${file.name}</div><div class="file-details"><span>路徑: ${truncatePath(file.path, 50)}</span><span>大小: ${formatFileSize(file.size)}</span><span>修改: ${formatDate(file.date_modified)}</span></div></div><div class="file-actions"><button class="action-btn preview-btn" data-path="${encodeURIComponent(file.path)}">預覽</button><button class="action-btn download-btn" data-path="${encodeURIComponent(file.path)}">下載</button></div></div>`;});resultsContainer.innerHTML = resultsHTML;// 添加事件監聽器document.querySelectorAll('.preview-btn').forEach(btn => {btn.addEventListener('click', (e) => {const filePath = decodeURIComponent(e.target.dataset.path);previewFile(filePath);});});document.querySelectorAll('.download-btn').forEach(btn => {btn.addEventListener('click', (e) => {const filePath = decodeURIComponent(e.target.dataset.path);downloadFile(filePath);});});}// 預覽文件function previewFile(filePath) {const fileExt = getFileExtension(filePath).toLowerCase();const fileName = filePath.split('\\').pop();previewFileName.textContent = fileName;previewBody.innerHTML = '';// 根據文件類型顯示不同預覽if (['jpg', 'jpeg', 'png', 'gif'].includes(fileExt)) {previewBody.innerHTML = `<img src="${EVERYTHING_HTTP_URL}/?thumb=${encodeURIComponent(filePath)}" alt="${fileName}" onerror="this.src='https://via.placeholder.com/600x400?text=無法預覽圖片'">`;} else if (['mp4', 'avi', 'mov'].includes(fileExt)) {previewBody.innerHTML = `<video controls><source src="${EVERYTHING_HTTP_URL}/?download=${encodeURIComponent(filePath)}" type="video/${fileExt === 'mp4' ? 'mp4' : fileExt === 'mov' ? 'quicktime' : 'x-msvideo'}">您的瀏覽器不支持視頻預覽</video>`;}else if (['mp3', 'wav'].includes(fileExt)) {previewBody.innerHTML = `<audio controls><source src="${EVERYTHING_HTTP_URL}/?download=${encodeURIComponent(filePath)}" type="audio/${fileExt === 'mp3' ? 'mpeg' : 'wav'}">您的瀏覽器不支持音頻預覽</audio>`;}else if (fileExt === 'pdf') {previewBody.innerHTML = `<iframe src="${EVERYTHING_HTTP_URL}/?download=${encodeURIComponent(filePath)}" width="100%" height="600px" style="border: none;"></iframe>`;}else {previewBody.innerHTML = `<p>此文件類型不支持預覽</p><p>文件路徑: ${filePath}</p><p>大小: ${formatFileSize(getFileSizeFromPath(filePath))}</p>`;}previewContainer.style.display = 'block';}// 下載文件function downloadFile(filePath) {const fileName = filePath.split('\\').pop();const downloadUrl = `${EVERYTHING_HTTP_URL}/?download=${encodeURIComponent(filePath)}`;const a = document.createElement('a');a.href = downloadUrl;a.download = fileName;document.body.appendChild(a);a.click();document.body.removeChild(a);}// 輔助函數function getFileExtension(filename) {return filename.split('.').pop().toLowerCase();}function formatFileSize(bytes) {if (bytes === 0) return '0 B';const k = 1024;const sizes = ['B', 'KB', 'MB', 'GB'];const i = Math.floor(Math.log(bytes) / Math.log(k));return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i];}function formatDate(dateString) {const date = new Date(dateString);return date.toLocaleDateString() + ' ' + date.toLocaleTimeString();}function truncatePath(path, maxLength) {if (path.length <= maxLength) return path;const parts = path.split('\\');let result = '';for (let i = parts.length - 1; i >= 0; i--) {const newPart = '...\\' + parts.slice(i).join('\\');if (newPart.length <= maxLength) {return newPart;}}return '...\\' + path.slice(-maxLength + 4);}function getFileSizeFromPath(filePath) {// 在實際應用中,這里應該通過API獲取文件大小// 此處僅用于演示return Math.floor(Math.random() * 10000000);}</script>
</body>
</html>

Everything 配置指南

步驟 1: 啟用 HTTP 服務器

  1. 打開 Everything → 工具 → 選項 → HTTP 服務器
  2. 啟用 HTTP 服務器
  3. 設置端口 (默認為 8080)
  4. 綁定到 127.0.0.1 (僅限本地訪問)
  5. 勾選"允許文件下載"和"允許文件瀏覽"
  6. 保存設置

步驟 2: 高級配置 (可選)

在 Everything.ini 文件中添加以下配置以增強功能:

http_server_port=8080
http_server_bind_address=127.0.0.1
http_server_allow_http=1
http_server_allow_download=1
http_server_allow_file_browsing=1
http_server_thumbnails=1

功能說明

  1. 文件搜索

    • 支持文件名、擴展名和路徑搜索
    • 可使用 Everything 高級搜索語法 (如 *.pdf, project.docx, size:>10MB)
  2. 篩選功能

    • 按文件類型篩選 (文檔、圖片、視頻等)
    • 按路徑篩選 (如 C:\Projects\)
    • 多種排序方式 (日期、大小、名稱)
  3. 文件操作

    • 預覽功能 (支持圖片、視頻、音頻和PDF)
    • 文件下載
    • 文件詳細信息查看
  4. 響應式設計

    • 適配桌面和移動設備
    • 美觀的用戶界面

使用說明

  1. 確保 Everything 正在運行且 HTTP 服務器已啟用
  2. 在 Chrome 中打開此 HTML 文件
  3. 輸入搜索關鍵字并點擊"搜索文件"按鈕
  4. 瀏覽搜索結果,可點擊"預覽"查看文件內容或"下載"獲取文件

安全注意事項

  1. 僅限本地訪問:HTTP 服務器應綁定到 127.0.0.1
  2. 訪問控制:如果需要,可設置用戶名和密碼
  3. 文件權限:避免暴露敏感目錄
  4. 瀏覽器限制:部分文件類型預覽需要瀏覽器支持

此解決方案提供了一種安全、高效的方式來通過 Chrome 瀏覽器搜索和訪問本地文件,充分利用了 Everything 強大的搜索能力和 HTTP 服務器的靈活性。在這里插入圖片描述

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/907769.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/907769.shtml
英文地址,請注明出處:http://en.pswp.cn/news/907769.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

Java八股文智能體——Agent提示詞(Prompt)

這個智能體能夠為正在學習Java八股文的同學提供切實幫助&#xff1a;不僅可以幫你優化答案表述&#xff0c;還能直接解答八股文相關問題——它會以面試者的視角&#xff0c;給出貼合求職場景的專業回答。 將以下內容發送給任何一個LLM&#xff0c;他會按照你提示詞的內容&…

Android 緩存應用凍結器(Cached Apps Freezer)

一、核心功能與原理 1. 功能概述 目標&#xff1a;通過凍結后臺緩存應用的進程&#xff0c;減少其對 CPU、內存等系統資源的消耗&#xff0c;優化設備性能與續航。適用場景&#xff1a;針對行為不當的后臺應用&#xff08;如后臺偷偷運行代碼、占用 CPU&#xff09;&#xff…

內存管理 : 06 內存換出

內存換出的重要性及與換入的關系 現在我們講第25講&#xff0c;主題是內存的換出&#xff08;swipe out&#xff09;。實際上&#xff0c;上一講我們講的是內存的換入&#xff0c;而這一節聚焦于內存的換出。 換入和換出必須合在一起工作&#xff0c;不能只有換入而沒有換出。…

第一節 51單片機概述

目錄 一、單片機系統組成 &#xff08;一&#xff09;、單片機硬件系統 &#xff08;二&#xff09;單片機的軟件系統 二、STC89C52單片機 &#xff08;1&#xff09;、基本信息 &#xff08;2&#xff09;、命名規則 &#xff08;3&#xff09;、單片機內部結構圖 &am…

前端面試準備-4

1.React Router的history模式中&#xff0c;push和replace有什么區別 都是用于頁面導航&#xff0c;但是他們對瀏覽器歷史記錄的處理不一樣。 ①&#xff1a;push是在瀏覽歷史棧里加入一條新的瀏覽歷史&#xff0c;點擊返回鍵會返回上一個頁面 ②;replace是替換當前歷史記錄…

【機器學習基礎】機器學習入門核心:Jaccard相似度 (Jaccard Index) 和 Pearson相似度 (Pearson Correlation)

機器學習入門核心&#xff1a;Jaccard相似度 &#xff08;Jaccard Index&#xff09; 和 Pearson相似度 &#xff08;Pearson Correlation&#xff09; 一、算法邏輯Jaccard相似度 (Jaccard Index)**Pearson相似度 (Pearson Correlation)** 二、算法原理與數學推導1. Jaccard相…

Unity3D仿星露谷物語開發57之保存庫存信息到文件

1、目標 保存下面庫存欄中信息到文件中。 2、修改SceneSave.cs腳本 添加2行代碼&#xff1a; 3、修改InventoryManager對象 添加Generate GUID組件。 4、修改InventoryManager.cs腳本 添加繼承自ISaveable 添加屬性信息&#xff1a; private string _iSaveableUniqueID;pub…

測量3D翼片的距離與角度

1&#xff0c;目的。 測量3D翼片的距離與角度。說明&#xff1a; 標注A 紅色框選的區域即為翼片&#xff0c;本示例的3D 對象共有3個翼片待測。L1與L2的距離、L1與L2的角度即為所求的翼片距離與角度。 2&#xff0c;原理。 使用線結構光模型&#xff08;標定模式&#xff0…

深入理解 SQL 的 JOIN 查詢:從基礎到高級的第一步

在處理數據庫時&#xff0c;我們常常需要從多個表中提取數據。比如想知道一個城市的天氣情況&#xff0c;同時又想知道這個城市的具體位置。這就需要將 weather 表和 cities 表結合起來查詢。這種操作在 SQL 中被稱為 JOIN 查詢。 現在看下兩種表的情況 1.weather 表&#xff…

上傳頭像upload的簡易方法,轉base64調接口的

1.首頁使用el-image顯示數據&#xff0c;用的是轉base64后端返給的 <el-table-column prop"avatar" align"center" label"頭像"><template #default"scope"><el-image style"height: 40px;width: 40px;" :sr…

[AD] CrownJewel-1 Logon 4799+vss-ShadowCopy+NTDS.dit/SYSTEM+$MFT

QA QA攻擊者可以濫用 vssadmin 實用程式來建立卷影快照&#xff0c;然後提取 NTDS.dit 等敏感檔案來繞過安全機制。確定卷影複製服務進入運作狀態的時間。2024-05-14 03:42:16建立卷影快照時&#xff0c;磁碟區複製服務會使用機器帳戶驗證權限並列舉使用者群組。找到卷影複製過…

rtpmixsound:實現音頻混音攻擊!全參數詳細教程!Kali Linux教程!

簡介 一種將預先錄制的音頻與指定目標音頻流中的音頻&#xff08;即 RTP&#xff09;實時混合的工具。 一款用于將預先錄制的音頻與指定目標音頻流中的音頻&#xff08;即 RTP&#xff09;實時混合的工具。該工具創建于 2006 年 8 月至 9 月之間。該工具名為 rtpmixsound。它…

GitHub 趨勢日報 (2025年05月28日)

&#x1f4ca; 由 TrendForge 系統生成 | &#x1f310; https://trendforge.devlive.org/ &#x1f310; 本日報中的項目描述已自動翻譯為中文 &#x1f4c8; 今日獲星趨勢圖 今日獲星趨勢圖 2379 agenticSeek 1521 computer-science 841 n8n 577 langflow 351 qlib 282 skt…

threejsPBR材質與紋理貼圖

1. PBR材質簡介 本節課沒有具體的代碼&#xff0c;就是給大家科普一下PBR材質&#xff0c;所謂PBR就是&#xff0c;基于物理的渲染(physically-based rendering)。 Three.js提供了兩個PBR材質相關的APIMeshStandardMaterial和MeshPhysicalMaterial,MeshPhysicalMaterial是Mes…

Android 12系統源碼_多屏幕(四)自由窗口模式

一、小窗模式 1.1 小窗功能的開啟方式 開發者模式下開啟小窗功能 adb 手動開啟 adb shell settings put global enable_freeform_support 1 adb shell settings put global force_resizable_activities 11.2 源碼配置 copy file # add for freedom PRODUCT_COPY_FILES …

C# 將HTML文檔、HTML字符串轉換為圖片

在.NET開發中&#xff0c;將HTML內容轉換為圖片的需求廣泛存在于報告生成、郵件內容存檔、網頁快照等場景。Free Spire.Doc for .NET作為一款免費的專業文檔處理庫&#xff0c;無需Microsoft Word依賴&#xff0c;即可輕松實現這一功能。本文將深入解析HTML文檔和字符串轉圖片兩…

【HTML-15.2】HTML表單按鈕全面指南:從基礎到高級實踐

表單按鈕是網頁交互的核心元素&#xff0c;作為用戶提交數據、觸發操作的主要途徑&#xff0c;其重要性不言而喻。本文將系統性地介紹HTML表單按鈕的各種類型、使用場景、最佳實踐以及高級技巧&#xff0c;幫助開發者構建更高效、更易用的表單交互體驗。 1. 基礎按鈕類型 1.1…

吳恩達MCP課程(4):connect_server_mcp_chatbot

目錄 完整代碼代碼解釋1. 導入和初始化2. 類型定義3. MCP_ChatBot 類初始化4. 查詢處理 (process_query)5. 服務器連接管理6. 核心特性總結 示例 完整代碼 原課程代碼是用Anthropic寫的&#xff0c;下面代碼是用OpenAI改寫的&#xff0c;模型則用阿里巴巴的模型做測試 .env 文…

C++內存學習

引入 在實例化對象時&#xff0c;不管是編譯器還是我們自己&#xff0c;會使用構造函數給成員變量一個合適的初始值。 但是經過構造函數之后&#xff0c;我們還不能將其稱為成員變量的初始化&#xff1a; 構造函數中的語句只能稱為賦初值&#xff0c;而不能稱作初始化 因為初…

MySQL 大戰 PostgreSQL

一、底層架構對比 ??維度????MySQL????PostgreSQL????存儲引擎??多引擎支持&#xff08;InnoDB、MyISAM等&#xff09;單一存儲引擎&#xff08;支持擴展如Zheap、Zedstore&#xff09;??事務實現??基于UNDO日志的MVCC基于堆表(Heap)的MVCC??鎖機制??…