├── .DS_Store ├── .babelrc ├── .editorconfig ├── .eslintignore ├── .eslintrc.js ├── .gitignore ├── .postcssrc.js ├── LICENSE ├── README.md ├── build ├── build.js ├── check-versions.js ├── logo.png ├── utils.js ├── vue-loader.conf.js ├── webpack.base.conf.js ├── webpack.dev.conf.js ├── webpack.prod.conf.js └── webpack.test.conf.js ├── config ├── dev.env.js ├── index.js └── prod.env.js ├── docs ├── CNAME ├── index.html └── static │ ├── css │ └── app.c652d09600bb3bf6c6826d17b4079e7b.css │ ├── img │ ├── hot.7423050.png │ ├── loading.70b31c2.gif │ └── loading.c6bc779.png │ └── js │ ├── 1.cca03e78bdaa28536dcd.js │ ├── 2.56e6ec2d93a63493ed30.js │ ├── 3.18da567097ad9b9cac29.js │ ├── 4.cd24d4e14760bcab3fe3.js │ ├── amfe-flexible.min.js │ ├── app.10893d4d7c15b8d09949.js │ ├── manifest.3d15a8c1b518e48f0f2d.js │ ├── vendor-async.5a41dcff90d51eb3408a.js │ └── vendor.4a0a8e13ec84c598bf80.js ├── index.html ├── mint-ui.common.js ├── package-lock.json ├── package.json ├── screenshots ├── .DS_Store ├── web_QRcode.png ├── web_detail.png ├── web_index.png ├── web_search.png └── web_search2.png ├── src ├── App.vue ├── assets │ ├── css │ │ ├── global.css │ │ ├── icon.css │ │ ├── reset.css │ │ └── transition.css │ ├── fonts │ │ ├── icomoon.eot │ │ ├── icomoon.svg │ │ ├── icomoon.ttf │ │ └── icomoon.woff │ └── img │ │ ├── back-black.png │ │ ├── back-white.png │ │ ├── back_right.png │ │ ├── close-black.png │ │ ├── close-white.png │ │ ├── close.png │ │ ├── collect-active.png │ │ ├── collect.png │ │ ├── comment.png │ │ ├── cover_bg.png │ │ ├── downLoad.png │ │ ├── edit-black.png │ │ ├── edit-white.png │ │ ├── goTop.png │ │ ├── header_back.png │ │ ├── hot.png │ │ ├── icon-refresh.png │ │ ├── loading.gif │ │ ├── loading.png │ │ ├── loading_logo.png │ │ ├── menu.png │ │ ├── menu_more.png │ │ ├── more.png │ │ ├── myColorp.png │ │ ├── myLogin.png │ │ ├── news_logo.png │ │ ├── qq.png │ │ ├── qq_1.png │ │ ├── qzone.png │ │ ├── repeat.png │ │ ├── search.png │ │ ├── shadow.png │ │ ├── share.png │ │ ├── sina_wb.png │ │ ├── wx_1.png │ │ ├── wx_2.png │ │ ├── wx_friend.png │ │ └── wx_pyq.png ├── components │ ├── banner.vue │ ├── commentItem.vue │ ├── error.vue │ ├── info.vue │ ├── listItem.vue │ ├── loading.vue │ ├── myHeader.vue │ └── popupMenu.vue ├── directives │ ├── goTop.js │ ├── index.js │ └── swiper.js ├── main.js ├── page │ ├── detail │ │ ├── components │ │ │ ├── article.vue │ │ │ ├── recommend.vue │ │ │ ├── share.vue │ │ │ └── tags.vue │ │ └── detail.vue │ ├── index │ │ ├── children │ │ │ └── channel.vue │ │ ├── components │ │ │ ├── index_footer.vue │ │ │ ├── index_header.vue │ │ │ ├── pullContainer.vue │ │ │ └── swiperContainer.vue │ │ └── index.vue │ └── search │ │ └── search.vue ├── router │ └── index.js ├── store │ ├── detail │ │ └── index.js │ ├── index.js │ ├── index │ │ └── index.js │ └── search │ │ └── index.js └── utils │ ├── cache.js │ └── request.js └── static ├── .gitkeep └── js └── amfe-flexible.min.js /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uncleLian/vue2-news/1c198d96059b6c51d78259d45ce2bc563df305b7/.DS_Store -------------------------------------------------------------------------------- /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | ["env", { 4 | "modules": false, 5 | "targets": { 6 | "browsers": ["> 1%", "last 2 versions", "not ie <= 8"] 7 | } 8 | }], 9 | "stage-2" 10 | ], 11 | "plugins": ["transform-runtime"], 12 | "env": { 13 | "test": { 14 | "presets": ["env", "stage-2"], 15 | "plugins": ["istanbul"] 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | charset = utf-8 5 | indent_style = space 6 | indent_size = 2 7 | end_of_line = lf 8 | insert_final_newline = true 9 | trim_trailing_whitespace = true 10 | -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | build/*.js 2 | config/*.js 3 | -------------------------------------------------------------------------------- /.eslintrc.js: -------------------------------------------------------------------------------- 1 | // https://eslint.org/docs/user-guide/configuring 2 | 3 | module.exports = { 4 | root: true, 5 | parser: 'babel-eslint', 6 | parserOptions: { 7 | sourceType: 'module' 8 | }, 9 | env: { 10 | browser: true, 11 | }, 12 | // https://github.com/standard/standard/blob/master/docs/RULES-en.md 13 | extends: 'standard', 14 | // required to lint *.vue files 15 | plugins: [ 16 | 'html' 17 | ], 18 | // add your custom rules here 19 | 'rules': { 20 | // allow paren-less arrow functions 21 | 'arrow-parens': 0, 22 | // allow async-await 23 | 'generator-star-spacing': 0, 24 | // allow debugger during development 25 | 'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0, 26 | 'no-undef': 0, 27 | 'indent': 0, 28 | 'camelcase': 0, 29 | 'space-before-function-paren':0 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules/ 3 | dist/ 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | package-lock.json 8 | 9 | # Editor directories and files 10 | .idea 11 | .vscode 12 | *.suo 13 | *.ntvs* 14 | *.njsproj 15 | *.sln 16 | .DS_Store 17 | -------------------------------------------------------------------------------- /.postcssrc.js: -------------------------------------------------------------------------------- 1 | // https://github.com/michael-ciniawsky/postcss-load-config 2 | 3 | module.exports = { 4 | "plugins": { 5 | // to edit target browsers: use "browserslist" field in package.json 6 | "autoprefixer": {} 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 uncleLian 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # vue2-news 2 | ![image](https://img.shields.io/badge/vue-2.5.13-blue.svg) 3 | ![image](https://img.shields.io/badge/vue--router-3.0.1-blue.svg) 4 | ![image](https://img.shields.io/badge/vuex-3.0.1-blue.svg) 5 | ![image](https://img.shields.io/badge/mint--ui-2.2.13-blue.svg) 6 | 7 | ## 公告 8 | - API 接口已失效‼️ 9 | - 原项目已拆分,此仓库保留今日头条(web端代码),[native端代码,请戳这里](https://github.com/uncleLian/vue2-native) 10 | 11 | ## 简介 12 | vue2-news 是一个仿今日头条移动端的项目,共4个页面,涉及文章的分类、展示、阅读、推荐、搜索等。 13 | 14 | ## 说明 15 | > 如果此开源系列对你有帮助,你可以点右上角 "star"支持一下,非常感谢!^_^ 🌹 16 | 17 | > 或者您可以 "follow(关注)" 一下作者,我正在不断开源更多实用的项目 18 | 19 | > 如有问题可以直接在 Issues 中提,或者加入我们下方Vue群更进一步地交流 20 | 21 | ## 最终目标 22 | Vue学习系列 23 | - 第一阶段:[vue2-echo](https://github.com/uncleLian/vue2-echo) —— echo回声( 移动端,难度:★★☆☆☆ 入门项目, 推荐 ⭐️⭐️⭐️️⭐️⭐️) 24 | - 第二阶段:[vue2-news](https://github.com/uncleLian/vue2-news) —— 今日头条( 移动端,难度:★★★☆☆ 过渡项目) 25 | - 第三阶段:[vue2-health](https://github.com/uncleLian/vue2-health) —— 头条号( pc端,难度:★★★☆☆ 过渡项目) 26 | - 第四阶段:[vue2-native](https://github.com/uncleLian/vue2-native) —— 今日头条( native端,难度:★★★★☆ 进阶项目,可跳过) 27 | - 第五阶段:[vue-blog](https://github.com/uncleLian/vue-blog) —— 后台管理集成解决方案( pc端管理后台,难度:★★★★★ 进阶项目,推荐 ⭐️⭐️⭐️️⭐️⭐️️️️) 28 | 29 | ##### 注:此系列只关注前端项目的实现,后端等知识不是此系列的范围,但会告知一二。 30 | 31 | ## 注意 32 | 33 | > 1、本地运行项目请把项目里的mint-ui.common.js文件替换掉 node_modules/minit-ui/lib/mint-ui.common.js文件。主要优化下拉动作和左右滑动的体验。 34 | 35 | > 2、下载App安装包请使用手机浏览器下载。 36 | 37 | ## 项目演示 38 | 39 | [ 在线链接 ](http://toutiao.liansixin.win)(请使用手机模式预览) 40 | 41 | 42 | 43 | ## 功能 44 | 45 | - [x] 下拉上滑查看更多内容 46 | - [x] 左右滑动切换栏目列表 47 | - [x] 点击头部回到顶部(指令) 48 | - [x] 右滑返回上一页(指令) 49 | - [x] 视频播放的加载、重播指示以及悬浮等功能 50 | - [x] 热点文章和搜索推荐(后台算法) 51 | - [x] 文章标签(后台算法) 52 | - [x] 分享 53 | - [x] 搜索(关键字高亮显示) 54 | - [x] 刷新保持页面的数据和状态 55 | - [x] 展开全文 56 | - [x] 下载页(目前只支持下载Android包) 57 | 58 | ## 部分截图 59 | 60 | - 首页、详情页 61 | 62 | 63 | 64 | - 搜索页 65 | 66 | 67 | 68 | 69 | 70 | ## 目录结构 71 | 72 | 73 | ``` bash 74 | ├── build // 构建相关 75 | ├── config // 配置相关 76 | ├── src // 项目代码 77 | │ ├── assets // 样式、图标等静态资源 78 | │ ├── components // 全局公用组件 79 | │ │ ├── banner.vue // banner组件 80 | │ │ ├── commentItem.vue // 评论Item组件 81 | │ │ ├── error.vue // 错误提示组件 82 | │ │ ├── info.vue // listItem的列表信息组件 83 | │ │ ├── listItem.vue // 文章List组件 84 | │ │ ├── loading.vue // 加载提示组件 85 | │ │ ├── myHeader.vue // 头部组件 86 | │ │ ├── popuMenu.vue // 模态框组件 87 | │ ├── config // 全局公用方法 88 | │ │ ├── cache.js // 缓存方法 89 | │ │ ├── directive.js // 指令方法 90 | │ │ ├── fetch.js // 请求方法 91 | │ ├── page 92 | │ │ ├── detail 93 | │ │ | ├── components 94 | │ │ | | ├── article.vue // 文章组件 95 | │ │ | | ├── recommend.vue // 推荐组件 96 | │ │ | | ├── share.vue // 分享组件 97 | │ │ | | ├── tags.vue // 标签组件 98 | │ │ | ├── detail.vue // 详情页 99 | │ │ ├── index 100 | │ │ | ├── children 101 | │ │ | | ├── channel.vue // 栏目页 102 | │ │ | ├── components 103 | │ │ | | ├── index_footer.vue // 首页底部组件 104 | │ │ | | ├── index_header.vue // 首页头部组件 105 | │ │ | | ├── pullContainer.vue // 下拉容器组件 106 | │ │ | | ├── swiperContainer.vue // 滑动容器组件 107 | │ │ | ├── index.vue // 首页 108 | │ │ ├── search 109 | │ │ | ├── search.vue // 搜索页 110 | │ ├── router 111 | │ │ ├── index.js // 路由配置 112 | │ ├── store 113 | │ │ ├── detail 114 | │ │ | ├── index.js // 详情页store 115 | │ │ ├── index 116 | │ │ | ├── index.js // 首页store 117 | │ │ ├── search 118 | │ │ | ├── index.js // 搜索页store 119 | │ │ ├── index.js // 全局store 120 | │ ├── App.vue // 页面入口 121 | │ └── main.js // 程序入口 122 | ├── static // 空文件夹,只作为github保留 123 | ├── .babelrc // babel-loader 配置 124 | ├── .eslintrc.js // eslint 配置项 125 | ├── .gitignore // git 忽略项 126 | ├── index.html // 入口html文件 127 | └── package.json // package.json 128 | ``` 129 | 130 | ## 安装运行 131 | 132 | ``` bash 133 | # 安装 134 | npm install 135 | 136 | # 运行 localhost:8086 137 | npm run dev 138 | 139 | # 打包 140 | npm run build(File in the docs folder) 141 | ``` 142 | 143 | ## 交流 144 | 145 | 欢迎热爱学习、忠于分享的朋友一起来交流 146 | - Vue交流群:338241465 147 | 148 | ## License 149 | 150 | [MIT](https://github.com/uncleLian/vue2-news/blob/master/LICENSE) 151 | 152 | Copyright (c) 2017-present,uncleLian -------------------------------------------------------------------------------- /build/build.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | require('./check-versions')() 3 | 4 | process.env.NODE_ENV = 'production' 5 | 6 | const ora = require('ora') 7 | const rm = require('rimraf') 8 | const path = require('path') 9 | const chalk = require('chalk') 10 | const webpack = require('webpack') 11 | const config = require('../config') 12 | const webpackConfig = require('./webpack.prod.conf') 13 | 14 | const spinner = ora('building for production...') 15 | spinner.start() 16 | 17 | rm(path.join(config.build.assetsRoot, config.build.assetsSubDirectory), err => { 18 | if (err) throw err 19 | webpack(webpackConfig, function (err, stats) { 20 | spinner.stop() 21 | if (err) throw err 22 | process.stdout.write(stats.toString({ 23 | colors: true, 24 | modules: false, 25 | children: false, 26 | chunks: false, 27 | chunkModules: false 28 | }) + '\n\n') 29 | 30 | if (stats.hasErrors()) { 31 | console.log(chalk.red(' Build failed with errors.\n')) 32 | process.exit(1) 33 | } 34 | 35 | console.log(chalk.cyan(' Build complete.\n')) 36 | console.log(chalk.yellow( 37 | ' Tip: built files are meant to be served over an HTTP server.\n' + 38 | ' Opening index.html over file:// won\'t work.\n' 39 | )) 40 | }) 41 | }) 42 | -------------------------------------------------------------------------------- /build/check-versions.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | const chalk = require('chalk') 3 | const semver = require('semver') 4 | const packageConfig = require('../package.json') 5 | const shell = require('shelljs') 6 | function exec (cmd) { 7 | return require('child_process').execSync(cmd).toString().trim() 8 | } 9 | 10 | const versionRequirements = [ 11 | { 12 | name: 'node', 13 | currentVersion: semver.clean(process.version), 14 | versionRequirement: packageConfig.engines.node 15 | } 16 | ] 17 | 18 | if (shell.which('npm')) { 19 | versionRequirements.push({ 20 | name: 'npm', 21 | currentVersion: exec('npm --version'), 22 | versionRequirement: packageConfig.engines.npm 23 | }) 24 | } 25 | 26 | module.exports = function () { 27 | const warnings = [] 28 | for (let i = 0; i < versionRequirements.length; i++) { 29 | const mod = versionRequirements[i] 30 | if (!semver.satisfies(mod.currentVersion, mod.versionRequirement)) { 31 | warnings.push(mod.name + ': ' + 32 | chalk.red(mod.currentVersion) + ' should be ' + 33 | chalk.green(mod.versionRequirement) 34 | ) 35 | } 36 | } 37 | 38 | if (warnings.length) { 39 | console.log('') 40 | console.log(chalk.yellow('To use this template, you must update following to modules:')) 41 | console.log() 42 | for (let i = 0; i < warnings.length; i++) { 43 | const warning = warnings[i] 44 | console.log(' ' + warning) 45 | } 46 | console.log() 47 | process.exit(1) 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /build/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uncleLian/vue2-news/1c198d96059b6c51d78259d45ce2bc563df305b7/build/logo.png -------------------------------------------------------------------------------- /build/utils.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | const path = require('path') 3 | const config = require('../config') 4 | const ExtractTextPlugin = require('extract-text-webpack-plugin') 5 | const pkg = require('../package.json') 6 | 7 | exports.assetsPath = function (_path) { 8 | const assetsSubDirectory = process.env.NODE_ENV === 'production' 9 | ? config.build.assetsSubDirectory 10 | : config.dev.assetsSubDirectory 11 | return path.posix.join(assetsSubDirectory, _path) 12 | } 13 | 14 | exports.cssLoaders = function (options) { 15 | options = options || {} 16 | 17 | const cssLoader = { 18 | loader: 'css-loader', 19 | options: { 20 | sourceMap: options.sourceMap 21 | } 22 | } 23 | 24 | var postcssLoader = { 25 | loader: 'postcss-loader', 26 | options: { 27 | sourceMap: options.sourceMap 28 | } 29 | } 30 | 31 | // generate loader string to be used with extract text plugin 32 | function generateLoaders (loader, loaderOptions) { 33 | const loaders = options.usePostCSS ? [cssLoader, postcssLoader] : [cssLoader] 34 | if (loader) { 35 | loaders.push({ 36 | loader: loader + '-loader', 37 | options: Object.assign({}, loaderOptions, { 38 | sourceMap: options.sourceMap 39 | }) 40 | }) 41 | } 42 | 43 | // Extract CSS when that option is specified 44 | // (which is the case during production build) 45 | if (options.extract) { 46 | return ExtractTextPlugin.extract({ 47 | use: loaders, 48 | fallback: 'vue-style-loader' 49 | }) 50 | } else { 51 | return ['vue-style-loader'].concat(loaders) 52 | } 53 | } 54 | 55 | // https://vue-loader.vuejs.org/en/configurations/extract-css.html 56 | return { 57 | css: generateLoaders(), 58 | postcss: generateLoaders(), 59 | less: generateLoaders('less'), 60 | sass: generateLoaders('sass', { indentedSyntax: true }), 61 | scss: generateLoaders('sass'), 62 | stylus: generateLoaders('stylus'), 63 | styl: generateLoaders('stylus') 64 | } 65 | } 66 | 67 | // Generate loaders for standalone style files (outside of .vue) 68 | exports.styleLoaders = function (options) { 69 | const output = [] 70 | const loaders = exports.cssLoaders(options) 71 | for (const extension in loaders) { 72 | const loader = loaders[extension] 73 | output.push({ 74 | test: new RegExp('\\.' + extension + '$'), 75 | use: loader 76 | }) 77 | } 78 | return output 79 | } 80 | 81 | exports.createNotifierCallback = function () { 82 | const notifier = require('node-notifier') 83 | 84 | return (severity, errors) => { 85 | if (severity !== 'error') { 86 | return 87 | } 88 | const error = errors[0] 89 | 90 | const filename = error.file.split('!').pop() 91 | notifier.notify({ 92 | title: pkg.name, 93 | message: severity + ': ' + error.name, 94 | subtitle: filename || '', 95 | icon: path.join(__dirname, 'logo.png') 96 | }) 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /build/vue-loader.conf.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | const utils = require('./utils') 3 | const config = require('../config') 4 | const isProduction = process.env.NODE_ENV === 'production' 5 | const sourceMapEnabled = isProduction 6 | ? config.build.productionSourceMap 7 | : config.dev.cssSourceMap 8 | 9 | 10 | module.exports = { 11 | loaders: utils.cssLoaders({ 12 | sourceMap: sourceMapEnabled, 13 | extract: isProduction 14 | }), 15 | cssSourceMap: sourceMapEnabled, 16 | transformToRequire: { 17 | video: 'src', 18 | source: 'src', 19 | img: 'src', 20 | image: 'xlink:href' 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /build/webpack.base.conf.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | const path = require('path') 3 | const utils = require('./utils') 4 | const config = require('../config') 5 | const vueLoaderConfig = require('./vue-loader.conf') 6 | 7 | function resolve (dir) { 8 | return path.join(__dirname, '..', dir) 9 | } 10 | 11 | module.exports = { 12 | context: path.resolve(__dirname, '../'), 13 | entry: { 14 | app: './src/main.js' 15 | }, 16 | output: { 17 | path: config.build.assetsRoot, 18 | filename: '[name].js', 19 | publicPath: process.env.NODE_ENV === 'production' 20 | ? config.build.assetsPublicPath 21 | : config.dev.assetsPublicPath 22 | }, 23 | resolve: { 24 | extensions: ['.js', '.vue', '.json'], 25 | alias: { 26 | 'vue$': 'vue/dist/vue.esm.js', 27 | '@': resolve('src'), 28 | } 29 | }, 30 | module: { 31 | rules: [ 32 | ...(config.dev.useEslint? [{ 33 | test: /\.(js|vue)$/, 34 | loader: 'eslint-loader', 35 | enforce: 'pre', 36 | include: [resolve('src'), resolve('test')], 37 | options: { 38 | formatter: require('eslint-friendly-formatter'), 39 | emitWarning: !config.dev.showEslintErrorsInOverlay 40 | } 41 | }] : []), 42 | { 43 | test: /\.vue$/, 44 | loader: 'vue-loader', 45 | options: vueLoaderConfig 46 | }, 47 | { 48 | test: /\.js$/, 49 | loader: 'babel-loader', 50 | include: [resolve('src'), resolve('test')] 51 | }, 52 | { 53 | test: /\.(png|jpe?g|gif|svg)(\?.*)?$/, 54 | loader: 'url-loader', 55 | options: { 56 | limit: 10000, 57 | name: utils.assetsPath('img/[name].[hash:7].[ext]') 58 | } 59 | }, 60 | { 61 | test: /\.(mp4|webm|ogg|mp3|wav|flac|aac)(\?.*)?$/, 62 | loader: 'url-loader', 63 | options: { 64 | limit: 10000, 65 | name: utils.assetsPath('media/[name].[hash:7].[ext]') 66 | } 67 | }, 68 | { 69 | test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/, 70 | loader: 'url-loader', 71 | options: { 72 | limit: 10000, 73 | name: utils.assetsPath('fonts/[name].[hash:7].[ext]') 74 | } 75 | } 76 | ] 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /build/webpack.dev.conf.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | const utils = require('./utils') 3 | const webpack = require('webpack') 4 | const config = require('../config') 5 | const merge = require('webpack-merge') 6 | const baseWebpackConfig = require('./webpack.base.conf') 7 | const HtmlWebpackPlugin = require('html-webpack-plugin') 8 | const FriendlyErrorsPlugin = require('friendly-errors-webpack-plugin') 9 | const portfinder = require('portfinder') 10 | 11 | const devWebpackConfig = merge(baseWebpackConfig, { 12 | module: { 13 | rules: utils.styleLoaders({ sourceMap: config.dev.cssSourceMap, usePostCSS: true }) 14 | }, 15 | // cheap-module-eval-source-map is faster for development 16 | devtool: config.dev.devtool, 17 | 18 | // these devServer options should be customized in /config/index.js 19 | devServer: { 20 | clientLogLevel: 'warning', 21 | historyApiFallback: true, 22 | hot: true, 23 | host: process.env.HOST || config.dev.host, 24 | port: process.env.PORT || config.dev.port, 25 | open: config.dev.autoOpenBrowser, 26 | overlay: config.dev.errorOverlay ? { 27 | warnings: false, 28 | errors: true, 29 | } : false, 30 | publicPath: config.dev.assetsPublicPath, 31 | proxy: config.dev.proxyTable, 32 | quiet: true, // necessary for FriendlyErrorsPlugin 33 | watchOptions: { 34 | poll: config.dev.poll, 35 | } 36 | }, 37 | plugins: [ 38 | new webpack.DefinePlugin({ 39 | 'process.env': require('../config/dev.env') 40 | }), 41 | new webpack.HotModuleReplacementPlugin(), 42 | new webpack.NamedModulesPlugin(), // HMR shows correct file names in console on update. 43 | new webpack.NoEmitOnErrorsPlugin(), 44 | // https://github.com/ampedandwired/html-webpack-plugin 45 | new HtmlWebpackPlugin({ 46 | filename: 'index.html', 47 | template: 'index.html', 48 | inject: true 49 | }), 50 | new webpack.ProvidePlugin({ 51 | $: 'jquery', 52 | jQuery: 'jquery', 53 | 'window.jQuery': 'jquery', 54 | 'window.$': 'jquery', 55 | }) 56 | ] 57 | }) 58 | 59 | module.exports = new Promise((resolve, reject) => { 60 | portfinder.basePort = process.env.PORT || config.dev.port 61 | portfinder.getPort((err, port) => { 62 | if (err) { 63 | reject(err) 64 | } else { 65 | // publish the new Port, necessary for e2e tests 66 | process.env.PORT = port 67 | // add port to devServer config 68 | devWebpackConfig.devServer.port = port 69 | 70 | // Add FriendlyErrorsPlugin 71 | devWebpackConfig.plugins.push(new FriendlyErrorsPlugin({ 72 | compilationSuccessInfo: { 73 | messages: [`Your application is running here: http://${config.dev.host}:${port}`], 74 | }, 75 | onErrors: config.dev.notifyOnErrors 76 | ? utils.createNotifierCallback() 77 | : undefined 78 | })) 79 | 80 | resolve(devWebpackConfig) 81 | } 82 | }) 83 | }) 84 | -------------------------------------------------------------------------------- /build/webpack.prod.conf.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | const path = require('path') 3 | const utils = require('./utils') 4 | const webpack = require('webpack') 5 | const config = require('../config') 6 | const merge = require('webpack-merge') 7 | const baseWebpackConfig = require('./webpack.base.conf') 8 | const CopyWebpackPlugin = require('copy-webpack-plugin') 9 | const HtmlWebpackPlugin = require('html-webpack-plugin') 10 | const ExtractTextPlugin = require('extract-text-webpack-plugin') 11 | const OptimizeCSSPlugin = require('optimize-css-assets-webpack-plugin') 12 | 13 | const env = require('../config/prod.env') 14 | 15 | const webpackConfig = merge(baseWebpackConfig, { 16 | module: { 17 | rules: utils.styleLoaders({ 18 | sourceMap: config.build.productionSourceMap, 19 | extract: true, 20 | usePostCSS: true 21 | }) 22 | }, 23 | devtool: config.build.productionSourceMap ? config.build.devtool : false, 24 | output: { 25 | path: config.build.assetsRoot, 26 | filename: utils.assetsPath('js/[name].[chunkhash].js'), 27 | chunkFilename: utils.assetsPath('js/[name].[chunkhash].js') 28 | }, 29 | plugins: [ 30 | // http://vuejs.github.io/vue-loader/en/workflow/production.html 31 | new webpack.DefinePlugin({ 32 | 'process.env': env 33 | }), 34 | // UglifyJs do not support ES6+, you can also use babel-minify for better treeshaking: https://github.com/babel/minify 35 | new webpack.optimize.UglifyJsPlugin({ 36 | compress: { 37 | warnings: false 38 | }, 39 | sourceMap: config.build.productionSourceMap, 40 | parallel: true 41 | }), 42 | // extract css into its own file 43 | new ExtractTextPlugin({ 44 | filename: utils.assetsPath('css/[name].[contenthash].css'), 45 | // set the following option to `true` if you want to extract CSS from 46 | // codesplit chunks into this main css file as well. 47 | // This will result in *all* of your app's CSS being loaded upfront. 48 | allChunks: false, 49 | }), 50 | // Compress extracted CSS. We are using this plugin so that possible 51 | // duplicated CSS from different components can be deduped. 52 | new OptimizeCSSPlugin({ 53 | cssProcessorOptions: config.build.productionSourceMap 54 | ? { safe: true, map: { inline: false } } 55 | : { safe: true } 56 | }), 57 | // generate dist index.html with correct asset hash for caching. 58 | // you can customize output by editing /index.html 59 | // see https://github.com/ampedandwired/html-webpack-plugin 60 | new HtmlWebpackPlugin({ 61 | filename: config.build.index, 62 | template: 'index.html', 63 | inject: true, 64 | minify: { 65 | removeComments: true, 66 | collapseWhitespace: true, 67 | removeAttributeQuotes: true 68 | // more options: 69 | // https://github.com/kangax/html-minifier#options-quick-reference 70 | }, 71 | // necessary to consistently work with multiple chunks via CommonsChunkPlugin 72 | chunksSortMode: 'dependency' 73 | }), 74 | // keep module.id stable when vender modules does not change 75 | new webpack.HashedModuleIdsPlugin(), 76 | // enable scope hoisting 77 | new webpack.optimize.ModuleConcatenationPlugin(), 78 | // split vendor js into its own file 79 | new webpack.optimize.CommonsChunkPlugin({ 80 | name: 'vendor', 81 | minChunks: function (module) { 82 | // any required modules inside node_modules are extracted to vendor 83 | return ( 84 | module.resource && 85 | /\.js$/.test(module.resource) && 86 | module.resource.indexOf( 87 | path.join(__dirname, '../node_modules') 88 | ) === 0 89 | ) 90 | } 91 | }), 92 | // extract webpack runtime and module manifest to its own file in order to 93 | // prevent vendor hash from being updated whenever app bundle is updated 94 | new webpack.optimize.CommonsChunkPlugin({ 95 | name: 'manifest', 96 | minChunks: Infinity 97 | }), 98 | // This instance extracts shared chunks from code splitted chunks and bundles them 99 | // in a separate chunk, similar to the vendor chunk 100 | // see: https://webpack.js.org/plugins/commons-chunk-plugin/#extra-async-commons-chunk 101 | new webpack.optimize.CommonsChunkPlugin({ 102 | name: 'app', 103 | async: 'vendor-async', 104 | children: true, 105 | minChunks: 3 106 | }), 107 | 108 | // copy custom static assets 109 | new CopyWebpackPlugin([ 110 | { 111 | from: path.resolve(__dirname, '../static'), 112 | to: config.build.assetsSubDirectory, 113 | ignore: ['.*'] 114 | } 115 | ]), 116 | new webpack.ProvidePlugin({ 117 | $: 'jquery', 118 | jQuery: 'jquery', 119 | 'window.jQuery': 'jquery', 120 | 'window.$': 'jquery', 121 | }) 122 | ] 123 | }) 124 | 125 | if (config.build.productionGzip) { 126 | const CompressionWebpackPlugin = require('compression-webpack-plugin') 127 | 128 | webpackConfig.plugins.push( 129 | new CompressionWebpackPlugin({ 130 | asset: '[path].gz[query]', 131 | algorithm: 'gzip', 132 | test: new RegExp( 133 | '\\.(' + 134 | config.build.productionGzipExtensions.join('|') + 135 | ')$' 136 | ), 137 | threshold: 10240, 138 | minRatio: 0.8 139 | }) 140 | ) 141 | } 142 | 143 | if (config.build.bundleAnalyzerReport) { 144 | const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin 145 | webpackConfig.plugins.push(new BundleAnalyzerPlugin()) 146 | } 147 | 148 | module.exports = webpackConfig 149 | -------------------------------------------------------------------------------- /build/webpack.test.conf.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | // This is the webpack config used for unit tests. 3 | 4 | const utils = require('./utils') 5 | const webpack = require('webpack') 6 | const merge = require('webpack-merge') 7 | const baseWebpackConfig = require('./webpack.base.conf') 8 | 9 | const webpackConfig = merge(baseWebpackConfig, { 10 | // use inline sourcemap for karma-sourcemap-loader 11 | module: { 12 | rules: utils.styleLoaders() 13 | }, 14 | devtool: '#inline-source-map', 15 | resolveLoader: { 16 | alias: { 17 | // necessary to to make lang="scss" work in test when using vue-loader's ?inject option 18 | // see discussion at https://github.com/vuejs/vue-loader/issues/724 19 | 'scss-loader': 'sass-loader' 20 | } 21 | }, 22 | plugins: [ 23 | new webpack.DefinePlugin({ 24 | 'process.env': require('../config/test.env') 25 | }) 26 | ] 27 | }) 28 | 29 | // no need for app entry during tests 30 | delete webpackConfig.entry 31 | 32 | module.exports = webpackConfig 33 | -------------------------------------------------------------------------------- /config/dev.env.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | const merge = require('webpack-merge') 3 | const prodEnv = require('./prod.env') 4 | 5 | module.exports = merge(prodEnv, { 6 | NODE_ENV: '"development"' 7 | }) 8 | -------------------------------------------------------------------------------- /config/index.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | // Template version: 1.2.3 3 | // see http://vuejs-templates.github.io/webpack for documentation. 4 | 5 | const path = require('path') 6 | 7 | module.exports = { 8 | dev: { 9 | 10 | // Paths 11 | assetsSubDirectory: 'static', 12 | assetsPublicPath: '/', 13 | proxyTable: {}, 14 | 15 | // Various Dev Server settings 16 | host: 'localhost', // can be overwritten by process.env.HOST 17 | port: 8086, // can be overwritten by process.env.HOST, if port is in use, a free one will be determined 18 | autoOpenBrowser: true, 19 | errorOverlay: true, 20 | notifyOnErrors: true, 21 | poll: false, // https://webpack.js.org/configuration/dev-server/#devserver-watchoptions- 22 | 23 | // Use Eslint Loader? 24 | // If true, your code will be linted during bundling and 25 | // linting errors and warnings will be shown in the console. 26 | useEslint: true, 27 | // If true, eslint errors and warnings will also be shown in the error overlay 28 | // in the browser. 29 | showEslintErrorsInOverlay: false, 30 | 31 | /** 32 | * Source Maps 33 | */ 34 | 35 | // https://webpack.js.org/configuration/devtool/#development 36 | devtool: 'eval-source-map', 37 | 38 | // If you have problems debugging vue-files in devtools, 39 | // set this to false - it *may* help 40 | // https://vue-loader.vuejs.org/en/options.html#cachebusting 41 | cacheBusting: true, 42 | 43 | // CSS Sourcemaps off by default because relative paths are "buggy" 44 | // with this option, according to the CSS-Loader README 45 | // (https://github.com/webpack/css-loader#sourcemaps) 46 | // In our experience, they generally work as expected, 47 | // just be aware of this issue when enabling this option. 48 | cssSourceMap: false, 49 | }, 50 | 51 | build: { 52 | // Template for index.html 53 | index: path.resolve(__dirname, '../docs/index.html'), 54 | 55 | // Paths 56 | assetsRoot: path.resolve(__dirname, '../docs'), 57 | assetsSubDirectory: 'static', 58 | assetsPublicPath: `/`, 59 | 60 | /** 61 | * Source Maps 62 | */ 63 | 64 | productionSourceMap: false, 65 | // https://webpack.js.org/configuration/devtool/#production 66 | devtool: '#source-map', 67 | 68 | // Gzip off by default as many popular static hosts such as 69 | // Surge or Netlify already gzip all static assets for you. 70 | // Before setting to `true`, make sure to: 71 | // npm install --save-dev compression-webpack-plugin 72 | productionGzip: false, 73 | productionGzipExtensions: ['js', 'css'], 74 | 75 | // Run the build command with an extra argument to 76 | // View the bundle analyzer report after build finishes: 77 | // `npm run build --report` 78 | // Set to `true` or `false` to always turn it on or off 79 | bundleAnalyzerReport: process.env.npm_config_report 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /config/prod.env.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | module.exports = { 3 | NODE_ENV: '"production"' 4 | } 5 | -------------------------------------------------------------------------------- /docs/CNAME: -------------------------------------------------------------------------------- 1 | toutiao.liansixin.win -------------------------------------------------------------------------------- /docs/index.html: -------------------------------------------------------------------------------- 1 | 健康头条-看头条,知健康
-------------------------------------------------------------------------------- /docs/static/img/hot.7423050.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uncleLian/vue2-news/1c198d96059b6c51d78259d45ce2bc563df305b7/docs/static/img/hot.7423050.png -------------------------------------------------------------------------------- /docs/static/img/loading.70b31c2.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uncleLian/vue2-news/1c198d96059b6c51d78259d45ce2bc563df305b7/docs/static/img/loading.70b31c2.gif -------------------------------------------------------------------------------- /docs/static/img/loading.c6bc779.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uncleLian/vue2-news/1c198d96059b6c51d78259d45ce2bc563df305b7/docs/static/img/loading.c6bc779.png -------------------------------------------------------------------------------- /docs/static/js/3.18da567097ad9b9cac29.js: -------------------------------------------------------------------------------- 1 | webpackJsonp([3],{"174N":function(e,t,n){var a=n("i0GS");"string"==typeof a&&(a=[[e.i,a,""]]),a.locals&&(e.exports=a.locals);n("rjj0")("400ff000",a,!0,{})},N3it:function(e,t,n){"use strict";(function(e){var a=n("Gu7T"),o=n.n(a),r=n("Dd8w"),s=n.n(r),i=n("NYxO");t.a={data:function(){return{key:"",page:1,search_state:"recommend",searchJson:[],hotJson:[],keyWords:null,history:{},bottomLock:!1,bottomStatus:"loading",bottomTip:!1,loading:!1}},watch:{$route:function(e,t){t.path.includes("index")&&(this.key="",this.search_state="recommend")},key:function(e){e||(this.search_state="recommend")}},methods:s()({},Object(i.b)("search",["get_hot_data","get_search_data"]),{get_hot:function(){var e=this;this.loading="loading",this.get_hot_data().then(function(t){t.data&&(e.hotJson=t.data),t.keyword&&(e.keyWords=t.keyword),e.loading=!1}).catch(function(t){console.log(t),e.loading="error"})},get_search:function(){var t=this;this.key&&(this.loading="loading",this.search_state="search",e("#search .container").scrollTop(0),this.$router.replace("/search?key="+this.key),this.get_search_data({key:this.key,page:1}).then(function(e){e.data?(t.searchJson=e.data,t.page=2,t.handleLocaltion("get")):(t.searchJson=[],t.search_state="empty"),t.loading=!1}).catch(function(e){console.log(e),t.search_state="empty",t.loading="error"}))},get_search_more:function(){var e=this;"noData"!==this.bottomStatus&&(this.bottomLock=!0,this.get_search_data({key:this.key,page:this.page}).then(function(t){if(t.data){var n;(n=e.searchJson).push.apply(n,o()(t.data)),e.page++}else e.bottomStatus="noData";e.bottomLock=!1}))},bottomVisible:function(){var t=this;this.$nextTick(function(){e("#search .listItem").height()>=e("#search .container").height()&&(t.bottomTip=!0)})},handleLocaltion:function(t){var n=this;"get"===t?this.$nextTick(function(){n.bottomVisible(),n.history&&n.history[n.key]&&e("#search .container").scrollTop(n.history[n.key].location)}):"set"===t&&this.key&&(this.history[this.key]={location:e("#search .container").scrollTop(),data:this.searchJson})}}),mounted:function(){this.get_hot()},activated:function(){this.$route.query.key&&(this.key=this.$route.query.key,this.history[this.key]&&this.history[this.key].data?(this.searchJson=this.history[this.key].data,this.search_state="search",this.handleLocaltion("get")):this.get_search())},deactivated:function(){this.handleLocaltion("set")}}}).call(t,n("7t+N"))},fy6o:function(e,t,n){e.exports=n.p+"static/img/hot.7423050.png"},i0GS:function(e,t,n){var a=n("kxFB");t=e.exports=n("FZ+f")(!1),t.push([e.i,"\n#search {\n position: relative;\n width: 100%;\n height: 100%;\n overflow: hidden;\n background: #fff;\n}\n#search a {\n text-decoration: none;\n}\n#search .search_top {\n position: fixed;\n top: 0;\n left: 0;\n right: 0;\n z-index: 999;\n}\n#search .search_top header {\n background: #fff;\n padding-right: 0.27rem;\n border-bottom: 1px solid #eee;\n background: #f4f5f6;\n}\n#search .search_top header .form {\n position: relative;\n display: -webkit-box;\n display: -ms-flexbox;\n display: flex;\n -webkit-box-align: center;\n -ms-flex-align: center;\n align-items: center;\n color: #aaa;\n font-size: 14px;\n background: #fff;\n border: 1px solid #ddd;\n border-radius: 50px;\n padding: 0.13rem 0.267rem;\n margin: 0 0.267rem;\n}\n#search .search_top header .form .form_input {\n width: 100%;\n color: #666;\n padding-left: 0.13rem;\n margin: 0;\n outline: none;\n -webkit-appearance: none;\n}\n#search .search_top header .form .form_input::-webkit-input-placeholder {\n color: #c8c8c9;\n font-size: 12px;\n}\n#search .search_top header .form .form_input::-moz-placeholder {\n color: #c8c8c9;\n font-size: 12px;\n}\n#search .search_top header .form .form_input:-ms-placeholder {\n color: #c8c8c9;\n font-size: 12px;\n}\n#search .search_top header .search_btn {\n color: #aaa;\n font-size: 14px;\n}\n#search .search_top header .search_btn.on {\n color: #00939c;\n font-weight: bold;\n}\n#search .content {\n background: #fff;\n}\n#search .content .search_recommend {\n position: relative;\n height: 100%;\n overflow-y: auto;\n -webkit-overflow-scrolling: touch;\n}\n#search .content .search_recommend .keyword {\n padding-top: 0.27rem;\n}\n#search .content .search_recommend .keyword .keyword_wrap {\n padding: 0 0.4rem;\n}\n#search .content .search_recommend .keyword .keyword_wrap span {\n display: inline-block;\n font-size: 13px;\n padding: 0.13rem 0.26rem;\n margin: 0 0.26rem 0.26rem 0;\n color: #403d3c;\n background: #f4f5f6;\n border-radius: 4px;\n}\n#search .content .search_recommend .keyword .gray_line {\n height: 0.13rem;\n background: #f4f5f6;\n}\n#search .content .search_recommend .article {\n padding: 0.27rem 0.4rem 0;\n}\n#search .content .search_recommend .article h3 {\n font-size: 15px;\n color: #403d3c;\n margin-bottom: 5px;\n}\n#search .content .search_recommend .article h3 .hot_icon {\n display: inline-block;\n vertical-align: middle;\n width: 24px;\n height: 24px;\n background: url("+a(n("fy6o"))+') no-repeat center center;\n background-size: 24px;\n margin-right: 0.13rem;\n}\n#search .content .search_recommend .article h3 span {\n display: inline-block;\n vertical-align: middle;\n margin-top: 2px;\n}\n#search .content .search_recommend .article ul {\n position: relative;\n height: 100%;\n}\n#search .content .search_recommend .article ul li {\n font-size: 14px;\n color: #717071;\n border-bottom: 1px solid #eee;\n}\n#search .content .search_recommend .article ul li a {\n display: block;\n width: 100%;\n padding: 0.27rem 0;\n text-overflow: ellipsis;\n overflow: hidden;\n white-space: nowrap;\n text-align: justify;\n}\n#search .content .search_recommend .article ul li span {\n margin-right: 0.24rem;\n}\n#search .content .search_recommend .article ul li span.hot {\n color: #00939c;\n}\n#search .content .search_result-empty {\n position: absolute;\n width: 100%;\n height: 150px;\n top: 40%;\n margin-top: -75px;\n padding: 70px 0 0;\n background: url("http://s3.pstatp.com/image/toutiao_mobile/noresuiticon_seach.png") no-repeat center top;\n background-size: 68px;\n text-align: center;\n color: #cacaca;\n font-size: 16px;\n}\n',""])},vCr1:function(e,t,n){"use strict";function a(e){n("174N")}Object.defineProperty(t,"__esModule",{value:!0});var o=n("N3it"),r=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{attrs:{id:"search"}},[n("div",{staticClass:"search_top"},[n("my-header",{staticClass:"header"},[n("a",{staticClass:"back-black",attrs:{slot:"left"},on:{click:function(t){t.stopPropagation(),e.$router.go(-1)}},slot:"left"}),e._v(" "),n("form",{staticClass:"form",attrs:{slot:"mid"},on:{submit:function(t){t.preventDefault(),e.get_search(t)}},slot:"mid"},[n("i",{staticClass:"form_icon icon-search"}),e._v(" "),n("input",{directives:[{name:"model",rawName:"v-model.trim",value:e.key,expression:"key",modifiers:{trim:!0}}],staticClass:"form_input",attrs:{type:"search",placeholder:"搜头条,知健康"},domProps:{value:e.key},on:{input:function(t){t.target.composing||(e.key=t.target.value.trim())},blur:function(t){e.$forceUpdate()}}})]),e._v(" "),n("a",{staticClass:"search_btn",class:e.key?"on":"",attrs:{slot:"right"},on:{click:function(t){t.stopPropagation(),e.get_search(t)}},slot:"right"},[e._v("搜索")])])],1),e._v(" "),n("div",{directives:[{name:"swiper",rawName:"v-swiper:swiperRight",value:!0,expression:"true",arg:"swiperRight"}],staticClass:"content"},["recommend"===e.search_state?[n("div",{staticClass:"search_recommend"},[e.keyWords?n("div",{staticClass:"keyword"},[n("div",{staticClass:"keyword_wrap"},e._l(e.keyWords,function(t,a){return n("span",{key:a,on:{click:function(n){n.stopPropagation(),e.$router.replace("/search?key="+t)}}},[e._v(e._s(t))])})),e._v(" "),n("div",{staticClass:"gray_line"})]):e._e(),e._v(" "),n("div",{staticClass:"article"},[e._m(0),e._v(" "),e.hotJson.length>0?n("ul",e._l(e.hotJson,function(t,a){return n("li",{key:a},[n("router-link",{attrs:{to:"/detail?classid="+t.classid+"&id="+t.id+"&datafrom="+t.datafrom}},[n("span",{class:a+1>0&&a+1<4?"hot":""},[e._v(e._s(a+1)+".")]),e._v("\n "+e._s(t.title)+"\n ")])],1)})):e._e()])])]:e._e(),e._v(" "),"search"===e.search_state?[n("div",{directives:[{name:"infinite-scroll",rawName:"v-infinite-scroll",value:e.get_search_more,expression:"get_search_more"}],staticClass:"container",attrs:{"infinite-scroll-disabled":"bottomLock","infinite-scroll-distance":"10","infinite-scroll-immediate-check":"false"}},[e.searchJson.length>0?n("list-item",{attrs:{itemJson:e.searchJson}}):e._e(),e._v(" "),e.bottomTip?n("div",{staticClass:"bottomLoad"},[n("div",{directives:[{name:"show",rawName:"v-show",value:"loading"===e.bottomStatus,expression:"bottomStatus === 'loading'"}],staticClass:"loading"},[e._v("加载中...")]),e._v(" "),"noData"===e.bottomStatus?n("div",{staticClass:"noData"},[e._v("没有更多的内容了")]):e._e()]):e._e()],1)]:e._e(),e._v(" "),"empty"==e.search_state&&0===e.searchJson.length?[e._m(1)]:e._e()],2),e._v(" "),n("my-loading",{attrs:{visible:e.loading,reload:e.get_search}})],1)},s=[function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("h3",[n("i",{staticClass:"hot_icon"}),e._v(" "),n("span",[e._v("今日热点")])])},function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{staticClass:"search_result-empty"},[n("p",[e._v("这个宇宙中搜寻不到")]),e._v(" "),n("p",[e._v("换个词试试")])])}],i={render:r,staticRenderFns:s},c=i,h=n("VU/8"),l=a,d=h(o.a,c,!1,l,null,null);t.default=d.exports}}); -------------------------------------------------------------------------------- /docs/static/js/4.cd24d4e14760bcab3fe3.js: -------------------------------------------------------------------------------- 1 | webpackJsonp([4],{BFVF:function(n,e,t){e=n.exports=t("FZ+f")(!1),e.push([n.i,"\n#channel {\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n height: 100%;\n overflow: hidden;\n z-index: 999;\n}\n#channel header {\n font-size: 16px;\n}\n#channel .content {\n height: 100%;\n padding-top: 44px;\n background-color: #f8f8f8;\n}\n#channel .content .container {\n height: 100%;\n}\n#channel .content .column {\n margin-top: 5px;\n}\n#channel .content .column .title {\n font-size: 12px;\n padding: 0 10px;\n line-height: 2em;\n background-color: #f5f5f5;\n color: #666;\n}\n#channel .content .column ul {\n margin: 10px 0;\n}\n#channel .content .column ul li {\n display: inline-block;\n width: 25%;\n margin-bottom: 10px;\n -webkit-animation: zoomIn 0.3s ease;\n animation: zoomIn 0.3s ease;\n}\n#channel .content .column ul li a {\n display: block;\n font-size: 16px;\n margin: 0 8px;\n border: 1px solid #ccc;\n line-height: 2em;\n color: #131313;\n text-align: center;\n text-decoration: none;\n}\n#channel .content .column ul li a.news_recommend {\n background-color: #f0f0f0;\n}\n",""])},PRDJ:function(n,e,t){var a=t("BFVF");"string"==typeof a&&(a=[[n.i,a,""]]),a.locals&&(n.exports=a.locals);t("rjj0")("49aba57c",a,!0,{})},d9kp:function(n,e,t){"use strict";function a(n){t("PRDJ")}Object.defineProperty(e,"__esModule",{value:!0});var i=t("Gu7T"),s=t.n(i),c=t("Dd8w"),l=t.n(c),o=t("TuU3"),r=t("NYxO"),h={data:function(){return{channel:[{classname:"Test20",classid:20,classpath:"t1"},{classname:"Test21",classid:21,classpath:"t2"},{classname:"Test22",classid:22,classpath:"t3"},{classname:"Test23",classid:23,classpath:"t4"},{classname:"Test24",classid:24,classpath:"t5"},{classname:"Test25",classid:25,classpath:"t6"}],removeChannel:[]}},computed:l()({},Object(r.e)("index",["indexPage","indexLocation","indexColumn"])),watch:{indexColumn:function(){this.set_indexColumn(this.indexColumn),this.set_indexActive("news_recommend")},removeChannel:function(){o.a.setSession("removeChannel",this.removeChannel)}},methods:l()({},Object(r.d)("index",["set_indexActive","set_indexPage","set_indexLocation","set_indexColumn"]),Object(r.b)("index",["get_channel_data"]),{get_channel:function(){var n=this;this.get_channel_data().then(function(e){e&&(n.channel=e)})},get_removeChannel:function(){var n=JSON.parse(getCache("removeChannel"));n&&(this.removeChannel=n)},add:function(n,e){if("channel"===n){var t,a=this.channel.splice(e,1);(t=this.indexColumn).push.apply(t,s()(a))}else if("removeChannel"===n){var i,c=this.removeChannel.splice(e,1);(i=this.indexColumn).push.apply(i,s()(c))}},remove:function(n,e){if("news_recommend"!==n.classpath){var t,a=this.indexColumn.splice(e,1);(t=this.removeChannel).push.apply(t,s()(a))}},sync:function(){for(var n={},e={},t=0;t1?n[a]=this.indexPage[a]:n[a]=1,this.indexLocation[a]>0?e[a]=this.indexLocation[a]:e[a]=0}this.set_indexPage(n),this.set_indexLocation(e)}}),mounted:function(){this.get_removeChannel()},deactivated:function(){this.sync()}},d=function(){var n=this,e=n.$createElement,t=n._self._c||e;return t("transition",{attrs:{name:"fadeIn"}},[t("div",{attrs:{id:"channel"}},[t("my-header",{attrs:{fixed:"",title:"频道管理"}},[t("a",{staticClass:"back-white",attrs:{slot:"left"},on:{click:function(e){n.$router.go(-1)}},slot:"left"})]),n._v(" "),t("div",{staticClass:"content"},[t("div",{directives:[{name:"swiper",rawName:"v-swiper:swiperRight",value:!0,expression:"true",arg:"swiperRight"}],staticClass:"container"},[t("section",{staticClass:"column"},[t("p",{staticClass:"title"},[n._v("点击删除以下频道")]),n._v(" "),t("ul",n._l(n.indexColumn,function(e,a){return t("li",{key:a,on:{click:function(t){n.remove(e,a)}}},[t("a",{class:e.classpath,attrs:{href:"javascript:;"}},[n._v(n._s(e.classname))])])}))]),n._v(" "),t("section",{staticClass:"column"},[t("p",{staticClass:"title"},[n._v("点击添加以下频道")]),n._v(" "),t("ul",n._l(n.removeChannel,function(e,a){return t("li",{key:a,on:{click:function(e){n.add("removeChannel",a)}}},[t("a",{attrs:{href:"javascript:;"}},[n._v(n._s(e.classname))])])})),n._v(" "),t("ul",n._l(n.channel,function(e,a){return t("li",{key:a,on:{click:function(e){n.add(a)}}},[t("a",{attrs:{href:"javascript:;"}},[n._v(n._s(e.classname))])])}))])])])],1)])},u=[],m={render:d,staticRenderFns:u},p=m,f=t("VU/8"),v=a,x=f(h,p,!1,v,null,null);e.default=x.exports}}); -------------------------------------------------------------------------------- /docs/static/js/amfe-flexible.min.js: -------------------------------------------------------------------------------- 1 | !function(e,t){function n(){t.body?t.body.style.fontSize=12*o+"px":t.addEventListener("DOMContentLoaded",n)}function d(){var e=i.clientWidth/10;i.style.fontSize=e+"px"}var i=t.documentElement,o=e.devicePixelRatio||1;if(n(),d(),e.addEventListener("resize",d),e.addEventListener("pageshow",function(e){e.persisted&&d()}),o>=2){var a=t.createElement("body"),s=t.createElement("div");s.style.border=".5px solid transparent",a.appendChild(s),i.appendChild(a),1===s.offsetHeight&&i.classList.add("hairlines"),i.removeChild(a)}}(window,document); -------------------------------------------------------------------------------- /docs/static/js/app.10893d4d7c15b8d09949.js: -------------------------------------------------------------------------------- 1 | webpackJsonp([6],{"/5Jc":function(t,e){},"2Wke":function(t,e){},"991W":function(t,e){},"9R5P":function(t,e){},A4KD:function(t,e){},J373:function(t,e){},Jjnl:function(t,e){},"N+zL":function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i={name:"swiper-slide",data:function(){return{slideClass:"swiper-slide"}},ready:function(){this.update()},mounted:function(){this.update(),this.$parent.options.slideClass&&(this.slideClass=this.$parent.options.slideClass)},updated:function(){this.update()},attached:function(){this.update()},methods:{update:function(){this.$parent&&this.$parent.swiper&&this.$parent.swiper.update&&(this.$parent.swiper.update(!0),this.$parent.options.loop&&this.$parent.swiper.reLoop())}}},s=function(){var t=this,e=t.$createElement;return(t._self._c||e)("div",{class:t.slideClass},[t._t("default")],2)},a=[],r={render:s,staticRenderFns:a},o=r,c=n("VU/8"),l=c(i,o,!1,null,null,null);e.default=l.exports},NHnr:function(t,e,n){"use strict";function i(t){n("2Wke")}function s(t){n("dRPW")}function a(t){n("RRfq"),n("Vu75")}function r(t){n("A4KD")}function o(t){n("bgQv")}function c(t){n("Jjnl")}function l(t){n("d4q3")}function u(t){n("cLP1")}function d(t){n("rQJG")}Object.defineProperty(e,"__esModule",{value:!0});var p=(n("j1ja"),n("7+uW")),v={data:function(){return{transitionName:""}},beforeRouteUpdate:function(t,e,n){var i=this.$router.isBack;this.transitionName=i?"slide-right":"slide-left",this.$router.isBack=!1,n()}},f=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",{attrs:{id:"app"}},[n("transition",{attrs:{name:t.transitionName}},[n("keep-alive",{attrs:{exclude:"detail"}},[n("router-view",{staticClass:"child-view"})],1)],1)],1)},_=[],m={render:f,staticRenderFns:_},h=m,x=n("VU/8"),w=i,g=x(v,h,!1,w,null,null),C=g.exports,b=n("/ocq");p.default.use(b.a),b.a.prototype.go=function(){this.isBack=!0,window.history.go(-1)};var y=function(){return Promise.all([n.e(0),n.e(2)]).then(n.bind(null,"Fw7Z"))},k=function(){return Promise.all([n.e(0),n.e(4)]).then(n.bind(null,"d9kp"))},S=function(){return Promise.all([n.e(0),n.e(1)]).then(n.bind(null,"tgJt"))},j=function(){return Promise.all([n.e(0),n.e(3)]).then(n.bind(null,"vCr1"))},P=new b.a({routes:[{path:"",redirect:"/index",component:C,children:[{name:"index",path:"/index",component:y,children:[{name:"channel",path:"channel",component:k}]},{name:"detail",path:"/detail",component:S},{name:"search",path:"/search",component:j}]}]}),$=n("NYxO"),A=n("Xxa5"),J=n.n(A),L=n("Gu7T"),N=n.n(L),T=n("exGp"),R=n.n(T),z=n("TuU3"),M=n("mtWM"),U=n.n(M),E=n("mw3O"),I=n.n(E),O=this;p.default.prototype.$http=U.a,U.a.defaults.baseURL="http://data.toutiaojk.com/extend/list/";var F={classID:"appclassid.php",Class:"appclass.php",Stick:"appistop.php",Artilce:"apparticle.php",Recommend:"apptuijian.php",Search:"search.php"},V=function(){var t=R()(J.a.mark(function t(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"POST",i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return J.a.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(e=void 0,n=n.toUpperCase(),i=F[i],"GET"!==n){t.next=8;break}return t.next=6,U.a.get(i,{params:s}).then(function(t){e=t.data});case 6:t.next=11;break;case 8:if("POST"!==n){t.next=11;break}return t.next=11,U.a.post(i,I.a.stringify(s)).then(function(t){e=t.data});case 11:return t.abrupt("return",e);case 12:case"end":return t.stop()}},t,O)}));return function(){return t.apply(this,arguments)}}(),B={namespaced:!0,state:{indexActive:"news_recommend",indexPage:{news_recommend:1},indexLocation:{news_recommend:0},indexColumn:[{classname:"推荐",classid:0,classpath:"news_recommend"}],currentContent:"",indexSwiper:!1},getters:{activeMeta:function(t){var e=t.indexColumn.findIndex(function(e){return e.classpath===t.indexActive});return{index:e,classid:t.indexColumn[e].classid,page:t.indexPage[t.indexActive],location:t.indexLocation[t.indexActive]}}},mutations:{set_indexActive:function(t,e){t.indexActive=e,z.a.setSession("index_Active",e)},set_indexPage:function(t,e){t.indexPage=e,z.a.setSession("index_Page",e)},set_indexLocation:function(t,e){t.indexLocation=e,z.a.setSession("index_Location",e)},set_indexColumn:function(t,e){t.indexColumn=e,z.a.setSession("index_Column",e)},set_currentContent:function(t,e){t.currentContent=e,z.a.setSession(t.indexActive+"_json",e)},set_indexSwiper:function(t,e){t.indexSwiper=e}},actions:{get_indexActive_cache:function(t){var e=t.commit,n=(t.dispatch,z.a.getSession("index_Active"));n?e("set_indexActive",n):e("set_indexActive","news_recommend")},get_indexPage_cache:function(t,e){var n=t.commit,i=JSON.parse(z.a.getSession("index_Page"));if(i)n("set_indexPage",i);else if(e){var s={};e.forEach(function(t){s[t.classpath]=1}),n("set_indexPage",s)}},get_indexLocation_cache:function(t,e){var n=t.commit,i=JSON.parse(z.a.getSession("index_Location"));if(i)n("set_indexLocation",i);else if(e){var s={};e.forEach(function(t){s[t.classpath]=0}),n("set_indexLocation",s)}},get_listItem_cache:function(t,e){var n=(t.commit,t.state);return JSON.parse(z.a.getSession(n.indexActive+"_json"))},get_indexColumn_data:function(t){var e=this,n=t.commit,i=t.state,s=t.dispatch;return R()(J.a.mark(function t(){var a,r,o;return J.a.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(a=void 0,!(r=JSON.parse(z.a.getSession("index_Column")))){t.next=6;break}a=r,t.next=10;break;case 6:return t.next=8,V("post","classID");case 8:o=t.sent,a=[].concat(N()(i.indexColumn),N()(o));case 10:return n("set_indexColumn",a),s("get_indexPage_cache",a),s("get_indexLocation_cache",a),s("get_indexActive_cache"),t.abrupt("return",a);case 15:case"end":return t.stop()}},t,e)}))()},get_listItem_data:function(t,e){var n=this,i=t.getters;return R()(J.a.mark(function t(){var s,a;return J.a.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return s={classid:i.activeMeta.classid,page:e},t.next=3,V("post","Class",s);case 3:return a=t.sent,t.abrupt("return",a);case 5:case"end":return t.stop()}},t,n)}))()},get_stick_data:function(t){var e=this,n=(t.commit,t.getters);return R()(J.a.mark(function t(){var i,s;return J.a.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return i={classid:n.activeMeta.classid,type:"stick"},t.next=3,V("post","Stick",i);case 3:return s=t.sent,t.abrupt("return",s);case 5:case"end":return t.stop()}},t,e)}))()},get_banner_data:function(t){var e=this,n=(t.commit,t.getters);return R()(J.a.mark(function t(){var i,s;return J.a.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return i={classid:n.activeMeta.classid,type:"banner"},t.next=3,V("post","Stick",i);case 3:return s=t.sent,t.abrupt("return",s);case 5:case"end":return t.stop()}},t,e)}))()},get_channel_data:function(t){var e=this;t.state;return R()(J.a.mark(function t(){var n;return J.a.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,V("post","classID",{channel:"channel"});case 2:return n=t.sent,t.abrupt("return",n);case 4:case"end":return t.stop()}},t,e)}))()}}},H={namespaced:!0,state:{historyArticle:{},location:{}},getters:{},mutations:{set_historyArticle:function(t,e){t.historyArticle=e,z.a.setSession("history_Article",e)},set_location:function(t,e){t.location=e}},actions:{get_Article_data:function(t,e){var n=this,i=t.commit,s=t.state,a=e.id,r=e.datafrom;return R()(J.a.mark(function t(){var e,o,c;return J.a.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(e=void 0,o=void 0,!(o=JSON.parse(z.a.getSession("history_Article")))||!o[a]){t.next=7;break}e=o[a],t.next=10;break;case 7:return c={id:a,datafrom:r},t.next=10,V("post","Artilce",c).then(function(t){e=t.data,s.historyArticle[a]=e,o=s.historyArticle});case 10:return i("set_historyArticle",o),t.abrupt("return",e);case 12:case"end":return t.stop()}},t,n)}))()}}},q={namespaced:!0,state:{},getters:{},mutations:{},actions:{get_hot_data:function(){var t=this;return R()(J.a.mark(function e(){var n;return J.a.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,V("post","Search");case 2:return n=t.sent,t.abrupt("return",n);case 4:case"end":return t.stop()}},e,t)}))()},get_search_data:function(t,e){var n=this,i=(t.commit,t.state,e.key),s=e.page;return R()(J.a.mark(function t(){var e;return J.a.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,V("post","Search",{key:i,page:s});case 2:return e=t.sent,t.abrupt("return",e);case 4:case"end":return t.stop()}},t,n)}))()}}};p.default.use($.a);var D={},W={},G={},Q={},X=new $.a.Store({state:D,getters:W,mutations:G,actions:Q,modules:{index:B,detail:H,search:q}}),Y=(n("991W"),n("/5Jc"),n("9R5P"),n("J373"),n("Au9i")),K=n.n(Y),Z=(n("d8/S"),n("F3EI")),tt=n.n(Z),et=(n("v2ns"),{props:{fixed:Boolean,title:String}}),nt=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("header",{staticClass:"myHeader",class:{fixed:t.fixed}},[n("div",{staticClass:"top_bar"},[n("div",{staticClass:"abs_l"},[t._t("left")],2),t._v(" "),n("div",{staticClass:"abs_m"},[t._v(t._s(t.title)),t._t("mid")],2),t._v(" "),n("div",{staticClass:"abs_r"},[t._t("right")],2)])])},it=[],st={render:nt,staticRenderFns:it},at=st,rt=n("VU/8"),ot=s,ct=rt(et,at,!1,ot,null,null),lt=ct.exports,ut={props:{visible:{type:[Boolean,String],default:!1},type:{type:String,default:"fixed"},reload:Function},data:function(){return{size:36,color:"#00939c"}}},dt=function(){var t=this,e=t.$createElement,n=t._self._c||e;return t.visible?n("div",{class:"absolute"===t.type?"absolute":"",attrs:{id:"loading"}},["loading"===t.visible?n("div",{staticClass:"loading_container"},[n("mt-spinner",{attrs:{type:3,size:t.size,color:t.color}})],1):"error"===t.visible?n("div",{staticClass:"error_container"},[n("div",{staticClass:"error_box"},[n("p",{staticClass:"error_text"},[t._v("网络出现错误")]),t._v(" "),n("mt-button",{staticClass:"error_btn",attrs:{type:"danger"},on:{click:function(e){e.stopPropagation(),t.reload(e)}}},[t._v("重试")])],1)]):t._e()]):t._e()},pt=[],vt={render:dt,staticRenderFns:pt},ft=vt,_t=n("VU/8"),mt=a,ht=_t(ut,ft,!1,mt,"data-v-5bc0539b",null),xt=ht.exports,wt={props:{visible:{type:Boolean,default:!1},method:Function,fixed:Boolean}},gt=function(){var t=this,e=t.$createElement,n=t._self._c||e;return t.visible?n("div",{staticClass:"error",class:{fixed:t.fixed}},[n("div",{staticClass:"container"},[n("p",{staticClass:"error_text"},[t._v("网络出现错误")]),t._v(" "),n("mt-button",{staticClass:"error_btn",attrs:{type:"primary"},on:{click:function(e){e.stopPropagation(),t.method(e)}}},[t._v("重试")])],1)]):t._e()},Ct=[],bt={render:gt,staticRenderFns:Ct},yt=bt,kt=n("VU/8"),St=r,jt=kt(wt,yt,!1,St,"data-v-50261742",null),Pt=jt.exports,$t={props:["json"],filters:{watchFilter:function(t){var e=Math.floor(101*Math.random()+100);return t?e+parseInt(t):""}}},At=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",{staticClass:"news_info"},[t.json.playonlineurl?n("span",{staticClass:"news_label blue"},[t._v("视频")]):t.json.istop&&t.json.istop>=9?n("span",{staticClass:"news_label red"},[t._v("置顶")]):t.json.isgood>=6?n("span",{staticClass:"news_label blue"},[t._v("荐")]):t.json.firsttitle>=6?n("span",{staticClass:"news_label red"},[t._v("热")]):t._e(),t._v(" "),t.json.befrom?n("span",{staticClass:"news_from"},[t._v(t._s(t.json.befrom))]):t._e(),t._v(" "),t.json.onclick?n("span",{staticClass:"news_click"},[t._v(t._s(t._f("watchFilter")(t.json.onclick))+"阅读")]):t._e(),t._v(" "),t.json.plnum?n("span",{staticClass:"news_plnum"},[t._v(t._s(t.json.plnum)+"评论")]):t._e(),t._v(" "),t.json.time?n("span",{staticClass:"news_time"},[t._v(t._s(t.json.time))]):t._e(),t._v(" "),t.json.nlist?n("span",{staticClass:"news_tag"},[t._v(t._s(t.json.nlist))]):t._e()])},Jt=[],Lt={render:At,staticRenderFns:Jt},Nt=Lt,Tt=n("VU/8"),Rt=o,zt=Tt($t,Nt,!1,Rt,null,null),Mt=zt.exports,Ut={props:["itemJson"],methods:{url:function(t){return"/detail?classid="+t.classid+"&id="+t.id+"&datafrom="+t.datafrom}}},Et=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("ul",{staticClass:"listItem"},[t._l(t.itemJson,function(e){return[e.playonlineurl?n("li",[n("router-link",{staticClass:"video",attrs:{to:t.url(e)}},[n("div",{staticClass:"video_wrapper"},[n("div",{staticClass:"video_info"},[n("div",{staticClass:"video_title"},[n("p",{domProps:{innerHTML:t._s(e.title)}})]),t._v(" "),n("div",{staticClass:"totalTime"},[t._v(t._s(e.playtime))]),t._v(" "),n("img",{directives:[{name:"lazy",rawName:"v-lazy.container",value:e.titlepic,expression:"section.titlepic",modifiers:{container:!0}}]})]),t._v(" "),n("div",{staticClass:"playRound"},[n("div",{staticClass:"playSan"})])]),t._v(" "),n("list-info",{attrs:{json:e}})],1)],1):e.ptitlepic?n("li",[n("router-link",{staticClass:"oneLarge",attrs:{to:t.url(e)}},[n("div",{staticClass:"news_title"},[n("h3",{domProps:{innerHTML:t._s(e.title)}})]),t._v(" "),n("div",{staticClass:"news_img"},[n("img",{directives:[{name:"lazy",rawName:"v-lazy.container",value:e.ptitlepic,expression:"section.ptitlepic",modifiers:{container:!0}}]})]),t._v(" "),n("list-info",{attrs:{json:e}})],1)],1):e.titlepic3?n("li",[n("router-link",{staticClass:"threeSmall",attrs:{to:t.url(e)}},[n("div",{staticClass:"news_title"},[n("h3",{domProps:{innerHTML:t._s(e.title)}})]),t._v(" "),n("div",{staticClass:"list_img"},[n("ul",[n("li",[n("img",{directives:[{name:"lazy",rawName:"v-lazy.container",value:e.titlepic,expression:"section.titlepic",modifiers:{container:!0}}]})]),t._v(" "),n("li",[n("img",{directives:[{name:"lazy",rawName:"v-lazy.container",value:e.titlepic2,expression:"section.titlepic2",modifiers:{container:!0}}]})]),t._v(" "),n("li",[n("img",{directives:[{name:"lazy",rawName:"v-lazy.container",value:e.titlepic3,expression:"section.titlepic3",modifiers:{container:!0}}]})])])]),t._v(" "),n("list-info",{attrs:{json:e}})],1)],1):e.titlepic?n("li",[n("router-link",{staticClass:"oneSmall",attrs:{to:t.url(e)}},[n("div",{staticClass:"news_title"},[n("h3",{domProps:{innerHTML:t._s(e.title)}}),t._v(" "),n("list-info",{attrs:{json:e}})],1),t._v(" "),n("div",{staticClass:"news_img"},[n("img",{directives:[{name:"lazy",rawName:"v-lazy.container",value:e.titlepic,expression:"section.titlepic",modifiers:{container:!0}}]})])])],1):e.title?n("li",[n("router-link",{staticClass:"text",attrs:{to:t.url(e)}},[n("h3",{domProps:{innerHTML:t._s(e.title)}}),t._v(" "),n("list-info",{attrs:{json:e}})],1)],1):e.type?n("li",{attrs:{id:"lookHere"}},[t._m(0,!0)]):t._e()]})],2)},It=[function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("p",[t._v("上次看到这里,点击刷新 "),n("i",{staticClass:"icon-refresh"})])}],Ot={render:Et,staticRenderFns:It},Ft=Ot,Vt=n("VU/8"),Bt=c,Ht=Vt(Ut,Ft,!1,Bt,null,null),qt=Ht.exports,Dt={props:["itemJson"]},Wt=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("section",{staticClass:"comment_item"},[n("div",{staticClass:"topFooter"},[n("div",{staticClass:"top"},[n("div",{staticClass:"portrait"},[n("img",{attrs:{src:t.itemJson.headimgurl}})]),t._v(" "),n("div",{staticClass:"name"},[t._v(t._s(t.itemJson.nickname))])]),t._v(" "),n("div",{staticClass:"mid"},[n("div",{staticClass:"content_text"},[t._v("\n "+t._s(t.itemJson.content)+"\n "),t.itemJson.altuser?n("span",{staticClass:"altUser"},[t._v("//\n "),n("span",{staticClass:"altUser_name"},[t._v("@"+t._s(t.itemJson.altuser.nickname))]),t._v(" "),n("span",{staticClass:"altUser_content"},[t._v(":"+t._s(t.itemJson.altuser.content))])]):t._e()])]),t._v(" "),n("div",{staticClass:"footer"},[t.itemJson.plnum>0?n("span",{staticClass:"reply"},[t._v(t._s(t.itemJson.plnum)+"回复 · ")]):t._e(),t._v(" "),t.itemJson.dznum?n("span",{staticClass:"zan"},[t._v(t._s(t.itemJson.dznum)+"赞 · ")]):t._e(),t._v(" "),t.itemJson.time?n("span",{staticClass:"time"},[t._v(t._s(t.itemJson.time))]):t._e()])])])},Gt=[],Qt={render:Wt,staticRenderFns:Gt},Xt=Qt,Yt=n("VU/8"),Kt=l,Zt=Yt(Dt,Xt,!1,Kt,null,null),te=Zt.exports,ee={props:["json"],data:function(){return{swiperOption:{notNextTick:!0,loop:!0,direction:"horizontal",autoplay:3e3,pagination:".swiper-pagination",autoplayDisableOnInteraction:!1}}},methods:{url:function(t){return"/detail?classid="+t.classid+"&id="+t.id}}},ne=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",{staticClass:"banner"},[n("swiper",{ref:"mySwiper",staticClass:"swiper-box",attrs:{options:t.swiperOption}},t._l(t.json,function(e){return n("swiper-slide",{key:e},[n("router-link",{attrs:{to:t.url(e)}},[n("img",{attrs:{src:e.ptitlepic}}),t._v(" "),n("div",{staticClass:"banner_title"},[n("p",[t._v(t._s(e.title))])])])],1)})),t._v(" "),n("div",{staticClass:"swiper-pagination",attrs:{slot:"pagination"},slot:"pagination"})],1)},ie=[],se={render:ne,staticRenderFns:ie},ae=se,re=n("VU/8"),oe=u,ce=re(ee,ae,!1,oe,null,null),le=ce.exports,ue={props:{value:{type:Boolean,default:!1}},data:function(){return{visible:!1}},methods:{cancel:function(){this.visible=!1}},watch:{value:function(t){this.visible=t},visible:function(t){this.$emit("input",t)}}},de=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",{attrs:{id:"popupMenu"}},[n("transition",{attrs:{name:"toggleSide"}},[n("div",{directives:[{name:"show",rawName:"v-show",value:t.visible,expression:"visible"}],staticClass:"functionItem"},[t._t("default"),t._v(" "),n("div",{staticClass:"cancle",on:{click:t.cancel}},[t._v("取消")])],2)]),t._v(" "),n("div",{directives:[{name:"show",rawName:"v-show",value:t.visible,expression:"visible"}],staticClass:"black",on:{click:t.cancel}}),t._v(" "),n("input",{staticStyle:{display:"none"},attrs:{type:"text"},domProps:{value:t.value}})],1)},pe=[],ve={render:de,staticRenderFns:pe},fe=ve,_e=n("VU/8"),me=d,he=_e(ue,fe,!1,me,null,null),xe=he.exports,we=n("uyT5"),ge=n("yyl+");p.default.directive("swiper",{inserted:function(t,e,n){if(!e.value)return"";Object(we.a)(t,e.arg,e.value,n.context)}}),p.default.directive("goTop",{inserted:function(t,e,n){if(!e.value)return"";Object(ge.a)(t,e.arg,n.context)}}),p.default.config.productionTip=!1,p.default.use(K.a),p.default.prototype.$toast=Y.Toast,p.default.prototype.$msgBox=Y.MessageBox,p.default.prototype.$indicator=Y.Indicator,p.default.use(tt.a),p.default.component("my-header",lt),p.default.component("my-loading",xt),p.default.component("my-error",Pt),p.default.component("list-info",Mt),p.default.component("list-item",qt),p.default.component("comment-item",te),p.default.component("my-banner",le),p.default.component("popup-menu",xe),new p.default({el:"#app",router:P,store:X,template:"",components:{App:C}})},RRfq:function(t,e){},TuU3:function(t,e,n){"use strict";var i=n("mvHQ"),s=n.n(i);e.a={getSession:function(t){if(t)return window.sessionStorage.getItem(t)},setSession:function(t,e){t&&("string"!=typeof e&&(e=s()(e)),window.sessionStorage.setItem(t,e))},removeSession:function(t){t&&window.sessionStorage.removeItem(t)},getLocal:function(t){if(t)return window.localStorage.getItem(t)},setLocal:function(t,e){t&&("string"!=typeof e&&(e=s()(e)),window.localStorage.setItem(t,e))},removeLocal:function(t){t&&window.localStorage.removeItem(t)}}},Vu75:function(t,e){},bgQv:function(t,e){},cLP1:function(t,e){},d4q3:function(t,e){},"d8/S":function(t,e){},dRPW:function(t,e){},pYmz:function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i="undefined"!=typeof window;i&&(window.Swiper=n("gsqX"));var s={name:"swiper",props:{options:{type:Object,default:function(){return{autoplay:3500}}},notNextTick:{type:Boolean,default:function(){return!1}}},data:function(){return{defaultSwiperClasses:{wrapperClass:"swiper-wrapper"}}},ready:function(){!this.swiper&&i&&(this.swiper=new Swiper(this.$el,this.options))},mounted:function(){var t=this,e=function(){if(!t.swiper&&i){delete t.options.notNextTick;var e=!1;for(var n in t.defaultSwiperClasses)t.defaultSwiperClasses.hasOwnProperty(n)&&t.options[n]&&(e=!0,t.defaultSwiperClasses[n]=t.options[n]);var s=function(){t.swiper=new Swiper(t.$el,t.options)};e?t.$nextTick(s):s()}}(this.options.notNextTick||this.notNextTick)?e():this.$nextTick(e)},updated:function(){this.swiper&&this.swiper.update()},beforeDestroy:function(){this.swiper&&(this.swiper.destroy(),delete this.swiper)}},a=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",{staticClass:"swiper-container"},[t._t("parallax-bg"),t._v(" "),n("div",{class:t.defaultSwiperClasses.wrapperClass},[t._t("default")],2),t._v(" "),t._t("pagination"),t._v(" "),t._t("button-prev"),t._v(" "),t._t("button-next"),t._v(" "),t._t("scrollbar")],2)},r=[],o={render:a,staticRenderFns:r},c=o,l=n("VU/8"),u=l(s,c,!1,null,null,null);e.default=u.exports},rQJG:function(t,e){},uyT5:function(t,e,n){"use strict";(function(t){function n(t,e,n,i,s){var a=e-i,r=n-t,o=void 0;if(!(Math.abs(r)=-45&&c<30?o="swiperRight":c>=45&&c<135?o="swiperUp":c>=-135&&c<-45?o="swiperDown":(c>=135&&c<=180||c>=-180&&c<-135)&&(o="swiperLeft"),o}}function i(e,i,s,a){if(e&&i){var r=void 0,o=void 0,c=void 0;e.addEventListener("touchstart",function(t){r="",o=t.touches[0].pageX,c=t.touches[0].pageY},!1),e.addEventListener("touchmove",function(e){var i=void 0,l=void 0;if(i=e.changedTouches[0].pageX,l=e.changedTouches[0].pageY,r=n(o,c,i,l,50),"blur"===s){var u=t(a.$el.querySelector("#input"));u.is(":focus")&&u.blur()}},!1),e.addEventListener("touchend",function(t){i===r&&a.$router.go(-1)},!1)}}e.a=i}).call(e,n("7t+N"))},v2ns:function(t,e){},"yyl+":function(t,e,n){"use strict";(function(t){function n(e,n,i){"click"===n&&t(e).on("click",function(){t(i.$el.querySelector(".container")).animate({scrollTop:0})})}e.a=n}).call(e,n("7t+N"))}},["NHnr"]); -------------------------------------------------------------------------------- /docs/static/js/manifest.3d15a8c1b518e48f0f2d.js: -------------------------------------------------------------------------------- 1 | !function(e){function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}var r=window.webpackJsonp;window.webpackJsonp=function(t,c,a){for(var i,u,f,d=0,s=[];ds;)for(var p,b=u(arguments[s++]),O=l?o(b).concat(l(b)):o(b),d=O.length,j=0;d>j;)i.call(b,p=O[j++])&&(e[p]=b[p]);return e}:a},V3tA:function(t,n,e){e("R4wc"),t.exports=e("FeBl").Object.assign},woOf:function(t,n,e){t.exports={default:e("V3tA"),__esModule:!0}}}); -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 健康头条-看头条,知健康 12 | 13 | 14 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "vue2-news", 3 | "version": "1.0.0", 4 | "description": "A Vue.js project", 5 | "author": "uncleLian <771674109@qq.com> https://github.com/uncleLian", 6 | "private": true, 7 | "scripts": { 8 | "dev": "webpack-dev-server --inline --progress --config build/webpack.dev.conf.js", 9 | "start": "npm run dev", 10 | "lint": "eslint --ext .js,.vue src", 11 | "build": "node build/build.js" 12 | }, 13 | "dependencies": { 14 | "amfe-flexible": "^2.2.1", 15 | "axios": "^0.17.1", 16 | "babel-polyfill": "^6.26.0", 17 | "jquery": "^3.2.1", 18 | "mint-ui": "^2.2.13", 19 | "qs": "^6.5.1", 20 | "vue": "^2.5.13", 21 | "vue-awesome-swiper": "^2.6.7", 22 | "vue-router": "^3.0.1", 23 | "vuex": "^3.0.1" 24 | }, 25 | "devDependencies": { 26 | "autoprefixer": "^7.1.2", 27 | "babel-core": "^6.22.1", 28 | "babel-eslint": "^7.1.1", 29 | "babel-loader": "^7.1.1", 30 | "babel-plugin-transform-runtime": "^6.22.0", 31 | "babel-preset-env": "^1.3.2", 32 | "babel-preset-stage-2": "^6.22.0", 33 | "babel-register": "^6.22.0", 34 | "chalk": "^2.0.1", 35 | "copy-webpack-plugin": "^4.0.1", 36 | "css-loader": "^0.28.0", 37 | "eslint": "^3.19.0", 38 | "eslint-config-standard": "^10.2.1", 39 | "eslint-friendly-formatter": "^3.0.0", 40 | "eslint-loader": "^1.7.1", 41 | "eslint-plugin-html": "^3.0.0", 42 | "eslint-plugin-import": "^2.7.0", 43 | "eslint-plugin-node": "^5.2.0", 44 | "eslint-plugin-promise": "^3.4.0", 45 | "eslint-plugin-standard": "^3.0.1", 46 | "eventsource-polyfill": "^0.9.6", 47 | "extract-text-webpack-plugin": "^3.0.0", 48 | "file-loader": "^1.1.4", 49 | "friendly-errors-webpack-plugin": "^1.6.1", 50 | "html-webpack-plugin": "^2.30.1", 51 | "node-notifier": "^5.1.2", 52 | "optimize-css-assets-webpack-plugin": "^3.2.0", 53 | "ora": "^1.2.0", 54 | "portfinder": "^1.0.13", 55 | "postcss-import": "^11.0.0", 56 | "postcss-loader": "^2.0.8", 57 | "rimraf": "^2.6.0", 58 | "semver": "^5.3.0", 59 | "shelljs": "^0.7.6", 60 | "stylus": "^0.54.5", 61 | "stylus-loader": "^3.0.1", 62 | "url-loader": "^0.5.8", 63 | "vue-loader": "^13.3.0", 64 | "vue-style-loader": "^3.0.1", 65 | "vue-template-compiler": "^2.5.13", 66 | "webpack": "^3.6.0", 67 | "webpack-bundle-analyzer": "^2.9.0", 68 | "webpack-dev-server": "^2.9.1", 69 | "webpack-merge": "^4.1.0" 70 | }, 71 | "engines": { 72 | "node": ">= 4.0.0", 73 | "npm": ">= 3.0.0" 74 | }, 75 | "browserslist": [ 76 | "> 1%", 77 | "last 2 versions", 78 | "not ie <= 8" 79 | ] 80 | } 81 | -------------------------------------------------------------------------------- /screenshots/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uncleLian/vue2-news/1c198d96059b6c51d78259d45ce2bc563df305b7/screenshots/.DS_Store -------------------------------------------------------------------------------- /screenshots/web_QRcode.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uncleLian/vue2-news/1c198d96059b6c51d78259d45ce2bc563df305b7/screenshots/web_QRcode.png -------------------------------------------------------------------------------- /screenshots/web_detail.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uncleLian/vue2-news/1c198d96059b6c51d78259d45ce2bc563df305b7/screenshots/web_detail.png -------------------------------------------------------------------------------- /screenshots/web_index.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uncleLian/vue2-news/1c198d96059b6c51d78259d45ce2bc563df305b7/screenshots/web_index.png -------------------------------------------------------------------------------- /screenshots/web_search.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uncleLian/vue2-news/1c198d96059b6c51d78259d45ce2bc563df305b7/screenshots/web_search.png -------------------------------------------------------------------------------- /screenshots/web_search2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uncleLian/vue2-news/1c198d96059b6c51d78259d45ce2bc563df305b7/screenshots/web_search2.png -------------------------------------------------------------------------------- /src/App.vue: -------------------------------------------------------------------------------- 1 | 10 | 29 | 41 | -------------------------------------------------------------------------------- /src/assets/css/global.css: -------------------------------------------------------------------------------- 1 | html{ 2 | font-size: 37.5px; /* 解决UC浏览,rem适配问题 https://www.cnblogs.com/chenrong/articles/4686601.html */ 3 | } 4 | .content { 5 | width: 100%; 6 | height: 100%; 7 | padding-top: 1.335rem; 8 | position: relative; 9 | } 10 | .container { 11 | height: 100%; 12 | overflow: auto; 13 | position: relative; 14 | -webkit-overflow-scrolling: touch; 15 | } 16 | 17 | .bottomLoad{ 18 | width: 100%; 19 | position: relative; 20 | } 21 | 22 | .bottomLoad div{ 23 | width: 100%; 24 | height: 50px; 25 | line-height: 50px; 26 | text-align: center; 27 | font-size: 16px; 28 | color: #999; 29 | } -------------------------------------------------------------------------------- /src/assets/css/icon.css: -------------------------------------------------------------------------------- 1 | /*back图标*/ 2 | .back-white { 3 | background: url(~@/assets/img/back-white.png) no-repeat center center; 4 | background-size: 20px; 5 | } 6 | .back-black { 7 | background: url(~@/assets/img/back-black.png) no-repeat center center; 8 | background-size: 20px; 9 | } 10 | 11 | /*close图标*/ 12 | .close-white { 13 | background: url(~@/assets/img/close-white.png) no-repeat center center; 14 | background-size: 20px; 15 | } 16 | .close-black { 17 | background: url(~@/assets/img/close-black.png) no-repeat center center; 18 | background-size: 20px; 19 | } 20 | 21 | /*edit图标*/ 22 | .edit-white { 23 | background: url(~@/assets/img/edit-white.png) no-repeat center center; 24 | background-size: 20px; 25 | } 26 | .edit-black { 27 | background: url(~@/assets/img/edit-black.png) no-repeat center center; 28 | background-size: 20px; 29 | } 30 | 31 | .icon-refresh { 32 | display: inline-block; 33 | vertical-align: middle; 34 | width: 12px; 35 | height: 12px; 36 | background: url(~@/assets/img/icon-refresh.png) no-repeat center center; 37 | background-size: contain; 38 | margin-top: -2px; 39 | } -------------------------------------------------------------------------------- /src/assets/css/reset.css: -------------------------------------------------------------------------------- 1 | *{ 2 | box-sizing:border-box; 3 | } 4 | html{ 5 | width: 100%; 6 | height: 100%; 7 | touch-action: manipulation; /* IE11+ 禁止双击缩放,关于移动端300ms延迟:https://github.com/ftlabs/fastclick */ 8 | -ms-touch-action: manipulation /* IE10+ 禁止双击缩放 */ 9 | } 10 | body{ 11 | width: 100%; 12 | height: 100%; 13 | font-family: Microsoft YaHei,STHeiti,Helvetica,Arial,sans-serif; 14 | } 15 | img{vertical-align: top;border: 0;} 16 | ul, li, ol{ 17 | list-style-type: none; 18 | } 19 | a, blockquote, body, button, code, dd, div, dl, dt, em, fieldset, form, h1, h2, h3, h4, h5, h6, html,iframe, img, input, label, li, object, ol, p, q, small, span, strong, table, tbody, td, th, tr, ul { 20 | margin: 0; 21 | padding: 0; 22 | border: 0; 23 | } 24 | h1, h2, h3, h4, h5, h6{ 25 | font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; 26 | } 27 | button, input, select, textarea { font-size: 100%; line-height:normal; } 28 | button, input, select, label{vertical-align:middle;} 29 | table{ border-collapse: collapse; border-spacing: 0; } 30 | input[type="button"],input[type="submit"],input[type="reset"]{cursor:pointer;} 31 | a{color: #333; outline: none; text-decoration: none;} 32 | a:focus{outline: none;} 33 | .clearfix:after {visibility:hidden;display:block;font-size:0;content:" ";clear:both;height:0;} 34 | .clearfix {zoom:1; } -------------------------------------------------------------------------------- /src/assets/css/transition.css: -------------------------------------------------------------------------------- 1 | /*过度效果*/ 2 | .slide-left-enter,.slide-right-leave-active { 3 | transform: translate3d(100%, 0, 0); 4 | } 5 | .slide-left-leave-active,.slide-right-enter { 6 | transform: translate3d(-100%, 0, 0); 7 | } 8 | .toggleSide-enter,.toggleSide-leave-active{ 9 | -webkit-transform: translate3d(0, 100%, 0); 10 | transform: translate3d(0, 100%, 0); 11 | } 12 | .toggleSide-enter-active,.toggleSide-leave{ 13 | -webkit-transform: translate3d(0, 0%, 0); 14 | transform: translate3d(0, 0%, 0); 15 | } 16 | /*动画效果*/ 17 | .fadeIn-enter-active { 18 | animation: fadeInRight .3s ease; 19 | } 20 | .fadeIn-leave-active { 21 | animation: fadeOutRight .3s ease; 22 | } 23 | @keyframes fadeInRight { 24 | from { 25 | opacity: 0; 26 | transform: translate3d(100%, 0, 0); 27 | } 28 | to { 29 | opacity: 1; 30 | transform: none; 31 | } 32 | } 33 | @keyframes fadeOutRight { 34 | from { 35 | opacity: 1; 36 | } 37 | to { 38 | opacity: 0; 39 | transform: translate3d(100%, 0, 0); 40 | } 41 | } 42 | @keyframes zoomIn { 43 | 0% { 44 | opacity: 0; 45 | -webkit-transform: scale3d(.3,.3,.3); 46 | transform: scale3d(.3,.3,.3); 47 | } 48 | 50% { 49 | opacity: 1; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/assets/fonts/icomoon.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uncleLian/vue2-news/1c198d96059b6c51d78259d45ce2bc563df305b7/src/assets/fonts/icomoon.eot -------------------------------------------------------------------------------- /src/assets/fonts/icomoon.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Generated by IcoMoon 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /src/assets/fonts/icomoon.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uncleLian/vue2-news/1c198d96059b6c51d78259d45ce2bc563df305b7/src/assets/fonts/icomoon.ttf -------------------------------------------------------------------------------- /src/assets/fonts/icomoon.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uncleLian/vue2-news/1c198d96059b6c51d78259d45ce2bc563df305b7/src/assets/fonts/icomoon.woff -------------------------------------------------------------------------------- /src/assets/img/back-black.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uncleLian/vue2-news/1c198d96059b6c51d78259d45ce2bc563df305b7/src/assets/img/back-black.png -------------------------------------------------------------------------------- /src/assets/img/back-white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uncleLian/vue2-news/1c198d96059b6c51d78259d45ce2bc563df305b7/src/assets/img/back-white.png -------------------------------------------------------------------------------- /src/assets/img/back_right.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uncleLian/vue2-news/1c198d96059b6c51d78259d45ce2bc563df305b7/src/assets/img/back_right.png -------------------------------------------------------------------------------- /src/assets/img/close-black.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uncleLian/vue2-news/1c198d96059b6c51d78259d45ce2bc563df305b7/src/assets/img/close-black.png -------------------------------------------------------------------------------- /src/assets/img/close-white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uncleLian/vue2-news/1c198d96059b6c51d78259d45ce2bc563df305b7/src/assets/img/close-white.png -------------------------------------------------------------------------------- /src/assets/img/close.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uncleLian/vue2-news/1c198d96059b6c51d78259d45ce2bc563df305b7/src/assets/img/close.png -------------------------------------------------------------------------------- /src/assets/img/collect-active.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uncleLian/vue2-news/1c198d96059b6c51d78259d45ce2bc563df305b7/src/assets/img/collect-active.png -------------------------------------------------------------------------------- /src/assets/img/collect.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uncleLian/vue2-news/1c198d96059b6c51d78259d45ce2bc563df305b7/src/assets/img/collect.png -------------------------------------------------------------------------------- /src/assets/img/comment.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uncleLian/vue2-news/1c198d96059b6c51d78259d45ce2bc563df305b7/src/assets/img/comment.png -------------------------------------------------------------------------------- /src/assets/img/cover_bg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uncleLian/vue2-news/1c198d96059b6c51d78259d45ce2bc563df305b7/src/assets/img/cover_bg.png -------------------------------------------------------------------------------- /src/assets/img/downLoad.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uncleLian/vue2-news/1c198d96059b6c51d78259d45ce2bc563df305b7/src/assets/img/downLoad.png -------------------------------------------------------------------------------- /src/assets/img/edit-black.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uncleLian/vue2-news/1c198d96059b6c51d78259d45ce2bc563df305b7/src/assets/img/edit-black.png -------------------------------------------------------------------------------- /src/assets/img/edit-white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uncleLian/vue2-news/1c198d96059b6c51d78259d45ce2bc563df305b7/src/assets/img/edit-white.png -------------------------------------------------------------------------------- /src/assets/img/goTop.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uncleLian/vue2-news/1c198d96059b6c51d78259d45ce2bc563df305b7/src/assets/img/goTop.png -------------------------------------------------------------------------------- /src/assets/img/header_back.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uncleLian/vue2-news/1c198d96059b6c51d78259d45ce2bc563df305b7/src/assets/img/header_back.png -------------------------------------------------------------------------------- /src/assets/img/hot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uncleLian/vue2-news/1c198d96059b6c51d78259d45ce2bc563df305b7/src/assets/img/hot.png -------------------------------------------------------------------------------- /src/assets/img/icon-refresh.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uncleLian/vue2-news/1c198d96059b6c51d78259d45ce2bc563df305b7/src/assets/img/icon-refresh.png -------------------------------------------------------------------------------- /src/assets/img/loading.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uncleLian/vue2-news/1c198d96059b6c51d78259d45ce2bc563df305b7/src/assets/img/loading.gif -------------------------------------------------------------------------------- /src/assets/img/loading.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uncleLian/vue2-news/1c198d96059b6c51d78259d45ce2bc563df305b7/src/assets/img/loading.png -------------------------------------------------------------------------------- /src/assets/img/loading_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uncleLian/vue2-news/1c198d96059b6c51d78259d45ce2bc563df305b7/src/assets/img/loading_logo.png -------------------------------------------------------------------------------- /src/assets/img/menu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uncleLian/vue2-news/1c198d96059b6c51d78259d45ce2bc563df305b7/src/assets/img/menu.png -------------------------------------------------------------------------------- /src/assets/img/menu_more.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uncleLian/vue2-news/1c198d96059b6c51d78259d45ce2bc563df305b7/src/assets/img/menu_more.png -------------------------------------------------------------------------------- /src/assets/img/more.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uncleLian/vue2-news/1c198d96059b6c51d78259d45ce2bc563df305b7/src/assets/img/more.png -------------------------------------------------------------------------------- /src/assets/img/myColorp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uncleLian/vue2-news/1c198d96059b6c51d78259d45ce2bc563df305b7/src/assets/img/myColorp.png -------------------------------------------------------------------------------- /src/assets/img/myLogin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uncleLian/vue2-news/1c198d96059b6c51d78259d45ce2bc563df305b7/src/assets/img/myLogin.png -------------------------------------------------------------------------------- /src/assets/img/news_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uncleLian/vue2-news/1c198d96059b6c51d78259d45ce2bc563df305b7/src/assets/img/news_logo.png -------------------------------------------------------------------------------- /src/assets/img/qq.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uncleLian/vue2-news/1c198d96059b6c51d78259d45ce2bc563df305b7/src/assets/img/qq.png -------------------------------------------------------------------------------- /src/assets/img/qq_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uncleLian/vue2-news/1c198d96059b6c51d78259d45ce2bc563df305b7/src/assets/img/qq_1.png -------------------------------------------------------------------------------- /src/assets/img/qzone.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uncleLian/vue2-news/1c198d96059b6c51d78259d45ce2bc563df305b7/src/assets/img/qzone.png -------------------------------------------------------------------------------- /src/assets/img/repeat.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uncleLian/vue2-news/1c198d96059b6c51d78259d45ce2bc563df305b7/src/assets/img/repeat.png -------------------------------------------------------------------------------- /src/assets/img/search.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uncleLian/vue2-news/1c198d96059b6c51d78259d45ce2bc563df305b7/src/assets/img/search.png -------------------------------------------------------------------------------- /src/assets/img/shadow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uncleLian/vue2-news/1c198d96059b6c51d78259d45ce2bc563df305b7/src/assets/img/shadow.png -------------------------------------------------------------------------------- /src/assets/img/share.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uncleLian/vue2-news/1c198d96059b6c51d78259d45ce2bc563df305b7/src/assets/img/share.png -------------------------------------------------------------------------------- /src/assets/img/sina_wb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uncleLian/vue2-news/1c198d96059b6c51d78259d45ce2bc563df305b7/src/assets/img/sina_wb.png -------------------------------------------------------------------------------- /src/assets/img/wx_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uncleLian/vue2-news/1c198d96059b6c51d78259d45ce2bc563df305b7/src/assets/img/wx_1.png -------------------------------------------------------------------------------- /src/assets/img/wx_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uncleLian/vue2-news/1c198d96059b6c51d78259d45ce2bc563df305b7/src/assets/img/wx_2.png -------------------------------------------------------------------------------- /src/assets/img/wx_friend.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uncleLian/vue2-news/1c198d96059b6c51d78259d45ce2bc563df305b7/src/assets/img/wx_friend.png -------------------------------------------------------------------------------- /src/assets/img/wx_pyq.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uncleLian/vue2-news/1c198d96059b6c51d78259d45ce2bc563df305b7/src/assets/img/wx_pyq.png -------------------------------------------------------------------------------- /src/components/banner.vue: -------------------------------------------------------------------------------- 1 | 16 | 38 | 82 | -------------------------------------------------------------------------------- /src/components/commentItem.vue: -------------------------------------------------------------------------------- 1 | 28 | 33 | 91 | -------------------------------------------------------------------------------- /src/components/error.vue: -------------------------------------------------------------------------------- 1 | 9 | 21 | 52 | -------------------------------------------------------------------------------- /src/components/info.vue: -------------------------------------------------------------------------------- 1 | 14 | 30 | 60 | -------------------------------------------------------------------------------- /src/components/listItem.vue: -------------------------------------------------------------------------------- 1 | 75 | 85 | 290 | -------------------------------------------------------------------------------- /src/components/loading.vue: -------------------------------------------------------------------------------- 1 | 14 | 35 | 78 | 84 | -------------------------------------------------------------------------------- /src/components/myHeader.vue: -------------------------------------------------------------------------------- 1 | 11 | 19 | 66 | -------------------------------------------------------------------------------- /src/components/popupMenu.vue: -------------------------------------------------------------------------------- 1 | 14 | 42 | 77 | -------------------------------------------------------------------------------- /src/directives/goTop.js: -------------------------------------------------------------------------------- 1 | // 点击滚动到顶部 2 | export default function goTop(el, eventType, vm) { 3 | if (eventType === 'click') { 4 | $(el).on('click', () => { 5 | $(vm.$el.querySelector('.container')).animate({ scrollTop: 0 }) 6 | }) 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /src/directives/index.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import swiper from './swiper' 3 | import goTop from './goTop' 4 | 5 | // 右滑返回上一页 6 | Vue.directive('swiper', { 7 | inserted: function(el, binding, vnode) { 8 | if (binding.value) { 9 | swiper(el, binding.arg, binding.value, vnode.context) 10 | } else { 11 | return '' 12 | } 13 | } 14 | }) 15 | // 点击头部返回页面顶部 16 | Vue.directive('goTop', { 17 | inserted: function(el, binding, vnode) { 18 | if (binding.value) { 19 | goTop(el, binding.arg, vnode.context) 20 | } else { 21 | return '' 22 | } 23 | } 24 | }) 25 | -------------------------------------------------------------------------------- /src/directives/swiper.js: -------------------------------------------------------------------------------- 1 | // 判断方向 2 | function GetSlideDirection(startX, startY, endX, endY, move) { 3 | let dy = startY - endY 4 | let dx = endX - startX 5 | let result 6 | // 如果滑动距离太短 7 | if (Math.abs(dx) < move && Math.abs(dy) < move) { 8 | return 9 | } 10 | let angle = Math.atan2(dy, dx) * 180 / Math.PI // 获取角度 11 | if (angle >= -45 && angle < 30) { 12 | result = 'swiperRight' // 右 13 | } else if (angle >= 45 && angle < 135) { 14 | result = 'swiperUp' // 上 15 | } else if (angle >= -135 && angle < -45) { 16 | result = 'swiperDown' // 下 17 | } else if ((angle >= 135 && angle <= 180) || (angle >= -180 && angle < -135)) { 18 | result = 'swiperLeft' // 左 19 | } 20 | return result 21 | } 22 | 23 | // 根据触摸方向做相应需求 24 | export default function swiper(el, direction, type, vm) { 25 | if (!el || !direction) { 26 | return 27 | } 28 | let res // 结果 29 | let startX, startY 30 | el.addEventListener('touchstart', function(ev) { 31 | res = '' 32 | startX = ev.touches[0].pageX 33 | startY = ev.touches[0].pageY 34 | }, false) 35 | 36 | el.addEventListener('touchmove', function(ev) { 37 | let endX, endY 38 | endX = ev.changedTouches[0].pageX 39 | endY = ev.changedTouches[0].pageY 40 | res = GetSlideDirection(startX, startY, endX, endY, 50) 41 | // 如果组件传的类型为blur,找到当前组件的input元素失去焦点 42 | if (type === 'blur') { 43 | let input = $(vm.$el.querySelector('#input')) 44 | if (input.is(':focus')) { 45 | input.blur() 46 | } 47 | } 48 | }, false) 49 | 50 | el.addEventListener('touchend', function(ev) { 51 | // 触摸滑动的方向和组件传的方向相等,则返回上一页 52 | if (direction === res) { 53 | vm.$router.go(-1) 54 | } 55 | }, false) 56 | } 57 | -------------------------------------------------------------------------------- /src/main.js: -------------------------------------------------------------------------------- 1 | // The Vue build version to load with the `import` command 2 | // (runtime-only or standalone) has been set in webpack.base.conf with an alias. 3 | import 'babel-polyfill' 4 | import Vue from 'vue' 5 | import App from './App' 6 | import router from './router' 7 | import store from './store' 8 | 9 | // css 10 | import '@/assets/css/reset.css' 11 | import '@/assets/css/icon.css' 12 | import '@/assets/css/transition.css' 13 | import '@/assets/css/global.css' 14 | 15 | // 第三方库 16 | import MintUI, { MessageBox, Toast, Indicator } from 'mint-ui' // 饿了么移动端UI组件 17 | import 'mint-ui/lib/style.css' 18 | import VueAwesomeSwiper from 'vue-awesome-swiper' // swiper滑动组件 19 | import 'swiper/dist/css/swiper.css' 20 | 21 | // 自定义组件 22 | import myHeader from '@/components/myHeader' // header组件 23 | import myLoading from '@/components/loading' // loading组件 24 | import myError from '@/components/error' // error组件 25 | import listInfo from '@/components/info' // 文章列表信息组件 26 | import listItem from '@/components/listItem' // 文章列表组件 27 | import commentItem from '@/components/commentItem' // 评论列表组件 28 | import myBanner from '@/components/banner' // banner组件 29 | import popupMenu from '@/components/popupMenu' // 弹框组件 30 | 31 | import '@/directives' // 指令 32 | 33 | Vue.config.productionTip = false 34 | Vue.use(MintUI) 35 | Vue.prototype.$toast = Toast 36 | Vue.prototype.$msgBox = MessageBox 37 | Vue.prototype.$indicator = Indicator 38 | Vue.use(VueAwesomeSwiper) 39 | 40 | // 注册全局组件 41 | Vue.component('my-header', myHeader) 42 | Vue.component('my-loading', myLoading) 43 | Vue.component('my-error', myError) 44 | Vue.component('list-info', listInfo) 45 | Vue.component('list-item', listItem) 46 | Vue.component('comment-item', commentItem) 47 | Vue.component('my-banner', myBanner) 48 | Vue.component('popup-menu', popupMenu) 49 | 50 | /* eslint-disable no-new */ 51 | new Vue({ 52 | el: '#app', 53 | router, 54 | store, 55 | template: '', 56 | components: { App } 57 | }) 58 | -------------------------------------------------------------------------------- /src/page/detail/components/article.vue: -------------------------------------------------------------------------------- 1 | 51 | 141 | 313 | -------------------------------------------------------------------------------- /src/page/detail/components/recommend.vue: -------------------------------------------------------------------------------- 1 | 11 | 18 | 57 | -------------------------------------------------------------------------------- /src/page/detail/components/share.vue: -------------------------------------------------------------------------------- 1 | 33 | 54 | 95 | -------------------------------------------------------------------------------- /src/page/detail/components/tags.vue: -------------------------------------------------------------------------------- 1 | 6 | 20 | 38 | -------------------------------------------------------------------------------- /src/page/detail/detail.vue: -------------------------------------------------------------------------------- 1 | 42 | 161 | 244 | -------------------------------------------------------------------------------- /src/page/index/children/channel.vue: -------------------------------------------------------------------------------- 1 | 38 | 144 | 200 | -------------------------------------------------------------------------------- /src/page/index/components/index_footer.vue: -------------------------------------------------------------------------------- 1 | 12 | 32 | 88 | -------------------------------------------------------------------------------- /src/page/index/components/index_header.vue: -------------------------------------------------------------------------------- 1 | 28 | 94 | 220 | 235 | -------------------------------------------------------------------------------- /src/page/index/components/pullContainer.vue: -------------------------------------------------------------------------------- 1 | 36 | 222 | 262 | -------------------------------------------------------------------------------- /src/page/index/components/swiperContainer.vue: -------------------------------------------------------------------------------- 1 | 8 | 63 | 72 | -------------------------------------------------------------------------------- /src/page/index/index.vue: -------------------------------------------------------------------------------- 1 | 15 | 32 | 40 | -------------------------------------------------------------------------------- /src/page/search/search.vue: -------------------------------------------------------------------------------- 1 | 65 | 210 | 356 | -------------------------------------------------------------------------------- /src/router/index.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import Router from 'vue-router' 3 | import App from '../App' 4 | 5 | Vue.use(Router) 6 | 7 | Router.prototype.go = function() { 8 | this.isBack = true 9 | window.history.go(-1) 10 | } 11 | 12 | // 路由懒加载 13 | const index = () => import('@/page/index/index') 14 | const channel = () => import('@/page/index/children/channel') 15 | const detail = () => import('@/page/detail/detail') 16 | const search = () => import('@/page/search/search') 17 | 18 | export default new Router({ 19 | routes: [ 20 | { 21 | path: '', 22 | redirect: '/index', 23 | component: App, 24 | children: [ 25 | // index页面 26 | { 27 | name: 'index', 28 | path: '/index', 29 | component: index, 30 | children: [ 31 | // channel页面 32 | { 33 | name: 'channel', 34 | path: 'channel', 35 | component: channel 36 | } 37 | ] 38 | }, 39 | // detail页面 40 | { 41 | name: 'detail', 42 | path: '/detail', 43 | component: detail 44 | }, 45 | // search页面 46 | { 47 | name: 'search', 48 | path: '/search', 49 | component: search 50 | } 51 | ] 52 | } 53 | ] 54 | }) 55 | -------------------------------------------------------------------------------- /src/store/detail/index.js: -------------------------------------------------------------------------------- 1 | import cache from '@/utils/cache' 2 | import { request } from '@/utils/request' 3 | export default { 4 | namespaced: true, 5 | state: { 6 | historyArticle: {}, // 文章历史数据 7 | location: {} // 储存页面滚动条位置 8 | }, 9 | getters: { 10 | }, 11 | mutations: { 12 | set_historyArticle(state, val) { 13 | state.historyArticle = val 14 | cache.setSession('history_Article', val) 15 | }, 16 | set_location(state, val) { 17 | state.location = val 18 | } 19 | }, 20 | actions: { 21 | // 获取文章数据 22 | async get_Article_data({ commit, state }, { id, datafrom }) { 23 | let res 24 | let historyArticle 25 | historyArticle = JSON.parse(cache.getSession('history_Article')) 26 | if (historyArticle && historyArticle[id]) { 27 | res = historyArticle[id] 28 | } else { 29 | let params = { 30 | 'id': id, 31 | 'datafrom': datafrom 32 | } 33 | await request('post', 'Artilce', params) 34 | .then(json => { 35 | res = json.data 36 | state.historyArticle[id] = res 37 | historyArticle = state.historyArticle 38 | }) 39 | } 40 | commit('set_historyArticle', historyArticle) 41 | return res 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/store/index.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import Vuex from 'vuex' 3 | import index_module from './index/index' 4 | import detail_module from './detail/index' 5 | import search_module from './search/index' 6 | Vue.use(Vuex) 7 | 8 | // 本项目为了尽可能深入vue的层面,这里vuex使用modules,以页面级的方式来进行状态管理 (适合大型项目:native端将会展示) 9 | // 这里的全局状态可以用来管理类似:登录、设备信息等(更多内容请查看vuex官网) 10 | 11 | const state = { 12 | } 13 | 14 | const getters = { 15 | } 16 | 17 | const mutations = { 18 | } 19 | 20 | const actions = { 21 | } 22 | 23 | export default new Vuex.Store({ 24 | state, 25 | getters, 26 | mutations, 27 | actions, 28 | modules: { 29 | index: index_module, 30 | detail: detail_module, 31 | search: search_module 32 | } 33 | }) 34 | -------------------------------------------------------------------------------- /src/store/index/index.js: -------------------------------------------------------------------------------- 1 | import cache from '@/utils/cache' 2 | import { request } from '@/utils/request' 3 | export default { 4 | namespaced: true, 5 | state: { 6 | indexActive: 'news_recommend', // active的栏目 7 | indexPage: { news_recommend: 1 }, // 各个栏目page的对象 8 | indexLocation: { news_recommend: 0 }, // 各个栏目location的对象 9 | // 栏目数据 10 | indexColumn: [{ 11 | classname: '推荐', 12 | classid: 0, 13 | classpath: 'news_recommend' 14 | }], 15 | currentContent: '', // 当前栏目的缓存数据,为了刷新时不用再次请求 16 | indexSwiper: false // 页面是否在滑动 17 | }, 18 | getters: { 19 | activeMeta: state => { 20 | // 当前active的栏目的index、classid、page、location 21 | let index = state.indexColumn.findIndex(obj => obj.classpath === state.indexActive) 22 | let classid = state.indexColumn[index].classid 23 | let page = state.indexPage[state.indexActive] 24 | let location = state.indexLocation[state.indexActive] 25 | return { index, classid, page, location } 26 | } 27 | }, 28 | mutations: { 29 | set_indexActive(state, val) { 30 | state.indexActive = val 31 | cache.setSession('index_Active', val) 32 | }, 33 | set_indexPage(state, obj) { 34 | state.indexPage = obj 35 | cache.setSession('index_Page', obj) 36 | }, 37 | set_indexLocation(state, obj) { 38 | state.indexLocation = obj 39 | cache.setSession('index_Location', obj) 40 | }, 41 | set_indexColumn(state, arr) { 42 | state.indexColumn = arr 43 | cache.setSession('index_Column', arr) 44 | }, 45 | set_currentContent(state, val) { 46 | state.currentContent = val 47 | cache.setSession(`${state.indexActive}_json`, val) 48 | }, 49 | set_indexSwiper(state, val) { 50 | state.indexSwiper = val 51 | } 52 | }, 53 | actions: { 54 | // 获取active栏目缓存 55 | get_indexActive_cache({ commit, dispatch }) { 56 | const data = cache.getSession('index_Active') 57 | if (data) { 58 | commit('set_indexActive', data) 59 | } else { 60 | commit('set_indexActive', 'news_recommend') 61 | } 62 | }, 63 | 64 | // 获取page缓存 65 | get_indexPage_cache({ commit }, indexColumn) { 66 | const data = JSON.parse(cache.getSession('index_Page')) 67 | if (data) { 68 | commit('set_indexPage', data) 69 | } else { 70 | if (indexColumn) { 71 | let pageObj = {} 72 | indexColumn.forEach(item => { 73 | pageObj[item.classpath] = 1 74 | }) 75 | commit('set_indexPage', pageObj) 76 | } 77 | } 78 | }, 79 | 80 | // 获取location缓存 81 | get_indexLocation_cache({ commit }, indexColumn) { 82 | const data = JSON.parse(cache.getSession('index_Location')) 83 | if (data) { 84 | commit('set_indexLocation', data) 85 | } else { 86 | if (indexColumn) { 87 | let locationObj = {} 88 | indexColumn.forEach(item => { 89 | locationObj[item.classpath] = 0 90 | }) 91 | commit('set_indexLocation', locationObj) 92 | } 93 | } 94 | }, 95 | 96 | // 获取列表数据缓存 97 | get_listItem_cache({ commit, state }, activeType) { 98 | let data = JSON.parse(cache.getSession(`${state.indexActive}_json`)) 99 | return data 100 | }, 101 | 102 | // 获取栏目数据 103 | async get_indexColumn_data({commit, state, dispatch}) { 104 | let res 105 | const data = JSON.parse(cache.getSession('index_Column')) 106 | if (data) { 107 | res = data 108 | } else { 109 | let json = await request('post', 'classID') 110 | res = [...state.indexColumn, ...json] 111 | } 112 | commit('set_indexColumn', res) 113 | // 栏目数据是动态获取的,生成对应的page、location对象 114 | dispatch('get_indexPage_cache', res) 115 | dispatch('get_indexLocation_cache', res) 116 | dispatch('get_indexActive_cache') 117 | return res 118 | }, 119 | 120 | // 获取文章列表数据 121 | async get_listItem_data({ getters }, page) { 122 | let params = { 123 | 'classid': getters.activeMeta.classid, 124 | 'page': page 125 | } 126 | let res = await request('post', 'Class', params) 127 | return res 128 | }, 129 | 130 | // 获取置顶数据 131 | async get_stick_data({ commit, getters }) { 132 | let params = { 133 | 'classid': getters.activeMeta.classid, 134 | 'type': 'stick' 135 | } 136 | let res = await request('post', 'Stick', params) 137 | return res 138 | }, 139 | 140 | // 获取banner数据 141 | async get_banner_data({ commit, getters }) { 142 | let params = { 143 | 'classid': getters.activeMeta.classid, 144 | 'type': 'banner' 145 | } 146 | let res = await request('post', 'Stick', params) 147 | return res 148 | }, 149 | 150 | // 获取频道数据 151 | async get_channel_data({ state }) { 152 | let res = await request('post', 'classID', { 'channel': 'channel' }) 153 | return res 154 | } 155 | } 156 | } 157 | -------------------------------------------------------------------------------- /src/store/search/index.js: -------------------------------------------------------------------------------- 1 | import { request } from '@/utils/request' 2 | export default { 3 | namespaced: true, 4 | state: { 5 | }, 6 | getters: { 7 | }, 8 | mutations: { 9 | }, 10 | actions: { 11 | // 获取热点数据 12 | async get_hot_data() { 13 | let res = await request('post', 'Search') 14 | return res 15 | }, 16 | 17 | // 获取搜索数据 18 | async get_search_data({ commit, state }, { key, page }) { 19 | let res = await request('post', 'Search', { 'key': key, 'page': page }) 20 | return res 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/utils/cache.js: -------------------------------------------------------------------------------- 1 | export default { 2 | getSession: function(name) { 3 | if (!name) return 4 | return window.sessionStorage.getItem(name) 5 | }, 6 | setSession: function(name, content) { 7 | if (!name) return 8 | if (typeof content !== 'string') { 9 | content = JSON.stringify(content) 10 | } 11 | window.sessionStorage.setItem(name, content) 12 | }, 13 | removeSession: function(name) { 14 | if (!name) return 15 | window.sessionStorage.removeItem(name) 16 | }, 17 | getLocal: function(name) { 18 | if (!name) return 19 | return window.localStorage.getItem(name) 20 | }, 21 | setLocal: function(name, content) { 22 | if (!name) return 23 | if (typeof content !== 'string') { 24 | content = JSON.stringify(content) 25 | } 26 | window.localStorage.setItem(name, content) 27 | }, 28 | removeLocal: function(name) { 29 | if (!name) return 30 | window.localStorage.removeItem(name) 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/utils/request.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import axios from 'axios' 3 | import qs from 'qs' 4 | 5 | Vue.prototype.$http = axios 6 | axios.defaults.baseURL = 'http://data.toutiaojk.com/extend/list/' 7 | 8 | const ajaxURL = { 9 | // 主页 10 | classID: 'appclassid.php', // 栏目 11 | Class: 'appclass.php', // 栏目列表 12 | Stick: 'appistop.php', // 栏目置顶 13 | // 详情页 14 | Artilce: 'apparticle.php', // 文章 15 | Recommend: 'apptuijian.php', // 文章推荐 16 | // 搜索页 17 | Search: 'search.php' // 搜索 18 | } 19 | 20 | export var request = async(type = 'POST', url = '', data = {}) => { 21 | let result 22 | type = type.toUpperCase() 23 | url = ajaxURL[url] 24 | if (type === 'GET') { 25 | await axios.get(url, { params: data }) 26 | .then(res => { 27 | result = res.data 28 | }) 29 | } else if (type === 'POST') { 30 | await axios.post(url, qs.stringify(data)) 31 | .then(res => { 32 | result = res.data 33 | }) 34 | } 35 | return result 36 | } 37 | -------------------------------------------------------------------------------- /static/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uncleLian/vue2-news/1c198d96059b6c51d78259d45ce2bc563df305b7/static/.gitkeep -------------------------------------------------------------------------------- /static/js/amfe-flexible.min.js: -------------------------------------------------------------------------------- 1 | !function(e,t){function n(){t.body?t.body.style.fontSize=12*o+"px":t.addEventListener("DOMContentLoaded",n)}function d(){var e=i.clientWidth/10;i.style.fontSize=e+"px"}var i=t.documentElement,o=e.devicePixelRatio||1;if(n(),d(),e.addEventListener("resize",d),e.addEventListener("pageshow",function(e){e.persisted&&d()}),o>=2){var a=t.createElement("body"),s=t.createElement("div");s.style.border=".5px solid transparent",a.appendChild(s),i.appendChild(a),1===s.offsetHeight&&i.classList.add("hairlines"),i.removeChild(a)}}(window,document); --------------------------------------------------------------------------------