perf: ♻️ Remove console log

This commit is contained in:
viarotel 2024-03-13 11:03:50 +08:00
parent a5cbf194cc
commit 6e25eb7ad6
30 changed files with 10 additions and 126 deletions

View File

@ -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`)
})
}
@ -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/, '/')
},
}),

View File

@ -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))

View File

@ -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)
}

View File

@ -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()
@ -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)
})
}

View File

@ -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
}
@ -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,
@ -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)
}
@ -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
}
}
@ -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)
@ -185,8 +176,6 @@ const display = async (deviceId) => {
console.warn(error?.message || error)
}
console.log('display.deviceId.value', value)
return value
}
@ -206,8 +195,6 @@ const push = async (
return new Promise((resolve, reject) => {
res.on('progress', (stats) => {
console.log('adb.push.progress', stats)
progress?.(stats)
})
@ -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,

View File

@ -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,
@ -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)
}
@ -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()
}
@ -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
}
@ -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')
})

View File

@ -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,
@ -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)
}
@ -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,
@ -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
// 提取视频编码器列表
@ -105,8 +94,6 @@ const getEncoders = async (serial) => {
video: videoEncoders,
}
console.log('getEncoders.value', value)
return value
}

View File

@ -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,

View File

@ -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 = {}

View File

@ -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'),
@ -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(
@ -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'),

View File

@ -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
@ -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

View File

@ -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() {},

View File

@ -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)

View File

@ -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() {},

View File

@ -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)

View File

@ -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

View File

@ -85,9 +85,6 @@ export default {
])
const onOpen = () => {
console.log('vShell.value', vShell.value)
console.log('history.value', history.value)
renderShell.value = true
}
@ -114,12 +111,9 @@ export default {
watch: {
'vShell.signals': {
handler(value) {
console.log('vShell.signals.value', value)
value.off('SIGINT')
value.on('SIGINT', () => {
console.log('vShell.signals.on.SIGINT')
this.onCtrlC()
})
},
@ -135,8 +129,6 @@ export default {
},
onDispatchedQueriesUpdate(value) {
console.log('onDispatchedQueriesUpdate.value', value)
this.$appStore.set('terminal.dispatchedQueries', Array.from(value))
this.dispatchedQueries = value

View File

@ -101,7 +101,6 @@ export default {
try {
await this.$refs.elForm.validate()
const command = `pair ${this.formData.host}:${this.formData.port} ${this.formData.pair}`
// console.log(command)
await this.$adb.shell(command)
this.$emit('success')
this.handleClose()

View File

@ -98,15 +98,12 @@ export default {
return this.handleConnect(...args)
},
onSelect({ host, port }) {
// console.log('onSelect.value', value)
Object.assign(this.formData, {
host,
port,
})
},
fetchSuggestions(value, callback) {
// console.log('fetchSuggestions.value', value)
let results = []
if (value) {

View File

@ -62,8 +62,6 @@ export default {
await sleep()
console.log('host:port', `${host}:${port}`)
this.handleConnect({
host,
port,

View File

@ -140,8 +140,6 @@ export default {
this.getDeviceData()
this.unAdbWatch = await this.$adb.watch(async (type, ret) => {
console.log('adb.watch.ret', ret)
if (ret && ret.id) {
this.getDeviceData()
}
@ -220,8 +218,6 @@ export default {
$recordLoading: false,
$stopLoading: false,
})) || []
console.log('getDeviceData.data', this.deviceList)
}
catch (error) {
console.warn(error)

View File

@ -81,8 +81,6 @@ export default {
value,
}
})
console.log('AudioCodecSelect.deviceOptions', this.deviceOptions)
},
},
}

View File

@ -78,8 +78,6 @@ export default {
value: item,
}
}) || []
console.log('DisplaySelect.deviceOptions', this.deviceOptions)
},
},
}

View File

@ -81,8 +81,6 @@ export default {
value,
}
})
console.log('VideoCodecSelect.deviceOptions', this.deviceOptions)
},
},
}

View File

@ -31,7 +31,6 @@ export default {
async getSvgComponent() {
const module = await import(`../svg/${this.name}.svg?component`)
this.SvgComponent = module.default.render()
// console.log('this.SvgComponent', this.SvgComponent)
},
},
render() {

View File

@ -5,10 +5,6 @@ const locale
= window.appStore?.get('common.language')
|| window.electron?.process?.env?.LOCALE
// const locale = 'en_US'
// console.log('locale', locale)
export const i18n = createI18n({
allowComposition: false,
locale,
@ -17,6 +13,5 @@ export const i18n = createI18n({
fallbackWarn: false,
missingWarn: false,
})
// console.log('i18n', i18n)
export const t = i18n.global.t

View File

@ -44,5 +44,3 @@ app.mount('#app').$nextTick(() => {
// Remove Preload scripts loading
postMessage({ payload: 'removeLoading' }, '*')
})
console.log('electron', window.electron)

View File

@ -27,8 +27,6 @@ export function getModelMap(data = model) {
return obj
}, {})
// console.log('getModelMap.value', value)
return value
}
@ -42,8 +40,6 @@ export function getDefaultData(parentId) {
return obj
}, {})
// console.log('getDefaultData.value', value)
return value
}
@ -60,8 +56,6 @@ export const getStoreData = (scope) => {
Object.assign(value, storeValue)
})
// console.log('getStoreData.value', value)
return value
}
@ -91,8 +85,6 @@ export function setStoreData(data, scope) {
return arr
}, [])
// console.log('setStoreData.storeList', storeList)
storeList.forEach((item) => {
window.appStore.set(item.field, item.value)
})

View File

@ -137,8 +137,6 @@ export const usePreferenceStore = defineStore({
) {
const data = this.getData(scope)
console.log('getScrcpyArgs.data', data)
if (!data) {
return ''
}
@ -190,13 +188,10 @@ export const usePreferenceStore = defineStore({
const value = valueList.join(' ')
console.log('getScrcpyArgs.value', value)
return value
},
getModel(path) {
const value = get(this.model, path)
// console.log('getModel.value', value)
return value
},

View File

@ -70,7 +70,5 @@ systemTheme('change', async ({ isDark, value }) => {
return
}
console.log('systemTheme.change.isDark', isDark)
themeStore.update(value)
})