Skip to content

Commit

Permalink
fixed: Fix stack overflow
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhaoJiSen committed Nov 6, 2024
1 parent 61a217f commit ec3171e
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 144 deletions.
5 changes: 0 additions & 5 deletions electron/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { Readable } from 'stream';
import { createGunzip } from 'zlib';
import { fileURLToPath } from 'node:url';
import { createReadStream, createWriteStream, unlink } from 'fs';
import install, { VUEJS3_DEVTOOLS } from 'electron-devtools-installer';

import { app, ipcMain } from 'electron';
import { BrowserWindow } from 'electron';
Expand Down Expand Up @@ -132,10 +131,6 @@ app.on('window-all-closed', () => {
if (process.platform !== 'darwin') app.quit();
});

app.on('ready', () => {
install(VUEJS3_DEVTOOLS).then((_r: string) => {});
});

app.on('activate', () => {
if (BrowserWindow.getAllWindows().length === 0) {
createWindow();
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@
},
"linux": {
"icon": "assets",
"target": ["zip"]
"target": [
"zip"
]
}
},
"dependencies": {
Expand Down Expand Up @@ -90,7 +92,6 @@
"@vitejs/plugin-vue": "^5.1.2",
"electron": "^32.0.1",
"electron-builder": "^24.13.3",
"electron-devtools-installer": "^3.2.0",
"eslint": "^9.9.1",
"naive-ui": "^2.39.0",
"prettier": "^3.3.3",
Expand Down
13 changes: 9 additions & 4 deletions src/layouts/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,23 @@
<Header @back="handleBack" />
</n-layout-header>
<n-divider />
<n-layout-content w-full main-bg-base class="h-[calc(100%-56px)]">
<n-grid :cols="12" h-full w-full>
<n-layout-content
w-full
main-bg-base
class="h-[calc(100%-56px)]"
content-style="overflow: hidden"
>
<n-grid :cols="12" w-full style="height: calc(100vh - 60px)">
<n-gi :span="8">
<n-flex h-full justify="center" align="center">
<n-flex justify="center" align="center" style="height: 100%">
<Upload v-if="!showPlayer" @parser="handleParser" />
<template v-else>
<router-view :key="route.fullPath"></router-view>
</template>
</n-flex>
</n-gi>
<n-gi :span="4">
<n-flex h-full justify="center" align="center">
<n-flex justify="center" align="center" style="height: 100%">
<SliceList
@play="handlePlay"
:json-file="currentPartJsonFile"
Expand Down
50 changes: 40 additions & 10 deletions src/views/guaPlayer/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
<template #description> {{ t('parsing') }} </template>
</n-spin>
</n-space>
<div id="guacamolePlayer" w-730px h-520px></div>
<n-flex align="center" :wrap="false" w-full px-10px>
<div id="guacamolePlayer" w-full style="height: 90%"></div>
<n-flex align="center" :wrap="false" w-full px-10px style="height: 10%">
<n-flex :wrap="false" w-160px align="center">
<n-button
v-if="!isPlaying"
Expand Down Expand Up @@ -44,7 +44,7 @@
import { useI18n } from 'vue-i18n';
import { useRoute } from 'vue-router';
import { useMessage } from 'naive-ui';
import { computed, onMounted, onUnmounted, ref, onBeforeUnmount } from 'vue';
import { computed, onBeforeUnmount, onMounted, onUnmounted, ref } from 'vue';
import { PlayCircleOutline, StopCircleOutline } from '@vicons/ionicons5';
// @ts-ignore
import * as Guacamole from 'guacamole-common-js-jumpserver/dist/guacamole-common';
Expand All @@ -60,6 +60,7 @@ let tunnel: any;
let recording: any;
let display: any;
const scale = ref(0);
const max = ref(100);
const currentPercent = ref(0);
const chunks = ref('');
Expand Down Expand Up @@ -101,8 +102,7 @@ const loadResource = async (record: any) => {
record.connect(chunks.value);
chunks.value = '';
initRecordingEvent(record);
record.play();
initRecordingEvent(record, el);
});
window.electron.onFileDataError(() => {
Expand All @@ -111,7 +111,7 @@ const loadResource = async (record: any) => {
});
};
const initRecordingEvent = record => {
const initRecordingEvent = (record, el: HTMLElement) => {
record.onerror = (message: string) => {
console.log('Error occurred: ' + message);
};
Expand All @@ -132,11 +132,40 @@ const initRecordingEvent = record => {
record.play();
// todo))
display.scale(0.42);
const parentEl = el.parentElement as HTMLElement;
max.value = record.getDuration();
totalDuration.value = formatTime(record.getDuration());
setTimeout(() => {
if (parentEl) {
const parentWidth = parentEl.offsetWidth;
const parentHeight = parentEl.offsetHeight;
let width = display.getDefaultLayer().width;
let height = display.getDefaultLayer().height;
if (width >= 3000) {
width = width / 2;
}
if (width <= 700) {
height = 1060;
}
const targetWidth = parentWidth;
const targetHeight = parentHeight;
const scaleWidth = targetWidth / width;
const scaleHeight = targetHeight / height;
scale.value = Math.min(scaleWidth, scaleHeight);
} else {
console.log('No parent element found');
}
display.scale(scale.value);
max.value = record.getDuration();
totalDuration.value = formatTime(record.getDuration());
}, 100);
};
/**
Expand Down Expand Up @@ -241,6 +270,7 @@ onBeforeUnmount(() => {
recording.disconnect();
tunnel = null;
recording = null;
chunks.value = '';
Expand Down
Loading

0 comments on commit ec3171e

Please sign in to comment.