diff --git a/var/Widget/Options.php b/var/Widget/Options.php index 941d3312..585e55f8 100644 --- a/var/Widget/Options.php +++ b/var/Widget/Options.php @@ -261,18 +261,18 @@ class Options extends Base * * @param string|null $path 子路径 * @param string|null $theme 模版名称 - * @return string + * @return string | void */ - public function themeUrl(?string $path = null, ?string $theme = null): string + public function themeUrl(?string $path, ?string $theme) { - if (empty($theme)) { + if (!isset($theme)) { echo Common::url($path, $this->themeUrl); + } else { + $url = defined('__TYPECHO_THEME_URL__') ? __TYPECHO_THEME_URL__ : + Common::url(__TYPECHO_THEME_DIR__ . '/' . $theme, $this->siteUrl); + + return isset($path) ? Common::url($path, $url) : $url; } - - $url = defined('__TYPECHO_THEME_URL__') ? __TYPECHO_THEME_URL__ : - Common::url(__TYPECHO_THEME_DIR__ . '/' . $theme, $this->siteUrl); - - return Common::url($path, $url); } /** @@ -482,8 +482,7 @@ class Options extends Base */ protected function ___themeUrl(): string { - return defined('__TYPECHO_THEME_URL__') ? __TYPECHO_THEME_URL__ : - Common::url(__TYPECHO_THEME_DIR__ . '/' . $this->theme, $this->siteUrl); + return $this->themeUrl(null, $this->theme); } /** diff --git a/var/Widget/Themes/Edit.php b/var/Widget/Themes/Edit.php index a41b62b9..90aefdb4 100644 --- a/var/Widget/Themes/Edit.php +++ b/var/Widget/Themes/Edit.php @@ -46,7 +46,7 @@ class Edit extends Options implements ActionInterface $this->update(['value' => 'recent'], $this->db->sql()->where('name = ?', 'frontPage')); } - $this->options->themeUrl = rtrim($this->options->themeUrl('', $theme), '/'); + $this->options->themeUrl = $this->options->themeUrl(null, $theme); $configFile = $this->options->themeFile($theme, 'functions.php');