mirror of
https://github.com/geekgeekrun/geekgeekrun.git
synced 2026-09-04 23:17:39 +08:00
enhance cookie assistant dialog - help info, form validation, ui text. style, etc.
This commit is contained in:
@@ -103,6 +103,12 @@ export function createMainWindow(): void {
|
|||||||
])
|
])
|
||||||
})
|
})
|
||||||
|
|
||||||
|
ipcMain.handle('write-storage-file', async (ev, payload) => {
|
||||||
|
ensureStorageFileExist()
|
||||||
|
|
||||||
|
return await writeStorageFile(payload.fileName, JSON.parse(payload.data))
|
||||||
|
})
|
||||||
|
|
||||||
// const currentExecutablePath = app.getPath('exe')
|
// const currentExecutablePath = app.getPath('exe')
|
||||||
// console.log(currentExecutablePath)
|
// console.log(currentExecutablePath)
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,12 @@
|
|||||||
<template>
|
<template>
|
||||||
<el-dialog v-bind="$attrs" :close-on-click-modal="false" title="Boss直聘 Cookie助手" :width="600">
|
<el-dialog
|
||||||
|
v-bind="$attrs"
|
||||||
|
:close-on-click-modal="false"
|
||||||
|
title="Boss直聘 Cookie助手"
|
||||||
|
:width="720"
|
||||||
|
top="20px"
|
||||||
|
lock-scroll
|
||||||
|
>
|
||||||
<el-alert type="warning" title="需要获取您的Boss直聘Cookie才能继续">
|
<el-alert type="warning" title="需要获取您的Boss直聘Cookie才能继续">
|
||||||
由于您是首次使用本程序,或者您之前使用的Boss直聘账号登录状态失效,因此您需要重新获取登录凭证。
|
由于您是首次使用本程序,或者您之前使用的Boss直聘账号登录状态失效,因此您需要重新获取登录凭证。
|
||||||
</el-alert>
|
</el-alert>
|
||||||
@@ -27,41 +34,130 @@
|
|||||||
<li>按照正常流程,通过 <b>短信验证码/二维码/微信小程序</b> 登录您的Boss直聘账号</li>
|
<li>按照正常流程,通过 <b>短信验证码/二维码/微信小程序</b> 登录您的Boss直聘账号</li>
|
||||||
<li>
|
<li>
|
||||||
如果流程顺利,登录后预计5-10秒内,您将可以在下方输入框看到您的Cookie
|
如果流程顺利,登录后预计5-10秒内,您将可以在下方输入框看到您的Cookie
|
||||||
<div>
|
<details>
|
||||||
<details>
|
<summary color-orange cursor-pointer>我已完成登录,但Cookie一直没出现?</summary>
|
||||||
<summary color-orange cursor-pointer>我已完成登录,但Cookie一直没出现?</summary>
|
<div ml-2em max-h-200px of-auto>
|
||||||
<div ml-2em>
|
如果您确实已经在打开浏览器中看到您已登录了Boss直聘,请尝试按照如图所示方式复制Cookie:
|
||||||
如果您确实已经在浏览器中看到您已登录了Boss直聘,请尝试按照如图所示方式复制Cookie:
|
<figure>
|
||||||
<figure></figure>
|
<figcaption>依次点击浏览器右上角“扩展程序”图标、“EditThisCookie”图标</figcaption>
|
||||||
然后粘贴您刚刚复制的内容到下方输入框。粘贴后,将
|
<img block max-w-full src="./resources/copy-cookie-step-1.png" />
|
||||||
</div>
|
</figure>
|
||||||
</details>
|
<figure>
|
||||||
</div>
|
<figcaption>点击“EditThisCookie”弹出框中的“Export”按钮</figcaption>
|
||||||
|
<img block max-w-full src="./resources/copy-cookie-step-2.png" />
|
||||||
|
</figure>
|
||||||
|
<figure>
|
||||||
|
<figcaption>在下方输入框执行粘贴操作。</figcaption>
|
||||||
|
</figure>
|
||||||
|
</div>
|
||||||
|
</details>
|
||||||
</li>
|
</li>
|
||||||
</ol>
|
</ol>
|
||||||
<el-input
|
<el-form
|
||||||
v-model="collectedCookies"
|
ref="formRef"
|
||||||
type="textarea"
|
inline-message
|
||||||
:autosize="{
|
:model="formContent"
|
||||||
minRows: 4,
|
label-position="top"
|
||||||
maxRows: 10
|
:rules="formRules"
|
||||||
}"
|
class="cookie-form"
|
||||||
font-size-12px
|
>
|
||||||
></el-input>
|
<el-form-item prop="collectedCookies" mb-0>
|
||||||
<el-alert v-if="!collectedCookies" :closable="false">正在等待登录……</el-alert>
|
<el-input
|
||||||
|
v-model="formContent.collectedCookies"
|
||||||
|
type="textarea"
|
||||||
|
:autosize="{
|
||||||
|
minRows: 10,
|
||||||
|
maxRows: 10
|
||||||
|
}"
|
||||||
|
font-size-12px
|
||||||
|
></el-input>
|
||||||
|
<el-alert
|
||||||
|
v-if="!formContent.collectedCookies"
|
||||||
|
:closable="false"
|
||||||
|
title="正在等待登录……"
|
||||||
|
></el-alert>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
<template #footer>
|
||||||
|
<el-button type="primary" @click="handleSubmit">确定</el-button>
|
||||||
|
</template>
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
|
import { ElForm, ElMessage } from 'element-plus';
|
||||||
import { ref, onUnmounted, onMounted } from 'vue'
|
import { ref, onUnmounted, onMounted } from 'vue'
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
dispose: Function
|
dispose: Function
|
||||||
})
|
})
|
||||||
|
|
||||||
const collectedCookies = ref('')
|
const formRef = ref<InstanceType<typeof ElForm>>()
|
||||||
|
const formContent = ref({
|
||||||
|
collectedCookies: ''
|
||||||
|
})
|
||||||
|
|
||||||
|
const formRules = {
|
||||||
|
collectedCookies: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请输入Cookie'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
trigger: 'blur',
|
||||||
|
validator(rule, val, cb) {
|
||||||
|
let arr
|
||||||
|
try {
|
||||||
|
arr = JSON.parse(val)
|
||||||
|
} catch (err) {
|
||||||
|
cb(
|
||||||
|
new Error(
|
||||||
|
`JSON格式无效 - 存在语法错误: ${err.message};建议使用EditThisCookie扩展程序进行复制。`
|
||||||
|
)
|
||||||
|
)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
const allExpectKeySet = new Set([
|
||||||
|
'name',
|
||||||
|
'value',
|
||||||
|
'domain',
|
||||||
|
'path',
|
||||||
|
'secure',
|
||||||
|
'session',
|
||||||
|
'httpOnly'
|
||||||
|
])
|
||||||
|
if (
|
||||||
|
!Array.isArray(arr) ||
|
||||||
|
!arr.length ||
|
||||||
|
!(
|
||||||
|
arr.length > 0 &&
|
||||||
|
arr.some((it) => {
|
||||||
|
const currentOwnedKeySet = new Set(Object.keys(it))
|
||||||
|
if (currentOwnedKeySet.size < allExpectKeySet.size) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
const allExpectKeyArr = [...allExpectKeySet]
|
||||||
|
for (let i = 0; i < allExpectKeyArr.length; i++) {
|
||||||
|
if (!currentOwnedKeySet.has(allExpectKeyArr[i])) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
})
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
cb(new Error(`Cookie格式无效 - 部分字段缺失;建议使用EditThisCookie扩展程序进行复制。`))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
cb()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
const handleCookieCollected = (_, payload) => {
|
const handleCookieCollected = (_, payload) => {
|
||||||
collectedCookies.value = JSON.stringify(payload.cookies, null, 2)
|
formContent.value.collectedCookies = JSON.stringify(payload.cookies, null, 2)
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleClickLaunchLogin = () => {
|
const handleClickLaunchLogin = () => {
|
||||||
@@ -75,6 +171,16 @@ const handleEditThisCookieExtensionStoreLinkClick = () => {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const handleSubmit = async () => {
|
||||||
|
await formRef.value!.validate()
|
||||||
|
await electron.ipcRenderer.invoke('write-storage-file', {
|
||||||
|
fileName: 'boss-cookies.json',
|
||||||
|
data: formContent.value.collectedCookies
|
||||||
|
})
|
||||||
|
ElMessage.success('Boss直聘 Cookie 保存成功')
|
||||||
|
props.dispose()
|
||||||
|
}
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
electron.ipcRenderer.once('BOSS_ZHIPIN_COOKIE_COLLECTED', handleCookieCollected)
|
electron.ipcRenderer.once('BOSS_ZHIPIN_COOKIE_COLLECTED', handleCookieCollected)
|
||||||
})
|
})
|
||||||
@@ -82,3 +188,12 @@ onUnmounted(() => {
|
|||||||
electron.ipcRenderer.removeListener('BOSS_ZHIPIN_COOKIE_COLLECTED', handleCookieCollected)
|
electron.ipcRenderer.removeListener('BOSS_ZHIPIN_COOKIE_COLLECTED', handleCookieCollected)
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss">
|
||||||
|
.cookie-form.el-form {
|
||||||
|
.el-form-item__error--inline {
|
||||||
|
margin-left: 0;
|
||||||
|
margin-top: 10px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|||||||
BIN
Binary file not shown.
|
After Width: | Height: | Size: 118 KiB |
BIN
Binary file not shown.
|
After Width: | Height: | Size: 83 KiB |
Reference in New Issue
Block a user