File tree Expand file tree Collapse file tree 4 files changed +22
-48
lines changed
Expand file tree Collapse file tree 4 files changed +22
-48
lines changed Original file line number Diff line number Diff line change @@ -4,31 +4,16 @@ const Controller = require('egg').Controller;
44
55class PageController extends Controller {
66 async about ( ) {
7- await this . ctx . render (
8- 'static/about' ,
9- {
10- pageTitle : '关于我们' ,
11- } ,
12- {
13- layout : 'layout.html' ,
14- }
15- ) ;
7+ await this . ctx . render ( 'static/about' , { pageTitle : '关于我们' } ) ;
168 }
179
1810 // FAQ
1911 async faq ( ) {
20- await this . ctx . render ( 'static/faq' , { } ,
21- {
22- layout : 'layout.html' ,
23- } ) ;
12+ await this . ctx . render ( 'static/faq' ) ;
2413 }
2514
2615 async getstart ( ) {
27- await this . ctx . render ( 'static/getstart' , {
28- pageTitle : 'Node.js 新手入门' ,
29- } , {
30- layout : 'layout.html' ,
31- } ) ;
16+ await this . ctx . render ( 'static/getstart' , { pageTitle : 'Node.js 新手入门' } ) ;
3217 }
3318
3419 async robots ( ) {
@@ -43,10 +28,7 @@ class PageController extends Controller {
4328 }
4429
4530 async api ( ) {
46- await this . ctx . render ( 'static/api' , { } ,
47- {
48- layout : 'layout.html' ,
49- } ) ;
31+ await this . ctx . render ( 'static/api' ) ;
5032 }
5133
5234}
Original file line number Diff line number Diff line change @@ -5,11 +5,8 @@ const Controller = require('egg').Controller;
55class SignController extends Controller {
66 async showLogin ( ) {
77 const { ctx } = this ;
8- const data = { } ;
9- const options = {
10- layout : 'layout.html' ,
11- } ;
12- await ctx . render ( '/sign/signin' , data , options ) ;
8+ const locals = { } ;
9+ await ctx . render ( '/sign/signin' , locals ) ;
1310 }
1411
1512 async signup ( ) {
Original file line number Diff line number Diff line change @@ -84,24 +84,20 @@ class HomeController extends Controller {
8484 }
8585
8686 const tabName = this . ctx . helper . tabName ( tab ) ;
87- const viewOptions = {
88- layout : 'layout.html' ,
87+
88+ const locals = {
89+ topics,
90+ current_page : page ,
91+ list_topic_count : limit ,
92+ tops,
93+ no_reply_topics,
94+ pages,
95+ tabs : this . config . tabs ,
96+ tab,
97+ pageTitle : tabName && tabName + '版块' ,
8998 } ;
90- await this . ctx . render (
91- 'index' ,
92- {
93- topics,
94- current_page : page ,
95- list_topic_count : limit ,
96- tops,
97- no_reply_topics,
98- pages,
99- tabs : this . config . tabs ,
100- tab,
101- pageTitle : tabName && tabName + '版块' ,
102- } ,
103- viewOptions
104- ) ;
99+
100+ await this . ctx . render ( 'index' , locals ) ;
105101 }
106102
107103 async sitemap ( ) {
Original file line number Diff line number Diff line change 11'use strict' ;
22
3- const path = require ( 'path' ) ;
4-
53module . exports = appInfo => {
64 const config = { } ;
75
@@ -43,14 +41,15 @@ module.exports = appInfo => {
4341 } ;
4442
4543 config . view = {
46- root : path . join ( appInfo . baseDir , 'app/view' ) ,
4744 defaultViewEngine : 'ejs' ,
4845 mapping : {
4946 '.html' : 'ejs' ,
5047 } ,
5148 } ;
5249
53- config . ejs = { } ;
50+ config . ejs = {
51+ layout : 'layout.html' ,
52+ } ;
5453
5554 return config ;
5655} ;
You can’t perform that action at this time.
0 commit comments