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