Skip to content

Commit 49b08ee

Browse files
committed
完善使用说明
1 parent 8f05d76 commit 49b08ee

File tree

2 files changed

+71
-24
lines changed

2 files changed

+71
-24
lines changed

README.md

Lines changed: 70 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ class Index
2222
use \liliuwei\think\Jump;
2323
public function index()
2424
{
25-
// return $this->error('error');
26-
// return $this->success('success');
27-
// return $this->redirect('index/test');
28-
return $this->result(['username' => 'liliuwei', 'sex' => '男']);
25+
//return $this->error('error');
26+
//return $this->success('success','index/index');
27+
//return $this->redirect('/admin/index/index');
28+
return $this->result(['username' => 'liliuwei', 'sex' => '男']);
2929
}
3030
}
3131
~~~
@@ -139,25 +139,71 @@ namespace app\admin\controller;
139139
class Index extends \app\BaseController
140140
{
141141
public function demo1()
142-
{
143-
return $this->success('success');
144-
}
145-
146-
public function demo2()
147-
{
148-
return $this->error('error');
149-
}
150-
151-
public function demo3()
152-
{
153-
return $this->redirect('index/index');
154-
}
155-
156-
public function demo4()
157-
{
158-
return $this->result(['username' => 'liliuwei', 'sex' => '男']);
159-
}
160-
}
161-
~~~
142+
{
143+
/**
144+
* 操作成功跳转的快捷方法
145+
* @param mixed $msg 提示信息
146+
* @param string $url 跳转的URL地址
147+
* @param mixed $data 返回的数据
148+
* @param integer $wait 跳转等待时间
149+
* @param array $header 发送的Header信息
150+
*/
151+
// 一般用法
152+
return $this->success('登录成功', 'index/index');
153+
//完整用法
154+
//return $this->success($msg = '登录成功', $url = 'index/index', $data = '', $wait = 3, $header = []);
155+
}
156+
157+
public function demo2()
158+
{
159+
/**
160+
* 操作错误跳转的快捷方法
161+
* @param mixed $msg 提示信息
162+
* @param string $url 跳转的URL地址
163+
* @param mixed $data 返回的数据
164+
* @param integer $wait 跳转等待时间
165+
* @param array $header 发送的Header信息
166+
*/
167+
// 一般用法
168+
return $this->error('登录失败');
169+
//return $this->success('登录失败','login/index');
170+
//完整用法
171+
//return $this->error($msg = '登录失败', $url = 'login/index', $data = '', $wait = 3, $header = []);
172+
173+
}
162174

175+
public function demo3()
176+
{
177+
/**
178+
* URL重定向
179+
* @param string $url 跳转的URL表达式
180+
* @param integer $code http code
181+
* @param array $with 隐式传参
182+
*/
183+
//一般用法
184+
//第一种方式:直接使用完整地址(/打头)
185+
//return $this->redirect('/admin/index/index');
186+
//第二种方式:如果你需要自动生成URL地址,应该在调用之前调用url函数先生成最终的URL地址。
187+
return $this->redirect(url('index/index', ['name' => 'think']));
188+
//return $this->redirect('http://www.thinkphp.cn');
189+
//完整用法
190+
//return $this->redirect($url= '/admin/index/index', $code = 302, $with = ['data' => 'hello']);
191+
}
192+
193+
public function demo4()
194+
{
195+
/**
196+
* 返回封装后的API数据到客户端
197+
* @param mixed $data 要返回的数据
198+
* @param integer $code 返回的code
199+
* @param mixed $msg 提示信息
200+
* @param string $type 返回数据格式
201+
* @param array $header 发送的Header信息
202+
*/
203+
//一般用法
204+
return $this->result(['username' => 'liliuwei', 'sex' => '男']);
205+
//完整用法
206+
//return $this->result($data=['username' => 'liliuwei', 'sex' => '男'], $code = 0, $msg = '', $type = '', $header = []);
207+
}
208+
}
163209
~~~

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"description": "适用于thinkphp6.0的跳转扩展",
44
"keywords": ["thinkphp", "think-jump", "success","error","result","redirect"],
55
"license": "Apache-2.0",
6+
"type": "think-extend",
67
"authors": [
78
{
89
"name": "liliuwei",

0 commit comments

Comments
 (0)