sudo/sync-links

同步链接 Sudo 包

2.2.5 2020-10-07 06:53 UTC

This package is auto-updated.

Last update: 2024-09-05 05:15:59 UTC


README

介绍:这是一个用于管理 SudoCms 同步链接的 package。

默认情况下,该 package 会创建一个管理界面,用于管理所有同步链接,该界面位于 /{admin_dir}/sync_links,其中 admin_dir 是在 config('app.admin_dir') 中设置的 admin 路径。

安装以使用

  • Package 需要具有基础 sudo/core 才能正常工作而不出现错误
  • 要使用此 package,需要按照以下命令 require:composer require sudo/sync-links
  • 运行 php artisan migrate 以创建 package 所需的表格

在菜单中进行配置

[
	'type' 		=> 'single',
	'name' 		=> 'Link đồng bộ',
	'icon' 		=> 'fas fa-link',
	'route' 	=> 'admin.sync_links.index',
	'role'		=> 'sync_links_index'
],
  • 配置位置在 config/SudoMenu.php
  • 要显示在菜单中,可以将上述配置放在 config('SudoMenu.menu')

在模块中进行配置

'sync_links' => [
	'name' 			=> 'Link đồng bộ',
	'permision' 	=> [
		[ 'type' => 'index', 'name' => 'Truy cập' ],
		[ 'type' => 'create', 'name' => 'Thêm' ],
		[ 'type' => 'edit', 'name' => 'Sửa' ],
		[ 'type' => 'restore', 'name' => 'Lấy lại' ],
		[ 'type' => 'delete', 'name' => 'Xóa' ],
	],
],
  • 配置位置在 config/SudoModule.php
  • 为了进行权限分配,可以将上述配置放在 config('SudoModule.modules')

使用

此功能用于将旧链接导向新链接,支持 301 和 302 重定向,以服务于 SEO。

将以下代码段放在 app/Exceptions/Handler.phprender 方法中以执行检查和重定向

$check_syncs = \DB::table('sync_links')->where('old', $_SERVER['REQUEST_URI'])->where('status', 1)->first();
if(!empty($check_syncs) && !empty($check_syncs->new)){
    return redirect($check_syncs->new ?? '/', $check_syncs->redirect);
}