Commit e947eb47 authored by SpinShare's avatar SpinShare

added build settings, added deeplinks

parent 88725d89
{
"name": "spinshare-client",
"productName": "SpinSha.re",
"description": "SpinSha.re Client",
"homepage": "https://spinsha.re",
"copyright": "Copyright © SpinSha.re",
"version": "2.0.0",
"author": "SpinSha.re",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
......@@ -15,12 +20,10 @@
"adm-zip": "^0.4.14",
"axios": "^0.19.2",
"core-js": "^3.6.4",
"electron-download-manager": "^2.1.2",
"glob": "^7.1.6",
"ncp": "^2.0.0",
"rimraf": "^3.0.2",
"uniqid": "^5.2.0",
"unzipper": "^0.10.11",
"vue": "^2.6.11",
"vue-axios": "^2.1.5",
"vue-i18n": "^8.17.4",
......
......@@ -58,6 +58,22 @@
e.preventDefault();
});
ipcRenderer.send("getDeeplink");
ipcRenderer.on('deeplink', (event, data) => {
console.log(data);
switch(data.view) {
case "Settings":
this.$router.push('Settings');
break;
case "SongDetail":
this.$router.push({ name: 'SongDetail', params: { id: data.data } });
break;
case "UserDetail":
this.$router.push({ name: 'UserDetail', params: { id: data.data } });
break;
}
});
this.$root.$on('download', (url) => {
this.addToQueue(url);
});
......
const { app, protocol, BrowserWindow, ipcMain } = require('electron');
const DownloadManager = require("electron-download-manager");
const { app, protocol, BrowserWindow, ipcMain, dialog } = require('electron');
const { createProtocol } = require('vue-cli-plugin-electron-builder/lib');
const isDevelopment = process.env.NODE_ENV !== 'production';
const fs = require('fs');
......@@ -8,17 +7,58 @@ const path = require('path');
const uniqid = require('uniqid');
let win;
let deeplinkingUrl;
let deeplinkingType;
let deeplinkingData;
let deeplinkingView;
const gotTheLock = app.requestSingleInstanceLock();
if (!gotTheLock) {
app.quit();
} else {
app.on('open-url', function (event, data) {
event.preventDefault();
executeDeeplink(data);
});
app.on('second-instance', (event, commandLine, workingDirectory) => {
let fullCommand = "";
if (process.platform == 'win32') {
let commandLineString = commandLine.slice(1) + '';
let commandLineArgs = commandLineString.split(",");
fullCommand = commandLineArgs[commandLineArgs.length - 1];
}
executeDeeplink(fullCommand);
});
}
function executeDeeplink(deeplink) {
if(deeplink.includes("spinshare-song")) {
deeplinkingView = "SongDetail";
deeplinkingData = deeplink.replace("spinshare-song://", "").replace("/", "");
} else if(deeplink.includes("spinshare-user")) {
deeplinkingView = "UserDetail";
deeplinkingData = deeplink.replace("spinshare-user://", "").replace("/", "");
}
if (win) {
if (win.isMinimized()) win.restore();
win.focus();
win.webContents.send("deeplink", {
view: deeplinkingView,
data: deeplinkingData
});
}
}
DownloadManager.register({
downloadFolder: app.getPath("temp")
});
protocol.registerSchemesAsPrivileged([{scheme: 'app', privileges: { secure: true, standard: true } }]);
protocol.registerSchemesAsPrivileged([{scheme: 'app', privileges: { secure: true, standard: true } }]);
protocol.registerSchemesAsPrivileged([{scheme: 'app', privileges: { secure: true, standard: true } }]);
app.setAsDefaultProtocolClient("spinshare-song");
app.setAsDefaultProtocolClient("spinshare-user");
function createWindow () {
win = new BrowserWindow({
title: "SpinSha.re",
......@@ -41,6 +81,12 @@ function createWindow () {
win.setMenuBarVisibility(false);
if (process.platform == 'win32') {
if(process.argv.length > 1) {
executeDeeplink(process.argv[1]);
}
}
win.on('closed', () => {
win = null;
});
......@@ -104,6 +150,13 @@ ipcMain.on("download", (event, ipcData) => {
});
});
ipcMain.on("getDeeplink", (event) => {
win.webContents.send("deeplink", {
view: deeplinkingView,
data: deeplinkingData
});
});
function download(url, fileName, cb) {
let dest = path.join(app.getPath('temp'), fileName + ".zip");
let file = fs.createWriteStream(dest);
......
......@@ -3,10 +3,11 @@ import App from './App.vue';
import router from './router';
import store from './store';
import i18n from './i18n';
import { ipcRenderer } from 'electron';
Vue.config.productionTip = false;
new Vue({
window.VueRoot = new Vue({
router,
store,
i18n,
......
module.exports = {
pluginOptions: {
electronBuilder: {
builderOptions: {
productName: "SpinShare",
appId: "re.spinsha.client",
protocols: {
name: "spinshare-song-deeplink",
schemes: [
"spinshare-song",
"spinshare-user"
]
},
win: {
icon: "build/icons_AppIcon.ico"
},
nsis: {
oneClick: false,
allowToChangeInstallationDirectory: true
},
mac: {
category: "public.app-category.music-games",
target: "dmg",
icon: "build/AppIcon.icns"
},
dmg: {
backgroundColor: "#212629"
}
}
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment