Skip to content

Commit 0a55c34

Browse files
committed
init
1 parent 1f9a4c6 commit 0a55c34

File tree

18 files changed

+10974
-2
lines changed

18 files changed

+10974
-2
lines changed

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Created by .ignore support plugin (hsz.mobi)
2+
node_modules/
3+
www/
4+
dist/
5+
.DS_Store
6+
.idea/

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
# pc
2-
circling.cc
1+
# pc

common/cookie.js

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
/*!
2+
* jQuery Cookie Plugin v1.4.1
3+
* https://github.com/carhartl/jquery-cookie
4+
*
5+
* Copyright 2013 Klaus Hartl
6+
* Released under the MIT license
7+
*/
8+
9+
export default function ($) {
10+
11+
var pluses = /\+/g;
12+
13+
function encode(s) {
14+
return config.raw ? s : encodeURIComponent(s);
15+
}
16+
17+
function decode(s) {
18+
return config.raw ? s : decodeURIComponent(s);
19+
}
20+
21+
function stringifyCookieValue(value) {
22+
return encode(config.json ? JSON.stringify(value) : String(value));
23+
}
24+
25+
function parseCookieValue(s) {
26+
if (s.indexOf('"') === 0) {
27+
// This is a quoted cookie as according to RFC2068, unescape...
28+
s = s.slice(1, -1).replace(/\\"/g, '"').replace(/\\\\/g, '\\');
29+
}
30+
31+
try {
32+
// Replace server-side written pluses with spaces.
33+
// If we can't decode the cookie, ignore it, it's unusable.
34+
// If we can't parse the cookie, ignore it, it's unusable.
35+
s = decodeURIComponent(s.replace(pluses, ' '));
36+
return config.json ? JSON.parse(s) : s;
37+
} catch(e) {}
38+
}
39+
40+
function read(s, converter) {
41+
var value = config.raw ? s : parseCookieValue(s);
42+
return $.isFunction(converter) ? converter(value) : value;
43+
}
44+
45+
var config = $.cookie = function (key, value, options) {
46+
47+
// Write
48+
49+
if (value !== undefined && !$.isFunction(value)) {
50+
options = $.extend({}, config.defaults, options);
51+
52+
if (typeof options.expires === 'number') {
53+
var days = options.expires, t = options.expires = new Date();
54+
t.setTime(+t + days * 864e+5);
55+
}
56+
57+
return (document.cookie = [
58+
encode(key), '=', stringifyCookieValue(value),
59+
options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
60+
options.path ? '; path=' + options.path : '',
61+
options.domain ? '; domain=' + options.domain : '',
62+
options.secure ? '; secure' : ''
63+
].join(''));
64+
}
65+
66+
// Read
67+
68+
var result = key ? undefined : {};
69+
70+
// To prevent the for loop in the first place assign an empty array
71+
// in case there are no cookies at all. Also prevents odd result when
72+
// calling $.cookie().
73+
var cookies = document.cookie ? document.cookie.split('; ') : [];
74+
75+
for (var i = 0, l = cookies.length; i < l; i++) {
76+
var parts = cookies[i].split('=');
77+
var name = decode(parts.shift());
78+
var cookie = parts.join('=');
79+
80+
if (key && key === name) {
81+
// If second argument (value) is a function it's a converter...
82+
result = read(cookie, value);
83+
break;
84+
}
85+
86+
// Prevent storing a cookie that we couldn't decode.
87+
if (!key && (cookie = read(cookie)) !== undefined) {
88+
result[name] = cookie;
89+
}
90+
}
91+
92+
return result;
93+
};
94+
95+
config.defaults = {};
96+
97+
$.removeCookie = function (key, options) {
98+
if ($.cookie(key) === undefined) {
99+
return false;
100+
}
101+
102+
// Must not alter options, thus extending a fresh object...
103+
$.cookie(key, '', $.extend({}, options, { expires: -1 }));
104+
return !$.cookie(key);
105+
};
106+
107+
}

common/dev.js

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
/**
2+
* Created by army8735 on 2017/9/15.
3+
*/
4+
5+
import $ from 'anima-yocto-ajax';
6+
import qs from 'anima-querystring';
7+
8+
export default {
9+
ajax: function(url, data, success, error, type) {
10+
// 兼容无host
11+
if (!/^http(s)?:\/\//.test(url)) {
12+
url = 'http://192.168.0.3:8080/' + url.replace(/^\//, '');
13+
// url = '/' + url.replace(/^\//, '');
14+
}
15+
// console.log('ajax: ' + url + ', ' + JSON.stringify(data));
16+
function load() {
17+
return $.ajax({
18+
url: url,
19+
data: data,
20+
dataType: 'json',
21+
cache: false,
22+
crossDomain: true,
23+
timeout: 6000,
24+
type: type || 'get',
25+
// ajax 跨域设置必须加上
26+
beforeSend: function (xhr) {
27+
xhr.withCredentials = true;
28+
},
29+
success: function (data, state, xhr) {
30+
success(data, state, xhr);
31+
},
32+
error: function (data) {
33+
// console.error('ajax error: ' + url + ', ' + JSON.stringify(data));
34+
if(!error.__hasExec) {
35+
error.__hasExec = true;
36+
error(data || {});
37+
}
38+
}
39+
});
40+
}
41+
return load();
42+
},
43+
getUrl: function(url) {
44+
if(/^\/works\/v\d+\/\d+$/.test(url)) {
45+
let id = /^\/works\/v\d+\/(\d+)$/.exec(url)[1];
46+
url = 'works.html?' + id;
47+
}
48+
else if(/^\/author\/v\d+\/\d+$/.test(url)) {
49+
let id = /^\/author\/v\d+\/(\d+)$/.exec(url)[1];
50+
url = 'author.html?' + id;
51+
}
52+
else if(/^\/(?:follow)|(?:zhuanquan)|(?:find)|(?:my)$/.test(url)) {
53+
let name = /^\/(?:follow)|(?:zhuanquan)|(?:find)|(?:my)$/.exec(url)[0];
54+
url = name + '.html';
55+
}
56+
else if(/^\/search(\/.*)?/.test(url)) {
57+
let kw = /^\/search(\/.*)?/.exec(url)[1] || '';
58+
url = 'search.html?' + kw.slice(1);
59+
}
60+
return url;
61+
}
62+
};
63+
64+
let url = location.href;
65+
if(/\/works\.html\?\d+$/.test(url)) {
66+
let id = /\/works\.html\?(\d+)$/.exec(url)[1];
67+
window.workID = id;
68+
}
69+
else if(/\/author\.html\?\d+$/.test(url)) {
70+
let id = /\/author\.html\?(\d+)$/.exec(url)[1];
71+
window.authorID = id;
72+
}
73+
else if(/\/search\.html\?(.*)$/.test(url)) {
74+
let kw = /\/search\.html\?(.*)$/.exec(url)[1];
75+
window.kw = decodeURIComponent(kw);
76+
}

common/global.jsx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/**
2+
* Created by army8735 on 2017/9/18.
3+
*/
4+
5+
import MLogin from '../component/mlogin/MLogin.jsx';
6+
7+
let mlogin;
8+
9+
migi.eventBus.on('NEED_LOGIN', function() {
10+
if(!mlogin) {
11+
mlogin = migi.render(
12+
<MLogin/>,
13+
document.body
14+
);
15+
}
16+
mlogin.show();
17+
});

common/index.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/**
2+
* Created by army on 2017/3/19.
3+
* For my goddess.
4+
*/
5+
6+
import 'migi-es6-shim';
7+
import 'migi';
8+
import $ from 'jquery-3.2.1';
9+
import cookie from './cookie';
10+
import util from './util';
11+
import './global.jsx';
12+
13+
import './index.less';
14+
15+
cookie($);
16+
17+
window.requestAnimationFrame = function() {
18+
return window.requestAnimationFrame
19+
|| window.webkitRequestAnimationFrame
20+
|| window.mozRequestAnimationFrame
21+
|| function(callback) {
22+
window.setTimeout(callback, 16.7);
23+
};
24+
}();
25+
26+
window.$ = $;
27+
window.util = util;

0 commit comments

Comments
 (0)