migrate DependenciesSetupProgressIndicatorDialog mount logic to single file

This commit is contained in:
bossgeekgo
2024-02-17 01:27:31 +08:00
parent 7b22aca5e2
commit 56adf2787d
2 changed files with 39 additions and 6 deletions
@@ -0,0 +1,36 @@
import { createApp } from 'vue'
import ElementPlus from 'element-plus'
import DependenciesSetupProgressIndicatorDialog from './index.vue'
export const mountGlobalDialog = () => {
const containerElId = `elForDependenciesSetupProgressIndicatorDialog`
if (document.getElementById(containerElId)) {
return
}
let containerEl: null | HTMLElement = (() => {
const el = document.createElement('div')
el.id = containerElId
return el
})()
document.body.append(containerEl)
const dispose = () => {
app?.unmount()
containerEl?.remove()
app = null
containerEl = null
}
let app: null | ReturnType<typeof createApp> = createApp(DependenciesSetupProgressIndicatorDialog, {
modelValue: true,
onClosed() {
dispose()
}
}).use(ElementPlus)
app.mount(containerEl)
return {
dispose
}
}
@@ -27,7 +27,6 @@
<el-button type="primary" @click="handleSubmit"> I'm ready, geekgeekgo! </el-button> <el-button type="primary" @click="handleSubmit"> I'm ready, geekgeekgo! </el-button>
</el-form-item> </el-form-item>
</el-form> </el-form>
<DependenciesSetupProgressIndicatorDialog v-model="shouldShowDependenciesSetupProgressIndicatorDialog" />
</div> </div>
</template> </template>
@@ -36,7 +35,7 @@ import { onUnmounted, ref } from 'vue'
import JSON5 from 'json5' import JSON5 from 'json5'
import { ElForm, ElMessage, ElMessageBox } from 'element-plus' import { ElForm, ElMessage, ElMessageBox } from 'element-plus'
import router from '../../router/index' import router from '../../router/index'
import DependenciesSetupProgressIndicatorDialog from '../../features/DependenciesSetupProgressIndicatorDialog/index.vue' import { mountGlobalDialog as mountDependenciesSetupProgressIndicatorDialog } from '@renderer/features/DependenciesSetupProgressIndicatorDialog/operations'
const formContent = ref({ const formContent = ref({
bossZhipinCookies: '', bossZhipinCookies: '',
@@ -118,13 +117,11 @@ const handleExpectCompaniesInputBlur = (event) => {
.join(',') .join(',')
} }
const shouldShowDependenciesSetupProgressIndicatorDialog = ref(false)
const needWarmingUpDenpendenciesHandler = () => { const needWarmingUpDenpendenciesHandler = () => {
shouldShowDependenciesSetupProgressIndicatorDialog.value = true const processDialog = mountDependenciesSetupProgressIndicatorDialog()
const handlePuppeteerDownloadFinished = () => { const handlePuppeteerDownloadFinished = () => {
shouldShowDependenciesSetupProgressIndicatorDialog.value = false processDialog?.dispose()
} }
electron.ipcRenderer.once('PUPPETEER_DOWNLOAD_FINISHED', handlePuppeteerDownloadFinished) electron.ipcRenderer.once('PUPPETEER_DOWNLOAD_FINISHED', handlePuppeteerDownloadFinished)
} }