diff --git a/README.md b/README.md index 34a1d15..595d46f 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # com.frontend.www -> A Vue.js project +> 自用代码测试与部分功能实现项目 ## Build Setup diff --git a/build/check-versions.js b/build/check-versions.js index 3ef972a..72e13a5 100644 --- a/build/check-versions.js +++ b/build/check-versions.js @@ -1,54 +1,55 @@ -'use strict' -const chalk = require('chalk') -const semver = require('semver') -const packageConfig = require('../package.json') -const shell = require('shelljs') - -function exec (cmd) { - return require('child_process').execSync(cmd).toString().trim() +'use strict'; +const chalk = require('chalk'); +const semver = require('semver'); +const packageConfig = require('../package.json'); +const shell = require('shelljs'); + +function exec(cmd) { + return require('child_process').execSync(cmd).toString().trim(); } const versionRequirements = [ - { - name: 'node', - currentVersion: semver.clean(process.version), - versionRequirement: packageConfig.engines.node - } -] + { + name: 'node', + currentVersion: semver.clean(process.version), + versionRequirement: packageConfig.engines.node + } +]; if (shell.which('npm')) { - versionRequirements.push({ - name: 'npm', - currentVersion: exec('npm --version'), - versionRequirement: packageConfig.engines.npm - }) + versionRequirements.push({ + name: 'npm', + currentVersion: exec('npm --version'), + versionRequirement: packageConfig.engines.npm + }); } module.exports = function () { - const warnings = [] + const warnings = []; - for (let i = 0; i < versionRequirements.length; i++) { - const mod = versionRequirements[i] + for (let i = 0; i < versionRequirements.length; i++) { + const mod = versionRequirements[i]; + if (!semver.satisfies(mod.currentVersion, mod.versionRequirement)) { + warnings.push(mod.name + ': ' + + chalk.red(mod.currentVersion) + ' should be ' + + chalk.green(mod.versionRequirement) + ); + } - if (!semver.satisfies(mod.currentVersion, mod.versionRequirement)) { - warnings.push(mod.name + ': ' + - chalk.red(mod.currentVersion) + ' should be ' + - chalk.green(mod.versionRequirement) - ) } - } - if (warnings.length) { - console.log('') - console.log(chalk.yellow('To use this template, you must update following to modules:')) - console.log() + if (warnings.length) { + console.log(''); + console.log(chalk.yellow('To use this template, you must update following to modules:')); + console.log(); + + for (let i = 0; i < warnings.length; i++) { + const warning = warnings[i]; + console.log(' ' + warning); + } - for (let i = 0; i < warnings.length; i++) { - const warning = warnings[i] - console.log(' ' + warning) + console.log(); + process.exit(1); } - console.log() - process.exit(1) - } -} +}; diff --git a/build/utils.js b/build/utils.js index 38cb0d9..d28e9df 100644 --- a/build/utils.js +++ b/build/utils.js @@ -1,102 +1,107 @@ -'use strict' -const path = require('path') -const config = require('../config') -const ExtractTextPlugin = require('extract-text-webpack-plugin') -const packageConfig = require('../package.json') +'use strict'; +const path = require('path'); +const config = require('../config'); +const ExtractTextPlugin = require('extract-text-webpack-plugin'); +const packageConfig = require('../package.json'); exports.assetsPath = function (_path) { - const assetsSubDirectory = process.env.NODE_ENV === 'production' - ? config.build.assetsSubDirectory - : config.dev.assetsSubDirectory + const assetsSubDirectory = process.env.NODE_ENV === 'production' + ? config.build.assetsSubDirectory + : config.dev.assetsSubDirectory; - return path.posix.join(assetsSubDirectory, _path) -} + return path.posix.join(assetsSubDirectory, _path); +}; exports.cssLoaders = function (options) { - options = options || {} - - const cssLoader = { - loader: 'css-loader', - options: { - sourceMap: options.sourceMap + options = options || {}; + + const cssLoader = { + loader: 'css-loader', + options: { + sourceMap: options.sourceMap + } + }; + + const postcssLoader = { + loader: 'postcss-loader', + options: { + sourceMap: options.sourceMap + } + }; + + // generate loader string to be used with extract text plugin + function generateLoaders(loader, loaderOptions) { + const loaders = options.usePostCSS ? [cssLoader, postcssLoader] : [cssLoader]; + + if (loader) { + loaders.push({ + loader: loader + '-loader', + options: Object.assign({}, loaderOptions, { + sourceMap: options.sourceMap + }) + }); + } + + // Extract CSS when that option is specified + // (which is the case during production build) + if (options.extract) { + return ExtractTextPlugin.extract({ + use: loaders, + fallback: 'vue-style-loader', + publicPath: '../../' + }); + } + else { + return ['vue-style-loader'].concat(loaders); + } } - } - const postcssLoader = { - loader: 'postcss-loader', - options: { - sourceMap: options.sourceMap - } - } - - // generate loader string to be used with extract text plugin - function generateLoaders (loader, loaderOptions) { - const loaders = options.usePostCSS ? [cssLoader, postcssLoader] : [cssLoader] - - if (loader) { - loaders.push({ - loader: loader + '-loader', - options: Object.assign({}, loaderOptions, { - sourceMap: options.sourceMap - }) - }) - } - - // Extract CSS when that option is specified - // (which is the case during production build) - if (options.extract) { - return ExtractTextPlugin.extract({ - use: loaders, - fallback: 'vue-style-loader', - publicPath:'../../' - }) - } else { - return ['vue-style-loader'].concat(loaders) - } - } - - // https://vue-loader.vuejs.org/en/configurations/extract-css.html - return { - css: generateLoaders(), - postcss: generateLoaders(), - less: generateLoaders('less'), - sass: generateLoaders('sass', { indentedSyntax: true }), - scss: generateLoaders('sass'), - stylus: generateLoaders('stylus'), - styl: generateLoaders('stylus') - } -} + // https://vue-loader.vuejs.org/en/configurations/extract-css.html + return { + css: generateLoaders(), + postcss: generateLoaders(), + less: generateLoaders('less'), + sass: generateLoaders('sass', { + indentedSyntax: true + }), + scss: generateLoaders('sass'), + stylus: generateLoaders('stylus'), + styl: generateLoaders('stylus') + }; +}; // Generate loaders for standalone style files (outside of .vue) exports.styleLoaders = function (options) { - const output = [] - const loaders = exports.cssLoaders(options) - - for (const extension in loaders) { - const loader = loaders[extension] - output.push({ - test: new RegExp('\\.' + extension + '$'), - use: loader - }) - } + const output = []; + const loaders = exports.cssLoaders(options); + + for (const extension in loaders) { + const loader = loaders[extension]; + output.push({ + test: new RegExp('\\.' + extension + '$'), + use: loader + }); + } - return output -} + return output; +}; exports.createNotifierCallback = () => { - const notifier = require('node-notifier') - - return (severity, errors) => { - if (severity !== 'error') return - - const error = errors[0] - const filename = error.file && error.file.split('!').pop() - - notifier.notify({ - title: packageConfig.name, - message: severity + ': ' + error.name, - subtitle: filename || '', - icon: path.join(__dirname, 'logo.png') - }) - } -} + const notifier = require('node-notifier'); + + return (severity, errors) => { + if (severity !== 'error') { + return; + } + + const error = errors[0]; + const filename = error.file && error.file.split('!').pop(); + + notifier.notify({ + title: packageConfig.name, + message: severity + ': ' + error.name, + subtitle: filename || '', + icon: path.join(__dirname, 'logo.png') + }); + }; +}; diff --git a/package.json b/package.json index 304094d..df7d21b 100644 --- a/package.json +++ b/package.json @@ -11,10 +11,11 @@ "pm2": "pm2 start process/test.js" }, "dependencies": { - "axios": "^0.18.1", + "axios": "^0.21.1", "es6-promise": "^4.0.5", "html2canvas": "^1.0.0-rc.1", "iview": "^3.4.0", + "node-sass": "^6.0.0", "vue": "^2.5.2", "vue-router": "^3.0.1", "webpack-cli": "^3.3.12", @@ -38,8 +39,7 @@ "file-loader": "^1.1.4", "friendly-errors-webpack-plugin": "^1.6.1", "html-webpack-plugin": "^2.30.1", - "node-notifier": "^5.1.2", - "node-sass": "^3.10.1", + "node-notifier": "^8.0.1", "optimize-css-assets-webpack-plugin": "^3.2.0", "ora": "^1.2.0", "portfinder": "^1.0.13", diff --git a/src/App.vue b/src/App.vue index 29eab1a..b55abf4 100644 --- a/src/App.vue +++ b/src/App.vue @@ -6,8 +6,8 @@ diff --git a/src/components/HelloWorld.vue b/src/components/HelloWorld.vue index fcb5c24..97e1559 100644 --- a/src/components/HelloWorld.vue +++ b/src/components/HelloWorld.vue @@ -1,7 +1,7 @@ @@ -11,7 +11,7 @@ export default { data() { return { routerListData: [] - } + }; }, mounted() { if (this.$router @@ -21,7 +21,7 @@ export default { this.routerListData = this.$router.options.routes; } } -} +}; diff --git a/src/components/bottom-tip.vue b/src/components/bottom-tip.vue index 3ca3fb8..e1d5563 100644 --- a/src/components/bottom-tip.vue +++ b/src/components/bottom-tip.vue @@ -1,181 +1,186 @@ \ No newline at end of file diff --git a/src/components/drop-down-refresh.vue b/src/components/drop-down-refresh.vue index 8255dc7..f546b20 100644 --- a/src/components/drop-down-refresh.vue +++ b/src/components/drop-down-refresh.vue @@ -1,149 +1,155 @@ diff --git a/src/plugins/tools.js b/src/plugins/tools.js index 6ed943b..40ffa85 100644 --- a/src/plugins/tools.js +++ b/src/plugins/tools.js @@ -1,29 +1,34 @@ -var baseTool = { - simpleClone:function(obj) { - return JSON.parse(JSON.stringify(obj)) - }, - simpleExtend:function(to, from) { - var arr = []; - arr.forEach.call(arr.slice.call(arguments, 1), function(source) { - if (source) { - for (var prop in source) { +/** + * @file tools 工具类 + */ +let baseTool = { + simpleClone(obj) { + return JSON.parse(JSON.stringify(obj)); + }, + simpleExtend(to, from) { + let arr = []; + arr.forEach.call(arr.slice.call(arguments, 1), function (source) { + if (source) { + for (let prop in source) { to[prop] = source[prop]; } } + }); - return to; - }, - //todo: 传入的对象数组被赋值为对象了 - deepCopy:function (obj) { - if (typeof obj !== 'object') { - return obj; - } - var newobj = {}; - for (var attr in obj) { - newobj[attr] = baseTool.deepCopy(obj[attr]); - } - return newobj; - }, -} -export default baseTool; \ No newline at end of file + return to; + }, + // todo: 传入的对象数组被赋值为对象了 + deepCopy(obj) { + if (typeof obj !== 'object') { + return obj; + } + + let newobj = {}; + for (let attr in obj) { + newobj[attr] = baseTool.deepCopy(obj[attr]); + } + return newobj; + } +}; +export default baseTool; diff --git a/src/router/index.js b/src/router/index.js index 1bd82ce..2541a64 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -1,3 +1,6 @@ +/** + * @file route index.js + */ import Vue from 'vue'; import Router from 'vue-router'; import HelloWorld from '@/components/HelloWorld'; @@ -10,114 +13,142 @@ import Copy from '@/views/copy.vue'; import ChangeDatas from '@/views/changeDatas.vue'; import CssTest from '@/views/cssTest.vue'; import WholeLife from '@/views/wholeLife.vue'; -// import Extend from '@/views/extend.vue'; +import Extend from '@/views/extend.vue'; import ExpendCard from '@/views/expendCard.vue'; import VueQuillEditor from '@/views/vueQuillEditor.vue'; import Wechat from '@/views/wechat.vue'; import CssTestPhone from '@/views/cssTestPhone.vue'; import Tree from '@/views/tree.vue'; -// import Currying from '@/views/currying.vue'; +import Currying from '@/views/currying.vue'; import Proxy from '@/views/proxy.vue'; +import Tabindex from '@/views/tabindex.vue'; +import LeetCode from '@/views/leetCode.vue'; +import JsDbclick from '@/views/jsdbclick.vue'; +import MixBlendMode from '@/views/mixblendmode.vue'; -Vue.use(Router) +Vue.use(Router); export default new Router({ - mode:'history', - routes: [ - { - path: '/', - name: 'HelloWorld', - component: HelloWorld - }, - { - path: '/highLight.html', - name: 'HighLight', - component: HighLight - }, - { - path: '/pure.html', - name: 'Pure', - component: Pure - }, - { - path: '/pureModel.html', - name: 'PureModel', - component: PureModel - }, - { - path: '/jsTest.html', - name: 'JsTest', - component: JsTest - }, - { - path: '/countDown.html', - name: 'CountDown', - component: CountDown - }, - { - path: '/copy.html', - name: 'Copy', - component: Copy, - showInfo: 'Copy & Paste' - }, - { - path: '/changeDatas.html', - name: 'ChangeDatas', - component: ChangeDatas - }, - { - path: '/cssTest.html', - name: 'CssTest', - component: CssTest - }, - { - path: '/cssTestPhone.html', - name: 'CssTestPhone', - component: CssTestPhone - }, - { - path: '/wholeLife.html', - name: 'WholeLife', - component: WholeLife - }, - // { - // path: '/extend.html', - // name: 'Extend', - // component: Extend - // }, - { - path: '/expendCard.html', - name: 'ExpendCard', - component: ExpendCard - }, - { - path: '/quillEditor.html', - name: 'VueQuillEditor', - component: VueQuillEditor - }, - { - path: '/wechat.html', - name: 'Wechat', - component: Wechat, - showInfo: 'WechatQrCode' - }, - { - path: '/tree.html', - name: 'Tree', - component: Tree, - showInfo: '用 iView 实现 Tree' - }, - // { - // path: '/currying.html', - // name: 'Currying', - // component: Currying, - // showInfo: '手动实现 bind/call/apply/Currying' - // }, - { - path: '/proxy.html', - name: 'Proxy', - component: Proxy, - showInfo: 'Proxy 的使用' - } - ] -}) + mode: 'history', + routes: [ + { + path: '/', + name: 'HelloWorld', + component: HelloWorld + }, + { + path: '/highLight.html', + name: 'HighLight', + component: HighLight + }, + { + path: '/pure.html', + name: 'Pure', + component: Pure + }, + { + path: '/pureModel.html', + name: 'PureModel', + component: PureModel + }, + { + path: '/jsTest.html', + name: 'JsTest', + component: JsTest + }, + { + path: '/countDown.html', + name: 'CountDown', + component: CountDown + }, + { + path: '/copy.html', + name: 'Copy', + component: Copy, + showInfo: 'Copy & Paste' + }, + { + path: '/changeDatas.html', + name: 'ChangeDatas', + component: ChangeDatas + }, + { + path: '/cssTest.html', + name: 'CssTest', + component: CssTest + }, + { + path: '/cssTestPhone.html', + name: 'CssTestPhone', + component: CssTestPhone + }, + { + path: '/wholeLife.html', + name: 'WholeLife', + component: WholeLife + }, + { + path: '/extend.html', + name: 'Extend', + component: Extend + }, + { + path: '/expendCard.html', + name: 'ExpendCard', + component: ExpendCard + }, + { + path: '/quillEditor.html', + name: 'VueQuillEditor', + component: VueQuillEditor + }, + { + path: '/wechat.html', + name: 'Wechat', + component: Wechat, + showInfo: 'WechatQrCode' + }, + { + path: '/tree.html', + name: 'Tree', + component: Tree, + showInfo: '用 iView 实现 Tree' + }, + { + path: '/currying.html', + name: 'Currying', + component: Currying, + showInfo: '手动实现 bind/call/apply/Currying' + }, + { + path: '/proxy.html', + name: 'Proxy', + component: Proxy, + showInfo: 'Proxy 的使用' + }, + { + path: '/tabindex.html', + name: 'Tabindex', + component: Tabindex, + showInfo: 'HTML tabindex 的使用' + }, + { + path: '/leetcode.html', + name: 'LeetCode', + component: LeetCode, + showInfo: 'leetCode做题记录' + }, + { + path: '/jsbinddbclick.html', + name: 'JsBindDbclick&Click', + component: JsDbclick, + showInfo: 'JS 同时绑定单击&双击事件' + }, + { + path: '/mixblendmode.html', + name: 'MixBlendMode', + component: MixBlendMode, + showInfo: 'css mix-blend-mode 混合模式' + } + ] +}); diff --git a/src/test/pure.vue b/src/test/pure.vue index 691504e..be34696 100644 --- a/src/test/pure.vue +++ b/src/test/pure.vue @@ -8,7 +8,7 @@