Authored by ityuany

格式化

... ... @@ -11,6 +11,7 @@ const watcher = {
};
let renderer;
let realyPromise;
if (cluster.isMaster) {
... ...
... ... @@ -5,6 +5,7 @@ const stringify = function(list) {
for (let i = 0; i < list.length; i++) {
let obj = list[i];
let params = [];
for (let prop in obj) {
... ...
... ... @@ -37,6 +37,7 @@ export const throttle = (delay, action) => { // 函数节æµå™¨ï¼Œå®šä¹‰å‡½æ•°æ‰
return function() {
let args = arguments;
let curr = +new Date();
if (curr - last > delay) {
... ...
... ... @@ -13,6 +13,7 @@
const nullFun = () => {};
let isYohoBuy = /YohoBuy/i.test(navigator.userAgent || '');
let $appLink = document.querySelector('#yoho-app-link');
if (isYohoBuy && !$appLink) {
... ...
... ... @@ -157,6 +157,7 @@ export default {
},
async fetchComments(pre) {
const result = await this.fetchCommentsAsync(pre);
let dirty = true;
if (result.code === 200) {
... ... @@ -181,6 +182,7 @@ export default {
if (this.commentId) {
setTimeout(() => {
let scrollHeight = this.$refs.scroll.$el.offsetHeight;
let dom = this.$refs.commentList.getElementsByClassName('comment-' + this.commentId);
if (scrollHeight && dom.length && (dom[0].offsetHeight + dom[0].offsetTop > scrollHeight)) {
... ...
... ... @@ -225,7 +225,9 @@ export default {
// update item height
let increHeight = 0;
let cur = this.items[index];
let dom = this.$refs[`loads${cur.index}`];
try {
... ... @@ -262,6 +264,7 @@ export default {
},
updateIndex(scrollTop) {
let top = scrollTop;
let hasTopItem = false;
for (let i = 0; i < this.items.length; i++) {
... ...
... ... @@ -209,7 +209,9 @@ export default {
this.$nextTick(() => {
for (let i = 0; i < this.cols; i++) {
let loop = true;
let col = this[this.colPrefix + i];
let k = col.length - 1;
while (loop) {
... ... @@ -282,6 +284,7 @@ export default {
},
updateCurrentItems(scrollTop) {
let top = scrollTop - this.$refs.eternal.offsetHeight;
let arr = [];
for (let i = 0; i < this.cols; i++) {
... ... @@ -290,7 +293,9 @@ export default {
},
updateColumnCurrentItems(index, top) {
let col = this[this.colPrefix + index];
let startIndex = this.startIndexs[index];
let hasTopItem = false;
for (let i = 0; i < col.length; i++) {
... ...
... ... @@ -60,8 +60,11 @@ export default {
limitShow() {
this.$nextTick(() => {
let textDom = this.$el.querySelector('.text-ellipsis-limit-text');
let title = this.$el;
let more = this.$el.querySelector('.h-text-ellipsis-more');
let n = 1000;
if (textDom) {
... ...
... ... @@ -163,8 +163,11 @@ export default {
// ios 退出全屏自动播放
if (this.$yoho.isiOS && versionCompare(this.$yoho.appVersion, '6.9.7') > 0) {
let changeTime = this.getTime();
let playTime = this.player._yohoPlayTime || 0;
let pauseTime = this.player._yohoPauseTime || 0;
let endedTime = this.player._yohoEndedTime || 0;
if ((changeTime - pauseTime) < 600 && pauseTime > playTime && playTime > endedTime) {
... ...
... ... @@ -34,6 +34,7 @@ export default {
computed: {
avatarList() {
let list = [];
let length = this.avatars && this.avatars.length;
if (this.option.maxDisplayNum > 0 && this.avatars.length > this.option.maxDisplayNum) {
... ... @@ -43,6 +44,7 @@ export default {
for (let i = 0; i < length; i++) {
let avt = this.avatars[i];
let src = avt;
if (this.option.srcKey && typeof avt !== 'string') {
... ...
... ... @@ -28,6 +28,7 @@ const directive = {
return;
}
const home = document.createComment('');
let hasMovedOut = false;
if (value !== false) {
... ...
... ... @@ -59,6 +59,7 @@ export default {
});
let list = [];
let end = false;
if (result.code === 200) {
... ...
... ... @@ -94,6 +94,7 @@ export default {
if (!this.$yoho.isApp) {
let shareImage = '';
let shareIntro = '';
get(first, 'blockList', []).forEach(block => {
... ...
... ... @@ -70,6 +70,7 @@ export default {
},
isEllipsis() {
let line = 0;
let textArr = [];
forEach(this.trimIntro, (val) => {
... ...
... ... @@ -128,7 +128,9 @@ export default {
dotClass(current, inx) {
const offset = 1;
const len = this.data.blockList.length;
let left = current - offset;
let right = current + offset;
if (left < 0) {
... ...
... ... @@ -278,6 +278,7 @@ export default {
},
startReportShow() {
let preview = null;
let name = this.$yoho.isiOS ? 'iFP_ArticleList' : 'aFP_ArticleList';
return (index, item) => {
... ...
... ... @@ -52,6 +52,7 @@ export default {
},
showIntro() {
let line = 0;
let textArr = [];
forEach(this.trimIntro, (val) => {
... ...
... ... @@ -22,6 +22,7 @@ export default {
{name: '最新', type: 2},
{name: '热门', type: 1},
];
let index = Math.max(findIndex(tabList, {type: this.activeType}), 0);
return {
... ...
... ... @@ -244,6 +244,7 @@ export default {
this.tabFixed = animePlayed;
let start;
let self = this;
function step(timestamp) {
... ... @@ -323,6 +324,7 @@ export default {
}
let info = this.fetchInfo[this.activeIndex] || {};
let result;
info.page = info.page || 1;
... ... @@ -408,6 +410,7 @@ export default {
},
toPage(type) {
let routerName = '';
let params = {};
if (type) {
... ... @@ -442,6 +445,7 @@ export default {
this._preReportArticles = this._preReportArticles || {};
let reportArticles = {};
let articles = [];
items.forEach((item, index) => {
... ...
... ... @@ -22,6 +22,7 @@ export default {
{name: '用户', type: 1},
{name: '话题', type: 0},
];
let index = Math.max(findIndex(tabList, {type: this.activeType}), 0);
return {
... ...
... ... @@ -58,10 +58,12 @@ export default {
methods: {
getCoverImgWidth() {
let imgWidth = this.$el.offsetWidth / this.cols;
let $item = this.$el.getElementsByClassName('sr-temp');
if ($item && $item.length) {
let _w = $item[0].offsetWidth;
let $img = $item[0].children;
(_w > 0) && (imgWidth = _w);
... ... @@ -88,6 +90,7 @@ export default {
});
let minHeight = Math.min.apply(null, this.colsHeight);
let minIndex = this.colsHeight.indexOf(minHeight);
let end = 1;
... ...
... ... @@ -3,7 +3,9 @@ import {isArray} from 'lodash';
export default {
install(Vue) {
let promptVM = null;
let promptEle = null;
let timer = null;
function createPromptVM(parent) {
... ...
... ... @@ -25,6 +25,7 @@ const setWxShareData = function(shareInfo) {
function loadScript(url, success) {
const head = document.getElementsByTagName('head')[0];
let script = document.createElement('script');
script.type = 'text/javascript';
... ... @@ -41,6 +42,7 @@ function loadScript(url, success) {
function jsonp(url, data = {}) {
return new Promise((resolve) => {
let JSONP = document.createElement('script');
let query = [];
data.callback = 'jsonCallBack';
... ...
... ... @@ -20,6 +20,7 @@ let crc32 = function(str, crc) {
// crc = 0;
// }
let n = 0; // a number between 0 and 255
let x = 0; // an hex number
crc = crc ^ (-1);
... ... @@ -33,7 +34,9 @@ let crc32 = function(str, crc) {
function getDomain(bucket, filename) {
let domain = '';
let node = '';
let domainL, nodeNum;
if (domainList[bucket]) {
... ... @@ -81,7 +84,9 @@ function productGlobalUrl(skn) {
export function processArticleDetail(articleContent) {
let finalDetail = [];
let allgoods = {id: [], skn: []};
let recommends = [];
for (let value of articleContent) {
... ... @@ -97,7 +102,9 @@ export function processArticleDetail(articleContent) {
// 一张图
if (get(value, 'singleImage.data.length', false)) {
let tagList = get(value, 'singleImage.data[0].tagList', []);
let tagListGlobal = get(value, 'singleImage.data[0].tagListGlobal', []);
let tagListLimit = get(value, 'singleImage.data[0].tagListLimit', []);
// 普通商品
... ... @@ -155,7 +162,9 @@ export function processArticleDetail(articleContent) {
get(value, 'goods.dataGlobal', false) ||
get(value, 'goods.dataLimit', false)) {
let goodsData = get(value, 'goods.data', []);
let goodsDataGlobal = get(value, 'goods.dataGlobal', []);
let goodsDataLimit = get(value, 'goods.dataLimit', []);
// 普通商品
... ... @@ -204,7 +213,9 @@ export function processArticleDetail(articleContent) {
// 推荐商品
if (get(value, 'recommend_products', false)) {
let recommendProducts = get(value, 'recommend_products.data', []);
let recommendProductsGlobal = get(value, 'recommend_products.dataGlobal', []);
let recommendProductsLimit = get(value, 'recommend_products.dataLimit', []);
recommendProducts.forEach(p => {
... ...
export const calcPx = (px) => {
const clientWidth = document.body.clientWidth;
let fz;
if (clientWidth > 750) {
... ...
... ... @@ -23,6 +23,7 @@ export function getArticleImageSize({width, height, minScale = 0.75, maxWidth =
export function processImage(src, mode, width, height, webp) {
let splits = (src || '').split('?');
const imgName = splits[0] || '';
let query = splits[1] || '';
if (!src || src.indexOf('{width}') < 0) {
... ...
... ... @@ -17,6 +17,7 @@ const setStatusBar = (width, height, store) => {
// 仅支持ios
if (yoho.isYohoBuy && yoho.isiOS) {
let isX = (height / width) > 2.1;
let actionBarHeight = isX ? 32 : 0;
statusBar.statusBarHeight = isX ? 44 : 22;
... ...
... ... @@ -15,6 +15,7 @@ function handleProtocol(url) {
const getDetailShareData = (article) => {
let shareImage = '';
let desc = '';
if (article.sort === 2) {
... ...
... ... @@ -3,10 +3,13 @@ const path = require('path');
const MFS = require('memory-fs');
const webpackDevMiddleware = require('webpack-dev-middleware');
const webpackHotMiddleware = require('webpack-hot-middleware');
let clientConfig = require('./webpack.client.conf.js');
let serverConfig = require('./webpack.server.conf.js');
let devMiddleware;
let hotMiddleware;
const _readFile = (fs, file) => {
... ... @@ -30,9 +33,11 @@ exports.publish = (data) => {
exports.devServer = (app, cb) => {
let resolve;
let realyPromise = new Promise(r => {
resolve = r;
});
let ready = (...args) => {
resolve();
cb(...args);
... ... @@ -77,6 +82,7 @@ exports.devServer = (app, cb) => {
app.use(hotMiddleware);
const serverCompiler = webpack(serverConfig);
let mfs = new MFS();
serverCompiler.outputFileSystem = mfs;
... ...
... ... @@ -31,6 +31,7 @@ new Promise(resolve => { // 加载manifest.json文件
}).then(() => { // 拷贝node代码
cpPaths.forEach(p => {
let dist = distDir;
let file = p;
if (typeof p === 'object') {
... ...
... ... @@ -9,6 +9,7 @@ const VueSSRClientPlugin = require('vue-server-renderer/client-plugin');
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin');
const CopyPlugin = require('copy-webpack-plugin');
let baseConfig = require('./webpack.base.conf');
const isProd = process.env.NODE_ENV === 'production';
... ...
... ... @@ -2,6 +2,7 @@ const webpack = require('webpack');
const merge = require('webpack-merge');
const nodeExternals = require('webpack-node-externals');
const VueSSRServerPlugin = require('vue-server-renderer/server-plugin');
let baseConfig = require('./webpack.base.conf');
const isProd = process.env.NODE_ENV === 'production';
... ...
... ... @@ -7,6 +7,7 @@ const yohoLib = require('yoho-node-lib');
const pkg = require('./package.json');
const devtools = require('./doraemon/middleware/devtools');
const _ = require('lodash');
let pkgJson;
// 全局注册library
... ...
'use strict';
const fs = require('fs');
let devHost = 'm.yohoblk.com';
fs.readFile('.devhost', (err, buf)=> {
... ...
... ... @@ -9,6 +9,7 @@ const qiniuYohoCdnConfig = global.yoho.config.qiniuYohoCdn;
function getToken(req, res) {
let conf = qiniuConfig;
let type = req.query.type || '';
if (type.toLowerCase() === 'yohocdn') {
... ... @@ -16,10 +17,13 @@ function getToken(req, res) {
}
let mac = new qiniu.auth.digest.Mac(conf.ACCESS_KEY, conf.SECRET_KEY);
let options = {
scope: conf.BUCKET_NAME
};
let putPolicy = new qiniu.rs.PutPolicy(options);
let uploadToken = putPolicy.uploadToken(mac);
res.json({
... ...
... ... @@ -37,6 +37,7 @@ module.exports = async(req, res, next) => {
const reqParams = Object.assign({}, req.query, req.body, baseParams);
const params = checkParams.getParams(reqParams, apiInfo, req);
const cache = (req.method.toLowerCase() !== 'get' || apiInfo.auth) ? false : apiInfo.cache;
let method = req.method.toLowerCase() === 'post' ? 'post' : 'get';
let result;
... ...
... ... @@ -16,7 +16,9 @@ const config = global.yoho.config;
const isDev = process.env.NODE_ENV === 'development' || !process.env.NODE_ENV;
let renderer;
let serverBundle;
let degradeHtml;
const hbs = fs.readFileSync(path.join(__dirname, '../views/index.hbs'), 'utf-8');
... ... @@ -100,6 +102,7 @@ const getChannel = (yoho) => {
const getCacheKey = (req, route) => {
const urlObj = url.parse(req.url);
let ck = urlObj.pathname;
if (route.query) {
... ... @@ -154,10 +157,14 @@ const render = (route) => {
return handlerError(err, req, res, next);
}
let styles = context.renderStyles();
let scripts = context.renderScripts();
let resources = context.renderResourceHints();
const states = context.renderState();
let asyncScripts;
let zk = {
asyncJs: _.get(req.app.locals.wap, 'webapp.ios-async-js', true)
};
... ...
... ... @@ -3,6 +3,7 @@ const md5 = require('md5');
const microtime = function() {
let unixtimeMs = new Date().getTime();
let sec = parseInt(unixtimeMs / 1000, 10);
return (unixtimeMs - (sec * 1000)) / 1000 + ' ' + sec;
... ... @@ -62,6 +63,7 @@ module.exports = function(str, key, expiry, operation) {
let box = new Array(256);
let rndkey = [];
for (let i = 0; i < 256; i++) {
... ...
... ... @@ -10,6 +10,7 @@ const simpleCheckRE = /^(String|Number|Boolean|Function|Symbol)$/;
const assetType = (value, type) => {
const expectedType = getType(type);
let valid;
if (simpleCheckRE.test(expectedType)) {
... ...
... ... @@ -3,6 +3,7 @@ const _ = require('lodash');
module.exports = (result, apiInfo) => {
if (result.code === 200 && _.isObject(apiInfo.fields)) {
let resData = result.data || {};
let data = {};
_.forEach(apiInfo.fields, (v, k) => {
... ...
... ... @@ -12,8 +12,11 @@ module.exports = {
image2: function(imageUrl, opts) {
if (imageUrl && _.isString(imageUrl)) {
let params = opts.hash;
let urls = imageUrl.split('?');
let query = urls[1] || '';
let uri = urls[0];
if (uri.indexOf('http:') === 0) {
... ...
... ... @@ -3,6 +3,7 @@ const _ = require('lodash');
const redis = require('redis');
const bluebird = require('bluebird');
const config = require('../config/common');
let client;
const timeout = 200; // redis 操作超时时间
... ...
... ... @@ -13,6 +13,7 @@ const encode = _.memoize(_encode);
function getRouter(req) {
let route = req.route ? req.route.path : '';
let appPath = req.app.mountpath;
if (_.isArray(route) && route.length > 0) {
... ...