mirror of
https://github.com/flarum/framework.git
synced 2025-02-21 09:00:55 +08:00
Fix admin
This commit is contained in:
parent
25daca8685
commit
c4e18488b9
@ -9,10 +9,10 @@ import boot from 'flarum/initializers/boot';
|
||||
var app = new App();
|
||||
|
||||
app.initializers.add('store', store);
|
||||
app.initializers.add('preload', preload);
|
||||
app.initializers.add('session', session);
|
||||
app.initializers.add('routes', routes);
|
||||
app.initializers.add('timestamps', timestamps);
|
||||
app.initializers.add('preload', preload, {last: true});
|
||||
app.initializers.add('boot', boot, {last: true});
|
||||
|
||||
export default app;
|
||||
|
@ -7,16 +7,14 @@ use Auth;
|
||||
use Cookie;
|
||||
use Config;
|
||||
use View;
|
||||
use DB;
|
||||
use Flarum\Api\Request as ApiRequest;
|
||||
|
||||
class IndexAction extends Action
|
||||
{
|
||||
public function handle(Request $request, $params = [])
|
||||
{
|
||||
$config = [
|
||||
'baseURL' => 'http://flarum.dev/admin',
|
||||
'apiURL' => 'http://flarum.dev/api',
|
||||
'forumTitle' => Config::get('flarum::forum_title', 'Flarum Demo Forum')
|
||||
];
|
||||
$config = DB::table('config')->whereIn('key', ['base_url', 'api_url', 'forum_title', 'welcome_title', 'welcome_message'])->lists('value', 'key');
|
||||
$data = [];
|
||||
$session = [];
|
||||
$alert = Session::get('alert');
|
||||
@ -27,23 +25,35 @@ class IndexAction extends Action
|
||||
'token' => Cookie::get('flarum_remember')
|
||||
];
|
||||
|
||||
$response = $this->callAction('Flarum\Api\Actions\Users\ShowAction', ['id' => $user->id]);
|
||||
$response = $response->getData();
|
||||
$response = app('Flarum\Api\Actions\Users\ShowAction')
|
||||
->handle(new ApiRequest(['id' => $user->id], $this->actor))
|
||||
->content->toArray();
|
||||
|
||||
$data = [$response->data];
|
||||
if (isset($response->included)) {
|
||||
$data = array_merge($data, $response->included);
|
||||
$data = [$response['data']];
|
||||
if (isset($response['included'])) {
|
||||
$data = array_merge($data, $response['included']);
|
||||
}
|
||||
}
|
||||
|
||||
return View::make('flarum.admin::index')
|
||||
$view = View::make('flarum.admin::index')
|
||||
->with('title', 'Administration - '.Config::get('flarum::forum_title', 'Flarum Demo Forum'))
|
||||
->with('styles', app('flarum.admin.assetManager')->getCSSFiles())
|
||||
->with('scripts', app('flarum.admin.assetManager')->getJSFiles())
|
||||
->with('config', $config)
|
||||
->with('layout', View::make('flarum.admin::admin'))
|
||||
->with('layout', 'flarum.admin::admin')
|
||||
->with('data', $data)
|
||||
->with('session', $session)
|
||||
->with('alert', $alert);
|
||||
|
||||
$assetManager = app('flarum.admin.assetManager');
|
||||
$root = __DIR__.'/../../..';
|
||||
$assetManager->addFile([
|
||||
$root.'/js/admin/dist/app.js',
|
||||
$root.'/less/admin/app.less'
|
||||
]);
|
||||
|
||||
// event(new RenderView($view, $assetManager, $this));
|
||||
|
||||
return $view
|
||||
->with('styles', $assetManager->getCSSFiles())
|
||||
->with('scripts', $assetManager->getJSFiles());
|
||||
}
|
||||
}
|
||||
|
@ -16,13 +16,6 @@ class AdminServiceProvider extends ServiceProvider
|
||||
|
||||
$this->loadViewsFrom($root.'/views', 'flarum.admin');
|
||||
|
||||
$assetManager = $this->app['flarum.admin.assetManager'];
|
||||
|
||||
$assetManager->addFile([
|
||||
$root.'/js/admin/dist/app.js',
|
||||
$root.'/less/admin/app.less'
|
||||
]);
|
||||
|
||||
$this->publishes([
|
||||
$root.'/public/fonts' => public_path('flarum/fonts')
|
||||
]);
|
||||
|
@ -6,7 +6,6 @@
|
||||
<title>{{ $title }}</title>
|
||||
<meta name="description" content="">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1">
|
||||
<base href="/">
|
||||
@foreach ($styles as $file)
|
||||
<link rel="stylesheet" href="{{ str_replace(public_path(), '', $file) }}">
|
||||
@endforeach
|
||||
|
Loading…
x
Reference in New Issue
Block a user