优化安装报错问题
This commit is contained in:
@@ -668,7 +668,7 @@ class Install extends Api
|
||||
|
||||
/**
|
||||
* 获取安装完成后的访问地址(根据请求来源区分 API 与前端开发模式)
|
||||
* - 通过 API 访问(8787):index.html#/admin、index.html#/
|
||||
* - 通过 API 访问(8787):index#/admin、index#/(无 index 与 # 之间的斜杠)
|
||||
* - 通过前端开发服务访问(1818):/#/admin、/#/
|
||||
*/
|
||||
public function accessUrls(Request $request): Response
|
||||
@@ -680,7 +680,8 @@ class Install extends Api
|
||||
$port = substr($host, strrpos($host, ':') + 1);
|
||||
}
|
||||
$scheme = $request->header('x-forwarded-proto', 'http');
|
||||
$base = rtrim($scheme . '://' . $host, '/');
|
||||
$basePath = $request instanceof \support\Request ? $request->publicBasePath() : '';
|
||||
$base = rtrim($scheme . '://' . $host, '/') . $basePath;
|
||||
|
||||
if ($port === '1818') {
|
||||
$adminUrl = $base . '/#/admin';
|
||||
|
||||
@@ -231,8 +231,17 @@ class InstallData extends AbstractMigration
|
||||
|
||||
public function menuRule(): void
|
||||
{
|
||||
if (!$this->hasTable('menu_rule')) return;
|
||||
$table = $this->table('menu_rule');
|
||||
// Install 迁移在已存在 admin_rule(旧版表名)时会跳过创建 menu_rule,此处需与之一致
|
||||
$ruleTable = null;
|
||||
if ($this->hasTable('menu_rule')) {
|
||||
$ruleTable = 'menu_rule';
|
||||
} elseif ($this->hasTable('admin_rule')) {
|
||||
$ruleTable = 'admin_rule';
|
||||
}
|
||||
if ($ruleTable === null) {
|
||||
return;
|
||||
}
|
||||
$table = $this->table($ruleTable);
|
||||
$rows = [
|
||||
[
|
||||
'id' => '1',
|
||||
@@ -1155,7 +1164,7 @@ class InstallData extends AbstractMigration
|
||||
'createtime' => $this->nowTime,
|
||||
],
|
||||
];
|
||||
$exist = Db::name('menu_rule')->where('id', 1)->value('id');
|
||||
$exist = Db::name($ruleTable)->where('id', 1)->value('id');
|
||||
if (!$exist) {
|
||||
$table->insert($rows)->saveData();
|
||||
}
|
||||
|
||||
@@ -13,11 +13,7 @@ if (!defined('BASE_PATH')) {
|
||||
require $baseDir . '/vendor/autoload.php';
|
||||
|
||||
if (class_exists('Dotenv\Dotenv') && is_file($baseDir . '/.env')) {
|
||||
if (method_exists('Dotenv\Dotenv', 'createUnsafeImmutable')) {
|
||||
Dotenv\Dotenv::createUnsafeImmutable($baseDir)->load();
|
||||
} else {
|
||||
Dotenv\Dotenv::createMutable($baseDir)->load();
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('env')) {
|
||||
|
||||
@@ -10,11 +10,8 @@ $baseDir = __DIR__;
|
||||
require $baseDir . '/vendor/autoload.php';
|
||||
|
||||
if (class_exists('Dotenv\Dotenv') && is_file($baseDir . '/.env')) {
|
||||
if (method_exists('Dotenv\Dotenv', 'createUnsafeImmutable')) {
|
||||
Dotenv\Dotenv::createUnsafeImmutable($baseDir)->load();
|
||||
} else {
|
||||
// 必须用 Mutable:Webman Worker 已加载过时,Immutable 不会覆盖 $_ENV,会导致 Phinx 与 Db::name() 前缀/库名不一致
|
||||
Dotenv\Dotenv::createMutable($baseDir)->load();
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('env')) {
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -107,7 +107,7 @@
|
||||
if (!urls.adminUrl && !urls.frontUrl) return;
|
||||
document.querySelectorAll('input[type="text"], input:not([type])').forEach(function(inp){
|
||||
var v = (inp.value || '').trim();
|
||||
if (v && (v.indexOf('#/admin') >= 0 || v.indexOf('index.html') >= 0) && v.indexOf('#/') >= 0) {
|
||||
if (v && (v.indexOf('#/admin') >= 0 || v.indexOf('index.html') >= 0 || v.indexOf('/index#') >= 0) && v.indexOf('#/') >= 0) {
|
||||
inp.value = urls.adminUrl;
|
||||
inp.dispatchEvent(new Event('input', { bubbles: true }));
|
||||
}
|
||||
@@ -116,6 +116,22 @@
|
||||
document.querySelectorAll('a[href*="#/"]').forEach(function(a){
|
||||
if (urls.frontUrl && a.href.indexOf('#/admin') < 0) a.href = urls.frontUrl;
|
||||
});
|
||||
// index.html/#/ 会被当成路径 /index.html/ 导致 webman 404,统一为 index.html#/
|
||||
document.querySelectorAll('a[href*="index.html/#"]').forEach(function(a){
|
||||
a.href = a.href.replace(/index\.html\/#\//g, 'index.html#/');
|
||||
});
|
||||
// 打包的 index.js 完成页用 protocol+host 拼 adminUrl,会漏掉 /index.php 等前缀;用接口结果覆盖展示与点击
|
||||
if (urls.adminUrl) {
|
||||
document.querySelectorAll('.admin-url').forEach(function(el){
|
||||
el.textContent = urls.adminUrl;
|
||||
el.style.cursor = 'pointer';
|
||||
el.onclick = function(ev){
|
||||
ev.preventDefault();
|
||||
ev.stopPropagation();
|
||||
window.open(urls.adminUrl, '_blank', 'noreferrer');
|
||||
};
|
||||
});
|
||||
}
|
||||
ensureQuickPanel();
|
||||
}
|
||||
if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', function(){ setInterval(applyUrls, 800); });
|
||||
|
||||
@@ -35,6 +35,18 @@ class Request extends \Webman\Http\Request
|
||||
return $path;
|
||||
}
|
||||
|
||||
/**
|
||||
* 入口为 /index.php/... 时返回 /index.php,用于拼接后台/前台完整 URL(与路由 path() 剥离规则对应)
|
||||
*/
|
||||
public function publicBasePath(): string
|
||||
{
|
||||
$path = parent::path();
|
||||
if (str_starts_with($path, '/index.php')) {
|
||||
return '/index.php';
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取请求参数(兼容 ThinkPHP param,合并 get/post,post 优先)
|
||||
* @param string|null $name 参数名,null 返回全部
|
||||
|
||||
@@ -100,6 +100,16 @@ export const useTerminal = defineStore(
|
||||
}
|
||||
|
||||
function addTask(command: string, blockOnFailure = true, extend = '', callback: Function = () => {}) {
|
||||
const duplicatePending = state.taskList.some(
|
||||
(item) =>
|
||||
item.command === command &&
|
||||
(item.status === taskStatus.Waiting ||
|
||||
item.status === taskStatus.Connecting ||
|
||||
item.status === taskStatus.Executing)
|
||||
)
|
||||
if (duplicatePending) {
|
||||
return
|
||||
}
|
||||
if (!state.show) toggleDot(true)
|
||||
state.taskList = state.taskList.concat({
|
||||
uuid: uuid(),
|
||||
|
||||
Reference in New Issue
Block a user