提交 fd5f45e6 编写于 作者: ModStart's avatar ModStart

develop

上级 dbb83383
......@@ -49,8 +49,5 @@ return [
'SiteCounter' => [
'enable' => true,
],
'LinkExternalJumper' => [
'enable' => true,
],
],
];
<?php
namespace Module\LinkExternalJumper\Core;
use Illuminate\Events\Dispatcher;
use Illuminate\Support\Facades\View;
use Illuminate\Support\ServiceProvider;
use ModStart\Admin\Config\AdminMenu;
use ModStart\Core\Hook\ModStartHook;
class ModuleServiceProvider extends ServiceProvider
{
public function boot(Dispatcher $events)
{
ModStartHook::subscribe('PageBodyAppend', function () {
return View::make('module::LinkExternalJumper.View.widget.script')->render();
});
}
public function register()
{
}
}
当跳转到外部链接时,网站先跳转到提示页面告知用户
外链跳转提示插件
---
- 当跳转到外部链接时,网站先跳转到提示页面告知用户
修复跳转异常
---
- 修复:修复链接为相对路径时的跳转异常
@extends('modstart::layout.frame')
@section('headAppend')
@parent
<style type="text/css">
.pb-link-external-jumper{display:flex;position:fixed;top:0;left:0;right:0;bottom:20%;align-items:center;}
</style>
@endsection
@section('body')
<div class="pb-link-external-jumper">
<div style="margin:0 auto;display:block;max-width:800px;" class="lg:tw-w-1/2 tw-w-full tw-px-4">
<div>
<a href="{{modstart_web_url('')}}">
<img style="height:60px;" src="{{\ModStart\Core\Assets\AssetsUtil::fix(modstart_config('siteLogo'))}}"/>
</a>
</div>
<div class="tw-bg-white tw-rounded-2xl tw-shadow-lg tw-p-8">
<h2>您即将离开{{modstart_config('siteName')}}请注意您的帐号和财产安全</h2>
<div class="tw-py-4">
<a class="tw-text-gray-400" href="{{$target}}">{{$target}}</a>
</div>
<div class="tw-text-right tw-pt-4 tw-border-0 tw-border-t tw-border-gray-200 tw-border-solid">
<a class="btn btn-primary btn-lg" href="{{$target}}">继续访问</a>
</div>
</div>
</div>
</div>
@endsection
<script>
$(function () {
$(document).on('click', 'a', function () {
var href = this.href;
if(!href) return;
var l = window.location;
var currentUrl = l.protocol + '//' + l.host;
if (href.indexOf('http://') === 0 || href.indexOf('https://') === 0 || href.indexOf('//') === 0) {
if (href.indexOf(currentUrl) !== 0) {
$(this).attr('href', "{{modstart_web_url('link_external_jumper')}}?target=" + MS.util.urlencode(href));
}
}
});
});
</script>
<?php
namespace Module\LinkExternalJumper\Web\Controller;
use ModStart\Core\Input\InputPackage;
use ModStart\Core\Input\Response;
use ModStart\Module\ModuleBaseController;
class IndexController extends ModuleBaseController
{
public function index()
{
$input = InputPackage::buildFromInput();
$target = $input->getTrimString('target');
if (empty($target)) {
return Response::redirect(modstart_web_url(''));
}
return $this->view('linkExternalJumper.index', [
'target' => $target,
]);
}
}
<?php
$router->match(['get', 'post'], 'link_external_jumper', 'IndexController@index');
{
"name": "LinkExternalJumper",
"title": "外链跳转提示插件",
"require": [
"Vendor:>=1.2.0"
],
"version": "1.1.0",
"modstartVersion": ">=1.3.0",
"author": "ModStart",
"description": "当跳转到外部链接时,网站先跳转到提示页面告知用户",
"providers": [
],
"config": {
}
}
{!! \ModStart\ModStart::js('asset/common/share.js') !!}
<div data-share-buttons data-sites="weibo,qq,qzone,wechat"></div>
<div data-share-buttons data-sites="weibo,qq,qzone,wechat"></div>
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册