问题摘要
就其本身而言,下面以“上下文”为标题的部分应该向 Stack Overflow 提问。然而,经过进一步诊断,我确定我似乎完全无法applications:/
通过 CLI 在 Dolphin 之外访问 URI:
CLI(
gio
)gio list -l applications:/
PS /home/RokeJulianLockhart/Documents/webpage_frontend> gio list -l applications:/ gio: applications:/: Operation not supported
海豚
为什么会这样?据我所知,这应该可以通过 GVFS 子系统作为虚拟安装访问。但是,它似乎没有被安装:
PS /home/RokeJulianLockhart/Documents/webpage_frontend> gio mount -l
Mount(0): s11vzd -> file:///run/media/RokeJulianLockhart/s11vzd
Type: GUnixMount
甚至没有它们的目录:
PS /home/RokeJulianLockhart/Documents/webpage_frontend> tree "$Env:XDG_RUNTIME_DIR/gvfs"
/run/user/1000/gvfs [error opening dir]
0 directories, 0 files
我猜我肯定做错了什么。但是,我无法确定是什么。
语境
我正在尝试创建一个.JS
文件,将 的内容applications:/
(可通过 KDE 的Dolphin和 GNOME 的Nautilus文件管理器访问) 输出到一个.HTML
文件,以便我可以在Web 浏览器 KDE Plasma 6 plasmashell
plasmoid中呈现它。但是,当我连接到服务器 (在http://localhost:3000/index.html
) 时,我看到:
<html><head>
<title>List GVFS Files</title>
</head>
<body>
<h1>Files in applications:/</h1>
<div id="fileList"><ol><li>Error accessing GVFS URI: gio: applications:/: Operation not supported</li></ol></div>
<script>
async function fetchFiles() {
try {
const response = await fetch('http://localhost:3000/list-gvfs-files');
const fileList = await response.text();
// Parse and display the file list
const fileArray = fileList.split('\n').filter(line => line.trim() !== '');
const listContainer = document.getElementById('fileList');
const list = document.createElement('ol');
fileArray.forEach(file => {
const listItem = document.createElement('li');
listItem.textContent = file;
list.appendChild(listItem);
});
listContainer.appendChild(list);
} catch (error) {
console.error("Error fetching files:", error);
}
}
fetchFiles();
</script>
</body></html>
具体来说:
访问 GVFS URI 时出错:gio:应用程序:/:操作不受支持
下文中,如果感兴趣的话,我附上了文件的副本:
server.js
// server.js const express = require('express'); const { exec } = require('child_process'); const app = express(); const PORT = 3000; // Serve static files from the current directory app.use(express.static(__dirname)); app.get('/list-gvfs-files', (req, res) => { // Check current environment variables console.log('Current Environment Variables:', process.env); // Run the gio command and capture output for debugging exec("gio list -l applications:/", (error, stdout, stderr) => { if (error) { console.error("Command Error:", error); console.error("Standard Error:", stderr); return res.status(500).send("Error accessing GVFS URI: " + stderr); } console.log("Command Output:", stdout); res.send(stdout); }); }); app.listen(PORT, () => { console.log(`Server running at http://localhost:${PORT}`); });
index.html
<!DOCTYPE html> <html> <head> <title>List GVFS Files</title> </head> <body> <h1>Files in applications:/</h1> <div id="fileList"></div> <script> async function fetchFiles() { try { const response = await fetch('http://localhost:3000/list-gvfs-files'); const fileList = await response.text(); // Parse and display the file list const fileArray = fileList.split('\n').filter(line => line.trim() !== ''); const listContainer = document.getElementById('fileList'); const list = document.createElement('ol'); fileArray.forEach(file => { const listItem = document.createElement('li'); listItem.textContent = file; list.appendChild(listItem); }); listContainer.appendChild(list); } catch (error) { console.error("Error fetching files:", error); } } fetchFiles(); </script> </body> </html>
它们都是我根据在线找到的类似主题的信息拼凑起来的(不幸的是,关于这个主题的大多数讨论都涉及 PHP,而我不想使用它,因为我对它更不熟悉)。