├── .env ├── .gitignore ├── LICENSE ├── README.md ├── build └── icon.png ├── package.json ├── src ├── config.ts └── main.ts └── tsconfig.json /.env: -------------------------------------------------------------------------------- 1 | APP_URL=https://www.example.com 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /node_modules 2 | /package-lock.json 3 | /dist/ 4 | /release 5 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2024 akl7777777 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ShellApp 2 | 3 | ShellApp 手机端地址 https://github.com/akl7777777/ShellAppMobile 4 | 5 | 一款针对于Electron开发的可以将任意网站变成app的软件 6 | 7 | 安装Electron: 8 | 9 | npm install electron --save-dev 10 | 11 | 安装TypeScript和Electron的类型定义: 12 | npm install typescript electron @types/electron --save-dev 13 | 14 | 安装cross-env包,用于在不同操作系统上设置环境变量: 15 | 16 | npm install cross-env --save-dev 17 | npm install dotenv --save 18 | npm install electron-store --save 19 | 20 | 21 | npm install electron-builder --save-dev 22 | 23 | 修改.env中的url为你的网站地址 24 | 25 | image 26 | -------------------------------------------------------------------------------- /build/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/akl7777777/ShellApp/436626be29d6f8ae643e196ec7fcbac17a4739f2/build/icon.png -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "shellapp", 3 | "version": "1.0.0", 4 | "description": "一款针对于Electron开发的可以将任意网站变成app的软件", 5 | "main": "dist/main.js", 6 | "scripts": { 7 | "build": "tsc", 8 | "start": "npm run build && electron .", 9 | "pack": "npm run build && electron-builder --dir", 10 | "dist": "npm run build && electron-builder", 11 | "dist:mac": "npm run build && electron-builder --mac", 12 | "dist:win": "npm run build && electron-builder --win --x64 --ia32", 13 | "dist:linux": "npm run build && electron-builder --linux --x64 --arm64", 14 | "dist:all": "npm run dist:mac && npm run dist:win && npm run dist:linux" 15 | }, 16 | "author": { 17 | "name": "akl7777777", 18 | "email": "akl7777777@163.com" 19 | }, 20 | "license": "MIT", 21 | "build": { 22 | "appId": "com.shellgpt.shellapp", 23 | "productName": "Shell App", 24 | "directories": { 25 | "output": "release" 26 | }, 27 | "files": [ 28 | "dist/**/*", 29 | "node_modules/**/*", 30 | "package.json", 31 | ".env" 32 | ], 33 | "win": { 34 | "icon": "build/icon.png", 35 | "target": [ 36 | { 37 | "target": "nsis", 38 | "arch": [ 39 | "x64", 40 | "ia32" 41 | ] 42 | } 43 | ] 44 | }, 45 | "mac": { 46 | "icon": "build/icon.png", 47 | "target": [ 48 | { 49 | "target": "default", 50 | "arch": [ 51 | "arm64", 52 | "x64" 53 | ] 54 | } 55 | ] 56 | }, 57 | "linux": { 58 | "icon": "build/icon.png", 59 | "target": [ 60 | { 61 | "target": "deb", 62 | "arch": [ 63 | "x64", 64 | "arm64" 65 | ] 66 | }, 67 | { 68 | "target": "rpm", 69 | "arch": [ 70 | "x64", 71 | "arm64" 72 | ] 73 | } 74 | ], 75 | "category": "Utility" 76 | } 77 | }, 78 | "devDependencies": { 79 | "@types/electron": "^1.6.10", 80 | "cross-env": "^7.0.3", 81 | "electron": "^29.1.1", 82 | "electron-builder": "^24.13.3", 83 | "typescript": "^5.4.2" 84 | }, 85 | "dependencies": { 86 | "dotenv": "^16.4.5", 87 | "electron-store": "^8.2.0" 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /src/config.ts: -------------------------------------------------------------------------------- 1 | import Store from 'electron-store'; 2 | 3 | interface AppConfig { 4 | url: string; 5 | } 6 | 7 | const store = new Store(); 8 | 9 | export function getConfig(): AppConfig { 10 | return { 11 | url: store.get('url', ''), 12 | }; 13 | } 14 | 15 | export function setConfig(config: AppConfig): void { 16 | store.set('url', config.url); 17 | } 18 | -------------------------------------------------------------------------------- /src/main.ts: -------------------------------------------------------------------------------- 1 | import {app, BrowserWindow} from 'electron'; 2 | import dotenv from 'dotenv'; 3 | import * as path from "path"; 4 | const envPath = path.join(app.getAppPath(), '.env'); 5 | dotenv.config({ path: envPath }); 6 | 7 | const appUrl = process.env.APP_URL || ''; 8 | 9 | 10 | function createWindow(): void { 11 | const win = new BrowserWindow({ 12 | width: 800, 13 | height: 600, 14 | webPreferences: { 15 | nodeIntegration: true 16 | } 17 | }); 18 | 19 | win.loadURL(appUrl); 20 | } 21 | 22 | app.whenReady().then(createWindow); 23 | 24 | app.on('window-all-closed', () => { 25 | if (process.platform !== 'darwin') { 26 | app.quit(); 27 | } 28 | }); 29 | 30 | app.on('activate', () => { 31 | if (BrowserWindow.getAllWindows().length === 0) { 32 | createWindow(); 33 | } 34 | }); 35 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ES2018", 4 | "module": "commonjs", 5 | "sourceMap": true, 6 | "strict": true, 7 | "esModuleInterop": true, 8 | "outDir": "dist" 9 | }, 10 | "include": ["src/**/*"] 11 | } 12 | --------------------------------------------------------------------------------