mirror of
https://github.com/TheGreyDiamond/open360viewer.git
synced 2025-07-17 20:33:48 +02:00
- packaging kinda works now
- start of file listing - allow argument opening
This commit is contained in:
BIN
icons/colorPalette.png
Normal file
BIN
icons/colorPalette.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 7.1 KiB |
43
icons/fullLogo.svg
Normal file
43
icons/fullLogo.svg
Normal file
File diff suppressed because one or more lines are too long
After Width: | Height: | Size: 32 KiB |
29
icons/logoOnly.svg
Normal file
29
icons/logoOnly.svg
Normal file
File diff suppressed because one or more lines are too long
After Width: | Height: | Size: 19 KiB |
43
index.js
43
index.js
@ -9,6 +9,10 @@ const {
|
||||
const url = require("url");
|
||||
const path = require("path");
|
||||
const FileType = require("file-type");
|
||||
const glob = require("glob");
|
||||
const fs = require("fs");
|
||||
|
||||
|
||||
let win;
|
||||
const isMac = process.platform === "darwin";
|
||||
|
||||
@ -96,6 +100,9 @@ function createWindow() {
|
||||
app.on("ready", function () {
|
||||
createWindow();
|
||||
|
||||
|
||||
console.log(process.argv)
|
||||
|
||||
ipcMain.on("synchronous-message", (event, arg) => {
|
||||
console.log(arg);
|
||||
if (arg == "openFile") {
|
||||
@ -104,16 +111,50 @@ app.on("ready", function () {
|
||||
.then(function (data) {
|
||||
FileType.fromFile(data.filePaths[0]).then((type) => {
|
||||
data.type = type["mime"].split("/")[0];
|
||||
console.info(data)
|
||||
win.webContents.send("FileData", data);
|
||||
});
|
||||
});
|
||||
event.returnValue = "";
|
||||
} else if (arg == "resize") {
|
||||
// A really ugly hack to force the window to update, so the canvas shows up
|
||||
win.setSize(win.getSize()[0] + 1, win.getSize()[1]);
|
||||
setTimeout(function () {
|
||||
win.setSize(win.getSize()[0] + 1, win.getSize()[1]);
|
||||
}, 200);
|
||||
event.returnValue = "";
|
||||
} else if (arg.includes("indexFolder")) {
|
||||
const fold = arg.split(";")[1];
|
||||
folder = fs.readdirSync(fold);
|
||||
let result = [];
|
||||
for (const file in folder) {
|
||||
const myFile = folder[file];
|
||||
if (fs.statSync(fold + "/" + myFile).isFile()) {
|
||||
result.push(myFile)
|
||||
}
|
||||
}
|
||||
event.returnValue = result;
|
||||
} else if (arg == "finishedLoading") {
|
||||
const tryOpenFile = process.argv[1];
|
||||
|
||||
if (tryOpenFile != undefined) {
|
||||
console.log("Opening file: ", process.argv[1])
|
||||
if (fs.existsSync(tryOpenFile)) {
|
||||
data = {
|
||||
canceled: false,
|
||||
filePaths: [process.argv[1]]
|
||||
};
|
||||
FileType.fromFile(data.filePaths[0]).then((type) => {
|
||||
data.type = type["mime"].split("/")[0];
|
||||
console.log(data)
|
||||
win.webContents.send("FileData", data);
|
||||
});
|
||||
} else {
|
||||
console.log("Argument file does not exist")
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
event.returnValue = "";
|
||||
|
||||
});
|
||||
});
|
||||
|
40
package.json
40
package.json
@ -10,56 +10,24 @@
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1",
|
||||
"start": "electron .",
|
||||
"start": "electron ",
|
||||
"startDev": "npm run buildCss && npm run minify && electron .",
|
||||
"minify": "node tooling/minifyAll/minifyAllSrcs.js",
|
||||
"buildCss": "npx tailwindcss -i ./src/main.css -o ./dist/output.css",
|
||||
"buildCssWatch": "npx tailwindcss -i ./src/main.css -o ./dist/output.css --watch",
|
||||
"package": "electron-forge package",
|
||||
"make": "electron-forge make"
|
||||
"buildCssWatch": "npx tailwindcss -i ./src/main.css -o ./dist/output.css --watch"
|
||||
},
|
||||
"author": "TheGreydiamond",
|
||||
"license": "GPL-3.0",
|
||||
"config": {
|
||||
"forge": {
|
||||
"packagerConfig": {},
|
||||
"makers": [
|
||||
{
|
||||
"name": "@electron-forge/maker-squirrel",
|
||||
"config": {
|
||||
"name": "open360viewer"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "@electron-forge/maker-zip",
|
||||
"platforms": [
|
||||
"darwin"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "@electron-forge/maker-deb",
|
||||
"config": {}
|
||||
},
|
||||
{
|
||||
"name": "@electron-forge/maker-rpm",
|
||||
"config": {}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"dependencies": {
|
||||
"@fortawesome/fontawesome-free": "^5.15.4",
|
||||
"@themesberg/flowbite": "^1.2.0",
|
||||
"file-type": "^16.5.3",
|
||||
"glob": "^7.2.0",
|
||||
"marzipano": "^0.10.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@electron-forge/cli": "^6.0.0-beta.61",
|
||||
"@electron-forge/maker-deb": "^6.0.0-beta.61",
|
||||
"@electron-forge/maker-rpm": "^6.0.0-beta.61",
|
||||
"@electron-forge/maker-squirrel": "^6.0.0-beta.61",
|
||||
"@electron-forge/maker-zip": "^6.0.0-beta.61",
|
||||
"electron": "^16.0.6",
|
||||
"electron-packager": "^15.4.0",
|
||||
"minify": "^8.0.3",
|
||||
"tailwindcss": "^3.0.11"
|
||||
}
|
||||
|
21
src/main.js
21
src/main.js
@ -1,5 +1,7 @@
|
||||
const { ipcRenderer, ipcMain } = require("electron");
|
||||
|
||||
let currentIndex = -1;
|
||||
|
||||
ipcRenderer.on("FileData", function (event, data) {
|
||||
console.log(data);
|
||||
if (data.canceled == false) {
|
||||
@ -14,9 +16,28 @@ ipcRenderer.on("FileData", function (event, data) {
|
||||
} else if (data.type == "video") {
|
||||
loadVideoFromSource(data.filePaths[0]);
|
||||
}
|
||||
makeFileIndex(data.filePaths[0]);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
function getPathWithoutExtension(path) {
|
||||
return path.substring(0, path.lastIndexOf("/")) || path.substring(0, path.lastIndexOf("\\"));
|
||||
}
|
||||
|
||||
function makeFileIndex(fullPath) {
|
||||
fileName = fullPath.substring(fullPath.lastIndexOf("/")) || fullPath.substring(0, fullPath.lastIndexOf("\\"));
|
||||
path = getPathWithoutExtension(fullPath);
|
||||
const result = ipcRenderer.sendSync("synchronous-message", "indexFolder;" + path);
|
||||
const finalResult = [];
|
||||
for(elm in result) {
|
||||
const curr = result[elm];
|
||||
finalResult.push(path + curr)
|
||||
}
|
||||
currentIndex = fin
|
||||
console.log(finalResult)
|
||||
}
|
||||
|
||||
function openFile() {
|
||||
ipcRenderer.sendSync("synchronous-message", "openFile");
|
||||
}
|
||||
|
@ -8,7 +8,7 @@
|
||||
<link href="../output.css" rel="stylesheet">
|
||||
</head>
|
||||
|
||||
<body class="dark:bg-gray-800">
|
||||
<body class="dark:bg-gray-800" >
|
||||
<div id="alert-1" class="flex p-4 mb-4 bg-red-100 rounded-lg dark:bg-red-200" role="alert" style="display: none;">
|
||||
<svg class="flex-shrink-0 w-5 h-5 text-red-700 dark:text-red-800" fill="currentColor" viewBox="0 0 20 20"
|
||||
xmlns="http://www.w3.org/2000/svg">
|
||||
@ -105,6 +105,10 @@
|
||||
</script>
|
||||
<script src="../../dist/dropHandler.js"></script>
|
||||
<script>
|
||||
window.onload = function handleDoneLoad(){
|
||||
console.log("Window load finish")
|
||||
ipcRenderer.sendSync("synchronous-message", "finishedLoading");
|
||||
}
|
||||
|
||||
function loadImageFromSource(path) {
|
||||
testImage(path,
|
||||
|
Reference in New Issue
Block a user