OneBot: Leantime 改造版源码(BOM/Univer 表格/AI 接管/品牌替换等)
This commit is contained in:
52
app/Views/Composers/App.php
Normal file
52
app/Views/Composers/App.php
Normal file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace Leantime\Views\Composers;
|
||||
|
||||
use Illuminate\Contracts\Container\BindingResolutionException;
|
||||
use Leantime\Core\Controller\Frontcontroller as FrontcontrollerCore;
|
||||
use Leantime\Core\Events\DispatchesEvents;
|
||||
use Leantime\Core\UI\Composer;
|
||||
use Leantime\Core\UI\Theme;
|
||||
use Leantime\Domain\Menu\Repositories\Menu;
|
||||
|
||||
class App extends Composer
|
||||
{
|
||||
use DispatchesEvents;
|
||||
|
||||
public static array $views = [
|
||||
'global::layouts.app',
|
||||
];
|
||||
|
||||
private Menu $menuRepo;
|
||||
|
||||
private Theme $themeCore;
|
||||
|
||||
public function init(Menu $menuRepo, Theme $themeCore): void
|
||||
{
|
||||
$this->menuRepo = $menuRepo;
|
||||
$this->themeCore = $themeCore;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws BindingResolutionException
|
||||
*/
|
||||
public function with(): array
|
||||
{
|
||||
// These needs to live in the main app since the menu open or closed changes the entire html layout
|
||||
if (session()->exists('userdata')) {
|
||||
session(['menuState' => $this->menuRepo->getSubmenuState('mainMenu') ?: 'open']);
|
||||
}
|
||||
|
||||
$menuType = $this->menuRepo->getSectionMenuType(FrontcontrollerCore::getCurrentRoute(), 'project');
|
||||
|
||||
$announcement = null;
|
||||
$announcement = self::dispatch_filter('appAnnouncement', $announcement);
|
||||
|
||||
return [
|
||||
'module' => strtolower(FrontcontrollerCore::getModuleName()),
|
||||
'section' => $menuType,
|
||||
'appAnnouncement' => $announcement,
|
||||
'themeBgUrl' => $this->themeCore->getBackgroundImage(),
|
||||
];
|
||||
}
|
||||
}
|
||||
30
app/Views/Composers/Entry.php
Normal file
30
app/Views/Composers/Entry.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace Leantime\Views\Composers;
|
||||
|
||||
use Leantime\Core\UI\Composer;
|
||||
use Leantime\Core\UI\Theme;
|
||||
|
||||
class Entry extends Composer
|
||||
{
|
||||
public static array $views = [
|
||||
'global::layouts.entry',
|
||||
];
|
||||
|
||||
private Theme $themeCore;
|
||||
|
||||
public function init(Theme $themeCore): void
|
||||
{
|
||||
$this->themeCore = $themeCore;
|
||||
}
|
||||
|
||||
public function with(): array
|
||||
{
|
||||
$this->themeCore->getActive();
|
||||
$logoUrl = $this->themeCore->getLogoUrl();
|
||||
|
||||
return [
|
||||
'logoPath' => $logoUrl ?: BASE_URL.'/dist/images/logo.svg',
|
||||
];
|
||||
}
|
||||
}
|
||||
27
app/Views/Composers/Footer.php
Normal file
27
app/Views/Composers/Footer.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace Leantime\Views\Composers;
|
||||
|
||||
use Leantime\Core\Configuration\AppSettings;
|
||||
use Leantime\Core\UI\Composer;
|
||||
|
||||
class Footer extends Composer
|
||||
{
|
||||
public static array $views = [
|
||||
'global::sections.footer',
|
||||
];
|
||||
|
||||
protected AppSettings $settings;
|
||||
|
||||
public function init(AppSettings $settings): void
|
||||
{
|
||||
$this->settings = $settings;
|
||||
}
|
||||
|
||||
public function with(): array
|
||||
{
|
||||
return [
|
||||
'version' => $this->settings->appVersion,
|
||||
];
|
||||
}
|
||||
}
|
||||
96
app/Views/Composers/Header.php
Normal file
96
app/Views/Composers/Header.php
Normal file
@@ -0,0 +1,96 @@
|
||||
<?php
|
||||
|
||||
namespace Leantime\Views\Composers;
|
||||
|
||||
use Leantime\Core\Configuration\AppSettings;
|
||||
use Leantime\Core\Configuration\Environment;
|
||||
use Leantime\Core\UI\Composer;
|
||||
use Leantime\Core\UI\Theme;
|
||||
use Leantime\Domain\Setting\Repositories\Setting;
|
||||
|
||||
class Header extends Composer
|
||||
{
|
||||
public static array $views = [
|
||||
'global::sections.header',
|
||||
];
|
||||
|
||||
private Environment $config;
|
||||
|
||||
private Theme $themeCore;
|
||||
|
||||
private AppSettings $appSettings;
|
||||
|
||||
private Setting $settingsRepo;
|
||||
|
||||
public function init(
|
||||
Setting $settingsRepo,
|
||||
Environment $config,
|
||||
AppSettings $appSettings,
|
||||
Theme $themeCore
|
||||
): void {
|
||||
$this->settingsRepo = $settingsRepo;
|
||||
$this->config = $config;
|
||||
$this->appSettings = $appSettings;
|
||||
$this->themeCore = $themeCore;
|
||||
}
|
||||
|
||||
public function with(): array
|
||||
{
|
||||
// Batch-preload all theme settings in a single query on first load.
|
||||
// This populates SettingCache's in-memory tier so all subsequent
|
||||
// getSetting() calls from getActive(), getColorMode(), etc. are instant.
|
||||
$this->themeCore->preloadUserSettings();
|
||||
|
||||
$theme = $this->themeCore->getActive();
|
||||
$colorMode = $this->themeCore->getColorMode();
|
||||
$colorScheme = $this->themeCore->getColorScheme();
|
||||
$themeFont = $this->themeCore->getFont();
|
||||
|
||||
// Set colors to use
|
||||
if (! session()->exists('companysettings.sitename')) {
|
||||
$sitename = $this->settingsRepo->getSetting('companysettings.sitename');
|
||||
if ($sitename !== false) {
|
||||
session(['companysettings.sitename' => $sitename]);
|
||||
} else {
|
||||
session(['companysettings.sitename' => $this->config->sitename]);
|
||||
}
|
||||
}
|
||||
|
||||
$backgroundOpacity = 0.1;
|
||||
if ($this->themeCore->getBackgroundType() == 'image') {
|
||||
$backgroundOpacity = 1;
|
||||
}
|
||||
|
||||
return [
|
||||
'sitename' => session('companysettings.sitename') ?? '',
|
||||
'primaryColor' => $this->themeCore->getPrimaryColor(),
|
||||
'theme' => $theme,
|
||||
'version' => $this->appSettings->appVersion ?? '',
|
||||
'themeScripts' => [
|
||||
$this->themeCore->getJsUrl(),
|
||||
$this->themeCore->getCustomJsUrl(),
|
||||
],
|
||||
'themeColorMode' => $colorMode,
|
||||
'themeColorScheme' => $colorScheme,
|
||||
'themeFont' => $themeFont,
|
||||
'themeStyles' => [
|
||||
[
|
||||
'id' => 'themeStyleSheet',
|
||||
'url' => $this->themeCore->getStyleUrl(),
|
||||
],
|
||||
[
|
||||
'url' => $this->themeCore->getCustomStyleUrl(),
|
||||
],
|
||||
],
|
||||
'accents' => [
|
||||
$this->themeCore->getPrimaryColor(),
|
||||
$this->themeCore->getSecondaryColor(),
|
||||
false, // accent3 uses CSS default
|
||||
false, // accent4 uses CSS default
|
||||
],
|
||||
'themeBg' => $this->themeCore->getBackgroundImage(),
|
||||
'themeOpacity' => $backgroundOpacity,
|
||||
'themeType' => $this->themeCore->getBackgroundType(),
|
||||
];
|
||||
}
|
||||
}
|
||||
36
app/Views/Composers/PageBottom.php
Normal file
36
app/Views/Composers/PageBottom.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace Leantime\Views\Composers;
|
||||
|
||||
use Leantime\Core\Configuration\AppSettings;
|
||||
use Leantime\Core\Configuration\Environment;
|
||||
use Leantime\Core\UI\Composer;
|
||||
|
||||
class PageBottom extends Composer
|
||||
{
|
||||
/**
|
||||
* @var array|string[]
|
||||
*/
|
||||
public static array $views = [
|
||||
'global::sections.pageBottom',
|
||||
];
|
||||
|
||||
protected AppSettings $settings;
|
||||
|
||||
protected Environment $environment;
|
||||
|
||||
public function init(AppSettings $settings, Environment $environment): void
|
||||
{
|
||||
$this->settings = $settings;
|
||||
$this->environment = $environment;
|
||||
}
|
||||
|
||||
public function with(): array
|
||||
{
|
||||
return [
|
||||
'version' => $this->settings->appVersion,
|
||||
'poorMansCron' => $this->environment->get('poorMansCron'),
|
||||
'loggedIn' => session()->exists('userdata'),
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user