mirror of
https://github.com/bs-community/blessing-skin-server.git
synced 2024-12-15 06:09:58 +08:00
add some application information for javascript
This commit is contained in:
parent
6ff4ad0c33
commit
a858456d38
@ -3,7 +3,10 @@
|
||||
namespace App\Providers;
|
||||
|
||||
use View;
|
||||
use Event;
|
||||
use Validator;
|
||||
use App\Events;
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
class AppServiceProvider extends ServiceProvider
|
||||
@ -24,6 +27,15 @@ class AppServiceProvider extends ServiceProvider
|
||||
$this->app['request']->headers->set('host', $host[1]);
|
||||
};
|
||||
}
|
||||
|
||||
Event::listen(Events\RenderingHeader::class, function($event) {
|
||||
// provide some application information for javascript
|
||||
$blessing = array_merge(Arr::except(config('app'), ['key', 'providers', 'aliases', 'cipher', 'log', 'url']), [
|
||||
'baseUrl' => url('/'),
|
||||
]);
|
||||
|
||||
$event->addContent('<script>var blessing = '.json_encode($blessing).';</script>');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2,14 +2,11 @@
|
||||
* @Author: printempw
|
||||
* @Date: 2016-09-15 10:39:41
|
||||
* @Last Modified by: printempw
|
||||
* @Last Modified time: 2016-10-23 11:04:11
|
||||
* @Last Modified time: 2016-12-10 21:57:23
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
// guesss base url
|
||||
var base_url = (location.pathname.endsWith('user') || location.pathname.endsWith('admin')) ? "." : "..";
|
||||
|
||||
function logout(with_out_confirm, callback) {
|
||||
if (!with_out_confirm) {
|
||||
swal({
|
||||
@ -24,7 +21,9 @@ function logout(with_out_confirm, callback) {
|
||||
type: 'success',
|
||||
html: json.msg
|
||||
});
|
||||
window.setTimeout('window.location = "'+base_url+'/"', 1000);
|
||||
window.setTimeout(function() {
|
||||
window.location = blessing.baseUrl;
|
||||
}, 1000);
|
||||
});
|
||||
});
|
||||
} else {
|
||||
@ -37,7 +36,7 @@ function logout(with_out_confirm, callback) {
|
||||
function do_logout(callback) {
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: base_url + "/auth/logout",
|
||||
url: blessing.baseUrl + "/auth/logout",
|
||||
dataType: "json",
|
||||
success: function(json) {
|
||||
if (callback) callback(json);
|
||||
|
Loading…
Reference in New Issue
Block a user