Download the PHP package xvv/think-jump without Composer
On this page you can find all versions of the php package xvv/think-jump. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Please rate this library. Is it a good library?
Informations about the package think-jump
xvv/think-jump
ThinkPHP 8 跳转与重定向扩展包,兼容 PHP 8.4+,内置现代美观的跳转页面模板,支持明暗主题自适应。
安装
使用
在控制器中引入并使用 Jump Trait:
方法说明
success($msg, $url, $data, $wait, $header)
操作成功跳转。
| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
$msg |
mixed | '' |
提示信息 |
$url |
string|null | null |
跳转 URL,为 null 时返回上一页 |
$data |
mixed | '' |
返回数据 |
$wait |
int | 3 |
等待秒数 |
$header |
array | [] |
自定义响应头 |
error($msg, $url, $data, $wait, $header)
操作失败跳转。$url 为 null 时:AJAX 请求返回空字符串,普通请求返回 javascript:history.back(-1)。
result($data, $code, $msg, $type, $header)
直接封装并返回 API 数据,不走页面跳转。
| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
$data |
mixed | 返回数据 | |
$code |
int | 0 |
状态码 |
$msg |
mixed | '' |
提示信息 |
$type |
string | '' |
响应类型,为空时自动判断 |
$header |
array | [] |
自定义响应头 |
返回数据格式:
redirect($url, $code, $with)
HTTP 重定向。
| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
$url |
string | '' |
目标 URL |
$code |
int | 302 |
HTTP 状态码(301/302/307/308) |
$with |
array | [] |
通过 Session 附加的参数 |
配置
发布配置文件:
或在 config/ 目录下手动创建 jump.php:
模板说明
内置跳转模板 success.html 和 error.html 支持:
- 响应式布局,适配移动端
- 明暗主题自动切换(跟随系统偏好)
- 自动倒计时跳转
- 支持自定义模板路径覆盖默认配置
进阶用法
路由 URL 构建
传入非绝对路径时,自动调用 $this->app->route->buildUrl() 构建路由 URL:
自动判断响应类型
框架自动根据请求类型选择响应格式:
- AJAX / JSON 请求 → 返回 JSON 数据
- 普通请求 → 返回 HTML 跳转页
环境要求
- PHP >= 8.0
- ThinkPHP >= 8.0
- topthink/think-view >= 2.0
License
Apache-2.0
All versions of think-jump with dependencies
PHP Build Version
Package Version
The package xvv/think-jump contains the following files
Loading the files please wait ...