Skip to content

Commit

Permalink
feature(App): added ads integration
Browse files Browse the repository at this point in the history
  • Loading branch information
pavloniym committed Jun 20, 2020
1 parent 88676a3 commit c318e41
Show file tree
Hide file tree
Showing 59 changed files with 2,021 additions and 1,504 deletions.
1 change: 0 additions & 1 deletion .electron-vue/webpack.main.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ let mainConfig = {
},
externals: [
...Object.keys(dependencies || {}),
/^firebase/
],

module: {
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ jobs:
env:
ELECTRON_CACHE: ${{ github.workspace }}/.cache/electron
ELECTRON_BUILDER_CACHE: ${{ github.workspace }}/.cache/electron-builder
ADS_URLS: ${{ secrets.ADS_URLS }}
SENTRY_DSN: ${{ secrets.SENTRY_DSN }}
YANDEX_TRACKING_ID: ${{ secrets.YANDEX_TRACKING_ID }}

Expand Down
7 changes: 2 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@
},
"nsis": {
"oneClick": false,
"perMachine": true,
"artifactName": "${productName}-${os}-${version}-setup.${ext}",
"installerSidebar": "build/installer/installerSidebar.bmp",
"deleteAppDataOnUninstall": true,
Expand All @@ -97,19 +98,15 @@
"@sentry/electron": "1.3.0",
"@sentry/integrations": "^5.15.5",
"axios": "^0.19.2",
"axios-https-proxy-fix": "^0.17.1",
"chromecast-api": "^0.3.3",
"electron-promise-ipc": "^2.0.1",
"electron-store": "^5.1.1",
"electron-updater": "^4.2.2",
"firebase": "^7.14.2",
"firebase-admin": "^8.11.0",
"flatted": "^3.0.2",
"form-data": "^3.0.0",
"fuse.js": "^3.4.6",
"hls.js": "^0.13.1",
"https-proxy-agent": "^5.0.0",
"jikan-node": "^1.2.0",
"lethargy": "^1.0.9",
"lodash": "^4.17.15",
"moment": "^2.24.0",
Expand Down Expand Up @@ -162,7 +159,7 @@
"del": "^5.1.0",
"devtron": "^1.4.0",
"dotenv-webpack": "^1.7.0",
"electron": "^8.2.1",
"electron": "^8.2.3",
"electron-builder": "^22.7.0",
"electron-debug": "^3.0.1",
"electron-devtools-installer": "^2.2.4",
Expand Down
16 changes: 4 additions & 12 deletions src/main/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,11 @@ const communications = [
* Set `__static` path to static files in production
* https://simulatedgreg.gitbooks.io/electron-vue/content/en/using-static-assets.html
*/
if (process.env.NODE_ENV !== 'development') // eslint-disable-line
if (process.env.NODE_ENV !== 'development') {
global.__static = require('path').join(__dirname, '/static').replace(/\\/g, '\\\\'); // eslint-disable-line
}

app.commandLine.appendSwitch('disable-site-isolation-trials');

app.on('window-all-closed', () => app.quit());
app.on('ready', async () => {
Expand All @@ -58,11 +60,6 @@ app.on('ready', async () => {
// Main window close event
Main.getWindow().on('close', () => app.quit());

// Set initial fullscreen mode
// Set os
store.dispatch('app/setFullscreen', Main.getWindow().isFullScreen());
store.dispatch('app/setOS');

// Create menu
menuController
.setWindows({main: Main, torrent: Torrent, chromecast: Chromecast})
Expand Down Expand Up @@ -99,14 +96,9 @@ app.on('ready', async () => {
// Set dock number
// If dock is available
ipc.on('app:dock:number', (e, number) => {
if(app.dock) {
if (app.dock) {
app.dock.setBadge(number && number > 0 ? number.toString() : '')
}
});


// Set fullscreen events to main window
Main.getWindow().on('enter-full-screen', () => store.dispatch('app/setFullscreen', true));
Main.getWindow().on('leave-full-screen', () => store.dispatch('app/setFullscreen', false));

});
55 changes: 29 additions & 26 deletions src/main/utils/menu/appMenu.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import store from '@store'
import {meta} from '@package'
import {Menu, shell} from 'electron'


export const aboutTemplate = [
{
role: 'about',
Expand Down Expand Up @@ -30,13 +30,6 @@ export const aboutTemplate = [
{
type: 'separator'
},
{
role: 'togglefullscreen',
label: 'На полный экран',
},
{
type: 'separator'
},
{
role: 'minimize',
label: 'Свернуть приложение',
Expand Down Expand Up @@ -117,29 +110,39 @@ export default class AppMenu {
label: 'Отладка',
submenu: [
{
role: 'forcereload',
label: 'Перезагрузить приложение',
role: 'toggledevtools',
label: 'Консоль приложения',
click: () => this._mainWindow.showDevTools()
},
{
label: 'Консоль торрент-сервер',
click: () => this._torrentWindow.showDevTools()
},
{
type: 'separator'
},
{
label: 'Инструменты разработчика',
submenu: [
{
label: 'Основное приложение',
click: () => this._mainWindow.showDevTools()
},
{
label: 'Торрент-сервер',
click: () => this._torrentWindow.showDevTools()
},
{
label: 'Chromecast клиент',
click: () => this._chromecastWindow.showDevTools()
},
]
}
label: 'Показать тестовое уведомление',
click: () => this._mainWindow.sendToWindow('app:notification', store.state.releases.data[0])
},
{
label: 'Добавить уведомление в хранилище',
click: () => store.dispatch('notifications/setRelease', store.state.releases.data[0])
},
{
type: 'separator'
},
{
label: 'Показать данные хранилища в консоли',
click: () => console.log(store.state),
},
{
type: 'separator'
},
{
role: 'forcereload',
label: 'Перезагрузить приложение',
},
],
}
];
Expand Down
2 changes: 1 addition & 1 deletion src/main/utils/tray/appTray.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {aboutTemplate, devTemplate} from './../menu/appMenu'
import {aboutTemplate} from './../menu/appMenu'
import {Menu, nativeImage, Tray} from "electron";

export default class {
Expand Down
8 changes: 6 additions & 2 deletions src/main/utils/windows/appWindowMain.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,15 @@ class MainWindow extends Window {
titleBarStyle: 'hiddenInset',
useContentSize: true,
webPreferences: {
plugins: true,
webgl: true,
webSecurity: false,
nodeIntegration: true,
experimentalFeatures: true,
allowRunningInsecureContent: true,
enableBlinkFeatures: 'SameSiteDefaultChecksMethodRigorously',
disableBlinkFeatures: 'CookiesWithoutSameSiteMustBeSecure'
},
backgroundColor: '#121212',
disableHtmlFullscreenWindowResize: true,
}
}

Expand Down
1 change: 0 additions & 1 deletion src/renderer/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@
_updates: s => s.updates.enabled,
_timeout: s => (s.updates.timeout > 0 ? s.updates.timeout : 1) * 60 * 1000
})
},
methods: {
Expand Down
6 changes: 3 additions & 3 deletions src/renderer/chromecast.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,11 @@ const playOnDevice = ({device, src, options = null} = {}) => {
console.log('Play On Device', {device, src, options});

// Search for device from local store
device = store.devices.find(d => d.name === device.name);
const player = store.devices.find(d => device && d.name === device.name);

// If device is found
if (device && src) {
device.play(src, options, e => console.log('Player Error: ', e));
if (player && src) {
player.play(src, options, e => console.log('Player Error: ', e));
}

};
Expand Down
4 changes: 1 addition & 3 deletions src/renderer/components/app/errors/AppErrors.vue
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
<script>
import {ipcRenderer as ipc} from 'electron'
export default {
render: () => null,
created() {
ipc.on('app:error', (e, error) =>
this.$electron.ipcRenderer.on('app:error', (e, error) =>
this.$toasted.show(error, {type: 'error'})
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import {meta} from '@package'
import {mapState} from 'vuex'
import {remote, ipcRenderer as ipc} from 'electron'
export default {
render: () => null,
Expand Down Expand Up @@ -33,7 +32,7 @@
created() {
ipc.on('app:notification', (e, release) => {
this.$electron.ipcRenderer.on('app:notification', (e, release) => {
// Check if release is set
// Check if system notifications is enabled
Expand All @@ -48,7 +47,7 @@
if (title && name) {
// Set notification name
remote.app.setAppUserModelId(meta.name);
this.$electron.remote.app.setAppUserModelId(meta.name);
// Create notification
const notification = new window.Notification(title, {
Expand Down
13 changes: 4 additions & 9 deletions src/renderer/components/app/settings/AppSettings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<system-bar-placeholder fixed/>

<!-- Header -->
<v-toolbar flat class="shrink" color="#363636" :class="{'mt-9': !(_is_mac && _is_fullscreen)}">
<v-toolbar flat class="shrink" color="#363636" :class="{'mt-9': !this.isMacOnFullscreen}">
<v-app-bar-nav-icon @click="drawer = false">
<v-icon>mdi-arrow-left</v-icon>
</v-app-bar-nav-icon>
Expand Down Expand Up @@ -50,19 +50,17 @@
import SystemBarPlaceholder from './../systembar/placeholder'
import {AppPlatformMixin} from '@mixins/app'
import {mapState, mapActions} from 'vuex'
export default {
mixins: [AppPlatformMixin],
components: {
Credentials,
SystemBarPlaceholder
},
computed: {
...mapState('app', {
_drawer: s => s.drawer,
_is_mac: s => s.is_mac,
_is_fullscreen: s => s.is_fullscreen,
}),
...mapState('app', {_drawer: s => s.drawer}),
...mapState('app/settings/system', {_devtools: s => s.devtools}),
/**
Expand All @@ -72,14 +70,12 @@
*/
categories() {
return [
PlayerSettings,
SystemSettings,
ConnectionSettings,
ActionsSettings,
AnilibriaSettings,
this._devtools ? DevtoolsSettings : null
].filter(category => category)
},
Expand Down Expand Up @@ -109,7 +105,6 @@
methods: {
...mapActions('app', {_setDrawer: 'setDrawer'}),
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@
import ExitDialog from './dialogs/exit'
import CacheDialog from './dialogs/cache'
import {remote} from 'electron'
export default {
data() {
return {
Expand All @@ -63,17 +61,12 @@
{
title: 'Перезагрузить приложение',
value: this.shortcuts['reload'],
action: () => remote.getCurrentWindow().reload(),
action: () => this.$electron.remote.getCurrentWindow().reload(),
},
{
title: 'Свернуть приложение',
value: this.shortcuts['minimize'],
action: () => remote.getCurrentWindow().minimize(),
},
{
title: 'На полный экран',
value: this.shortcuts['fullscreen'],
action: () => remote.getCurrentWindow().setFullScreen(!remote.getCurrentWindow().isFullScreen()),
action: () => this.$electron.remote.getCurrentWindow().minimize(),
},
{
title: 'Закрыть приложение',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@

<script>
import {remote} from 'electron'
const props = {
attach: {
type: HTMLDivElement,
Expand Down Expand Up @@ -55,7 +53,7 @@
this.loading = true;
this.$store
.dispatchPromise('RESET_STORE')
.then(() => remote.getCurrentWindow().reload())
.then(() => this.$electron.remote.getCurrentWindow().reload())
.finally(() => this.loading = false)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@

<script>
import {remote} from 'electron'
const props = {
attach: {
type: HTMLDivElement,
Expand Down Expand Up @@ -52,7 +50,7 @@
* @return void
*/
exitApp() {
remote.app.exit(0);
this.$electron.remote.app.exit(0);
}
}
Expand Down
Loading

0 comments on commit c318e41

Please sign in to comment.