mirror of
https://github.com/viarotel-org/escrcpy.git
synced 2024-11-14 18:57:40 +01:00
fix: 🔧 修复自定义路径功能没有生效的问题
This commit is contained in:
parent
517eecd2e1
commit
894b581988
@ -18,8 +18,8 @@ window.addEventListener('beforeunload', () => {
|
||||
}
|
||||
})
|
||||
|
||||
appStore.onDidChange('scrcpy.common.adbPath', async (value, oldValue) => {
|
||||
console.log('onDidChange.scrcpy.common.adbPath', value)
|
||||
appStore.onDidChange('common.adbPath', async (value, oldValue) => {
|
||||
console.log('onDidChange.common.adbPath', value)
|
||||
|
||||
if (value === oldValue) {
|
||||
return false
|
||||
@ -146,7 +146,7 @@ const watch = async (callback) => {
|
||||
}
|
||||
|
||||
export default () => {
|
||||
const binPath = appStore.get('scrcpy.common.adbPath') || adbPath
|
||||
const binPath = appStore.get('common.adbPath') || adbPath
|
||||
|
||||
client = Adb.createClient({
|
||||
bin: binPath,
|
||||
|
@ -3,8 +3,8 @@ import appStore from '@electron/helpers/store.js'
|
||||
import { adbPath, scrcpyPath } from '@electron/configs/index.js'
|
||||
|
||||
const shell = async (command, { stdout, stderr } = {}) => {
|
||||
const spawnPath = appStore.get('scrcpy.common.scrcpyPath') || scrcpyPath
|
||||
const ADB = appStore.get('scrcpy.common.adbPath') || adbPath
|
||||
const spawnPath = appStore.get('common.scrcpyPath') || scrcpyPath
|
||||
const ADB = appStore.get('common.adbPath') || adbPath
|
||||
const args = command.split(' ')
|
||||
|
||||
const scrcpyProcess = spawn(`"${spawnPath}"`, args, {
|
||||
|
@ -1,9 +1,8 @@
|
||||
import { createPinia } from 'pinia'
|
||||
import { useScrcpyStore } from './scrcpy/index.js'
|
||||
import { useDeviceStore } from './device/index.js'
|
||||
import { usePreferenceStore } from './preference/index.js'
|
||||
|
||||
export { useScrcpyStore, useDeviceStore, usePreferenceStore }
|
||||
export { useDeviceStore, usePreferenceStore }
|
||||
|
||||
export default {
|
||||
install(app) {
|
||||
@ -12,7 +11,6 @@ export default {
|
||||
app.use(store)
|
||||
|
||||
app.config.globalProperties.$store = {
|
||||
scrcpy: useScrcpyStore(),
|
||||
device: useDeviceStore(),
|
||||
preference: usePreferenceStore(),
|
||||
}
|
||||
|
@ -1,185 +0,0 @@
|
||||
import { defineStore } from 'pinia'
|
||||
import { cloneDeep, mergeWith } from 'lodash-es'
|
||||
import * as scrcpyModel from './model/index.js'
|
||||
import { replaceIP } from '@/utils/index.js'
|
||||
|
||||
const $appStore = window.appStore
|
||||
|
||||
const { adbPath, scrcpyPath } = window.electron?.configs || {}
|
||||
|
||||
function mergeConfig(object, sources, { debug = false } = {}) {
|
||||
const customizer = (objValue, srcValue) => {
|
||||
if (debug) {
|
||||
console.log('objValue', typeof objValue)
|
||||
console.log('srcValue', typeof srcValue)
|
||||
}
|
||||
|
||||
if (typeof srcValue === 'boolean') {
|
||||
return srcValue
|
||||
}
|
||||
|
||||
return srcValue || objValue
|
||||
}
|
||||
|
||||
const value = mergeWith(cloneDeep(object), cloneDeep(sources), customizer)
|
||||
|
||||
return value
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 Scrcpy 默认配置
|
||||
*/
|
||||
function getDefaultConfig(type) {
|
||||
const model = []
|
||||
if (type) {
|
||||
const handler = scrcpyModel[type]
|
||||
model.push(...handler())
|
||||
}
|
||||
else {
|
||||
// console.raw('scrcpyModel', scrcpyModel)
|
||||
const values = Object.values(scrcpyModel)
|
||||
model.push(...values.flatMap(handler => handler()))
|
||||
}
|
||||
|
||||
const value = model.reduce((obj, item) => {
|
||||
const { field, value } = item
|
||||
obj[field] = value
|
||||
return obj
|
||||
}, {})
|
||||
|
||||
return value
|
||||
}
|
||||
|
||||
export const useScrcpyStore = defineStore({
|
||||
id: 'app-scrcpy',
|
||||
state() {
|
||||
return {
|
||||
scope: $appStore.get('scrcpy.scope') || 'global',
|
||||
model: { ...scrcpyModel },
|
||||
defaultConfig: getDefaultConfig(),
|
||||
config: {},
|
||||
excludeKeys: ['--record-format', 'savePath', 'adbPath', 'scrcpyPath'],
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
replaceIP,
|
||||
getDefaultConfig,
|
||||
init(scope = this.scope) {
|
||||
let tempConfig = mergeConfig(
|
||||
this.defaultConfig,
|
||||
$appStore.get('scrcpy.global') || {},
|
||||
)
|
||||
|
||||
if (scope !== 'global') {
|
||||
const scopeConfig = $appStore.get(`scrcpy.${replaceIP(scope)}`) || {}
|
||||
tempConfig = mergeConfig(tempConfig, scopeConfig)
|
||||
}
|
||||
|
||||
this.config = tempConfig
|
||||
|
||||
return this.config
|
||||
},
|
||||
reset(scope) {
|
||||
if (scope) {
|
||||
this.scope = scope
|
||||
$appStore.set(`scrcpy.${replaceIP(scope)}`, {})
|
||||
}
|
||||
else {
|
||||
this.scope = 'global'
|
||||
$appStore.set('scrcpy', {})
|
||||
}
|
||||
|
||||
this.init()
|
||||
},
|
||||
resetDeps(type) {
|
||||
switch (type) {
|
||||
case 'adb':
|
||||
$appStore.set('scrcpy.common.adbPath', '')
|
||||
break
|
||||
case 'scrcpy':
|
||||
$appStore.set('scrcpy.common.scrcpyPath', '')
|
||||
break
|
||||
default:
|
||||
$appStore.set('scrcpy.common.adbPath', '')
|
||||
$appStore.set('scrcpy.common.scrcpyPath', '')
|
||||
break
|
||||
}
|
||||
this.init()
|
||||
},
|
||||
setScope(value) {
|
||||
this.scope = replaceIP(value)
|
||||
$appStore.set('scrcpy.scope', this.scope)
|
||||
this.init()
|
||||
},
|
||||
getStringConfig(scope = this.scope) {
|
||||
const config = this.getConfig(scope)
|
||||
|
||||
if (!config) {
|
||||
return ''
|
||||
}
|
||||
|
||||
const value = Object.entries(config)
|
||||
.reduce((arr, [key, value]) => {
|
||||
if (!value) {
|
||||
return arr
|
||||
}
|
||||
|
||||
if (this.excludeKeys.includes(key)) {
|
||||
return arr
|
||||
}
|
||||
|
||||
if (typeof value === 'boolean') {
|
||||
arr.push(key)
|
||||
}
|
||||
else {
|
||||
arr.push(`${key}=${value}`)
|
||||
}
|
||||
|
||||
return arr
|
||||
}, [])
|
||||
.join(' ')
|
||||
|
||||
// console.log('stringifyConfig.value', value)
|
||||
|
||||
return value
|
||||
},
|
||||
setConfig(data, scope = this.scope) {
|
||||
const cloneData = cloneDeep(data)
|
||||
|
||||
// console.log('adbPath', adbPath)
|
||||
// console.log('scrcpyPath', scrcpyPath)
|
||||
|
||||
if (data.adbPath === adbPath) {
|
||||
delete cloneData.adbPath
|
||||
}
|
||||
|
||||
if (data.scrcpyPath === scrcpyPath) {
|
||||
delete cloneData.scrcpyPath
|
||||
}
|
||||
|
||||
$appStore.set(`scrcpy.${replaceIP(scope)}`, cloneData)
|
||||
|
||||
this.init(scope)
|
||||
},
|
||||
getConfig(scope = this.scope) {
|
||||
const value = this.init(scope)
|
||||
return value
|
||||
},
|
||||
getModel(key, params) {
|
||||
const handler = this.model[key]
|
||||
const value = handler(params)
|
||||
// console.log('setModel.value', value)
|
||||
|
||||
return value
|
||||
},
|
||||
setModel(key, params) {
|
||||
const handler = this.model[key]
|
||||
const value = handler(params)
|
||||
// console.log('setModel.value', value)
|
||||
|
||||
this.model[key] = () => value
|
||||
|
||||
return this.model
|
||||
},
|
||||
},
|
||||
})
|
@ -1,17 +0,0 @@
|
||||
import { t } from '@/locales/index.js'
|
||||
|
||||
export default () => {
|
||||
// "[server] INFO: List of audio encoders:"
|
||||
// "--audio-codec=opus --audio-encoder='c2.android.opus.encoder'"
|
||||
// "--audio-codec=aac --audio-encoder='c2.android.aac.encoder'"
|
||||
// "--audio-codec=aac --audio-encoder='OMX.google.aac.encoder'"
|
||||
return [
|
||||
{
|
||||
label: t('preferences.audio.disable.name'),
|
||||
field: '--no-audio',
|
||||
type: 'switch',
|
||||
value: false,
|
||||
placeholder: t('preferences.audio.disable.placeholder'),
|
||||
},
|
||||
]
|
||||
}
|
@ -1,39 +0,0 @@
|
||||
import { t } from '@/locales/index.js'
|
||||
|
||||
export default () => {
|
||||
const { adbPath, scrcpyPath, desktopPath } = window?.electron?.configs || {}
|
||||
|
||||
return [
|
||||
{
|
||||
label: t('preferences.common.file.name'),
|
||||
type: 'input.path',
|
||||
field: 'savePath',
|
||||
value: desktopPath,
|
||||
placeholder: t('preferences.common.file.placeholder'),
|
||||
tips: t('preferences.common.file.tips'),
|
||||
properties: ['openDirectory'],
|
||||
},
|
||||
{
|
||||
label: t('preferences.common.adb.name'),
|
||||
field: 'adbPath',
|
||||
type: 'input.path',
|
||||
value: adbPath,
|
||||
placeholder: t('preferences.common.adb.placeholder'),
|
||||
tips: t('preferences.common.adb.tips'),
|
||||
properties: ['openFile'],
|
||||
filters: [{ name: t('preferences.common.adb.name'), extensions: ['*'] }],
|
||||
},
|
||||
{
|
||||
label: t('preferences.common.scrcpy.name'),
|
||||
field: 'scrcpyPath',
|
||||
type: 'input.path',
|
||||
value: scrcpyPath,
|
||||
placeholder: t('preferences.common.scrcpy.placeholder'),
|
||||
tips: t('preferences.common.scrcpy.tips'),
|
||||
properties: ['openFile'],
|
||||
filters: [
|
||||
{ name: t('preferences.common.scrcpy.name'), extensions: ['*'] },
|
||||
],
|
||||
},
|
||||
]
|
||||
}
|
@ -1,44 +0,0 @@
|
||||
import { t } from '@/locales/index.js'
|
||||
|
||||
export default () => {
|
||||
return [
|
||||
{
|
||||
label: t('preferences.device.show-touch.name'),
|
||||
type: 'switch',
|
||||
field: '--show-touches',
|
||||
value: false,
|
||||
placeholder: t('preferences.device.show-touch.placeholder'),
|
||||
tips: t('preferences.device.show-touch.tips'),
|
||||
},
|
||||
{
|
||||
label: t('preferences.device.stay-awake.name'),
|
||||
type: 'switch',
|
||||
field: '--stay-awake',
|
||||
value: false,
|
||||
placeholder: t('preferences.device.stay-awake.placeholder'),
|
||||
tips: t('preferences.device.stay-awake.tips'),
|
||||
},
|
||||
{
|
||||
label: t('preferences.device.control-in-close-screen.name'),
|
||||
type: 'switch',
|
||||
field: '--turn-screen-off',
|
||||
value: false,
|
||||
placeholder: t('preferences.device.control-in-close-screen.placeholder'),
|
||||
},
|
||||
{
|
||||
label: t('preferences.device.control-end-video.name'),
|
||||
type: 'switch',
|
||||
field: '--power-off-on-close',
|
||||
value: false,
|
||||
placeholder: t('preferences.device.control-end-video.placeholder'),
|
||||
},
|
||||
{
|
||||
label: t('preferences.device.control-in-stop-charging.name'),
|
||||
type: 'switch',
|
||||
field: '--no-power-on',
|
||||
value: false,
|
||||
placeholder: t('preferences.device.control-in-stop-charging.placeholder'),
|
||||
tips: t('preferences.device.control-in-stop-charging.tips'),
|
||||
},
|
||||
]
|
||||
}
|
@ -1,6 +0,0 @@
|
||||
export { default as custom } from './custom/index.js'
|
||||
export { default as video } from './video/index.js'
|
||||
export { default as device } from './device/index.js'
|
||||
export { default as window } from './window/index.js'
|
||||
export { default as audio } from './audio/index.js'
|
||||
export { default as record } from './record/index.js'
|
@ -1,23 +0,0 @@
|
||||
import { t } from '@/locales/index.js'
|
||||
|
||||
export default () => {
|
||||
return [
|
||||
{
|
||||
label: t('preferences.record.format.name'),
|
||||
type: 'select',
|
||||
field: '--record-format',
|
||||
value: 'mp4',
|
||||
placeholder: t('preferences.record.format.placeholder'),
|
||||
options: [
|
||||
{
|
||||
label: 'mp4',
|
||||
value: 'mp4',
|
||||
},
|
||||
{
|
||||
label: 'mkv',
|
||||
value: 'mkv',
|
||||
},
|
||||
],
|
||||
},
|
||||
]
|
||||
}
|
@ -1,154 +0,0 @@
|
||||
import { t } from '@/locales/index.js'
|
||||
|
||||
const getDisplayOptions = (display = []) =>
|
||||
display?.map(value => ({ label: value, value })) || []
|
||||
|
||||
export default ({ display } = {}) => {
|
||||
const displayOptions = display?.length
|
||||
? getDisplayOptions(display)
|
||||
: [
|
||||
{ label: '0', value: '0' },
|
||||
{ label: '1', value: '1' },
|
||||
{ label: '2', value: '2' },
|
||||
]
|
||||
|
||||
return [
|
||||
{
|
||||
label: t('preferences.video.resolution.name'),
|
||||
type: 'input.number',
|
||||
field: '--max-size',
|
||||
value: '',
|
||||
placeholder: t('preferences.video.resolution.placeholder'),
|
||||
},
|
||||
{
|
||||
label: t('preferences.video.bit.name'),
|
||||
type: 'input',
|
||||
field: '--video-bit-rate',
|
||||
value: '',
|
||||
placeholder: t('preferences.video.bit.placeholder'),
|
||||
},
|
||||
{
|
||||
label: t('preferences.video.refresh-rate.name'),
|
||||
type: 'input.number',
|
||||
field: '--max-fps',
|
||||
value: '',
|
||||
placeholder: t('preferences.video.refresh-rate.placeholder'),
|
||||
},
|
||||
{
|
||||
label: t('preferences.video.decoder.name'),
|
||||
type: 'select',
|
||||
field: '--video-codec',
|
||||
value: '',
|
||||
placeholder: t('preferences.video.decoder.placeholder'),
|
||||
options: [
|
||||
{
|
||||
label: 'h264',
|
||||
value: 'h264',
|
||||
},
|
||||
{
|
||||
label: 'h265',
|
||||
value: 'h265',
|
||||
},
|
||||
{
|
||||
label: 'av1',
|
||||
value: 'av1',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
label: t('preferences.video.encoder.name'),
|
||||
type: 'select',
|
||||
field: '--video-encoder',
|
||||
value: '',
|
||||
placeholder: t('preferences.video.encoder.placeholder'),
|
||||
// "[server] INFO: List of video encoders:"
|
||||
// "--video-codec=h264 --video-encoder='OMX.qcom.video.encoder.avc'"
|
||||
// "--video-codec=h264 --video-encoder='c2.android.avc.encoder'"
|
||||
// "--video-codec=h264 --video-encoder='OMX.google.h264.encoder'"
|
||||
// "--video-codec=h265 --video-encoder='OMX.qcom.video.encoder.hevc'"
|
||||
// "--video-codec=h265 --video-encoder='c2.android.hevc.encoder'"
|
||||
options: [
|
||||
{
|
||||
label: 'Android HEVC(H.265) ',
|
||||
value: 'OMX.qcom.video.encoder.avc',
|
||||
},
|
||||
{
|
||||
label: 'Qualcomm HEVC(H.265) ',
|
||||
value: 'c2.android.avc.encoder',
|
||||
},
|
||||
{
|
||||
label: 'Google H.264(AVC)',
|
||||
value: 'OMX.google.h264.encoder',
|
||||
},
|
||||
{
|
||||
label: 'Android AVC(H.264) ',
|
||||
value: 'OMX.qcom.video.encoder.hevc',
|
||||
},
|
||||
{
|
||||
label: 'Qualcomm AVC(H.264)',
|
||||
value: 'c2.android.hevc.encoder',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
label: t('preferences.video.screen-rotation.name'),
|
||||
type: 'select',
|
||||
field: '--rotation',
|
||||
value: '',
|
||||
placeholder: t('preferences.video.screen-rotation.placeholder'),
|
||||
options: [
|
||||
{ label: '0°', value: '0' },
|
||||
{ label: '-90°', value: '1' },
|
||||
{ label: '180°', value: '2' },
|
||||
{ label: '90°', value: '3' },
|
||||
],
|
||||
},
|
||||
{
|
||||
label: t('preferences.video.screen-cropping.name'),
|
||||
type: 'input',
|
||||
field: '--crop',
|
||||
value: '',
|
||||
placeholder: t('preferences.video.screen-cropping.placeholder'),
|
||||
},
|
||||
{
|
||||
label: t('preferences.video.multi-display.name'),
|
||||
type: 'select',
|
||||
field: '--display',
|
||||
value: '',
|
||||
placeholder: t('preferences.video.multi-display.placeholder'),
|
||||
options: displayOptions,
|
||||
props: {
|
||||
filterable: true,
|
||||
allowCreate: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
label: t('preferences.video.video-buffering.name'),
|
||||
type: 'input.number',
|
||||
field: '--display-buffer',
|
||||
value: '',
|
||||
placeholder: t('preferences.video.video-buffering.placeholder'),
|
||||
},
|
||||
{
|
||||
label: t('preferences.video.audio-buffering.name'),
|
||||
type: 'input.number',
|
||||
field: '--audio-buffer',
|
||||
value: '',
|
||||
placeholder: t('preferences.video.video-buffering.placeholder'),
|
||||
},
|
||||
{
|
||||
label: t('preferences.video.receiver-buffering.name'),
|
||||
type: 'input.number',
|
||||
field: '--v4l2-buffer',
|
||||
value: '',
|
||||
placeholder: t('preferences.video.video-buffering.placeholder'),
|
||||
},
|
||||
{
|
||||
label: t('preferences.video.disable.name'),
|
||||
type: 'switch',
|
||||
field: '--no-video',
|
||||
value: false,
|
||||
placeholder: t('preferences.video.disable.placeholder'),
|
||||
},
|
||||
]
|
||||
}
|
@ -1,34 +0,0 @@
|
||||
import { t } from '@/locales/index.js'
|
||||
|
||||
export default () => {
|
||||
return [
|
||||
{
|
||||
label: t('preferences.window.borderless.name'),
|
||||
field: '--window-borderless',
|
||||
type: 'switch',
|
||||
value: false,
|
||||
placeholder: t('preferences.window.borderless.placeholder'),
|
||||
},
|
||||
{
|
||||
label: t('preferences.window.full-screen.name'),
|
||||
field: '--fullscreen',
|
||||
type: 'switch',
|
||||
value: false,
|
||||
placeholder: t('preferences.window.full-screen.placeholder'),
|
||||
},
|
||||
{
|
||||
label: t('preferences.window.always-top.name'),
|
||||
field: '--always-on-top',
|
||||
type: 'switch',
|
||||
value: false,
|
||||
placeholder: t('preferences.window.always-top.placeholder'),
|
||||
},
|
||||
{
|
||||
label: t('preferences.window.disable-screen-saver.name'),
|
||||
field: '--disable-screensaver',
|
||||
type: 'switch',
|
||||
value: false,
|
||||
placeholder: t('preferences.window.disable-screen-saver.placeholder'),
|
||||
},
|
||||
]
|
||||
}
|
Loading…
Reference in New Issue
Block a user