Skip to content

Commit

Permalink
feat: ✨ 多账户切换
Browse files Browse the repository at this point in the history
  • Loading branch information
Ocyss committed Apr 3, 2024
1 parent 9e1d011 commit 2302e18
Show file tree
Hide file tree
Showing 12 changed files with 359 additions and 96 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,13 @@ greasyfork地址: <https://greasyfork.org/zh-CN/scripts/491340>
## 最后

嗯...

## Star 趋势

<a href="https://star-history.com/#ocyss/boos-helper&Date">
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/svg?repos=ocyss/boos-helper&type=Date&theme=dark" />
<source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/svg?repos=ocyss/boos-helper&type=Date" />
<img alt="Star History Chart" src="https://api.star-history.com/svg?repos=ocyss/boos-helper&type=Date" />
</picture>
</a>
18 changes: 14 additions & 4 deletions README.user.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ Boos直聘助手, 皆在减少投递简历的麻烦, 和提高投递简历的效
>
> 测试阶段,目前可以正常筛选,自动打招呼并且进行投递,统计,GPT等功能制作中
## 项目预览
### 项目预览

[![统计界面](https://s21.ax1x.com/2024/04/02/pFHa3ZD.png)](https://imgse.com/i/pFHa3ZD)
[![配置界面](https://s21.ax1x.com/2024/04/02/pFHa8de.png)](https://imgse.com/i/pFHa8de)
[![日志界面](https://s21.ax1x.com/2024/04/02/pFHalqO.png)](https://imgse.com/i/pFHalqO)

## 未来计划
### 未来计划

- [x] 优化UI去除广告
- [x] 批量投递简历
Expand All @@ -40,13 +40,13 @@ Boos直聘助手, 皆在减少投递简历的麻烦, 和提高投递简历的效
- [ ] 聊天屏蔽已读消息
- [ ] boos消息弹窗

# 免责声明
## 免责声明

本项目仅供学习交流,禁止用于商业用途

使用该脚本有一定风险(如黑号,封号,权重降低等),本项目不承担任何责任

# 相关链接
## 相关链接

Github开源地址: <https://github.com/ocyss/boos-helper>

Expand All @@ -58,3 +58,13 @@ greasyfork地址: <https://greasyfork.org/zh-CN/scripts/491340>
- <https://github.com/lisonge/vite-plugin-monkey>

- <https://www.runoob.com/manual/mqtt/protocol/MQTT-3.1.1-CN.pdf>

## Star 趋势

<a href="https://star-history.com/#ocyss/boos-helper&Date">
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/svg?repos=ocyss/boos-helper&type=Date&theme=dark" />
<source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/svg?repos=ocyss/boos-helper&type=Date" />
<img alt="Star History Chart" src="https://api.star-history.com/svg?repos=ocyss/boos-helper&type=Date" />
</picture>
</a>
43 changes: 23 additions & 20 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,20 @@ import {
ElAvatar,
} from "element-plus";
import { GM_deleteValue, GM_listValues } from "$";
import storeVue from "@/components/conf/store.vue";
import userVue from "@/components/conf/user.vue";
import logVue from "@/components/conf/log.vue";
import { ref } from "vue";
logger.info("BoosHelper挂载成功");
ElMessage("BoosHelper挂载成功!");
const confBox = ref(false);
const confs = {
store: { name: "存储配置", component: storeVue },
user: { name: "账号配置", component: userVue },
log: { name: "日志配置", component: logVue },
};
const confKey = ref<keyof typeof confs>("store");
const clone = async () => {
if (confirm("将清空脚本全部的设置!!")) {
const asyncKeys = await GM_listValues();
Expand Down Expand Up @@ -41,29 +51,22 @@ const clone = async () => {
<el-dropdown-menu>
<el-dropdown-item disabled>BossHelp配置项</el-dropdown-item>
<el-dropdown-item divided disabled></el-dropdown-item>
<el-dropdown-item @click="clone">存储配置</el-dropdown-item>
<el-dropdown-item @click="confBox = true">日志查看</el-dropdown-item>
<el-dropdown-item @click="confBox = true">账户配置</el-dropdown-item>
<el-dropdown-item
v-for="(v, k) in confs"
:key="k"
@click="
confKey = k;
confBox = true;
"
>
{{ v.name }}
</el-dropdown-item>
</el-dropdown-menu>
</template>
</el-dropdown>
<el-dialog
v-model="confBox"
title="Tips"
width="500"
align-center
destroy-on-close
center
:z-index="9999999999"
>
<span>This is a message</span>
<template #footer>
<div class="dialog-footer">
<el-button @click="confBox = false">Cancel</el-button>
<el-button type="primary" @click="confBox = false">Confirm</el-button>
</div>
</template>
</el-dialog>
<Teleport to="body">
<component :is="confs[confKey].component" v-model="confBox" />
</Teleport>
</template>

<style lang="scss">
Expand Down
25 changes: 25 additions & 0 deletions src/components/conf/log.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<script lang="ts" setup>
import { ElDialog } from "element-plus";
const show = defineModel<boolean>({ required: true });
</script>

<template>
<el-dialog
v-model="show"
title="日志查看"
width="500"
align-center
destroy-on-close
:z-index="20"
>
<span>Log</span>
<template #footer>
<div>
<el-button @click="show = false">Cancel</el-button>
<el-button type="primary" @click="show = false">Confirm</el-button>
</div>
</template>
</el-dialog>
</template>

<style lang="scss" scoped></style>
27 changes: 27 additions & 0 deletions src/components/conf/store.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<script lang="ts" setup>
import { ElDialog, ElButton } from "element-plus";
const show = defineModel<boolean>({ required: true });
</script>

<template>
<el-dialog
v-model="show"
title="存储配置"
width="500"
align-center
destroy-on-close
:z-index="20"
>
<span>
当使用多账户时候,该配置内含有敏感信息,导入导出一定要注意,避免泄露
</span>
<template #footer>
<div>
<el-button @click="show = false">Cancel</el-button>
<el-button type="primary" @click="show = false">Confirm</el-button>
</div>
</template>
</el-dialog>
</template>

<style lang="scss" scoped></style>
212 changes: 210 additions & 2 deletions src/components/conf/user.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,215 @@
<script lang="ts" setup></script>
<script lang="ts" setup>
import { GM_cookie, GM_getValue, GM_setValue } from "$";
import {
useFormData,
formDataKey,
todayKey,
} from "@/pages/web/geek/job/hooks/useForm";
import {
ElDialog,
ElButton,
ElTableColumn,
ElTable,
ElAlert,
ElMessage,
ElTag,
ElAvatar,
ElPopconfirm,
} from "element-plus";
import { FormData, Statistics } from "@/types/formData";
import { computed, reactive, ref, toRaw } from "vue";
const confUserKey = "conf-user";
const { formData, todayData } = useFormData();
const show = defineModel<boolean>({ required: true });
type Data = {
uid: string;
user: string;
avatar: string;
remark: string;
gender: "man" | "woman";
flag: "student" | "staff";
date: string;
cookie: string;
form?: FormData;
statistics?: Statistics;
};
const data = reactive(GM_getValue<{ [keys: string]: Data }>(confUserKey, {}));
const tableData = computed<Data[]>(() => Object.values(data));
console.log("账户数据", toRaw(data));
const currentRow = ref<Data | undefined>();
const handleCurrentChange = (val: Data | undefined) => {
currentRow.value = val;
};
async function create(flag = true) {
try {
const list = await new Promise<any[]>((resolve, reject) => {
GM_cookie.list({}, (cookies, error) => {
if (error) {
reject(error);
} else {
resolve(cookies);
}
});
});
const pg = window._PAGE;
let uid: string | number | undefined = pg.uid || pg.userId;
if (!uid) {
return;
}
uid = String(uid);
data[uid] = {
uid,
user: pg.showName || pg.name,
avatar: pg.tinyAvatar || pg.largeAvatar,
remark: "",
gender: pg.gender === 0 ? "man" : "woman",
flag: pg.studentFlag ? "student" : "staff",
date: new Date().toLocaleString(),
cookie: JSON.stringify(list),
form: toRaw(formData),
statistics: toRaw(todayData),
};
GM_setValue(confUserKey, data);
await Promise.all(
list.map((item) => GM_cookie.delete({ name: item.name }))
);
if (flag) {
ElMessage.success("创建成功,开始清空ck并刷新");
window.location.reload();
}
} catch (e) {
ElMessage.error("遇到错误,请重试," + e);
throw new Error("err", { cause: e });
}
}
async function change() {
try {
const data = currentRow.value;
if (!data) {
ElMessage.error("错误,空状态");
return;
}
currentRow.value = undefined;
await create(false);
if (data.form) GM_setValue(formDataKey, data.form);
if (data.statistics) GM_setValue(todayKey, data.statistics);
const ck: any[] = JSON.parse(data.cookie);
await Promise.all(ck.map((c) => GM_cookie.set(c)));
ElMessage.success("切换完成,即将刷新");
window.location.reload();
} catch (e: any) {
console.log("错误,切换失败", e);
if (e.name !== "err" || !e.name) ElMessage.error("错误,切换失败");
}
}
function del(d: Data) {
delete data[d.uid];
console.log(data);
GM_setValue(confUserKey, toRaw(data));
ElMessage.success("删除成功");
}
</script>

<template>
<div></div>
<el-dialog
v-model="show"
title="账户配置"
width="70%"
align-center
destroy-on-close
:z-index="20"
>
<el-alert
title="使用该功能将会明文存储cookie信息,可能包含隐私信息"
type="warning"
style="margin: 6px 0"
/>
<el-alert
title="每个用户都有自己的相关配置但历史投递等信息将全局共享,如果切换后是未登陆状态可能ck不完整或过期再次登陆即可(不要删除,不然配置会丢失)"
type="info"
style="margin: 6px 0"
/>
<el-table
:data="tableData"
style="width: 100%"
highlight-current-row
table-layout="auto"
@current-change="handleCurrentChange"
>
<el-table-column type="index" width="40" />
<el-table-column label="账户">
<template #default="scope">
<div style="align-items: center; display: flex">
<el-avatar :src="scope.row.avatar" :size="30" />
<span style="margin-left: 8px">{{ scope.row.user }}</span>
</div>
</template>
</el-table-column>
<el-table-column label="性别" align="center">
<template #default="scope">
<el-tag
round
effect="dark"
style="border-style: none"
:color="scope.row.gender === 'man' ? '#9BC1FE' : '#FFBDEB'"
>
{{ scope.row.gender === "man" ? "可爱男孩" : "温柔女孩" }}
</el-tag>
</template>
</el-table-column>
<el-table-column label="身份" align="center">
<template #default="scope">
<el-tag
effect="dark"
round
style="border-style: none"
:type="scope.row.flag === 'student' ? 'success' : 'warning'"
>
{{ scope.row.flag === "student" ? "哈巴学生" : "无情社畜" }}
</el-tag>
</template>
</el-table-column>
<el-table-column prop="date" label="上次登录" />
<el-table-column fixed="right" label="操作">
<template #default="scope">
<el-button link type="primary" size="small" disabled>导出</el-button>
<el-button
link
type="primary"
size="small"
@click="() => del(scope.row)"
>
删除
</el-button>
</template>
</el-table-column>
</el-table>
<template #footer>
<div>
<el-button @click="show = false">取消</el-button>
<el-popconfirm
title="确认后将保存数据退出账户并自动刷新"
@confirm="() => create()"
>
<template #reference>
<el-button type="primary">新建&登出</el-button>
</template>
</el-popconfirm>
<el-button type="primary" @click="change" :disabled="!currentRow">
切换
</el-button>
</div>
</template>
</el-dialog>
</template>

<style lang="scss" scoped></style>
Loading

0 comments on commit 2302e18

Please sign in to comment.