https://gitee.com/vip_huage/webman-admin-electron (保持同步)
https://github.com/Mr-ShiHuaYu/webman-admin-electron (主倉庫)
使用electron框架,封裝了webman,使得webman直接變成客戶端,運(yùn)行后,自動啟動webman服務(wù),退出軟件后,自動關(guān)閉所有webman進(jìn)程及子進(jìn)程。
藍(lán)奏云:
webman-admin-electron-win-0.0.1-x64.7z:
https://wwck.lanzoub.com/ijpmV2tsl94j
webman-admin-electron-win-0.0.1-x64.exe:
https://wwck.lanzoub.com/iQ6pO2tsmjde
https://gitee.com/vip_huage/webman-admin-electron/releases/tag/0.0.1
https://github.com/Mr-ShiHuaYu/webman-admin-electron/releases/tag/0.0.1
一定不能放在含有有中文的目錄
一定不能放在含有空格的目錄
例如,以下目錄均不行
C:\Program Files //不行,有空格
D:\軟件\webman-admin-electron // 不行,含有中文目錄
雙擊 electron-webman.exe運(yùn)行
用戶名:admin
密碼:admin
此項目為electron和webman的結(jié)合,將webman項目和php放在resources\extraResources下,會自動啟動服務(wù),軟件關(guān)閉后,會自動關(guān)閉所有webman進(jìn)程及子進(jìn)程。
倉庫源地址是electron-egg,我將其改為可根據(jù)setting.json動態(tài)配置,以及適配webman
源倉庫地址:
https://gitee.com/dromara/electron-egg
源倉庫官方文檔:
https://www.kaka996.com/
部分原軟件的設(shè)置沒有遷移過來,個人覺得夠用了,后續(xù)再添加
如果軟件打開后,無法正常顯示,大概是因為setting.json中的webman的port配置錯誤,請核對是否與webman項目下的config.php中的listen的端口一致
demo項目已改為兼容sqlite后,不支持原項目的所有表功能,webman官網(wǎng)只支持mysql,已注釋下面 table.render 代碼
建議在mysql上開發(fā)好后,使用navicat的數(shù)據(jù)庫遷移工具,將mysql數(shù)據(jù)庫轉(zhuǎn)為sqlite數(shù)據(jù)庫,然后,關(guān)閉代碼生成等功能
為了兼容sqlite,需要替換源webman-admin框架的2個文件,一個是
plugin/admin/app/common/Util.php
plugin/admin/app/controller/Crud.php
可以自行對比修改了什么內(nèi)容
如果在新電腦上運(yùn)行,可能需要將resource\php8的目錄添加到環(huán)境變量中,測試中發(fā)現(xiàn),絕對路徑\php.exe 絕對路徑\windows.php 會提示 php is not recognized as an internal command,但如果將windows.php換成start.php就沒事??赡苁且驗闆]有注釋掉那個監(jiān)控進(jìn)程導(dǎo)致的。
如果在新客戶端上部署,出現(xiàn)上面這個問題的話,2個建議,一是將monitor進(jìn)程注釋,二是將resource\php8的目錄添加到環(huán)境變量中??梢允褂孟旅嬲Z句,制作成.bat文件,用戶雙擊即可添加環(huán)境變量。
setx path /m "%path%;%~dp0resources\php8.0;"
實(shí)際測試,如果不想加環(huán)境變量,則必須關(guān)閉monitor進(jìn)程,不是因為monitor進(jìn)程導(dǎo)致環(huán)境變量的問題,而是php.exe 后面在沒有環(huán)境變量的環(huán)境下,就不能跟2個php文件,所以,在交付給客戶的時候,建議關(guān)閉monitor進(jìn)程
你好,請問這個地方怎么修改
/**
* 創(chuàng)建服務(wù)
*/
async create(cfg) {
this.options = cfg;
if (this.options.enable === false) {
return;
}
const hostname = this.options.hostname;
if (['localhost', '127.0.0.1'].indexOf(hostname) === -1) {
// 不是localhost就退出,不啟動服務(wù)
return;
}
try {
const phpPath = this.options.phpPath;
const projectPath = this.options.projectPath;
const stdioIgnore = this.options.stdioIgnore;
let phpBinaryPath = path.join(UtilsPs.getExtraResourcesDir(), phpPath, "php");
const windowsPhpPath = path.join(UtilsPs.getExtraResourcesDir(), projectPath, "start.php");
Log.info("[addon:webmanServer] phpBinaryPath file path:", phpBinaryPath);
Log.info("[addon:webmanServer] windowsPhpPath file path:", windowsPhpPath);
if (!fs.existsSync(phpBinaryPath)) throw new Error('php does not exist');
if (!fs.existsSync(windowsPhpPath)) throw new Error('start.php does not exist');
// const processOption = stdioIgnore === true ? {stdio: 'ignore'} : {"start"};
const processOption = "start -d";
Log.info("[addon:webmanServer] processOption :", processOption);
if (is.windows()) {
this.phpProcess = spawn(phpBinaryPath, [windowsPhpPath], processOption);
if (!stdioIgnore) {
this.phpProcess.stdout.on('data', (data) => {
Log.info(`[addon:webmanServer] ${data}`);
});
}
} else if (is.macOS()) {
// todo macos
this.phpProcess = spawn(phpBinaryPath, [windowsPhpPath], processOption);
if (!stdioIgnore) {
this.phpProcess.stdout.on('data', (data) => {
Log.info(`[addon:webmanServer] ${data}`);
});
}
} else {
// todo linux
}
// Log.info("[addon:webmanServer] cmdStr:", cmdStr);
// exec(cmdStr);
} catch (err) {
Log.error('[addon:webmanServer] throw error:', err);
}
}
windows 用戶執(zhí)行 php windows.php 啟動就可以了
mac 用戶啟動webman 需要執(zhí)行
php start.php start
我這個代碼執(zhí)行npm run dev 出現(xiàn)報錯
~/electron/electron-egg-webman ? 2023-12-22 10:04:33,152 INFO 32361 [addon:security] load
2023-12-22 10:04:33,153 INFO 32361 [addon:awaken] load
2023-12-22 10:04:33,161 INFO 32361 [addon:webmanServer] phpBinaryPath file path: /Users/110/electron/electron-egg-webman/build/extraResources/php8.0/php
2023-12-22 10:04:33,161 INFO 32361 [addon:webmanServer] windowsPhpPath file path: /Users/110/electron/electron-egg-webman/build/extraResources/webman/start.php
2023-12-22 10:04:33,161 INFO 32361 [addon:webmanServer] processOption : start -d
2023-12-22 10:04:33,164 ERROR 32361 [addon:webmanServer] throw error: TypeError [ERR_INVALID_ARG_TYPE]: The "options" argument must be of type object. Received type string ('start -d')
at normalizeSpawnArguments (node:child_process:533:5)
at spawn (node:child_process:702:13)
at WebmanServer.create (/Users/110/electron/electron-egg-webman/electron/addon/webman/server.js:57:35)
at WebmanServerAddon.create (/Users/110/electron/electron-egg-webman/electron/addon/webman/index.js:30:29)
at /Users/110/electron/electron-egg-webman/electron/preload/index.js:19:29
at AppLoader.loadFile (/Users/110/electron/electron-egg-webman/node_modules/ee-core/core/lib/loader/ee_loader.js:259:13)
at Index._loderPreload (/Users/110/electron/electron-egg-webman/node_modules/ee-core/ee/eeApp.js:363:33)
at Index.createWindow (/Users/110/electron/electron-egg-webman/node_modules/ee-core/ee/eeApp.js:97:16) {
code: 'ERR_INVALID_ARG_TYPE'
}
(node:32361) electron: Failed to load URL: http://localhost:8789/ with error: ERR_CONNECTION_REFUSED
(Use `Electron --trace-warnings ...` to show where the warning was created)
另外,我node 的版本是v20.5.1,會有問題嗎
electron-egg 的示例demo 可以跑起來
win 代碼直接在mac 上運(yùn)行會有空格或者回車字符串的問題,需要把no_moudle 刪除重新安裝依賴
https://wwp.lanzoup.com/iNK9R1l1xuqd 用這個源碼接哪里操作?
需要先安裝
npm install
再執(zhí)行
npm run build-wz
打包?
還是直接 npm run build-wz打包?
webman.phar 這種打包的可以運(yùn)行嗎? 該怎么使用呢 大佬們
我已經(jīng)實(shí)現(xiàn)了,可以正常運(yùn)行。連接如下:
https://wwmr.lanzoul.com/b0xw8xzpc 密碼:bzfm
看“使用說明2”,數(shù)據(jù)庫連接字符串自己改 resources\extraResources\webman\plugin\admin\config\database.php 里面配置,我演示是寫死的。
額,數(shù)據(jù)庫連接字符串改成 'database' => str_replace('phar://', '', run_path()) . '/webman_demo.db', 就行了,已測試。
webman不是支持sqlite嗎?為啥要改原文件?
我說要改webman-electron-egg源碼實(shí)現(xiàn)支持webman.phar文件運(yùn)行。
還有webman咋會不支持sqlite呢? 看文檔: http://www.wtbis.cn/doc/webman/db/config.html
為了兼容sqlite,需要替換源webman-admin框架的2個文件,一個是
plugin/admin/app/common/Util.php
plugin/admin/app/controller/Crud.php
我是指這個,是webman-admin不支持sqlite?
哦,不是和我說啊,尷尬。 webman-admin原先確實(shí)是用的mysql,現(xiàn)在作者為了做成桌面應(yīng)用轉(zhuǎn)為sqlite確實(shí)要改。
cool 這就很棒棒了