Skip to content

Commit ad65f6c

Browse files
committed
share rel and static html config
1 parent fe9e684 commit ad65f6c

File tree

7 files changed

+743
-2
lines changed

7 files changed

+743
-2
lines changed

_config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ archive_dir: archives
2626
category_dir: categories
2727
code_dir: downloads/code
2828
i18n_dir: :lang
29-
skip_render:
29+
skip_render: [sta/*]
3030

3131
# Writing
3232
new_post_name: :title.md # File name of new posts

source/404.html

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
layout: false
2+
---
3+
4+
<!DOCTYPE html>
5+
<html lang="en">
6+
<head>
7+
<meta charset="UTF-8">
8+
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
9+
<meta http-equiv="Cache-Control" content="no-transform">
10+
<meta http-equiv="Cache-Control" content="no-siteapp">
11+
<meta name="renderer" content="webkit">
12+
<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1">
13+
<meta name="keywords" content="前端,h5,移动端开发,博客">
14+
<meta name="author" content="tiny_may@163.com">
15+
<meta name="description" content="记录前端开发道路上的点点滴滴">
16+
<meta http-equiv="refresh" content="5;http://littlemay.cn">
17+
<title>404页面</title>
18+
<style>
19+
.tip {
20+
text-align: center;
21+
margin-top: 20%;
22+
}
23+
a {
24+
color: red;
25+
}
26+
</style>
27+
</head>
28+
<body>
29+
<p class="tip">哇哦,你好像走错了,<span id="tipInner"><span id="rest">5</span>秒后自动刷新至博客首页~</span></p>
30+
</body>
31+
<script src="http://cdn.66173.cn/www/js/jquery-1.8.3.min.js"></script>
32+
<script>
33+
var rest = document.getElementById("rest");
34+
var tipInner = document.getElementById("tipInner");
35+
var count = 5;
36+
interval1 = setInterval(function() {
37+
if(--count < 1) {
38+
tipInner.innerHTML = '正在跳转至<a href="http://littlemay.cn">博客</a>首页...'
39+
}
40+
else {
41+
rest.innerHTML = count;
42+
}
43+
}, 1000);
44+
</script>
45+
</html>

source/_posts/function.md

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
---
2+
title: 函数之call,apply,arguments,闭包
3+
date: 2017-08-09 11:45:20
4+
description:
5+
categories: 前端
6+
tags: [前端,函数调用]
7+
---
8+
9+
### 函数的实参和形参
10+
- JavaScript 的函数定义不用指定形参的类型
11+
- 调用传入的实参也可以是任意类型
12+
- JavaScript甚至不检查传入实参的个数
13+
#### 可选形参
14+
15+
如果调用函数的时候传入的实参比指定的形参少,剩下的形参都将设置为 undefined 值,通常使用逻辑与运算符给形参指定默认值
16+
```
17+
function getType(type) {
18+
// 如果 type 传入值则使用传入值,否则使用默认值 "normal"
19+
// 通常建议可选参数放在参数列表最后
20+
type = type || 'normal'
21+
// ... the rest code
22+
return type;
23+
}
24+
```
25+
26+
#### 可变长的实参列表:实参对象
27+
- 当调用函数的时候传入实参人个数超过形参个数时(和上面相反),没有办法直接获得未命名值的引用。参数对象解决了这个问题.
28+
- 在函数体内,标识符 arguments 是指向实参对象的引用,参数对象是一个 类数组对象,这样可以通过索引来访问实参了
29+
```
30+
function push(arr /* optional items [, item ... [, item]] */) {
31+
// 注意,arguments是类数组对象,不能直接使用数组的slice方法,而是要通过Array.prototype.slice.call的方式来实现数组剥离操作,后面传入1指取出从arguments数组index为1的开始向后的所有参数,如果是普通的数组,相当于arr1.slice(1)
32+
var items = Array.prototype.slice.call(arguments, 1)
33+
for (var i = 0; i < items.length; i++) {
34+
arr[arr.length] = items[i];
35+
}
36+
}
37+
var arr1 = [1,2,3];
38+
push(arr1, 4,5,6);
39+
arr1 // => [1, 2, 3, 4, 5, 6]
40+
```
41+
- 既然说到类数组对象arguments, 顺便来个类数组对象与数组对象的辨别吧.
42+
1. 类数组有哪些? arguments, NodeList,HTML Collections,字符串
43+
2. 类数组和数组对象都有length属性,可通过Array.prototype.xxx.call(类数组,其他参数1,其他参数2...)的方式调用slice, indexOf, lastIndexOf, forEach方法。不同的类数组会不能使用push, pop, splice, shift等方法的其中几种。
44+
- NodeList,HTML Collections,字符串 只能使用Array.prototype.slice.call(NodeList),上面列举的方法均不能使用
45+
- arguments可通过Array.prototype.xxx.call使用上面列举的方法
46+
#### 闭包
47+
> 词法作用域(lexical scoping)的执行依赖于变量作用域,这个作用域是在函数 定义时 决定的,而不是函数调用时,为了实现这种词法作用域,JavaScript 函数对象的内部状态不仅包含函数的代码逻辑,还必须引用当前的作用域链。函数对象可以通过作用域链相互关联起来,函数体内部的变量都可以保存在函数作用域内,这种特性在计算机科学文献中称为「闭包」
48+
```
49+
// 例 1
50+
var scope = "global scope";
51+
function checkscope() {
52+
var scope = "local scope";
53+
function f() { return scope;}
54+
return f(); //注意这里和例2的区别
55+
}
56+
checkscope(); // => "local scope" 注意这里函数调用和例2的区别
57+
// 例 2
58+
var scope = "global scope";
59+
function checkscope() {
60+
var scope = "local scope";
61+
function f() { return scope;}
62+
return f; //注意这里和例1的区别
63+
}
64+
checkscope()() // => "local scope" 注意这里函数调用和例1的区别
65+
```
66+
- JavaScript 函数的执行用到了作用域链,这个作用域链是函数 定义的时候 创建的,嵌套的函数 f() 定义在这个作用域链里,其中的变量 scope 一定是局部变量,不管在何时执行函数f(),这种绑定在执行 f() 时依然有效。因此最后一行代码返回「local scope」而不是「global scope」。简而言之,闭包的有个强大特性:它可以捕捉到局部变量(和参数),并一直保存下来
67+
68+
##### 趁热打铁,再来举个栗子~
69+
```
70+
function counter() {
71+
var n = 0;
72+
return {
73+
count: function() { return n++ },
74+
reset: function() { n = 0 }
75+
}
76+
}
77+
// 创建两个计数器
78+
var c = counter(), d = counter();
79+
c.count() // => 0 互
80+
c.count() // => 1 不
81+
d.count() // => 0 干
82+
d.count() // => 1 扰
83+
c.reset() // => 0 重置 c
84+
d.count() // => 2 不影响 d
85+
```

source/_posts/hexo-start.md

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,34 @@ hexo n 'article_file_name'
5252
### 文章中插入图片
5353

5454
方法一:使用本地路径:在hexo/source目录下新建一个uploads文件夹,将图片放入该文件夹下,插入图片时链接即为/uploads/图片名称。
55-
方法二:使用微博图床,推荐 [<span style="color:blue">七牛</span>](https://portal.qiniu.com/signup)
55+
方法二:使用微博图床,推荐 [<span style="color:blue">七牛</span>](https://portal.qiniu.com/signup)
56+
57+
### 写不需要模板渲染的静态html页面
58+
假设博客文件名为hexo
59+
60+
方法一:
61+
1,加入要添加static目录,根目录的_config.yml中添加 一行:
62+
skip_render: [static/**],
63+
若有多个可在数组内添加,如 [static/**, some.html]
64+
2, 在hexo/source下新建sta目录,然后再写xxx.html
65+
访问 server_name/static/xxx.html
66+
67+
方法二:
68+
在hexo/source下新建sta2目录,然后再写xxx.html
69+
在html最上面加上两行,如下:
70+
<span style="color:red">注意:layout:与false之间要有空格!!!</span>
71+
```
72+
layout: false
73+
---
74+
75+
<!DOCTYPE>
76+
<html>
77+
....
78+
79+
```
80+
访问 server_name/static/xxx.html
81+
82+
### 生成静态文件时奇怪事件处理
83+
84+
比如,写了个静态html文件,改了名,用 hexo g 时,会生出原来名和现在名两个文件
85+
处理方法: 把根目录下的 db.json文件以及.deploy_git文件夹删了

source/sta/share.html

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
6+
<meta http-equiv="Cache-Control" content="no-transform">
7+
<meta http-equiv="Cache-Control" content="no-siteapp">
8+
<meta name="renderer" content="webkit">
9+
<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1">
10+
<meta name="keywords" content="QQ分享,微信分享,QQ空间分享,h5分享,js分享,移动端分享,社会化分享,自定义分享,自定义分享链接,自定义分享图片">
11+
<meta name="author" content="tiny_may@163.com">
12+
<meta name="description" content="移动端h5页面的QQ分享,微信分享,QQ空间分享中自定义分享图片,自定义分享链接">
13+
<title>share</title>
14+
</head>
15+
<body>
16+
<div>share try, u can set customized share links in QQ,Qzone,Wechat.Remember it need several special authorized strings in Wechat. </div>
17+
</body>
18+
<script type="text/javascript" src="http://qzonestyle.gtimg.cn/qzone/qzact/common/share/share.js"></script>
19+
<script type="text/javascript">
20+
setShareInfo({
21+
title: '父爱,在你看不到的地方',
22+
summary: '父爱如山,感觉不到只因身在此山中',
23+
pic: 'http://qzonestyle.gtimg.cn/aoi/sola/20150617094556_OvfOpoRKRB.png',
24+
url: 'http://littlemay.cn/sta/share.html?a=11',
25+
WXconfig: {
26+
swapTitleInWX: true,
27+
appId: '',
28+
timestamp: '',
29+
nonceStr: '',
30+
signature: ''
31+
}
32+
});
33+
</script>
34+
</html>

source/sta/share2.html

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=0.0, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0, minimal-ui" />
6+
<title>分享</title>
7+
<style type="text/css">
8+
*{margin: 0;padding: 0;}
9+
body{
10+
text-align: center;
11+
}
12+
h1{
13+
text-align: center;
14+
font-size: 30px;
15+
padding: 0 5px;
16+
border-bottom: 3px solid #49b233;
17+
color: #49b233;
18+
display: inline-block;
19+
margin:20px 0;
20+
}
21+
</style>
22+
</head>
23+
<body>
24+
<h1>分享组件Demo</h1>
25+
<div id="share" class="share">
26+
</div>
27+
<script src="./share_app.js"></script>
28+
<script type="text/javascript">
29+
var config = {
30+
url:window.location.host,// 分享的网页链接
31+
title:'分享标题',// 标题
32+
desc:'分享描述',// 描述
33+
img:'https://hbfile.b0.upaiyun.com/img/category_page/2e94335da287cfdfd7990bd88eb8ff37262e322492a5',// 图片
34+
img_title:'图片标题',// 图片标题
35+
from:'振霖', // 来源
36+
apps:['weixin', 'weixintimeline', 'qq', 'qzone', 'weibo', 'yixin'],
37+
//微信config
38+
WXconfig:{
39+
swapTitleInWX: false, // 是否标题内容互换(仅朋友圈,因朋友圈内只显示标题)
40+
appId: 'appId', // 公众号的唯一标识
41+
timestamp: 'timestamp', // 生成签名的时间戳
42+
nonceStr: 'nonceStr', // 生成签名的随机串
43+
signature: 'signature' // 签名
44+
},
45+
//是否采用默认样式,默认true
46+
//defaultStyles: false,
47+
//是否采用自己的图标,默认不采用,不需要配置setIcons
48+
//defaultIcons设置false,进行icon的修改
49+
//setIcons: {
50+
//defaultIcons:false,
51+
//icons:{
52+
//weixin:''
53+
//}
54+
//},
55+
bridgeBrowser:'qqbrowser', //默认ucbrowser
56+
//如果是APP内嵌网页,直接调用本app的分享js接口
57+
//nativeAppJSApi函数内部还需要分享接口是否支持进行判断,如果成功请return
58+
// nativeAppJSApi: function () {
59+
// console.log(1);
60+
// return;
61+
// }
62+
};
63+
var shareApp = new ShareApp('#share',config);
64+
</script>
65+
</body>
66+
</html>

0 commit comments

Comments
 (0)