Skip to content

Commit

Permalink
Merge pull request #1320 from ipy/airshare
Browse files Browse the repository at this point in the history
Airshare
  • Loading branch information
ipy authored Jul 20, 2020
2 parents 4488546 + 9b1a8dc commit 81e21d7
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 31 deletions.
9 changes: 5 additions & 4 deletions src/main/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -806,10 +806,13 @@ function createAirSharedWindow() {
useContentSize: true,
frame: false,
titleBarStyle: 'none',
minWidth: 300,
maxWidth: 300,
minHeight: 350,
width: 300,
height: 240,
height: 400,
transparent: true,
resizable: false,
resizable: true,
show: false,
webPreferences: {
webSecurity: false,
Expand Down Expand Up @@ -1844,13 +1847,11 @@ function createMainWindow(openDialog, playlistId) {
}
mainWindow.webContents.userAgent = `${mainWindow.webContents.userAgent.replace(/Electron\S+/i, '')} SPlayerX@2018 Platform/${os.platform()} Release/${os.release()} Version/${app.getVersion()} EnvironmentName/${environmentName}`;
menuService.setMainWindow(mainWindow);
setTimeout(() => app.emit('airShared-menu-update'), 50);

mainWindow.on('closed', () => {
ipcMain.removeAllListeners(); // FIXME: decouple mainWindow and ipcMain
mainWindow = null;
menuService.setMainWindow(null);
app.emit('airShared-menu-update');
});

mainWindow.once('ready-to-show', () => {
Expand Down
4 changes: 3 additions & 1 deletion src/main/menu/MenuService.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ipcMain } from 'electron';
import { app, ipcMain } from 'electron';
import { IBrowsingHistoryMenuInfo } from '@/interfaces/IBrowsingHistory';
import Menu from './Menu';
import { IMenuDisplayInfo } from '../../renderer/interfaces/IRecentPlay';
Expand All @@ -15,6 +15,7 @@ export default class MenuService {
this.menu.setMainWindow(window);
if (window) this.registeMenuActions();
else this.menu.closedMenu();
setTimeout(() => app.emit('airShared-menu-update'), 50);
}

public enableMenu(enable: boolean) {
Expand Down Expand Up @@ -44,6 +45,7 @@ export default class MenuService {
});
ipcMain.on('update-locale', () => {
this.menu.updateLocale();
setTimeout(() => app.emit('airShared-menu-update'), 50);
});
ipcMain.on('update-browisng-history', (e: Event, items: IBrowsingHistoryMenuInfo[]) => {
this.menu.updateBrowsingHistory(items);
Expand Down
86 changes: 62 additions & 24 deletions src/renderer/components/AirShared.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,32 +27,43 @@
class="win-title-button no-drag"
type="titleBarWinClose"
/>
<div class="info">
<div>
<span class="label">{{ $t('msg.file.airShared.status') }}:</span>
<span>{{ info.enabled ? $t('msg.file.airShared.on') : $t('msg.file.airShared.off') }}</span>
<div class="main">
<div class="file">
<div class="title">
{{ $t('msg.file.airShared.title') }}:
</div>
{{ info.filePath }}
</div>
<div>
<span class="label">{{ $t('msg.file.airShared.host') }}:</span>
<span>{{ info.host }}</span>
<div class="info">
<div>
<span class="label">{{ $t('msg.file.airShared.status') }}:</span>
<span>
{{ info.enabled ? $t('msg.file.airShared.on') : $t('msg.file.airShared.off') }}
</span>
</div>
<div>
<span class="label">{{ $t('msg.file.airShared.host') }}:</span>
<span>{{ info.host }}</span>
</div>
<div>
<span class="label">{{ $t('msg.file.airShared.token') }}:</span>
<span class="special">
{{ token }}
</span>
</div>
</div>
<div>
<span class="label">{{ $t('msg.file.airShared.token') }}:</span>
<span class="special">
{{ info.code.slice(0, info.code.length - 5) }}
{{ info.code.slice(info.code.length - 5, info.code.length) }}
</span>
<div class="tip">
<p>{{ $t('msg.file.airShared.tip') }}</p>
<p>{{ $t('msg.file.airShared.tipWnB') }}</p>
</div>
</div>
<div class="tip">
{{ $t('msg.file.airShared.tip') }}
</div>
</div>
</template>

<script lang="ts">
import Vue from 'vue';
import { ipcRenderer, remote } from 'electron';
import path from 'path';
import qs from 'querystring';
import Icon from '@/components/BaseIconContainer.vue';
Expand All @@ -75,6 +86,19 @@ export default Vue.extend({
isDarwin() {
return process.platform === 'darwin';
},
token() {
if (!this.info.code) return '';
const code = this.info.code.toString();
const res = [];
for (let i = 0; i < code.length; i += 1) {
res.push(code[i]);
if ((i + 1) % 4 === 0 && i < code.length - 1) res.push(' ');
}
return res.join('');
},
fileName() {
return this.info.filePath ? path.basename(this.info.filePath) : '';
},
},
mounted() {
document.title = 'Air Shared';
Expand Down Expand Up @@ -102,6 +126,7 @@ export default Vue.extend({
border-radius: 4px;
display: flex;
flex-direction: column;
font-family: $font-medium;
.mac-icons {
position: absolute;
top: 12px;
Expand Down Expand Up @@ -138,14 +163,14 @@ export default Vue.extend({
}
}
}
.info {
.main {
width: 80%;
margin: 50px auto 0;
margin: 40px auto 0;
}
.info {
font-size: 16px;
color: rgba(255, 255, 255, 0.7);
opacity: 0.7;
line-height: 1.75em;
font-weight: 700;
&>div {
display: flex;
}
Expand All @@ -156,12 +181,25 @@ export default Vue.extend({
color: white;
}
}
.file {
.title {
font-size: 16px;
margin-bottom: 5px;
color: rgba(255, 255, 255, 0.7);
}
word-break: break-all;
margin: 10px auto;
font-size: 12px;
color: rgba(255,255,255,0.25);
line-height: 1.5em;
}
.tip {
width: 80%;
p {
margin: 10px auto;
}
margin: 20px auto;
font-size: 11px;
font-size: 12px;
color: rgba(255,255,255,0.25);
line-height: 1.5em;
color: white;
opacity: 0.7;
}
</style>
1 change: 1 addition & 0 deletions src/renderer/components/Bubbles/ResolvedBubble.vue
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ export default {
}
.content {
white-space: pre-line;
word-break: break-all;
color: rgba(255, 255, 255, 0.5);
font-size: 11px;
line-height: 14px;
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/helpers/notificationControl.js
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ export function addBubble(code, options = {}) { // eslint-disable-line complexit
handler: () => {
remote.app.emit('add-window-airshared');
},
dismissAfter: 10000,
dismissAfter: 20000,
});
break;
case AIRSHARED_STOP:
Expand Down
4 changes: 3 additions & 1 deletion src/renderer/locales/lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,14 @@
"stop": "Stop Sharing",
"sharing": "Air Shared and Streaming:",
"stopped": "Air Sharing Stopped",
"title": "Now Streaming",
"status": "Status",
"on": "Running",
"off": "Stopped",
"host": "IP Address",
"token": "Token",
"tip": "Open SPlayer on your Apple TV or iPad / iPhone within the same network and tap \"DISCOVERY\" to streaming your video with the best quality"
"tip": "Open SPlayer on your Apple TV or iPad / iPhone within the same network and tap \"DISCOVERY\" to streaming your video with the best quality",
"tipWnB": "Please make sure your device is connected to Wi-Fi and Bluetooth is turned on."
}
},
"account": {
Expand Down

0 comments on commit 81e21d7

Please sign in to comment.