Skip to content

Commit

Permalink
perf: ♻️ Remove console log
Browse files Browse the repository at this point in the history
  • Loading branch information
viarotel committed Mar 13, 2024
1 parent a5cbf19 commit 6e25eb7
Show file tree
Hide file tree
Showing 30 changed files with 10 additions and 126 deletions.
2 changes: 0 additions & 2 deletions electron/copilot/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ export default async (mainWindow) => {

if (VITE_DEV_SERVER_URL) {
app.get('/', (ctx) => {
console.log('ctx', ctx.get('wss'))
return ctx.redirect(`${VITE_DEV_SERVER_URL}copilot/index.html`)
})
}
Expand All @@ -34,7 +33,6 @@ export default async (mainWindow) => {
serveStatic({
root: relative('./', `${process.env.DIST}/assets/`),
rewriteRequestPath: (path) => {
console.log('path', path)
return path.replace(/^\/assets/, '/')
},
}),
Expand Down
1 change: 0 additions & 1 deletion electron/events/handles/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ export default (mainWindow) => {
ipcMain.handle(
'show-open-dialog',
async (_, { preset = '', ...options } = {}) => {
// console.log('options', options)
const res = await dialog
.showOpenDialog(options)
.catch(e => console.warn(e))
Expand Down
3 changes: 0 additions & 3 deletions electron/events/tray/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,6 @@ export default (mainWindow) => {
checkboxLabel: await t('close.remember'),
})

// console.log('response', response)
// console.log('checkboxChecked', checkboxChecked)

if (checkboxChecked) {
appStore.set('appCloseCode', response)
}
Expand Down
7 changes: 0 additions & 7 deletions electron/events/updater/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,16 @@ export default (mainWindow) => {

// 触发检查更新(此方法用于被渲染线程调用,例如页面点击检查更新按钮来调用此方法)
ipcMain.on('check-for-update', () => {
console.log('ipcMain:check-for-update')
autoUpdater.checkForUpdates()
})

// 下载更新
ipcMain.on('download-update', () => {
console.log('ipcMain:download-update')
autoUpdater.downloadUpdate()
})

// 安装更新
ipcMain.on('quit-and-install', () => {
console.log('ipcMain:quit-and-install')
setImmediate(() => {
app.isQuiting = true
autoUpdater.quitAndInstall()
Expand All @@ -49,25 +46,21 @@ export default (mainWindow) => {

// 检测到可以更新时
autoUpdater.on('update-available', (ret) => {
console.log('update-available')
mainWindow.webContents.send('update-available', ret)
})

// 检测到不需要更新时
autoUpdater.on('update-not-available', (ret) => {
console.log('update-not-available')
mainWindow.webContents.send('update-not-available', ret)
})

// 更新下载进度
autoUpdater.on('download-progress', (ret) => {
console.log('download-progress')
mainWindow.webContents.send('download-progress', ret)
})

// 当需要更新的内容下载完成后
autoUpdater.on('update-downloaded', (ret) => {
console.log('update-downloaded')
mainWindow.webContents.send('update-downloaded', ret)
})
}
19 changes: 1 addition & 18 deletions electron/exposes/adbkit/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ window.addEventListener('beforeunload', () => {
})

appStore.onDidChange('common.adbPath', async (value, oldValue) => {
console.log('onDidChange.common.adbPath', value)

if (value === oldValue) {
return false
}
Expand Down Expand Up @@ -49,9 +47,6 @@ const spawnShell = async (command, { stdout, stderr } = {}) => {
const spawnPath = appStore.get('common.adbPath') || adbPath
const args = command.split(' ')

console.log('adb.spawnShell.spawnPath', spawnPath)
console.log('adb.spawnShell.args', args)

const spawnProcess = spawn(`"${spawnPath}"`, args, {
env: { ...process.env },
shell: true,
Expand All @@ -61,8 +56,6 @@ const spawnShell = async (command, { stdout, stderr } = {}) => {
spawnProcess.stdout.on('data', (data) => {
const stringData = data.toString()

console.log('spawnProcess.stdout.data:', stringData)

if (stdout) {
stdout(stringData, spawnProcess)
}
Expand Down Expand Up @@ -115,15 +108,14 @@ const disconnect = async (...params) => client.disconnect(...params)
const getDeviceIP = async (id) => {
try {
const { stdout } = await shell(`-s ${id} shell ip -f inet addr show wlan0`)
// console.log('stdout', stdout)
const reg = /inet ([0-9.]+)\/\d+/
const match = stdout.match(reg)
const value = match[1]

console.log('adbkit.getDeviceIP', value)
return value
}
catch (error) {
console.warn('adbkit.getDeviceIP.error', error.message)
return false
}
}
Expand All @@ -135,7 +127,6 @@ const screencap = async (deviceId, options = {}) => {
try {
const device = client.getDevice(deviceId)
fileStream = await device.screencap()
console.log('fileStream', fileStream)
}
catch (error) {
console.warn(error?.message || error)
Expand Down Expand Up @@ -185,8 +176,6 @@ const display = async (deviceId) => {
console.warn(error?.message || error)
}

console.log('display.deviceId.value', value)

return value
}

Expand All @@ -206,8 +195,6 @@ const push = async (

return new Promise((resolve, reject) => {
res.on('progress', (stats) => {
console.log('adb.push.progress', stats)

progress?.(stats)
})

Expand Down Expand Up @@ -248,14 +235,10 @@ const watch = async (callback) => {
export default () => {
const binPath = appStore.get('common.adbPath') || adbPath

console.log('adb.binPath', binPath)

client = Adb.createClient({
bin: binPath,
})

console.log('client', client)

return {
shell,
spawnShell,
Expand Down
12 changes: 0 additions & 12 deletions electron/exposes/gnirehtet/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@ const shell = async (command, { debug = false, stdout, stderr } = {}) => {

const args = command.split(' ')

console.log('gnirehtet.shell.spawnPath', spawnPath)
console.log('gnirehtet.shell.adbPath', adbPath)
console.log('gnirehtet.shell.command', command)

const gnirehtetProcess = spawn(`"${spawnPath}"`, args, {
env: { ...process.env, ADB, GNIREHTET_APK },
shell: true,
Expand All @@ -37,10 +33,6 @@ const shell = async (command, { debug = false, stdout, stderr } = {}) => {
gnirehtetProcess.stdout.on('data', (data) => {
const stringData = data.toString()

if (debug) {
console.log(`${command}.gnirehtet.process.stdout.data:`, stringData)
}

if (stdout) {
stdout(stringData, gnirehtetProcess)
}
Expand All @@ -63,8 +55,6 @@ const shell = async (command, { debug = false, stdout, stderr } = {}) => {

return new Promise((resolve, reject) => {
gnirehtetProcess.on('close', (code) => {
console.log(`${command}.gnirehtet.process.close.code`, code)

if (code === 0) {
resolve()
}
Expand All @@ -91,7 +81,6 @@ const tunnel = deviceId => shell(`tunnel "${deviceId}"`)

const installed = async (deviceId) => {
const res = await adbkit.isInstalled(deviceId, 'com.genymobile.gnirehtet')
console.log('gnirehtet.apk.installed', res)
return res
}

Expand Down Expand Up @@ -136,7 +125,6 @@ const run = async (deviceId) => {
const isInstalled = installed(deviceId)

if (gnirehtetFix || !isInstalled) {
console.log('Installing Gnirehtet Client...')
await install(deviceId).catch((error) => {
throw new Error(error?.message || 'Gnirehtet Install Client fail')
})
Expand Down
13 changes: 0 additions & 13 deletions electron/exposes/scrcpy/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@ const shell = async (command, { stdout, stderr } = {}) => {
const ADB = appStore.get('common.adbPath') || adbPath
const args = command.split(' ')

console.log('scrcpy.shell.spawnPath', spawnPath)
console.log('scrcpy.shell.ADB', ADB)
console.log('scrcpy.shell.args', args)

const scrcpyProcess = spawn(`"${spawnPath}"`, args, {
env: { ...process.env, ADB },
shell: true,
Expand All @@ -26,8 +22,6 @@ const shell = async (command, { stdout, stderr } = {}) => {
scrcpyProcess.stdout.on('data', (data) => {
const stringData = data.toString()

console.log('scrcpyProcess.stdout.data:', stringData)

if (stdout) {
stdout(stringData, scrcpyProcess)
}
Expand Down Expand Up @@ -68,10 +62,6 @@ const execShell = async (command) => {
const spawnPath = appStore.get('common.scrcpyPath') || scrcpyPath
const ADB = appStore.get('common.adbPath') || adbPath

console.log('scrcpy.execShell.spawnPath', spawnPath)
console.log('scrcpy.execShell.ADB', ADB)
console.log('scrcpy.shell.command', command)

const res = exec(`"${spawnPath}" ${command}`, {
env: { ...process.env, ADB },
shell: true,
Expand All @@ -83,7 +73,6 @@ const execShell = async (command) => {

const getEncoders = async (serial) => {
const res = await execShell(`--serial="${serial}" --list-encoders`)
// console.log('getEncoders.res', res)
const stdout = res.stdout

// 提取视频编码器列表
Expand All @@ -105,8 +94,6 @@ const getEncoders = async (serial) => {
video: videoEncoders,
}

console.log('getEncoders.value', value)

return value
}

Expand Down
2 changes: 0 additions & 2 deletions electron/helpers/log.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ const levels = Object.keys(log.functions)

const getFilePath = () => log.transports.file.getFile()?.path

console.log('logPath', getFilePath())

export default {
...createProxy(log, ['initialize', ...levels]),
levels,
Expand Down
4 changes: 0 additions & 4 deletions electron/helpers/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@ import { createProxy } from './index.js'

const appStore = new Store()

// appStore.onDidAnyChange((value) => {
// console.log('appStore.onDidAnyChange.value', value)
// })

// 如果没有数据则手动设置值,以保证配置文件生成成功
if (isEqual(appStore.store, {})) {
appStore.store = {}
Expand Down
4 changes: 0 additions & 4 deletions src/components/About/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ export default {
onUpdateError() {
this.$electron.ipcRenderer.on('update-error', async (_, ret) => {
this.loading = false
console.log('onUpdateError.ret', ret)
try {
await this.$confirm(
this.$t('about.update-error.message'),
Expand All @@ -91,13 +90,11 @@ export default {
},
onDownloadProgress() {
this.$electron.ipcRenderer.on('download-progress', async (event, ret) => {
console.log('ret', ret)
this.percent = ret.percent
})
},
async onUpdateDownloaded() {
this.$electron.ipcRenderer.on('update-downloaded', async (event, ret) => {
console.log('ret', ret)
this.loading = false
try {
await this.$confirm(
Expand All @@ -120,7 +117,6 @@ export default {
this.$electron.ipcRenderer.on('update-available', async (event, ret) => {
this.loading = false
try {
console.log('ret', ret)
await this.$confirm(
ret.releaseNotes,
this.$t('about.update-available.title'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ export default {
async handleCommand(command) {
await sleep(300)
console.log('handleCommand.command', command)
if (command === 'close') {
this.handleStop()
this.loading = false
Expand All @@ -65,8 +63,6 @@ export default {
args: this.scrcpyArgs(this.device.id),
})
console.log('handleCommand.res', res)
res.forEach((item) => {
if (item.status === 'rejected') {
throw item.reason || item
Expand Down
6 changes: 3 additions & 3 deletions src/components/Device/components/MirrorAction/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@ export default {
await mirroring
}
catch (error) {
console.warn(error)
console.error('mirror.args', args)
console.error('mirror.error', error)
if (error.message) {
this.$message.warning(error.message)
}
this.handleReset()
}
},
onStdout() {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ export default {
await mirroring
}
catch (error) {
console.warn(error)
console.error('camera.args', args)
console.error('camera.error', error)
if (error.message) {
this.$message.warning(error.message)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,12 @@ export default {
await mirroring
}
catch (error) {
console.warn(error)
console.error('otg.args', args)
console.error('otg.error', error)
if (error.message) {
this.$message.warning(error.message)
}
this.handleReset()
}
},
onStdout() {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ export default {
this.onRecordSuccess(savePath)
}
catch (error) {
console.warn(error)
console.error('record.args', args)
console.error('record.error', error)
if (error.message) {
this.$message.warning(error.message)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ export function useScrcpy({ vShell, history, loading } = {}) {
let stderrText = ''
$scrcpy.shell(command, {
stdout(text) {
console.log('history', history)
loading.value = false

stdoutText += text
Expand Down
Loading

0 comments on commit 6e25eb7

Please sign in to comment.