fix and ensure the execution sequence of download browser and check cookie file

This commit is contained in:
geekgeekrun
2024-03-04 08:48:06 +08:00
parent f26e2e35bb
commit f71ff9797a
6 changed files with 27 additions and 11 deletions

View File

@@ -26,7 +26,8 @@ const props = defineProps({
dependenciesStatus: {
type: Object as PropType<Record<string, boolean>>,
default: () => ({})
}
},
processWaitee: Object
})
// shallow copy
@@ -75,6 +76,7 @@ const processTasks = async () => {
try {
p.then(() => {
if (!promiseList.length) {
props.processWaitee?.resolve?.()
props.dispose?.()
}
})

View File

@@ -2,7 +2,7 @@ import { createApp } from 'vue'
import ElementPlus from 'element-plus'
import DependenciesSetupProgressIndicatorDialog from './index.vue'
export const mountGlobalDialog = (dependenciesStatus: Record<string, boolean>) => {
export const mountGlobalDialog = (o: { dependenciesStatus: Record<string, boolean>, processWaitee? }) => {
const containerElId = `elForDependenciesSetupProgressIndicatorDialog`
if (document.getElementById(containerElId)) {
@@ -28,7 +28,8 @@ export const mountGlobalDialog = (dependenciesStatus: Record<string, boolean>) =
dispose()
},
dispose,
dependenciesStatus
dependenciesStatus: o?.dependenciesStatus,
processWaitee: o?.processWaitee
}).use(ElementPlus)
app.mount(containerEl)

View File

@@ -117,7 +117,8 @@ import { ref, onUnmounted, onMounted } from 'vue'
import { checkCookieListFormat } from '../../../../common/utils/cookie'
const props = defineProps({
dispose: Function
dispose: Function,
processWaitee: Object
})
const cookieInvalid = ref(false)
@@ -201,6 +202,7 @@ const handleSubmit = async () => {
data: formContent.value.collectedCookies
})
ElMessage.success('Boss直聘 Cookie 保存成功')
props.processWaitee?.resolve?.()
props.dispose()
}

View File

@@ -2,7 +2,7 @@ import { createApp } from 'vue'
import ElementPlus from 'element-plus'
import WaitForLogin from './index.vue'
export const mountGlobalDialog = () => {
export const mountGlobalDialog = (o: { processWaitee? }) => {
const containerElId = `elForWaitForLogin`
if (document.getElementById(containerElId)) {
@@ -28,6 +28,7 @@ export const mountGlobalDialog = () => {
dispose()
},
dispose,
processWaitee: o?.processWaitee
}).use(ElementPlus)
app.mount(containerEl)

View File

@@ -23,12 +23,22 @@ onUnmounted(() => {
;(async () => {
const checkDependenciesResult = await electron.ipcRenderer.invoke('check-dependencies')
if (Object.values(checkDependenciesResult).includes(false)) {
mountDependenciesSetupProgressIndicatorDialog(checkDependenciesResult)
const processWaitee = Promise.withResolvers()
mountDependenciesSetupProgressIndicatorDialog({
checkDependenciesResult, processWaitee
})
await processWaitee.promise
}
const isCookieFileValid = await electron.ipcRenderer.invoke('check-boss-zhipin-cookie-file')
if (!isCookieFileValid) {
mountWaitForLoginDialog()
const processWaitee = Promise.withResolvers()
mountWaitForLoginDialog({
processWaitee
})
await processWaitee.promise
}
})()
</script>

8
pnpm-lock.yaml generated
View File

@@ -1,9 +1,5 @@
lockfileVersion: '6.0'
settings:
autoInstallPeers: true
excludeLinksFromLockfile: false
importers:
.:
@@ -5465,3 +5461,7 @@ packages:
resolution: {integrity: sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==}
engines: {node: '>=10'}
dev: true
settings:
autoInstallPeers: true
excludeLinksFromLockfile: false