Skip to content

路由、模板、变量映射参考

本文档按模块列出全部路由 → 控制器方法 → 模板文件 → 注入变量的完整映射关系。主题开发者可根据此表了解每个页面会渲染哪个 EJS 模板、模板中可使用哪些由控制器 assign() 注入的变量。

路径说明:所有前端路由统一挂载在 /index 前缀下(Fastify 的 prefix),对外 URL 去除该前缀。即 /index/song/:id 的实际访问地址是 /song/:id


约定

标记含义
fetch调用的 EJS 模板路径(相对于 view/,不含 .ejs 后缀)
assign控制器通过 this.assign() 注入的变量及说明
layout使用的布局名(false=无布局, 'default'=默认, 'author'=作者布局)
noNeedLogin该方法是否无需登录
AJAX是否通过 x-requested-with: XMLHttpRequest 头区分返回格式
动态路径参数(:id 等),对应模板中通过 request.params 获取

首页 (Index)

URL方法fetchassignlayout免登录
GET /indexindex/indextitle, keywords, descriptiondefault
GET /sitemapsitemapindex/sitemapdefault
GET /link?type=&id=link—(重定向到详情页)

音乐 (Music)

URL方法fetchassignlayout免登录
GET /song/⚠:iddetailmusic/detaildownloadurl, title, keywords, description, obj(音乐数据对象)default

专辑 (Album)

URL方法fetchassignlayout免登录
GET /album/⚠:iddetailalbum/detailobj, type, title, keywords, description, downloadurldefault

视频 (Video)

URL方法fetchassignlayout免登录
GET /video/⚠:iddetailvideo/singlevideo/multiple(动态)obj, title, keywords, description(条件:total, videoInfo, videoData, sid, niddefault

创作者 (Author)

URL方法fetchassignlayout免登录
GET /author/⚠:iddetailauthor/detailtypeList, title, keywords, description, obj, by, typedefault
GET /author/creatorcreatorauthor/creatorobj, weeklyStats, newStats, titleauthor
GET /author/applyapplyauthor/applycategory, obj, links, musicianDisclaimer, city_area, isApply, titleauthor
GET|POST /author/update/⚠:idupdateauthor/updatecategory, obj, links, jumpauthor
GET|POST /author/post_musicpostMusicauthor/post_musictypeList, source_type, playbitrate, row, treeauthor
GET|POST /author/post_albumpostAlbumauthor/post_albumlist, row, query, treeauthor
GET|POST /author/musicmusicauthor/music(非AJAX)by, list, page, titleauthor
GET|POST /author/albumalbumauthor/albumby, list, page, titleauthor
GET|POST /author/followingfollowingauthor/followinglist, page, titleauthor
GET|POST /author/followerfollowerauthor/followerlist, page, titleauthor
GET|POST /author/incomeincomeauthor/incomeobj, list, page, titleauthor
GET|POST /author/withdrawwithdrawauthor/withdrawlist, page, obj, chineseMap, status, titleauthor
GET /author/ajax_imageajax_imageauthor/ajax_imagelist, total, pageSize, pageNum, pageCount, typefalse(AJAX)
GET /author/ajax_withdrawajax_withdrawauthor/ajax_withdrawmin_withdrawal, paymentMethods, objfalse(AJAX)

分类 (Type)

URL方法fetchassignlayout免登录
GET /type/⚠:iddetail动态(如 music/listobj, parent, children, sameLeveldefault

URL方法fetchassignlayout免登录
GET /search/indexsearch/index__list__, page, wd(搜索词), by, allCountdefault
GET /search/albumalbumsearch/album同上(私有方法 #handleSearch 统一注入)default
GET /search/specialspecialsearch/special同上default
GET /search/authorauthorsearch/author同上default
GET /search/circlecirclesearch/circle同上default
GET /search/goodsgoodssearch/goods同上default

商品 (Goods)

URL方法fetchassignlayout免登录
GET /goods/⚠:iddetailgoods/detailtitle, keywords, description, obj, commentdefault
GET|POST /goods/buybuygoods/buycoupon_list(条件), default_paytype, shopList, postage, paytype, pink_id, address, productAttrValue, order_id, productResult, product, quantity, type, titledefault
GET|POST /goods/confirm_orderconfirm_ordergoods/confirmencrypt, self_package, self_collection, shopList, title, list, paytype, default_paytype, address, defaultAddress, currency, total, totalNum, postage, coupon_listdefault
GET /goods/commentcommentgoods/commentid, all, hasImage, totalAdditional, list, currentType, pagefalse(AJAX)

圈子 (Circle)

URL方法fetchassignlayout免登录
GET /circle/⚠:iddetailcircle/detailtitle, keywords, description, objdefault
GET|POST /circle/createcreatecircle/createfalse(弹窗)
GET /circle/hothotcircle/hotdefault
GET /circle/homehomecircle/homequerydefault
GET|POST /circle/favsfavscircle/favstype, ids, query(非AJAX) / modeName, query, orderway, orderby, tplid, pageNum(AJAX)default
GET|POST /circle/likeslikescircle/likes(非AJAX)
ajax/index(AJAX)
ids, type, query(非AJAX)default

用户 (User)

URL方法fetchassignlayout免登录
GET /user/indexindexuser/indexnewTrack, event_list, userDataCount, titledefault
GET|POST /user/loginloginuser/logintitledefault
GET|POST /user/registerregisteruser/registerreg_verify_type, titledefault
GET /user/ajax_loginajax_loginuser/ajax_loginfalse(弹窗)
GET /user/ajax_regajax_registeruser/ajax_registerreg_verify_typefalse(弹窗)
GET /user/ajax_resetpwdajax_resetpwduser/ajax_resetpwdfalse(弹窗)
GET /user/profileprofileuser/profiledefault
GET|POST /user/favsfavsuser/favstype, rows, titledefault
GET|POST /user/likeslikesuser/likestype, rowsdefault
GET|POST /user/followfollowuser/followlist, pagedefault
GET|POST /user/recordrecorduser/recorddefault
GET|POST /user/downloaddownloaduser/downloadlist, page, type, titledefault
GET|POST /user/addressaddressuser/addressrows, titledefault
GET|POST /user/ajax_addressajax_addressuser/ajax_addressobj, idfalse(弹窗)

订单 (Order)

URL方法fetchassignlayout免登录
GET /order/indexindexorder/indexlist, page, statusdefault
GET /order/detail/⚠:iddetailorder/detailtitle, order, timelinedefault
GET /order/goodsgoodsorder/goodsstatus, keyword, list, page, title, shippingStatusdefault
GET /order/videovideoorder/videolist, page, status, keyworddefault
GET /order/circlecircleorder/circlelist, page, status, keyworddefault
GET /order/albumalbumorder/albumlist, page, status, keyworddefault
GET|POST /order/wechatwechatorder/wechatisWechat, isMobile, payData, orderData, type, titledefault
GET|POST /order/alipayalipayorder/alipayisWechat, isMobile, payData, orderData, type, titledefault
GET /order/track_ajaxtrack_ajaxorder/track_ajaxlistfalse(AJAX)
GET|POST /order/comment/⚠:oidcommentorder/commenttitle, order, product, commentsdefault

购物车 (Cart)

URL方法fetchassignlayout免登录
GET|POST /cart/indexindexcart/indextitle, typeMenu, list, page, type, paymentTypedefault

VIP (Vip)

URL方法fetchassignlayout免登录
GET /vip/indexindexvip/indexvipListdefault
GET /vip/ajax_vipajax_vipvip/ajax_vipvipList, levelfalse(弹窗)
GET /vip/ajax_redeemajax_redeemvip/ajax_redeemerror(条件), obj(条件), vip_down(条件)false(弹窗)

充值 (Recharge)

URL方法fetchassignlayout免登录
GET /recharge/indexindexrecharge/indexrechargeConfig, titledefault
GET /recharge/moneylogmoneylogrecharge/moneyloglist, total, page, rechargeConfig, titledefault

通知 (Notify)

URL方法fetchassignlayout免登录
GET /notify/indexindexnotify/indextitle, list, pagedefault
GET /notify/followerfollowernotify/followertitle, list, pagedefault
GET /notify/atteattenotify/attetitle, list, pagedefault
GET /notify/commentscommentsnotify/commentstitle, list, pagedefault
GET /notify/likelikenotify/liketitle, list, pagedefault
GET /notify/detaildetailnotify/detailobjdefault

消息 (Message)

URL方法fetchassignlayout免登录
GET /message/indexindexmessage/indexdefault

歌单 (Special)

URL方法fetchassignlayout免登录
GET /special/indexindexspecial/indexdefault
GET /special/mymyspecial/mytitle, rowsdefault
GET /special/⚠:iddetailspecial/detailby, rows, obj, author, title, typedefault
GET|POST /special/createcreatespecial/createobj(条件), titledefault
GET|POST /special/packagepackagespecial/packagestatus, rows, titledefault

签到 (Signin)

URL方法fetchassignlayout免登录
GET /signin/indexindexsignin/indexsignInRule, smakeList, signinData, signinRank, titledefault

秒杀 (Seckill)

URL方法fetchassignlayout免登录
GET /seckill/indexindexseckill/indexdefault
GET /seckill/⚠:iddetail动态(如 seckill/product_detailtitle, keywords, description, objdefault

团购 (Combination)

URL方法fetchassignlayout免登录
GET /combination/detail/⚠:iddetail动态(如 combination/product_detailtitle, keywords, description, obj, commentdefault
GET /combination/pink/⚠:idpinkcombination/pinktitle, keywords, description, objdefault

优惠券 (Coupon)

URL方法fetchassignlayout免登录
GET /coupon/indexindex优惠券列表
GET /coupon/mymyuser/couponlist, typedefault

卡密 (Cdkey)

URL方法fetchassignlayout免登录
GET /cdkey/ajax_cdkeyajax_cdkeycdkey/ajax_cdkeysale_url, cdkey_remark, type, titlefalse(弹窗)

第三方 (Third)

URL方法fetchassignlayout免登录
GET|POST /third/prepare/⚠:platformpreparethird/prepareuserinfo, platform, jump, bindurl, titledefault

AI 搜索 (Agent)

URL方法fetchassignlayout免登录
searchagent/search

频道 (Channel)

URL方法fetchassignlayout免登录
GET /channel/⚠:iddetailchannel/detaildefault
GET|POST /channel/applyapplychannel/applydefault

RSS (Rss)

URL方法fetchassignlayout免登录
GET /rss/indexrss/indexfalse
GET /rss/baidubaidurss/baidufalse
GET /rss/googlegooglerss/googlefalse
GET /rss/bingbingrss/bingfalse
GET /rss/smsmrss/smfalse
GET /rss/sosorss/sofalse
GET /rss/sogousogourss/sogoufalse

RSS 页面全部 layout(false),返回 XML 格式内容


AJAX 通用接口 (Ajax)

这些方法不走 fetch() 渲染模板,直接返回 JSON 或 HTML 片段。

URL方法说明免登录
GET /ajax/indexindexAJAX 列表加载(→ ajax/index),注入 modeName, query, orderway, orderby, tplid, pageNum, limit
POST /ajax/buyDownloadbuyDownload购买下载判断
POST /ajax/collectcollect收藏/取消
POST /ajax/shareshare获取分享链接
POST /ajax/followfollow关注/取消
GET /ajax/audioplayeraudioplayer音频播放数据(WASM 加密)
POST /ajax/sendEmailsendEmail发送邮件验证码
POST /ajax/sendSmssendSms发送短信验证码
POST /ajax/uploadConfiguploadConfig上传配置(签名字段)
POST /ajax/uploadNotifyuploadNotify上传回调通知
GET /ajax/pinyinpinyin汉字转拼音
GET /ajax/checkExistcheckExist检查字段值是否存在
POST /ajax/signaturesignature生成下载签名
GET /ajax/downloaddownload文件下载
POST /ajax/reactionsreactions点赞/踩
GET /ajax/get_cityget_city获取城市数据
GET /ajax/getNotifyCountgetNotifyCount未读通知数量
GET /ajax/getCartCountgetCartCount购物车数量
GET /ajax/captchacaptcha点选验证码
POST /ajax/mkzipmkzip创建打包文件
POST /ajax/download_packagedownload_package下载打包文件

动态页面 (Dynamic)

动态页面不由静态路由配置,而是由数据库中的 dynamic_page 集合数据动态注册。路由在系统启动时从数据库读取,注册到 Fastify。

当命中动态页面路由时:

js
// controller/Dynamic.js
const dynamic = reply.routeOptions.config;  // 从数据中读取页面配置
this.assign('obj', dynamic);
this.assign('title', dynamic.title + " - " + site_name);
this.assign('keywords', dynamic.keywords.join(","));
this.assign('description', dynamic.description);
this.assign('query', request.query);
this.assign('page_model', dynamic.model_name);
this.fetch(dynamic.tpl);  // 模板由数据中的 tpl 字段指定

模板中的可用变量

变量说明
obj动态页面的完整配置对象(title、seotitle、keywords、description、route、model_name 等)
query当前请求的 query 参数
page_model关联的数据模型名(如 MusicSong

动态页面的 diyname 用于分组:

  • header → 顶部导航栏
  • event → 活动类导航下拉
  • agreement → 协议类页面(页脚)

全局模板变量(所有页面共有)

无论哪个控制器,Base 基类的 setupRequestHooks()view() 方法都会向每个模板注入以下变量,无需在控制器中手动 assign:

变量来源说明
titlesetDefaultVariables页面标题(控制器可覆盖)
keywordssetDefaultVariablesSEO 关键词
descriptionsetDefaultVariablesSEO 描述
usergetSafeUser当前用户对象(含 isLogin/isGuest/_id/nickname/avatar 等)
cookierequest当前请求 Cookie 对象
requestFastify完整请求对象(含 query/params/raw/session 等)
siteinitConfig站点配置对象(site_name/logo/icp/copyright 等)
site_namesite 展开站点名称
site_logosite 展开Logo URL
designgetTemplateDesign装修布局数据对象
__TPL_STATIC__自动注入主题静态资源路径(如 /default_pc/
__STATIC__defaultContext全局静态资源路径(/
currentTheme自动注入当前主题名
themeType自动注入设备类型(pc / wap
devdefaultContext开发模式标识
isWechat自动注入是否来自微信浏览器
isMobile自动注入是否移动端
isAjax自动注入是否 AJAX 请求
global.DJ_VERSIONdefaultContext系统版本号
page_model控制器设置当前页面的数据模型名
source_typedefaultContext资源来源类型

Released under the MIT License.