Skip to content

Commit 26fae13

Browse files
committed
项目开源
1 parent 53e24da commit 26fae13

39 files changed

+5221
-2
lines changed

README.md

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,32 @@
1-
# local-ai
2-
本地AI,一键安装,国内镜像,无需魔法,绿色汉化,沙箱运行。可以一键安装稳Stable Diffusion WebUI,Lama Cleaner等实用工具
1+
# 本地AI
2+
3+
Mac和Windows一键安装Stable Diffusion WebUI,Lama Cleaner,SadTalker,等AI工具,使用国内镜像,无需魔法。
4+
5+
## Stable Diffusion WebUI
6+
7+
根据任何领域的文本输入生成高质量、高分辨率且逼真的图像。
8+
9+
Window 使用xformers提速 RTX2060 3秒出图
10+
11+
Mac M1 使用MPS支持GPU 10秒出图
12+
13+
![20230601204523.png](https://b3logfile.com/file/2023/06/20230601204523-ESNiRdm.png)
14+
15+
## Lama Cleaner
16+
17+
智能图片编辑器:轻松擦除、修复!利用先进深度学习,删除照片中不需要的对象、缺陷、人物,自动填充背景修复图像。无需专业技能,几步操作让照片焕然一新。忘掉糟糕照片,让作品完美无瑕!一键擦除、修复,让您的照片变得惊艳无比!
18+
19+
[LamaCleaner.mp4](https://b3logfile.com/file/2023/05/%E9%A3%9E%E4%B9%A620230525-235656-gHpr4TV.mp4)
20+
21+
## SadTalker
22+
23+
让照片说话:照片 + 音频 = 会说话的视频
24+
25+
[tmpazikd9t19s0100enhanced.mp4](https://b3logfile.com/file/2023/06/tmpazikd9t19s-0-100_enhanced-pdsQKmN.mp4)
26+
27+
28+
## 给我买杯咖啡
29+
30+
嗨,如果你觉得我的项目有用,请考虑给我买杯咖啡来支持我的工作。谢谢
31+
32+
![二维码.png](https://b3logfile.com/file/2023/06/二维码-ZsBOlo6.png)

package.json

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
{
2+
"name": "local-ai",
3+
"productName": "本地AI",
4+
"version": "1.4.0",
5+
"description": "AI工具一键安装",
6+
"main": "src/index.js",
7+
"scripts": {
8+
"start": "electron-forge start",
9+
"package": "electron-forge package",
10+
"make": "electron-forge make",
11+
"publish": "electron-forge publish",
12+
"lint": "echo \"No linting configured\""
13+
},
14+
"config": {
15+
"forge": {
16+
"packagerConfig": {
17+
"name": "本地AI"
18+
},
19+
"makers": [
20+
{
21+
"name": "@electron-forge/maker-dmg"
22+
}
23+
]
24+
}
25+
},
26+
"keywords": [],
27+
"author": {
28+
"name": "dxcweb",
29+
"email": "dxcweb@qq.com"
30+
},
31+
"license": "MIT",
32+
"dependencies": {
33+
"adm-zip": "^0.5.10",
34+
"axios": "^1.4.0",
35+
"electron-is": "^3.0.0",
36+
"electron-squirrel-startup": "^1.0.0",
37+
"semver": "^7.5.1",
38+
"tree-kill": "^1.2.2"
39+
},
40+
"devDependencies": {
41+
"@electron-forge/cli": "^6.1.1",
42+
"@electron-forge/maker-dmg": "^6.1.1",
43+
"electron": "24.2.0"
44+
}
45+
}

src/index.css

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
body {
2+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica,
3+
Arial, sans-serif;
4+
margin: auto;
5+
max-width: 38rem;
6+
padding: 2rem;
7+
}

src/index.html

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="UTF-8" />
5+
<title>Hello World!</title>
6+
<link rel="stylesheet" href="index.css" />
7+
</head>
8+
<body>
9+
<h1>💖 Hello World!</h1>
10+
<p>Welcome to your Electron application.</p>
11+
</body>
12+
</html>

src/index.js

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
const { app, BrowserWindow, Menu, session } = require("electron");
2+
const path = require("path");
3+
const service = require("./service/service");
4+
const sleep = require("./utils/sleep");
5+
const is = require("electron-is");
6+
// Handle creating/removing shortcuts on Windows when installing/uninstalling.
7+
if (require("electron-squirrel-startup")) {
8+
app.quit();
9+
}
10+
11+
const createWindow = () => {
12+
// session.defaultSession.webRequest.onBeforeSendHeaders((details, callback) => {
13+
// if (details.url.indexOf("baidu.com") >= 0) {
14+
// if (details.url.indexOf("%2Fweb%2Findex.html") >= 0) {
15+
// console.log(11, details.url);
16+
// details.url += "&xx=1";
17+
// }
18+
// details.requestHeaders["Referer"] = "https://local-ai.dxcweb.com/";
19+
// }
20+
// callback({ cancel: false, requestHeaders: details.requestHeaders });
21+
// });
22+
// Create the browser window.
23+
const mainWindow = new BrowserWindow({
24+
titleBarStyle: "hidden",
25+
// width: 1200,
26+
// height: 800,
27+
width: 1500,
28+
height: 1000,
29+
webPreferences: {
30+
preload: path.join(__dirname, "preload.js"),
31+
},
32+
});
33+
service(mainWindow);
34+
if (is.macOS()) {
35+
// macOS
36+
const template = [
37+
{
38+
label: "本地AI",
39+
submenu: [
40+
{ role: "undo", label: "撤销" },
41+
{ role: "redo", label: "重做" },
42+
{ role: "cut", label: "剪切" },
43+
{ role: "copy", label: "复制" },
44+
{ role: "paste", label: "粘贴" },
45+
{ role: "selectall", label: "全选" },
46+
{ role: "quit", label: "退出" },
47+
],
48+
},
49+
];
50+
Menu.setApplicationMenu(Menu.buildFromTemplate(template));
51+
} else {
52+
// Windows and Linux
53+
mainWindow.setMenu(null);
54+
}
55+
// and load the index.html of the app.
56+
// mainWindow.loadFile(path.join(__dirname, "web/index.html"));
57+
mainWindow.loadURL("https://ai.dxcweb.com/el/?v=1.4.0");
58+
// mainWindow.loadURL("http://localhost:18888");
59+
60+
// Open the DevTools.
61+
// mainWindow.webContents.openDevTools();
62+
};
63+
64+
// This method will be called when Electron has finished
65+
// initialization and is ready to create browser windows.
66+
// Some APIs can only be used after this event occurs.
67+
app.on("ready", createWindow);
68+
69+
app.on("window-all-closed", () => {
70+
app.quit();
71+
});
72+
73+
app.on("activate", () => {
74+
//在 macOS 上,点击 dock 图标时没有已打开的其他窗口时,会重新创建一个窗口
75+
if (BrowserWindow.getAllWindows().length === 0) {
76+
createWindow();
77+
}
78+
});
79+
// 在应用程序退出之前执行
80+
81+
// In this file you can include the rest of your app's specific main process
82+
// code. You can also put them in separate files and import them here.

src/preload.js

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
// See the Electron documentation for details on how to use preload scripts:
2+
// https://www.electronjs.org/docs/latest/tutorial/process-model#preload-scripts
3+
4+
const { contextBridge, ipcRenderer } = require("electron");
5+
6+
const onListener = (eventName) => {
7+
return (callback) => {
8+
ipcRenderer.send(eventName);
9+
function handleEvent(event, data) {
10+
callback(data);
11+
}
12+
ipcRenderer.on(`${eventName}-status`, handleEvent);
13+
return () => {
14+
ipcRenderer.removeListener(`${eventName}-status`, handleEvent);
15+
};
16+
};
17+
};
18+
contextBridge.exposeInMainWorld("electronAPI", {
19+
close: () => ipcRenderer.send("close"),
20+
setTitle: (title) => {
21+
ipcRenderer.send("set-title", title);
22+
// const preloadPath = path.join(__dirname);
23+
// // 根据当前脚本的路径获取安装路径
24+
// const appPath = path.join(preloadPath, "../../");
25+
// ipcRenderer.send("log", appPath);
26+
return { xxx: 123 };
27+
},
28+
openFile: () => ipcRenderer.invoke("dialog:openFile"),
29+
handleCounter: (callback) => ipcRenderer.on("update-counter", callback),
30+
// 下载miniconda
31+
downloadMiniconda: () => ipcRenderer.send("download-miniconda"),
32+
// 环境检查
33+
checkEnv: () => ipcRenderer.invoke("check-env"),
34+
// 安装Lama Cleaner
35+
installLamaCleaner: () => ipcRenderer.send("install-lama-cleaner"),
36+
// hndleCounter: (callback) => ipcRenderer.on("update-counter", callback),
37+
registerNavigationListener: (callback) => {
38+
ipcRenderer.send("register-navigation-listener");
39+
ipcRenderer.on("navigation-status-changed", (event, status) => {
40+
callback(status);
41+
});
42+
},
43+
44+
getVersion: () => ipcRenderer.invoke("get-version"),
45+
checkUpdate: () => ipcRenderer.invoke("checkUpdate"),
46+
update: onListener("update"),
47+
startLamaCleaner: onListener("lama-cleaner"),
48+
startStableDiffusion: onListener("stable-diffusion"),
49+
SadTalker: onListener("SadTalker"),
50+
});

0 commit comments

Comments
 (0)