初始化

master
yutent 2024-01-03 15:00:36 +08:00
parent 2f53964321
commit 0029d2cbe3
15 changed files with 308 additions and 4 deletions

2
.envrc Normal file
View File

@ -0,0 +1,2 @@
export ELECTRON_MIRROR=https://npm.taobao.org/mirrors/electron/
export electron_use_remote_checksums=true

16
.gitignore vendored Normal file
View File

@ -0,0 +1,16 @@
.DS_Store
.AppleDouble
.LSOverride
.idea
._*
.Spotlight-V100
.Trashes
build
build/**
node_modules
node_modules/**
package-lock.json

16
.vscode/launch.json vendored Normal file
View File

@ -0,0 +1,16 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "Debug Main Process",
"type": "node",
"request": "launch",
"cwd": "${workspaceRoot}",
"runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron",
"windows": {
"runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron.cmd"
},
"args": ["."]
}
]
}

View File

@ -2,14 +2,23 @@ Sequel Ice <img alt="Logo" src="https://sequel-ace.com/images/appIcon-1024.png"
=======
Sequel Ice is the "sequel" to the longtime macOS tool Sequel Pro.
Sequel Ice is a fast, easy-to-use Linux database management application for working with MySQL & MariaDB databases.
"Sequel Ice"是一个基于electron开发的数据库(MySQL & MariaDB)管理工具,界面仿照已经不维护的"Sequel Pro", 某种程度上可算作"Sequel Pro"的Linux版本.
## Compatibility
## 兼容性
- **DebianOS:** >= 12 \*
- **DebianOS:** >= 12
- **Arch:** x86_64
- **Electron:** >= 12.0
- **MySQL:** >= 5.7
- **MariaDB:** >= 10.0
## 安装依赖
```bash
# 需要先初始化一些环境变量 (否则国内的网络环境可能会下载electron失败)
. .envrc && npm i
```

BIN
icons/128x128.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

BIN
icons/256x256.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

BIN
icons/512x512.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 98 KiB

BIN
icons/tray.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

BIN
icons/tray@2x.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

55
package.json Normal file
View File

@ -0,0 +1,55 @@
{
"name": "sequel-ice",
"version": "0.0.1",
"description": "MySQL/MariaDB database management for Linux",
"main": "src/main.js",
"scripts": {
"preinstall": "source .npmrc",
"start": "electron .",
"pack": "electron-builder --linux"
},
"author": {
"name": "yutent",
"email": "yutent.io@gmail.com"
},
"homepage": "https://git.wkit.fun/appcat/sequel-ice",
"license": "MIT",
"build": {
"appId": "sequel-ice",
"productName": "Sequel Ice",
"copyright": "Copyright © 2024 ${author}",
"directories": {
"buildResources": "icons",
"output": "build"
},
"electronDownload": {
"version": "28.1.0",
"mirror": "https://registry.npmmirror.com/binary.html?path=electron/"
},
"files": [
"src/**/*",
"node_modules/iofs/*",
"node_modules/ssh2/*",
"node_modules/mysql2/*"
],
"linux": {
"category": "Network;Development",
"target": [
{
"target": "deb",
"arch": "x64"
}
],
"icon": "./icons/"
}
},
"dependencies": {
"iofs": "^1.5.3",
"mysql2": "^3.6.5",
"ssh2": "^1.15.0"
},
"devDependencies": {
"electron": "^28.1.0",
"electron-builder": "^24.9.1"
}
}

15
src/index.html Normal file
View File

@ -0,0 +1,15 @@
<!doctype html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no">
<title>Examples</title>
<meta name="keywords" content="">
<meta name="description" content="">
<link href="" rel="stylesheet">
</head>
<body>
<h1>It works!</h1>
</body>
</html>

72
src/main.js Normal file
View File

@ -0,0 +1,72 @@
/**
* 主入口
* @author yutent<yutent.io@gmail.com>
* @date 2020/11/18 09:27:09
*/
const { app, session, protocol, globalShortcut, ipcMain } = require('electron')
const path = require('path')
const fs = require('iofs')
require('./tools/init.js')
const { createMainWindow } = require('./tools/windows.js')
const MIME_TYPES = {
'.js': 'text/javascript',
'.html': 'text/html',
'.htm': 'text/plain',
'.css': 'text/css',
'.jpg': 'image/jpg',
'.png': 'image/png',
'.gif': 'image/gif',
'.svg': 'image/svg+xml',
'.ico': 'image/ico',
'.mp3': 'audio/mpeg',
'.m4a': 'audio/m4a',
'.aac': 'audio/x-aac',
'.ogg': 'audio/ogg',
'.wav': 'audio/x-wav',
'.flac': 'audio/flac',
all: 'audio/*'
}
/* ----------------------------------------------------- */
app.commandLine.appendSwitch('--lang', 'zh-CN')
app.commandLine.appendSwitch('--autoplay-policy', 'no-user-gesture-required')
protocol.registerSchemesAsPrivileged([
{ scheme: 'app', privileges: { secure: true, standard: true } }
])
/* ----------------------------------------------------- */
// 初始化应用
app.once('ready', () => {
// 注册协议
protocol.registerStreamProtocol('app', function (req, cb) {
var file = decodeURIComponent(req.url.replace(/^app:\/\/local\//, ''))
var ext = path.extname(req.url)
file = path.resolve(__dirname, file)
cb({
data: fs.origin.createReadStream(file),
mimeType: MIME_TYPES[ext],
headers: {
'Cache-Control': 'max-age=144000000'
}
})
})
let win = createMainWindow(path.resolve(__dirname, './images/app.png'))
ipcMain.on('app', (ev, conn) => {
switch (conn.type) {
case '':
break
default:
break
}
})
})

48
src/tools/init.js Normal file
View File

@ -0,0 +1,48 @@
/**
* 配置/DB通讯
* @author yutent<yutent@doui.cc>
* @date 2019/01/26 18:11:26
*/
const { app, ipcMain } = require('electron')
const { resolve, join } = require('path')
const fs = require('iofs')
// const sec = require('crypto.js')
const HOME = resolve(app.getPath('userData'))
/* ********** 修复环境变量 start *********** */
let PATH_SET = new Set()
process.env.PATH.split(':').forEach(_ => {
PATH_SET.add(_)
})
PATH_SET.add('/usr/local/bin')
PATH_SET.add('/usr/local/sbin')
process.env.PATH = Array.from(PATH_SET).join(':')
PATH_SET = null
/* ********** 修复环境变量 end *********** */
/* ----------------------------------------------------------------- */
/* --------------------- 事件开始 ------------------------- */
/* ---------------------------------------------------------------- */
ipcMain.on('ready', ev => {
ev.returnValue = { CONFIG_FILE, SONGS_FILE, PLAYLIST_FILE, MUSIC_DIR }
})
// ipcMain.on('app', (ev, conn) => {
// switch (conn.type) {
// // 获取应用配置
// case 'get-init':
// var ini = fs.cat(INIT_FILE).toString('')
// ev.returnValue = JSON.parse(ini)
// break
// // 设置应用配置
// case 'set-init':
// fs.echo(JSON.stringify(conn.data, null, 2), INIT_FILE)
// break
// }
// })

20
src/tools/inject.js Normal file
View File

@ -0,0 +1,20 @@
/**
* {}
* @author yutent<yutent.io@gmail.com>
* @date 2022/07/14 11:54:32
*/
const { ipcRenderer, shell, contextBridge } = require('electron')
const { resolve } = require('path')
const fs = require('iofs')
const { CONFIG_FILE } = ipcRenderer.sendSync('ready')
let timer = null
contextBridge.exposeInMainWorld('electron', {
hostname: HOST,
open(url) {
shell.openExternal(url)
}
})

51
src/tools/windows.js Normal file
View File

@ -0,0 +1,51 @@
/**
* 各种窗口创建
* @author yutent<yutent.io@gmail.com>
* @date 2020/11/27 13:59:55
*/
const { BrowserWindow } = require('electron')
/**
* 应用主窗口
*/
exports.createMainWindow = function (icon) {
// 创建浏览器窗口
let win = new BrowserWindow({
title: '',
width: 320,
height: 240,
frame: false,
resizable: false,
maximizable: false,
icon,
transparent: true,
vibrancy: 'dark',
webPreferences: {
webSecurity: false,
experimentalFeatures: true,
preload: './inject.js'
},
show: false
})
// 然后加载应用的 index.html。
win.loadURL('app://local/index.html')
// createAppTray(win)
// ctrlTrayBtn(win)
// createLrcTray(win)
win.on('ready-to-show', _ => {
win.show()
win.openDevTools()
})
win.on('close', ev => {
ev.preventDefault()
win.hide()
})
return win
}