mirror of
https://github.com/geekgeekrun/geekgeekrun.git
synced 2026-06-03 14:40:49 +08:00
add launch login page button. when user click it, will open the login page
This commit is contained in:
@@ -35,7 +35,7 @@ if (!fs.existsSync(extensionDir)) {
|
||||
const editThisCookieZipPath = path.join(__dirname, 'extensions', 'EditThisCookie.zip')
|
||||
const editThisCookieExtensionPath = path.join(extensionDir, 'EditThisCookie')
|
||||
|
||||
async function main() {
|
||||
export async function main() {
|
||||
if (!fs.existsSync(
|
||||
path.join(editThisCookieExtensionPath, 'manifest.json')
|
||||
)) {
|
||||
@@ -80,5 +80,3 @@ async function main() {
|
||||
const { dispose: disposeNavigation } = await blockNavigation(page, (req) => !req.url().startsWith('https://www.zhipin.com'))
|
||||
await page.goto('https://www.zhipin.com/web/user/');
|
||||
}
|
||||
|
||||
main()
|
||||
@@ -14,7 +14,7 @@ export default defineConfig({
|
||||
},
|
||||
plugins: [
|
||||
externalizeDepsPlugin({
|
||||
exclude: ['@geekgeekrun/geek-auto-start-chat-with-boss', '@geekgeekrun/dingtalk-plugin', '@geekgeekrun/utils', 'find-chrome-bin']
|
||||
exclude: ['@geekgeekrun/geek-auto-start-chat-with-boss', '@geekgeekrun/dingtalk-plugin', '@geekgeekrun/utils', 'find-chrome-bin', '@geekgeekrun/launch-bosszhipin-login-page-with-preload-extension']
|
||||
})
|
||||
]
|
||||
},
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
"dev": "electron-vite dev",
|
||||
"dev:geek-auto-start-chat-with-boss-only": "cross-env MAIN_BOSSGEEKGO_UI_RUN_MODE=geekAutoStartWithBoss electron-vite dev",
|
||||
"dev:check-and-download-dependencies-for-init-only": "cross-env MAIN_BOSSGEEKGO_UI_RUN_MODE=checkAndDownloadDependenciesForInit electron-vite dev",
|
||||
"dev:launch-bosszhipin-login-page-with-preload-extension-only": "cross-env MAIN_BOSSGEEKGO_UI_RUN_MODE=launchBossZhipinLoginPageWithPreloadExtension electron-vite dev",
|
||||
"build": "electron-vite build",
|
||||
"format": "prettier --write .",
|
||||
"lint": "eslint . --ext .js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts,.vue --fix",
|
||||
@@ -27,6 +28,7 @@
|
||||
"@electron-toolkit/utils": "^3.0.0",
|
||||
"@geekgeekrun/dingtalk-plugin": "workspace:*",
|
||||
"@geekgeekrun/geek-auto-start-chat-with-boss": "workspace:*",
|
||||
"@geekgeekrun/launch-bosszhipin-login-page-with-preload-extension": "workspace:*",
|
||||
"@geekgeekrun/utils": "workspace:*",
|
||||
"@puppeteer/browsers": "^2.0.0",
|
||||
"JSONStream": "^1.3.5",
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
import { app } from 'electron'
|
||||
import { main } from '@geekgeekrun/launch-bosszhipin-login-page-with-preload-extension'
|
||||
import { pipeWriteRegardlessError } from './utils/pipe'
|
||||
|
||||
export enum DOWNLOAD_ERROR_EXIT_CODE {
|
||||
NO_ERROR = 0,
|
||||
DOWNLOAD_ERROR = 1
|
||||
}
|
||||
|
||||
export const launchBossZhipinLoginPageWithPreloadExtension = async () => {
|
||||
process.on('disconnect', () => app.exit())
|
||||
app.dock?.hide()
|
||||
let pipe: null | fs.WriteStream = null
|
||||
try {
|
||||
pipe = fs.createWriteStream(null, { fd: 3 })
|
||||
} catch {
|
||||
console.warn('pipe is not available')
|
||||
}
|
||||
pipeWriteRegardlessError(
|
||||
pipe,
|
||||
JSON.stringify({
|
||||
type: 'INITIALIZE_PUPPETEER'
|
||||
}) + '\r\n'
|
||||
)
|
||||
const { initPuppeteer } = await import('@geekgeekrun/geek-auto-start-chat-with-boss/index.mjs')
|
||||
try {
|
||||
await initPuppeteer()
|
||||
pipeWriteRegardlessError(
|
||||
pipe,
|
||||
JSON.stringify({
|
||||
type: 'PUPPETEER_INITIALIZE_SUCCESSFULLY'
|
||||
}) + '\r\n'
|
||||
)
|
||||
} catch (err) {
|
||||
console.error(err)
|
||||
app.exit(1)
|
||||
return
|
||||
}
|
||||
|
||||
main()
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
import { runAutoChat } from './flow/GEEK_AUTO_START_CHAT_WITH_BOSS'
|
||||
import { openSettingWindow } from './flow/OPEN_SETTING_WINDOW'
|
||||
import { checkAndDownloadDependenciesForInit } from './flow/CHECK_AND_DOWNLOAD_DEPENDENCIES/index';
|
||||
import { checkAndDownloadDependenciesForInit } from './flow/CHECK_AND_DOWNLOAD_DEPENDENCIES/index'
|
||||
import { launchBossZhipinLoginPageWithPreloadExtension } from './flow/LAUNCH_BOSS_ZHIPIN_LOGIN_PAGE_WITH_PRELOAD_EXTENSION'
|
||||
|
||||
const runMode = process.env.MAIN_BOSSGEEKGO_UI_RUN_MODE
|
||||
switch (runMode) {
|
||||
@@ -12,6 +13,10 @@ switch (runMode) {
|
||||
checkAndDownloadDependenciesForInit()
|
||||
break
|
||||
}
|
||||
case 'launchBossZhipinLoginPageWithPreloadExtension': {
|
||||
launchBossZhipinLoginPageWithPreloadExtension()
|
||||
break
|
||||
}
|
||||
default: {
|
||||
openSettingWindow()
|
||||
break
|
||||
|
||||
@@ -216,6 +216,30 @@ export function createMainWindow(): void {
|
||||
})
|
||||
})
|
||||
|
||||
let subProcessOfBossZhipinLoginPageWithPreloadExtension: ChildProcess | null = null
|
||||
ipcMain.on('launch-bosszhipin-login-page-with-preload-extension', async () => {
|
||||
if (subProcessOfBossZhipinLoginPageWithPreloadExtension) {
|
||||
return
|
||||
}
|
||||
const subProcessEnv = {
|
||||
...process.env,
|
||||
MAIN_BOSSGEEKGO_UI_RUN_MODE: 'launchBossZhipinLoginPageWithPreloadExtension',
|
||||
PUPPETEER_EXECUTABLE_PATH: (await getAnyAvailablePuppeteerExecutable())!.executablePath
|
||||
}
|
||||
subProcessOfBossZhipinLoginPageWithPreloadExtension = childProcess.spawn(
|
||||
process.argv[0],
|
||||
process.argv.slice(1),
|
||||
{
|
||||
env: subProcessEnv,
|
||||
stdio: [null, null, null, 'pipe', 'ipc']
|
||||
}
|
||||
)
|
||||
|
||||
subProcessOfBossZhipinLoginPageWithPreloadExtension!.once('exit', () => {
|
||||
subProcessOfBossZhipinLoginPageWithPreloadExtension = null
|
||||
})
|
||||
})
|
||||
|
||||
mainWindow!.once('closed', () => {
|
||||
mainWindow = null
|
||||
})
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
<!-- <div>操作过程中,本程序缓存的 Boss直聘 Cookie 会被自动更新</div> -->
|
||||
<div>
|
||||
您可
|
||||
<el-button size="small" type="primary" font-size-inherit
|
||||
<el-button size="small" type="primary" font-size-inherit @click="launchLogin"
|
||||
>点击此处打开BOSS直聘登录页</el-button
|
||||
>,按照稍后的提示,使用EditThisCookie复制Cookie,并进行粘贴
|
||||
</div>
|
||||
@@ -127,6 +127,10 @@ const handleExpectCompaniesInputBlur = (event) => {
|
||||
.filter(Boolean)
|
||||
.join(',')
|
||||
}
|
||||
|
||||
const launchLogin = () => {
|
||||
electron.ipcRenderer.send('launch-bosszhipin-login-page-with-preload-extension')
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
|
||||
3
pnpm-lock.yaml
generated
3
pnpm-lock.yaml
generated
@@ -76,6 +76,9 @@ importers:
|
||||
'@geekgeekrun/geek-auto-start-chat-with-boss':
|
||||
specifier: workspace:*
|
||||
version: link:../geek-auto-start-chat-with-boss
|
||||
'@geekgeekrun/launch-bosszhipin-login-page-with-preload-extension':
|
||||
specifier: workspace:*
|
||||
version: link:../launch-bosszhipin-login-page-with-preload-extension
|
||||
'@geekgeekrun/utils':
|
||||
specifier: workspace:*
|
||||
version: link:../utils
|
||||
|
||||
Reference in New Issue
Block a user