diff --git a/app.js b/app.js index e446783..4d4994f 100644 --- a/app.js +++ b/app.js @@ -150,7 +150,7 @@ app.use('/weibo', weibo); app.use('/ranking', ranking); app.use('/v1', v1); -app.use('/about.html', function(req, res, next) { +app.get('/about.html', function(req, res, next) { res.render('about'); }); /** diff --git a/robots.txt b/robots.txt new file mode 100644 index 0000000..301e448 --- /dev/null +++ b/robots.txt @@ -0,0 +1,2 @@ +User-Agent: * +Allow: / \ No newline at end of file diff --git a/static/css/main.css b/static/css/main.css index 00b55c5..aacfa32 100644 --- a/static/css/main.css +++ b/static/css/main.css @@ -212,10 +212,13 @@ .detail .preview img { width: 0; height: 0; - position: absolute; border: 0; } +.detail .preview .progressive { + background: transparent; +} + .detail .preview .options { font-size: .12rem; padding: .1rem; @@ -224,6 +227,9 @@ text-align: right; -webkit-transition: all .5s ease; transition: all .5s ease; + position: absolute; + right: 0; + top: 0; } .detail .preview .ctrl { diff --git a/views/detail.pug b/views/detail.pug index 5df0d1d..3251b89 100644 --- a/views/detail.pug +++ b/views/detail.pug @@ -7,13 +7,17 @@ html(lang="en") - location = doc.continent ? (location ? doc.continent + ', ' + location : doc.continent) : location; meta(name="keywords",content=`${doc.copyright}, ${doc.title}, ${location}`) meta(name="description",content=`${doc.description}`) + link(rel='stylesheet',href="/static/css/progressively.css") link(rel='stylesheet', href='/static/css/common.css') link(rel='stylesheet', href='/static/css/main.css') + style. + body.detail div.preview - var small = doc.photo; - img.target(src=`https://static.ioliu.cn/bing/${small}_1920x1080.jpg?imageView2/1/w/19/h/11/q/100`,data-src=`https://static.ioliu.cn/bing/${small}_1920x1080.jpg`) + div.progressive + img.target.progressive__img.progressive--not-loaded(src=`https://static.ioliu.cn/bing/${small}_1920x1080.jpg?imageView2/1/w/19/h/11/q/100`,data-progressive=`https://static.ioliu.cn/bing/${small}_1920x1080.jpg`) div.mark div.options a.ctrl.left(href=`${doc.back_url}`) @@ -39,26 +43,36 @@ body.detail em.t #{location} script(src='/static/js/jquery-1.12.4.min.js') + script(src='/static/js/progressively.js') script(src='/static/js/baidu-analysis.js') script(src='/static/js/like.js') //- script(data-no-instant,src="/static/js/instantclick.min.js") //- script(data-no-instant,src="/static/js/mine-instantclick.js") script. $(function() { + var i=0; var img = $('.target'); var mini = img.attr('src'); - var big = img.attr('data-src'); var mark = $('.mark'); mark.css({ 'background-image': `url(${mini})` }); - img = img[0]; - img.src = big; - img.onload = function() { - mark.css({ - backgroundImage: `url(${big})`, - filter: 'blur(0)' - }); - img.remove(); - } + progressively.init({ + delay: 20, + throttle: 300, + onLoad: function(elem) { + }, + onLoadComplete: function() { + i++; + if(i>=2){ + var big = img.attr('src'); + mark.css({ + backgroundImage: `url(${big})`, + filter: 'blur(0)' + }); + img.remove(); + } + } + }); + }); \ No newline at end of file