Initial commit

This commit is contained in:
2025-06-26 11:28:55 +08:00
commit e11c59cdc2
167 changed files with 6029 additions and 0 deletions

36
src/main/config.js Normal file
View File

@@ -0,0 +1,36 @@
import logger from './utils/logger'
import { join } from 'path'
let configUrl=join(__dirname, '../../config/customConfig.json')
logger.info("configUrl:"+configUrl)
let configPath=configUrl
const config = require('electron-json-config').factory(configPath)
logger.info(config)
logger.info("================config.get(MAIN_VITE_DIFY_HOST):")
logger.info(config.get('MAIN_VITE_DIFY_HOST'))
logger.info(config.get('MAIN_VITE_DIFY_HOST'))
logger.info(config.get('MAIN_VITE_DIFY_HOST'))
logger.info(config.get('MAIN_VITE_DIFY_HOST'))
function initFunc() {
if(typeof config.get('MAIN_VITE_DIFY_HOST')=="undefined"){
logger.info("set config to local json:import.meta.env.MAIN_VITE_DIFY_HOST:"+import.meta.env.MAIN_VITE_DIFY_HOST)
config.set("MAIN_VITE_DIFY_HOST", import.meta.env.MAIN_VITE_DIFY_HOST)
}
}
export default {
set(key, value) {
config.set(key, value)
},
get(param) {
return config.get(param)
}
}

56
src/main/dify.js Normal file
View File

@@ -0,0 +1,56 @@
import axios from 'axios';
import { getStoreValue } from './store.js';
import logger from './utils/logger'
let difyRetryRequesTimer = null;
export async function difyRetryRequestTimer() {
// 如果定时器已经存在,则不再重复启动
if (difyRetryRequesTimer !== null) {
logger.info("定时器已存在,不再重复启动。");
return;
}
// 启动定时器
difyRetryRequesTimer = setInterval(async () => {
try {
// 从 store 中获取必要的数据
const difySite = getStoreValue("difySite");
const accessToken = getStoreValue("dify_access_token");
// 检查必要的参数是否存在
if (!difySite || !accessToken) {
console.error("缺少必要的参数difySite 或 dify_access_token");
return;
}
// 构造请求 URL 和 Headers
const url = `${difySite}/console/api/workspaces/current`;
const response = await axios.get(url, {
headers: {
'Authorization': `Bearer ${accessToken}`,
'Content-Type': 'application/json'
}
});
// 打印成功响应
logger.info("======================== 请求成功 ========================");
logger.info("difySite:", difySite);
logger.info("dify_access_token:", accessToken);
logger.info("响应数据:", response.data);
} catch (error) {
// 捕获并处理错误
console.error("======================== 请求失败 ========================");
console.error("错误信息:", error.message || error);
}
}, 5000); // 每 5 秒执行一次
}
export function stopDifyRetryRequestTimer() {
if (difyRetryRequesTimer !== null) {
clearInterval(difyRetryRequesTimer);
difyRetryRequesTimer = null;
logger.info("定时器已停止。");
}
}

176
src/main/index.js Normal file
View File

@@ -0,0 +1,176 @@
import { app, shell, BrowserWindow, ipcMain, Menu, session, screen, dialog } from 'electron'
import { electronApp, optimizer } from '@electron-toolkit/utils'
import Store from 'electron-store'
import { createWindow, createDrageWindow, unregisterAllShortcuts } from './window.js'
import { setupIPC } from './ipc.js'
import { createTray, destroyTray } from './tray.js'
import { getStoreValue } from './store.js'
import XEUtils from 'xe-utils'
import logger from './utils/logger'
import AutoLaunch from 'auto-launch'
import WebSocketClient from './utils/WebSocketClient';
let wsClient=null
wsClient=new WebSocketClient({
autoReconnect: true,
autoReconnectAttempts: 9999,
autoReconnectInterval: 5000,
timeout: 30000,
})
wsClient.on('open', () => {
logger.info('WebSocket连接已打开')
});
var minecraftAutoLauncher = new AutoLaunch({
name: '百千万AI智能体共创平台',
path: app.getPath('exe')
});
app.commandLine.appendSwitch('allow-insecure-localhost'); // 允许本地回环地址使用不安全连接
app.commandLine.appendSwitch('ignore-certificate-errors'); // 忽略证书错误(开发时可用)
const h5_client_url=getStoreValue("h5_client_url")
if(!XEUtils.isEmpty(h5_client_url)){
logger.info("=======================h5_client_url 非空,设置 unsafely-treat-insecure-origin-as-secure的值为:"+h5_client_url)
app.commandLine.appendSwitch('unsafely-treat-insecure-origin-as-secure', h5_client_url);
}
let difySite=getStoreValue("difySite")
if(!XEUtils.isEmpty(difySite)){
difySite = XEUtils.parseUrl(difySite)
logger.info("=======================h5_client_url 非空,设置 unsafely-treat-insecure-origin-as-secure的值为:"+h5_client_url+","+difySite.origin)
app.commandLine.appendSwitch('unsafely-treat-insecure-origin-as-secure', h5_client_url+","+difySite.origin);
}
// 设置控制台编码为 UTF-8
logger.info(`当前运行平台: ${process.platform}`)
if (process.platform === 'win32') {
logger.info('Windows 系统,设置控制台编码为 UTF-8')
require('child_process').execSync('chcp 65001', { stdio: 'ignore' })
} else {
logger.info('非 Windows 系统,使用默认编码')
}
logger.info('%cRed text. %cGreen text', 'color: red', 'color: green')
const store = new Store()
app.commandLine.appendSwitch('disable-features', 'OutOfBlinkCors')
app.commandLine.appendSwitch('ignore-certificate-errors')
app.disableHardwareAcceleration()
logger.info(app.getPath('userData'))
// 检查是否为第一个实例
const gotTheLock = app.requestSingleInstanceLock()
if (!gotTheLock) {
// 如果不是第一个实例,尝试激活第一个实例的窗口
const windows = BrowserWindow.getAllWindows()
if (windows.length > 0) {
const mainWindow = windows[0]
if (mainWindow.isMinimized()) {
mainWindow.restore()
}
mainWindow.show()
mainWindow.focus()
}
app.quit() // 退出当前实例
} else {
// 这是第一个实例
// 监听第二个实例的启动
app.on('second-instance', (event, commandLine, workingDirectory) => {
// 当运行第二个实例时,将显示第一个实例的窗口
const windows = BrowserWindow.getAllWindows()
if (windows.length > 0) {
const mainWindow = windows[0]
if (mainWindow.isMinimized()) {
mainWindow.restore()
}
mainWindow.show()
mainWindow.focus()
}
})
app.whenReady().then(() => {
// 获取默认会话并全局设置允许第三方 Cookie
const defaultSession = session.defaultSession;
// 设置 Cookie 策略以允许第三方 Cookie
defaultSession.setPermissionRequestHandler((webContents, permission, callback) => {
callback(true);
});
electronApp.setAppUserModelId('com.electron')
app.on('browser-window-created', (_, window) => {
optimizer.watchWindowShortcuts(window)
})
// 根据存储的状态决定是否创建悬浮窗口
if (getStoreValue('showDrageWindow')) {
createDrageWindow()
}
createWindow()
createTray()
setupIPC()
minecraftAutoLauncher.isEnabled()
.then(function(isEnabled){
if(isEnabled){
return;
}
minecraftAutoLauncher.enable();
})
.catch(function(err){
logger.info(err)
});
app.on('activate', function () {
if (BrowserWindow.getAllWindows().length === 0) createWindow()
})
})
// 修改窗口关闭行为
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
if (!app.isQuiting) {
// 如果不是主动退出,则隐藏所有窗口
BrowserWindow.getAllWindows().forEach(window => {
window.hide()
})
} else {
// 如果是主动退出,则销毁托盘并退出应用
destroyTray()
app.quit()
}
}
})
// 在应用退出时注销所有快捷键
app.on('will-quit', () => {
unregisterAllShortcuts()
})
}

242
src/main/ipc.js Normal file
View File

@@ -0,0 +1,242 @@
import { BrowserWindow, ipcMain, shell, Notification, app } from "electron";
import { setStoreValue, getStoreValue } from './store.js'
import { createNewWindow, createWindow, getMainWindow, getDrageWindow, closeApiConfigWindow, closeConfigWindow } from './window.js'
import { difyRetryRequestTimer } from './dify.js'
import axios from 'axios'
import log from 'electron-log/main';
log.initialize();
import {checkForUpdates} from "./utils/updateUtils"
import logger from './utils/logger'
function isValidUrl(_url) {
const containsApp = _url.includes('/app/');
const containsConfigurationOrWorkflow = _url.includes('/configuration') || _url.includes('/workflow');
// 只有当 URL 包含 'app' 并且包含 'configuration' 或 'workflow' 时,才返回 true
return containsApp && containsConfigurationOrWorkflow;
}
export function setupIPC() {
ipcMain.handle('initClientData', (event, data) => {
logger.info('=======================================initClientData')
logger.info(data)
setStoreValue("token", data.token);
setStoreValue("dify_access_token:", data.dify_access_token);
setStoreValue("dify_refresh_token", data.dify_refresh_token);
setStoreValue("userInfo", data.userInfo);
setStoreValue("apiUrl", data.apiUrl);
setStoreValue("difySite", data.difySite);
setStoreValue("test_12222222", "test_12222222");
difyRetryRequestTimer()
return 'pong'
})
ipcMain.handle('openNewWindow', (event, _url, dify_access_token, refresh_token) => {
logger.info('=======================================openNewWindow')
logger.info(_url)
const _sandbox=isValidUrl(_url)
logger.info('=======================================openNewWindow _sandbox:',_sandbox)
createNewWindow(_url, dify_access_token, refresh_token,_sandbox)
return 'pong'
})
ipcMain.handle('setMainWindowTitle', (event, title) => {
const mainWindow = getMainWindow();
if (mainWindow && !mainWindow.isDestroyed()) {
mainWindow.setTitle(title);
}
return 'pong'
})
ipcMain.handle('setLocalStorage', (event, key, value) => {
setStoreValue("token", data.token);
return 'pong'
})
ipcMain.handle('setGuiLocalStorage', (event, key, value) => {
logger.info("=============================================: setGuiLocalStorage key", key)
logger.info("=============================================: setGuiLocalStorage value", value)
setStoreValue(key, value);
return 'pong'
})
ipcMain.handle('getGuiLocalStorage', (event, key) => {
return getStoreValue(key)
})
ipcMain.handle('difyWebUploadFileToApi', async (event, datasetId, data) => {
logger.info("=============================================: difyWebUploadFileToApi");
logger.info("=============================================: datasetId: " + datasetId);
logger.info("=============================================: data: ");
logger.info(data)
try {
const java_api = getStoreValue("apiUrl") + "/bqw-ai" + "/app/api/knowledge/addDocumentToKnowledge";
const token = getStoreValue("token");
if (!java_api || !token) {
throw new Error("API URL or Token is missing in the store.");
}
const params = {
kg_id: datasetId,
files: datasetId,
knowledgeDocumentParams: JSON.parse(data)
};
logger.info("=======================java_api:"+java_api);
logger.info("=======================params:")
logger.info(params)
const response = await axios.post(java_api, params, {
headers: {
'x-access-token': `${token}`,
'Content-Type': 'application/json'
}
});
logger.info("Response from server:", response.data);
// 获取当前窗口并关闭
const currentWindow = event.sender.getOwnerBrowserWindow();
if (currentWindow && !currentWindow.isDestroyed()) {
currentWindow.close();
}
return response.data;
} catch (error) {
console.error("Error making POST request:", error.message);
throw error;
}
});
ipcMain.on('difyWebUpdateDatasetsInfo', (event) => {
return 'pong'
})
ipcMain.on('app:window:set-position', (event, x, y) => {
const drageWindow = getDrageWindow();
if (drageWindow) {
drageWindow.setPosition(x, y)
}
return 'pong'
})
ipcMain.handle('app:window:switch-show-main-window', (event) => {
const mainWindow = getMainWindow();
if (mainWindow && !mainWindow.isDestroyed()) {
if (mainWindow.isVisible()) {
mainWindow.hide();
} else {
mainWindow.show();
}
} else {
createWindow();
}
});
ipcMain.handle('app:window:get-position', (event) => {
const drageWindow = getDrageWindow();
if (drageWindow) {
const [x, y] = drageWindow.getPosition();
return { x, y }
}
return { x: 0, y: 0 }
})
// 获取存储值
ipcMain.handle('getStoreValue', (event, key) => {
return getStoreValue(key)
})
// 设置存储值
ipcMain.handle('setStoreValue', (event, key, value) => {
return setStoreValue(key, value)
})
// 设置存储值
ipcMain.handle('setStoreValueByConfig', (event, key, value) => {
return setStoreValue(key, value)
})
// 关闭配置窗口
ipcMain.on('closeApiConfigWindow', () => {
closeApiConfigWindow()
})
ipcMain.on('closeConfigWindow', () => {
closeConfigWindow()
})
// 添加新的 IPC 监听处理函数
ipcMain.handle('openNewPage', (event, url) => {
const newWindow = new BrowserWindow({
fullscreen: false,
width: 1200,
height: 700,
minWidth: 1200,
minHeight: 700,
webPreferences: {
webSecurity: false, // 禁用 Web 安全
nodeIntegration: true,
contextIsolation: false,
}
});
newWindow.loadURL(url);
// 可选:添加错误处理
newWindow.webContents.on('did-fail-load', (event, errorCode, errorDescription) => {
console.error('页面加载失败:', errorDescription);
});
return 'success';
});
// 添加新的 IPC 监听处理函数
ipcMain.handle('openCSDNAiPage', (event, url) => {
const newWindow = new BrowserWindow({
fullscreen: false,
width: 1600,
height: 900,
webPreferences: {
webSecurity: false, // 禁用 Web 安全
nodeIntegration: false,
contextIsolation: false,
}
});
newWindow.loadURL(url);
// 可选:添加错误处理
newWindow.webContents.on('did-fail-load', (event, errorCode, errorDescription) => {
console.error('页面加载失败:', errorDescription);
});
return 'success';
});
ipcMain.handle('openNewPagebySystemBrowser', (event, url) => {
shell.openExternal(url);
return 'success';
});
// 添加新的 IPC 监听处理函数
ipcMain.handle('updateToNewVersion', async (event) => {
checkForUpdates({},false)
});
}

6
src/main/menu.js Normal file
View File

@@ -0,0 +1,6 @@
import { Menu } from 'electron';
export function createMenu(mainWindow, difyfullScreenWindow) {
// 移除应用菜单
Menu.setApplicationMenu(null)
}

26
src/main/store.js Normal file
View File

@@ -0,0 +1,26 @@
import Store from 'electron-store';
const store = new Store({
defaults: {
showDrageWindow: true // 默认显示悬浮窗口
}
});
export const getStore = () => store;
export const deleteStore = (key) => {
store.delete(key);
};
export const setStoreValue = (key, value) => {
store.set(key, value);
};
export const getStoreValue = (key) => {
return store.get(key);
};
export function clearStore() {
store.clear();
}

186
src/main/tray.js Normal file
View File

@@ -0,0 +1,186 @@
import { Tray, Menu, app, BrowserWindow } from 'electron'
import { join } from 'path'
import icon from '../../resources/icon.png?asset'
import { getMainWindow, createWindow, createApiConfigWindow, createConfigWindow ,getDragWindow} from './window.js'
import { getStoreValue, setStoreValue, clearStore } from './store.js'
import { createDrageWindow, getDrageWindow } from './window.js'
import logger from './utils/logger'
import fs from 'fs'
let tray = null
import {checkForUpdates} from "./utils/updateUtils"
async function clearBrowserCache() {
try {
// 清除所有窗口的浏览器缓存
const windows = BrowserWindow.getAllWindows()
for (const window of windows) {
const session = window.webContents.session
await session.clearStorageData({
storages: [
'appcache',
'cookies',
'filesystem',
'indexdb',
'localstorage',
'shadercache',
'websql',
'serviceworkers',
'cachestorage'
]
})
}
logger.info('浏览器缓存清除成功')
} catch (error) {
logger.error('清除浏览器缓存失败:', error)
}
}
export function createTray() {
// 创建托盘图标
tray = new Tray(icon)
// 设置托盘图标的提示文本
tray.setToolTip('Dify Market Manager')
// 创建右键菜单
const contextMenu = Menu.buildFromTemplate([
{
label: '显示主窗口',
click: () => {
const mainWindow = getMainWindow()
if (mainWindow) {
mainWindow.show()
} else {
createWindow()
}
}
},
{
label: '隐藏主窗口',
click: () => {
const mainWindow = getMainWindow()
if (mainWindow) {
mainWindow.hide()
}
}
},
{ type: 'separator' },
{
label: '配置',
submenu: [
{ type: 'separator' },
{
label: '配置客户端地址',
click: () => {
createConfigWindow()
}
}
]
},
{ type: 'separator' },
{
label: '显示隐藏桌面悬浮',
click: () => {
const drageWindow = getDrageWindow()
if (!drageWindow) {
createDrageWindow()
} else {
if (drageWindow.isVisible()) {
drageWindow.hide()
setStoreValue('showDrageWindow', false)
} else {
drageWindow.show()
setStoreValue('showDrageWindow', true)
}
}
}
},
{ type: 'separator' },
{
label: '检查更新',
click: async (menuItem) => {
checkForUpdates(menuItem,true)
}
},
{ type: 'separator' },
{
label: '清除缓存',
click: async () => {
await clearBrowserCache()
// 删除配置文件
try {
const userDataPath = app.getPath('userData')
const configPath = join(userDataPath, 'config.json')
if (fs.existsSync(configPath)) {
fs.unlinkSync(configPath)
logger.info('配置文件删除成功')
}
} catch (error) {
logger.error('删除配置文件失败:', error)
}
// 重新加载所有窗口
const windows = BrowserWindow.getAllWindows()
for (const window of windows) {
window.reload()
}
}
},
{ type: 'separator' },
{
label: '退出登录',
click: async () => {
await clearBrowserCache()
// 重新加载主窗口
const mainWindow = getMainWindow()
if (mainWindow) {
mainWindow.reload()
}
logger.info('用户已退出登录')
}
},
{ type: 'separator' },
{
label: '退出应用',
click: () => {
app.isQuiting = true
// 确保所有窗口都被关闭
BrowserWindow.getAllWindows().forEach(window => {
window.destroy()
})
app.quit()
}
}
])
// 设置托盘图标的右键菜单
tray.setContextMenu(contextMenu)
// 点击托盘图标时显示/隐藏主窗口
tray.on('click', () => {
const mainWindow = getMainWindow()
if (mainWindow) {
if (mainWindow.isVisible()) {
mainWindow.hide()
} else {
mainWindow.show()
}
} else {
createWindow()
}
})
}
export function destroyTray() {
if (tray) {
tray.destroy()
tray = null
}
}

View File

@@ -0,0 +1,222 @@
import WebSocket from 'ws';
import logger from './logger'
import { getStoreValue } from '../store.js'
import { Notification } from "electron";
class WebSocketClient {
constructor(options = {}) {
this.reconnectInterval = 5000; // 重连间隔时间
this.lockReconnect = false;
this.ws = null;
this.pingTimeout = null;
this.reconnectAttempts = 0;
this.messageHandlers = new Map();
this.isConnected = false;
// 初始化时立即创建连接
this.createConnect();
}
createConnect() {
try {
const apiUrl = getStoreValue("apiUrl");
const userInfo = getStoreValue("userInfo");
const token = getStoreValue("token");
// 检查必要的连接信息是否存在
if (!apiUrl || !userInfo || !token) {
logger.error("WebSocket连接信息不完整等待重试");
logger.error("apiUrl:", apiUrl);
logger.error("userInfo:", userInfo);
logger.error("token:", token);
this.scheduleReconnect();
return;
}
// 处理基础URL
let baseUrl = apiUrl.replace("https://", "wss://").replace("http://", "ws://");
// 移除末尾的斜杠(如果有)
baseUrl = baseUrl.replace(/\/$/, '');
// 构建完整的WebSocket URL
this.url = `${baseUrl}/bqw-ai/websocket/${userInfo.id}`;
// this.url = `${baseUrl}/bqw-ai/${userInfo.id}`;
logger.info("==================== WebSocketClient create WebSocketClient");
logger.info("WebSocket URL: " + this.url);
// 设置WebSocket选项
this.options = {
headers: {
'User-Agent': 'WebSocketClient',
'Connection': 'Upgrade',
'Upgrade': 'websocket',
'Sec-WebSocket-Version': '13'
},
handshakeTimeout: 10000,
perMessageDeflate: false,
followRedirects: true,
rejectUnauthorized: false
};
logger.info("Token:", token); // 添加token日志
// 创建连接
this.connect();
} catch (error) {
logger.error("创建WebSocket连接时发生错误:", error);
this.scheduleReconnect();
}
}
scheduleReconnect() {
if (this.lockReconnect) return;
this.lockReconnect = true;
logger.info("==================== WebSocketClient schedule reconnect");
setTimeout(() => {
this.lockReconnect = false;
this.createConnect(); // 重新获取本地缓存并创建连接
}, this.reconnectInterval);
}
connect() {
logger.info("==================== WebSocketClient begin connect");
if (this.lockReconnect) return;
try {
const token = getStoreValue("token");
// 直接在构造函数中传递协议
this.ws = new WebSocket(this.url, token, this.options);
this.ws.on('open', () => {
logger.info('😀😀😀😀 WebSocket connect create ok 😀😀😀😀');
logger.info('😀😀😀😀 WebSocket connect create ok 😀😀😀😀');
logger.info('😀😀😀😀 WebSocket connect create ok 😀😀😀😀');
logger.info('WebSocket protocol:', this.ws.protocol); // 添加协议日志
this.isConnected = true;
this.reconnectAttempts = 0;
this.lockReconnect = false;
this.startHeartbeat();
this.emit('open');
});
this.ws.on('message', (data) => {
try {
logger.info('收到消息:', data.toString());
const message = JSON.parse(data);
this.handleMessage(message);
} catch (error) {
logger.error('消息解析错误:', error);
}
});
this.ws.on('close', (code, reason) => {
logger.info(`WebSocket连接已关闭代码: ${code}, 原因: ${reason}`);
this.isConnected = false;
this.stopHeartbeat();
this.emit('close', { code, reason });
this.scheduleReconnect();
});
this.ws.on('error', (error) => {
logger.error('WebSocket error:', error);
this.emit('error', error);
this.scheduleReconnect();
});
this.ws.on('unexpected-response', (request, response) => {
logger.info(`收到响应: ${response.statusCode} ${response.statusMessage}`);
logger.info('响应头:', response.headers);
if (response.statusCode === 101) {
logger.info('WebSocket升级成功');
return;
}
this.scheduleReconnect();
});
} catch (error) {
logger.error('WebSocket connect error:', error);
this.scheduleReconnect();
}
}
startHeartbeat() {
this.pingTimeout = setInterval(() => {
if (this.isConnected) {
this.ws.send("heartcheck");
}
}, 30000);
}
stopHeartbeat() {
if (this.pingTimeout) {
clearInterval(this.pingTimeout);
this.pingTimeout = null;
}
}
send(message) {
if (!this.isConnected) {
console.error('WebSocket未连接');
return false;
}
try {
const data = typeof message === 'string' ? message : JSON.stringify(message);
this.ws.send(data);
return true;
} catch (error) {
console.error('发送消息失败:', error);
return false;
}
}
on(event, handler) {
if (!this.messageHandlers.has(event)) {
this.messageHandlers.set(event, new Set());
}
this.messageHandlers.get(event).add(handler);
}
off(event, handler) {
if (this.messageHandlers.has(event)) {
this.messageHandlers.get(event).delete(handler);
}
}
emit(event, data) {
if (this.messageHandlers.has(event)) {
this.messageHandlers.get(event).forEach(handler => {
try {
handler(data);
} catch (error) {
console.error(`事件处理器错误 (${event}):`, error);
}
});
}
}
handleMessage(message) {
if (message.cmd==="Notification") {
logger.info("Notification:", message)
const msg=JSON.parse(message.msgTxt)
// systemMsgType
const isNotification = getStoreValue("Notification_"+msg.systemMsgType);
if (isNotification!=0){
new Notification({ title: msg.title, body: msg.content }).show()
}
}
this.emit('message', message);
}
close() {
if (this.ws) {
this.ws.close();
}
}
}
export default WebSocketClient;

View File

@@ -0,0 +1,16 @@
// 检查路径是否包含 '/api/datasets/' 并以 'documents' 结尾
export function isApiDatasetsDocumentsPath(path) {
const containsApiDatasets = path.includes('/api/datasets/');
const endsWithDocuments = path.endsWith('documents');
return containsApiDatasets && endsWithDocuments;
}
// 提取路径中的 ID 字符串
export function extractIdFromPath(path) {
const regex = /\/api\/datasets\/([^\/]+)\/documents$/;
const match = path.match(regex);
if (match && match[1]) {
return match[1]; // 返回捕获组中的 ID
}
return null; // 如果没有匹配成功,返回 null
}

49
src/main/utils/index.js Normal file
View File

@@ -0,0 +1,49 @@
import * as http from "node:http";
import * as https from "node:https"
import path, { join } from "path";
import fs from "fs"
import { app } from "electron";
export function download(fileUrl, filePath=null) {
if(filePath==null){
const filename = path.basename(new URL(fileUrl).pathname);
const updateDir = join(app.getPath('userData'))
filePath = path.resolve(updateDir, filename);
}
return new Promise((resolve, reject) => {
// 根据 URL 前缀选择不同的下载方式
const protocol = fileUrl.startsWith('https://') ? https :
fileUrl.startsWith('http://') ? http :
null;
if (!protocol) {
reject(new Error('不支持的 URL 协议'));
return;
}
protocol.get(fileUrl, (response) => {
// 检查响应状态码
if (response.statusCode !== 200) {
reject(new Error(`下载失败,状态码: ${response.statusCode}`));
return;
}
const file = fs.createWriteStream(filePath);
response.pipe(file);
file.on('finish', () => {
file.close();
resolve(filePath);
});
file.on('error', (err) => {
fs.unlink(filePath, () => {}); // 删除不完整的文件
reject(err);
});
}).on('error', (err) => {
reject(err);
});
});
}

14
src/main/utils/logger.js Normal file
View File

@@ -0,0 +1,14 @@
import log from 'electron-log/main';
log.initialize();
export const logger = {
log: log.info,
info: log.info,
error: log.error,
warn: log.warn,
debug: log.debug
}
export default logger

View File

@@ -0,0 +1,75 @@
import { autoUpdater} from "electron-updater"
import { dialog} from "electron";
import { getStoreValue } from "../store";
/**
* updater.js
*
* Please use manual update only when it is really required, otherwise please use recommended non-intrusive auto update.
*
* Import steps:
* 1. create `updater.js` for the code snippet
* 2. require `updater.js` for menu implementation, and set `checkForUpdates` callback from `updater` for the click property of `Check Updates...` MenuItem.
*/
let updater
autoUpdater.autoDownload = false
autoUpdater.on('error', (error) => {
dialog.showErrorBox('Error: ', error == null ? "unknown" : (error.stack || error).toString())
})
autoUpdater.on('update-available', () => {
dialog.showMessageBox({
type: 'info',
title: '发现新版本',
message: '发现新版本, 是否需要现在更新?',
buttons: ['立即更新', '取消']
}).then((buttonIndex) => {
if (buttonIndex.response === 0) {
autoUpdater.downloadUpdate()
}
else {
updater.enabled = true
updater = null
}
})
})
autoUpdater.on('update-not-available', () => {
if (updater.toast){
dialog.showMessageBox({
type: 'info',
title: '暂未发现新版本',
message: '当前版本已经是最新的了'
})
}
updater.enabled = true
updater = null
})
autoUpdater.on('update-downloaded', () => {
dialog.showMessageBox({
type: 'info',
title: '安装更新',
message: '新版本已经下载结束, 应用即将退出并重新安装...'
}).then(() => {
setImmediate(() => autoUpdater.quitAndInstall())
})
})
// export this to MenuItem click callback
export function checkForUpdates (menuItem,toast=true) {
if(menuItem!=null){
updater = menuItem
updater.enabled = false
updater.toast = toast
const h5_client_url=getStoreValue("h5_client_url")+"/update_files"
autoUpdater.setFeedURL(h5_client_url)
autoUpdater.checkForUpdates()
}
}

612
src/main/window.js Normal file
View File

@@ -0,0 +1,612 @@
import { BrowserWindow, screen, Menu, shell, session, app, globalShortcut, dialog ,systemPreferences } from 'electron'
import { join } from 'path'
import { is } from '@electron-toolkit/utils'
import icon from '../../resources/icon.png?asset'
import { isApiDatasetsDocumentsPath, extractIdFromPath } from './utils/difyUtils.js'
import XEUtils from 'xe-utils'
import logger from './utils/logger'
import { createMenu } from './menu.js'
import { setStoreValue, getStoreValue,deleteStore } from './store.js'
import {checkForUpdates} from "./utils/updateUtils"
import dayjs from 'dayjs'
let mainWindow = null
let difyfullScreenWindow = null
let drageWindow = null
let apiConfigWindow = null
let configWindow = null
// 权限授权
async function checkMediaAccess(mediaType){
const result = systemPreferences.getMediaAccessStatus(mediaType)
logger.info(`=====================systemPreferences.getMediaAccessStatus:${mediaType} result:${result}`)
if(result !== "granted"){
await systemPreferences.askForMediaAccess(mediaType)
}
}
async function checkAndApplyDeviceAccessPrivilege() {
if (process.platform === "darwin" || process.platform === 'win32') {
// 检查并申请摄像头权限
const cameraPrivilege = systemPreferences.getMediaAccessStatus("camera");
if (cameraPrivilege !== "granted") {
await systemPreferences.askForMediaAccess("camera");
}
// 检查并申请麦克风权限
const micPrivilege = systemPreferences.getMediaAccessStatus("microphone");
if (micPrivilege !== "granted") {
await systemPreferences.askForMediaAccess("microphone");
}
// 检查访问屏幕权限
const screenPrivilege = systemPreferences.getMediaAccessStatus("screen");
if (screenPrivilege !== 'granted') {
// 没有屏幕访问权限,做后续处理...
}
}
}
export async function createWindow() {
// 如果窗口已经存在,直接显示并返回
if (mainWindow) {
mainWindow.show()
return
}
logger.info(`启动主窗口`)
Menu.setApplicationMenu(null)
// Create the browser window.
mainWindow = new BrowserWindow({
width: 420,
height: 900,
show: false,
media: {
audio: true,
video: true
},
icon: icon,
webPreferences: {
contextIsolation: false,
nodeIntegration: true,
nodeIntegrationInWorker: true,
preload: join(__dirname, '../preload/index.js'),
// sandbox: false
}
})
// 创建菜单
createMenu(mainWindow, difyfullScreenWindow)
let code = `localStorage.setItem("IsHsAiApp","IsHsAiApp");localStorage.setItem("HsAppCode",${import.meta.env.VITE_HsAppCode});`
const isAdmin = getStoreValue("isAdmin")
let display='';
await checkAndApplyDeviceAccessPrivilege()
mainWindow.webContents.on('did-finish-load', () => {
mainWindow.webContents
.executeJavaScript(code)
.then((result) => {
})
.catch((error) => {
console.error('Error:', error)
})
})
// 监听快捷键 F12 来打开/关闭 DevTools
mainWindow.webContents.on('before-input-event', (event, input) => {
if (input.key === 'F12') {
mainWindow.webContents.toggleDevTools()
}
})
mainWindow.on('resize',async () => {
// logger.info('窗口大小发生变化...');
// 触发窗口内容重新布局,而不是重新加载
mainWindow.webContents.executeJavaScript(`
if (document.body) {
// 触发窗口重排
window.dispatchEvent(new Event('resize'));
}
`).catch(err => {
console.error('执行布局调整时出错:', err);
});
});
mainWindow.on('ready-to-show', () => {
mainWindow.show()
})
mainWindow.webContents.setWindowOpenHandler((details) => {
shell.openExternal(details.url)
return { action: 'deny' }
})
mainWindow.on('close', (event) => {
if (!app.isQuiting) {
event.preventDefault()
mainWindow.hide()
return false
}
})
// setStoreValue("h5_client_url", "")
// 检查本地存储中是否已有 h5_client_url
const existingH5ClientUrl = getStoreValue("h5_client_url")
if (!existingH5ClientUrl || existingH5ClientUrl.trim() === '') {
// 只有当值不存在或为空时,才设置默认值
// setStoreValue("h5_client_url", "http://work.ii999.live:20040")
// setStoreValue("h5_client_url", "http://10.102.8.56:18900")
// setStoreValue("h5_client_url", "http://68.66.24.160:18900")
setStoreValue("h5_client_url", import.meta.env.VITE_h5_client_url)
}
const h5_client_url=getStoreValue("h5_client_url")+"/h5_client/"
logger.info("==================================== mainWindow.loadURL:"+h5_client_url)
// 加载存储的 URL
mainWindow.loadURL(h5_client_url)
// 超过30分钟不活动则退出登录
await tokenExpireTimer()
setTimeout(()=>{
try {
// 注册全局快捷键
registerShortcuts(mainWindow)
checkForUpdates({},false)
}catch (e) {
logger.info(e)
}
},1500)
session.defaultSession.setPermissionRequestHandler((webContents, permission, callback) => {
if (permission === 'microphone') {
// 用户是否允许使用麦克风
callback(true); // 或者根据实际情况返回false
} else {
// 对于其他权限,拒绝或根据实际情况处理
callback(false);
}
});
}
// 添加一个专门的快捷键注册函数
function registerShortcuts(window) {
// 注册 F5 刷新快捷键
globalShortcut.register('F5', () => {
logger.info('F5 快捷键触发')
if (window && !window.isDestroyed()) {
window.reload()
}
})
const isRegistered_F12 = globalShortcut.isRegistered('F12');
logger.info(`Is CommandOrControl+X registered: ${isRegistered_F12}`);
// 桌面端快要退出的时候,注销快捷键
app.on('will-quit', () => {
globalShortcut.unregisterAll() // 注销所有快捷键
})
}
export async function createNewWindow(url, access_token, refresh_token,sandbox=false) {
const origin_url = url
logger.info('==========createNewWindow')
logger.info('==========createNewWindow sandbox',sandbox)
await checkAndApplyDeviceAccessPrivilege()
difyfullScreenWindow = new BrowserWindow({
width: 1920,
height: 1200,
show: false,
icon: icon,
webPreferences: {
contextIsolation: false,
nodeIntegration: true,
nodeIntegrationInWorker: true,
preload: join(__dirname, '../preload/index.js'),
sandbox: sandbox,
webSecurity: false, // 注意:在生产环境中应谨慎使用
enableRemoteModule: true, // Electron 10+ 默认禁用,需要显式启用
}
})
difyfullScreenWindow.on('ready-to-show', () => {
difyfullScreenWindow.show()
})
let code = `localStorage.setItem("IsHsAiApp","IsHsAiApp");localStorage.setItem("console_token","${access_token}");localStorage.setItem("refresh_token","12");`
const isAdmin = getStoreValue("isAdmin")
const hs_version = getStoreValue("hs_version")
let display='';
if (isAdmin==true){
display = `
(function() {
const stickyDivs = document.querySelectorAll('.sticky.top-0.left-0.right-0.basis-auto.shrink-0');
stickyDivs.forEach(div => {
// div.style.display = 'none';
});
})();
`
}else {
display = `
(function() {
const stickyDivs = document.querySelectorAll('.sticky.top-0.left-0.right-0.basis-auto.shrink-0');
stickyDivs.forEach(div => {
div.style.display = 'none';
});
})();
`
}
code=code+`document.cookie="hs_version=${hs_version}";`
difyfullScreenWindow.webContents.on('did-finish-load', () => {
difyfullScreenWindow.webContents
.executeJavaScript(code + display)
.then((result) => {
})
.catch((error) => {
console.error('Error:', error)
})
let times = 0
let timer = setInterval(() => {
if (times > 3) {
clearInterval(timer)
timer = null
times = 0
return
}
if (difyfullScreenWindow != null) {
difyfullScreenWindow.webContents
.executeJavaScript(code + display)
.then((result) => {
times = times + 1
})
.catch((error) => {
console.error('Error:', error)
})
}
}, 2000)
})
// 监听快捷键 F12 来打开/关闭 DevTools
difyfullScreenWindow.webContents.on('before-input-event', (event, input) => {
if (input.key === 'F12') {
difyfullScreenWindow.webContents.toggleDevTools()
}
})
difyfullScreenWindow.webContents.setWindowOpenHandler((details) => {
shell.openExternal(details.url)
return { action: 'deny' }
})
difyfullScreenWindow.on('closed', () => {
logger.info('主窗口已关闭')
difyfullScreenWindow = null
})
difyfullScreenWindow.webContents.on('did-navigate', (event, url) => {
logger.info('navigate to new URL:', url)
})
session.defaultSession.webRequest.onHeadersReceived((details, callback) => {
callback({
responseHeaders: {
...details.responseHeaders,
'Access-Control-Allow-Origin': ['*'],
'Access-Control-Allow-Methods': ['GET, POST, PUT, DELETE, OPTIONS'],
'Access-Control-Allow-Headers': ['Content-Type, Authorization']
}
})
})
let times = 0
difyfullScreenWindow.webContents.on('did-navigate-in-page', (event, url) => {
logger.info('navigate URL change:', url)
logger.info(`===============current:${access_token}`)
if (url.includes('/signin')) {
logger.info("token 注入失效,重新注入并且加载页面")
if (times>3){
difyfullScreenWindow.close()
difyfullScreenWindow=null
times=0;
return
}
let _display = `
(function() {
const stickyDivs = document.querySelectorAll('body');
stickyDivs.forEach(div => {
div.style.display = 'none';
});
})();
`
difyfullScreenWindow.webContents
.executeJavaScript(code + _display)
.then((result) => {
logger.info('load url:', origin_url)
setTimeout(()=>{
times=times+1;
difyfullScreenWindow.loadURL(origin_url)
},1000)
})
.catch((error) => {
console.error('Error:', error)
})
}
})
let dify_site = 'http://df.1024web.cn'
const filter = { urls: [`${dify_site}/*`] }
session.defaultSession.webRequest.onBeforeRequest(filter, (details, callback) => {
if (isApiDatasetsDocumentsPath(details.url)) {
logger.info('========== onBeforeRequest url:', details.url)
logger.info('============datasetId :', extractIdFromPath(details.url))
logger.info(details)
const url = new URL(details.url)
const pathAndQuery = url.pathname + url.search
const redirectURL = `http://192.168.50.22:8001/items/`
logger.info(`[basehttp:setProxy] redirectURL = ${redirectURL}`)
callback({ redirectURL })
} else {
callback({ cancel: false })
}
})
difyfullScreenWindow.on('resize', () => {
logger.info('窗口大小发生变化,重新加载页面...');
if (difyfullScreenWindow!=null){
difyfullScreenWindow.webContents.executeJavaScript(`
if (document.body) {
// 触发窗口重排
window.dispatchEvent(new Event('resize'));
}
`).catch(err => {
console.error('执行布局调整时出错:', err);
});
}
// 触发窗口内容重新布局,而不是重新加载
});
difyfullScreenWindow.loadURL(url)
}
export function createDrageWindow() {
logger.info('开始创建悬浮窗口')
if (drageWindow) {
drageWindow.focus()
return
}
drageWindow = new BrowserWindow({
width: 120,
height: 120,
frame: false,
show: true,
skipTaskbar: true,
transparent: true,
resizable: false,
alwaysOnTop: true,
autoHideMenuBar: true,
webPreferences: {
contextIsolation: false,
nodeIntegration: true,
nodeIntegrationInWorker: true,
preload: join(__dirname, '../preload/index.js')
}
})
drageWindow.setAlwaysOnTop(true, 'screen-saver')
drageWindow.on('ready-to-show', () => {
drageWindow.show()
})
drageWindow.webContents.setWindowOpenHandler((details) => {
shell.openExternal(details.url)
return { action: 'deny' }
})
drageWindow.on('close', (event) => {
if (!app.isQuiting) {
event.preventDefault()
drageWindow.hide()
return false
}
})
const h5_client_url=getStoreValue("h5_client_url")+"/electron_h5/"
logger.log("======================== drageWindow :")
logger.log(h5_client_url)
drageWindow.loadURL(h5_client_url)
const { width: screenWidth, height: screenHeight } = screen.getPrimaryDisplay().workAreaSize
drageWindow.setPosition(screenWidth - drageWindow.getSize()[0] -100, screenHeight - drageWindow.getSize()[1] - 100)
}
export async function tokenExpireTimer(){
const tokenExpireTimer = setInterval(async () => {
logger.info("tokenExpireTimer 触发")
const lastActiveTime = getStoreValue("lastActiveTime")||null
if (lastActiveTime!=null){
logger.info("tokenExpireTimer 触发 对比时间戳")
try {
const nowTime=dayjs();
const lastTime=dayjs(lastActiveTime);
const diff=nowTime.diff(lastTime, 'minute')
logger.info("tokenExpireTimer 触发 对比时间戳差距为:"+diff)
if ( diff> 30) {
deleteStore("lastActiveTime")
try {
// 清除所有窗口的浏览器缓存
const windows = BrowserWindow.getAllWindows()
for (const window of windows) {
const session = window.webContents.session
await session.clearStorageData({
storages: [
'appcache',
'cookies',
'filesystem',
'indexdb',
'localstorage',
'shadercache',
'websql',
'serviceworkers',
'cachestorage'
]
})
}
logger.info('浏览器缓存清除成功')
} catch (error) {
logger.error('清除浏览器缓存失败:', error)
}
if (mainWindow) {
mainWindow.reload()
}
logger.info('用户已退出登录')
}
} catch (e) {
}
}
}, 1000 * 10)
}
export function getMainWindow() {
if (!mainWindow || mainWindow.isDestroyed()) {
return null
}
return mainWindow
}
export function getDragWindow() {
if (!drageWindow || drageWindow.isDestroyed()) {
return null
}
return drageWindow
}
export function getDifyFullScreenWindow() {
return difyfullScreenWindow;
}
export function getDrageWindow() {
return drageWindow;
}
// 在应用退出时注销所有快捷键
export function unregisterAllShortcuts() {
globalShortcut.unregisterAll()
}
export function closeApiConfigWindow() {
if (apiConfigWindow) {
apiConfigWindow.close()
apiConfigWindow = null
}
}
export function createConfigWindow() {
if (configWindow) {
configWindow.focus()
return
}
configWindow = new BrowserWindow({
width: 600,
height: 400,
resizable: false,
minimizable: false,
maximizable: false,
parent: getMainWindow(),
modal: true,
webPreferences: {
contextIsolation: false,
nodeIntegration: true,
nodeIntegrationInWorker: true,
preload: join(__dirname, '../preload/index.js')
},
permissions: {
microphone: 'allow'
}
})
const h5_client_url=getStoreValue("h5_client_url")+"/electron_h5/#/config"
logger.info("======================== configWindow 11111111111:")
logger.info(h5_client_url)
// configWindow.loadURL(h5_client_url)
if (is.dev && process.env['ELECTRON_RENDERER_URL']) {
configWindow.loadURL(process.env['ELECTRON_RENDERER_URL'] + '/#/config')
} else {
configWindow.loadFile(join(__dirname, '../renderer/index.html'), { hash: '/config' })
}
//
configWindow.on('closed', () => {
configWindow = null
})
}
// 添加关闭配置窗口的方法
export function closeConfigWindow() {
if (configWindow) {
configWindow.close()
configWindow = null
}
}

27
src/preload/index.js Normal file
View File

@@ -0,0 +1,27 @@
import { contextBridge , ipcRenderer} from 'electron'
import { electronAPI } from '@electron-toolkit/preload'
// Custom APIs for renderer
const api = {}
// Use `contextBridge` APIs to expose Electron APIs to
// renderer only if context isolation is enabled, otherwise
// just add to the DOM global.
if (process.contextIsolated) {
try {
contextBridge.exposeInMainWorld('electron', electronAPI)
contextBridge.exposeInMainWorld('api', api)
ipcRenderer.on('data-from-main', (event, key,value) => {
localStorage.setItem(key, value);
});
} catch (error) {
console.error(error)
}
} else {
window.electron = electronAPI
window.api = api
}

24
src/renderer/index.html Normal file
View File

@@ -0,0 +1,24 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>Dify Market Manager</title>
<!-- https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP -->
<meta
http-equiv="Content-Security-Policy"
content="default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data:"
/>
<style>
*{
margin: 0;
padding: 0;
background-color: rgba(0,0,0,0);
}
</style>
</head>
<body>
<div id="app"></div>
<script type="module" src="./src/main.js"></script>
</body>
</html>

216
src/renderer/src/App.vue Normal file
View File

@@ -0,0 +1,216 @@
<template>
<div class="mini-window"
@dblclick="handleDoubleClick"
@mousedown="handleMouseDown"
@mouseenter="handleMouseEnter"
@mouseleave="handleMouseLeave">
<!-- 折叠状态 -->
<div class="mini-content">
<span class="mini-bg">
</span>
</div>
</div>
</template>
<script setup>
import { ref, onMounted } from 'vue'
let ipcRenderService=null
try {
ipcRenderService= window.electron.ipcRenderer
}catch (e){
}
const isExpanded = ref(false)
let isDragging = false
let initialMouseX = 0
let initialMouseY = 0
let mouseDownTime = 0
let windowInitialX = 0
let windowInitialY = 0
const isFlashing = ref(false)
const handleDoubleClick=(e)=>{
console.log("双击事件")
ipcRenderService.invoke('app:window:switch-show-main-window').then(() => {
})
}
// 处理鼠标按下事件
const handleMouseDown = (e) => {
// if (isExpanded.value) return // 展开状态不允许拖动
// isDragging = false
initialMouseX = e.screenX // 使用screenX/screenY获取相对于屏幕的坐标
initialMouseY = e.screenY
mouseDownTime = Date.now()
document.addEventListener('mousemove', handleMouseMove)
document.addEventListener('mouseup', handleMouseUp)
// 获取窗口初始位置
ipcRenderService.invoke('app:window:get-position').then((postion) => {
console.log("app:window:get-position")
console.log(postion.x)
console.log(postion.y)
windowInitialX = postion.x
windowInitialY = postion.y
})
}
// 处理鼠标移动事件
const handleMouseMove = (e) => {
const deltaX = e.screenX - initialMouseX
const deltaY = e.screenY - initialMouseY
// 判断是否达到拖动阈值
if (!isDragging && (Math.abs(deltaX) > 5 || Math.abs(deltaY) > 5)) {
isDragging = true
}
if (isDragging) {
// 计算新位置
const newX = windowInitialX + deltaX
const newY = windowInitialY + deltaY
console.log("发送位置:",newX)
console.log("发送位置:",newY)
// 发送新位置到主进程
window.electron.ipcRenderer.send('ping', newX, newY)
window.electron.ipcRenderer.send('app:window:set-position', newX, newY )
}
}
const handleMouseUp = () => {
document.removeEventListener('mousemove', handleMouseMove)
document.removeEventListener('mouseup', handleMouseUp)
// 如果不是拖拽且点击时间小于200ms则触发展开/收起
// if (!isDragging && (Date.now() - mouseDownTime < 200)) {
// toggleExpand()
// }
}
const handleMouseEnter = () => {
// 每次进入都触发闪烁
// isFlashing.value = true
//
// // 300ms 后移除闪烁效果
// setTimeout(() => {
// isFlashing.value = false
// }, 300)
ipcRenderService.send('app:window:mouse-enter')
}
const handleMouseLeave = () => {
// 确保离开时重置闪烁状态
isFlashing.value = false
ipcRenderService.send('app:window:mouse-leave')
}
const toggleExpand = () => {
isExpanded.value = !isExpanded.value
}
const handleAction = (action) => {
switch (action) {
case 'restore':
ipcRenderService.send('app:window:restore-main')
break
case 'dashboard':
ipcRenderService.send('app:window:restore-main', { route: 'INDEX' })
break
case 'settings':
ipcRenderService.send('app:window:restore-main', { route: 'SETTINGS' })
break
}
isExpanded.value = false
}
// 监听主进程发来的事件
onMounted(() => {
ipcRenderService.on('app:window:mouse-enter', () => {
// 可以在这里处理鼠标进入事件
})
ipcRenderService.on('app:window:mouse-leave', () => {
// 可以在这里处理鼠标离开事件
})
})
</script>
<style>
.mini-window {
width: 120px;
height: 120px;
border-radius: 25px;
background: rgba(0,0,0,0);
transition: all 0.3s ease;
overflow: hidden;
user-select: none;
background-image: url("./assets/lxi_120.png");
background-size: contain;
background-repeat: no-repeat;
background-position: center;
}
.mini-window.expanded .mini-content {
width: 100%;
height: 100%;
opacity: 0;
pointer-events: none;
}
.mini-window .mini-content {
position: absolute;
bottom: 1px;
right: 5px;
opacity: 1;
transition: opacity 0.3s;
}
.mini-window .mini-content .mini-bg {
cursor: pointer;
display: inline-block;
width: 120px;
height: 120px;
border-radius: 20px;
}
.mini-window .expanded-content .actions .action-item .el-icon {
font-size: 18px;
}
.mini-window .expanded-content .actions .action-item span {
font-size: 14px;
}
@keyframes flash {
0% {
opacity: 1;
}
50% {
opacity: 0;
}
100% {
opacity: 1;
}
}
</style>

View File

@@ -0,0 +1,21 @@
<template>
<div class="main-app">
<router-view></router-view>
</div>
</template>
<script setup>
// 这里可以添加全局的逻辑
</script>
<style>
*{
margin: 0;
padding: 0;
overflow: hidden;
}
.main-app {
width: 100%;
height: 100%;
}
</style>

View File

@@ -0,0 +1,86 @@
/* color palette from <https://github.com/vuejs/theme> */
:root {
--vt-c-white: #ffffff;
--vt-c-white-soft: #f8f8f8;
--vt-c-white-mute: #f2f2f2;
--vt-c-black: #181818;
--vt-c-black-soft: #222222;
--vt-c-black-mute: #282828;
--vt-c-indigo: #2c3e50;
--vt-c-divider-light-1: rgba(60, 60, 60, 0.29);
--vt-c-divider-light-2: rgba(60, 60, 60, 0.12);
--vt-c-divider-dark-1: rgba(84, 84, 84, 0.65);
--vt-c-divider-dark-2: rgba(84, 84, 84, 0.48);
--vt-c-text-light-1: var(--vt-c-indigo);
--vt-c-text-light-2: rgba(60, 60, 60, 0.66);
--vt-c-text-dark-1: var(--vt-c-white);
--vt-c-text-dark-2: rgba(235, 235, 235, 0.64);
}
/* semantic color variables for this project */
:root {
--color-background: var(--vt-c-white);
--color-background-soft: var(--vt-c-white-soft);
--color-background-mute: var(--vt-c-white-mute);
--color-border: var(--vt-c-divider-light-2);
--color-border-hover: var(--vt-c-divider-light-1);
--color-heading: var(--vt-c-text-light-1);
--color-text: var(--vt-c-text-light-1);
--section-gap: 160px;
}
@media (prefers-color-scheme: dark) {
:root {
--color-background: var(--vt-c-black);
--color-background-soft: var(--vt-c-black-soft);
--color-background-mute: var(--vt-c-black-mute);
--color-border: var(--vt-c-divider-dark-2);
--color-border-hover: var(--vt-c-divider-dark-1);
--color-heading: var(--vt-c-text-dark-1);
--color-text: var(--vt-c-text-dark-2);
}
}
*,
*::before,
*::after {
box-sizing: border-box;
margin: 0;
font-weight: normal;
}
body {
min-height: 100vh;
color: var(--color-text);
background: var(--color-background);
transition:
color 0.5s,
background-color 0.5s;
line-height: 1.6;
font-family:
Inter,
-apple-system,
BlinkMacSystemFont,
'Segoe UI',
Roboto,
Oxygen,
Ubuntu,
Cantarell,
'Fira Sans',
'Droid Sans',
'Helvetica Neue',
sans-serif;
font-size: 15px;
text-rendering: optimizeLegibility;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}

View File

@@ -0,0 +1,10 @@
<svg viewBox="0 0 128 128" fill="none" xmlns="http://www.w3.org/2000/svg">
<circle cx="64" cy="64" r="64" fill="#2F3242"/>
<ellipse cx="63.9835" cy="23.2036" rx="4.48794" ry="4.495" stroke="#A2ECFB" stroke-width="3.6" stroke-linecap="round"/>
<path d="M51.3954 39.5028C52.3733 39.6812 53.3108 39.033 53.4892 38.055C53.6676 37.0771 53.0194 36.1396 52.0414 35.9612L51.3954 39.5028ZM28.6153 43.5751L30.1748 44.4741L30.1748 44.4741L28.6153 43.5751ZM28.9393 60.9358C29.4332 61.7985 30.5329 62.0976 31.3957 61.6037C32.2585 61.1098 32.5575 60.0101 32.0636 59.1473L28.9393 60.9358ZM37.6935 66.7457C37.025 66.01 35.8866 65.9554 35.1508 66.6239C34.415 67.2924 34.3605 68.4308 35.029 69.1666L37.6935 66.7457ZM53.7489 81.7014L52.8478 83.2597L53.7489 81.7014ZM96.9206 89.515C97.7416 88.9544 97.9526 87.8344 97.3919 87.0135C96.8313 86.1925 95.7113 85.9815 94.8904 86.5422L96.9206 89.515ZM52.0414 35.9612C46.4712 34.9451 41.2848 34.8966 36.9738 35.9376C32.6548 36.9806 29.0841 39.1576 27.0559 42.6762L30.1748 44.4741C31.5693 42.0549 34.1448 40.3243 37.8188 39.4371C41.5009 38.5479 46.1547 38.5468 51.3954 39.5028L52.0414 35.9612ZM27.0559 42.6762C24.043 47.9029 25.2781 54.5399 28.9393 60.9358L32.0636 59.1473C28.6579 53.1977 28.1088 48.0581 30.1748 44.4741L27.0559 42.6762ZM35.029 69.1666C39.6385 74.24 45.7158 79.1355 52.8478 83.2597L54.6499 80.1432C47.8081 76.1868 42.0298 71.5185 37.6935 66.7457L35.029 69.1666ZM52.8478 83.2597C61.344 88.1726 70.0465 91.2445 77.7351 92.3608C85.359 93.4677 92.2744 92.6881 96.9206 89.515L94.8904 86.5422C91.3255 88.9767 85.4902 89.849 78.2524 88.7982C71.0793 87.7567 62.809 84.8612 54.6499 80.1432L52.8478 83.2597ZM105.359 84.9077C105.359 81.4337 102.546 78.6127 99.071 78.6127V82.2127C100.553 82.2127 101.759 83.4166 101.759 84.9077H105.359ZM99.071 78.6127C95.5956 78.6127 92.7831 81.4337 92.7831 84.9077H96.3831C96.3831 83.4166 97.5892 82.2127 99.071 82.2127V78.6127ZM92.7831 84.9077C92.7831 88.3817 95.5956 91.2027 99.071 91.2027V87.6027C97.5892 87.6027 96.3831 86.3988 96.3831 84.9077H92.7831ZM99.071 91.2027C102.546 91.2027 105.359 88.3817 105.359 84.9077H101.759C101.759 86.3988 100.553 87.6027 99.071 87.6027V91.2027Z" fill="#A2ECFB"/>
<path d="M91.4873 65.382C90.8456 66.1412 90.9409 67.2769 91.7002 67.9186C92.4594 68.5603 93.5951 68.465 94.2368 67.7058L91.4873 65.382ZM99.3169 43.6354L97.7574 44.5344L99.3169 43.6354ZM84.507 35.2412C83.513 35.2282 82.6967 36.0236 82.6838 37.0176C82.6708 38.0116 83.4661 38.8279 84.4602 38.8409L84.507 35.2412ZM74.9407 39.8801C75.9127 39.6716 76.5315 38.7145 76.323 37.7425C76.1144 36.7706 75.1573 36.1517 74.1854 36.3603L74.9407 39.8801ZM53.7836 46.3728L54.6847 47.931L53.7836 46.3728ZM25.5491 80.9047C25.6932 81.8883 26.6074 82.5688 27.5911 82.4247C28.5747 82.2806 29.2552 81.3664 29.1111 80.3828L25.5491 80.9047ZM94.2368 67.7058C97.8838 63.3907 100.505 58.927 101.752 54.678C103.001 50.4213 102.9 46.2472 100.876 42.7365L97.7574 44.5344C99.1494 46.9491 99.3603 50.0419 98.2974 53.6644C97.2323 57.2945 94.9184 61.3223 91.4873 65.382L94.2368 67.7058ZM100.876 42.7365C97.9119 37.5938 91.7082 35.335 84.507 35.2412L84.4602 38.8409C91.1328 38.9278 95.7262 41.0106 97.7574 44.5344L100.876 42.7365ZM74.1854 36.3603C67.4362 37.8086 60.0878 40.648 52.8826 44.8146L54.6847 47.931C61.5972 43.9338 68.5948 41.2419 74.9407 39.8801L74.1854 36.3603ZM52.8826 44.8146C44.1366 49.872 36.9669 56.0954 32.1491 62.3927C27.3774 68.63 24.7148 75.2115 25.5491 80.9047L29.1111 80.3828C28.4839 76.1026 30.4747 70.5062 35.0084 64.5802C39.496 58.7143 46.2839 52.7889 54.6847 47.931L52.8826 44.8146Z" fill="#A2ECFB"/>
<path d="M49.0825 87.2295C48.7478 86.2934 47.7176 85.8059 46.7816 86.1406C45.8455 86.4753 45.358 87.5055 45.6927 88.4416L49.0825 87.2295ZM78.5635 96.4256C79.075 95.5732 78.7988 94.4675 77.9464 93.9559C77.0941 93.4443 75.9884 93.7205 75.4768 94.5729L78.5635 96.4256ZM79.5703 85.1795C79.2738 86.1284 79.8027 87.1379 80.7516 87.4344C81.7004 87.7308 82.71 87.2019 83.0064 86.2531L79.5703 85.1795ZM84.3832 64.0673H82.5832H84.3832ZM69.156 22.5301C68.2477 22.1261 67.1838 22.535 66.7799 23.4433C66.3759 24.3517 66.7848 25.4155 67.6931 25.8194L69.156 22.5301ZM45.6927 88.4416C47.5994 93.7741 50.1496 98.2905 53.2032 101.505C56.2623 104.724 59.9279 106.731 63.9835 106.731V103.131C61.1984 103.131 58.4165 101.765 55.8131 99.0249C53.2042 96.279 50.8768 92.2477 49.0825 87.2295L45.6927 88.4416ZM63.9835 106.731C69.8694 106.731 74.8921 102.542 78.5635 96.4256L75.4768 94.5729C72.0781 100.235 68.0122 103.131 63.9835 103.131V106.731ZM83.0064 86.2531C85.0269 79.7864 86.1832 72.1831 86.1832 64.0673H82.5832C82.5832 71.8536 81.4723 79.0919 79.5703 85.1795L83.0064 86.2531ZM86.1832 64.0673C86.1832 54.1144 84.4439 44.922 81.4961 37.6502C78.5748 30.4436 74.3436 24.8371 69.156 22.5301L67.6931 25.8194C71.6364 27.5731 75.3846 32.1564 78.1598 39.0026C80.9086 45.7836 82.5832 54.507 82.5832 64.0673H86.1832Z" fill="#A2ECFB"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M103.559 84.9077C103.559 82.4252 101.55 80.4127 99.071 80.4127C96.5924 80.4127 94.5831 82.4252 94.5831 84.9077C94.5831 87.3902 96.5924 89.4027 99.071 89.4027C101.55 89.4027 103.559 87.3902 103.559 84.9077V84.9077Z" stroke="#A2ECFB" stroke-width="3.6" stroke-linecap="round"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M28.8143 89.4027C31.2929 89.4027 33.3023 87.3902 33.3023 84.9077C33.3023 82.4252 31.2929 80.4127 28.8143 80.4127C26.3357 80.4127 24.3264 82.4252 24.3264 84.9077C24.3264 87.3902 26.3357 89.4027 28.8143 89.4027V89.4027V89.4027Z" stroke="#A2ECFB" stroke-width="3.6" stroke-linecap="round"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M64.8501 68.0857C62.6341 68.5652 60.451 67.1547 59.9713 64.9353C59.4934 62.7159 60.9007 60.5293 63.1167 60.0489C65.3326 59.5693 67.5157 60.9798 67.9954 63.1992C68.4742 65.4186 67.066 67.6052 64.8501 68.0857Z" fill="#A2ECFB"/>
</svg>

After

Width:  |  Height:  |  Size: 5.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 66 KiB

View File

@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 261.76 226.69"><path d="M161.096.001l-30.225 52.351L100.647.001H-.005l130.877 226.688L261.749.001z" fill="#41b883"/><path d="M161.096.001l-30.225 52.351L100.647.001H52.346l78.526 136.01L209.398.001z" fill="#34495e"/></svg>

After

Width:  |  Height:  |  Size: 276 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

View File

@@ -0,0 +1,35 @@
@import './base.css';
#app {
max-width: 1280px;
margin: 0 auto;
padding: 2rem;
font-weight: normal;
}
a,
.green {
text-decoration: none;
color: hsla(160, 100%, 37%, 1);
transition: 0.4s;
padding: 3px;
}
@media (hover: hover) {
a:hover {
background-color: hsla(160, 100%, 37%, 0.2);
}
}
@media (min-width: 1024px) {
body {
display: flex;
place-items: center;
}
#app {
display: grid;
grid-template-columns: 1fr 1fr;
padding: 0 2rem;
}
}

View File

@@ -0,0 +1,25 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1422 800" opacity="0.3">
<defs>
<linearGradient x1="50%" y1="0%" x2="50%" y2="100%" id="oooscillate-grad">
<stop stop-color="hsl(206, 75%, 49%)" stop-opacity="1" offset="0%"></stop>
<stop stop-color="hsl(331, 90%, 56%)" stop-opacity="1" offset="100%"></stop>
</linearGradient>
</defs>
<g stroke-width="1" stroke="url(#oooscillate-grad)" fill="none" stroke-linecap="round">
<path d="M 0 448 Q 355.5 -100 711 400 Q 1066.5 900 1422 448" opacity="0.05"></path>
<path d="M 0 420 Q 355.5 -100 711 400 Q 1066.5 900 1422 420" opacity="0.11"></path>
<path d="M 0 392 Q 355.5 -100 711 400 Q 1066.5 900 1422 392" opacity="0.18"></path>
<path d="M 0 364 Q 355.5 -100 711 400 Q 1066.5 900 1422 364" opacity="0.24"></path>
<path d="M 0 336 Q 355.5 -100 711 400 Q 1066.5 900 1422 336" opacity="0.30"></path>
<path d="M 0 308 Q 355.5 -100 711 400 Q 1066.5 900 1422 308" opacity="0.37"></path>
<path d="M 0 280 Q 355.5 -100 711 400 Q 1066.5 900 1422 280" opacity="0.43"></path>
<path d="M 0 252 Q 355.5 -100 711 400 Q 1066.5 900 1422 252" opacity="0.49"></path>
<path d="M 0 224 Q 355.5 -100 711 400 Q 1066.5 900 1422 224" opacity="0.56"></path>
<path d="M 0 196 Q 355.5 -100 711 400 Q 1066.5 900 1422 196" opacity="0.62"></path>
<path d="M 0 168 Q 355.5 -100 711 400 Q 1066.5 900 1422 168" opacity="0.68"></path>
<path d="M 0 140 Q 355.5 -100 711 400 Q 1066.5 900 1422 140" opacity="0.75"></path>
<path d="M 0 112 Q 355.5 -100 711 400 Q 1066.5 900 1422 112" opacity="0.81"></path>
<path d="M 0 84 Q 355.5 -100 711 400 Q 1066.5 900 1422 84" opacity="0.87"></path>
<path d="M 0 56 Q 355.5 -100 711 400 Q 1066.5 900 1422 56" opacity="0.94"></path>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

@@ -0,0 +1,103 @@
<template>
<div class="api-config">
<h2>系统配置</h2>
<div class="form-item">
<label>客户端地址</label>
<input
type="text"
v-model="h5ClientUrl"
placeholder="请输入客户端访问地址"
>
<div class="hint">例如http://10.102.8.56:18900</div>
</div>
<div class="button-group">
<button @click="saveConfig">保存</button>
</div>
</div>
</template>
<script setup>
import { ref, onMounted } from 'vue'
const h5ClientUrl = ref('')
onMounted(async () => {
// 从本地存储获取现有配置
h5ClientUrl.value = await window.electron.ipcRenderer.invoke('getStoreValue', 'h5_client_url') || ''
})
const saveConfig = async () => {
try {
await window.electron.ipcRenderer.invoke('setStoreValue', 'h5_client_url', h5ClientUrl.value)
alert('保存成功')
// 关闭当前窗口
window.electron.ipcRenderer.send('closeConfigWindow')
} catch (error) {
alert('保存失败:' + error.message)
}
}
</script>
<style scoped>
.api-config {
padding: 20px;
font-family: Arial, sans-serif;
}
h2 {
margin-bottom: 20px;
color: #333;
text-align: center;
}
.form-item {
margin-bottom: 20px;
}
label {
display: block;
margin-bottom: 8px;
font-weight: bold;
color: #666;
}
input {
width: 400px;
padding: 8px;
border: 1px solid #ddd;
border-radius: 4px;
font-size: 14px;
}
input:focus {
outline: none;
border-color: #4CAF50;
box-shadow: 0 0 5px rgba(76, 175, 80, 0.2);
}
.hint {
margin-top: 5px;
font-size: 12px;
color: #999;
}
.button-group {
margin-top: 30px;
text-align: right;
}
button {
padding: 8px 20px;
background-color: #4CAF50;
color: white;
border: none;
border-radius: 4px;
cursor: pointer;
font-size: 14px;
transition: background-color 0.3s;
}
button:hover {
background-color: #45a049;
}
</style>

View File

@@ -0,0 +1,44 @@
<script setup>
defineProps({
msg: {
type: String,
required: true,
},
})
</script>
<template>
<div class="greetings">
<h1 class="green">{{ msg }}</h1>
<h3>
Youve successfully created a project with
<a href="https://vite.dev/" target="_blank" rel="noopener">Vite</a> +
<a href="https://vuejs.org/" target="_blank" rel="noopener">Vue 3</a>.
</h3>
</div>
</template>
<style scoped>
h1 {
font-weight: 500;
font-size: 2.6rem;
position: relative;
top: -10px;
}
h3 {
font-size: 1.2rem;
}
.greetings h1,
.greetings h3 {
text-align: center;
}
@media (min-width: 1024px) {
.greetings h1,
.greetings h3 {
text-align: left;
}
}
</style>

View File

@@ -0,0 +1,94 @@
<script setup>
import WelcomeItem from './WelcomeItem.vue'
import DocumentationIcon from './icons/IconDocumentation.vue'
import ToolingIcon from './icons/IconTooling.vue'
import EcosystemIcon from './icons/IconEcosystem.vue'
import CommunityIcon from './icons/IconCommunity.vue'
import SupportIcon from './icons/IconSupport.vue'
const openReadmeInEditor = () => fetch('/__open-in-editor?file=README.md')
</script>
<template>
<WelcomeItem>
<template #icon>
<DocumentationIcon />
</template>
<template #heading>Documentation</template>
Vues
<a href="https://vuejs.org/" target="_blank" rel="noopener">official documentation</a>
provides you with all information you need to get started.
</WelcomeItem>
<WelcomeItem>
<template #icon>
<ToolingIcon />
</template>
<template #heading>Tooling</template>
This project is served and bundled with
<a href="https://vite.dev/guide/features.html" target="_blank" rel="noopener">Vite</a>. The
recommended IDE setup is
<a href="https://code.visualstudio.com/" target="_blank" rel="noopener">VSCode</a>
+
<a href="https://github.com/vuejs/language-tools" target="_blank" rel="noopener">Vue - Official</a>. If
you need to test your components and web pages, check out
<a href="https://vitest.dev/" target="_blank" rel="noopener">Vitest</a>
and
<a href="https://www.cypress.io/" target="_blank" rel="noopener">Cypress</a>
/
<a href="https://playwright.dev/" target="_blank" rel="noopener">Playwright</a>.
<br />
More instructions are available in
<a href="javascript:void(0)" @click="openReadmeInEditor"><code>README.md</code></a
>.
</WelcomeItem>
<WelcomeItem>
<template #icon>
<EcosystemIcon />
</template>
<template #heading>Ecosystem</template>
Get official tools and libraries for your project:
<a href="https://pinia.vuejs.org/" target="_blank" rel="noopener">Pinia</a>,
<a href="https://router.vuejs.org/" target="_blank" rel="noopener">Vue Router</a>,
<a href="https://test-utils.vuejs.org/" target="_blank" rel="noopener">Vue Test Utils</a>, and
<a href="https://github.com/vuejs/devtools" target="_blank" rel="noopener">Vue Dev Tools</a>. If
you need more resources, we suggest paying
<a href="https://github.com/vuejs/awesome-vue" target="_blank" rel="noopener">Awesome Vue</a>
a visit.
</WelcomeItem>
<WelcomeItem>
<template #icon>
<CommunityIcon />
</template>
<template #heading>Community</template>
Got stuck? Ask your question on
<a href="https://chat.vuejs.org" target="_blank" rel="noopener">Vue Land</a>
(our official Discord server), or
<a href="https://stackoverflow.com/questions/tagged/vue.js" target="_blank" rel="noopener"
>StackOverflow</a
>. You should also follow the official
<a href="https://bsky.app/profile/vuejs.org" target="_blank" rel="noopener">@vuejs.org</a>
Bluesky account or the
<a href="https://x.com/vuejs" target="_blank" rel="noopener">@vuejs</a>
X account for latest news in the Vue world.
</WelcomeItem>
<WelcomeItem>
<template #icon>
<SupportIcon />
</template>
<template #heading>Support Vue</template>
As an independent project, Vue relies on community backing for its sustainability. You can help
us by
<a href="https://vuejs.org/sponsor/" target="_blank" rel="noopener">becoming a sponsor</a>.
</WelcomeItem>
</template>

View File

@@ -0,0 +1,13 @@
<script setup>
import { reactive } from 'vue'
const versions = reactive({ ...window.electron.process.versions })
</script>
<template>
<ul class="versions">
<li class="electron-version">Electron v{{ versions.electron }}</li>
<li class="chrome-version">Chromium v{{ versions.chrome }}</li>
<li class="node-version">Node v{{ versions.node }}</li>
</ul>
</template>

View File

@@ -0,0 +1,87 @@
<template>
<div class="item">
<i>
<slot name="icon"></slot>
</i>
<div class="details">
<h3>
<slot name="heading"></slot>
</h3>
<slot></slot>
</div>
</div>
</template>
<style scoped>
.item {
margin-top: 2rem;
display: flex;
position: relative;
}
.details {
flex: 1;
margin-left: 1rem;
}
i {
display: flex;
place-items: center;
place-content: center;
width: 32px;
height: 32px;
color: var(--color-text);
}
h3 {
font-size: 1.2rem;
font-weight: 500;
margin-bottom: 0.4rem;
color: var(--color-heading);
}
@media (min-width: 1024px) {
.item {
margin-top: 0;
padding: 0.4rem 0 1rem calc(var(--section-gap) / 2);
}
i {
top: calc(50% - 25px);
left: -26px;
position: absolute;
border: 1px solid var(--color-border);
background: var(--color-background);
border-radius: 8px;
width: 50px;
height: 50px;
}
.item:before {
content: ' ';
border-left: 1px solid var(--color-border);
position: absolute;
left: 0;
bottom: calc(50% + 25px);
height: calc(50% - 25px);
}
.item:after {
content: ' ';
border-left: 1px solid var(--color-border);
position: absolute;
left: 0;
top: calc(50% + 25px);
height: calc(50% - 25px);
}
.item:first-of-type:before {
display: none;
}
.item:last-of-type:after {
display: none;
}
}
</style>

View File

@@ -0,0 +1,7 @@
<template>
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" fill="currentColor">
<path
d="M15 4a1 1 0 1 0 0 2V4zm0 11v-1a1 1 0 0 0-1 1h1zm0 4l-.707.707A1 1 0 0 0 16 19h-1zm-4-4l.707-.707A1 1 0 0 0 11 14v1zm-4.707-1.293a1 1 0 0 0-1.414 1.414l1.414-1.414zm-.707.707l-.707-.707.707.707zM9 11v-1a1 1 0 0 0-.707.293L9 11zm-4 0h1a1 1 0 0 0-1-1v1zm0 4H4a1 1 0 0 0 1.707.707L5 15zm10-9h2V4h-2v2zm2 0a1 1 0 0 1 1 1h2a3 3 0 0 0-3-3v2zm1 1v6h2V7h-2zm0 6a1 1 0 0 1-1 1v2a3 3 0 0 0 3-3h-2zm-1 1h-2v2h2v-2zm-3 1v4h2v-4h-2zm1.707 3.293l-4-4-1.414 1.414 4 4 1.414-1.414zM11 14H7v2h4v-2zm-4 0c-.276 0-.525-.111-.707-.293l-1.414 1.414C5.42 15.663 6.172 16 7 16v-2zm-.707 1.121l3.414-3.414-1.414-1.414-3.414 3.414 1.414 1.414zM9 12h4v-2H9v2zm4 0a3 3 0 0 0 3-3h-2a1 1 0 0 1-1 1v2zm3-3V3h-2v6h2zm0-6a3 3 0 0 0-3-3v2a1 1 0 0 1 1 1h2zm-3-3H3v2h10V0zM3 0a3 3 0 0 0-3 3h2a1 1 0 0 1 1-1V0zM0 3v6h2V3H0zm0 6a3 3 0 0 0 3 3v-2a1 1 0 0 1-1-1H0zm3 3h2v-2H3v2zm1-1v4h2v-4H4zm1.707 4.707l.586-.586-1.414-1.414-.586.586 1.414 1.414z"
/>
</svg>
</template>

View File

@@ -0,0 +1,7 @@
<template>
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="17" fill="currentColor">
<path
d="M11 2.253a1 1 0 1 0-2 0h2zm-2 13a1 1 0 1 0 2 0H9zm.447-12.167a1 1 0 1 0 1.107-1.666L9.447 3.086zM1 2.253L.447 1.42A1 1 0 0 0 0 2.253h1zm0 13H0a1 1 0 0 0 1.553.833L1 15.253zm8.447.833a1 1 0 1 0 1.107-1.666l-1.107 1.666zm0-14.666a1 1 0 1 0 1.107 1.666L9.447 1.42zM19 2.253h1a1 1 0 0 0-.447-.833L19 2.253zm0 13l-.553.833A1 1 0 0 0 20 15.253h-1zm-9.553-.833a1 1 0 1 0 1.107 1.666L9.447 14.42zM9 2.253v13h2v-13H9zm1.553-.833C9.203.523 7.42 0 5.5 0v2c1.572 0 2.961.431 3.947 1.086l1.107-1.666zM5.5 0C3.58 0 1.797.523.447 1.42l1.107 1.666C2.539 2.431 3.928 2 5.5 2V0zM0 2.253v13h2v-13H0zm1.553 13.833C2.539 15.431 3.928 15 5.5 15v-2c-1.92 0-3.703.523-5.053 1.42l1.107 1.666zM5.5 15c1.572 0 2.961.431 3.947 1.086l1.107-1.666C9.203 13.523 7.42 13 5.5 13v2zm5.053-11.914C11.539 2.431 12.928 2 14.5 2V0c-1.92 0-3.703.523-5.053 1.42l1.107 1.666zM14.5 2c1.573 0 2.961.431 3.947 1.086l1.107-1.666C18.203.523 16.421 0 14.5 0v2zm3.5.253v13h2v-13h-2zm1.553 12.167C18.203 13.523 16.421 13 14.5 13v2c1.573 0 2.961.431 3.947 1.086l1.107-1.666zM14.5 13c-1.92 0-3.703.523-5.053 1.42l1.107 1.666C11.539 15.431 12.928 15 14.5 15v-2z"
/>
</svg>
</template>

View File

@@ -0,0 +1,7 @@
<template>
<svg xmlns="http://www.w3.org/2000/svg" width="18" height="20" fill="currentColor">
<path
d="M11.447 8.894a1 1 0 1 0-.894-1.789l.894 1.789zm-2.894-.789a1 1 0 1 0 .894 1.789l-.894-1.789zm0 1.789a1 1 0 1 0 .894-1.789l-.894 1.789zM7.447 7.106a1 1 0 1 0-.894 1.789l.894-1.789zM10 9a1 1 0 1 0-2 0h2zm-2 2.5a1 1 0 1 0 2 0H8zm9.447-5.606a1 1 0 1 0-.894-1.789l.894 1.789zm-2.894-.789a1 1 0 1 0 .894 1.789l-.894-1.789zm2 .789a1 1 0 1 0 .894-1.789l-.894 1.789zm-1.106-2.789a1 1 0 1 0-.894 1.789l.894-1.789zM18 5a1 1 0 1 0-2 0h2zm-2 2.5a1 1 0 1 0 2 0h-2zm-5.447-4.606a1 1 0 1 0 .894-1.789l-.894 1.789zM9 1l.447-.894a1 1 0 0 0-.894 0L9 1zm-2.447.106a1 1 0 1 0 .894 1.789l-.894-1.789zm-6 3a1 1 0 1 0 .894 1.789L.553 4.106zm2.894.789a1 1 0 1 0-.894-1.789l.894 1.789zm-2-.789a1 1 0 1 0-.894 1.789l.894-1.789zm1.106 2.789a1 1 0 1 0 .894-1.789l-.894 1.789zM2 5a1 1 0 1 0-2 0h2zM0 7.5a1 1 0 1 0 2 0H0zm8.553 12.394a1 1 0 1 0 .894-1.789l-.894 1.789zm-1.106-2.789a1 1 0 1 0-.894 1.789l.894-1.789zm1.106 1a1 1 0 1 0 .894 1.789l-.894-1.789zm2.894.789a1 1 0 1 0-.894-1.789l.894 1.789zM8 19a1 1 0 1 0 2 0H8zm2-2.5a1 1 0 1 0-2 0h2zm-7.447.394a1 1 0 1 0 .894-1.789l-.894 1.789zM1 15H0a1 1 0 0 0 .553.894L1 15zm1-2.5a1 1 0 1 0-2 0h2zm12.553 2.606a1 1 0 1 0 .894 1.789l-.894-1.789zM17 15l.447.894A1 1 0 0 0 18 15h-1zm1-2.5a1 1 0 1 0-2 0h2zm-7.447-5.394l-2 1 .894 1.789 2-1-.894-1.789zm-1.106 1l-2-1-.894 1.789 2 1 .894-1.789zM8 9v2.5h2V9H8zm8.553-4.894l-2 1 .894 1.789 2-1-.894-1.789zm.894 0l-2-1-.894 1.789 2 1 .894-1.789zM16 5v2.5h2V5h-2zm-4.553-3.894l-2-1-.894 1.789 2 1 .894-1.789zm-2.894-1l-2 1 .894 1.789 2-1L8.553.106zM1.447 5.894l2-1-.894-1.789-2 1 .894 1.789zm-.894 0l2 1 .894-1.789-2-1-.894 1.789zM0 5v2.5h2V5H0zm9.447 13.106l-2-1-.894 1.789 2 1 .894-1.789zm0 1.789l2-1-.894-1.789-2 1 .894 1.789zM10 19v-2.5H8V19h2zm-6.553-3.894l-2-1-.894 1.789 2 1 .894-1.789zM2 15v-2.5H0V15h2zm13.447 1.894l2-1-.894-1.789-2 1 .894 1.789zM18 15v-2.5h-2V15h2z"
/>
</svg>
</template>

View File

@@ -0,0 +1,7 @@
<template>
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" fill="currentColor">
<path
d="M10 3.22l-.61-.6a5.5 5.5 0 0 0-7.666.105 5.5 5.5 0 0 0-.114 7.665L10 18.78l8.39-8.4a5.5 5.5 0 0 0-.114-7.665 5.5 5.5 0 0 0-7.666-.105l-.61.61z"
/>
</svg>
</template>

View File

@@ -0,0 +1,19 @@
<!-- This icon is from <https://github.com/Templarian/MaterialDesign>, distributed under Apache 2.0 (https://www.apache.org/licenses/LICENSE-2.0) license-->
<template>
<svg
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
aria-hidden="true"
role="img"
class="iconify iconify--mdi"
width="24"
height="24"
preserveAspectRatio="xMidYMid meet"
viewBox="0 0 24 24"
>
<path
d="M20 18v-4h-3v1h-2v-1H9v1H7v-1H4v4h16M6.33 8l-1.74 4H7v-1h2v1h6v-1h2v1h2.41l-1.74-4H6.33M9 5v1h6V5H9m12.84 7.61c.1.22.16.48.16.8V18c0 .53-.21 1-.6 1.41c-.4.4-.85.59-1.4.59H4c-.55 0-1-.19-1.4-.59C2.21 19 2 18.53 2 18v-4.59c0-.32.06-.58.16-.8L4.5 7.22C4.84 6.41 5.45 6 6.33 6H7V5c0-.55.18-1 .57-1.41C7.96 3.2 8.44 3 9 3h6c.56 0 1.04.2 1.43.59c.39.41.57.86.57 1.41v1h.67c.88 0 1.49.41 1.83 1.22l2.34 5.39z"
fill="currentColor"
></path>
</svg>
</template>

7
src/renderer/src/main.js Normal file
View File

@@ -0,0 +1,7 @@
import { createApp } from 'vue'
import router from './router'
import MainApp from './MainApp.vue'
const app = createApp(MainApp)
app.use(router)
app.mount('#app')

View File

@@ -0,0 +1,23 @@
import { createRouter, createWebHashHistory } from 'vue-router'
import App from '../App.vue'
import ApiConfig from '../components/ApiConfig.vue'
const routes = [
{
path: '/',
name: 'home',
component: App
},
{
path: '/config',
name: 'config',
component: ApiConfig
}
]
const router = createRouter({
history: createWebHashHistory(),
routes
})
export default router