Skip to content

Commit

Permalink
style: ➖ Remove redundant comments
Browse files Browse the repository at this point in the history
  • Loading branch information
viarotel committed Nov 7, 2024
1 parent 9b7f6a9 commit 05c9766
Showing 1 changed file with 0 additions and 7 deletions.
7 changes: 0 additions & 7 deletions electron/exposes/scrcpy/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,31 +69,25 @@ export function parseScrcpyCodecList(rawText) {
audio: [],
}

// 分行处理
const lines = rawText.split('\n')

// 遍历每一行
for (const line of lines) {
const trimmedLine = line.trim()

// 跳过空行和不包含编码器信息的行
if (!trimmedLine || !trimmedLine.startsWith('--')) {
continue
}

// 提取所有的键值对
const pairs = trimmedLine.match(/--[\w-]+=[\w.-]+/g)
if (!pairs || pairs.length < 2)
continue

// 将键值对转换为对象
const info = pairs.reduce((acc, pair) => {
const [key, value] = pair.substring(2).split('=')
acc[key] = value
return acc
}, {})

// 根据键名判断类型并保存数据
if (info['video-codec'] && info['video-encoder']) {
result.video.push({
type: 'video',
Expand All @@ -110,7 +104,6 @@ export function parseScrcpyCodecList(rawText) {
}
}

// 验证结果是否为空
if (result.video.length === 0 && result.audio.length === 0) {
throw new Error('No valid codec information found in the log content')
}
Expand Down

0 comments on commit 05c9766

Please sign in to comment.