51 Commits

Author SHA1 Message Date
zhenjie1
02d4f9dff6 Merge 77da3cf339 into b4cf3b4c5f 2023-07-05 14:35:32 +08:00
dependabot[bot]
b4cf3b4c5f chore(deps-dev): bump vite-plugin-electron from 0.11.2 to 0.12.0 (#406)
Bumps [vite-plugin-electron](https://github.com/electron-vite/vite-plugin-electron) from 0.11.2 to 0.12.0.
- [Release notes](https://github.com/electron-vite/vite-plugin-electron/releases)
- [Changelog](https://github.com/electron-vite/vite-plugin-electron/blob/main/CHANGELOG.md)
- [Commits](https://github.com/electron-vite/vite-plugin-electron/compare/v0.11.2...v0.12.0)

---
updated-dependencies:
- dependency-name: vite-plugin-electron
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-07-01 14:34:53 +08:00
dependabot[bot]
69e11a78ac chore(deps-dev): bump electron-builder from 23.6.0 to 24.4.0 (#405)
Bumps [electron-builder](https://github.com/electron-userland/electron-builder/tree/HEAD/packages/electron-builder) from 23.6.0 to 24.4.0.
- [Release notes](https://github.com/electron-userland/electron-builder/releases)
- [Changelog](https://github.com/electron-userland/electron-builder/blob/master/packages/electron-builder/CHANGELOG.md)
- [Commits](https://github.com/electron-userland/electron-builder/commits/v24.4.0/packages/electron-builder)

---
updated-dependencies:
- dependency-name: electron-builder
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-07-01 14:34:30 +08:00
yema
77da3cf339 增加库存功能 2023-06-18 01:12:27 +08:00
yema
9dbe2184dd 同步master最新代码 2023-06-16 16:03:45 +08:00
yema
836bf7393a commit 2023-06-15 23:13:46 +08:00
yema
87880184b5 改造前 2023-06-13 21:39:23 +08:00
yema
7a5dfc0439 准备替换所有 browser 2023-06-13 00:12:56 +08:00
yema
8d5beec179 批量申请 4.0 2023-06-08 13:00:26 +08:00
yema
74507b17e0 commit 2023-06-06 10:19:43 +08:00
yema
828e987119 修复 google 登录中错误 2023-06-05 20:13:42 +08:00
yema
49d36516c1 init 2023-06-04 18:09:47 +08:00
dependabot[bot]
3d3daf1db5 chore(deps-dev): bump electron from 24.4.1 to 25.0.1 (#391)
Bumps [electron](https://github.com/electron/electron) from 24.4.1 to 25.0.1.
- [Release notes](https://github.com/electron/electron/releases)
- [Changelog](https://github.com/electron/electron/blob/main/docs/breaking-changes.md)
- [Commits](https://github.com/electron/electron/compare/v24.4.1...v25.0.1)

---
updated-dependencies:
- dependency-name: electron
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-06-01 11:01:45 +08:00
dependabot[bot]
516234dce5 chore(deps-dev): bump electron from 23.3.0 to 24.1.3 (#378)
Bumps [electron](https://github.com/electron/electron) from 23.3.0 to 24.1.3.
- [Release notes](https://github.com/electron/electron/releases)
- [Changelog](https://github.com/electron/electron/blob/main/docs/breaking-changes.md)
- [Commits](https://github.com/electron/electron/compare/v23.3.0...v24.1.3)

---
updated-dependencies:
- dependency-name: electron
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-05-04 13:53:21 +08:00
草鞋没号
a551ff2f3a chore: cleanup assets 2023-04-23 09:54:03 +08:00
草鞋没号
c74834b35e fix(CI): correct Linux icon 2023-04-17 10:51:21 +08:00
草鞋没号
1017a297e8 feat: use logo.svg as favicon 2023-04-17 10:23:38 +08:00
草鞋没号
cfd0fff1ed docs: update 2023-04-17 09:51:41 +08:00
草鞋没号
546eeb29d9 chore: bump vite-plugin-electron to ^0.11.1, vite-plugin-electron-renderer to 0.14.1 2023-04-17 09:51:26 +08:00
草鞋没号
3b766bd0b7 chore: bump vite-plugin-electron-renderer to 0.13.14 2023-03-31 10:02:35 +08:00
草鞋没号
b1b5ee4d24 chore: bump vite-plugin-electron-renderer to 0.13.13 2023-03-30 19:23:40 +08:00
草鞋没号
c96459cf7a chore: udpate deps 2023-03-28 12:59:33 +08:00
草鞋没号
6fbe501537 chore: bump vite-plugin-electron-renderer tot 0.13.11 2023-03-27 16:14:22 +08:00
草鞋没号
8171344a13 chore: bump up deps 2023-03-27 09:39:58 +08:00
草鞋没号
8720ba1f8a fix(#344): location.reload() causes open browser 2023-02-24 18:07:52 +08:00
草鞋没号
efaa80cd11 chore: bump deps 2023-02-24 15:21:21 +08:00
草鞋没号
85bcc91b66 chore: bump vite-plugin-electron-renderer to 0.12.1 2023-02-13 14:23:08 +08:00
Иван Музыка
0bb17a61a8 fix: links open in app, not browser (#343)
* fix: opening links in browser

#342

---------

Co-authored-by: 草鞋没号 <308487730@qq.com>
2023-02-13 14:19:45 +08:00
草鞋没号
b2f8887fab fix: correct load sourcemap #332 2023-02-02 22:07:51 +08:00
草鞋没号
40b8c08cf9 Merge pull request #337 from xhayper/patch-1
feat: pull code from upstream + update dependencies
2023-01-20 08:13:56 +08:00
hayper
025addbceb feat: 2023 2023-01-19 13:01:58 +07:00
hayper
3544247016 Merge branch 'electron-vite:main' into patch-1 2023-01-19 13:01:30 +07:00
xhayper
82e54afe81 feat: pull code from upstream + update package 2023-01-19 12:41:05 +07:00
草鞋没号
a7b905980f chore: cleanup 2023-01-11 23:45:22 +08:00
草鞋没号
efbe4d9645 chore: bump vite-plugin-electron-renderer to 0.11.4 2023-01-08 09:01:38 +08:00
草鞋没号
d9c4d3502a Merge pull request #327 from xhayper/patch-1
feat: improvement to template
2022-12-22 16:04:12 +08:00
xhayper
bafa8ae8ae feat: improvement to template 2022-12-22 10:38:43 +07:00
草鞋没号
67bbe33498 Merge pull request #324 from clarkttfu/main
fix: type reference in electron/electron-env.d.ts
2022-12-20 10:23:43 +08:00
Clark
919be49609 fix: type reference in electron/electron-env.d.ts
Resolve TS error "Cannot find type definition file for 'vite-electron/electron-env'"
2022-12-20 09:51:27 +08:00
草鞋没号
7f003bd95e chore: remove loadEnvPlugin() 2022-12-19 09:53:10 +08:00
草鞋没号
afc83731d5 chore: bump vite-plugin-electron to 0.11.1 2022-12-19 09:52:51 +08:00
草鞋没号
0776ebea38 chore: VITE_DEV_SERVER_URL instead app.isPackaged 2022-12-12 08:56:27 +08:00
草鞋没号
f9fee2e62f Merge pull request #317 from xuxiaowei-com-cn/main
⬆️ vite 升级到 4.0.0
2022-12-11 07:39:56 +08:00
徐晓伟
722298fd6e ⬆️ vite 升级到 4.0.0 2022-12-10 22:28:39 +08:00
草鞋没号
89d8730352 docs: correct link 2022-12-09 09:10:56 +08:00
草鞋没号
e522b5bbc6 feat: load .env file for Electron-Main 2022-12-08 09:24:46 +08:00
草鞋没号
5a3c6c7d23 Merge pull request #314 from electron-vite/dependabot/npm_and_yarn/electron-22.0.0
chore(deps-dev): bump electron from 21.3.1 to 22.0.0
2022-12-01 11:20:45 +08:00
dependabot[bot]
5e7c54a90d chore(deps-dev): bump electron from 21.3.1 to 22.0.0
Bumps [electron](https://github.com/electron/electron) from 21.3.1 to 22.0.0.
- [Release notes](https://github.com/electron/electron/releases)
- [Changelog](https://github.com/electron/electron/blob/main/docs/breaking-changes.md)
- [Commits](https://github.com/electron/electron/compare/v21.3.1...v22.0.0)

---
updated-dependencies:
- dependency-name: electron
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-12-01 02:02:03 +00:00
草鞋没号
c43f6484b9 chore: VITE_DEV_SERVER_URL instead app.isPackaged 2022-11-22 08:14:27 +08:00
草鞋没号
f55466cdad docs: update 2022-11-21 09:07:40 +08:00
草鞋没号
77cda603be chore: bum vite-plugin-electron-renderer to 0.11.3 2022-11-19 07:54:40 +08:00
42 changed files with 2640 additions and 216 deletions

View File

@@ -24,12 +24,12 @@ jobs:
steps:
- name: Checkout Code
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v2
uses: actions/setup-node@v3
with:
node-version: 14
node-version: 18
- name: Install Dependencies
run: npm install

9
.gitignore vendored
View File

@@ -10,9 +10,12 @@ lerna-debug.log*
node_modules
dist
dist-ssr
dist-electron
release
*.local
# Editor directories and files
.vscode/.debug.env
.idea
.DS_Store
*.suo
@@ -21,9 +24,7 @@ dist-ssr
*.sln
*.sw?
release
.vscode/.debug.env
# lockfile
package-lock.json
pnpm-lock.yaml
yarn.lock
dist-electron
yarn.lock

View File

@@ -1,8 +1,8 @@
import fs from 'fs'
import path from 'path'
import { fileURLToPath } from 'url'
import { createRequire } from 'module'
import { spawn } from 'child_process'
import fs from 'node:fs'
import path from 'node:path'
import { fileURLToPath } from 'node:url'
import { createRequire } from 'node:module'
import { spawn } from 'node:child_process'
const pkg = createRequire(import.meta.url)('../package.json')
const __dirname = path.dirname(fileURLToPath(import.meta.url))

4
.vscode/launch.json vendored
View File

@@ -22,7 +22,7 @@
"configurations": [
{
"name": "Debug Main Process",
"type": "pwa-node",
"type": "node",
"request": "launch",
"runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron",
"windows": {
@@ -39,7 +39,7 @@
"name": "Debug Renderer Process",
"port": 9229,
"request": "attach",
"type": "pwa-chrome",
"type": "chrome",
"timeout": 60000,
"skipFiles": [
"<node_internals>/**",

View File

@@ -1,10 +1,11 @@
{
"typescript.tsdk": "node_modules/typescript/lib",
"typescript.enablePromptUseWorkspaceTsdk": true,
"typescript.tsc.autoDetect": "off",
"json.schemas": [
{
"fileMatch": [
"/*electron-builder.json5"
"/*electron-builder.json5",
"/*electron-builder.json"
],
"url": "https://json.schemastore.org/electron-builder"
}

View File

@@ -1,6 +1,6 @@
MIT License
Copyright (c) 2020 草鞋没号
Copyright (c) 2023 草鞋没号
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

View File

@@ -2,12 +2,13 @@
🥳 Really simple `Electron` + `Vue` + `Vite` boilerplate.
[![awesome-vite](https://awesome.re/mentioned-badge.svg)](https://github.com/vitejs/awesome-vite)
[![Netlify Status](https://api.netlify.com/api/v1/badges/ae3863e3-1aec-4eb1-8f9f-1890af56929d/deploy-status)](https://app.netlify.com/sites/electron-vite/deploys)
[![GitHub license](https://img.shields.io/github/license/caoxiemeihao/electron-vite-vue)](https://github.com/electron-vite/electron-vite-vue/blob/main/LICENSE)
[![GitHub stars](https://img.shields.io/github/stars/caoxiemeihao/electron-vite-vue?color=fa6470)](https://github.com/electron-vite/electron-vite-vue)
[![GitHub forks](https://img.shields.io/github/forks/caoxiemeihao/electron-vite-vue)](https://github.com/electron-vite/electron-vite-vue)
<!-- [![awesome-vite](https://awesome.re/mentioned-badge.svg)](https://github.com/vitejs/awesome-vite) -->
<!-- [![Netlify Status](https://api.netlify.com/api/v1/badges/ae3863e3-1aec-4eb1-8f9f-1890af56929d/deploy-status)](https://app.netlify.com/sites/electron-vite/deploys) -->
<!-- [![GitHub license](https://img.shields.io/github/license/caoxiemeihao/electron-vite-vue)](https://github.com/electron-vite/electron-vite-vue/blob/main/LICENSE) -->
<!-- [![GitHub stars](https://img.shields.io/github/stars/caoxiemeihao/electron-vite-vue?color=fa6470)](https://github.com/electron-vite/electron-vite-vue) -->
<!-- [![GitHub forks](https://img.shields.io/github/forks/caoxiemeihao/electron-vite-vue)](https://github.com/electron-vite/electron-vite-vue) -->
[![GitHub Build](https://github.com/electron-vite/electron-vite-vue/actions/workflows/build.yml/badge.svg)](https://github.com/electron-vite/electron-vite-vue/actions/workflows/build.yml)
[![GitHub Discord](https://img.shields.io/badge/chat-discord-blue?logo=discord)](https://discord.gg/sRqjYpEAUK)
## Features
@@ -26,11 +27,11 @@ npm create electron-vite
<!-- [![quick-start](https://asciinema.org/a/483731.svg)](https://asciinema.org/a/483731) -->
![electron-vite-vue.gif](https://github.com/electron-vite/electron-vite-vue/blob/main/public/electron-vite-vue.gif?raw=true)
![electron-vite-vue.gif](/electron-vite-vue.gif)
## Debug
![electron-vite-react-debug.gif](https://github.com/electron-vite/electron-vite-react/blob/main/public/electron-vite-react-debug.gif?raw=true)
![electron-vite-react-debug.gif](https://github.com/electron-vite/electron-vite-react/blob/main/electron-vite-react-debug.gif?raw=true)
## Directory
@@ -47,9 +48,10 @@ npm create electron-vite
└── vite.config.ts
```
<!--
## Be aware
🚨 By default, this template integrates Node.js in the Renderer process. If you don't need it, you just remove the option below. [Because it will modify the default config of Vite](https://github.com/electron-vite/vite-plugin-electron/tree/main/packages/electron-renderer#config-presets-opinionated).
🚨 By default, this template integrates Node.js in the Renderer process. If you don't need it, you just remove the option below. [Because it will modify the default config of Vite](https://github.com/electron-vite/vite-plugin-electron-renderer#config-presets-opinionated).
```diff
# vite.config.ts
@@ -63,8 +65,9 @@ export default {
],
}
```
-->
## FAQ
- [dependencies vs devDependencies](https://github.com/electron-vite/vite-plugin-electron-renderer#dependencies-vs-devdependencies)
- [C/C++ addons, Node.js modules - Pre-Bundling](https://github.com/electron-vite/vite-plugin-electron-renderer#dependency-pre-bundling)
- [dependencies vs devDependencies](https://github.com/electron-vite/vite-plugin-electron-renderer#dependencies-vs-devdependencies)

View File

@@ -2,8 +2,9 @@
* @see https://www.electron.build/configuration/configuration
*/
{
"$schema": "https://raw.githubusercontent.com/electron-userland/electron-builder/master/packages/app-builder-lib/scheme.json",
"appId": "YourAppID",
"asar": true,
"asar": false,
"directories": {
"output": "release/${version}"
},

View File

Before

Width:  |  Height:  |  Size: 3.3 MiB

After

Width:  |  Height:  |  Size: 3.3 MiB

View File

@@ -1,4 +1,4 @@
/// <reference types="vite-electron-plugin/electron-env" />
/// <reference types="vite-plugin-electron/electron-env" />
declare namespace NodeJS {
interface ProcessEnv {

View File

@@ -0,0 +1,152 @@
import type { Browser, Page } from 'puppeteer'
import puppeteer from 'puppeteer-extra'
import StealthPlugin from 'puppeteer-extra-plugin-stealth'
import { clog } from "../tools";
import { awaitWrap, randomNum } from '../tools';
import login from '../login'
import Mock from 'mockjs'
import axios from 'axios'
import { SocksProxyAgent } from 'socks-proxy-agent'
import proxyChain from 'proxy-chain'
// const proxyChain = require('proxy-chain');
puppeteer.use(StealthPlugin())
function getProxy(options = {} as any) {
const log = clog(options)
log('开始获取代理ip')
return axios.get('http://api.proxy.ipidea.io/getBalanceProxyIp?num=1&return_type=json&lb=1&sb=0&flow=1&regions=&protocol=socks5', {
// return axios.get('https://www.miyaip.com/api/ProxyGenerage/PublicGenerateProxy?country=us&city=jaffrey®ion=nh&num=1&apiSwitch=0&mealType=2&genType=2&username=nmfk549724@163.com&secret=E3BCBmiyaipC23358C250F5', {
// return axios.get('http://api.tianqiip.com/getip?secret=loy0r7fpmnlshm8l&num=1&type=json&port=3&time=3&mr=1&sign=5f73ab58ad7ab40346311014bef59b79', {
timeout: 10 * 1000,
}).then(res => {
// // const [user, pass] = res.data.split(':')
// // return { user, pass, ip, port }
// // // return axios.get('https://www.miyaip.com/api/ProxyGenerage/PublicGenerateProxy?country=us&city=cairo®ion=ny&num=1&apiSwitch=0&mealType=2&genType=2&username=nmfk549724@163.com&secret=E3BCBmiyaipC23358C250F5').then(res => {
// const [ip, port] = res.data.replace(/(\n|\r\s)/g, '').split(':')
// console.log({ ip, port, })
// // const [ip, pory, user, pass] = res.data.split(':')
return res.data.data[0]
})
return Promise.resolve({
ip: '43.130.10.70',
port: '22993',
// user: '1E783B07miyaip489C251B3FA7',
// pass: '1g7E3M4U5w03vO'
})
}
// 获取组织id
async function getOrgId(page: Page, options: any) {
const log = clog(options)
log('准备进入组织页面')
await page.goto('https://platform.openai.com/account/org-settings')
await page.waitForSelector('input')
log('开始获取组织id')
const orgId = await page.$$eval('input', (inputs: HTMLInputElement[]) => inputs?.[1].value || '')
log('获取组织id成功', { orgId })
return orgId
}
// 申请
export async function application(page: Page, options = {} as any) {
const log = clog(options)
log('准备进入申请页面')
await page.goto('https://openai.com/waitlist/gpt-4-api')
log('等待出现输入框')
await page.waitForSelector('input')
log('开始申请')
const f = Mock.mock('@first')
const l = Mock.mock('@last')
console.log(f, l);
await page.type('#firstname', f)
await page.type('#lastname', l)
await page.type('#email', options.user)
await page.type('#organizationId', options.orgId)
const i = randomNum(1, 4)
log('选择申请类型', { i })
page.evaluate((i) => {
document.querySelector('#primaryUse').nextSibling.childNodes[i].childNodes[1].click()
}, i)
log('等待 gpt 生成描述')
const desc = await generateDescription(i)
await page.type('#ideas', desc)
log('点击提交申请')
const isSuccess = await page.evaluate((selector, searchText) => {
const elements = Array.from(document.querySelectorAll(selector));
const target = elements.find(el => el.textContent.trim() === searchText);
if (target) target.click()
return !!target
}, 'button', 'Join waitlist')
if (isSuccess) {
log('提交成功,等待 gpt 返回结果')
console.log('isSuccess', isSuccess)
await page.waitForSelector('button[type="submit"] + .ui-richtext')
const text = await page.evaluate(() => document.querySelector('button[type="submit"] + .ui-richtext').textContent)
log('gpt 返回已结果', { result: text })
}
// await page.click('form[data-gtm-form-interact-id] button[type="submit"]')
}
// 生成描述
export async function generateDescription(desIndex = 0): Promise<string> {
const types = {
1: 'Build a new product',
2: 'Integrate into an existing product',
3: 'General exploration of capabilities',
4: 'Academic research',
}
return axios({
url: 'https://api.openai-proxy.com/v1/chat/completions',
method: 'post',
headers: {
Authorization: `Bearer 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`
},
data: {
max_tokens: 1024,
model: 'gpt-3.5-turbo',
messages: [
{ "role": "user", "content": `我在申请gpt4.0,我的类型是 ${types[desIndex]},不要解释,给我一段申请的理由,以我的身份,以英语形式发给我,结尾不要带任何名字或位置,三四句话就行` },
]
},
timeout: 1000 * 30,
}).then(res => {
console.log('gpt 生成描述', res.data.choices[0].message.content)
return res.data.choices[0].message.content
})
}
export async function batchApplication(options) {
const log = clog(options)
log('开始', { ident: 'gpt-batch-4.0' })
const [error, [page, browser]] = await awaitWrap(login.openai(options))
if (error) return log('登录失败', { error, ident: 'gpt-batch-4.0' })
await page.waitForSelector('.ovr-section')
const orgId = await getOrgId(page, options)
options.orgId = orgId
console.log('orgId', orgId)
await application(page, options)
browser.close()
}

View File

@@ -0,0 +1,48 @@
import { clog } from "../tools";
import login from "../login";
export async function getLink(options) {
const log = clog(options)
log('开始', { ident: 'gpt-link', ...options })
const [page, browser] = await login.chatgpt({ ...options, changeUS: false })
// await page.waitForTimeout(500)
await page.waitForSelector('body > div.absolute.inset-0', { timeout: 0 })
await page.evaluate(() => {
const $mark = document.querySelector("body > div.absolute.inset-0")
if ($mark) $mark.hidden = true
document.body.style.pointerEvents = 'all'
})
log('隐藏欢迎页面')
await page.waitForSelector('.gold-new-button', { visible: true })
log('等待升级plus按钮出现')
await page.waitForTimeout(500)
await page.evaluate(() => {
const $mark = document.querySelector("body > div.absolute.inset-0")
if ($mark) $mark.remove()
})
log('开始点击升级plus按钮')
await page.click('.gold-new-button')
const [response] = await Promise.all([
page.waitForNavigation({ waitUntil: 'domcontentloaded', timeout: 0 }),
page.evaluate((selector, searchText) => {
const elements = Array.from(document.querySelectorAll(selector));
const target = elements.find(el => el.textContent.trim() === searchText);
target && target.click()
}, 'button', 'Upgrade plan')
])
if (response.ok()) {
const url = response._request._frame._url
log('获取链接成功', { result: url, type: 'success' })
browser.close()
return url
}
browser.close()
}

View File

@@ -0,0 +1,93 @@
import { ipcMain } from 'electron'
import { getLink } from './getLink'
import { validate } from './validate'
import { batchApplication } from './batchApplication'
import { chunk } from 'lodash'
import { sleep } from '../tools'
const parseAccount = text => text.split('\n').filter(Boolean).map(v => {
v = v.split(/(——|-)+/).filter(v => !['-', '——'].includes(v))
return v
})
ipcMain.handle('gpt-link', async (event, arg) => {
const { text } = arg
// 进程数
const processNum = 2
const totalArr = parseAccount(text)
const accounts = chunk(totalArr, Math.ceil(totalArr.length / processNum))
async function run (accounts) {
for(let i = 0; i < accounts.length; i++) {
const [user, pass] = accounts[i]
const link = await getLink({ user, pass, index: i, id: user, ...arg })
console.log('process', i, user, link)
}
}
const links = []
for(let i = 0; i < accounts.length; i++) {
if (i !== 0) await sleep(2000)
run(accounts[i])
}
})
ipcMain.handle('gpt-result', async (event, arg) => {
const { text } = arg
const accounts = parseAccount(text)
const links = []
for(let i = 0; i < accounts.length; i++) {
const [user, pass] = accounts[i]
const link = await validate({ user, pass, index: i, id: user })
links.push({
i,
user,
link
})
console.log('process', i, user, link)
}
// browser && browser.close()
})
ipcMain.handle('gpt-batch-4.0', async (event, arg) => {
const { text } = arg
const accounts = parseAccount(text)
const links = []
for(let i = 0; i < accounts.length; i++) {
const [user, pass] = accounts[i]
const link = await batchApplication({ user, pass, index: i, id: user })
links.push({
i,
user,
link
})
console.log('process', i, user, link)
}
// browsers.forEach(browser => browser.close())
})
const actions = {
'gpt-link': getLink,
'gpt-result': validate,
'gpt-batch-4.0': batchApplication
}
export async function runActions(action: keyof typeof actions, options: any) {
const { text } = options
const accounts = parseAccount(text)
const links = []
for(let i = 0; i < accounts.length; i++) {
const [user, pass] = accounts[i]
const link = await batchApplication({ user, pass, index: i, id: user })
links.push({
i,
user,
link
})
console.log('process', i, user, link)
}
}

View File

@@ -0,0 +1,28 @@
import { clog } from "../tools";
import login from "../login";
export async function validate(options) {
const log = clog(options)
log('开始', { ident: 'gpt-validate' })
const [page, browser] = await login.chatgpt(options)
await page.waitForSelector('body > div.absolute.inset-0')
await page.evaluate(() => {
const $mark = document.querySelector("body > div.absolute.inset-0")
if ($mark) $mark.hidden = true
document.body.style.pointerEvents = 'all'
})
log('隐藏欢迎页面,开始检测')
await page.waitForTimeout(2000)
const isSuccess = await page.evaluate((selector, searchText) => {
const elements = Array.from(document.querySelectorAll(selector));
const target = elements.find(el => el.textContent.trim() === searchText);
return !!target
}, 'button', 'GPT-4')
log('获取链接成功', { result: isSuccess ? '充值成功😘' : '充值失败😭', type: isSuccess ? 'success' : 'fail' })
console.log(isSuccess)
browser.close()
}

View File

@@ -1,3 +1,25 @@
import { app, BrowserWindow, shell, ipcMain } from 'electron'
import { release } from 'node:os'
import { join } from 'node:path'
import './poe/index'
import './gpt/index'
import { browsers, test1 } from './tools'
import puppeteer from 'puppeteer-extra'
import StealthPlugin from 'puppeteer-extra-plugin-stealth'
puppeteer.use(StealthPlugin())
// test1()
// puppeteer.launch({
// headless: false,
// args: [
// '--no-sandbox',
// '--disable-setuid-sandbox',
// '--proxy-server=socks5://127.0.0.1:40000'
// ]
// })
// The built directory structure
//
// ├─┬ dist-electron
@@ -10,11 +32,9 @@
//
process.env.DIST_ELECTRON = join(__dirname, '..')
process.env.DIST = join(process.env.DIST_ELECTRON, '../dist')
process.env.PUBLIC = app.isPackaged ? process.env.DIST : join(process.env.DIST_ELECTRON, '../public')
import { app, BrowserWindow, shell, ipcMain } from 'electron'
import { release } from 'os'
import { join } from 'path'
process.env.PUBLIC = process.env.VITE_DEV_SERVER_URL
? join(process.env.DIST_ELECTRON, '../public')
: process.env.DIST
// Disable GPU Acceleration for Windows 7
if (release().startsWith('6.1')) app.disableHardwareAcceleration()
@@ -32,7 +52,7 @@ if (!app.requestSingleInstanceLock()) {
// Read more on https://www.electronjs.org/docs/latest/tutorial/security
// process.env['ELECTRON_DISABLE_SECURITY_WARNINGS'] = 'true'
let win: BrowserWindow | null = null
export let win: BrowserWindow | null = null
// Here, you can also use other preload
const preload = join(__dirname, '../preload/index.js')
const url = process.env.VITE_DEV_SERVER_URL
@@ -41,6 +61,8 @@ const indexHtml = join(process.env.DIST, 'index.html')
async function createWindow() {
win = new BrowserWindow({
title: 'Main window',
width: 1000,
height: 800,
icon: join(process.env.PUBLIC, 'favicon.ico'),
webPreferences: {
preload,
@@ -54,8 +76,10 @@ async function createWindow() {
if (process.env.VITE_DEV_SERVER_URL) { // electron-vite-vue#298
win.loadURL(url)
console.log('process.env.VITE_DEV_SERVER_URL', process.env.VITE_DEV_SERVER_URL);
// Open devTool if the app is not packaged
win.webContents.openDevTools()
// win.webContents.openDevTools()
} else {
win.loadFile(indexHtml)
}
@@ -70,6 +94,7 @@ async function createWindow() {
if (url.startsWith('https:')) shell.openExternal(url)
return { action: 'deny' }
})
// win.webContents.on('will-navigate', (event, url) => { }) #344
}
app.whenReady().then(createWindow)
@@ -96,8 +121,8 @@ app.on('activate', () => {
}
})
// new window example arg: new windows url
ipcMain.handle('open-win', (event, arg) => {
// New window example arg: new windows url
ipcMain.handle('open-win', (_, arg) => {
const childWindow = new BrowserWindow({
webPreferences: {
preload,
@@ -106,10 +131,14 @@ ipcMain.handle('open-win', (event, arg) => {
},
})
if (app.isPackaged) {
childWindow.loadFile(indexHtml, { hash: arg })
} else {
if (process.env.VITE_DEV_SERVER_URL) {
childWindow.loadURL(`${url}#${arg}`)
// childWindow.webContents.openDevTools({ mode: "undocked", activate: true })
} else {
childWindow.loadFile(indexHtml, { hash: arg })
}
})
ipcMain.handle('stop', async (event, arg) => {
browsers.forEach(browser => browser.close())
return true
})

373
electron/main/login.ts Normal file
View File

@@ -0,0 +1,373 @@
import type { Page, Browser } from 'puppeteer'
import { browsers, clog, statusCheck } from './tools'
import { awaitWrap, browserAndPage, randomNum } from './tools'
const login = {
// poe 邮箱登录
async poe_email(options, getCodeFn: Function, tryCount = 1): Promise<[Page, Browser]> {
const log = clog(options)
if (tryCount > 2) {
log('重试次数已达上限')
throw '重试次数已达上限'
return
}
log('启动浏览器')
const { browser, page } = await browserAndPage({ ...options, proxy: true })
log('正在进入登录页面')
await page.goto('https://poe.com/login')
log('设置登录方式')
await page.evaluate((selector, searchText) => {
const elements = Array.from(document.querySelectorAll(selector));
const target = elements.find(el => el.textContent.trim() === searchText);
if (!target) return false
const text = target.nextElementSibling?.textContent || ''
if (text.includes('email')) target.nextElementSibling.click()
}, 'button', 'Go')
log('开始输入邮箱')
await page.waitForSelector('input[type="email"]')
await page.type('input[type="email"]', options.user)
await page.waitForTimeout(1000)
await statusCheck(
async () => await page.keyboard.press('Enter'),
async () => await page.$('.LoadingDots_wrapper__lXyQd'), // LoadingDots_wrapper__lXyQd
)
// 检查是否有错误
const isOk = await Promise.race([
page.waitForSelector('.InfoText_error__OQwmg').then(() => false),
page.waitForSelector('input[class^="VerificationCodeInput_verificationCodeInput"]').then(() => true)
])
console.log('isOk', isOk)
if (!isOk) {
const reason = await page.$eval('.InfoText_error__OQwmg', (el: HTMLElement) => el.textContent.trim())
if (reason.startsWith('Something')) {
await page.waitForTimeout(3482)
await statusCheck(
async () => await page.keyboard.press('Enter'),
async () => await page.$('.LoadingDots_wrapper__lXyQd'), // LoadingDots_wrapper__lXyQd
)
} else {
log('', { result: `登录失败: ${reason}` })
browser.close()
throw '登录失败'
}
// return login.poe_email(options, getCodeFn, tryCount + 1)
}
// await page.keyboard.press('Enter')
log('开始输入密码')
const code = await getCodeFn(options, { page, browser })
await page.type('input[class^=VerificationCodeInput_verificationCodeInput]', code)
await page.keyboard.press('Enter')
await page.waitForNavigation()
return [page, browser]
},
async poe_google(options, tryCount = 1): Promise<[Page, Browser]> {
let resolve: (value: [Page, Browser] | PromiseLike<[Page, Browser]>) => void,
reject
const log = clog(options)
const p = new Promise<[Page, Browser]>((res, rej) => {
resolve = res
reject = rej
})
const env = {
GUSER: options.user,
GPASS: options.pass
}
const { browser, page } = await browserAndPage(options)
log('开始访问 poe')
await page.goto('https://poe.com')
log('已进入 poe')
await page.waitForTimeout(randomNum(1000, 2600))
log('准备进入 google 登录页')
page.click('.ContinueWithGoogleButton_buttonContentWrapper__Mrp0W')
const [err, response] = await awaitWrap(page.waitForNavigation({ timeout: 10000 }))
if (err) {
reject({ text: '登录报错', try: true })
return p
}
log('已进入 google 登录页')
if (response.ok()) {
await page.waitForSelector('input[type="email"]')
log('准备输入账号')
await page.type('input[type="email"]', env.GUSER)
await Promise.all([
page.waitForNavigation(),
await page.keyboard.press('Enter')
])
log('已输入账号,准备输入密码')
if (await isError(page)) {
reject({ text: '登录报错', try: true })
return p
}
await page.waitForSelector('input[type="password"]', { visible: true })
await page.type('input[type="password"]', env.GPASS)
log('已输入密码,开始登录')
await Promise.all([
page.waitForFunction(() => location.href === 'https://poe.com/'),
await page.keyboard.press('Enter')
])
if (await isError(page)) {
reject({ text: '登录报错', try: true })
return p
}
log('登录成功,准备进入 poe')
resolve([page, browser])
return p
}
if (tryCount < 4) {
log(`google 登录失败,准备 ${tryCount} 次重试`)
await page.close()
return await login.poe_google(options, tryCount + 1)
} else {
log('google 登录失败,重试次数已达上限')
reject('google 登录失败')
}
return p
},
async openai(options): Promise<[Page, Browser]> {
const { user, pass } = options
const log = clog(options)
log('启动浏览器')
const { browser, page } = await browserAndPage({ ...options, changeUS: false })
log('准备进入 gpt 登录')
await page.goto('https://platform.openai.com')
log('等待出现输入框')
await page.waitForSelector('#username', { visible: true, timeout: 10000 })
// 输入账号
log('输入账号')
await page.type('#username', user)
await Promise.all([
page.waitForNavigation(),
page.keyboard.press('Enter')
])
log('等待出现密码输入框')
await page.waitForSelector('#password', { visible: true })
log('输入密码')
await page.type('#password', pass)
log('准备登录')
await Promise.all([
page.waitForNavigation({ timeout: 10000 }),
page.keyboard.press('Enter')
])
log('登录成功')
return [page, browser]
},
/**
* 登录邮箱并获取验证码
*/
async mail_get_code(options): Promise<[Page, Browser, {
code?: string,
validateCode: () => Promise<string>
}]> {
const { emailText = 'Poe' } = options
const log = clog(options)
const { browser, page } = await browserAndPage({ ...options })
log('准备进入邮箱登录页')
const [error] = await awaitWrap(page.goto('https://www.mail.com/', { waitUntil: 'domcontentloaded' }))
await page.waitForSelector('.header-bar .button-login')
await page.click('.header-bar .button-login')
log('输入帐密')
await page.waitForTimeout(500)
await page.waitForSelector('input#login-email')
await page.waitForTimeout(500)
await page.type('input#login-email', options.user)
await page.type('input#login-password', options.pass)
await page.keyboard.press('Enter')
log('开始登录')
/**
*
* @param reload 是否点击刷新验证码按钮
*/
async function validateCode() {
log('开始获取code')
let $iframe = await page.$('#thirdPartyFrame_home')
let frame = await $iframe?.contentFrame()
if (!frame) {
log('未找到页面,刷新重试中...')
await page.reload()
return await validateCode()
}
const [err] = await awaitWrap(frame.waitForSelector('ul.inbox-container li', { timeout: 4000 }))
if (err) {
console.log(err)
console.log('有报错')
await frame.waitForSelector('.ico.sync')
const sync = await page.$('.ico.sync')
if (!sync) {
console.log('未找到刷新按钮')
log('未找到刷新按钮')
return ''
}
await frame.click('.ico.sync')
await frame.waitForTimeout(4000)
return await validate()
}
return await validate()
// console.log('type', type)
// if (type === 'list') {
// return await validate()
// }
await frame.waitForSelector('.ico.sync')
await frame.click('.ico.sync')
await frame.waitForTimeout(1000)
await frame.waitForSelector('ul.inbox-container li')
log('查找邮箱')
async function validate() {
const $li = await frame.evaluate((emailText) => {
const $li: any = Array.from(document.querySelectorAll('ul.inbox-container li')).find($li => {
let sender = $li.querySelector('.sender')?.textContent || ''
return sender.includes(emailText)
})
if ($li) $li.click()
return $li
}, emailText)
if (!$li) {
log('未找到邮箱')
return ''
} else {
log('等待出现验证码 iframe')
await page.waitForSelector('#thirdPartyFrame_mail')
log('出现了验证码 iframe,寻找他的 iframe')
$iframe = await page.$('#thirdPartyFrame_mail')
frame = await $iframe?.contentFrame()
await frame.waitForSelector('iframe#mail-detail')
log('出现验证码 iframe')
$iframe = await frame.$('iframe#mail-detail')
frame = await $iframe?.contentFrame()
log('等待验证码')
await frame.waitForSelector('table table table ')
const code = (await frame.$eval('table table table tr:nth-of-type(5)', el => el.textContent)) || ''
return code.trim()
}
}
}
await awaitWrap(page.waitForNavigation({ waitUntil: 'load' }))
const code = await validateCode()
log(`邮箱验证码 ${code}`)
return [page, browser, { code, validateCode }]
},
async chatgpt(options, tryCount = 1): Promise<[Page, Browser]> {
let resolve: (value: [Page, Browser] | PromiseLike<[Page, Browser]>) => void,
reject
const log = clog(options)
const p = new Promise<[Page, Browser]>((res, rej) => {
resolve = res
reject = rej
})
const env = {
GUSER: options.user,
GPASS: options.pass
}
const { browser, page } = await browserAndPage({ ...options, changeUS: false })
log('开始访问 gpt')
await page.goto('https://chat.openai.com/auth/login')
await page.waitForSelector('button')
// log('准备进入 google 登录页')
const [response] = await Promise.all([
page.waitForNavigation({ timeout: 0 }),
page.click('button')
])
// log('已进入 google 登录页')
if (!response.ok()) {
log('进入 google 登录页失败')
reject('进入 google 登录页失败')
return p
}
log('准备输入账号')
await page.type('#username', env.GUSER)
await Promise.all([
page.waitForNavigation({ timeout: 0 }),
page.keyboard.press('Enter')
])
log('已输入账号,准备输入密码')
await page.waitForSelector('#password', { visible: true })
await page.type('#password', env.GPASS)
log('已输入密码,开始登录')
await Promise.all([
page.waitForNavigation({ timeout: 10000, waitUntil: 'domcontentloaded' }),
page.keyboard.press('Enter')
])
log('登录成功')
resolve([page, browser])
return p
},
closeAll() {
browsers.map(b => b.close())
}
}
export default login
async function isError(page: Page) {
const text = await page.evaluate(() => (document.querySelector('p')?.textContent || ''));
// const text = await page.evaluate('p', element => element.textContent);
return text && text.includes('error')
}

193
electron/main/poe/cookie.ts Normal file
View File

@@ -0,0 +1,193 @@
import type { Browser, Page } from 'puppeteer'
import puppeteer from 'puppeteer-extra'
import StealthPlugin from 'puppeteer-extra-plugin-stealth'
import { browserAndPage, browsers, clog, createPromise, statusCheck } from "../tools"
import login from '../login'
puppeteer.use(StealthPlugin())
export async function getCookie(options) {
console.log('options', options);
const log = clog(options)
log('开始', { ident: 'link_7day' })
let { p, resolve, reject } = createPromise<string>()
login.mail_get_code({ ...options, changeUS: false }).then(async ([page, browser, options]) => {
const isOk = await statusCheck(
() => options.code,
async () => {
log('未获取验证码,重试一次', { ident: 'link_7day' })
options.code = await options.validateCode()
return options.code
},
{ interval: 4000 }
)
resolve(options.code)
browser.close()
})
const [page, browser] = await login.poe_email(options, async () => {
const code = await p
console.log('获取验证码结果', code)
if (!code) {
log('获取验证码失败', { ident: 'link_7day' })
reject('获取验证码失败')
throw '获取验证码失败'
}
return code
}).catch(() => '' as any)
// 登录失败了
if (!page) {
console.log('登录失败了')
browsers.map(b => b.close())
return
}
const cookies = await page.cookies()
const token = cookies.find(v => v.name === 'p-b')?.value
log('获取token', { result: token })
console.log('cookies', cookies)
// browser.close()
// await page.waitForTimeout(2000)
browser.close()
// const { page } = await login.poe_email(options)
}
async function recharge(options: {
browser: Browser,
page: Page,
user: string,
liao: any,
}) {
const { browser, page, liao, ...args } = options
const log = clog(args)
log('开始充值')
await page.waitForSelector('#cardNumber')
await page.evaluate(() => {
const btn: HTMLElement = document.querySelector('.AddressAutocomplete-manual-entry .Link')
if (btn) btn.click()
})
await page.evaluate((email: string) => {
const el: HTMLInputElement = document.querySelector('#email')
if (el) el.value = email
}, options.user)
await page.type('#cardNumber', liao.bank)
await page.type('#cardExpiry', liao.date)
await page.type('#cardCvc', liao.cvc)
await page.type('#billingName', liao.name)
await page.select('#billingCountry', liao.nation)
await page.type('#billingAddressLine1', liao.address)
await page.type('#billingLocality', liao.city)
await page.type('#billingPostalCode', liao.postalCode)
await page.waitForTimeout(1000)
await page.click('.SubmitButton-IconContainer')
// await page.waitForTimeout(9000)
// await page.waitForSelector('iframe')
// let $frame = await page.$('iframe')
// let frame = await $frame.contentFrame()
// console.log('$frame', $frame)
// // console.log('frame', frame)
// await $frame.waitForSelector('iframe')
// $frame = await frame.$('iframe')
// frame = await $frame.contentFrame()
// await frame.waitForSelector('iframe')
// $frame = await frame.$('iframe')
// frame = await $frame.contentFrame()
// await frame.waitForSelector('#checkbox', { timeout: 0 })
// await frame.click('#checkbox')
// await page.waitForNavigation()
console.log('充值成功')
log('充值成功')
}
function existDialog(page: Page) {
return page.evaluate((selector, searchText) => {
const elements = Array.from(document.querySelectorAll(selector));
const target = elements.find(el => el.textContent.trim() === searchText);
target && target.click()
return !!target
}, 'button', 'Start free trial')
}
export async function getLink(options, [page, browser]: [Page, Browser]) {
const log = clog(options)
log('开始', { ident: 'poe-link' })
await page.waitForTimeout(1000)
const isExistDialog = await existDialog(page)
isExistDialog && log('检测到充值弹窗,无需前往设置页')
if (!isExistDialog) {
await Promise.all([
page.waitForNavigation(),
page.goto('https://poe.com/settings')
])
log('已进入设置页面, 检查中')
const existMange = await page.evaluate(() => {
const mange = document.querySelector('[class*="SettingsSubscriptionSection_manageSubscription"]')
if (mange) return true
return false
})
if (existMange) {
log('已经订阅')
return
}
await page.waitForSelector('[class*=SettingsSubscriptionSection_subscribeButton]', { timeout: 0 })
page.waitForTimeout(500)
log('点击显示订阅套餐按钮')
// await page.click('[class*=SettingsSubscriptionSection_subscribeButton]')
const disabled = await page.$eval('[class*=SettingsSubscriptionSection_subscribeButton]', (el: HTMLButtonElement) => el.disabled)
if (disabled) {
log('订阅按钮不可用,地区不可用')
return
}
await statusCheck(
async () => {
return page.evaluate(() => {
const $el = document.querySelector("[class*=SettingsSubscriptionSection_subscribeButton]")
console.log('$el', $el)
$el.click();
})
},
// async () => page.click('[class*=SettingsSubscriptionSection_subscribeButton]'),
async () => page.$('.Modal_modal__SxITf'),
)
}
// log('显示更多套餐')
// await page.waitForSelector('[class*=WebSubscriptionFreeTrial_viewAllPlansButton]')
// await page.click('[class*=WebSubscriptionFreeTrial_viewAllPlansButton]')
// log('点击最后一个套餐')
// await page.waitForSelector('[class*=WebSubscriptionPaywall_plans]')
// await page.click('[class*=WebSubscriptionPaywall_plans] > button:last-child')
// 点击订阅
log('4, 开始点击订阅')
await page.waitForSelector('[class*=WebSubscriptionPaywall_button]', { timeout: 0 })
page.click('[class*=WebSubscriptionPaywall_button]')
const [response] = await Promise.all([
page.waitForNavigation({ waitUntil: 'domcontentloaded' }),
])
if (response.ok()) {
const url = response._request._frame._url
log('获取链接成功', { result: url, type: 'success' })
return url
}
}

View File

@@ -0,0 +1,69 @@
import { clog } from '../tools'
import type { Page } from 'puppeteer'
import path from 'path'
import login from '../login'
function existDialog(page: Page) {
return page.evaluate((selector, searchText) => {
const elements = Array.from(document.querySelectorAll(selector));
const target = elements.find(el => el.textContent.trim() === searchText);
target && target.click()
return !!target
}, 'button', 'Start free trial')
}
export async function getLink(options) {
const log = clog(options)
log('开始', { ident: 'poe-link' })
return login.poe_google(options).then(async ([page, browser]) => {
await page.waitForTimeout(1000)
const isExistDialog = await existDialog(page)
isExistDialog && log('检测到充值弹窗,无需前往设置页')
if (!isExistDialog) {
await Promise.all([
page.waitForNavigation(),
page.goto('https://poe.com/settings')
])
log('已进入设置页面, 检查中')
await page.waitForSelector('[class*=SettingsSubscriptionSection_subscribeButton]')
log('点击显示订阅套餐按钮')
await page.click('[class*=SettingsSubscriptionSection_subscribeButton]')
}
log('显示更多套餐')
await page.waitForSelector('[class*=WebSubscriptionFreeTrial_viewAllPlansButton]')
await page.click('[class*=WebSubscriptionFreeTrial_viewAllPlansButton]')
log('点击最后一个套餐')
await page.waitForSelector('[class*=WebSubscriptionPaywall_plans]')
await page.click('[class*=WebSubscriptionPaywall_plans] > button:last-child')
// 点击订阅
log('4, 开始点击订阅')
page.click('[class*=WebSubscriptionPaywall_button]')
const [response] = await Promise.all([
page.waitForNavigation({ waitUntil: 'domcontentloaded' }),
])
if (response.ok()) {
const url = response._request._frame._url
log('获取链接成功', { result: url, type: 'success' })
browser.close()
return url
}
browser.close()
}).catch(error => {
console.log('error ->', error.try, error.text, error)
if (error?.try) {
return getLink(options)
}
})
}
function resolve(url) {
return path.resolve(__dirname, '../src/poe/', url)
}

102
electron/main/poe/index.js Normal file
View File

@@ -0,0 +1,102 @@
import { getLink } from './getLink'
import { validate } from './validate'
import { ipcMain } from 'electron'
import { link_7day } from './link_7day'
import { getCookie } from './cookie'
import { browserAndPage } from '../tools'
export const parseAccount = text => text.split('\n').filter(Boolean).map(v => {
v = v.split(/(——|-)+/).filter(v => !['-', '——'].includes(v))
return v
})
ipcMain.handle('getLink', async (event, arg) => {
const { text } = arg
const accounts = parseAccount(text)
const links = []
for (let i = 0; i < accounts.length; i++) {
const [user, pass, auxiliary] = accounts[i]
const link = await getLink({ user, pass, auxiliary, index: i, id: user })
// .catch(err => {
// console.log('error ->', err)
// })
links.push({
i,
user,
link
})
console.log('process', i, user, link)
}
return links
})
ipcMain.handle('get-poe-link-7day', async (event, arg) => {
const { text, liao } = arg
const accounts = parseAccount(text)
const links = []
for (let i = 0; i < accounts.length; i++) {
const [user, pass, auxiliary] = accounts[i]
const link = await link_7day({ user, pass, auxiliary, index: i, id: user, liao })
// .catch(err => {
// console.log('error ->', err)
// })
links.push({
i,
user,
link
})
console.log('process', i, user, link)
}
return links
})
ipcMain.handle('get-poe-cookie', async (event, arg) => {
const { text, liao } = arg
const accounts = parseAccount(text)
const links = []
for (let i = 0; i < accounts.length; i++) {
const [user, pass, auxiliary] = accounts[i]
const link = await getCookie({ user, pass, auxiliary, index: i, id: user, liao })
// .catch(err => {
// console.log('error ->', err)
// })
links.push({
i,
user,
link
})
console.log('process', i, user, link)
}
return links
})
ipcMain.handle('poe-result', async (event, arg) => {
const { text } = arg
const accounts = parseAccount(text)
const links = []
for (let i = 0; i < accounts.length; i++) {
const [user, pass, auxiliary] = accounts[i]
const link = await validate({ user, pass, auxiliary, index: i, id: user })
// .catch(err => {
// console.log('error ->', err)
// })
links.push({
i,
user,
link
})
console.log('process', i, user, link)
}
return links
})
ipcMain.handle('start-one-chrom', async (event, arg) => {
browserAndPage({ proxy: true })
})

View File

@@ -0,0 +1,217 @@
import type { Browser, Page } from 'puppeteer'
import puppeteer from 'puppeteer-extra'
import StealthPlugin from 'puppeteer-extra-plugin-stealth'
import { awaitWrap, browserAndPage, browsers, clog, createPromise, statusCheck } from "../tools"
import login from '../login'
puppeteer.use(StealthPlugin())
export async function link_7day(options) {
console.log('options', options);
const log = clog(options)
log('开始', { ident: 'link_7day' })
let { p, resolve, reject } = createPromise<string>()
login.mail_get_code({ ...options, changeUS: false }).then(async ([page, browser, options]) => {
const isOk = await statusCheck(
() => options.code,
async () => {
log('未获取验证码,重试一次', { ident: 'link_7day' })
options.code = await options.validateCode()
return options.code
},
{ interval: 4000 }
)
resolve(options.code)
browser.close()
})
const [page, browser] = await login.poe_email(options, async () => {
const code = await p
console.log('获取验证码结果', code)
if (!code) {
log('获取验证码失败', { ident: 'link_7day' })
reject('获取验证码失败')
throw '获取验证码失败'
}
return code
}).catch(() => '' as any)
// 登录失败了
if (!page) {
console.log('登录失败了')
browsers.map(b => b.close())
return
}
const url = await getLink(options, [page, browser])
return url
if (url && options.liao) {
await recharge({ ...options, page, browser })
}
// browser.close()
// await page.waitForTimeout(2000)
// browser.close()
// const { page } = await login.poe_email(options)
}
async function test() {
const url = 'https://checkout.stripe.com/c/pay/cs_live_a1MXhrEYuI3qJEjw85zmuIxjFsgswafv0xlcxUGAOIeyiGJBGLA56mvRto#fidkdWxOYHwnPyd1blppbHNgWjxITDJsdEROY3Y1NjZpNTc8Q1RMU3ZTNicpJ2N3amhWYHdzYHcnP3F3cGApJ2lkfGpwcVF8dWAnPyd2bGtiaWBabHFgaCcpJ2BrZGdpYFVpZGZgbWppYWB3dic%2FcXdwYHgl'
const liao = {"bank":"4833160230060672","cvc":"727","date":"04/26","name":"Zackary Wais","address":"1200LakeshoreaveApt8G","city":"Oakland","postalCode":"94606","nation":"US"}
const user = 'neletegcongder@mail.com'
const { page, browser } = await browserAndPage()
await page.goto(url, { waitUntil: 'domcontentloaded' })
await recharge({ browser, page, user, liao })
}
// test()
async function recharge(options: {
browser: Browser,
page: Page,
user: string,
liao: any,
}) {
const { browser, page, liao, ...args } = options
const log = clog(args)
log('开始充值')
await page.waitForSelector('#cardNumber')
await page.evaluate(() => {
const btn: HTMLElement = document.querySelector('.AddressAutocomplete-manual-entry .Link')
if (btn) btn.click()
})
const isEmail = await page.evaluate((email: string) => {
const el: HTMLInputElement = document.querySelector('#email')
return !!el
}, options.user)
if (isEmail) await page.type('#email', options.user)
await page.type('#cardNumber', liao.bank)
await page.type('#cardExpiry', liao.date)
await page.type('#cardCvc', liao.cvc)
await page.type('#billingName', liao.name)
await page.select('#billingCountry', liao.nation)
await page.type('#billingAddressLine1', liao.address)
await page.type('#billingLocality', liao.city)
await page.type('#billingPostalCode', liao.postalCode)
await page.waitForTimeout(1000)
await page.click('.SubmitButton-IconContainer')
// await page.waitForTimeout(8000)
// const [error, config] = await awaitWrap(page.solveRecaptchas())
// if (error) {
// log('充值失败', { result: '充值失败', })
// } else {
// console.log(config)
// log('充值成功', { result: '充值成功', })
// }
// await page.waitForSelector('iframe')
// let $frame = await page.$('iframe')
// let frame = await $frame.contentFrame()
// console.log('$frame', $frame)
// // console.log('frame', frame)
// await frame.waitForSelector('iframe')
// $frame = await frame.$('iframe')
// frame = await $frame.contentFrame()
// await frame.waitForSelector('iframe')
// $frame = await frame.$('iframe')
// frame = await $frame.contentFrame()
// await frame.waitForSelector('#checkbox', { timeout: 0 })
// await frame.click('#checkbox')
await page.waitForNavigation()
console.log('充值成功')
log('充值成功')
}
function existDialog(page: Page) {
return page.evaluate((selector, searchText) => {
const elements = Array.from(document.querySelectorAll(selector));
const target = elements.find(el => el.textContent.trim() === searchText);
target && target.click()
return !!target
}, 'button', 'Start free trial')
}
export async function getLink(options, [page, browser]: [Page, Browser]) {
const log = clog(options)
log('开始', { ident: 'poe-link' })
await page.waitForTimeout(1000)
const isExistDialog = await existDialog(page)
isExistDialog && log('检测到充值弹窗,无需前往设置页')
if (!isExistDialog) {
await Promise.all([
page.waitForNavigation(),
page.goto('https://poe.com/settings')
])
log('已进入设置页面, 检查中')
const existMange = await page.evaluate(() => {
const mange = document.querySelector('[class*="SettingsSubscriptionSection_manageSubscription"]')
if (mange) return true
return false
})
if (existMange) {
log('已经订阅')
return
}
await page.waitForSelector('[class*=SettingsSubscriptionSection_subscribeButton]', { timeout: 0 })
page.waitForTimeout(500)
log('点击显示订阅套餐按钮')
// await page.click('[class*=SettingsSubscriptionSection_subscribeButton]')
const disabled = await page.$eval('[class*=SettingsSubscriptionSection_subscribeButton]', (el: HTMLButtonElement) => el.disabled)
if (disabled) {
log('订阅按钮不可用,地区不可用')
return
}
await statusCheck(
async () => {
return page.evaluate(() => {
const $el = document.querySelector("[class*=SettingsSubscriptionSection_subscribeButton]")
console.log('$el', $el)
$el.click();
})
},
// async () => page.click('[class*=SettingsSubscriptionSection_subscribeButton]'),
async () => page.$('.Modal_modal__SxITf'),
)
}
// log('显示更多套餐')
// await page.waitForSelector('[class*=WebSubscriptionFreeTrial_viewAllPlansButton]')
// await page.click('[class*=WebSubscriptionFreeTrial_viewAllPlansButton]')
// log('点击最后一个套餐')
// await page.waitForSelector('[class*=WebSubscriptionPaywall_plans]')
// await page.click('[class*=WebSubscriptionPaywall_plans] > button:last-child')
// 点击订阅
log('4, 开始点击订阅')
await page.waitForSelector('[class*=WebSubscriptionPaywall_button]', { timeout: 0 })
page.click('[class*=WebSubscriptionPaywall_button]')
const [response] = await Promise.all([
page.waitForNavigation({ waitUntil: 'domcontentloaded' }),
])
if (response.ok()) {
const url = response._request._frame._url
log('获取链接成功', { result: url, type: 'success' })
return url
}
}

View File

@@ -0,0 +1,26 @@
import login from '../login'
import path from 'path'
import { clog } from '../tools'
export async function validate (options) {
const log = clog(options)
log('开始', { ident: 'poe-validate' })
const [page, browser] = await login.poe_google(options)
await Promise.all([
page.waitForNavigation(),
page.goto('https://poe.com/settings')
])
log('已进入设置页面, 检查中', { ident: 'poe-validate' })
const length = await page.$$eval('.SettingsSubscriptionSection_botLimitSection__j4mSO > div:first-child > div', (doms) => doms.length)
const resultTxt = length === 1 ? '失败😭' : '成功😘'
log(resultTxt, { type: length === 1 ? 'fail' : 'success', result: length === 1 ? '失败😭' : '成功😘' })
browser.close()
}
function resolve (url) {
return path.resolve(__dirname, '../src/poe/', url)
}

236
electron/main/tools.ts Normal file
View File

@@ -0,0 +1,236 @@
import type { Page } from "puppeteer"
import puppeteer from 'puppeteer-extra'
import StealthPlugin from 'puppeteer-extra-plugin-stealth'
import RecaptchaPlugin from 'puppeteer-extra-plugin-recaptcha'
import chromeLauncher from 'chrome-launcher'
import { win } from './index'
import fakeUa from 'fake-useragent'
import axios from "axios"
puppeteer.use(StealthPlugin())
puppeteer.use(RecaptchaPlugin({
provider: {
id: '2captcha',
token: '25bd4a3638f3836b0d119007cbc21954'
},
visualFeedback: true
}))
export function test1() {
// puppeteer-extra is a drop-in replacement for puppeteer,
// it augments the installed puppeteer with plugin functionality
const puppeteer = require('puppeteer-extra')
// add recaptcha plugin and provide it your 2captcha token (= their apiKey)
// 2captcha is the builtin solution provider but others would work as well.
// Please note: You need to add funds to your 2captcha account for this to work
const RecaptchaPlugin = require('puppeteer-extra-plugin-recaptcha')
puppeteer.use(
RecaptchaPlugin({
provider: {
id: '2captcha',
token: '25bd4a3638f3836b0d119007cbc21954' // REPLACE THIS WITH YOUR OWN 2CAPTCHA API KEY ⚡
},
visualFeedback: true // colorize reCAPTCHAs (violet = detected, green = solved)
})
)
// puppeteer usage as normal
puppeteer.launch({ headless: false }).then(async browser => {
const page = await browser.newPage()
await page.goto('https://www.google.com/recaptcha/api2/demo')
// That's it, a single line of code to solve reCAPTCHAs 🎉
const {
captchas,
filtered,
solutions,
solved,
error
} = await page.solveRecaptchas()
console.log({ captchas, filtered, solutions, solved, error })
await Promise.all([
page.waitForNavigation(),
page.click(`#recaptcha-demo-submit`)
])
await page.screenshot({ path: 'response.png', fullPage: true })
await browser.close()
})
}
//生成从minNum到maxNum的随机数
export function randomNum (min, max) {
return parseInt(Math.random() * (max - min + 1) + min)
}
// promise 错误处理
export function awaitWrap<T, U = any>(promise: Promise<T>): Promise<[U | null, T | null]> {
return promise
.then<[null, T]>((data: T) => [null, data])
.catch<[U, null]>(err => [err, null])
}
// 设置页面请求
export function pageRequest (page: Page) {
page.setRequestInterception(true)
page.on('request', (request) => {
if (['stylesheet', 'font'].indexOf(request.resourceType()) !== -1) {
request.abort()
} else {
request.continue()
}
})
}
export const browsers = []
export async function browserAndPage (options: any = {}) {
const { request, changeUS = true, proxy = false } = options
async function proxyCommand () {
// const proxy = (await axios.get('http://127.0.0.1:10101/api/get_ip_list?num=1&country=US&state=all&city=all&zip=all&isp=all&t=1&port=40000&ip_time=1')).data
console.log('proxy', proxy);
// return proxy ?
return `--proxy-server=socks5://127.0.0.1:40000`
}
const args = [
'--no-sandbox',
'--disable-setuid-sandbox',
'--disable-web-security',
'--disable-features=IsolateOrigins,site-per-process,SitePerProcess',
'--flag-switches-begin --disable-site-isolation-trials --flag-switches-end'
]
proxy ? args.push(await proxyCommand()) : null
// proxy ? args.push(await proxyCommand()) : ''
const browser = await puppeteer.launch({
headless: false,
args
})
browsers.push(browser)
const close = browser.close
browser.close = async function () {
let i = browsers.find(b => b === browser)
await close.call(this)
if (i !== -1) browsers.slice(i, 1)
}
const page = await browser.newPage()
console.log('fakeUa', fakeUa());
changeUS && page.setUserAgent(fakeUa())
await page.setExtraHTTPHeaders({
'accept-language': 'en-US,en;q=0.9,hy;q=0.8'
})
if (request) pageRequest(page)
return { browser, page }
}
function getProxy () {
return axios({
url: 'http://api.tianqiip.com/getip?secret=loy0r7fpmnlshm8l&num=1&type=json&port=3&time=5&mr=1&sign=5f73ab58ad7ab40346311014bef59b79',
method: 'get',
}).then(res => {
console.log('proxy', res.data.data[0])
return res.data.data[0]
}).catch(err => {
console.log(err)
})
}
/**
* 记录日志
*/
export function clog(options) {
return (info, data = {}) => {
if (win) {
win?.webContents?.send?.('progress', { ...options, info, ...data })
}
}
}
/**
* 创建一个 promise
*/
export function createPromise<T> () {
let resolve: (value: T | PromiseLike<T>) => void,
reject
const p = new Promise<T>((res, rej) => {
resolve = res
reject = rej
})
return { resolve, reject, p }
}
async function findElement (page: Page, selector: string, searchText: string) {
return page.evaluate((selector, searchText) => {
const elements = Array.from(document.querySelectorAll(selector));
const target = elements.find(el => el.textContent.trim() === searchText);
return target
}, selector, searchText)
}
/**
* 元素检查,被点击或按下按键后,检查是否成功,不成功测重试或其他操作
*/
export async function statusCheck(
operationsFn: Function,
checkFn: Function,
options: {interval?: number, tryCount?: number} = {}
) {
options.interval = options.interval ?? 1000
options.tryCount = options.tryCount ?? 1
let { interval, tryCount } = options
const { p, resolve, reject } = createPromise<boolean>()
await operationsFn()
const pass = await checkFn()
console.log('检查状态', !!pass)
if (pass) {
resolve(true)
} else {
if (tryCount <= 5) {
await sleep(interval)
options.tryCount++
return await statusCheck(operationsFn, checkFn, options)
} else {
resolve(false)
}
}
return p
}
export function sleep (time = 1000) {
return new Promise((resolve) => {
setTimeout(resolve, time)
})
}
/**
* 将方法重试n次
*/
export function retry(fn: Function, tryCount = 1) {
return async function (...args) {
try {
return await fn(...args)
} catch (error) {
if (tryCount <= 5) {
await sleep(1000)
tryCount++
return await retry(fn, tryCount)(...args)
} else {
throw error
}
}
}
}

View File

@@ -1,5 +1,5 @@
function domReady(condition: DocumentReadyState[] = ['complete', 'interactive']) {
return new Promise(resolve => {
return new Promise((resolve) => {
if (condition.includes(document.readyState)) {
resolve(true)
} else {
@@ -85,7 +85,7 @@ function useLoading() {
const { appendLoading, removeLoading } = useLoading()
domReady().then(appendLoading)
window.onmessage = ev => {
window.onmessage = (ev) => {
ev.data.payload === 'removeLoading' && removeLoading()
}

View File

@@ -2,10 +2,10 @@
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" href="/favicon.ico" />
<link rel="icon" type="image/svg+xml" href="/logo.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="Content-Security-Policy" content="script-src 'self' 'unsafe-inline';" />
<title>Vite App</title>
<title>Electron + Vite + Vue</title>
</head>
<body>
<div id="app"></div>

View File

@@ -1,40 +1,59 @@
{
"name": "electron-vue-vite",
"version": "2.0.0",
"name": "poe_gpt",
"version": "1.0.0",
"main": "dist-electron/main/index.js",
"description": "Really simple Electron + Vue + Vite boilerplate.",
"author": "草鞋没号 <308487730@qq.com>",
"license": "MIT",
"private": true,
"scripts": {
"dev": "vite",
"build": "vue-tsc --noEmit && vite build && electron-builder"
},
"engines": {
"node": "^14.18.0 || >=16.0.0"
},
"dependencies": {},
"devDependencies": {
"@vitejs/plugin-vue": "^3.1.2",
"electron": "^21.1.0",
"electron-builder": "^23.3.3",
"typescript": "^4.8.4",
"vite": "^3.2.2",
"vite-plugin-electron": "^0.10.4",
"vite-plugin-electron-renderer": "^0.11.1",
"vue": "^3.2.40",
"vue-tsc": "^1.0.9"
},
"debug": {
"env": {
"VITE_DEV_SERVER_URL": "http://127.0.0.1:3344"
}
},
"keywords": [
"electron",
"rollup",
"vite",
"vue3",
"vue"
]
],
"debug": {
"env": {
"VITE_DEV_SERVER_URL": "http://127.0.0.1:3200/"
}
},
"scripts": {
"dev": "vite",
"build": "vite build && electron-builder",
"build:64": "vite build && electron-builder --win --x64",
"build:32": "vite build && electron-builder --win --x32",
"preview": "vite preview"
},
"devDependencies": {
"@vitejs/plugin-vue": "^4.1.0",
"@vitejs/plugin-vue-jsx": "^3.0.1",
"electron": "^25.0.1",
"electron-builder": "^24.4.0",
"typescript": "^5.0.2",
"unplugin-auto-import": "^0.16.4",
"unplugin-vue-components": "^0.25.0",
"vite": "^4.1.4",
"vite-plugin-electron": "^0.12.0",
"vite-plugin-electron-renderer": "^0.14.1",
"vue": "^3.2.47",
"vue-tsc": "^1.2.0"
},
"dependencies": {
"@vueuse/core": "^10.1.2",
"axios": "^1.4.0",
"chrome-launcher": "^0.15.2",
"fake-useragent": "^1.0.1",
"lodash": "^4.17.21",
"mockjs": "^1.1.0",
"naive-ui": "^2.34.4",
"proxy-chain": "^2.3.0",
"puppeteer": "^13.3.2",
"puppeteer-extra": "^3.3.6",
"puppeteer-extra-plugin-recaptcha": "^3.6.8",
"puppeteer-extra-plugin-stealth": "^2.11.2",
"sass": "^1.62.1",
"socks-proxy-agent": "^8.0.1",
"unocss": "^0.52.7"
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.2 KiB

20
public/logo.svg Normal file
View File

@@ -0,0 +1,20 @@
<svg width="534" height="534" viewBox="0 0 534 534" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M266.667 533.333C413.943 533.333 533.333 413.943 533.333 266.667C533.333 119.391 413.943 0 266.667 0C119.391 0 0 119.391 0 266.667C0 413.943 119.391 533.333 266.667 533.333Z" fill="url(#paint0_linear)"/>
<path d="M408.012 291.99C443.487 250.081 455.873 207.931 438.835 178.423C426.3 156.708 399.798 145.244 364.575 144.785C363.115 144.788 361.715 145.364 360.677 146.39C359.639 147.417 359.046 148.81 359.027 150.27C359.008 151.729 359.565 153.138 360.576 154.191C361.587 155.243 362.972 155.856 364.431 155.896C396.108 156.308 418.942 166.185 429.215 183.979C443.365 208.49 432.319 246.077 399.531 284.81C399.05 285.366 398.684 286.011 398.454 286.709C398.224 287.408 398.135 288.144 398.192 288.877C398.249 289.61 398.45 290.324 398.785 290.978C399.12 291.632 399.581 292.214 400.142 292.689C400.703 293.163 401.352 293.522 402.053 293.744C402.753 293.966 403.491 294.047 404.223 293.982C404.955 293.917 405.667 293.708 406.317 293.366C406.968 293.023 407.544 292.556 408.012 291.99ZM316.844 149.958C284.769 156.831 250.627 170.269 217.84 189.198C136.71 236.037 83.7874 305.106 91.1374 355.187C91.2354 355.916 91.4771 356.618 91.8485 357.253C92.2198 357.888 92.7135 358.442 93.3008 358.885C93.8881 359.327 94.5574 359.649 95.2699 359.831C95.9824 360.013 96.7239 360.051 97.4515 359.944C98.179 359.837 98.8781 359.587 99.5082 359.208C100.138 358.829 100.687 358.329 101.122 357.736C101.558 357.144 101.871 356.47 102.044 355.756C102.217 355.041 102.247 354.299 102.131 353.573C95.6041 309.106 145.771 243.637 223.396 198.821C255.202 180.456 288.26 167.446 319.171 160.823C319.894 160.68 320.582 160.395 321.194 159.984C321.806 159.573 322.33 159.044 322.736 158.429C323.142 157.813 323.421 157.123 323.557 156.398C323.693 155.673 323.684 154.929 323.529 154.208C323.375 153.487 323.078 152.804 322.657 152.199C322.236 151.593 321.699 151.078 321.077 150.682C320.455 150.287 319.76 150.019 319.033 149.895C318.306 149.771 317.562 149.792 316.844 149.958V149.958Z" fill="#9feaf9"/>
<path d="M211.933 148.108C157.756 138.242 114.919 148.569 97.8458 178.14C85.1062 200.206 88.7478 229.462 106.679 260.735C107.033 261.385 107.513 261.957 108.092 262.419C108.67 262.88 109.334 263.221 110.046 263.423C110.758 263.624 111.503 263.681 112.237 263.59C112.971 263.5 113.68 263.264 114.322 262.896C114.963 262.528 115.525 262.035 115.974 261.447C116.423 260.859 116.75 260.188 116.936 259.472C117.121 258.755 117.162 258.01 117.056 257.277C116.95 256.545 116.698 255.842 116.317 255.208C100.167 227.037 97.0228 201.79 107.469 183.696C121.652 159.131 159.86 149.919 209.942 159.04C211.381 159.279 212.856 158.943 214.05 158.104C215.243 157.265 216.059 155.99 216.32 154.555C216.582 153.119 216.268 151.639 215.448 150.433C214.627 149.227 213.364 148.392 211.933 148.108Z" fill="#9feaf9"/>
<path d="M298.488 204.045L234.806 216.594C233.76 216.8 232.985 217.692 232.922 218.763L229.004 285.297C228.912 286.864 230.343 288.081 231.864 287.728L249.594 283.613C251.253 283.228 252.752 284.698 252.411 286.375L247.143 312.315C246.789 314.061 248.419 315.554 250.114 315.036L261.065 311.69C262.762 311.172 264.394 312.669 264.035 314.416L255.664 355.162C255.14 357.711 258.511 359.101 259.917 356.916L260.856 355.456L312.747 251.312C313.616 249.569 312.117 247.58 310.213 247.95L291.963 251.492C290.248 251.824 288.789 250.218 289.273 248.531L301.184 207.005C301.669 205.315 300.205 203.707 298.488 204.045Z" fill="url(#paint1_linear)"/>
<path d="M217.677 364.14C185.219 345.402 156.758 322.821 134.852 298.748C134.358 298.209 133.975 297.577 133.725 296.89C133.475 296.202 133.363 295.472 133.396 294.742C133.429 294.011 133.606 293.294 133.917 292.632C134.228 291.97 134.666 291.375 135.207 290.883C135.748 290.391 136.381 290.01 137.07 289.763C137.758 289.516 138.489 289.407 139.219 289.443C139.95 289.479 140.666 289.658 141.327 289.972C141.988 290.285 142.581 290.726 143.071 291.269C164.185 314.473 191.746 336.34 223.233 354.519C298.527 397.99 378.002 409.51 414.906 384.348C415.508 383.922 416.189 383.619 416.91 383.459C417.63 383.299 418.375 383.284 419.101 383.414C419.827 383.545 420.52 383.819 421.139 384.22C421.758 384.622 422.291 385.142 422.707 385.752C423.123 386.362 423.413 387.048 423.56 387.771C423.708 388.494 423.71 389.239 423.567 389.963C423.424 390.686 423.137 391.374 422.725 391.986C422.313 392.598 421.783 393.122 421.167 393.527C379.933 421.642 296.267 409.515 217.677 364.14Z" fill="#9feaf9"/>
<path d="M185.408 389.906C203.958 441.698 234.302 473.587 268.423 473.587C293.308 473.587 316.331 456.623 334.285 426.758C334.674 426.133 334.934 425.436 335.051 424.709C335.168 423.982 335.139 423.239 334.967 422.523C334.794 421.807 334.481 421.133 334.045 420.539C333.609 419.945 333.06 419.444 332.428 419.065C331.797 418.685 331.097 418.435 330.368 418.329C329.639 418.222 328.897 418.262 328.184 418.445C327.47 418.628 326.8 418.951 326.213 419.396C325.626 419.84 325.133 420.397 324.762 421.033C308.627 447.873 288.808 462.475 268.423 462.475C240.079 462.475 213.015 434.033 195.871 386.162C195.636 385.461 195.264 384.814 194.776 384.259C194.288 383.704 193.694 383.252 193.029 382.929C192.364 382.606 191.641 382.419 190.903 382.379C190.165 382.339 189.426 382.447 188.73 382.696C188.034 382.945 187.395 383.331 186.85 383.83C186.304 384.329 185.864 384.932 185.555 385.604C185.246 386.275 185.074 387.001 185.049 387.74C185.024 388.479 185.147 389.215 185.41 389.906H185.408ZM354.829 379.775C364.433 349.092 369.59 313.696 369.59 276.81C369.59 184.771 337.375 105.429 291.492 85.0562C290.151 84.4948 288.644 84.4809 287.294 85.0174C285.943 85.554 284.857 86.5983 284.267 87.9265C283.677 89.2546 283.631 90.761 284.139 92.1226C284.647 93.4842 285.668 94.5927 286.983 95.2104C327.906 113.383 358.477 188.681 358.477 276.81C358.477 312.596 353.483 346.873 344.227 376.456C343.997 377.156 343.908 377.894 343.966 378.628C344.024 379.362 344.227 380.077 344.564 380.732C344.901 381.387 345.364 381.968 345.928 382.442C346.491 382.917 347.143 383.274 347.846 383.494C348.549 383.714 349.288 383.792 350.021 383.724C350.754 383.655 351.467 383.442 352.117 383.096C352.767 382.75 353.341 382.278 353.807 381.708C354.273 381.138 354.621 380.481 354.831 379.775H354.829ZM459.462 374.333C459.462 359.648 447.558 347.744 432.873 347.744C418.187 347.744 406.283 359.648 406.283 374.333C406.283 389.019 418.187 400.923 432.873 400.923C447.558 400.923 459.462 389.019 459.462 374.333ZM448.352 374.333C448.352 376.366 447.952 378.379 447.174 380.257C446.396 382.135 445.256 383.841 443.818 385.279C442.381 386.716 440.674 387.856 438.796 388.634C436.918 389.412 434.906 389.812 432.873 389.812C430.84 389.812 428.827 389.412 426.949 388.634C425.071 387.856 423.365 386.716 421.927 385.279C420.49 383.841 419.35 382.135 418.572 380.257C417.794 378.379 417.394 376.366 417.394 374.333C417.394 370.228 419.025 366.291 421.927 363.388C424.83 360.485 428.768 358.854 432.873 358.854C436.978 358.854 440.915 360.485 443.818 363.388C446.721 366.291 448.352 370.228 448.352 374.333ZM103.59 400.923C118.277 400.923 130.181 389.019 130.181 374.333C130.181 359.648 118.275 347.744 103.59 347.744C88.9062 347.744 77 359.648 77 374.333C77 389.019 88.9062 400.923 103.59 400.923ZM103.59 389.812C99.4843 389.812 95.5471 388.182 92.6442 385.279C89.7413 382.376 88.1104 378.439 88.1104 374.333C88.1104 370.228 89.7413 366.291 92.6442 363.388C95.5471 360.485 99.4843 358.854 103.59 358.854C107.695 358.854 111.632 360.485 114.535 363.388C117.438 366.291 119.069 370.228 119.069 374.333C119.069 378.439 117.438 382.376 114.535 385.279C111.632 388.182 107.695 389.812 103.59 389.812Z" fill="#9feaf9"/>
<path d="M268.423 112.179C283.108 112.179 295.013 100.275 295.013 85.5896C295.013 70.9042 283.108 59 268.423 59C253.738 59 241.833 70.9042 241.833 85.5896C241.833 100.275 253.738 112.179 268.423 112.179ZM268.423 101.069C264.318 101.069 260.38 99.4379 257.478 96.535C254.575 93.6321 252.944 89.6949 252.944 85.5896C252.944 81.4843 254.575 77.5471 257.478 74.6442C260.38 71.7413 264.318 70.1104 268.423 70.1104C272.528 70.1104 276.465 71.7413 279.368 74.6442C282.271 77.5471 283.902 81.4843 283.902 85.5896C283.902 89.6949 282.271 93.6321 279.368 96.535C276.465 99.4379 272.528 101.069 268.423 101.069Z" fill="#9feaf9"/>
<defs>
<linearGradient id="paint0_linear" x1="6.00017" y1="32.9999" x2="235" y2="344" gradientUnits="userSpaceOnUse">
<stop stop-color="#41D1FF"/>
<stop offset="1" stop-color="#BD34FE"/>
</linearGradient>
<linearGradient id="paint1_linear" x1="194.651" y1="8.81818" x2="236.076" y2="292.989" gradientUnits="userSpaceOnUse">
<stop stop-color="#FFEA83"/>
<stop offset="0.0833333" stop-color="#FFDD35"/>
<stop offset="1" stop-color="#FFA800"/>
</linearGradient>
</defs>
</svg>

After

Width:  |  Height:  |  Size: 8.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

BIN
response.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

View File

@@ -1,68 +1,390 @@
<script setup lang="ts">
// This starter template is using Vue 3 <script setup> SFCs
// Check out https://vuejs.org/api/sfc-script-setup.html#script-setup
import HelloWorld from './components/HelloWorld.vue'
<script setup lang="tsx">
import { ipcRenderer } from 'electron'
import { NButton } from 'naive-ui'
import { useClipboard, useLocalStorage } from '@vueuse/core'
import Business from './Business.vue'
const input = useLocalStorage('accountInput', 'pollcribracacom@mail.com-----XAxeEgy34j')
// const input = ref('126vdsjmgyanpgqrvb@ddmvp.icu----EOJ2NgPfS')
// const input = ref('traceetakashi6274@gmail.com----kedaraditi0214----kedaraditi4760@hotmail.com')
const accountArr = computed(() => {
const text = input.value.split('\n').filter(Boolean).map(v => {
return v.split(/(——|-)+/).filter(v => !['-', '——'].includes(v))
})
return text
})
const result = ref('')
const liao = useLocalStorage('result', '')
const list = useLocalStorage('list', [] as any[])
const listInstock = ref([] as any[])
listInstock.value = list.value.filter(v => v.instock === true)
const filterInput = ref('')
const renderList = computed(() => {
// 成功的排在前面
let data = list.value.sort((a, b) => {
if (a.type === 'success' && b.type !== 'success') {
return -1
} else if (a.type !== 'success' && b.type === 'success') {
return 1
} else {
return 0
}
}).filter(v => v.instock !== true)
if (filterInput.value) {
data = data.filter(v => {
return v.user.startsWith(filterInput.value)
})
}
return data
})
const remainingData = computed(() => {
return accountArr.value.filter((item, i) => {
const user = item[0]
const target = list.value.find((v) => v.user === user)
if (target && target.type === 'success') {
return false
}
return true
})
})
function copyRemaining() {
const text = remainingData.value.map(v => `${v[0]}----${v[1]}`).join('\n')
copyText(text)
}
const remainingColumns = [{
title: '序列',
render: (row, index) => h('span', undefined, index + 1),
width: 60
},
{
title: '邮箱',
key: '0',
width: 300
},
{
title: '密码',
key: '1',
width: 220
},
]
ipcRenderer.on('progress', (event, args) => {
const { user } = args
const target = list.value.find((item) => item.user === user)
if (target) {
Object.assign(target, args)
} else {
list.value.push(args)
}
})
// function handler () {
// const data = {
// 'getLink'
// }
// }
function getLink(val?: string) {
ipcRenderer.invoke('getLink', { text: val || input.value }).then((res) => {
console.log(res);
})
}
function getLink_7day(val?: string) {
let liaoObj
if (liao.value) {
const [_1, bank, cvc, cardExpiry, name, address, city, _2, postalCode, nation] = liao.value.split('|').map(v => v.trim())
liaoObj = { bank, cvc, date: cardExpiry, name, address, city, postalCode, nation }
}
console.log(liaoObj)
ipcRenderer.invoke('get-poe-link-7day', { text: val || input.value, liao: liaoObj }).then((res) => {
console.log(res);
})
}
function getResult(val?: string) {
ipcRenderer.invoke('poe-result', { text: val || input.value }).then((res) => {
console.log(res);
})
}
function stopHandler() {
ipcRenderer.invoke('stop')
}
function startOneChromHandler() {
ipcRenderer.invoke('start-one-chrom')
}
function gptLinkHandler() {
ipcRenderer.invoke('gpt-link', { text: input.value })
}
function gptResultHandler() {
ipcRenderer.invoke('gpt-result', { text: input.value })
}
const listSuccess = computed(() => {
return list.value.filter((item) => item.instock !== true && item.type === 'success')
})
function copyAllSuccess() {
const text = listSuccess.value.map((item, i) => `${i + 1}. ${item.user}----${item.result}`).join('\n')
copyText(text)
}
const listFail = computed(() => {
return list.value.filter((item) => item.type !== 'success')
})
function copyFailHandler() {
const text = listFail.value.map((item) => `${item.user}----${item.pass}`).join('\n\n')
copyText(text)
}
function clearLocalHandler() {
list.value = list.value.filter(v => v.instock === true)
}
const { copy } = useClipboard()
function copyText(text: any) {
copy(text)
}
function copyAccount(item: any) {
copy(item.user + '----' + item.pass + '----' + item.auxiliary)
}
function application() {
ipcRenderer.invoke('gpt-batch-4.0', { text: input.value })
}
// 申请结果
function applicationResult() {
ipcRenderer.invoke('gpt-batch-4.0-result', { text: input.value })
}
const showBusiness = ref(false)
const columns = [
{
title: '序列',
render: (row, index) => h('span', undefined, index + 1),
width: 60
},
{
title: '邮箱',
key: 'user',
width: 300
},
{
title: '进度',
key: 'info',
width: 220
},
{
title: '结果',
key: 'result',
ellipsis: true
},
{
title: '操作',
width: 230,
align: 'left',
fixed: 'right',
render: (row: any) => {
/**
* poe-link
* 再次提链: [type: fail, loading: false]
* 复制链接: [type: success, loading: false]
* 充值结果: [type: success, loading: false]
*/
/**
* poe-validate
* 充值结果: [type: fail, loading: false]
*/
const rechargeResult = () => {
let link = row.ident === 'poe-link' && !row.loading
let validate = row.ident === 'poe-validate' && row.type !== 'success' && !row.loading
return link || validate
}
return <n-space>
{row.ident === 'poe-link' && row.type === 'success' && !row.loading
? <NButton text type="primary" onClick={() => copyText(`${row.user}\n${row.result}`)}>复制链接</NButton>
: null
}
{row.type === 'success'
? <NButton text type="primary" onClick={() => row.instock = true}>标记入库</NButton>
: null
}
{row.ident === 'poe-link' && row.type !== 'success' && !row.loading
? <NButton text type="primary" onClick={() => getLink(`${row.user}----${row.pass}----${row.auxiliary}`)}>再次提链</NButton>
: null
}
<NButton text type="primary" onClick={() => copyAccount(row)}>复制帐密</NButton>
{rechargeResult() //.ident === 'poe-link' && row.type === 'success' && !row.loading
? <NButton text type="info" onClick={() => getResult(`${row.user}----${row.pass}----${row.auxiliary}`)}>充值结果</NButton>
: null
}
</n-space>
}
}
]
const liaoColumns = [
{
key: 'bank',
title: '银行'
},
{
key: 'cvc',
title: 'cvc'
},
{
key: 'date',
title: '日期'
},
{
key: 'name',
title: '名字'
},
{
key: 'address',
title: '地址'
},
{
key: 'city',
title: '城市'
},
{
key: 'postalCode',
title: '邮政编码'
},
{
key: 'nation',
title: '国家'
}
]
const liaoData = computed(() => {
if (liao.value) {
const [_1, bank, cvc, cardExpiry, name, address, city, _2, postalCode, nation] = liao.value.split('|').map(v => v.trim())
return { bank, cvc, date: cardExpiry, name, address, city, postalCode, nation }
}
return {}
})
function getLiao() {
let liaoObj = liaoData.value
copy(JSON.stringify(liaoObj))
return liaoObj
}
function handler(proxyType, name) {
const isProxy = proxyType === 'proxy'
console.log(proxyType, name, isProxy)
let liaoObj
// if (liao.value) {
// const [_1, bank, cvc, cardExpiry, name, address, city, _2, postalCode, nation] = liao.value.split('|').map(v => v.trim())
// liaoObj = { bank, cvc, date: cardExpiry, name, address, city, postalCode, nation }
// }
ipcRenderer.invoke(name, { text: input.value, liao: liaoObj, proxy: isProxy })
}
</script>
<template>
<div class="logo-box">
<img class="logo vite" src="./assets/vite.svg" >
<img class="logo electron" src="./assets/electron.svg" >
<img class="logo vue" src="./assets/vue.svg" >
</div>
<HelloWorld msg="Hello Vue 3 + TypeScript + Vite" />
<div class="static-public">
Place static files into the <code>/public</code> folder
<img style="width:77px;" :src="'./node.png'" >
<div>
<div class="left" flex-1>
<p>帐密: {{ accountArr.length }}</p>
<textarea class="textarea w-full min-w-100 max-w-94vw" v-model="input" rows="20" />
<div flex items-center>
<p>liao</p>
<NInput class="textarea w-full min-w-100 max-w-94vw flex-1 mr-3" v-model:value="liao" />
<NButton @click="getLiao">复制</NButton>
</div>
<NDataTable v-if="liaoData.bank" :data="[liaoData]" :scroll-x="1000" :columns="liaoColumns" />
<div>
<div flex gap-3 mt-3 items-center>
<span w-15>poe</span>
<TheButton type="primary" dashed @select="key => handler(key, 'getLink')">提取链接</TheButton>
<TheButton type="primary" dashed @select="key => handler(key, 'poe-result')">充值结果</TheButton>
<TheButton type="warning" dashed @select="key => handler(key, 'get-poe-link-7day')">提取链接-7天</TheButton>
<TheButton type="warning" dashed @select="key => handler(key, 'get-poe-cookie')">获取cookie</TheButton>
</div>
<div flex gap-3 mt-3 items-center>
<span w-15>gpt4.0</span>
<TheButton type="primary" dashed @select="key => handler(key, 'gpt-batch-4.0')">申请4.0</TheButton>
<TheButton type="primary" dashed @select="key => handler(key, 'gpt-batch-4.0-result')">检查申请结果(mail邮箱)
</TheButton>
</div>
<div flex gap-3 mt-3 items-center>
<span w-15 class="whitespace-nowrap">gpt plus</span>
<TheButton type="primary" dashed @select="key => handler(key, 'gpt-link')">gpt提链</TheButton>
<TheButton type="primary" dashed @select="key => handler(key, 'gpt-result')">充值结果</TheButton>
</div>
<div flex gap-3 mt-3 items-center>
<span w-15>操作</span>
<NButton type="error" dashed @click="stopHandler">关闭所有浏览器</NButton>
<NButton type="primary" dashed @click="startOneChromHandler">开一个浏览器测试</NButton>
</div>
</div>
</div>
<div class="right" flex-1>
<p>结果</p>
<n-space mb-3>
<n-button type="primary" dashed @click="copyAllSuccess">复制全部成功 {{ listSuccess.length }}</n-button>
<n-button type="error" dashed @click="copyFailHandler">复制全部失败 {{ listFail.length }}</n-button>
<n-button type="error" dashed @dblclick="clearLocalHandler">清除记录(双击)</n-button>
<n-button type="info" dashed @click="showBusiness = true">库存</n-button>
<n-input v-model:value="filterInput" clearable />
</n-space>
<NDataTable :data="renderList" :columns="columns" :scroll-x="1000" />
</div>
<div flex items-center gap-4>
<p>剩余{{ remainingData.length }}</p>
<NButton type="primary" @click="copyRemaining">复制</NButton>
</div>
<NDataTable :data="remainingData" :columns="remainingColumns"></NDataTable>
<Business v-if="showBusiness" @close="showBusiness = false" :data="list"/>
<div h-10></div>
</div>
</template>
<style>
#app {
font-family: Avenir, Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-align: center;
color: #2c3e50;
margin-top: 60px;
}
.logo-box {
display: flex;
<style lang="scss" scoped>
.textarea:nth-of-type() {
width: 100%;
justify-content: center;
}
.static-public {
display: flex;
align-items: center;
justify-content: center;
}
.static-public code {
background-color: #eee;
padding: 2px 4px;
margin: 0 4px;
display: block;
border: 1px solid #ccc;
border-radius: 4px;
color: #304455;
}
.logo {
height: 6em;
padding: 1.5em;
will-change: filter;
transition: 0.75s;
}
.logo.vite:hover {
filter: drop-shadow(0 0 2em #646cffaa);
}
.logo.electron:hover {
filter: drop-shadow(0 0 2em #9FEAF9);
}
.logo.vue:hover {
filter: drop-shadow(0 0 2em #42b883aa);
padding: 10px;
box-sizing: border-box;
font-size: 14px;
}
</style>

108
src/Business.vue Normal file
View File

@@ -0,0 +1,108 @@
<script lang="tsx" setup>
import { useLocalStorage } from '@vueuse/core';
const emits = defineEmits(['close'])
const { data } = defineProps<{
data: any[]
}>()
const show = ref(true)
watch(show, () => {
if (!show.value) emits('close')
})
const key = useLocalStorage('modal_ident', '')
const keys = computed(() => {
return data.map((item) => item.ident)
})
const input = ref('')
const list = computed(() => {
// 未卖
const unsold = data.filter((item) => {
return item.sold !== true
}).sort((a, b) => b.soldTime - a.soldTime)
// 已卖
const sold = data.filter((item) => {
return item.sold === true
}).sort((a, b) => b.soldTime - a.soldTime)
const newData = [...unsold, ...sold]
return newData.filter((item) => {
return item.instock === true && item.ident === key.value && (input.value ? item.user.startsWith(input.value) : true)
})
})
// 标记已卖
function handleMarkSold(row) {
row.sold = true
row.soldTime = Date.now()
}
const columns = [
{
title: '序列',
render: (row, index) => h('span', undefined, index + 1),
width: 60
},
{
title: '邮箱',
key: 'user',
width: 220,
ellipsis: true
},
{
title: '状态',
key: 'info',
width: 80,
render: (row) => {
return <n-space>
{row.sold === true
? <n-tag type="info">已卖</n-tag>
: <n-tag type="success">未卖</n-tag>
}
</n-space>
}
},
{
title: '结果',
key: 'result',
ellipsis: true
},
{
title: '操作',
width: 100,
align: 'left',
fixed: 'right',
render: (row: any) => {
return <n-space>
{row.sold !== true
? <n-button text type="primary" onClick={() => handleMarkSold(row)}>标记已卖</n-button>
: null
}
</n-space>
}
}
]
</script>
<template>
<NModal v-model:show="show">
<n-card class="w-90%! max-w-1000px!" title="库存" :bordered="false" size="huge" role="dialog" aria-modal="true">
<n-input placeholder="搜索邮箱" v-model:value="input" />
<n-tabs type="line" animated v-model:value="key">
<n-tab-pane v-for="(item, index) in keys" :key="index" :name="item" />
</n-tabs>
<NDataTable :data="list" :columns="columns" :scroll-x="1000"></NDataTable>
<template #header-extra>
<span px-3 class="cursor-pointer" @click="emits('close')">X</span>
</template>
<!-- <pre>{{ data }}</pre> -->
</n-card>
</NModal>
</template>

178
src/auto-imports.d.ts vendored Normal file
View File

@@ -0,0 +1,178 @@
/* eslint-disable */
/* prettier-ignore */
// @ts-nocheck
// Generated by unplugin-auto-import
export {}
declare global {
const EffectScope: typeof import('vue')['EffectScope']
const computed: typeof import('vue')['computed']
const createApp: typeof import('vue')['createApp']
const customRef: typeof import('vue')['customRef']
const defineAsyncComponent: typeof import('vue')['defineAsyncComponent']
const defineComponent: typeof import('vue')['defineComponent']
const effectScope: typeof import('vue')['effectScope']
const getCurrentInstance: typeof import('vue')['getCurrentInstance']
const getCurrentScope: typeof import('vue')['getCurrentScope']
const h: typeof import('vue')['h']
const inject: typeof import('vue')['inject']
const isProxy: typeof import('vue')['isProxy']
const isReactive: typeof import('vue')['isReactive']
const isReadonly: typeof import('vue')['isReadonly']
const isRef: typeof import('vue')['isRef']
const markRaw: typeof import('vue')['markRaw']
const nextTick: typeof import('vue')['nextTick']
const onActivated: typeof import('vue')['onActivated']
const onBeforeMount: typeof import('vue')['onBeforeMount']
const onBeforeUnmount: typeof import('vue')['onBeforeUnmount']
const onBeforeUpdate: typeof import('vue')['onBeforeUpdate']
const onDeactivated: typeof import('vue')['onDeactivated']
const onErrorCaptured: typeof import('vue')['onErrorCaptured']
const onMounted: typeof import('vue')['onMounted']
const onRenderTracked: typeof import('vue')['onRenderTracked']
const onRenderTriggered: typeof import('vue')['onRenderTriggered']
const onScopeDispose: typeof import('vue')['onScopeDispose']
const onServerPrefetch: typeof import('vue')['onServerPrefetch']
const onUnmounted: typeof import('vue')['onUnmounted']
const onUpdated: typeof import('vue')['onUpdated']
const provide: typeof import('vue')['provide']
const reactive: typeof import('vue')['reactive']
const readonly: typeof import('vue')['readonly']
const ref: typeof import('vue')['ref']
const resolveComponent: typeof import('vue')['resolveComponent']
const shallowReactive: typeof import('vue')['shallowReactive']
const shallowReadonly: typeof import('vue')['shallowReadonly']
const shallowRef: typeof import('vue')['shallowRef']
const toRaw: typeof import('vue')['toRaw']
const toRef: typeof import('vue')['toRef']
const toRefs: typeof import('vue')['toRefs']
const toValue: typeof import('vue')['toValue']
const triggerRef: typeof import('vue')['triggerRef']
const unref: typeof import('vue')['unref']
const useAttrs: typeof import('vue')['useAttrs']
const useCssModule: typeof import('vue')['useCssModule']
const useCssVars: typeof import('vue')['useCssVars']
const useSlots: typeof import('vue')['useSlots']
const watch: typeof import('vue')['watch']
const watchEffect: typeof import('vue')['watchEffect']
const watchPostEffect: typeof import('vue')['watchPostEffect']
const watchSyncEffect: typeof import('vue')['watchSyncEffect']
}
// for type re-export
declare global {
// @ts-ignore
export type { Component, ComponentPublicInstance, ComputedRef, InjectionKey, PropType, Ref, VNode } from 'vue'
}
// for vue template auto import
import { UnwrapRef } from 'vue'
declare module 'vue' {
interface ComponentCustomProperties {
readonly EffectScope: UnwrapRef<typeof import('vue')['EffectScope']>
readonly computed: UnwrapRef<typeof import('vue')['computed']>
readonly createApp: UnwrapRef<typeof import('vue')['createApp']>
readonly customRef: UnwrapRef<typeof import('vue')['customRef']>
readonly defineAsyncComponent: UnwrapRef<typeof import('vue')['defineAsyncComponent']>
readonly defineComponent: UnwrapRef<typeof import('vue')['defineComponent']>
readonly effectScope: UnwrapRef<typeof import('vue')['effectScope']>
readonly getCurrentInstance: UnwrapRef<typeof import('vue')['getCurrentInstance']>
readonly getCurrentScope: UnwrapRef<typeof import('vue')['getCurrentScope']>
readonly h: UnwrapRef<typeof import('vue')['h']>
readonly inject: UnwrapRef<typeof import('vue')['inject']>
readonly isProxy: UnwrapRef<typeof import('vue')['isProxy']>
readonly isReactive: UnwrapRef<typeof import('vue')['isReactive']>
readonly isReadonly: UnwrapRef<typeof import('vue')['isReadonly']>
readonly isRef: UnwrapRef<typeof import('vue')['isRef']>
readonly markRaw: UnwrapRef<typeof import('vue')['markRaw']>
readonly nextTick: UnwrapRef<typeof import('vue')['nextTick']>
readonly onActivated: UnwrapRef<typeof import('vue')['onActivated']>
readonly onBeforeMount: UnwrapRef<typeof import('vue')['onBeforeMount']>
readonly onBeforeUnmount: UnwrapRef<typeof import('vue')['onBeforeUnmount']>
readonly onBeforeUpdate: UnwrapRef<typeof import('vue')['onBeforeUpdate']>
readonly onDeactivated: UnwrapRef<typeof import('vue')['onDeactivated']>
readonly onErrorCaptured: UnwrapRef<typeof import('vue')['onErrorCaptured']>
readonly onMounted: UnwrapRef<typeof import('vue')['onMounted']>
readonly onRenderTracked: UnwrapRef<typeof import('vue')['onRenderTracked']>
readonly onRenderTriggered: UnwrapRef<typeof import('vue')['onRenderTriggered']>
readonly onScopeDispose: UnwrapRef<typeof import('vue')['onScopeDispose']>
readonly onServerPrefetch: UnwrapRef<typeof import('vue')['onServerPrefetch']>
readonly onUnmounted: UnwrapRef<typeof import('vue')['onUnmounted']>
readonly onUpdated: UnwrapRef<typeof import('vue')['onUpdated']>
readonly provide: UnwrapRef<typeof import('vue')['provide']>
readonly reactive: UnwrapRef<typeof import('vue')['reactive']>
readonly readonly: UnwrapRef<typeof import('vue')['readonly']>
readonly ref: UnwrapRef<typeof import('vue')['ref']>
readonly resolveComponent: UnwrapRef<typeof import('vue')['resolveComponent']>
readonly shallowReactive: UnwrapRef<typeof import('vue')['shallowReactive']>
readonly shallowReadonly: UnwrapRef<typeof import('vue')['shallowReadonly']>
readonly shallowRef: UnwrapRef<typeof import('vue')['shallowRef']>
readonly toRaw: UnwrapRef<typeof import('vue')['toRaw']>
readonly toRef: UnwrapRef<typeof import('vue')['toRef']>
readonly toRefs: UnwrapRef<typeof import('vue')['toRefs']>
readonly toValue: UnwrapRef<typeof import('vue')['toValue']>
readonly triggerRef: UnwrapRef<typeof import('vue')['triggerRef']>
readonly unref: UnwrapRef<typeof import('vue')['unref']>
readonly useAttrs: UnwrapRef<typeof import('vue')['useAttrs']>
readonly useCssModule: UnwrapRef<typeof import('vue')['useCssModule']>
readonly useCssVars: UnwrapRef<typeof import('vue')['useCssVars']>
readonly useSlots: UnwrapRef<typeof import('vue')['useSlots']>
readonly watch: UnwrapRef<typeof import('vue')['watch']>
readonly watchEffect: UnwrapRef<typeof import('vue')['watchEffect']>
readonly watchPostEffect: UnwrapRef<typeof import('vue')['watchPostEffect']>
readonly watchSyncEffect: UnwrapRef<typeof import('vue')['watchSyncEffect']>
}
}
declare module '@vue/runtime-core' {
interface ComponentCustomProperties {
readonly EffectScope: UnwrapRef<typeof import('vue')['EffectScope']>
readonly computed: UnwrapRef<typeof import('vue')['computed']>
readonly createApp: UnwrapRef<typeof import('vue')['createApp']>
readonly customRef: UnwrapRef<typeof import('vue')['customRef']>
readonly defineAsyncComponent: UnwrapRef<typeof import('vue')['defineAsyncComponent']>
readonly defineComponent: UnwrapRef<typeof import('vue')['defineComponent']>
readonly effectScope: UnwrapRef<typeof import('vue')['effectScope']>
readonly getCurrentInstance: UnwrapRef<typeof import('vue')['getCurrentInstance']>
readonly getCurrentScope: UnwrapRef<typeof import('vue')['getCurrentScope']>
readonly h: UnwrapRef<typeof import('vue')['h']>
readonly inject: UnwrapRef<typeof import('vue')['inject']>
readonly isProxy: UnwrapRef<typeof import('vue')['isProxy']>
readonly isReactive: UnwrapRef<typeof import('vue')['isReactive']>
readonly isReadonly: UnwrapRef<typeof import('vue')['isReadonly']>
readonly isRef: UnwrapRef<typeof import('vue')['isRef']>
readonly markRaw: UnwrapRef<typeof import('vue')['markRaw']>
readonly nextTick: UnwrapRef<typeof import('vue')['nextTick']>
readonly onActivated: UnwrapRef<typeof import('vue')['onActivated']>
readonly onBeforeMount: UnwrapRef<typeof import('vue')['onBeforeMount']>
readonly onBeforeUnmount: UnwrapRef<typeof import('vue')['onBeforeUnmount']>
readonly onBeforeUpdate: UnwrapRef<typeof import('vue')['onBeforeUpdate']>
readonly onDeactivated: UnwrapRef<typeof import('vue')['onDeactivated']>
readonly onErrorCaptured: UnwrapRef<typeof import('vue')['onErrorCaptured']>
readonly onMounted: UnwrapRef<typeof import('vue')['onMounted']>
readonly onRenderTracked: UnwrapRef<typeof import('vue')['onRenderTracked']>
readonly onRenderTriggered: UnwrapRef<typeof import('vue')['onRenderTriggered']>
readonly onScopeDispose: UnwrapRef<typeof import('vue')['onScopeDispose']>
readonly onServerPrefetch: UnwrapRef<typeof import('vue')['onServerPrefetch']>
readonly onUnmounted: UnwrapRef<typeof import('vue')['onUnmounted']>
readonly onUpdated: UnwrapRef<typeof import('vue')['onUpdated']>
readonly provide: UnwrapRef<typeof import('vue')['provide']>
readonly reactive: UnwrapRef<typeof import('vue')['reactive']>
readonly readonly: UnwrapRef<typeof import('vue')['readonly']>
readonly ref: UnwrapRef<typeof import('vue')['ref']>
readonly resolveComponent: UnwrapRef<typeof import('vue')['resolveComponent']>
readonly shallowReactive: UnwrapRef<typeof import('vue')['shallowReactive']>
readonly shallowReadonly: UnwrapRef<typeof import('vue')['shallowReadonly']>
readonly shallowRef: UnwrapRef<typeof import('vue')['shallowRef']>
readonly toRaw: UnwrapRef<typeof import('vue')['toRaw']>
readonly toRef: UnwrapRef<typeof import('vue')['toRef']>
readonly toRefs: UnwrapRef<typeof import('vue')['toRefs']>
readonly toValue: UnwrapRef<typeof import('vue')['toValue']>
readonly triggerRef: UnwrapRef<typeof import('vue')['triggerRef']>
readonly unref: UnwrapRef<typeof import('vue')['unref']>
readonly useAttrs: UnwrapRef<typeof import('vue')['useAttrs']>
readonly useCssModule: UnwrapRef<typeof import('vue')['useCssModule']>
readonly useCssVars: UnwrapRef<typeof import('vue')['useCssVars']>
readonly useSlots: UnwrapRef<typeof import('vue')['useSlots']>
readonly watch: UnwrapRef<typeof import('vue')['watch']>
readonly watchEffect: UnwrapRef<typeof import('vue')['watchEffect']>
readonly watchPostEffect: UnwrapRef<typeof import('vue')['watchPostEffect']>
readonly watchSyncEffect: UnwrapRef<typeof import('vue')['watchSyncEffect']>
}
}

25
src/components.d.ts vendored Normal file
View File

@@ -0,0 +1,25 @@
/* eslint-disable */
/* prettier-ignore */
// @ts-nocheck
// Generated by unplugin-vue-components
// Read more: https://github.com/vuejs/core/pull/3399
import '@vue/runtime-core'
export {}
declare module '@vue/runtime-core' {
export interface GlobalComponents {
HelloWorld: typeof import('./components/HelloWorld.vue')['default']
NButton: typeof import('naive-ui')['NButton']
NCard: typeof import('naive-ui')['NCard']
NDataTable: typeof import('naive-ui')['NDataTable']
NDropdown: typeof import('naive-ui')['NDropdown']
NInput: typeof import('naive-ui')['NInput']
NModal: typeof import('naive-ui')['NModal']
NSpace: typeof import('naive-ui')['NSpace']
NTabPane: typeof import('naive-ui')['NTabPane']
NTabs: typeof import('naive-ui')['NTabs']
NTag: typeof import('naive-ui')['NTag']
TheButton: typeof import('./components/TheButton.vue')['default']
}
}

View File

@@ -0,0 +1,30 @@
<script lang="ts" setup>
const options = [
{
label: '不加代理',
key: 'notProxy',
},
{
label: '加代理(port: 40000)',
key: "proxy"
},
]
const emits = defineEmits(['select'])
const handler = (key: string) => {
emits('select', key)
}
const config = useAttrs()
</script>
<template>
<n-dropdown trigger="hover" :options="options" @select="handler">
<n-button v-bind="config">
<slot></slot>
</n-button>
</n-dropdown>
</template>

View File

@@ -1,7 +1,11 @@
import { createApp } from 'vue'
import "./style.css"
import App from './App.vue'
import './samples/node-api'
import 'uno.css'
createApp(App)
.mount('#app')
.$nextTick(() => {

View File

@@ -1,5 +1,5 @@
import { lstat } from 'fs/promises'
import { cwd } from 'process'
import { lstat } from 'node:fs/promises'
import { cwd } from 'node:process'
import { ipcRenderer } from 'electron'
ipcRenderer.on('main-process-message', (_event, ...args) => {

95
src/style.css Normal file
View File

@@ -0,0 +1,95 @@
button:focus{outline-color: transparent !important;}
:root {
font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
line-height: 1.5;
font-weight: 400;
color-scheme: light dark;
color: rgba(255, 255, 255, 0.87);
background-color: #242424;
font-synthesis: none;
text-rendering: optimizeLegibility;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
-webkit-text-size-adjust: 100%;
}
a {
font-weight: 500;
color: #646cff;
text-decoration: inherit;
}
a:hover {
color: #535bf2;
}
body {
margin: 0;
display: flex;
place-items: center;
width: 100%;
height: 100vh;
}
h1 {
font-size: 3.2em;
line-height: 1.1;
}
button {
border-radius: 8px;
border: 1px solid transparent;
padding: 0.6em 1.2em;
font-size: 1em;
font-weight: 500;
font-family: inherit;
background-color: #1a1a1a;
cursor: pointer;
transition: border-color 0.25s;
}
button:hover {
border-color: #646cff;
}
button:focus,
button:focus-visible {
outline: 4px auto -webkit-focus-ring-color;
}
code {
background-color: #1a1a1a;
padding: 2px 4px;
margin: 0 4px;
border-radius: 4px;
}
.card {
padding: 2em;
}
button,input,textarea{outline: none;}
#app {
width: 100%;
height: 100%;
box-sizing: border-box;
margin: 0 auto;
padding: 2rem;
}
@media (prefers-color-scheme: light) {
:root {
color: #213547;
background-color: #ffffff;
}
a:hover {
color: #747bff;
}
button {
background-color: #f9f9f9;
}
code {
background-color: #f9f9f9;
}
}

View File

@@ -2,7 +2,6 @@
declare module '*.vue' {
import type { DefineComponent } from 'vue'
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/ban-types
const component: DefineComponent<{}, {}, any>
export default component
}

View File

@@ -1,18 +1,18 @@
{
"compilerOptions": {
"target": "ESNext",
"useDefineForClassFields": true,
"module": "ESNext",
"moduleResolution": "node",
"importHelpers": true,
"jsx": "preserve",
"esModuleInterop": true,
"resolveJsonModule": true,
"sourceMap": true,
"baseUrl": "./",
"moduleResolution": "Node",
"strict": true,
"paths": {},
"allowSyntheticDefaultImports": true,
"skipLibCheck": true
"noImplicitAny": false,
"jsx": "preserve",
"resolveJsonModule": true,
"isolatedModules": true,
"esModuleInterop": true,
"lib": ["ESNext", "DOM"],
"skipLibCheck": true,
"noEmit": true
},
"include": ["src"],
"references": [

View File

@@ -1,12 +1,10 @@
{
"compilerOptions": {
"target": "ESNext",
"composite": true,
"module": "ESNext",
"moduleResolution": "Node",
"jsx": "preserve",
"resolveJsonModule": true,
"allowSyntheticDefaultImports": true
},
"include": ["package.json", "electron"]
"include": ["vite.config.ts", "package.json", "electron"]
}

35
unocss.config.ts Normal file
View File

@@ -0,0 +1,35 @@
import {
defineConfig,
presetAttributify,
presetIcons,
presetUno,
presetWebFonts,
// transformerDirectives,
// transformerVariantGroup,
} from 'unocss'
export default defineConfig({
// shortcuts: [
// ['btn', 'px-4 py-1 rounded inline-block bg-teal-600 text-white cursor-pointer hover:bg-teal-700 disabled:cursor-default disabled:bg-gray-600 disabled:opacity-50'],
// ['icon-btn', 'text-[0.9em] inline-block cursor-pointer select-none opacity-75 transition duration-200 ease-in-out hover:opacity-100 hover:text-teal-600 !outline-none'],
// ],
presets: [
presetUno(),
presetAttributify(),
presetIcons({
scale: 1.2,
warn: true,
}),
presetWebFonts({
fonts: {
sans: 'DM Sans',
serif: 'DM Serif Display',
mono: 'DM Mono',
},
}),
],
// transformers: [
// transformerDirectives(),
// transformerVariantGroup(),
// ],
})

View File

@@ -1,79 +1,98 @@
import { rmSync } from 'fs'
import { rmSync } from 'node:fs'
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import electron from 'vite-plugin-electron'
import Components from 'unplugin-vue-components/vite'
import { NaiveUiResolver } from 'unplugin-vue-components/resolvers'
import renderer from 'vite-plugin-electron-renderer'
import pkg from './package.json'
rmSync('dist-electron', { recursive: true, force: true })
const sourcemap = !!process.env.VSCODE_DEBUG
const isBuild = process.argv.slice(2).includes('build')
import Unocss from 'unocss/vite'
import AutoImport from 'unplugin-auto-import/vite'
import vueJsx from '@vitejs/plugin-vue-jsx'
// https://vitejs.dev/config/
export default defineConfig({
plugins: [
vue(),
electron([
{
// Main-Process entry file of the Electron App.
entry: 'electron/main/index.ts',
onstart(options) {
if (process.env.VSCODE_DEBUG) {
console.log(/* For `.vscode/.debug.script.mjs` */'[startup] Electron App')
} else {
options.startup()
}
},
vite: {
build: {
sourcemap,
minify: isBuild,
outDir: 'dist-electron/main',
rollupOptions: {
external: Object.keys(pkg.dependencies),
},
},
},
},
{
entry: 'electron/preload/index.ts',
onstart(options) {
// Notify the Renderer-Process to reload the page when the Preload-Scripts build is complete,
// instead of restarting the entire Electron App.
options.reload()
},
vite: {
build: {
sourcemap,
minify: isBuild,
outDir: 'dist-electron/preload',
rollupOptions: {
external: Object.keys(pkg.dependencies),
},
},
},
}
]),
// Use Node.js API in the Renderer-process
renderer({
nodeIntegration: true,
optimizeDeps: {
include: [
'fs/promises',
'process',
export default defineConfig(({ command }) => {
rmSync('dist-electron', { recursive: true, force: true })
const isServe = command === 'serve'
const isBuild = command === 'build'
const sourcemap = isServe || !!process.env.VSCODE_DEBUG
return {
plugins: [
vue(),
vueJsx(),
Unocss(),
AutoImport({
imports: [
'vue',
],
},
}),
],
server: process.env.VSCODE_DEBUG ? (() => {
const url = new URL(pkg.debug.env.VITE_DEV_SERVER_URL)
return {
host: url.hostname,
port: +url.port,
}
})() : undefined,
clearScreen: false,
build: {
assetsDir: '', // #287
},
dts: 'src/auto-imports.d.ts',
dirs: [],
vueTemplate: true,
}),
// https://github.com/antfu/unplugin-vue-components
Components({
resolvers: [NaiveUiResolver()],
// allow auto load markdown components under `./src/components/`
extensions: ['vue', 'md'],
// allow auto import and register components used in markdown
include: [/\.vue$/, /\.vue\?vue/, /\.md$/],
dts: 'src/components.d.ts',
}),
electron([
{
// Main-Process entry file of the Electron App.
entry: 'electron/main/index.ts',
onstart(options) {
if (process.env.VSCODE_DEBUG) {
console.log(/* For `.vscode/.debug.script.mjs` */'[startup] Electron App')
} else {
options.startup()
}
},
vite: {
build: {
sourcemap,
minify: isBuild,
outDir: 'dist-electron/main',
rollupOptions: {
external: Object.keys('dependencies' in pkg ? pkg.dependencies : {}),
},
},
},
},
{
entry: 'electron/preload/index.ts',
onstart(options) {
// Notify the Renderer-Process to reload the page when the Preload-Scripts build is complete,
// instead of restarting the entire Electron App.
options.reload()
},
vite: {
build: {
sourcemap: sourcemap ? 'inline' : undefined, // #332
minify: isBuild,
outDir: 'dist-electron/preload',
rollupOptions: {
external: Object.keys('dependencies' in pkg ? pkg.dependencies : {}),
},
},
},
}
]),
// Use Node.js API in the Renderer-process
renderer(),
],
server: process.env.VSCODE_DEBUG && (() => {
const url = new URL(pkg.debug.env.VITE_DEV_SERVER_URL)
return {
host: url.hostname,
port: +url.port,
}
})(),
clearScreen: false,
}
})