Skip to content

Commit

Permalink
新增readme
Browse files Browse the repository at this point in the history
  • Loading branch information
zscorpio committed Sep 5, 2023
1 parent 6c62278 commit feb3202
Show file tree
Hide file tree
Showing 12 changed files with 145 additions and 30 deletions.
122 changes: 100 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,34 +1,112 @@
# account-manager
<p align="center">
<a href="https://github.com/zscorpio/account-manager"><img src="https://raw.githubusercontent.com/zscorpio/account-manager/main/build/icon.png" width="150" height="150" alt="account-manager logo"></a>
</p>

An Electron application with Vue
<div align="center">

## Recommended IDE Setup
# Account Manager

- [VSCode](https://code.visualstudio.com/) + [ESLint](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint) + [Prettier](https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode) + [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar)
_✨ 多账号隔离管理浏览器, 多平台电商从业者福音 ✨_

## Project Setup
</div>

### Install
<p align="center">
<a href="https://raw.githubusercontent.com/zscorpio/account-manager/main/LICENSE">
<img src="https://img.shields.io/github/license/zscorpio/account-manager?color=brightgreen" alt="license">
</a>
<a href="https://github.com/zscorpio/account-manager/releases/latest">
<img src="https://img.shields.io/github/v/release/zscorpio/account-manager?color=brightgreen&include_prereleases" alt="release">
</a>
<a href="https://github.com/zscorpio/account-manager/releases/latest">
<img src="https://img.shields.io/github/downloads/zscorpio/account-manager/total?color=brightgreen&include_prereleases" alt="release">
</a>
</p>

```bash
$ npm install
```
> **Note**
> 因为个人需求, 所以本身是想做个OpenAI余额管理器的, 之前也写了一个[OpenAI余额管理工具](https://github.com/zscorpio/openai-tool), 主要是因为之前那些方案基本上都不可用了, 目前github上开源的方案呢, 基本上都是需要提供账号密码到三方搭建的网站去模拟登录获取验证信息, 相对来说还是较为不安全的, 但是之前那个方案跑起来比较麻烦, 所以考虑还是做个客户端, 顺便练练手.
>
> 之前刚好也有一个朋友需要管理大量的第三方的电商平台账号, 淘宝, 拼多多, 京东等一共几十个账号, 每次来回切换登录极其麻烦. 我自己本身在公司也经常会有这种测试需求, 需要来回切换账号, 查看功能是否正常.
>
> 另外总会有些奇奇怪怪的网站你希望用隐私模式访问, 因为普通模式会同步浏览器访问记录, 地址栏会自动补全, 但是不登陆的话, 会缺少一些自定义的推荐, 每次登录又很麻烦.
>
> 所以我在实现OpenAI相关余额的管理之后,做了一个通用的账号切换管理.
### Development
## 功能
1. 支持多账号浏览器隔离管理.
2. 支持自定义数据目录
3. 支持自定义浏览器.

```bash
$ npm run dev
```
## 安装
1.[GitHub Releases](https://github.com/zscorpio/account-manager/releases/latest) 下载可执行文件或者从源码编译:
```shell
git clone git@github.com:zscorpio/account-manager.git

# 构建
cd account-manager
npm install

# build
npm run build:mac
npm run build:win
npm run build:linux

## 配置
系统本身下载即用, 同时你也可以修改一些配置来优化使用体验.

### Build
![系统设置](./doc/img/settings.jpeg)

```bash
# For windows
$ npm run build:win
1. 你可以自定义数据目录, 方便迁移和编辑配置.
2. 默认自带的浏览器是Puppeteer和Chrome会稍微有点区别, 比如不支持hls(目前这个我觉得是最伤的)

# For macOS
$ npm run build:mac
## 使用方法
1. 配置好个人目录之后, 打开数据目录, 并在目录下添加配置文件, 以.json结尾, 文件格式为json
```json
{
"order": 3,
"name": "杂项",
"type": "other",
"homePage": "https://baidu.com/",
"accountList": [
{
"account": "淘宝账号",
"password": "",
"remark": "淘宝测试",
"type": "taobao",
"homePage": "https://taobao.com/"
},
{
"account": "京东账号",
"password": "",
"remark": "京东测试",
"type": "jd",
"homePage": "https://jd.com/"
}
]
}
```
#### 配置含义
- order, 页面的排序, 默认是1000000, 越小越前面.
- name, 组名
- type, 可以自定义, openai会有专门的样式, 毕竟一开始是专门为OpenAI开发的.
- homePage, 默认打开的页面, 如果下面的accountList里面也配置了, 会覆盖, 比如全是OpenAI账号的话, 那么配置一个就够了.
- accountList 账号列表
- account, 账号名
- password, 密码, 其实是针对OpenAI的, 本身代码里面支持扩展自动登录, 暂时还没暴露.
- remark, 备注
- type, 类型, 配置了的话会覆盖父级.
- homePage, 默认打开的页面.

# For Linux
$ npm run build:linux
```
### 截图展示
![openai](./doc/img/openai.jpeg)
![other](./doc/img/other.jpeg)

## 常见问题
1. 因为每个账号都是独立的数据, 每个账号大概需要40MB空间, 当前需要手动清除, 目录在系统设置里面.

## 相关项目
* [electron-vite](https://github.com/alex8088/electron-vite): 下一代 Electron 开发构建工具
* [arco-design-vue](https://github.com/arco-design/arco-design-vue): 企业级产品的完整设计和开发解决方案

## 注意

本项目使用 GPT 协议进行开源
Binary file added doc/img/openai.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/img/other.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/img/settings.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "account-manager",
"version": "1.1.1",
"version": "1.3.0",
"description": "多账号切换管理器",
"main": "./out/main/index.js",
"author": "zsw.scorpio@gmail.com",
Expand Down
2 changes: 1 addition & 1 deletion src/main/common/Logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ logger.transports.file.level = "info";
logger.transports.file.maxSize = 1002430; // 10M
logger.transports.file.format = "[{y}-{m}-{d} {h}:{i}:{s}.{ms}] [{level}]{scope} {text}";
logger.transports.file.resolvePathFn = () => {
return path.join(FsUtils.getRootPath(), `${DateUtils.formatYMD()}.log`);
return path.join(FsUtils.getRootPath(), `log/${DateUtils.formatYMD()}.log`);
};

export default {
Expand Down
1 change: 1 addition & 0 deletions src/main/const/API.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export default {
},
system: {
dialog: "system/dialog",
dialogFile: "system/dialogFile",
openFolder: "system/openFolder"
}
};
5 changes: 5 additions & 0 deletions src/main/service/RouterService.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ export default {
ipcMain.handle(API.system.dialog, async () => {
return await SystemService.dialog();
});

ipcMain.handle(API.system.dialogFile, async () => {
return await SystemService.dialog("openFile");
});

ipcMain.handle(API.system.openFolder, async (event, data) => {
return await SystemService.openFolder(data);
});
Expand Down
14 changes: 11 additions & 3 deletions src/main/service/SettingService.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,23 @@ import FsUtils from "../utils/FsUtils";

export default {
get: async function () {
let systemConfigFile = FsUtils.getSystemConfigFile();
let systemConfig = FsUtils.readFileSync(systemConfigFile);
return {
rootPath: FsUtils.getRootPath()
rootPath: FsUtils.getRootPath(),
executablePath: systemConfig.executablePath
};
},
update: async function (data) {
let systemConfigFile = FsUtils.getSystemConfigFile();
let systemConfig = FsUtils.readFileSync(systemConfigFile);
if (data && data.rootPath) {
systemConfig.rootPath = data.rootPath;
if (data) {
if (data.rootPath) {
systemConfig.rootPath = data.rootPath;
}
if (data.executablePath) {
systemConfig.executablePath = data.executablePath;
}
FsUtils.writeFileSync(systemConfigFile, JSON.stringify(systemConfig));
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/service/SystemService.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
const { dialog, shell } = require("electron");

export default {
dialog: async function () {
dialog: async function (propertie = "openDirectory") {
const { canceled, filePaths } = await dialog.showOpenDialog({
properties: ["openDirectory", "createDirectory"]
properties: ["createDirectory", "treatPackageAsDirectory", propertie]
});
if (!canceled) {
return filePaths[0];
Expand Down
6 changes: 6 additions & 0 deletions src/main/utils/PuppeteerUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ export default {
}
}

let systemConfigFile = FsUtils.getSystemConfigFile();
let systemConfig = FsUtils.readFileSync(systemConfigFile);

let options = {
headless: false,
defaultViewport: null,
Expand All @@ -39,6 +42,9 @@ export default {
if (headless) {
options.headless = "new";
}
if (systemConfig.executablePath) {
options.executablePath = systemConfig.executablePath;
}
const browser = await puppeteer.launch(options);
global.__browser[uniqueId] = browser;
browser.on("disconnected", () => {
Expand Down
19 changes: 18 additions & 1 deletion src/renderer/src/components/Setting.vue
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
<template>
<a-form :model="form" :style="{ width: '1000px' }">
<a-form-item field="name" label="数据目录" extra="更改目录需要手动转移数据, 建议切换到个人目录">
<a-form-item field="rootPath" label="数据目录" extra="更改目录需要手动转移数据, 建议切换到个人目录">
<a-input v-model="settings.rootPath" placeholder="请自定义用户数据目录" disabled />
<a-button :style="{ marginLeft: '10px' }" @click="openRootPath">打开目录</a-button>
<a-button type="primary" :style="{ marginLeft: '10px' }" @click="changeRootPath">更换目录</a-button>
</a-form-item>
<a-form-item field="executablePath" label="浏览器目录">
<template #extra>
<div>可以自定义本机安装的chrome浏览器, 默认的浏览器可能会存在一些限制</div>
<div>Mac Chrome地址一般是/Applications/Google Chrome.app/Contents/MacOS/Google Chrome</div>
</template>
<a-input v-model="settings.executablePath" placeholder="你可以自定义浏览器执行路径" disabled />
<a-button type="primary" :style="{ marginLeft: '10px' }" @click="changeExecutablePath">更换执行路径</a-button>
</a-form-item>
</a-form>
</template>
<script>
Expand All @@ -27,6 +35,15 @@ export default {
path: this.settings.rootPath
});
},
changeExecutablePath: async function () {
const executablePath = await window.request.invoke(window.API.system.dialogFile, "");
if (executablePath) {
this.settings.executablePath = executablePath;
await window.request.invoke(window.API.setting.update, {
executablePath: executablePath
});
}
},
changeRootPath: async function () {
const rootPath = await window.request.invoke(window.API.system.dialog, "");
if (rootPath) {
Expand Down

0 comments on commit feb3202

Please sign in to comment.