Skip to content

Commit

Permalink
[feat] access the debug platform(PageSpy)
Browse files Browse the repository at this point in the history
  • Loading branch information
Hiram committed Jul 19, 2024
1 parent b1ca398 commit 97ccdc7
Show file tree
Hide file tree
Showing 9 changed files with 44 additions and 3 deletions.
8 changes: 8 additions & 0 deletions src/main/core/db/init/tbl_setting.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,5 +89,13 @@
"key": "",
"model": ""
}
},
{
"key": "defaultFilterType",
"value": "off"
},
{
"key": "debug",
"value": false
}
]
1 change: 1 addition & 0 deletions src/main/core/db/magrite/data/update3_3_6_to3_3_7.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const update3_3_6_to3_3_7 = () => {
db.get(TABLE_NAME).remove({ key: 'defaultFilterType' }).write();
};
db.get(TABLE_NAME).insert({ key: 'defaultFilterType', value: 'off' }).write();
db.get(TABLE_NAME).insert({ key: 'debug', value: false }).write();

db.get(TABLE_NAME).find({ key: 'version' }).assign({ key: 'version', value: '3.3.7' }).write();
logger.info('[db][magrite][update3_3_6_to3_3_7]completed');
Expand Down
2 changes: 2 additions & 0 deletions src/main/core/server/routes/setting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ const api: FastifyPluginAsync = async (fastify): Promise<void> => {
const webdev = await setting.find({ key: 'webdev' }).value;
const barrage = await setting.find({ key: 'barrage' }).value;
const timeout = await setting.find({ key: 'timeout' }).value;
const debug = await setting.find({ key: 'debug' }).value;

const res = {
agreementMask,
Expand All @@ -83,6 +84,7 @@ const api: FastifyPluginAsync = async (fastify): Promise<void> => {
webdev,
barrage,
timeout,
debug,
};
reply.code(200).send(res);
} catch (err) {
Expand Down
4 changes: 3 additions & 1 deletion src/main/utils/pie.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { app, BrowserWindow } from 'electron';
import { nanoid } from 'nanoid';
import puppeteer from 'puppeteer-core';
import pie from 'puppeteer-in-electron';
import { setting } from '../core/db/service';
import logger from '../core/logger';

interface PieResponse {
Expand Down Expand Up @@ -55,7 +56,8 @@ const puppeteerInElectron = async (

try {
const browser = await pie.connect(app, puppeteer as any); // 连接puppeteer
snifferWindow = new BrowserWindow({ show: false }); // 创建无界面窗口
const debugStatus = setting.find({ key: 'debug' })?.value || false;
snifferWindow = new BrowserWindow({ show: debugStatus }); // 创建无界面窗口
snifferWindow.webContents.setAudioMuted(true); // 设置窗口静音
snifferWindow.webContents.setWindowOpenHandler(() => {
return { action: 'deny' };
Expand Down
17 changes: 16 additions & 1 deletion src/renderer/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { usePlayStore, useSettingStore } from '@/store';
import { setup } from '@/api/setting';
import PLAY_CONFIG from '@/config/play';
import { autoSync } from '@/utils/webdev';
import { loadExternalResource } from '@/utils/tool';
import DisclaimerView from '@/pages/Disclaimer.vue';
Expand Down Expand Up @@ -64,7 +65,7 @@ onMounted(() => {
});
const initConfig = async () => {
const { agreementMask, theme, playerMode, webdev, barrage, timeout } = await setup();
const { agreementMask, theme, playerMode, webdev, barrage, timeout, debug } = await setup();
storeSetting.updateConfig({ mode: theme });
storeSetting.updateConfig({ webdev: webdev });
Expand All @@ -77,6 +78,20 @@ const initConfig = async () => {
init.playerMode = playerMode;
init.barrage = barrage;
storePlayer.updateConfig({ setting: init });
if (debug) {
const status = await loadExternalResource('https://test.jikejishu.com/page-spy/index.min.js', 'js');
console.log(status)
if (status) {
window.$pageSpy = new PageSpy({
api: 'test.jikejishu.com',
clientOrigin: 'https://test.jikejishu.com',
project: 'zyplayer',
autoRender: true,
title: 'zyplayer for debug',
});
}
}
}
window.electron.ipcRenderer.on('system-theme-updated', (_, activeTheme) => {
Expand Down
1 change: 1 addition & 0 deletions src/renderer/src/locales/lang/en_US/pages/setting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ export default {
selefBoot: 'SelefBoot',
hardwareAcceleration: 'HardwareAcceleration',
windowPosition: 'WindowPosition',
debug: 'Debug',
other: 'Other',
restoreFactory: 'RestoreFactory',
dataMange: 'DataMange',
Expand Down
1 change: 1 addition & 0 deletions src/renderer/src/locales/lang/zh_CN/pages/setting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ export default {
selefBoot: '自启动',
hardwareAcceleration: '硬件加速',
windowPosition: '窗口位置',
debug: '调试',
other: '其他',
restoreFactory: '恢复出厂',
dataMange: '数据管理',
Expand Down
11 changes: 10 additions & 1 deletion src/renderer/src/pages/setting/base/BaseSetting.vue
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,9 @@
<t-radio v-model="formData.windowPosition.status" allow-uncheck @change="windowPositionEvnet">
{{ $t('pages.setting.base.windowPosition') }}
</t-radio>
<t-radio v-model="formData.debug" allow-uncheck @change="debugEvnet">
{{ $t('pages.setting.base.debug') }}
</t-radio>
</t-space>
</t-form-item>
<t-form-item :label="$t('pages.setting.base.other')" name="other">
Expand Down Expand Up @@ -302,7 +305,8 @@ const formData = ref({
ua: '',
communitySubscribe: '',
webdev: { sync: false, data: { url: "https://dav.jianguoyun.com/dav/", username: "", password: "" } },
windowPosition: { status: false, position: { width: 1000, height: 640 } }
windowPosition: { status: false, position: { width: 1000, height: 640 } },
debug: false
});
const tmp = reactive({
Expand Down Expand Up @@ -639,6 +643,11 @@ const windowPositionEvnet = () => {
);
};
const debugEvnet = () => {
console.log('调试', formData.value.debug);
window?.location.reload();
};
// ua:打开dialog并设置数据
const uaEvnet = () => {
const { ua } = formData.value;
Expand Down
2 changes: 2 additions & 0 deletions src/renderer/src/pages/setting/base/components/DialogData.vue
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,8 @@ const formatSet = (data) => {
model: ""
}
},
{ key: "defaultFilterType", value: "off" },
{ key: "debug", value: false },
{ key: "version", value: pkgVersion },
// ... 其他新键值对
];
Expand Down

0 comments on commit 97ccdc7

Please sign in to comment.