Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e2c038b

Browse files
committed
左侧加点赞等
1 parent 6df0ae0 commit e2c038b

32 files changed

+478
-33
lines changed

http/controller/other.go

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// Copyright 2016 The StudyGolang Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style
3+
// license that can be found in the LICENSE file.
4+
// https://studygolang.com
5+
// Author: polaris [email protected]
6+
7+
package controller
8+
9+
import (
10+
"net/http"
11+
"path"
12+
13+
"github.com/labstack/echo/v4"
14+
"github.com/polaris1119/config"
15+
16+
"github.com/studygolang/studygolang/util"
17+
)
18+
19+
// OtherController 有些页面只是前端,因此通过这个页面统一控制
20+
// 只需要创建模板文件就可以访问到
21+
type OtherController struct{}
22+
23+
// RegisterRoute 注册路由
24+
func (self OtherController) RegisterRoute(g *echo.Group) {
25+
g.GET("/*", self.Any)
26+
}
27+
28+
func (OtherController) Any(ctx echo.Context) error {
29+
uri := ctx.Request().RequestURI
30+
tplFile := uri + ".html"
31+
if util.Exist(path.Clean(config.TemplateDir + tplFile)) {
32+
return render(ctx, tplFile, nil)
33+
}
34+
35+
return echo.NewHTTPError(http.StatusNotFound)
36+
}

http/controller/routes.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,6 @@ func RegisterRoutes(g *echo.Group) {
4444
new(WechatController).RegisterRoute(g)
4545

4646
new(InstallController).RegisterRoute(g)
47+
48+
new(OtherController).RegisterRoute(g)
4749
}

http/controller/sidebar.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ func (SidebarController) NewestUser(ctx echo.Context) error {
159159

160160
// FriendLinks 友情链接
161161
func (SidebarController) FriendLinks(ctx echo.Context) error {
162-
friendLinks := logic.DefaultFriendLink.FindAll(context.EchoContext(ctx), 5)
162+
friendLinks := logic.DefaultFriendLink.FindAll(context.EchoContext(ctx), 10)
163163
return success(ctx, friendLinks)
164164
}
165165

static/dist/js/sg_base.js

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,29 @@ jQuery(document).ready(function($) {
421421
});
422422
});
423423

424+
// 详情页左侧喜欢
425+
$('.suspended-panel .like-btn').on('click', function(evt) {
426+
evt.preventDefault();
427+
428+
var that = this;
429+
postLike('.page #content-thank a', function(likeNum, likeFlag) {
430+
var badge = $(that).attr('badge');
431+
if (likeFlag) {
432+
badge++;
433+
$(that).addClass('active');
434+
} else {
435+
badge--;
436+
$(that).removeClass('active');
437+
}
438+
$(that).attr('badge', badge);
439+
if (badge == 1) {
440+
$(that).addClass('with-badge');
441+
} else if (badge == 0) {
442+
$(that).removeClass('with-badge');
443+
}
444+
});
445+
});
446+
424447
// 列表页直接点喜欢(取消喜欢)
425448
$('.article .metatag .like').on('click', function(evt){
426449
evt.preventDefault();
@@ -494,6 +517,29 @@ jQuery(document).ready(function($) {
494517
});
495518
});
496519

520+
// 详情页左侧收藏(取消收藏)
521+
$('.suspended-panel .collect-btn').on('click', function(evt) {
522+
evt.preventDefault();
523+
524+
var that = this;
525+
postFavorite('.page .collect', function(hadCollect) {
526+
$('.page .collect').data('collect', hadCollect);
527+
528+
if (hadCollect) {
529+
$(that).addClass('active');
530+
531+
comTip("感谢收藏!");
532+
$('.page .collect').attr('title', '取消收藏').text('取消收藏');
533+
} else {
534+
$(that).removeClass('active');
535+
536+
$('.page .collect').attr('title', '稍后再读').text('加入收藏');
537+
comTip("已取消收藏!");
538+
}
539+
540+
});
541+
});
542+
497543
// 收藏页 取消收藏
498544
$('.article .metatag .collect').on('click', function(evt){
499545
evt.preventDefault();
@@ -504,6 +550,42 @@ jQuery(document).ready(function($) {
504550
});
505551
});
506552

553+
// 提示关注微信公众号
554+
$('.qrcode').on('mouseover', function(evt) {
555+
$('.qrcode-pop').show();
556+
});
557+
$('.qrcode').on('mouseout', function(evt) {
558+
$('.qrcode-pop').hide();
559+
});
560+
561+
// 当前链接的微信二维码
562+
var hadGenQRCode = false;
563+
$('.wechat-btn').on('mouseover', function(evt) {
564+
if (hadGenQRCode) {
565+
$(this).children('img').show();
566+
return;
567+
}
568+
new QRCode(this, {
569+
text: location.href,
570+
width: 256,
571+
height: 256,
572+
});
573+
hadGenQRCode = true;
574+
});
575+
$('.wechat-btn').on('mouseout', function(evt) {
576+
$(this).children('img').hide();
577+
});
578+
579+
// 详情页左侧评论按钮
580+
$('.comment-btn').on('click', function(evt) {
581+
var url = location.href;
582+
if (url.indexOf("#commentForm") == -1) {
583+
location.href = url + "#commentForm";
584+
} else {
585+
location.href = url;
586+
}
587+
});
588+
507589
window.saveComposeDraft = function(uid, keyprefix, objdata) {
508590
var key = keyprefix+':compose:by:' + uid;
509591
lscache.set(key, objdata, 525600);

static/dist/js/sg_base.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

static/dist/js/sg_libs.js

Lines changed: 2 additions & 0 deletions
Large diffs are not rendered by default.

static/dist/js/sg_libs.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

static/img/collect-active.svg

Lines changed: 3 additions & 0 deletions
Loading

static/img/collect-hover.svg

Lines changed: 3 additions & 0 deletions
Loading

static/img/collect.svg

Lines changed: 3 additions & 0 deletions
Loading

static/img/comment-hover.svg

Lines changed: 3 additions & 0 deletions
Loading

static/img/comment.svg

Lines changed: 3 additions & 0 deletions
Loading

static/img/qq-hover.svg

Lines changed: 3 additions & 0 deletions
Loading

static/img/qq.svg

Lines changed: 3 additions & 0 deletions
Loading

static/img/wechat-hover.svg

Lines changed: 3 additions & 0 deletions
Loading

static/img/wechat.svg

Lines changed: 3 additions & 0 deletions
Loading

static/img/weibo-hover.svg

Lines changed: 8 additions & 0 deletions
Loading

static/img/weibo.svg

Lines changed: 6 additions & 0 deletions
Loading

static/img/zan-active.svg

Lines changed: 3 additions & 0 deletions
Loading

static/img/zan-hover.svg

Lines changed: 3 additions & 0 deletions
Loading

static/img/zan.svg

Lines changed: 3 additions & 0 deletions
Loading

static/js/base/common.js

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,29 @@ jQuery(document).ready(function($) {
421421
});
422422
});
423423

424+
// 详情页左侧喜欢
425+
$('.suspended-panel .like-btn').on('click', function(evt) {
426+
evt.preventDefault();
427+
428+
var that = this;
429+
postLike('.page #content-thank a', function(likeNum, likeFlag) {
430+
var badge = $(that).attr('badge');
431+
if (likeFlag) {
432+
badge++;
433+
$(that).addClass('active');
434+
} else {
435+
badge--;
436+
$(that).removeClass('active');
437+
}
438+
$(that).attr('badge', badge);
439+
if (badge == 1) {
440+
$(that).addClass('with-badge');
441+
} else if (badge == 0) {
442+
$(that).removeClass('with-badge');
443+
}
444+
});
445+
});
446+
424447
// 列表页直接点喜欢(取消喜欢)
425448
$('.article .metatag .like').on('click', function(evt){
426449
evt.preventDefault();
@@ -494,6 +517,29 @@ jQuery(document).ready(function($) {
494517
});
495518
});
496519

520+
// 详情页左侧收藏(取消收藏)
521+
$('.suspended-panel .collect-btn').on('click', function(evt) {
522+
evt.preventDefault();
523+
524+
var that = this;
525+
postFavorite('.page .collect', function(hadCollect) {
526+
$('.page .collect').data('collect', hadCollect);
527+
528+
if (hadCollect) {
529+
$(that).addClass('active');
530+
531+
comTip("感谢收藏!");
532+
$('.page .collect').attr('title', '取消收藏').text('取消收藏');
533+
} else {
534+
$(that).removeClass('active');
535+
536+
$('.page .collect').attr('title', '稍后再读').text('加入收藏');
537+
comTip("已取消收藏!");
538+
}
539+
540+
});
541+
});
542+
497543
// 收藏页 取消收藏
498544
$('.article .metatag .collect').on('click', function(evt){
499545
evt.preventDefault();
@@ -504,6 +550,42 @@ jQuery(document).ready(function($) {
504550
});
505551
});
506552

553+
// 提示关注微信公众号
554+
$('.qrcode').on('mouseover', function(evt) {
555+
$('.qrcode-pop').show();
556+
});
557+
$('.qrcode').on('mouseout', function(evt) {
558+
$('.qrcode-pop').hide();
559+
});
560+
561+
// 当前链接的微信二维码
562+
var hadGenQRCode = false;
563+
$('.wechat-btn').on('mouseover', function(evt) {
564+
if (hadGenQRCode) {
565+
$(this).children('img').show();
566+
return;
567+
}
568+
new QRCode(this, {
569+
text: location.href,
570+
width: 256,
571+
height: 256,
572+
});
573+
hadGenQRCode = true;
574+
});
575+
$('.wechat-btn').on('mouseout', function(evt) {
576+
$(this).children('img').hide();
577+
});
578+
579+
// 详情页左侧评论按钮
580+
$('.comment-btn').on('click', function(evt) {
581+
var url = location.href;
582+
if (url.indexOf("#commentForm") == -1) {
583+
location.href = url + "#commentForm";
584+
} else {
585+
location.href = url;
586+
}
587+
});
588+
507589
window.saveComposeDraft = function(uid, keyprefix, objdata) {
508590
var key = keyprefix+':compose:by:' + uid;
509591
lscache.set(key, objdata, 525600);

static/js/libs/qrcode.min.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)