删除目录「desktop-client-废弃」

This commit is contained in:
xxk
2026-06-26 09:03:01 +08:00
parent a1b8dece99
commit 186181ff07
23 changed files with 0 additions and 4139 deletions
-25
View File
@@ -1,25 +0,0 @@
const { app, BrowserWindow } = require('electron')
const path = require('path')
function createWindow() {
const win = new BrowserWindow({
width: 1400,
height: 900,
backgroundColor: '#0f1115',
webPreferences: {
nodeIntegration: true,
contextIsolation: false
}
})
const devUrl = process.env.VITE_DEV_SERVER_URL || 'http://127.0.0.1:5178'
win.loadURL(devUrl)
}
app.whenReady().then(createWindow)
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit()
}
})
-12
View File
@@ -1,12 +0,0 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Desktop Client</title>
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/renderer/main.js"></script>
</body>
</html>
File diff suppressed because it is too large Load Diff
-24
View File
@@ -1,24 +0,0 @@
{
"name": "desktop-client",
"private": true,
"version": "0.1.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build",
"preview": "vite preview",
"electron:dev": "electron ."
},
"dependencies": {
"axios": "^1.7.9",
"pinia": "^2.2.6",
"tdesign-vue-next": "^1.11.0",
"vue": "^3.5.13",
"vue-router": "^4.5.0"
},
"devDependencies": {
"@vitejs/plugin-vue": "^5.2.1",
"electron": "^31.7.7",
"vite": "^6.1.0"
}
}
@@ -1,47 +0,0 @@
<template>
<t-layout class="shell">
<t-aside width="240px" class="side">
<div class="brand">Browser Desk</div>
<div class="sub">Electron + Vue3 + TDesign Vue Next</div>
<t-menu theme="dark" v-model:value="active" @change="go">
<t-menu-item value="/profiles">环境</t-menu-item>
<t-menu-item value="/proxy">代理</t-menu-item>
<t-menu-item value="/fingerprint">指纹</t-menu-item>
<t-menu-item value="/running">运行中</t-menu-item>
<t-menu-item value="/settings">设置</t-menu-item>
</t-menu>
</t-aside>
<t-layout>
<t-header class="topbar">
<div>Electron + TDesign Frontend</div>
</t-header>
<t-content class="content">
<router-view />
</t-content>
</t-layout>
</t-layout>
</template>
<script setup>
import { ref, watch } from 'vue'
import { useRoute, useRouter } from 'vue-router'
const route = useRoute()
const router = useRouter()
const active = ref(route.path)
watch(() => route.path, val => (active.value = val))
function go(value) {
router.push(value)
}
</script>
<style scoped>
.shell { height: 100vh; }
.side { background: #111827; color: #fff; }
.brand { padding: 20px 20px 6px; font-weight: 700; }
.sub { padding: 0 20px 12px; opacity: 0.7; font-size: 12px; }
.topbar { display:flex; align-items:center; padding: 0 24px; background:#fff; border-bottom:1px solid #e5e7eb; }
.content { padding: 20px; background: #f5f7fb; }
</style>
-26
View File
@@ -1,26 +0,0 @@
import axios from 'axios'
import { appConfig } from './config'
import { getToken } from './storage'
export function createCloudApi() {
const client = axios.create({
baseURL: appConfig.cloudBaseUrl,
timeout: 15000
})
client.interceptors.request.use(config => {
const token = getToken()
if (token) {
config.headers = config.headers || {}
config.headers.Authorization = `Bearer ${token}`
}
return config
})
return client
}
export function createLocalApi() {
return axios.create({
baseURL: appConfig.localBaseUrl,
timeout: 15000
})
}
@@ -1,25 +0,0 @@
import { createCloudApi } from './api'
import { getToken, setToken, removeToken } from './storage'
export async function login(username, password, code = '', uuid = '') {
const api = createCloudApi()
const { data } = await api.post('/member/auth/login', { username, password, code, uuid })
setToken(data.data.token)
return data
}
export async function register(payload) {
const api = createCloudApi()
return api.post('/member/auth/register', payload)
}
export async function getInfo() {
const api = createCloudApi()
return api.get('/member/auth/info', {
headers: { Authorization: `Bearer ${getToken()}` }
})
}
export function logout() {
removeToken()
}
@@ -1,8 +0,0 @@
import { reactive } from 'vue'
export const appConfig = reactive({
cloudBaseUrl: localStorage.getItem('cloudBaseUrl') || 'http://127.0.0.1:7796',
localBaseUrl: localStorage.getItem('localBaseUrl') || 'http://127.0.0.1:8001',
chromiumRuntimePath: localStorage.getItem('chromiumRuntimePath') || '',
camoufoxRuntimePath: localStorage.getItem('camoufoxRuntimePath') || ''
})
@@ -1,13 +0,0 @@
import { getToken } from './storage'
export function installGuard(router) {
router.beforeEach((to) => {
if (to.path === '/login' || to.path === '/register') {
return true
}
if (!getToken()) {
return '/login'
}
return true
})
}
@@ -1,8 +0,0 @@
import { createApp } from 'vue'
import { createPinia } from 'pinia'
import TDesign from 'tdesign-vue-next'
import 'tdesign-vue-next/es/style/index.css'
import App from './App.vue'
import router from './router'
createApp(App).use(createPinia()).use(router).use(TDesign).mount('#app')
@@ -1,29 +0,0 @@
import { createRouter, createWebHashHistory } from 'vue-router'
import Home from './views/Home.vue'
import Profiles from './views/Profiles.vue'
import Running from './views/Running.vue'
import Settings from './views/Settings.vue'
import Login from './views/Login.vue'
import Register from './views/Register.vue'
import Proxy from './views/Proxy.vue'
import Fingerprint from './views/Fingerprint.vue'
import { installGuard } from './guard'
const router = createRouter({
history: createWebHashHistory(),
routes: [
{ path: '/login', component: Login },
{ path: '/register', component: Register },
{ path: '/', redirect: '/profiles' },
{ path: '/profiles', component: Profiles },
{ path: '/proxy', component: Proxy },
{ path: '/fingerprint', component: Fingerprint },
{ path: '/running', component: Running },
{ path: '/settings', component: Settings },
{ path: '/home', component: Home }
]
})
installGuard(router)
export default router
@@ -1,76 +0,0 @@
import { createCloudApi, createLocalApi } from '../api'
export async function fetchProxyList(params) {
const api = createCloudApi()
const { data } = await api.get('/browser/proxy/list', { params })
return data
}
export async function fetchProxy(id) {
const api = createCloudApi()
const { data } = await api.get(`/browser/proxy/${id}`)
return data
}
export async function createProxy(payload) {
const api = createCloudApi()
const { data } = await api.post('/browser/proxy', payload)
return data
}
export async function updateProxy(payload) {
const api = createCloudApi()
const { data } = await api.put('/browser/proxy', payload)
return data
}
export async function deleteProxy(id) {
const api = createCloudApi()
const { data } = await api.delete(`/browser/proxy/${id}`)
return data
}
export async function refreshProxyGeo(id) {
const api = createCloudApi()
const { data } = await api.post(`/browser/proxy/${id}/refresh-geo`)
return data
}
export async function fetchFingerprintList(params) {
const api = createCloudApi()
const { data } = await api.get('/browser/fingerprint/list', { params })
return data
}
export async function fetchFingerprint(id) {
const api = createCloudApi()
const { data } = await api.get(`/browser/fingerprint/${id}`)
return data
}
export async function createFingerprint(payload) {
const api = createCloudApi()
const { data } = await api.post('/browser/fingerprint', payload)
return data
}
export async function updateFingerprint(payload) {
const api = createCloudApi()
const { data } = await api.put('/browser/fingerprint', payload)
return data
}
export async function deleteFingerprint(id) {
const api = createCloudApi()
const { data } = await api.delete(`/browser/fingerprint/${id}`)
return data
}
export async function generateFingerprint(browserFamily, runtimePath = null) {
const api = createLocalApi()
const { data } = await api.post('/fingerprints/generate', {
browser_family: browserFamily,
runtime_path: runtimePath
})
return data
}
@@ -1,133 +0,0 @@
import { createCloudApi, createLocalApi } from '../api'
import { appConfig } from '../config'
import { fetchFingerprint, fetchProxy } from './cloud'
export async function fetchProfiles(params) {
const api = createCloudApi()
const { data } = await api.get('/browser/profile/list', { params })
return data
}
export async function fetchProfile(profileId) {
const api = createCloudApi()
const { data } = await api.get(`/browser/profile/${profileId}`)
return data
}
export async function createProfile(payload) {
const api = createCloudApi()
const { data } = await api.post('/browser/profile', payload)
return data
}
export async function updateProfile(payload) {
const api = createCloudApi()
const { data } = await api.put('/browser/profile', payload)
return data
}
export async function deleteProfile(profileId) {
const api = createCloudApi()
const { data } = await api.delete(`/browser/profile/${profileId}`)
return data
}
function buildFingerprintPayload(item) {
if (!item) {
return null
}
return {
fingerprintId: item.fingerprintId,
browserFamily: item.browserFamily,
userAgent: item.userAgent,
locale: item.locale,
timezone: item.timezone,
geoCountry: item.geoCountry,
screenWidth: item.screenWidth,
screenHeight: item.screenHeight,
webRtcPolicy: item.webRtcPolicy,
canvasPolicy: item.canvasPolicy,
webglPolicy: item.webglPolicy,
audioPolicy: item.audioPolicy,
fontPolicy: item.fontPolicy,
payload: item.encryptedPayload
}
}
function buildProxyPayload(item) {
if (!item) {
return null
}
if (item.proxyType === 'direct') {
return null
}
return {
proxy_type: item.proxyType,
host: item.host,
port: Number(item.port),
username: item.username || null
}
}
export async function launchProfile(profileId, options = {}) {
const profileRes = await fetchProfile(profileId)
const profile = profileRes.data
const [proxyRes, fingerprintRes] = await Promise.all([
profile.proxyId ? fetchProxy(profile.proxyId) : Promise.resolve(null),
profile.fingerprintId ? fetchFingerprint(profile.fingerprintId) : Promise.resolve(null)
])
const proxy = proxyRes?.data || null
const fingerprint = fingerprintRes?.data || null
const localApi = createLocalApi()
const runtimePath = profile.browserEngine === 'firefox'
? (appConfig.camoufoxRuntimePath || null)
: (appConfig.chromiumRuntimePath || null)
const payload = {
profile_id: String(profile.profileId),
browser_engine: profile.browserEngine,
runtime_path: runtimePath,
start_url: options.startUrl || 'https://www.browserscan.net',
headless: false,
browser_args: [],
proxy: buildProxyPayload(proxy),
fingerprint: buildFingerprintPayload(fingerprint),
proxy_type: proxy?.proxyType || null,
proxy_host: proxy?.host || null,
proxy_port: proxy?.port ? Number(proxy.port) : null
}
const { data } = await localApi.post(`/profiles/${profileId}/launch`, payload)
return data
}
export async function closeProfile(profileId) {
const api = createLocalApi()
const { data } = await api.post(`/profiles/${profileId}/close`)
return data
}
export async function fetchRunningProfiles() {
const api = createLocalApi()
const { data } = await api.get('/profiles/running')
return data
}
export async function fetchRuntimeStatus() {
const api = createLocalApi()
const { data } = await api.get('/runtime/status')
return data
}
export async function fetchRuntimeConfig() {
const api = createLocalApi()
const { data } = await api.get('/runtime/config')
return data
}
export async function saveRuntimeConfig(payload) {
const api = createLocalApi()
const { data } = await api.put('/runtime/config', payload)
return data
}
@@ -1,13 +0,0 @@
const TOKEN_KEY = 'desktop_member_token_v2'
export function getToken() {
return localStorage.getItem(TOKEN_KEY) || ''
}
export function setToken(token) {
localStorage.setItem(TOKEN_KEY, token)
}
export function removeToken() {
localStorage.removeItem(TOKEN_KEY)
}
@@ -1,200 +0,0 @@
<template>
<t-card title="指纹管理">
<t-space style="margin-bottom: 16px">
<t-button theme="primary" @click="handleAdd">新增</t-button>
<t-button theme="success" @click="handleGenerate">自动生成</t-button>
<t-button @click="loadList">刷新</t-button>
<t-button @click="goProfiles">返回环境</t-button>
</t-space>
<t-table row-key="fingerprintId" :data="list" :columns="columns">
<template #op="{ row }">
<t-button theme="primary" variant="text" @click="handleEdit(row)">编辑</t-button>
<t-button theme="danger" variant="text" @click="handleDelete(row)">删除</t-button>
</template>
</t-table>
<t-dialog v-model:visible="open" :header="dialogTitle" @confirm="submit">
<t-form :data="form" label-align="top">
<t-form-item label="浏览器家族">
<t-select v-model="form.browserFamily" @change="handleFamilyChange">
<t-option value="chromium" label="chromium" />
<t-option value="firefox" label="firefox" />
</t-select>
</t-form-item>
<t-form-item label="UA">
<t-input v-model="form.userAgent" />
</t-form-item>
<t-form-item label="语言">
<t-input v-model="form.locale" />
</t-form-item>
<t-form-item label="时区">
<t-input v-model="form.timezone" />
</t-form-item>
<t-form-item label="国家">
<t-input v-model="form.geoCountry" />
</t-form-item>
<t-form-item label="屏幕宽">
<t-input v-model="form.screenWidth" />
</t-form-item>
<t-form-item label="屏幕高">
<t-input v-model="form.screenHeight" />
</t-form-item>
<t-form-item label="WebRTC">
<t-input v-model="form.webRtcPolicy" />
</t-form-item>
<t-form-item label="Canvas">
<t-input v-model="form.canvasPolicy" />
</t-form-item>
<t-form-item label="WebGL">
<t-input v-model="form.webglPolicy" />
</t-form-item>
<t-form-item label="Audio">
<t-input v-model="form.audioPolicy" />
</t-form-item>
<t-form-item label="字体">
<t-input v-model="form.fontPolicy" />
</t-form-item>
</t-form>
</t-dialog>
</t-card>
</template>
<script setup>
import { onMounted, reactive, ref } from 'vue'
import { MessagePlugin } from 'tdesign-vue-next'
import { useRouter } from 'vue-router'
import { appConfig } from '../config'
import {
createFingerprint,
deleteFingerprint,
fetchFingerprint,
fetchFingerprintList,
generateFingerprint,
updateFingerprint
} from '../services/cloud'
const router = useRouter()
const list = ref([])
const open = ref(false)
const dialogTitle = ref('新增指纹')
const form = reactive(emptyFingerprint())
const columns = [
{ colKey: 'browserFamily', title: '浏览器家族' },
{ colKey: 'userAgent', title: 'UA', ellipsis: true },
{ colKey: 'locale', title: '语言' },
{ colKey: 'timezone', title: '时区' },
{ colKey: 'geoCountry', title: '国家' },
{ colKey: 'screenWidth', title: '宽' },
{ colKey: 'screenHeight', title: '高' },
{ colKey: 'webRtcPolicy', title: 'WebRTC' },
{ colKey: 'op', title: '操作', width: 160 }
]
function normalizeFingerprint(item = {}) {
return {
fingerprintId: item.fingerprintId ?? item.fingerprint_id,
browserFamily: item.browserFamily ?? item.browser_family ?? 'chromium',
userAgent: item.userAgent ?? item.user_agent ?? '',
locale: item.locale ?? '',
timezone: item.timezone ?? '',
geoCountry: item.geoCountry ?? item.geo_country ?? '',
screenWidth: item.screenWidth ?? item.screen_width ?? '',
screenHeight: item.screenHeight ?? item.screen_height ?? '',
webRtcPolicy: item.webRtcPolicy ?? item.web_rtc_policy ?? '',
canvasPolicy: item.canvasPolicy ?? item.canvas_policy ?? '',
webglPolicy: item.webglPolicy ?? item.web_gl_policy ?? item.webgl_policy ?? '',
audioPolicy: item.audioPolicy ?? item.audio_policy ?? '',
fontPolicy: item.fontPolicy ?? item.font_policy ?? '',
encryptedPayload: item.encryptedPayload ?? item.encrypted_payload ?? ''
}
}
async function loadList() {
try {
const res = await fetchFingerprintList({ pageNum: 1, pageSize: 50 })
list.value = (res.rows || []).map(normalizeFingerprint)
} catch (error) {
list.value = []
MessagePlugin.error(error?.response?.data?.msg || '指纹列表加载失败')
}
}
function emptyFingerprint() {
return {
fingerprintId: undefined,
browserFamily: 'chromium',
userAgent: '',
locale: 'zh-CN',
timezone: 'Asia/Shanghai',
geoCountry: 'CN',
screenWidth: 1920,
screenHeight: 1080,
webRtcPolicy: 'default',
canvasPolicy: 'default',
webglPolicy: 'default',
audioPolicy: 'default',
fontPolicy: 'default',
encryptedPayload: ''
}
}
async function applyDefaults(target, browserFamily = 'chromium') {
const runtimePath = browserFamily === 'chromium'
? (appConfig.chromiumRuntimePath || null)
: (appConfig.camoufoxRuntimePath || null)
const res = await generateFingerprint(browserFamily, runtimePath)
Object.assign(target, res.data)
}
function reset() {
Object.assign(form, emptyFingerprint())
}
function handleAdd() {
reset()
dialogTitle.value = '新增指纹'
open.value = true
}
async function handleGenerate() {
reset()
await applyDefaults(form, form.browserFamily)
dialogTitle.value = '自动生成指纹'
open.value = true
}
async function handleFamilyChange(value) {
await applyDefaults(form, value)
}
async function handleEdit(row) {
const res = await fetchFingerprint(row.fingerprintId)
Object.assign(form, emptyFingerprint(), normalizeFingerprint(res.data))
dialogTitle.value = '编辑指纹'
open.value = true
}
async function submit() {
form.screenWidth = Number(form.screenWidth)
form.screenHeight = Number(form.screenHeight)
if (form.fingerprintId) {
await updateFingerprint(form)
} else {
await createFingerprint(form)
}
open.value = false
await loadList()
}
async function handleDelete(row) {
await deleteFingerprint(row.fingerprintId)
await loadList()
}
function goProfiles() {
router.push('/profiles')
}
onMounted(loadList)
</script>
@@ -1 +0,0 @@
<template><div>Home</div></template>
@@ -1,36 +0,0 @@
<template>
<div class="auth-page">
<t-card class="auth-card" title="Browser Desk 登录">
<t-form :data="form" @submit="submit">
<t-form-item label="账号">
<t-input v-model="form.username" />
</t-form-item>
<t-form-item label="密码">
<t-input v-model="form.password" type="password" />
</t-form-item>
<t-form-item>
<t-button theme="primary" type="submit">登录</t-button>
<t-button variant="text" @click="goRegister">注册</t-button>
</t-form-item>
</t-form>
</t-card>
</div>
</template>
<script setup>
import { reactive } from 'vue'
import { useRouter } from 'vue-router'
import { login } from '../auth'
const router = useRouter()
const form = reactive({ username: '', password: '', code: '', uuid: '' })
async function submit() {
await login(form.username, form.password, form.code, form.uuid)
router.push('/profiles')
}
function goRegister() {
router.push('/register')
}
</script>
@@ -1,349 +0,0 @@
<template>
<t-card title="环境列表">
<t-space style="margin-bottom: 16px">
<t-button theme="primary" @click="handleAdd">新增</t-button>
<t-button @click="loadProfiles">刷新</t-button>
<t-button @click="goRunning">查看运行中</t-button>
</t-space>
<t-table row-key="profileId" :data="profiles" :columns="columns">
<template #proxyName="{ row }">
{{ proxyDisplay(row) }}
</template>
<template #status="{ row }">
{{ row.status === '0' ? '启用' : '停用' }}
</template>
<template #op="{ row }">
<t-button theme="primary" variant="text" @click="start(row)">启动</t-button>
<t-button theme="success" variant="text" @click="startDiagnostic(row)">诊断启动</t-button>
<t-button theme="warning" variant="text" @click="stop(row)">关闭</t-button>
<t-button theme="default" variant="text" @click="handleEdit(row)">编辑</t-button>
<t-button theme="danger" variant="text" @click="handleDelete(row)">删除</t-button>
</template>
</t-table>
<t-dialog v-model:visible="open" :header="dialogTitle" width="680px" @confirm="submit">
<t-form :data="form" label-align="top">
<t-row :gutter="[16, 0]">
<t-col :span="6">
<t-form-item label="环境名称">
<t-input v-model="form.profileName" />
</t-form-item>
</t-col>
<t-col :span="6">
<t-form-item label="分组">
<t-input v-model="form.groupName" />
</t-form-item>
</t-col>
<t-col :span="6">
<t-form-item label="内核">
<t-select v-model="form.browserEngine">
<t-option value="chromium" label="chromium" />
<t-option value="firefox" label="firefox" />
</t-select>
</t-form-item>
</t-col>
<t-col :span="6">
<t-form-item label="状态">
<t-select v-model="form.status">
<t-option value="0" label="启用" />
<t-option value="1" label="停用" />
</t-select>
</t-form-item>
</t-col>
<t-col :span="6">
<t-form-item label="平台/用途">
<t-input v-model="form.platform" />
</t-form-item>
</t-col>
<t-col :span="6">
<t-form-item label="浏览器通道">
<t-input v-model="form.browserChannel" />
</t-form-item>
</t-col>
<t-col :span="6">
<t-form-item label="浏览器版本">
<t-input v-model="form.browserVersion" />
</t-form-item>
</t-col>
<t-col :span="6">
<t-form-item label="代理配置">
<t-select v-model="form.proxyId" clearable @change="handleProxyChange">
<t-option
v-for="item in proxyOptions"
:key="item.proxyId"
:value="item.proxyId"
:label="item.proxyName"
/>
</t-select>
</t-form-item>
</t-col>
<t-col :span="12">
<t-form-item label="指纹配置">
<t-select v-model="form.fingerprintId" clearable>
<t-option
v-for="item in fingerprintOptions"
:key="item.fingerprintId"
:value="item.fingerprintId"
:label="fingerprintLabel(item)"
/>
</t-select>
</t-form-item>
</t-col>
<t-col :span="12">
<t-form-item label="标签">
<t-input v-model="form.tags" />
</t-form-item>
</t-col>
<t-col :span="12">
<t-form-item label="本地标识">
<t-input v-model="form.localProfileKey" />
</t-form-item>
</t-col>
<t-col :span="6">
<t-form-item label="同步状态">
<t-select v-model="form.syncStatus">
<t-option value="0" label="未同步" />
<t-option value="1" label="已同步" />
</t-select>
</t-form-item>
</t-col>
<t-col :span="6">
<t-form-item label="纯净状态">
<t-select v-model="form.purityStatus">
<t-option value="0" label="未检测" />
<t-option value="1" label="纯净" />
</t-select>
</t-form-item>
</t-col>
<t-col :span="12">
<t-form-item label="备注">
<t-textarea v-model="form.remark" :autosize="{ minRows: 3, maxRows: 5 }" />
</t-form-item>
</t-col>
</t-row>
</t-form>
</t-dialog>
</t-card>
</template>
<script setup>
import { onMounted, reactive, ref } from 'vue'
import { MessagePlugin } from 'tdesign-vue-next'
import { useRouter } from 'vue-router'
import {
closeProfile,
createProfile,
deleteProfile,
fetchProfile,
fetchProfiles,
launchProfile,
updateProfile
} from '../services/profile'
import { fetchFingerprintList, fetchProxyList } from '../services/cloud'
const router = useRouter()
const profiles = ref([])
const proxyOptions = ref([])
const fingerprintOptions = ref([])
const open = ref(false)
const dialogTitle = ref('新增环境')
const columns = [
{ colKey: 'profileName', title: '环境名称' },
{ colKey: 'browserEngine', title: '内核', width: 120 },
{ colKey: 'proxyName', title: '代理', ellipsis: true },
{ colKey: 'fingerprintId', title: '指纹ID', width: 180 },
{ colKey: 'status', title: '状态', width: 100 },
{ colKey: 'op', title: '操作', width: 340 }
]
const form = reactive(emptyProfile())
function emptyProfile() {
return {
profileId: undefined,
profileName: '',
groupName: '',
tags: '',
platform: '',
browserEngine: 'chromium',
browserChannel: '',
browserVersion: '',
proxyName: '',
proxyId: undefined,
fingerprintId: undefined,
localProfileKey: '',
syncStatus: '0',
purityStatus: '0',
status: '0',
remark: ''
}
}
function reset() {
Object.assign(form, emptyProfile())
}
function normalizeProfile(item = {}) {
return {
profileId: item.profileId ?? item.profile_id,
profileName: item.profileName ?? item.profile_name ?? '',
groupName: item.groupName ?? item.group_name ?? '',
tags: item.tags ?? '',
platform: item.platform ?? '',
browserEngine: item.browserEngine ?? item.browser_engine ?? 'chromium',
browserChannel: item.browserChannel ?? item.browser_channel ?? '',
browserVersion: item.browserVersion ?? item.browser_version ?? '',
proxyName: item.proxyName ?? item.proxy_name ?? '',
proxyId: item.proxyId ?? item.proxy_id ?? undefined,
fingerprintId: item.fingerprintId ?? item.fingerprint_id ?? undefined,
localProfileKey: item.localProfileKey ?? item.local_profile_key ?? '',
syncStatus: item.syncStatus ?? item.sync_status ?? '0',
purityStatus: item.purityStatus ?? item.purity_status ?? '0',
status: item.status ?? '0',
remark: item.remark ?? ''
}
}
function fingerprintLabel(item) {
const family = item.browserFamily || item.browser_family || 'unknown'
const locale = item.locale || '-'
const timezone = item.timezone || '-'
return `${family} / ${locale} / ${timezone}`
}
function proxyDisplay(row) {
const proxy = proxyOptions.value.find(item => item.proxyId === row.proxyId)
const proxyType = proxy?.proxyType || row.proxyType
if (proxyType === 'direct') {
return '本地网络'
}
if (proxyType === 'https') {
return proxy?.proxyName || 'HTTPS 代理'
}
if (proxyType === 'socks5') {
return proxy?.proxyName || 'SOCKS5 代理'
}
return proxy?.proxyName || row.proxyName || 'HTTP 代理'
}
function handleProxyChange(value) {
const current = proxyOptions.value.find(item => item.proxyId === value)
form.proxyName = current?.proxyName || ''
}
async function loadMeta() {
const [proxyRes, fingerprintRes] = await Promise.all([
fetchProxyList({ pageNum: 1, pageSize: 200 }),
fetchFingerprintList({ pageNum: 1, pageSize: 200 })
])
proxyOptions.value = proxyRes.rows || []
fingerprintOptions.value = fingerprintRes.rows || []
}
async function loadProfiles() {
try {
const res = await fetchProfiles({ pageNum: 1, pageSize: 50 })
profiles.value = (res.rows || []).map(normalizeProfile)
} catch (error) {
profiles.value = []
MessagePlugin.error(error?.response?.data?.msg || '环境列表加载失败')
}
}
function handleAdd() {
reset()
dialogTitle.value = '新增环境'
open.value = true
}
async function handleEdit(row) {
try {
const res = await fetchProfile(row.profileId)
Object.assign(form, emptyProfile(), normalizeProfile(res.data))
dialogTitle.value = '编辑环境'
open.value = true
} catch (error) {
MessagePlugin.error(error?.response?.data?.msg || '环境详情加载失败')
}
}
async function submit() {
if (!form.profileName.trim()) {
MessagePlugin.error('环境名称不能为空')
return false
}
if (!form.browserEngine) {
MessagePlugin.error('浏览器内核不能为空')
return false
}
const payload = {
...form,
proxyId: form.proxyId || null,
fingerprintId: form.fingerprintId || null
}
try {
if (payload.profileId) {
await updateProfile(payload)
MessagePlugin.success('环境已更新')
} else {
await createProfile(payload)
MessagePlugin.success('环境已创建')
}
open.value = false
await loadProfiles()
return true
} catch (error) {
MessagePlugin.error(error?.response?.data?.msg || '环境保存失败')
return false
}
}
async function handleDelete(row) {
try {
await deleteProfile(row.profileId)
MessagePlugin.success('环境已删除')
await loadProfiles()
} catch (error) {
MessagePlugin.error(error?.response?.data?.msg || '环境删除失败')
}
}
async function start(row) {
try {
await launchProfile(row.profileId)
MessagePlugin.success('启动已发送')
} catch (error) {
MessagePlugin.error(error?.response?.data?.msg || '环境启动失败')
}
}
async function startDiagnostic(row) {
try {
await launchProfile(row.profileId, {
startUrl: 'http://127.0.0.1:8001/diagnostics/fingerprint'
})
MessagePlugin.success('诊断启动已发送')
} catch (error) {
MessagePlugin.error(error?.response?.data?.msg || '诊断启动失败')
}
}
async function stop(row) {
try {
await closeProfile(row.profileId)
MessagePlugin.success('关闭已发送')
} catch (error) {
MessagePlugin.error(error?.response?.data?.msg || '环境关闭失败')
}
}
function goRunning() {
router.push('/running')
}
onMounted(async () => {
await loadMeta()
await loadProfiles()
})
</script>
@@ -1,250 +0,0 @@
<template>
<t-card title="代理管理">
<t-space style="margin-bottom: 16px">
<t-button theme="primary" @click="handleAdd">新增</t-button>
<t-button @click="loadList">刷新</t-button>
<t-button @click="goProfiles">返回环境</t-button>
</t-space>
<t-table row-key="proxyId" :data="list" :columns="columns">
<template #proxyType="{ row }">
{{ proxyTypeLabel(row.proxyType) }}
</template>
<template #host="{ row }">
{{ row.proxyType === 'direct' ? '-' : row.host }}
</template>
<template #port="{ row }">
{{ row.proxyType === 'direct' ? '-' : row.port }}
</template>
<template #geoLocation="{ row }">
{{ proxyGeoLabel(row) }}
</template>
<template #op="{ row }">
<t-button theme="primary" variant="text" @click="handleEdit(row)">编辑</t-button>
<t-button theme="primary" variant="text" @click="handleRefreshGeo(row)">刷新地区</t-button>
<t-button theme="danger" variant="text" @click="handleDelete(row)">删除</t-button>
</template>
</t-table>
<t-dialog v-model:visible="open" :header="dialogTitle" @confirm="submit">
<t-form :data="form" label-align="top">
<t-form-item label="代理名称">
<t-input v-model="form.proxyName" />
</t-form-item>
<t-form-item label="代理模式">
<t-radio-group v-model="form.proxyType" @change="handleProxyTypeChange">
<t-radio-button value="direct">本地网络(不代理)</t-radio-button>
<t-radio-button value="http">IP代理</t-radio-button>
</t-radio-group>
</t-form-item>
<template v-if="form.proxyType !== 'direct'">
<t-form-item label="代理协议">
<t-select v-model="form.proxyType">
<t-option value="http" label="HTTP" />
<t-option value="https" label="HTTPS" />
<t-option value="socks5" label="SOCKS5" />
</t-select>
</t-form-item>
<t-form-item label="代理主机">
<t-input v-model="form.host" placeholder="例如 127.0.0.1" />
</t-form-item>
<t-form-item label="代理端口">
<t-input v-model="form.port" placeholder="例如 7890" />
</t-form-item>
<t-form-item label="代理用户名">
<t-input v-model="form.username" />
</t-form-item>
</template>
<t-form-item label="状态">
<t-select v-model="form.status">
<t-option value="0" label="启用" />
<t-option value="1" label="停用" />
</t-select>
</t-form-item>
</t-form>
</t-dialog>
</t-card>
</template>
<script setup>
import { reactive, onMounted, ref } from 'vue'
import { MessagePlugin } from 'tdesign-vue-next'
import { useRouter } from 'vue-router'
import { createProxy, deleteProxy, fetchProxy, fetchProxyList, refreshProxyGeo, updateProxy } from '../services/cloud'
const router = useRouter()
const list = ref([])
const open = ref(false)
const dialogTitle = ref('新增代理')
const columns = [
{ colKey: 'proxyName', title: '代理名称' },
{ colKey: 'proxyType', title: '类型', width: 150 },
{ colKey: 'host', title: '主机' },
{ colKey: 'port', title: '端口', width: 100 },
{ colKey: 'geoLocation', title: '地区', width: 240 },
{ colKey: 'status', title: '状态', width: 100 },
{ colKey: 'op', title: '操作', width: 240 }
]
const form = reactive(emptyProxy())
function emptyProxy() {
return {
proxyId: undefined,
proxyName: '',
proxyType: 'direct',
host: '',
port: '',
geoCountry: '',
geoRegion: '',
geoCity: '',
username: '',
passwordEncrypted: '',
status: '0'
}
}
function normalizeProxy(item = {}) {
return {
proxyId: item.proxyId ?? item.proxy_id,
proxyName: item.proxyName ?? item.proxy_name ?? '',
proxyType: item.proxyType ?? item.proxy_type ?? 'direct',
host: item.host ?? '',
port: item.port ?? '',
geoCountry: item.geoCountry ?? item.geo_country ?? '',
geoRegion: item.geoRegion ?? item.geo_region ?? '',
geoCity: item.geoCity ?? item.geo_city ?? '',
username: item.username ?? '',
passwordEncrypted: item.passwordEncrypted ?? item.password_encrypted ?? '',
status: item.status ?? '0'
}
}
function proxyTypeLabel(proxyType) {
if (proxyType === 'direct') {
return '本地网络'
}
if (proxyType === 'https') {
return 'HTTPS 代理'
}
if (proxyType === 'socks5') {
return 'SOCKS5 代理'
}
return 'HTTP 代理'
}
function proxyGeoLabel(row) {
if (row.proxyType === 'direct') {
return '-'
}
const parts = [row.geoCountry, row.geoRegion, row.geoCity].filter(Boolean)
return parts.length ? parts.join(' / ') : '-'
}
async function loadList() {
try {
const res = await fetchProxyList({ pageNum: 1, pageSize: 50 })
list.value = (res.rows || []).map(normalizeProxy)
} catch (error) {
list.value = []
MessagePlugin.error(error?.response?.data?.msg || '代理列表加载失败')
}
}
function reset() {
Object.assign(form, emptyProxy())
}
function handleProxyTypeChange(value) {
if (value === 'direct') {
form.host = ''
form.port = ''
form.geoCountry = ''
form.geoRegion = ''
form.geoCity = ''
form.username = ''
form.passwordEncrypted = ''
}
}
function handleAdd() {
reset()
dialogTitle.value = '新增代理'
open.value = true
}
async function handleEdit(row) {
try {
const res = await fetchProxy(row.proxyId)
Object.assign(form, emptyProxy(), normalizeProxy(res.data))
dialogTitle.value = '编辑代理'
open.value = true
} catch (error) {
MessagePlugin.error(error?.response?.data?.msg || '代理详情加载失败')
}
}
async function submit() {
if (!form.proxyName.trim()) {
MessagePlugin.error('代理名称不能为空')
return false
}
if (form.proxyType !== 'direct') {
if (!form.host.trim()) {
MessagePlugin.error('IP代理模式下代理主机不能为空')
return false
}
if (!form.port) {
MessagePlugin.error('IP代理模式下代理端口不能为空')
return false
}
}
const payload = {
...form,
port: form.proxyType === 'direct' ? null : Number(form.port),
host: form.proxyType === 'direct' ? null : form.host,
username: form.proxyType === 'direct' ? null : form.username
}
try {
if (payload.proxyId) {
await updateProxy(payload)
MessagePlugin.success('代理已更新')
} else {
await createProxy(payload)
MessagePlugin.success('代理已创建')
}
open.value = false
await loadList()
return true
} catch (error) {
MessagePlugin.error(error?.response?.data?.msg || '代理保存失败')
return false
}
}
async function handleDelete(row) {
try {
await deleteProxy(row.proxyId)
MessagePlugin.success('代理已删除')
await loadList()
} catch (error) {
MessagePlugin.error(error?.response?.data?.msg || '代理删除失败')
}
}
async function handleRefreshGeo(row) {
try {
await refreshProxyGeo(row.proxyId)
MessagePlugin.success('代理地区已刷新')
await loadList()
} catch (error) {
MessagePlugin.error(error?.response?.data?.msg || '代理地区刷新失败')
}
}
function goProfiles() {
router.push('/profiles')
}
onMounted(loadList)
</script>
@@ -1,48 +0,0 @@
<template>
<div class="auth-page">
<t-card class="auth-card" title="Browser Desk 注册">
<t-form :data="form" @submit="submit">
<t-form-item label="账号">
<t-input v-model="form.username" />
</t-form-item>
<t-form-item label="密码">
<t-input v-model="form.password" type="password" />
</t-form-item>
<t-form-item label="确认">
<t-input v-model="form.confirmPassword" type="password" />
</t-form-item>
<t-form-item>
<t-button theme="primary" type="submit">注册</t-button>
<t-button variant="text" @click="goLogin">返回登录</t-button>
</t-form-item>
</t-form>
</t-card>
</div>
</template>
<script setup>
import { reactive } from 'vue'
import { MessagePlugin } from 'tdesign-vue-next'
import { useRouter } from 'vue-router'
import { register } from '../auth'
const router = useRouter()
const form = reactive({ username: '', password: '', confirmPassword: '' })
async function submit() {
if (form.password !== form.confirmPassword) {
MessagePlugin.error('两次输入的密码不一致')
return
}
await register({
username: form.username,
password: form.password,
confirmPassword: form.confirmPassword
})
router.push('/login')
}
function goLogin() {
router.push('/login')
}
</script>
@@ -1,38 +0,0 @@
<template>
<t-card title="运行中">
<t-space style="margin-bottom: 16px">
<t-button theme="primary" @click="loadRunning">刷新</t-button>
</t-space>
<t-table row-key="profileId" :data="running">
<t-table-column col-key="profileId" title="Profile" />
<t-table-column col-key="browserEngine" title="内核" />
<t-table-column col-key="pid" title="PID" />
<t-table-column col-key="port" title="端口" />
<t-table-column col-key="status" title="状态" />
<t-table-column title="操作">
<template #cell="{ row }">
<t-button theme="danger" variant="text" @click="stop(row)">关闭</t-button>
</template>
</t-table-column>
</t-table>
</t-card>
</template>
<script setup>
import { onMounted, ref } from 'vue'
import { closeProfile, fetchRunningProfiles } from '../services/profile'
const running = ref([])
async function loadRunning() {
const res = await fetchRunningProfiles()
running.value = res.items || []
}
async function stop(row) {
await closeProfile(row.profileId)
await loadRunning()
}
onMounted(loadRunning)
</script>
@@ -1,111 +0,0 @@
<template>
<t-card title="设置">
<t-form :data="form" @submit="save">
<t-form-item label="云端地址">
<t-input v-model="form.cloudBaseUrl" />
</t-form-item>
<t-form-item label="本地地址">
<t-input v-model="form.localBaseUrl" />
</t-form-item>
<t-form-item label="Chromium 运行时">
<t-input v-model="form.chromiumRuntimePath" />
</t-form-item>
<t-form-item label="Camoufox 运行时">
<t-input v-model="form.camoufoxRuntimePath" />
</t-form-item>
<t-form-item label="自动检测">
<div class="runtime-status">
<div>Chromium: {{ runtimeStatus.chromium }}</div>
<div>Camoufox: {{ runtimeStatus.camoufox }}</div>
</div>
</t-form-item>
<t-form-item>
<t-button theme="primary" type="submit">保存</t-button>
<t-button type="button" variant="outline" style="margin-left: 12px" @click="resetRuntimeConfig">恢复自动检测</t-button>
</t-form-item>
</t-form>
</t-card>
</template>
<script setup>
import { onMounted, reactive } from 'vue'
import { MessagePlugin } from 'tdesign-vue-next'
import { appConfig } from '../config'
import { fetchRuntimeConfig, fetchRuntimeStatus, saveRuntimeConfig } from '../services/profile'
const form = reactive({
cloudBaseUrl: appConfig.cloudBaseUrl,
localBaseUrl: appConfig.localBaseUrl,
chromiumRuntimePath: appConfig.chromiumRuntimePath,
camoufoxRuntimePath: appConfig.camoufoxRuntimePath
})
const runtimeStatus = reactive({
chromium: '未检测',
camoufox: '未检测'
})
function formatRuntimeStatus(item) {
if (!item) {
return '未检测'
}
if (!item.installed) {
return '未找到'
}
return `${item.path} (${item.source || 'unknown'})`
}
async function loadRuntimeConfig() {
try {
const [configRes, statusRes] = await Promise.all([
fetchRuntimeConfig(),
fetchRuntimeStatus()
])
form.chromiumRuntimePath = configRes.data?.chromium_runtime_path || ''
form.camoufoxRuntimePath = configRes.data?.camoufox_runtime_path || ''
appConfig.chromiumRuntimePath = form.chromiumRuntimePath
appConfig.camoufoxRuntimePath = form.camoufoxRuntimePath
runtimeStatus.chromium = formatRuntimeStatus(statusRes.runtimes?.chromium)
runtimeStatus.camoufox = formatRuntimeStatus(statusRes.runtimes?.camoufox)
} catch (error) {
runtimeStatus.chromium = '本地控制器未连接'
runtimeStatus.camoufox = '本地控制器未连接'
}
}
async function save() {
appConfig.cloudBaseUrl = form.cloudBaseUrl
appConfig.localBaseUrl = form.localBaseUrl
appConfig.chromiumRuntimePath = form.chromiumRuntimePath
appConfig.camoufoxRuntimePath = form.camoufoxRuntimePath
localStorage.setItem('cloudBaseUrl', form.cloudBaseUrl)
localStorage.setItem('localBaseUrl', form.localBaseUrl)
localStorage.setItem('chromiumRuntimePath', form.chromiumRuntimePath)
localStorage.setItem('camoufoxRuntimePath', form.camoufoxRuntimePath)
try {
await saveRuntimeConfig({
chromium_runtime_path: form.chromiumRuntimePath || null,
camoufox_runtime_path: form.camoufoxRuntimePath || null
})
await loadRuntimeConfig()
MessagePlugin.success('设置已保存')
} catch (error) {
MessagePlugin.error('保存失败,请检查本地控制器地址')
}
}
async function resetRuntimeConfig() {
form.chromiumRuntimePath = ''
form.camoufoxRuntimePath = ''
await save()
}
onMounted(loadRuntimeConfig)
</script>
<style scoped>
.runtime-status {
line-height: 1.8;
color: #4b5563;
}
</style>
-13
View File
@@ -1,13 +0,0 @@
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
export default defineConfig({
plugins: [vue()],
server: {
host: '127.0.0.1',
port: 5178
},
build: {
outDir: 'dist/renderer'
}
})