├── .gitignore ├── .vscode └── settings.json ├── Demos ├── Express入门系列 │ ├── lesson01 │ │ ├── package.json │ │ └── server.js │ ├── lesson02 │ │ ├── package.json │ │ ├── server.js │ │ └── static │ │ │ ├── first │ │ │ └── index.html │ ├── lesson03 │ │ ├── libs │ │ │ └── body-parser.js │ │ ├── package.json │ │ ├── server.js │ │ └── static │ │ │ ├── first │ │ │ └── index.html │ ├── lesson04 │ │ ├── package.json │ │ ├── server.js │ │ └── static │ │ │ └── index.html │ ├── lesson05 │ │ ├── package.json │ │ └── server.js │ └── lesson06 │ │ ├── package.json │ │ └── server.js ├── Koa2入门系列 │ ├── lesson01 │ │ ├── package.json │ │ ├── server1.js │ │ └── server2.js │ ├── lesson02 │ │ ├── package.json │ │ ├── server1.js │ │ └── server2.js │ └── lesson03 │ │ ├── news │ │ ├── index.js │ │ ├── social.js │ │ └── sports.js │ │ ├── package.json │ │ ├── router.js │ │ ├── server.js │ │ └── user │ │ ├── account.js │ │ ├── index.js │ │ └── info.js ├── Node.js入门系列 │ ├── lesson01 │ │ └── server.js │ ├── lesson02 │ │ └── server.js │ ├── lesson03 │ │ ├── server.js │ │ └── test.txt │ ├── lesson04 │ │ ├── server.js │ │ └── www │ │ │ ├── 1.html │ │ │ └── 1.jpg │ ├── lesson06 │ │ ├── form_get.html │ │ └── server.js │ ├── lesson07 │ │ ├── form_post.html │ │ └── server.js │ ├── lesson08 │ │ ├── form_get.html │ │ ├── form_post.html │ │ └── server.js │ ├── lesson09 │ │ ├── index.html │ │ ├── server.js │ │ └── users.json │ ├── lesson10 │ │ ├── module1.js │ │ ├── module3.js │ │ └── require.js │ ├── lesson11 │ │ ├── assert.deepStrictEqual.array.js │ │ ├── assert.deepStrictEqual.object.js │ │ └── assert.js │ ├── lesson12 │ │ └── path.js │ ├── lesson13 │ │ └── url.js │ ├── lesson14 │ │ └── querystring.js │ ├── lesson16 │ │ ├── buffer.js │ │ ├── bufferSplit.js │ │ ├── google.jpg │ │ ├── post_file.html │ │ ├── server.js │ │ └── upload.txt │ ├── lesson17 │ │ ├── google.jpg │ │ ├── package.json │ │ ├── post_file.html │ │ ├── server.js │ │ ├── upload.txt │ │ └── upload │ │ │ ├── IqUHkFe0u2h2TsiBztjKxoBR.jpg │ │ │ └── uUygzo6qHeGQWwUJLc4kbXyr.txt │ ├── lesson18 │ │ ├── ajax.html │ │ └── server.js │ ├── lesson19 │ │ ├── index.html │ │ ├── package.json │ │ └── server.js │ ├── lesson20 │ │ ├── index.html │ │ └── server.js │ ├── lesson22 │ │ ├── index.html │ │ ├── package.json │ │ ├── server.js │ │ └── test.sql │ ├── lesson23 │ │ ├── index.html │ │ ├── package.json │ │ ├── server.js │ │ └── test.sql │ ├── lesson24 │ │ ├── 1.txt │ │ ├── google.jpg │ │ ├── gzip.js │ │ ├── index.html │ │ ├── server.js │ │ ├── server_gzip.js │ │ └── stream.js │ ├── lesson26 │ │ ├── config │ │ │ ├── config.dev.js │ │ │ ├── config.prod.js │ │ │ └── index.js │ │ ├── db │ │ │ └── test.sql │ │ ├── lib │ │ │ ├── database.js │ │ │ ├── http.js │ │ │ └── router.js │ │ ├── package.json │ │ ├── router │ │ │ ├── add.js │ │ │ ├── del.js │ │ │ ├── index.js │ │ │ └── list.js │ │ ├── server.js │ │ └── static │ │ │ ├── css │ │ │ └── bootstrap.css │ │ │ ├── fonts │ │ │ ├── glyphicons-halflings-regular.eot │ │ │ ├── glyphicons-halflings-regular.svg │ │ │ ├── glyphicons-halflings-regular.ttf │ │ │ ├── glyphicons-halflings-regular.woff │ │ │ └── glyphicons-halflings-regular.woff2 │ │ │ ├── index.html │ │ │ └── js │ │ │ └── bootstrap.js │ ├── lesson27 │ │ ├── config │ │ │ ├── config.dev.js │ │ │ ├── config.prod.js │ │ │ └── index.js │ │ ├── db │ │ │ └── test.sql │ │ ├── lib │ │ │ ├── database.js │ │ │ ├── http.js │ │ │ └── router.js │ │ ├── package.json │ │ ├── router │ │ │ ├── add.js │ │ │ ├── del.js │ │ │ ├── index.js │ │ │ └── list.js │ │ ├── server.js │ │ └── static │ │ │ ├── css │ │ │ └── bootstrap.css │ │ │ ├── fonts │ │ │ ├── glyphicons-halflings-regular.eot │ │ │ ├── glyphicons-halflings-regular.svg │ │ │ ├── glyphicons-halflings-regular.ttf │ │ │ ├── glyphicons-halflings-regular.woff │ │ │ └── glyphicons-halflings-regular.woff2 │ │ │ ├── index.html │ │ │ └── js │ │ │ └── bootstrap.js │ ├── lesson28 │ │ ├── config │ │ │ ├── config.dev.js │ │ │ ├── config.prod.js │ │ │ └── index.js │ │ ├── db │ │ │ └── test.sql │ │ ├── lib │ │ │ ├── database.js │ │ │ ├── http.js │ │ │ └── router.js │ │ ├── package.json │ │ ├── router │ │ │ ├── add.js │ │ │ ├── del.js │ │ │ ├── index.js │ │ │ └── list.js │ │ ├── server.js │ │ └── static │ │ │ ├── css │ │ │ └── bootstrap.css │ │ │ ├── fonts │ │ │ ├── glyphicons-halflings-regular.eot │ │ │ ├── glyphicons-halflings-regular.svg │ │ │ ├── glyphicons-halflings-regular.ttf │ │ │ ├── glyphicons-halflings-regular.woff │ │ │ └── glyphicons-halflings-regular.woff2 │ │ │ ├── index.html │ │ │ └── js │ │ │ └── bootstrap.js │ └── lesson29 │ │ ├── config │ │ ├── config.dev.js │ │ ├── config.prod.js │ │ └── index.js │ │ ├── db │ │ └── test.sql │ │ ├── ecosystem.config.js │ │ ├── lib │ │ ├── database.js │ │ ├── http.js │ │ └── router.js │ │ ├── new │ │ └── ecosystem.config.js │ │ ├── package.json │ │ ├── router │ │ ├── add.js │ │ ├── del.js │ │ ├── index.js │ │ └── list.js │ │ ├── server.js │ │ └── static │ │ ├── css │ │ └── bootstrap.css │ │ ├── fonts │ │ ├── glyphicons-halflings-regular.eot │ │ ├── glyphicons-halflings-regular.svg │ │ ├── glyphicons-halflings-regular.ttf │ │ ├── glyphicons-halflings-regular.woff │ │ └── glyphicons-halflings-regular.woff2 │ │ ├── index.html │ │ └── js │ │ ├── bootstrap.js │ │ └── jquery.min.js ├── React_Native入门系列 │ └── lesson02 │ │ ├── .babelrc │ │ ├── .buckconfig │ │ ├── .flowconfig │ │ ├── .gitattributes │ │ ├── .gitignore │ │ ├── .watchmanconfig │ │ ├── App.js │ │ ├── android │ │ ├── app │ │ │ ├── BUCK │ │ │ ├── build.gradle │ │ │ ├── proguard-rules.pro │ │ │ └── src │ │ │ │ └── main │ │ │ │ ├── AndroidManifest.xml │ │ │ │ ├── java │ │ │ │ └── com │ │ │ │ │ └── lesson01 │ │ │ │ │ ├── MainActivity.java │ │ │ │ │ └── MainApplication.java │ │ │ │ └── res │ │ │ │ ├── mipmap-hdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ │ ├── mipmap-mdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ │ ├── mipmap-xhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ │ ├── mipmap-xxhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ │ ├── mipmap-xxxhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ │ └── values │ │ │ │ ├── strings.xml │ │ │ │ └── styles.xml │ │ ├── build.gradle │ │ ├── gradle.properties │ │ ├── gradle │ │ │ └── wrapper │ │ │ │ ├── gradle-wrapper.jar │ │ │ │ └── gradle-wrapper.properties │ │ ├── gradlew │ │ ├── gradlew.bat │ │ ├── keystores │ │ │ ├── BUCK │ │ │ └── debug.keystore.properties │ │ └── settings.gradle │ │ ├── app.json │ │ ├── index.js │ │ ├── ios │ │ ├── lesson01-tvOS │ │ │ └── Info.plist │ │ ├── lesson01-tvOSTests │ │ │ └── Info.plist │ │ ├── lesson01.xcodeproj │ │ │ ├── project.pbxproj │ │ │ └── xcshareddata │ │ │ │ └── xcschemes │ │ │ │ ├── lesson01-tvOS.xcscheme │ │ │ │ └── lesson01.xcscheme │ │ ├── lesson01 │ │ │ ├── AppDelegate.h │ │ │ ├── AppDelegate.m │ │ │ ├── Base.lproj │ │ │ │ └── LaunchScreen.xib │ │ │ ├── Images.xcassets │ │ │ │ ├── AppIcon.appiconset │ │ │ │ │ └── Contents.json │ │ │ │ └── Contents.json │ │ │ ├── Info.plist │ │ │ └── main.m │ │ └── lesson01Tests │ │ │ ├── Info.plist │ │ │ └── lesson01Tests.m │ │ ├── package.json │ │ ├── unnamed.jpg │ │ ├── utils │ │ └── common.js │ │ └── yarn.lock ├── Vue入门系列 │ ├── lesson01 Vue表达式与v-bind指令 │ │ ├── 01. Vue表达式.html │ │ └── 02. v-bind指令.html │ ├── lesson02 v-model、v-text、v-html │ │ ├── 01. v-model指令.html │ │ └── 02. v-text、v-html指令.html │ ├── lesson03 Vue事件、v-show、v-if指令 │ │ ├── 01. v-on指令.html │ │ └── 02. v-show、v-if指令.html │ ├── lesson04 v-for指令 │ │ ├── 01. v-for指令循环数组、对象.html │ │ └── 02. v-for指令循环字符串、数字.html │ ├── lesson05 v-pre、v-cloak指令 │ │ ├── 01. v-pre指令.html │ │ └── 02. v-cloak指令.html │ ├── lesson06 数据同步、双向绑定原理 │ │ ├── 01. 数据同步.html │ │ └── 02. 双向绑定.html │ ├── lesson07 事件修饰符 │ │ ├── 01. 事件修饰符.html │ │ └── 02. 按键修饰符.html │ ├── lesson08 Computed计算属性、Watch监听属性 │ │ ├── 01. Computed计算属性.html │ │ └── 02. Watch监听属性.html │ ├── lesson09 Vue教程09:双向绑定对象中属性原理 │ │ └── 01. watch监听对象属性.html │ ├── lesson10 使用vue-router实现路由和传参 │ │ ├── 01. vue-router 最基本的路由.html │ │ └── 02. vue-router 路由传参.html │ ├── lesson11 利用JS实现路由跳转 │ │ ├── 01. vue-router 利用JS实现路由跳转.html │ │ └── 02. vue-router 路由监听和守卫.html │ ├── lesson12 多视图 │ │ └── 01. vue-router 多视图.html │ ├── lesson13 webpack project │ │ ├── css │ │ │ └── main.css │ │ ├── index.html │ │ ├── package.json │ │ ├── src │ │ │ ├── components │ │ │ │ ├── header.js │ │ │ │ ├── home.js │ │ │ │ ├── news1.js │ │ │ │ └── news2.js │ │ │ ├── router.js │ │ │ └── vm.js │ │ └── webpack.config.js │ ├── lesson14 child route │ │ ├── css │ │ │ └── main.css │ │ ├── index.html │ │ ├── package.json │ │ ├── src │ │ │ ├── components │ │ │ │ ├── header.js │ │ │ │ ├── home.js │ │ │ │ ├── news.js │ │ │ │ ├── news1.js │ │ │ │ ├── news2.js │ │ │ │ └── news_header.js │ │ │ ├── router.js │ │ │ └── vm.js │ │ └── webpack.config.js │ ├── lesson15 component │ │ ├── dest │ │ │ ├── 448c34a56d699c29117adc64c43affeb.woff2 │ │ │ ├── 89889688147bd7575d6327160d64e760.svg │ │ │ ├── bundle.js │ │ │ ├── e18bbf611f2a2e43afc071aa2f4e1512.ttf │ │ │ ├── f4769f9bdb7466be65088239c12046d1.eot │ │ │ └── fa2772327f55d8198301fdb8bcfc8158.woff │ │ ├── index.html │ │ ├── package.json │ │ ├── src │ │ │ ├── cmp1.js │ │ │ ├── css │ │ │ │ └── my-dialog.css │ │ │ ├── my-dialog.js │ │ │ └── vm.js │ │ └── webpack.config.js │ ├── lesson16 lifecycle │ │ └── lifecycle.png │ ├── lesson17 组件间通信之一:通过组件实例通信 │ │ ├── index.html │ │ ├── package.json │ │ ├── src │ │ │ ├── components │ │ │ │ ├── child.js │ │ │ │ └── parent.js │ │ │ ├── css │ │ │ │ └── my-dialog.css │ │ │ └── vm.js │ │ └── webpack.config.js │ ├── lesson18 组件间通信之二:通过事件通信 │ │ ├── index.html │ │ ├── package.json │ │ ├── src │ │ │ ├── components │ │ │ │ ├── child.js │ │ │ │ └── parent.js │ │ │ ├── css │ │ │ │ └── my-dialog.css │ │ │ └── vm.js │ │ └── webpack.config.js │ ├── lesson19 Vue 2.0组件开发模式 │ │ ├── config │ │ │ ├── webpack.development.js │ │ │ └── webpack.production.js │ │ ├── data │ │ │ └── 1.json │ │ ├── index.html │ │ ├── package.json │ │ ├── src │ │ │ ├── App.vue │ │ │ ├── components │ │ │ │ ├── cmp.vue │ │ │ │ ├── index.vue │ │ │ │ └── news.vue │ │ │ ├── css │ │ │ │ └── base.css │ │ │ ├── index.js │ │ │ └── routers │ │ │ │ └── index.js │ │ └── webpack.config.js │ ├── lesson20 Vuex入门 │ │ ├── .babelrc │ │ ├── .editorconfig │ │ ├── .eslintignore │ │ ├── .eslintrc.js │ │ ├── .gitignore │ │ ├── .postcssrc.js │ │ ├── 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 │ │ ├── config │ │ │ ├── dev.env.js │ │ │ ├── index.js │ │ │ ├── prod.env.js │ │ │ └── test.env.js │ │ ├── index.html │ │ ├── package.json │ │ ├── src │ │ │ ├── App.vue │ │ │ ├── components │ │ │ │ ├── Cmp1.vue │ │ │ │ ├── Index.vue │ │ │ │ └── common │ │ │ │ │ └── Table.vue │ │ │ ├── main.js │ │ │ └── router │ │ │ │ └── index.js │ │ ├── static │ │ │ └── .gitkeep │ │ ├── test │ │ │ ├── e2e │ │ │ │ ├── custom-assertions │ │ │ │ │ └── elementCount.js │ │ │ │ ├── nightwatch.conf.js │ │ │ │ ├── runner.js │ │ │ │ └── specs │ │ │ │ │ └── test.js │ │ │ └── unit │ │ │ │ ├── .eslintrc │ │ │ │ ├── jest.conf.js │ │ │ │ ├── setup.js │ │ │ │ └── specs │ │ │ │ └── HelloWorld.spec.js │ │ └── vuex.png │ ├── lesson21 Vuex Getter │ │ ├── .babelrc │ │ ├── .editorconfig │ │ ├── .eslintignore │ │ ├── .eslintrc.js │ │ ├── .gitignore │ │ ├── .postcssrc.js │ │ ├── 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 │ │ ├── config │ │ │ ├── dev.env.js │ │ │ ├── index.js │ │ │ ├── prod.env.js │ │ │ └── test.env.js │ │ ├── index.html │ │ ├── package.json │ │ ├── src │ │ │ ├── App.vue │ │ │ ├── components │ │ │ │ ├── Cmp1.vue │ │ │ │ ├── Index.vue │ │ │ │ ├── Index2.vue │ │ │ │ └── common │ │ │ │ │ └── Table.vue │ │ │ ├── main.js │ │ │ ├── router │ │ │ │ └── index.js │ │ │ └── store │ │ │ │ └── index.js │ │ ├── static │ │ │ └── .gitkeep │ │ └── test │ │ │ ├── e2e │ │ │ ├── custom-assertions │ │ │ │ └── elementCount.js │ │ │ ├── nightwatch.conf.js │ │ │ ├── runner.js │ │ │ └── specs │ │ │ │ └── test.js │ │ │ └── unit │ │ │ ├── .eslintrc │ │ │ ├── jest.conf.js │ │ │ ├── setup.js │ │ │ └── specs │ │ │ └── HelloWorld.spec.js │ ├── lesson22 mapState、mapActions、mapGetters │ │ ├── .babelrc │ │ ├── .editorconfig │ │ ├── .eslintignore │ │ ├── .eslintrc.js │ │ ├── .gitignore │ │ ├── .postcssrc.js │ │ ├── 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 │ │ ├── config │ │ │ ├── dev.env.js │ │ │ ├── index.js │ │ │ ├── prod.env.js │ │ │ └── test.env.js │ │ ├── index.html │ │ ├── package.json │ │ ├── src │ │ │ ├── App.vue │ │ │ ├── components │ │ │ │ ├── Cmp1.vue │ │ │ │ ├── Index.vue │ │ │ │ ├── Index2.vue │ │ │ │ └── common │ │ │ │ │ └── Table.vue │ │ │ ├── main.js │ │ │ ├── router │ │ │ │ └── index.js │ │ │ └── store │ │ │ │ └── index.js │ │ ├── static │ │ │ └── .gitkeep │ │ └── test │ │ │ ├── e2e │ │ │ ├── custom-assertions │ │ │ │ └── elementCount.js │ │ │ ├── nightwatch.conf.js │ │ │ ├── runner.js │ │ │ └── specs │ │ │ │ └── test.js │ │ │ └── unit │ │ │ ├── .eslintrc │ │ │ ├── jest.conf.js │ │ │ ├── setup.js │ │ │ └── specs │ │ │ └── HelloWorld.spec.js │ ├── lesson23 Vuex异步Action │ │ ├── .babelrc │ │ ├── .editorconfig │ │ ├── .eslintignore │ │ ├── .eslintrc.js │ │ ├── .gitignore │ │ ├── .postcssrc.js │ │ ├── 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 │ │ ├── config │ │ │ ├── dev.env.js │ │ │ ├── index.js │ │ │ ├── prod.env.js │ │ │ └── test.env.js │ │ ├── index.html │ │ ├── package.json │ │ ├── server │ │ │ ├── package.json │ │ │ ├── server.js │ │ │ └── static │ │ │ │ └── user.txt │ │ ├── src │ │ │ ├── App.vue │ │ │ ├── components │ │ │ │ ├── Cmp1.vue │ │ │ │ ├── Index.vue │ │ │ │ ├── Index2.vue │ │ │ │ └── common │ │ │ │ │ └── Table.vue │ │ │ ├── main.js │ │ │ ├── router │ │ │ │ └── index.js │ │ │ └── store │ │ │ │ ├── index.js │ │ │ │ ├── mod_a.js │ │ │ │ └── mod_b.js │ │ ├── static │ │ │ └── .gitkeep │ │ └── test │ │ │ ├── e2e │ │ │ ├── custom-assertions │ │ │ │ └── elementCount.js │ │ │ ├── nightwatch.conf.js │ │ │ ├── runner.js │ │ │ └── specs │ │ │ │ └── test.js │ │ │ └── unit │ │ │ ├── .eslintrc │ │ │ ├── jest.conf.js │ │ │ ├── setup.js │ │ │ └── specs │ │ │ └── HelloWorld.spec.js │ └── lesson24 Vuex Modules │ │ ├── .babelrc │ │ ├── .editorconfig │ │ ├── .eslintignore │ │ ├── .eslintrc.js │ │ ├── .gitignore │ │ ├── .postcssrc.js │ │ ├── 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 │ │ ├── config │ │ ├── dev.env.js │ │ ├── index.js │ │ ├── prod.env.js │ │ └── test.env.js │ │ ├── index.html │ │ ├── package.json │ │ ├── server │ │ ├── package.json │ │ ├── server.js │ │ └── static │ │ │ └── user.txt │ │ ├── src │ │ ├── App.vue │ │ ├── components │ │ │ ├── Cmp1.vue │ │ │ ├── Index.vue │ │ │ ├── Index2.vue │ │ │ └── common │ │ │ │ └── Table.vue │ │ ├── main.js │ │ ├── router │ │ │ └── index.js │ │ └── store │ │ │ ├── index.js │ │ │ ├── mod_a.js │ │ │ └── mod_b.js │ │ ├── static │ │ └── .gitkeep │ │ └── test │ │ ├── e2e │ │ ├── custom-assertions │ │ │ └── elementCount.js │ │ ├── nightwatch.conf.js │ │ ├── runner.js │ │ └── specs │ │ │ └── test.js │ │ └── unit │ │ ├── .eslintrc │ │ ├── jest.conf.js │ │ ├── setup.js │ │ └── specs │ │ └── HelloWorld.spec.js ├── rc-form源码解析 │ ├── .gitignore │ ├── ant-design │ │ └── components │ │ │ └── form │ │ │ └── Form.tsx │ ├── config-overrides.js │ ├── package.json │ ├── public │ │ ├── favicon.ico │ │ ├── index.html │ │ ├── logo192.png │ │ ├── logo512.png │ │ ├── manifest.json │ │ └── robots.txt │ ├── rc-form │ │ ├── .editorconfig │ │ ├── .gitignore │ │ ├── .travis.yml │ │ ├── HISTORY.md │ │ ├── LICENSE.md │ │ ├── README.md │ │ ├── examples │ │ │ ├── across-router.html │ │ │ ├── across-router.js │ │ │ ├── async-init.html │ │ │ ├── async-init.js │ │ │ ├── dynamic-fields.html │ │ │ ├── dynamic-fields.js │ │ │ ├── dynamic.html │ │ │ ├── dynamic.js │ │ │ ├── file-input.html │ │ │ ├── file-input.js │ │ │ ├── getFieldDecorator.html │ │ │ ├── getFieldDecorator.js │ │ │ ├── input-array.html │ │ │ ├── input-array.js │ │ │ ├── modal.html │ │ │ ├── modal.js │ │ │ ├── nested-field.html │ │ │ ├── nested-field.js │ │ │ ├── normalize.html │ │ │ ├── normalize.js │ │ │ ├── overview.html │ │ │ ├── overview.js │ │ │ ├── parallel-form.html │ │ │ ├── parallel-form.js │ │ │ ├── promise-validate.html │ │ │ ├── promise-validate.js │ │ │ ├── react-native │ │ │ │ ├── App.js │ │ │ │ └── expo.jpg │ │ │ ├── redux.html │ │ │ ├── redux.js │ │ │ ├── server-validate.html │ │ │ ├── server-validate.js │ │ │ ├── setFieldsValue.html │ │ │ ├── setFieldsValue.js │ │ │ ├── start-end-date.html │ │ │ ├── start-end-date.js │ │ │ ├── styles.js │ │ │ ├── suggest.html │ │ │ ├── suggest.js │ │ │ ├── validateFirst.html │ │ │ ├── validateFirst.js │ │ │ ├── validateTrigger.html │ │ │ └── validateTrigger.js │ │ ├── index.js │ │ ├── package.json │ │ ├── scripts │ │ │ └── index.js │ │ ├── src │ │ │ ├── createBaseForm.js │ │ │ ├── createDOMForm.js │ │ │ ├── createFieldsStore.js │ │ │ ├── createForm.js │ │ │ ├── createFormField.js │ │ │ ├── index.js │ │ │ ├── propTypes.js │ │ │ └── utils.js │ │ └── tests │ │ │ ├── async-validation.spec.js │ │ │ ├── clean-field.spec.js │ │ │ ├── createDOMForm.spec.js │ │ │ ├── createForm.spec.js │ │ │ ├── dynamic-binding.spec.js │ │ │ ├── dynamic-rule.spec.js │ │ │ ├── form.spec.js │ │ │ ├── getFieldDecorator.spec.js │ │ │ ├── getFieldProps.spec.js │ │ │ ├── index.js │ │ │ ├── overview.spec.js │ │ │ ├── setup.js │ │ │ ├── switch-field.spec.js │ │ │ ├── utils.spec.js │ │ │ ├── validateArray.spec.js │ │ │ └── validateFields.spec.js │ ├── src │ │ ├── App.css │ │ ├── App.test.tsx │ │ ├── App.tsx │ │ ├── components │ │ │ ├── FormModal.tsx │ │ │ ├── NewFormModal.tsx │ │ │ ├── ShowTimer.tsx │ │ │ └── ShowTimerModal.tsx │ │ ├── index.css │ │ ├── index.tsx │ │ ├── logo.svg │ │ ├── react-app-env.d.ts │ │ ├── serviceWorker.ts │ │ └── utils │ │ │ ├── createForm.tsx │ │ │ └── createTimer.tsx │ ├── tsconfig.json │ └── yarn.lock ├── 微信小程序入门系列 │ ├── lesson03 │ │ ├── app.js │ │ ├── app.json │ │ ├── app.wxss │ │ ├── pages │ │ │ ├── index │ │ │ │ ├── index.js │ │ │ │ ├── index.json │ │ │ │ ├── index.wxml │ │ │ │ └── index.wxss │ │ │ ├── login │ │ │ │ ├── login.js │ │ │ │ ├── login.json │ │ │ │ ├── login.wxml │ │ │ │ └── login.wxss │ │ │ └── logs │ │ │ │ ├── logs.js │ │ │ │ ├── logs.json │ │ │ │ ├── logs.wxml │ │ │ │ └── logs.wxss │ │ ├── project.config.json │ │ └── utils │ │ │ └── util.js │ └── lesson04 │ │ ├── app.js │ │ ├── app.json │ │ ├── app.wxss │ │ ├── images │ │ └── google.png │ │ ├── pages │ │ ├── index │ │ │ ├── index.js │ │ │ ├── index.json │ │ │ ├── index.wxml │ │ │ └── index.wxss │ │ └── logs │ │ │ ├── logs.js │ │ │ ├── logs.json │ │ │ ├── logs.wxml │ │ │ └── logs.wxss │ │ ├── project.config.json │ │ └── utils │ │ ├── toast.js │ │ └── util.js └── 零碎的记录 │ └── 解决火狐新窗口打开网页被拦截问题 │ └── prevented.png ├── Images ├── rc-form源码解读 │ ├── Demo.png │ ├── form-demo.png │ ├── rc-form实现思路.png │ ├── rc-form实现思路.xmind │ └── 时间弹窗.png ├── 如何成为有效学习的高手 │ ├── 如何成为有效学习的高手.png │ └── 如何成为有效学习的高手.xmind ├── 得到邀请_20191001155932.png ├── 得到邀请_20191001155932_444x658.png ├── 得到邀请_20191001155932_50X50.png ├── 得到邀请_20191001155932_tiny压缩.png └── 怎样成为快速阅读的高手 │ ├── 怎样成为快速阅读的高手.png │ └── 怎样成为快速阅读的高手.xmind └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "spellright.language": [ 3 | "en" 4 | ], 5 | "spellright.documentTypes": [ 6 | "markdown", 7 | "latex", 8 | "plaintext", 9 | "typescriptreact" 10 | ] 11 | } -------------------------------------------------------------------------------- /Demos/Express入门系列/lesson01/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "lesson01", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "keywords": [], 10 | "author": "", 11 | "license": "ISC", 12 | "dependencies": { 13 | "express": "^4.16.4" 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Demos/Express入门系列/lesson02/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "lesson01", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "keywords": [], 10 | "author": "", 11 | "license": "ISC", 12 | "dependencies": { 13 | "body-parser": "^1.18.3", 14 | "express": "^4.16.4" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Demos/Express入门系列/lesson02/server.js: -------------------------------------------------------------------------------- 1 | const express = require('express') 2 | const bodyParser = require('body-parser') 3 | 4 | const server = express() 5 | 6 | server.listen(8080) 7 | 8 | server.get('/reg', (req, res, next) => { 9 | console.log(req.query) 10 | res.send({ 11 | error: 0, 12 | data: req.query, 13 | msg: '注册成功' 14 | }) 15 | }) 16 | 17 | // 处理表单提交,对应请求头application/x-www-form-urlencoded 18 | server.use(bodyParser.urlencoded({ 19 | extended: false // 为true时将使用qs库处理数据,通常不需要 20 | })) 21 | 22 | // 处理fetch请求,对应请求头application/json 23 | server.use(bodyParser.json()) 24 | 25 | server.post('/login', (req, res, next) => { 26 | console.log(req.body) 27 | res.send({ 28 | error: 0, 29 | data: req.body, 30 | msg: '登陆成功' 31 | }) 32 | }) 33 | 34 | server.use(express.static('./static/')) 35 | 36 | console.log(`Server started at 8080`) 37 | -------------------------------------------------------------------------------- /Demos/Express入门系列/lesson02/static/first: -------------------------------------------------------------------------------- 1 | 这是first文件 -------------------------------------------------------------------------------- /Demos/Express入门系列/lesson03/libs/body-parser.js: -------------------------------------------------------------------------------- 1 | const querystring = require('querystring') 2 | 3 | module.exports = (req, res, next) => { 4 | let arr = [] // 接收数据的数组 5 | 6 | // 使用data事件接收数据 7 | req.on('data', (buffer) => { 8 | // 将数据保存在arr数组中 9 | arr.push(buffer) 10 | }) 11 | 12 | // 数据接收完成后,将数据转换为对象格式,保存到req.body上,交由下一级中间件处理 13 | req.on('end', () => { 14 | // 将数据解析为字符串 15 | let body = Buffer.concat(arr).toString() 16 | 17 | // 判断是否Fetch请求数据 18 | if (req.headers['content-type'] === 'application/json') { 19 | // 处理Fetch请求数据 20 | body = JSON.parse(body) 21 | } else { 22 | // 处理表单提交数据 23 | body = querystring.parse(body) 24 | } 25 | 26 | // 将保存到req.body上 27 | req.body = body 28 | 29 | // 交由下一级中间件处理 30 | next() 31 | }) 32 | } -------------------------------------------------------------------------------- /Demos/Express入门系列/lesson03/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "lesson01", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "keywords": [], 10 | "author": "", 11 | "license": "ISC", 12 | "dependencies": { 13 | "body-parser": "^1.18.3", 14 | "express": "^4.16.4" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Demos/Express入门系列/lesson03/server.js: -------------------------------------------------------------------------------- 1 | const express = require('express') 2 | 3 | // 引入bodyParser中间件 4 | const bodyParser = require('./libs/body-parser') 5 | 6 | const server = express() 7 | 8 | server.listen(8080) 9 | 10 | server.get('/reg', (req, res, next) => { 11 | console.log(req.query) 12 | res.send({ 13 | error: 0, 14 | data: req.query, 15 | msg: '注册成功' 16 | }) 17 | }) 18 | 19 | // 使用bodyParser中间件 20 | server.use(bodyParser) 21 | 22 | server.post('/login', (req, res, next) => { 23 | console.log(req.body) 24 | res.send({ 25 | error: 0, 26 | data: req.body, 27 | msg: '登陆成功' 28 | }) 29 | }) 30 | 31 | server.use(express.static('./static/')) 32 | 33 | console.log(`Server started at 8080`) 34 | -------------------------------------------------------------------------------- /Demos/Express入门系列/lesson03/static/first: -------------------------------------------------------------------------------- 1 | 这是first文件 -------------------------------------------------------------------------------- /Demos/Express入门系列/lesson04/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "lesson01", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "keywords": [], 10 | "author": "", 11 | "license": "ISC", 12 | "dependencies": { 13 | "body-parser": "^1.18.3", 14 | "express": "^4.16.4", 15 | "multer": "^1.4.1" 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Demos/Express入门系列/lesson05/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "lesson01", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "keywords": [], 10 | "author": "", 11 | "license": "ISC", 12 | "dependencies": { 13 | "body-parser": "^1.18.3", 14 | "cookie-parser": "^1.4.4", 15 | "express": "^4.16.4", 16 | "multer": "^1.4.1" 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Demos/Express入门系列/lesson06/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "lesson01", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "keywords": [], 10 | "author": "", 11 | "license": "ISC", 12 | "dependencies": { 13 | "body-parser": "^1.18.3", 14 | "cookie-parser": "^1.4.4", 15 | "cookie-session": "^1.3.3", 16 | "express": "^4.16.4", 17 | "multer": "^1.4.1" 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Demos/Koa2入门系列/lesson01/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "lesson01", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "server.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1", 8 | "start": "node server.js" 9 | }, 10 | "keywords": [], 11 | "author": "", 12 | "license": "ISC", 13 | "dependencies": { 14 | "koa": "^2.7.0" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Demos/Koa2入门系列/lesson01/server1.js: -------------------------------------------------------------------------------- 1 | const Koa = require('koa') 2 | 3 | const server = new Koa() // 创建一个Server 4 | 5 | server.use(async (ctx, next) => { 6 | ctx.body = 'Hello World' // 打印Hello World到前端 7 | }) 8 | 9 | server.listen(8080) // 监听8080端口 10 | 11 | console.log(`Server started at http://localhost:8080`) 12 | -------------------------------------------------------------------------------- /Demos/Koa2入门系列/lesson01/server2.js: -------------------------------------------------------------------------------- 1 | const Koa = require('koa'); 2 | const app = new Koa(); 3 | 4 | // logger 5 | 6 | app.use(async (ctx, next) => { 7 | await next(); // 先运行下一级中间件 8 | console.log('Third'); // 下级中间件都运行完成后,才执行此处代码 9 | const rt = ctx.response.get('X-Response-Time'); 10 | console.log(`${ctx.method} ${ctx.url} - ${rt}`); // 打印下一级中间件中设置的响应头 11 | }); 12 | 13 | // x-response-time 14 | 15 | app.use(async (ctx, next) => { 16 | const start = Date.now(); 17 | await next(); 18 | console.log('Second'); 19 | console.log(ctx.body); // 打印第三个中间件中赋值的ctx.body 20 | const ms = Date.now() - start; 21 | ctx.set('X-Response-Time', `${ms}ms`); // 设置响应头 22 | }); 23 | 24 | // response 25 | 26 | app.use(async ctx => { 27 | console.log('First'); 28 | ctx.body = 'Hello World'; // 赋值返回前台的数据 29 | }); 30 | 31 | app.listen(8080); 32 | 33 | console.log(`Server started at http://localhost:8080`); 34 | -------------------------------------------------------------------------------- /Demos/Koa2入门系列/lesson02/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "lesson01", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "server.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1", 8 | "start": "node server.js" 9 | }, 10 | "keywords": [], 11 | "author": "", 12 | "license": "ISC", 13 | "dependencies": { 14 | "koa": "^2.7.0", 15 | "koa-router": "^7.4.0" 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Demos/Koa2入门系列/lesson02/server1.js: -------------------------------------------------------------------------------- 1 | const Koa = require('koa') 2 | const Router = require('koa-router') 3 | 4 | const app = new Koa() // 创建一个服务器 5 | 6 | app.listen(8080) // 监听8080端口 7 | 8 | console.log(`app started at http://localhost:8080`) 9 | 10 | const router = new Router() // 创建路由 11 | 12 | // 配置一个get请求的路由 13 | router.get('/getData', async (ctx, next) => { 14 | ctx.body = 'response' // 向前台返回数据 15 | }) 16 | 17 | // 使用路由中间件 18 | app.use(router.routes()) 19 | -------------------------------------------------------------------------------- /Demos/Koa2入门系列/lesson03/news/index.js: -------------------------------------------------------------------------------- 1 | const Router = require('koa-router') // 引用koa-router 2 | 3 | const router = new Router() // 创建一个路由 4 | 5 | router.use('/social', require('./social')) // 配置社会新闻模块的访问路由,并且引用社会新闻模块的路由配置 6 | router.use('/sports', require('./sports')) // 配置体育新闻模块的访问路由,并且引用体育新闻模块的路由配置 7 | 8 | module.exports = router.routes() // 导出路由配置 9 | -------------------------------------------------------------------------------- /Demos/Koa2入门系列/lesson03/news/social.js: -------------------------------------------------------------------------------- 1 | const Router = require('koa-router') // 引用koa-router 2 | 3 | const router = new Router() // 创建一个路由 4 | 5 | // 配置访问新闻详情页的路由地址,并配置返回数据 6 | router.get('/detail', async (ctx, next) => { 7 | ctx.body = '社会新闻详情页' 8 | }) 9 | 10 | module.exports = router.routes() // 导出路由配置 11 | -------------------------------------------------------------------------------- /Demos/Koa2入门系列/lesson03/news/sports.js: -------------------------------------------------------------------------------- 1 | const Router = require('koa-router') 2 | 3 | const router = new Router() 4 | 5 | router.get('/detail', async (ctx, next) => { 6 | ctx.body = '体育新闻详情页' 7 | }) 8 | 9 | module.exports = router.routes() -------------------------------------------------------------------------------- /Demos/Koa2入门系列/lesson03/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "lesson01", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "server.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1", 8 | "start": "node server.js" 9 | }, 10 | "keywords": [], 11 | "author": "", 12 | "license": "ISC", 13 | "dependencies": { 14 | "koa": "^2.7.0", 15 | "koa-router": "^7.4.0" 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Demos/Koa2入门系列/lesson03/router.js: -------------------------------------------------------------------------------- 1 | const Router = require('koa-router') // 引用koa-router 2 | 3 | const router = new Router() // 创建一个路由 4 | 5 | router.use('/news', require('./news')) // 配置新闻模块的访问路由,并引用新闻模块路由配置 6 | router.use('/user', require('./user')) // 配置用户模块的访问路由,并引用用户模块路由配置 7 | 8 | module.exports = router.routes() // 导出路由配置 9 | -------------------------------------------------------------------------------- /Demos/Koa2入门系列/lesson03/server.js: -------------------------------------------------------------------------------- 1 | const Koa = require('koa') 2 | 3 | const app = new Koa() // 创建一个服务器 4 | 5 | app.listen(8080) // 监听8080端口 6 | 7 | console.log(`app started at http://localhost:8080`) 8 | 9 | app.use(require('./router')) // 使用路由中间件 10 | -------------------------------------------------------------------------------- /Demos/Koa2入门系列/lesson03/user/account.js: -------------------------------------------------------------------------------- 1 | const Router = require('koa-router') 2 | 3 | const router = new Router() 4 | 5 | router.get('/detail', async (ctx, next) => { 6 | ctx.body = '用户账户详情页' 7 | }) 8 | 9 | module.exports = router.routes() -------------------------------------------------------------------------------- /Demos/Koa2入门系列/lesson03/user/index.js: -------------------------------------------------------------------------------- 1 | const Router = require('koa-router') 2 | 3 | const router = new Router() 4 | 5 | router.use('/account', require('./account')) 6 | router.use('/info', require('./info')) 7 | 8 | module.exports = router.routes() 9 | -------------------------------------------------------------------------------- /Demos/Koa2入门系列/lesson03/user/info.js: -------------------------------------------------------------------------------- 1 | const Router = require('koa-router') 2 | 3 | const router = new Router() 4 | 5 | router.get('/detail', async (ctx, next) => { 6 | ctx.body = '用户信息详情页' 7 | }) 8 | 9 | module.exports = router.routes() 10 | -------------------------------------------------------------------------------- /Demos/Node.js入门系列/lesson01/server.js: -------------------------------------------------------------------------------- 1 | // 引入Nodejs自带的http模块 2 | const http = require('http'); 3 | // 引入Nodejs自带的child_process模块 4 | const childProcess = require('child_process'); 5 | 6 | const hostname = '127.0.0.1'; // 本机地址 7 | const port = 3000; // 端口 8 | 9 | // 创建一个服务器 10 | const server = http.createServer((request, response) => { 11 | response.statusCode = 200; // 设置响应状态码 12 | response.setHeader('Content-Type', 'text/plain'); // 设置响应头 13 | response.end('Hello World\n'); // 向前台输出内容 14 | }); 15 | 16 | // 开启监听 17 | server.listen(port, hostname, () => { 18 | // 在命令行打印运行结果 19 | console.log(`Server running at http://${hostname}:${port}/`); 20 | // 使用默认浏览器打开地址 21 | childProcess.exec(`start http://${hostname}:${port}/`); 22 | }); 23 | -------------------------------------------------------------------------------- /Demos/Node.js入门系列/lesson02/server.js: -------------------------------------------------------------------------------- 1 | // 引入Nodejs自带的http模块 2 | const http = require('http'); 3 | // 引入Nodejs自带的child_process模块 4 | const childProcess = require('child_process'); 5 | 6 | const hostname = '127.0.0.1'; // 本机地址 7 | const port = 8080; // 端口 8 | 9 | // 创建一个服务器 10 | const server = http.createServer((request, response) => { 11 | response.statusCode = 200; // 设置响应状态码 12 | response.setHeader('Content-Type', 'text/plain'); // 设置响应头 13 | response.write('a') 14 | response.write('b') 15 | response.write('c') 16 | response.end('d') // 向前台输出内容 17 | }); 18 | 19 | // 开启监听 20 | server.listen(port, hostname, () => { 21 | // 在命令行打印运行结果 22 | console.log(`Server running at http://${hostname}:${port}/`); 23 | // 使用默认浏览器打开地址 24 | childProcess.exec(`start http://${hostname}:${port}/`); 25 | }); 26 | -------------------------------------------------------------------------------- /Demos/Node.js入门系列/lesson03/server.js: -------------------------------------------------------------------------------- 1 | const fs = require('fs') 2 | 3 | fs.writeFile('./test.txt', 'test', (error) => { 4 | if (error) { 5 | console.log('文件写入失败', error) 6 | } else { 7 | console.log('文件写入成功') 8 | } 9 | }) 10 | 11 | fs.readFile('./test.txt', (error, data) => { 12 | if (error) { 13 | console.log('文件读取失败', error) 14 | } else { 15 | // 此处因确定读取到的数据是字符串,可以直接用toString方法将Buffer转为字符串。 16 | // 若是需要传输给浏览器可以直接用Buffer,机器之间通信是直接用Buffer数据。 17 | console.log('文件读取成功', data.toString()) 18 | } 19 | }) -------------------------------------------------------------------------------- /Demos/Node.js入门系列/lesson03/test.txt: -------------------------------------------------------------------------------- 1 | test -------------------------------------------------------------------------------- /Demos/Node.js入门系列/lesson04/server.js: -------------------------------------------------------------------------------- 1 | const http = require('http') 2 | const fs = require('fs') 3 | 4 | const server = http.createServer((request, response) => { 5 | console.log(request.url) // 在request对象中,可以获取请求的URL,通过URL判断请求的资源。 6 | if (request.url !== '/favicon.ico') { 7 | fs.readFile(`./www${request.url}`, (error, buffer) => { // 根据URL查找读取相应的文件。 8 | if (error) { // 若读取错误,则向前端返回404状态码,以及内容Not Found。 9 | response.writeHead(404) 10 | response.write('Not Found') 11 | } else { // 若读取成功,则向前端返回读取到的文件。 12 | response.write(buffer) 13 | } 14 | response.end() // 关闭连接。 15 | }) 16 | } 17 | }) 18 | 19 | server.listen(8080) -------------------------------------------------------------------------------- /Demos/Node.js入门系列/lesson04/www/1.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Document 8 | 9 | 10 | 网页内容 11 | 12 | 13 | -------------------------------------------------------------------------------- /Demos/Node.js入门系列/lesson04/www/1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chencl1986/Blog/60170ad67796c2f48526dae2e3078b2713b74482/Demos/Node.js入门系列/lesson04/www/1.jpg -------------------------------------------------------------------------------- /Demos/Node.js入门系列/lesson06/form_get.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Document 8 | 9 | 10 |
11 | 用户:
12 | 密码:
13 | 14 |
15 | 16 | -------------------------------------------------------------------------------- /Demos/Node.js入门系列/lesson06/server.js: -------------------------------------------------------------------------------- 1 | const http = require('http') 2 | const url = require('url') 3 | const { URL } = url 4 | const querystring = require('querystring') 5 | 6 | const server = http.createServer((req, res) => { 7 | { 8 | // 方法一: 9 | const [ pathname, queryStr ] = req.url.split('?') 10 | const query = querystring.parse(queryStr) 11 | console.log(pathname, query) 12 | } 13 | { 14 | // 方法二: 15 | const url = new URL(`http://localhost:8080${req.url}`) 16 | const { pathname, search } = url 17 | const query = querystring.parse(search.substring(1, url.search.length)) 18 | console.log(pathname, query) 19 | } 20 | { 21 | // 方法三: 22 | // parse方法第二个参数若传true,则会直接将解析出的query值转为对象形式,否则它只是字符串形式 23 | const { pathname, query } = url.parse(req.url, true) 24 | console.log(pathname, query) 25 | } 26 | }) 27 | 28 | server.listen(8080) -------------------------------------------------------------------------------- /Demos/Node.js入门系列/lesson07/form_post.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Document 8 | 9 | 10 |
11 | 用户:
12 | 密码:
13 | 14 |
15 | 16 | -------------------------------------------------------------------------------- /Demos/Node.js入门系列/lesson07/server.js: -------------------------------------------------------------------------------- 1 | const http = require('http') 2 | const querystring = require('querystring') 3 | 4 | const server = http.createServer((req, res) => { 5 | let bufferArray = [] // 用于存储data事件获取的Buffer数据。 6 | 7 | req.on('data', (buffer) => { 8 | bufferArray.push(buffer) // 将Buffer数据存储在数组中。 9 | }) 10 | 11 | req.on('end', () => { 12 | // Buffer 类是一个全局变量,使用时无需 require('buffer').Buffer。 13 | // Buffer.concat方法用于合并Buffer数组。 14 | const buffer = Buffer.concat(bufferArray) 15 | // 已知Buffer数据只是字符串,则可以直接用toString将其转换成字符串。 16 | const post = querystring.parse(buffer.toString()) 17 | console.log(post) 18 | }) 19 | }) 20 | 21 | server.listen(8080) -------------------------------------------------------------------------------- /Demos/Node.js入门系列/lesson08/form_get.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Document 8 | 9 | 10 |
11 | 用户:
12 | 密码:
13 | 14 |
15 | 16 | -------------------------------------------------------------------------------- /Demos/Node.js入门系列/lesson08/form_post.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Document 8 | 9 | 10 |
11 | 用户:
12 | 密码:
13 | 14 |
15 | 16 | -------------------------------------------------------------------------------- /Demos/Node.js入门系列/lesson09/users.json: -------------------------------------------------------------------------------- 1 | [{"username":"admin","password":"123456"},{"username":"lee","password":"123456"},{"username":"lxl","password":"11"}] -------------------------------------------------------------------------------- /Demos/Node.js入门系列/lesson10/module1.js: -------------------------------------------------------------------------------- 1 | module.exports.a = 1 2 | module.exports.b = 2 3 | 4 | let c = 3 -------------------------------------------------------------------------------- /Demos/Node.js入门系列/lesson10/module3.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | a: 1, 3 | b: 2 4 | } 5 | 6 | module.exports = 123 7 | 8 | module.exports = { 9 | a: 1, 10 | b: 2, 11 | c: 3 12 | } 13 | 14 | module.exports = function () { 15 | console.log('test') 16 | } 17 | 18 | module.exports = class { 19 | constructor(name) { 20 | this.name = name 21 | } 22 | 23 | show() { 24 | console.log(`Show ${this.name}`) 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Demos/Node.js入门系列/lesson10/require.js: -------------------------------------------------------------------------------- 1 | const module1 = require('./module1') 2 | 3 | console.log(module1) // { a: 1, b: 2 } 4 | 5 | const module2 = require('module2') 6 | 7 | console.log(module2) // { a: 1, b: 2 } 8 | 9 | const Module3 = require('./module3') 10 | const sayName = new Module3('Lee') 11 | 12 | sayName.show() 13 | -------------------------------------------------------------------------------- /Demos/Node.js入门系列/lesson11/assert.deepStrictEqual.array.js: -------------------------------------------------------------------------------- 1 | const assert = require('assert') 2 | 3 | const arr1 = [{ 4 | a: 1, 5 | b: 2, 6 | children: [{ 7 | c: 3 8 | }] 9 | }] 10 | 11 | const arr2 = [{ 12 | a: 1, 13 | b: 2, 14 | children: [{ 15 | c: 3 16 | }] 17 | }] 18 | 19 | const arr3 = [{ 20 | a: 1, 21 | b: 2, 22 | children: [{ 23 | c: '3' 24 | }] 25 | }] 26 | 27 | assert.deepStrictEqual(arr1, arr2, 'arr1 !== arr2') 28 | 29 | assert.deepStrictEqual(arr1, arr3, 'arr1 !== arr3') 30 | -------------------------------------------------------------------------------- /Demos/Node.js入门系列/lesson11/assert.deepStrictEqual.object.js: -------------------------------------------------------------------------------- 1 | const assert = require('assert') 2 | 3 | const obj1 = { 4 | a: 1, 5 | b: 2, 6 | children: { 7 | c: 3 8 | } 9 | } 10 | 11 | const obj2 = { 12 | a: 1, 13 | b: 2, 14 | children: { 15 | c: 3 16 | } 17 | } 18 | 19 | const obj3 = { 20 | a: 1, 21 | b: 2, 22 | children: { 23 | c: '3' 24 | } 25 | } 26 | 27 | assert.deepStrictEqual(obj1, obj2, 'obj1 !== obj2') 28 | 29 | assert.deepStrictEqual(obj1, obj3, 'obj1 !== obj3') 30 | -------------------------------------------------------------------------------- /Demos/Node.js入门系列/lesson11/assert.js: -------------------------------------------------------------------------------- 1 | const assert = require('assert') 2 | 3 | assert(2 > 1, '2 > 1') 4 | 5 | assert(1 > 2, '1 > 2') 6 | 7 | console.log('代码运行到此处。') 8 | -------------------------------------------------------------------------------- /Demos/Node.js入门系列/lesson12/path.js: -------------------------------------------------------------------------------- 1 | const path = require('path') 2 | 3 | const str = '/root/a/b/1.txt' 4 | 5 | console.log(path.dirname(str)) // 获取文件目录:/root/a/b 6 | console.log(path.basename(str)) // 获取文件名:1.txt 7 | console.log(path.extname(str)) // 获取文件后缀:.txt 8 | console.log(path.resolve(str, '../c', 'build', 'strict')) // 将路径解析为绝对路径:C:\root\a\b\c\build\strict 9 | console.log(path.resolve(str, '../c', 'build', 'strict', '../..', 'assets')) // 将路径解析为绝对路径:C:\root\a\b\c\assets 10 | console.log(path.resolve(__dirname, 'build')) // 将路径解析为绝对路径:C:\projects\nodejs-tutorial\lesson12\build 11 | -------------------------------------------------------------------------------- /Demos/Node.js入门系列/lesson13/url.js: -------------------------------------------------------------------------------- 1 | const url = require('url') 2 | 3 | const str = 'https://www.google.com:8080/a/b?x=1&y=2&y=3&y=4' 4 | 5 | console.log(url.parse(str).toString()) 6 | console.log(url.parse(str, true)) 7 | 8 | const { URL } = require('url') 9 | const urlObj = new URL(str) 10 | 11 | console.log(urlObj) 12 | console.log(urlObj.toString()) 13 | -------------------------------------------------------------------------------- /Demos/Node.js入门系列/lesson14/querystring.js: -------------------------------------------------------------------------------- 1 | const querystring = require('querystring') 2 | 3 | console.log(querystring.parse('foo=bar&abc=xyz&abc=123')) 4 | 5 | console.log(querystring.stringify({ foo: 'bar', baz: ['qux', 'quux'], corge: '' })) 6 | -------------------------------------------------------------------------------- /Demos/Node.js入门系列/lesson16/buffer.js: -------------------------------------------------------------------------------- 1 | let buffer = Buffer.from('lee\r\nchen\r\ntest') 2 | 3 | const index = buffer.indexOf('\r\n') 4 | 5 | console.log(index) 6 | console.log(buffer.slice(0, index).toString()) 7 | -------------------------------------------------------------------------------- /Demos/Node.js入门系列/lesson16/bufferSplit.js: -------------------------------------------------------------------------------- 1 | module.exports = function bufferSplit(buffer, separator) { 2 | let result = []; 3 | let index = 0; 4 | 5 | while ((index = buffer.indexOf(separator)) != -1) { 6 | result.push(buffer.slice(0, index)); 7 | buffer = buffer.slice(index + separator.length); 8 | } 9 | result.push(buffer); 10 | 11 | return result; 12 | } -------------------------------------------------------------------------------- /Demos/Node.js入门系列/lesson16/google.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chencl1986/Blog/60170ad67796c2f48526dae2e3078b2713b74482/Demos/Node.js入门系列/lesson16/google.jpg -------------------------------------------------------------------------------- /Demos/Node.js入门系列/lesson16/post_file.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Document 8 | 9 | 10 | 11 | 12 |
13 | 用户:
14 | 密码:
15 |
16 | 17 |
18 | 19 | -------------------------------------------------------------------------------- /Demos/Node.js入门系列/lesson16/upload.txt: -------------------------------------------------------------------------------- 1 | upload -------------------------------------------------------------------------------- /Demos/Node.js入门系列/lesson17/google.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chencl1986/Blog/60170ad67796c2f48526dae2e3078b2713b74482/Demos/Node.js入门系列/lesson17/google.jpg -------------------------------------------------------------------------------- /Demos/Node.js入门系列/lesson17/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "lesson17", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "server.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1", 8 | "start": "node server.js" 9 | }, 10 | "keywords": [], 11 | "author": "", 12 | "license": "ISC", 13 | "devDependencies": { 14 | "multiparty": "^4.2.1" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Demos/Node.js入门系列/lesson17/post_file.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Document 9 | 10 | 11 | 12 | 13 | 14 |
15 | 用户:
16 | 密码:
17 |
18 | 19 |
20 | 21 | 22 | -------------------------------------------------------------------------------- /Demos/Node.js入门系列/lesson17/server.js: -------------------------------------------------------------------------------- 1 | const http = require('http') 2 | const multiparty = require('multiparty') 3 | 4 | const server = http.createServer((req, res) => { 5 | const form = new multiparty.Form({ 6 | uploadDir: './upload' // 指定文件存储目录 7 | }) 8 | 9 | form.parse(req) // 将请求参数传入,multiparty会进行相应处理 10 | 11 | form.on('field', (name, value) => { // 接收到数据参数时,触发field事件 12 | console.log(name, value) 13 | }) 14 | 15 | form.on('file', (name, file, ...rest) => { // 接收到文件参数时,触发file事件 16 | console.log(name, file) 17 | }) 18 | 19 | form.on('close', () => { // 表单数据解析完成,触发close事件 20 | console.log('表单数据解析完成') 21 | }) 22 | }) 23 | 24 | server.listen(8080) 25 | -------------------------------------------------------------------------------- /Demos/Node.js入门系列/lesson17/upload.txt: -------------------------------------------------------------------------------- 1 | upload -------------------------------------------------------------------------------- /Demos/Node.js入门系列/lesson17/upload/IqUHkFe0u2h2TsiBztjKxoBR.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chencl1986/Blog/60170ad67796c2f48526dae2e3078b2713b74482/Demos/Node.js入门系列/lesson17/upload/IqUHkFe0u2h2TsiBztjKxoBR.jpg -------------------------------------------------------------------------------- /Demos/Node.js入门系列/lesson17/upload/uUygzo6qHeGQWwUJLc4kbXyr.txt: -------------------------------------------------------------------------------- 1 | upload -------------------------------------------------------------------------------- /Demos/Node.js入门系列/lesson18/server.js: -------------------------------------------------------------------------------- 1 | const http = require('http') 2 | 3 | const server = http.createServer((req, res) => { 4 | console.log(req.headers.origin) 5 | res.setHeader('Access-Control-Allow-Origin', '*') 6 | res.write(`{"resultCode": "0000", "msg": "success"}`) 7 | res.end() 8 | }) 9 | 10 | server.listen(8080) 11 | -------------------------------------------------------------------------------- /Demos/Node.js入门系列/lesson19/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "lesson19", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "keywords": [], 10 | "author": "", 11 | "license": "ISC", 12 | "devDependencies": { 13 | "socket.io": "^2.2.0" 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Demos/Node.js入门系列/lesson19/server.js: -------------------------------------------------------------------------------- 1 | const http = require('http') 2 | const io = require('socket.io') 3 | 4 | // 1. 建立HTTP服务器。 5 | const server = http.createServer((req, res) => { 6 | 7 | }) 8 | 9 | server.listen(8080) 10 | 11 | // 2. 建立WebSocket,让socket.io监听HTTP服务器,一旦发现是WebSocket请求,则会自动进行处理。 12 | const ws = io.listen(server) 13 | 14 | // 建立连接完成后,触发connection事件。 15 | // 该事件会返回一个socket对象(https://socket.io/docs/server-api/#Socket),可以利用socket对象进行发送、接收数据操作。 16 | ws.on('connection', (socket) => { 17 | // 根据事件名,向客户端发送数据,数据数量不限。 18 | socket.emit('msg', '服务端向客户端发送数据第一条', '服务端向客户端发送数据第二条') 19 | 20 | // 根据事件名接收客户端返回的数据 21 | socket.on('msg', (...msgs) => { 22 | console.log(msgs) 23 | }) 24 | 25 | // 使用计时器向客户端发送数据 26 | setInterval(() => { 27 | socket.emit('timer', new Date().getTime()) 28 | }, 500); 29 | }) 30 | -------------------------------------------------------------------------------- /Demos/Node.js入门系列/lesson22/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "lesson22", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "keywords": [], 10 | "author": "", 11 | "license": "ISC", 12 | "devDependencies": { 13 | "mysql": "^2.16.0" 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Demos/Node.js入门系列/lesson23/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "lesson22", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "keywords": [], 10 | "author": "", 11 | "license": "ISC", 12 | "devDependencies": { 13 | "co-mysql": "^1.0.0", 14 | "mysql": "^2.16.0" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Demos/Node.js入门系列/lesson24/1.txt: -------------------------------------------------------------------------------- 1 | 这是一段测试文本,通过Stream读取到2.txt -------------------------------------------------------------------------------- /Demos/Node.js入门系列/lesson24/google.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chencl1986/Blog/60170ad67796c2f48526dae2e3078b2713b74482/Demos/Node.js入门系列/lesson24/google.jpg -------------------------------------------------------------------------------- /Demos/Node.js入门系列/lesson24/gzip.js: -------------------------------------------------------------------------------- 1 | const fs = require('fs') 2 | // 引入zlib模块,用于实现压缩功能 3 | const zlib = require('zlib') 4 | 5 | // 创建一个可读流。 6 | const readStream = fs.createReadStream('./google.jpg') 7 | 8 | // 创建一个可写流。 9 | const writeStream = fs.createWriteStream('./google.jpg.gz') 10 | 11 | // 创建一个Gzip对象,用于将文件压缩成.gz文件 12 | const gzip = zlib.createGzip() 13 | 14 | // 将可读流读取的数据,先通过管道pipe推送到gzip中,再推送到写入流中。 15 | // 也就是先将可读流的数据压缩,再推送到可写流中。 16 | readStream.pipe(gzip).pipe(writeStream) 17 | 18 | // 读取出现错误时会触发error事件。 19 | readStream.on('error', (error) => { 20 | console.error(error) 21 | }) 22 | 23 | // 写入完成时,触发finish事件。 24 | writeStream.on('finish', () => { 25 | console.log('finish') 26 | }) 27 | -------------------------------------------------------------------------------- /Demos/Node.js入门系列/lesson24/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Document 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /Demos/Node.js入门系列/lesson24/server.js: -------------------------------------------------------------------------------- 1 | const http = require('http') 2 | const url = require('url') 3 | const fs = require('fs') 4 | 5 | const server = http.createServer((req, res) => { 6 | const { 7 | pathname 8 | } = url.parse(req.url, true) 9 | 10 | // 创建一个可读流。 11 | const readStream = fs.createReadStream(`./${pathname}`) 12 | 13 | // 将读取的内容,在通过管道推送到res中,该方法不经过压缩 14 | readStream.pipe(res) 15 | 16 | // 处理可读流报错,防止请求不存在的文件 17 | readStream.on('error', (error) => { 18 | console.error(error); 19 | res.writeHead(404) 20 | res.write('Not Found') 21 | res.end() 22 | }) 23 | }) 24 | 25 | server.listen(8080) 26 | -------------------------------------------------------------------------------- /Demos/Node.js入门系列/lesson24/stream.js: -------------------------------------------------------------------------------- 1 | const fs = require('fs') 2 | 3 | // 创建一个可读流。 4 | const readStream = fs.createReadStream('./1.txt') 5 | 6 | // 创建一个可写流。 7 | const writeStream = fs.createWriteStream('./2.txt') 8 | 9 | // 将可读流读取的数据,通过管道pipe推送到写入流中,即可将1.txt的内容,写入到2.txt中。 10 | readStream.pipe(writeStream) 11 | 12 | // 读取出现错误时会触发error事件。 13 | readStream.on('error', (error) => { 14 | console.error(error) 15 | }) 16 | 17 | // 写入完成时,触发finish事件。 18 | writeStream.on('finish', () => { 19 | console.log('finish') 20 | }) 21 | -------------------------------------------------------------------------------- /Demos/Node.js入门系列/lesson26/config/config.dev.js: -------------------------------------------------------------------------------- 1 | const path = require('path') 2 | 3 | module.exports = { 4 | // 数据库配置 5 | DB_HOST: 'localhost', 6 | DB_PORT: 3306, 7 | DB_USER: 'root', 8 | DB_PASS: '', 9 | DB_NAME: 'test', 10 | 11 | // HTTP端口 12 | HTTP_PORT: 8080, 13 | // 静态文件绝对路径 14 | HTTP_ROOT: path.resolve(__dirname, '../static/'), 15 | HTTP_UPLOAD: path.resolve(__dirname, '../static/upload') 16 | } -------------------------------------------------------------------------------- /Demos/Node.js入门系列/lesson26/config/config.prod.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | // 数据库配置 3 | DB_HOST: '11.11.11.11', 4 | DB_PORT: 3306, 5 | DB_USER: 'root', 6 | DB_PASS: '123456', 7 | DB_NAME: 'company', 8 | 9 | // HTTP端口 10 | HTTP_PORT: 8080, 11 | // 静态文件绝对路径 12 | HTTP_ROOT: path.resolve(__dirname, '../static/'), 13 | HTTP_UPLOAD: path.resolve(__dirname, '../static/upload') 14 | } -------------------------------------------------------------------------------- /Demos/Node.js入门系列/lesson26/config/index.js: -------------------------------------------------------------------------------- 1 | const process = require('process') 2 | 3 | const mode = process.env.OS === 'Windows_NT' ? 'env' : 'prod' 4 | 5 | module.exports = { 6 | mode, // 当前所处环境 7 | ...(mode === 'env' ? require('./config.dev') : require('./config.prod')) // 当前环境的配置 8 | } 9 | -------------------------------------------------------------------------------- /Demos/Node.js入门系列/lesson26/lib/database.js: -------------------------------------------------------------------------------- 1 | // 引入mysql和co-mysql,用于连接数据库 2 | const mysql = require('mysql') 3 | const coMysql = require('co-mysql') 4 | 5 | // 引入数据库配置 6 | const { 7 | DB_HOST, 8 | DB_PORT, 9 | DB_USER, 10 | DB_PASS, 11 | DB_NAME 12 | } = require('../config') 13 | 14 | // 1. 创建服务器连接池 15 | const pool = mysql.createPool({ 16 | host: DB_HOST, 17 | port: DB_PORT, 18 | user: DB_USER, 19 | password: DB_PASS, 20 | database: DB_NAME 21 | }) 22 | 23 | // 2. 使用co-mysql包装连接池,将连接转换为Async/Await异步方式 24 | const connection = coMysql(pool) 25 | 26 | // 3. 作为模块导出使用 27 | module.exports = connection 28 | -------------------------------------------------------------------------------- /Demos/Node.js入门系列/lesson26/lib/http.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chencl1986/Blog/60170ad67796c2f48526dae2e3078b2713b74482/Demos/Node.js入门系列/lesson26/lib/http.js -------------------------------------------------------------------------------- /Demos/Node.js入门系列/lesson26/lib/router.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chencl1986/Blog/60170ad67796c2f48526dae2e3078b2713b74482/Demos/Node.js入门系列/lesson26/lib/router.js -------------------------------------------------------------------------------- /Demos/Node.js入门系列/lesson26/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "lesson26", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "server.js", 6 | "directories": { 7 | "lib": "lib" 8 | }, 9 | "scripts": { 10 | "test": "echo \"Error: no test specified\" && exit 1", 11 | "start": "node server.js" 12 | }, 13 | "keywords": [], 14 | "author": "", 15 | "license": "ISC", 16 | "dependencies": { 17 | "co-mysql": "^1.0.0", 18 | "mysql": "^2.16.0" 19 | } 20 | } -------------------------------------------------------------------------------- /Demos/Node.js入门系列/lesson26/router/add.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chencl1986/Blog/60170ad67796c2f48526dae2e3078b2713b74482/Demos/Node.js入门系列/lesson26/router/add.js -------------------------------------------------------------------------------- /Demos/Node.js入门系列/lesson26/router/del.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chencl1986/Blog/60170ad67796c2f48526dae2e3078b2713b74482/Demos/Node.js入门系列/lesson26/router/del.js -------------------------------------------------------------------------------- /Demos/Node.js入门系列/lesson26/router/index.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chencl1986/Blog/60170ad67796c2f48526dae2e3078b2713b74482/Demos/Node.js入门系列/lesson26/router/index.js -------------------------------------------------------------------------------- /Demos/Node.js入门系列/lesson26/router/list.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chencl1986/Blog/60170ad67796c2f48526dae2e3078b2713b74482/Demos/Node.js入门系列/lesson26/router/list.js -------------------------------------------------------------------------------- /Demos/Node.js入门系列/lesson26/server.js: -------------------------------------------------------------------------------- 1 | const connection = require('./lib/database') 2 | 3 | ;(async () => { 4 | // 查询item_table表中的数据 5 | const response = await connection.query(`SELECT * FROM item_table`) 6 | console.log(response) 7 | })() 8 | -------------------------------------------------------------------------------- /Demos/Node.js入门系列/lesson26/static/fonts/glyphicons-halflings-regular.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chencl1986/Blog/60170ad67796c2f48526dae2e3078b2713b74482/Demos/Node.js入门系列/lesson26/static/fonts/glyphicons-halflings-regular.eot -------------------------------------------------------------------------------- /Demos/Node.js入门系列/lesson26/static/fonts/glyphicons-halflings-regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chencl1986/Blog/60170ad67796c2f48526dae2e3078b2713b74482/Demos/Node.js入门系列/lesson26/static/fonts/glyphicons-halflings-regular.ttf -------------------------------------------------------------------------------- /Demos/Node.js入门系列/lesson26/static/fonts/glyphicons-halflings-regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chencl1986/Blog/60170ad67796c2f48526dae2e3078b2713b74482/Demos/Node.js入门系列/lesson26/static/fonts/glyphicons-halflings-regular.woff -------------------------------------------------------------------------------- /Demos/Node.js入门系列/lesson26/static/fonts/glyphicons-halflings-regular.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chencl1986/Blog/60170ad67796c2f48526dae2e3078b2713b74482/Demos/Node.js入门系列/lesson26/static/fonts/glyphicons-halflings-regular.woff2 -------------------------------------------------------------------------------- /Demos/Node.js入门系列/lesson27/config/config.dev.js: -------------------------------------------------------------------------------- 1 | const path = require('path') 2 | 3 | module.exports = { 4 | // 数据库配置 5 | DB_HOST: 'localhost', 6 | DB_PORT: 3306, 7 | DB_USER: 'root', 8 | DB_PASS: '', 9 | DB_NAME: 'test', 10 | 11 | // HTTP端口 12 | HTTP_PORT: 8080, 13 | // 静态文件绝对路径 14 | HTTP_ROOT: path.resolve(__dirname, '../static/'), 15 | // 上传文件保存绝对路径 16 | HTTP_UPLOAD: path.resolve(__dirname, '../static/upload') 17 | } -------------------------------------------------------------------------------- /Demos/Node.js入门系列/lesson27/config/config.prod.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | // 数据库配置 3 | DB_HOST: '11.11.11.11', 4 | DB_PORT: 3306, 5 | DB_USER: 'root', 6 | DB_PASS: '123456', 7 | DB_NAME: 'company', 8 | 9 | // HTTP端口 10 | HTTP_PORT: 8080, 11 | // 静态文件绝对路径 12 | HTTP_ROOT: path.resolve(__dirname, '../static/'), 13 | // 上传文件保存绝对路径 14 | HTTP_UPLOAD: path.resolve(__dirname, '../static/upload') 15 | } -------------------------------------------------------------------------------- /Demos/Node.js入门系列/lesson27/config/index.js: -------------------------------------------------------------------------------- 1 | const process = require('process') 2 | 3 | const mode = process.env.OS === 'Windows_NT' ? 'env' : 'prod' 4 | 5 | module.exports = { 6 | mode, // 当前所处环境 7 | ...(mode === 'env' ? require('./config.dev') : require('./config.prod')) // 当前环境的配置 8 | } 9 | -------------------------------------------------------------------------------- /Demos/Node.js入门系列/lesson27/lib/database.js: -------------------------------------------------------------------------------- 1 | // 引入mysql和co-mysql,用于连接数据库 2 | const mysql = require('mysql') 3 | const coMysql = require('co-mysql') 4 | 5 | // 引入数据库配置 6 | const { 7 | DB_HOST, 8 | DB_PORT, 9 | DB_USER, 10 | DB_PASS, 11 | DB_NAME 12 | } = require('../config') 13 | 14 | // 1. 创建服务器连接池 15 | const pool = mysql.createPool({ 16 | host: DB_HOST, 17 | port: DB_PORT, 18 | user: DB_USER, 19 | password: DB_PASS, 20 | database: DB_NAME 21 | }) 22 | 23 | // 2. 使用co-mysql包装连接池,将连接转换为Async/Await异步方式 24 | const connection = coMysql(pool) 25 | 26 | // 3. 作为模块导出使用 27 | module.exports = connection 28 | -------------------------------------------------------------------------------- /Demos/Node.js入门系列/lesson27/lib/http.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chencl1986/Blog/60170ad67796c2f48526dae2e3078b2713b74482/Demos/Node.js入门系列/lesson27/lib/http.js -------------------------------------------------------------------------------- /Demos/Node.js入门系列/lesson27/lib/router.js: -------------------------------------------------------------------------------- 1 | // 创建路由表 2 | let router = { 3 | // 存储get请求的路由 4 | get: { 5 | 6 | }, 7 | // 存储post请求的路由 8 | post: { 9 | 10 | } 11 | } 12 | 13 | // 添加路由的方法,method为请求方法,url为请求地址,callback为处理该请求的回调函数 14 | function addRouter(method, url, callback) { 15 | // 为便于处理,将method和url统一转换成小写 16 | method = method.toLowerCase() 17 | url = url.toLowerCase() 18 | 19 | // 将处理请求的回调函数,按方法名和地址储存到路由表中 20 | router[method][url] = callback 21 | } 22 | 23 | // 查找处理请求的回调函数的方法,method为请求方法,url为请求地址,返回处理路由的回调函数 24 | function findRouter(method, url) { 25 | // 为便于处理,将method和url统一转换成小写 26 | method = method.toLowerCase() 27 | url = url.toLowerCase() 28 | 29 | // 找到路由对应的回调函数,不存在则默认返回null 30 | const callback = router[method][url] || null 31 | 32 | // 将回调函数返回 33 | return callback 34 | } 35 | 36 | // 将添加路由和查找路由方法导出 37 | module.exports = { 38 | addRouter, 39 | findRouter 40 | } 41 | -------------------------------------------------------------------------------- /Demos/Node.js入门系列/lesson27/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "lesson26", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "server.js", 6 | "directories": { 7 | "lib": "lib" 8 | }, 9 | "scripts": { 10 | "test": "echo \"Error: no test specified\" && exit 1", 11 | "start": "node server.js" 12 | }, 13 | "keywords": [], 14 | "author": "", 15 | "license": "ISC", 16 | "dependencies": { 17 | "co-mysql": "^1.0.0", 18 | "multiparty": "^4.2.1", 19 | "mysql": "^2.16.0" 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Demos/Node.js入门系列/lesson27/router/add.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chencl1986/Blog/60170ad67796c2f48526dae2e3078b2713b74482/Demos/Node.js入门系列/lesson27/router/add.js -------------------------------------------------------------------------------- /Demos/Node.js入门系列/lesson27/router/del.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chencl1986/Blog/60170ad67796c2f48526dae2e3078b2713b74482/Demos/Node.js入门系列/lesson27/router/del.js -------------------------------------------------------------------------------- /Demos/Node.js入门系列/lesson27/router/index.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chencl1986/Blog/60170ad67796c2f48526dae2e3078b2713b74482/Demos/Node.js入门系列/lesson27/router/index.js -------------------------------------------------------------------------------- /Demos/Node.js入门系列/lesson27/router/list.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chencl1986/Blog/60170ad67796c2f48526dae2e3078b2713b74482/Demos/Node.js入门系列/lesson27/router/list.js -------------------------------------------------------------------------------- /Demos/Node.js入门系列/lesson27/server.js: -------------------------------------------------------------------------------- 1 | const connection = require('./lib/database') 2 | 3 | ;(async () => { 4 | // 查询item_table表中的数据 5 | const response = await connection.query(`SELECT * FROM item_table`) 6 | console.log(response) 7 | })() 8 | -------------------------------------------------------------------------------- /Demos/Node.js入门系列/lesson27/static/fonts/glyphicons-halflings-regular.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chencl1986/Blog/60170ad67796c2f48526dae2e3078b2713b74482/Demos/Node.js入门系列/lesson27/static/fonts/glyphicons-halflings-regular.eot -------------------------------------------------------------------------------- /Demos/Node.js入门系列/lesson27/static/fonts/glyphicons-halflings-regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chencl1986/Blog/60170ad67796c2f48526dae2e3078b2713b74482/Demos/Node.js入门系列/lesson27/static/fonts/glyphicons-halflings-regular.ttf -------------------------------------------------------------------------------- /Demos/Node.js入门系列/lesson27/static/fonts/glyphicons-halflings-regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chencl1986/Blog/60170ad67796c2f48526dae2e3078b2713b74482/Demos/Node.js入门系列/lesson27/static/fonts/glyphicons-halflings-regular.woff -------------------------------------------------------------------------------- /Demos/Node.js入门系列/lesson27/static/fonts/glyphicons-halflings-regular.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chencl1986/Blog/60170ad67796c2f48526dae2e3078b2713b74482/Demos/Node.js入门系列/lesson27/static/fonts/glyphicons-halflings-regular.woff2 -------------------------------------------------------------------------------- /Demos/Node.js入门系列/lesson28/config/config.dev.js: -------------------------------------------------------------------------------- 1 | const path = require('path') 2 | 3 | module.exports = { 4 | // 数据库配置 5 | DB_HOST: 'localhost', 6 | DB_PORT: 3306, 7 | DB_USER: 'root', 8 | DB_PASS: '', 9 | DB_NAME: 'test', 10 | 11 | // HTTP端口 12 | HTTP_PORT: 8080, 13 | // 静态文件绝对路径 14 | HTTP_ROOT: path.resolve(__dirname, '../static/'), 15 | // 上传文件保存绝对路径 16 | HTTP_UPLOAD: path.resolve(__dirname, '../static/upload') 17 | } -------------------------------------------------------------------------------- /Demos/Node.js入门系列/lesson28/config/config.prod.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | // 数据库配置 3 | DB_HOST: '11.11.11.11', 4 | DB_PORT: 3306, 5 | DB_USER: 'root', 6 | DB_PASS: '123456', 7 | DB_NAME: 'company', 8 | 9 | // HTTP端口 10 | HTTP_PORT: 8080, 11 | // 静态文件绝对路径 12 | HTTP_ROOT: path.resolve(__dirname, '../static/'), 13 | // 上传文件保存绝对路径 14 | HTTP_UPLOAD: path.resolve(__dirname, '../static/upload') 15 | } -------------------------------------------------------------------------------- /Demos/Node.js入门系列/lesson28/config/index.js: -------------------------------------------------------------------------------- 1 | const process = require('process') 2 | 3 | const mode = process.env.OS === 'Windows_NT' ? 'env' : 'prod' 4 | 5 | module.exports = { 6 | mode, // 当前所处环境 7 | ...(mode === 'env' ? require('./config.dev') : require('./config.prod')) // 当前环境的配置 8 | } 9 | -------------------------------------------------------------------------------- /Demos/Node.js入门系列/lesson28/lib/database.js: -------------------------------------------------------------------------------- 1 | // 引入mysql和co-mysql,用于连接数据库 2 | const mysql = require('mysql') 3 | const coMysql = require('co-mysql') 4 | 5 | // 引入数据库配置 6 | const { 7 | DB_HOST, 8 | DB_PORT, 9 | DB_USER, 10 | DB_PASS, 11 | DB_NAME 12 | } = require('../config') 13 | 14 | // 1. 创建服务器连接池 15 | const pool = mysql.createPool({ 16 | host: DB_HOST, 17 | port: DB_PORT, 18 | user: DB_USER, 19 | password: DB_PASS, 20 | database: DB_NAME 21 | }) 22 | 23 | // 2. 使用co-mysql包装连接池,将连接转换为Async/Await异步方式 24 | const connection = coMysql(pool) 25 | 26 | // 3. 作为模块导出使用 27 | module.exports = connection 28 | -------------------------------------------------------------------------------- /Demos/Node.js入门系列/lesson28/lib/router.js: -------------------------------------------------------------------------------- 1 | // 创建路由表 2 | let router = { 3 | // 存储get请求的路由 4 | get: { 5 | 6 | }, 7 | // 存储post请求的路由 8 | post: { 9 | 10 | } 11 | } 12 | 13 | // 添加路由的方法,method为请求方法,url为请求地址,callback为处理该请求的回调函数 14 | function addRouter(method, url, callback) { 15 | // 为便于处理,将method和url统一转换成小写 16 | method = method.toLowerCase() 17 | url = url.toLowerCase() 18 | 19 | // 将处理请求的回调函数,按方法名和地址储存到路由表中 20 | router[method][url] = callback 21 | } 22 | 23 | // 查找处理请求的回调函数的方法,method为请求方法,url为请求地址,返回处理路由的回调函数 24 | function findRouter(method, url) { 25 | // 为便于处理,将method和url统一转换成小写 26 | method = method.toLowerCase() 27 | url = url.toLowerCase() 28 | 29 | // 找到路由对应的回调函数,不存在则默认返回null 30 | const callback = router[method][url] || null 31 | 32 | // 将回调函数返回 33 | return callback 34 | } 35 | 36 | // 将添加路由和查找路由方法导出 37 | module.exports = { 38 | addRouter, 39 | findRouter 40 | } 41 | -------------------------------------------------------------------------------- /Demos/Node.js入门系列/lesson28/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "lesson26", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "server.js", 6 | "directories": { 7 | "lib": "lib" 8 | }, 9 | "scripts": { 10 | "test": "echo \"Error: no test specified\" && exit 1", 11 | "start": "node server.js" 12 | }, 13 | "keywords": [], 14 | "author": "", 15 | "license": "ISC", 16 | "dependencies": { 17 | "co-mysql": "^1.0.0", 18 | "multiparty": "^4.2.1", 19 | "mysql": "^2.16.0" 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Demos/Node.js入门系列/lesson28/router/add.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chencl1986/Blog/60170ad67796c2f48526dae2e3078b2713b74482/Demos/Node.js入门系列/lesson28/router/add.js -------------------------------------------------------------------------------- /Demos/Node.js入门系列/lesson28/router/del.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chencl1986/Blog/60170ad67796c2f48526dae2e3078b2713b74482/Demos/Node.js入门系列/lesson28/router/del.js -------------------------------------------------------------------------------- /Demos/Node.js入门系列/lesson28/router/index.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chencl1986/Blog/60170ad67796c2f48526dae2e3078b2713b74482/Demos/Node.js入门系列/lesson28/router/index.js -------------------------------------------------------------------------------- /Demos/Node.js入门系列/lesson28/router/list.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chencl1986/Blog/60170ad67796c2f48526dae2e3078b2713b74482/Demos/Node.js入门系列/lesson28/router/list.js -------------------------------------------------------------------------------- /Demos/Node.js入门系列/lesson28/server.js: -------------------------------------------------------------------------------- 1 | const connection = require('./lib/database') 2 | const http = require('./lib/http') 3 | -------------------------------------------------------------------------------- /Demos/Node.js入门系列/lesson28/static/fonts/glyphicons-halflings-regular.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chencl1986/Blog/60170ad67796c2f48526dae2e3078b2713b74482/Demos/Node.js入门系列/lesson28/static/fonts/glyphicons-halflings-regular.eot -------------------------------------------------------------------------------- /Demos/Node.js入门系列/lesson28/static/fonts/glyphicons-halflings-regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chencl1986/Blog/60170ad67796c2f48526dae2e3078b2713b74482/Demos/Node.js入门系列/lesson28/static/fonts/glyphicons-halflings-regular.ttf -------------------------------------------------------------------------------- /Demos/Node.js入门系列/lesson28/static/fonts/glyphicons-halflings-regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chencl1986/Blog/60170ad67796c2f48526dae2e3078b2713b74482/Demos/Node.js入门系列/lesson28/static/fonts/glyphicons-halflings-regular.woff -------------------------------------------------------------------------------- /Demos/Node.js入门系列/lesson28/static/fonts/glyphicons-halflings-regular.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chencl1986/Blog/60170ad67796c2f48526dae2e3078b2713b74482/Demos/Node.js入门系列/lesson28/static/fonts/glyphicons-halflings-regular.woff2 -------------------------------------------------------------------------------- /Demos/Node.js入门系列/lesson29/config/config.dev.js: -------------------------------------------------------------------------------- 1 | const path = require('path') 2 | 3 | module.exports = { 4 | // 数据库配置 5 | DB_HOST: 'localhost', 6 | DB_PORT: 3306, 7 | DB_USER: 'root', 8 | DB_PASS: '', 9 | DB_NAME: 'test', 10 | 11 | // HTTP端口 12 | HTTP_PORT: 8080, 13 | // 静态文件绝对路径 14 | HTTP_ROOT: path.resolve(__dirname, '../static/'), 15 | // 上传文件保存绝对路径 16 | HTTP_UPLOAD: path.resolve(__dirname, '../static/upload') 17 | } -------------------------------------------------------------------------------- /Demos/Node.js入门系列/lesson29/config/config.prod.js: -------------------------------------------------------------------------------- 1 | const path = require('path') 2 | 3 | module.exports = { 4 | // 数据库配置 5 | DB_HOST: '11.11.11.11', 6 | DB_PORT: 3306, 7 | DB_USER: 'root', 8 | DB_PASS: '123456', 9 | DB_NAME: 'company', 10 | 11 | // HTTP端口 12 | HTTP_PORT: 8080, 13 | // 静态文件绝对路径 14 | HTTP_ROOT: path.resolve(__dirname, '../static/'), 15 | // 上传文件保存绝对路径 16 | HTTP_UPLOAD: path.resolve(__dirname, '../static/upload') 17 | } -------------------------------------------------------------------------------- /Demos/Node.js入门系列/lesson29/config/index.js: -------------------------------------------------------------------------------- 1 | const process = require('process') 2 | let mode = '' 3 | 4 | // 可以通过开发环境和生产环境系统等参数差异,判断处于哪个环境。 5 | // mode = process.env.OS === 'Windows_NT' ? 'dev' : 'prod' 6 | 7 | // 也可以通过package.json中配置的启动命令判断处于开发还是生产环境。 8 | // mode = process.argv[2] === '--dev' ? 'dev' : 'prod' 9 | 10 | // 通过pm2启动项目,直接传入mode 11 | // pm2 start ecosystem.config.js --watch --env production 为生产环境启动命令 12 | console.log(process.env.NODE_ENV) 13 | console.log(process.argv) 14 | mode = process.env.NODE_ENV 15 | 16 | module.exports = { 17 | mode, // 当前所处环境 18 | ...(mode === 'dev' ? require('./config.dev') : require('./config.prod')) // 当前环境的配置 19 | } 20 | -------------------------------------------------------------------------------- /Demos/Node.js入门系列/lesson29/ecosystem.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | apps : [{ 3 | name: 'server', 4 | script: 'server.js', 5 | 6 | // Options reference: https://pm2.io/doc/en/runtime/reference/ecosystem-file/ 7 | args: 'one two', 8 | instances: 1, 9 | autorestart: true, 10 | watch: false, 11 | max_memory_restart: '1G', 12 | env: { 13 | NODE_ENV: 'dev' 14 | }, 15 | env_development: { 16 | NODE_ENV: 'dev' 17 | }, 18 | env_production: { 19 | NODE_ENV: 'prod' 20 | } 21 | }], 22 | 23 | deploy : { 24 | production : { 25 | user : 'node', 26 | host : '212.83.163.1', 27 | ref : 'origin/master', 28 | repo : 'git@github.com:repo.git', 29 | path : '/var/www/production', 30 | 'post-deploy' : 'npm install && pm2 reload ecosystem.config.js --env production' 31 | } 32 | } 33 | }; 34 | -------------------------------------------------------------------------------- /Demos/Node.js入门系列/lesson29/lib/database.js: -------------------------------------------------------------------------------- 1 | // 引入mysql和co-mysql,用于连接数据库 2 | const mysql = require('mysql') 3 | const coMysql = require('co-mysql') 4 | 5 | // 引入数据库配置 6 | const { 7 | DB_HOST, 8 | DB_PORT, 9 | DB_USER, 10 | DB_PASS, 11 | DB_NAME 12 | } = require('../config') 13 | 14 | // 1. 创建服务器连接池 15 | const pool = mysql.createPool({ 16 | host: DB_HOST, 17 | port: DB_PORT, 18 | user: DB_USER, 19 | password: DB_PASS, 20 | database: DB_NAME 21 | }) 22 | 23 | // 2. 使用co-mysql包装连接池,将连接转换为Async/Await异步方式 24 | const connection = coMysql(pool) 25 | 26 | // 3. 作为模块导出使用 27 | module.exports = connection 28 | -------------------------------------------------------------------------------- /Demos/Node.js入门系列/lesson29/lib/router.js: -------------------------------------------------------------------------------- 1 | // 创建路由表 2 | let router = { 3 | // 存储get请求的路由 4 | get: { 5 | 6 | }, 7 | // 存储post请求的路由 8 | post: { 9 | 10 | } 11 | } 12 | 13 | // 添加路由的方法,method为请求方法,url为请求地址,callback为处理该请求的回调函数 14 | function addRouter(method, url, callback) { 15 | // 为便于处理,将method和url统一转换成小写 16 | method = method.toLowerCase() 17 | url = url.toLowerCase() 18 | 19 | // 将处理请求的回调函数,按方法名和地址储存到路由表中 20 | router[method][url] = callback 21 | } 22 | 23 | // 查找处理请求的回调函数的方法,method为请求方法,url为请求地址,返回处理路由的回调函数 24 | function findRouter(method, url) { 25 | // 为便于处理,将method和url统一转换成小写 26 | method = method.toLowerCase() 27 | url = url.toLowerCase() 28 | 29 | // 找到路由对应的回调函数,不存在则默认返回null 30 | const callback = router[method][url] || null 31 | 32 | // 将回调函数返回 33 | return callback 34 | } 35 | 36 | // 将添加路由和查找路由方法导出 37 | module.exports = { 38 | addRouter, 39 | findRouter 40 | } 41 | -------------------------------------------------------------------------------- /Demos/Node.js入门系列/lesson29/new/ecosystem.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | apps : [{ 3 | name: 'API', 4 | script: 'app.js', 5 | 6 | // Options reference: https://pm2.io/doc/en/runtime/reference/ecosystem-file/ 7 | args: 'one two', 8 | instances: 1, 9 | autorestart: true, 10 | watch: false, 11 | max_memory_restart: '1G', 12 | env: { 13 | NODE_ENV: 'development' 14 | }, 15 | env_production: { 16 | NODE_ENV: 'production' 17 | } 18 | }], 19 | 20 | deploy : { 21 | production : { 22 | user : 'node', 23 | host : '212.83.163.1', 24 | ref : 'origin/master', 25 | repo : 'git@github.com:repo.git', 26 | path : '/var/www/production', 27 | 'post-deploy' : 'npm install && pm2 reload ecosystem.config.js --env production' 28 | } 29 | } 30 | }; 31 | -------------------------------------------------------------------------------- /Demos/Node.js入门系列/lesson29/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "lesson26", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "server.js", 6 | "directories": { 7 | "lib": "lib" 8 | }, 9 | "scripts": { 10 | "test": "echo \"Error: no test specified\" && exit 1", 11 | "start": "node server.js --dev", 12 | "build": "node server.js --build", 13 | "pm2dev": "pm2 start ecosystem.config.js --watch", 14 | "pm2build": "pm2 start ecosystem.config.js --watch --env production", 15 | "monit": "pm2 monit" 16 | }, 17 | "keywords": [], 18 | "author": "", 19 | "license": "ISC", 20 | "dependencies": { 21 | "co-mysql": "^1.0.0", 22 | "multiparty": "^4.2.1", 23 | "mysql": "^2.16.0" 24 | } 25 | } -------------------------------------------------------------------------------- /Demos/Node.js入门系列/lesson29/router/del.js: -------------------------------------------------------------------------------- 1 | const connection = require('../lib/database') 2 | 3 | module.exports = async (res, query, post, files) => { 4 | const ID = query.id 5 | 6 | if (!ID) { 7 | res.writeJson({ 8 | error: 1, 9 | msg: '参数不合法' 10 | }) 11 | } else { 12 | await connection.query(`DELETE FROM item_table WHERE ID=${ID}`) 13 | 14 | res.writeJson({ 15 | error: 0, 16 | msg: '删除成功' 17 | }) 18 | } 19 | res.end() 20 | } -------------------------------------------------------------------------------- /Demos/Node.js入门系列/lesson29/router/index.js: -------------------------------------------------------------------------------- 1 | const { 2 | addRouter 3 | } = require('../lib/router') 4 | 5 | // 添加获取商品列表接口 6 | addRouter('get', '/list', require('./list')) 7 | 8 | // 添加商品接口 9 | addRouter('post', '/add', require('./add')) 10 | 11 | // 删除商品接口 12 | addRouter('get', '/del', require('./del')) -------------------------------------------------------------------------------- /Demos/Node.js入门系列/lesson29/router/list.js: -------------------------------------------------------------------------------- 1 | const connection = require('../lib/database') 2 | 3 | module.exports = async (res, query, post, files) => { 4 | try { 5 | // 查询商品列表 6 | const data = await connection.query(`SELECT * FROM item_table`) 7 | 8 | res.writeJson({ 9 | error: 0, // error为0则表示接口正常 10 | data // 查询到的商品列表数据 11 | }) 12 | } catch (error) { 13 | console.error(error) 14 | res.writeJson({ 15 | error: 1, // error为1则表示接口出错 16 | msg: '数据库出错' // 接口的错误信息 17 | }) 18 | } 19 | res.end() 20 | } -------------------------------------------------------------------------------- /Demos/Node.js入门系列/lesson29/server.js: -------------------------------------------------------------------------------- 1 | const connection = require('./lib/database') 2 | const http = require('./lib/http') 3 | const router = require('./router') 4 | -------------------------------------------------------------------------------- /Demos/Node.js入门系列/lesson29/static/fonts/glyphicons-halflings-regular.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chencl1986/Blog/60170ad67796c2f48526dae2e3078b2713b74482/Demos/Node.js入门系列/lesson29/static/fonts/glyphicons-halflings-regular.eot -------------------------------------------------------------------------------- /Demos/Node.js入门系列/lesson29/static/fonts/glyphicons-halflings-regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chencl1986/Blog/60170ad67796c2f48526dae2e3078b2713b74482/Demos/Node.js入门系列/lesson29/static/fonts/glyphicons-halflings-regular.ttf -------------------------------------------------------------------------------- /Demos/Node.js入门系列/lesson29/static/fonts/glyphicons-halflings-regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chencl1986/Blog/60170ad67796c2f48526dae2e3078b2713b74482/Demos/Node.js入门系列/lesson29/static/fonts/glyphicons-halflings-regular.woff -------------------------------------------------------------------------------- /Demos/Node.js入门系列/lesson29/static/fonts/glyphicons-halflings-regular.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chencl1986/Blog/60170ad67796c2f48526dae2e3078b2713b74482/Demos/Node.js入门系列/lesson29/static/fonts/glyphicons-halflings-regular.woff2 -------------------------------------------------------------------------------- /Demos/React_Native入门系列/lesson02/.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": ["module:metro-react-native-babel-preset"] 3 | } 4 | -------------------------------------------------------------------------------- /Demos/React_Native入门系列/lesson02/.buckconfig: -------------------------------------------------------------------------------- 1 | 2 | [android] 3 | target = Google Inc.:Google APIs:23 4 | 5 | [maven_repositories] 6 | central = https://repo1.maven.org/maven2 7 | -------------------------------------------------------------------------------- /Demos/React_Native入门系列/lesson02/.gitattributes: -------------------------------------------------------------------------------- 1 | *.pbxproj -text 2 | -------------------------------------------------------------------------------- /Demos/React_Native入门系列/lesson02/.watchmanconfig: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /Demos/React_Native入门系列/lesson02/android/app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /usr/local/Cellar/android-sdk/24.3.3/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /Demos/React_Native入门系列/lesson02/android/app/src/main/java/com/lesson01/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.lesson01; 2 | 3 | import com.facebook.react.ReactActivity; 4 | 5 | public class MainActivity extends ReactActivity { 6 | 7 | /** 8 | * Returns the name of the main component registered from JavaScript. 9 | * This is used to schedule rendering of the component. 10 | */ 11 | @Override 12 | protected String getMainComponentName() { 13 | return "lesson01"; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Demos/React_Native入门系列/lesson02/android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chencl1986/Blog/60170ad67796c2f48526dae2e3078b2713b74482/Demos/React_Native入门系列/lesson02/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /Demos/React_Native入门系列/lesson02/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chencl1986/Blog/60170ad67796c2f48526dae2e3078b2713b74482/Demos/React_Native入门系列/lesson02/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /Demos/React_Native入门系列/lesson02/android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chencl1986/Blog/60170ad67796c2f48526dae2e3078b2713b74482/Demos/React_Native入门系列/lesson02/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /Demos/React_Native入门系列/lesson02/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chencl1986/Blog/60170ad67796c2f48526dae2e3078b2713b74482/Demos/React_Native入门系列/lesson02/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /Demos/React_Native入门系列/lesson02/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chencl1986/Blog/60170ad67796c2f48526dae2e3078b2713b74482/Demos/React_Native入门系列/lesson02/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /Demos/React_Native入门系列/lesson02/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chencl1986/Blog/60170ad67796c2f48526dae2e3078b2713b74482/Demos/React_Native入门系列/lesson02/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /Demos/React_Native入门系列/lesson02/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chencl1986/Blog/60170ad67796c2f48526dae2e3078b2713b74482/Demos/React_Native入门系列/lesson02/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /Demos/React_Native入门系列/lesson02/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chencl1986/Blog/60170ad67796c2f48526dae2e3078b2713b74482/Demos/React_Native入门系列/lesson02/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /Demos/React_Native入门系列/lesson02/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chencl1986/Blog/60170ad67796c2f48526dae2e3078b2713b74482/Demos/React_Native入门系列/lesson02/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /Demos/React_Native入门系列/lesson02/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chencl1986/Blog/60170ad67796c2f48526dae2e3078b2713b74482/Demos/React_Native入门系列/lesson02/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /Demos/React_Native入门系列/lesson02/android/app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | lesson01 3 | 4 | -------------------------------------------------------------------------------- /Demos/React_Native入门系列/lesson02/android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /Demos/React_Native入门系列/lesson02/android/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chencl1986/Blog/60170ad67796c2f48526dae2e3078b2713b74482/Demos/React_Native入门系列/lesson02/android/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /Demos/React_Native入门系列/lesson02/android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | zipStoreBase=GRADLE_USER_HOME 4 | zipStorePath=wrapper/dists 5 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip 6 | -------------------------------------------------------------------------------- /Demos/React_Native入门系列/lesson02/android/keystores/BUCK: -------------------------------------------------------------------------------- 1 | keystore( 2 | name = "debug", 3 | properties = "debug.keystore.properties", 4 | store = "debug.keystore", 5 | visibility = [ 6 | "PUBLIC", 7 | ], 8 | ) 9 | -------------------------------------------------------------------------------- /Demos/React_Native入门系列/lesson02/android/keystores/debug.keystore.properties: -------------------------------------------------------------------------------- 1 | key.store=debug.keystore 2 | key.alias=androiddebugkey 3 | key.store.password=android 4 | key.alias.password=android 5 | -------------------------------------------------------------------------------- /Demos/React_Native入门系列/lesson02/android/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'lesson01' 2 | 3 | include ':app' 4 | -------------------------------------------------------------------------------- /Demos/React_Native入门系列/lesson02/app.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "lesson01", 3 | "displayName": "lesson01" 4 | } -------------------------------------------------------------------------------- /Demos/React_Native入门系列/lesson02/index.js: -------------------------------------------------------------------------------- 1 | /** @format */ 2 | 3 | import {AppRegistry} from 'react-native'; 4 | import App from './App'; 5 | import {name as appName} from './app.json'; 6 | 7 | AppRegistry.registerComponent(appName, () => App); 8 | -------------------------------------------------------------------------------- /Demos/React_Native入门系列/lesson02/ios/lesson01-tvOSTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /Demos/React_Native入门系列/lesson02/ios/lesson01/AppDelegate.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | #import 9 | 10 | @interface AppDelegate : UIResponder 11 | 12 | @property (nonatomic, strong) UIWindow *window; 13 | 14 | @end 15 | -------------------------------------------------------------------------------- /Demos/React_Native入门系列/lesson02/ios/lesson01/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | } 33 | ], 34 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /Demos/React_Native入门系列/lesson02/ios/lesson01/Images.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /Demos/React_Native入门系列/lesson02/ios/lesson01/main.m: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | #import 9 | 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Demos/React_Native入门系列/lesson02/ios/lesson01Tests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /Demos/React_Native入门系列/lesson02/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "lesson01", 3 | "version": "0.0.1", 4 | "private": true, 5 | "scripts": { 6 | "start": "node node_modules/react-native/local-cli/cli.js start", 7 | "test": "jest", 8 | "android": "react-native run-android", 9 | "ios": "react-native run-ios" 10 | }, 11 | "dependencies": { 12 | "react": "16.6.3", 13 | "react-native": "0.57.8" 14 | }, 15 | "devDependencies": { 16 | "babel-jest": "23.6.0", 17 | "jest": "23.6.0", 18 | "metro-react-native-babel-preset": "0.51.1", 19 | "react-test-renderer": "16.6.3" 20 | }, 21 | "jest": { 22 | "preset": "react-native" 23 | } 24 | } -------------------------------------------------------------------------------- /Demos/React_Native入门系列/lesson02/unnamed.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chencl1986/Blog/60170ad67796c2f48526dae2e3078b2713b74482/Demos/React_Native入门系列/lesson02/unnamed.jpg -------------------------------------------------------------------------------- /Demos/React_Native入门系列/lesson02/utils/common.js: -------------------------------------------------------------------------------- 1 | // 引入Dimensions,用于获取设备的尺寸 2 | import { Dimensions } from 'react-native'; 3 | 4 | // 设置基础宽度为750 5 | const BASE_WIDTH=750; 6 | 7 | export function calc(size){ 8 | // 获取当前窗口宽度,支持参数为window和screen 9 | let { width } = Dimensions.get('window'); 10 | 11 | // 换算出当前需要显示的尺寸 12 | return size * width / BASE_WIDTH; 13 | } 14 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson01 Vue表达式与v-bind指令/01. Vue表达式.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 姓名:{{name}}
13 | 年龄:{{age}}
14 | 出生日期:{{new Date().getFullYear() - age}} 15 | 出生日期:{{this.getBirth()}} 16 |
17 | 18 | 32 | 33 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson02 v-model、v-text、v-html/01. v-model指令.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 |

{{name}}

13 |
14 | 15 | 23 | 24 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson02 v-model、v-text、v-html/02. v-text、v-html指令.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 |
12 |
13 |
14 | 15 | 23 | 24 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson03 Vue事件、v-show、v-if指令/01. v-on指令.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | {{num}} 12 | 13 |
14 | 15 | 28 | 29 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson04 v-for指令/02. v-for指令循环字符串、数字.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 12 | 13 | 14 | 15 |
16 |
    17 |
  • 18 | {{item}} 19 |
  • 20 |
21 |
    22 |
  • 23 | {{index}} 24 |
  • 25 |
26 |
27 | 28 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson05 v-pre、v-cloak指令/01. v-pre指令.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 12 | 13 | 14 | 15 |
16 | 17 |
18 | {{a}} + {{b}} 19 |
20 |
21 | 22 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson13 webpack project/css/main.css: -------------------------------------------------------------------------------- 1 | .nav {overflow:hidden;} 2 | .nav .nav-item {float:left; color:#CCC; margin-right:10px; text-decoration:none;} 3 | .nav .router-link-active {color:#333;} 4 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson13 webpack project/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 |
14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson13 webpack project/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "routernested", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "keywords": [], 10 | "author": "", 11 | "license": "ISC", 12 | "devDependencies": { 13 | "css-loader": "^1.0.1", 14 | "style-loader": "^0.23.1", 15 | "vue": "^2.5.17", 16 | "vue-router": "^3.0.2", 17 | "webpack": "^4.27.1", 18 | "webpack-cli": "^3.1.2" 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson13 webpack project/src/components/header.js: -------------------------------------------------------------------------------- 1 | export default { 2 | template: ` 3 | 7 | ` 8 | } 9 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson13 webpack project/src/components/home.js: -------------------------------------------------------------------------------- 1 | export default { 2 | template: ` 3 |
4 | 首页 5 |
6 | ` 7 | } 8 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson13 webpack project/src/components/news1.js: -------------------------------------------------------------------------------- 1 | export default { 2 | template: ` 3 |
4 | 新闻 5 |
6 | ` 7 | } 8 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson13 webpack project/src/components/news2.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chencl1986/Blog/60170ad67796c2f48526dae2e3078b2713b74482/Demos/Vue入门系列/lesson13 webpack project/src/components/news2.js -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson13 webpack project/src/router.js: -------------------------------------------------------------------------------- 1 | // 引入VueRouter模块 2 | import VueRouter from 'vue-router'; 3 | 4 | // 引入组件 5 | import Header from './components/header'; 6 | import Home from './components/home'; 7 | import News from './components/news1'; 8 | 9 | export default new VueRouter({ 10 | routes: [ 11 | { 12 | path: '/index', // 路由的路径 13 | name: 'index', // 路由名称,可选属性,定义后可以用其实现跳转 14 | components: { // 通过components属性显示多个组件 15 | header: Header, // 命名视图,对应 16 | default: Home // 默认视图,对应 17 | } 18 | }, 19 | { 20 | path: '/news', 21 | name: 'news', 22 | components: { 23 | header: Header, 24 | default: News 25 | } 26 | } 27 | ] 28 | }) 29 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson13 webpack project/src/vm.js: -------------------------------------------------------------------------------- 1 | // 引入Vue的es module模块,使用vue-cli时,因为配置了alias,所以可以直接引用vue 2 | import Vue from 'vue/dist/vue.esm'; 3 | // 引入VueRouter模块 4 | import VueRouter from 'vue-router'; 5 | 6 | // 引入路由配置 7 | import router from './router'; 8 | 9 | // 引入项目样式表 10 | import '../css/main.css'; 11 | 12 | // 安装VueRouter插件 13 | Vue.use(VueRouter); 14 | 15 | // 配置Vue应用 16 | const vm=new Vue({ 17 | el: '#app', 18 | data: {}, 19 | router 20 | }); 21 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson13 webpack project/webpack.config.js: -------------------------------------------------------------------------------- 1 | const path=require('path'); 2 | 3 | module.exports={ 4 | mode: 'development', // 开发模式 5 | entry: './src/vm.js', // 入口文件配置 6 | output: { 7 | path: path.resolve(__dirname, 'dest'), // 输出文件夹 8 | filename: 'bundle.min.js' // 打包输出的文件名 9 | }, 10 | module: { 11 | rules: [ 12 | { // 处理CSS 13 | test: /\.css$/i, 14 | use: ['style-loader', 'css-loader'] 15 | } 16 | ] 17 | } 18 | }; 19 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson14 child route/css/main.css: -------------------------------------------------------------------------------- 1 | .nav {overflow:hidden;} 2 | .nav .nav-item {float:left; color:#CCC; margin-right:10px; text-decoration:none;} 3 | .nav .router-link-active {color:#333;} 4 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson14 child route/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 |
14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson14 child route/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "routernested", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "keywords": [], 10 | "author": "", 11 | "license": "ISC", 12 | "devDependencies": { 13 | "css-loader": "^1.0.1", 14 | "style-loader": "^0.23.1", 15 | "vue": "^2.5.17", 16 | "vue-router": "^3.0.2", 17 | "webpack": "^4.27.1", 18 | "webpack-cli": "^3.1.2" 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson14 child route/src/components/header.js: -------------------------------------------------------------------------------- 1 | export default { 2 | template: ` 3 | 7 | ` 8 | } 9 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson14 child route/src/components/home.js: -------------------------------------------------------------------------------- 1 | export default { 2 | template: ` 3 |
4 | 首页 5 |
6 | ` 7 | } 8 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson14 child route/src/components/news.js: -------------------------------------------------------------------------------- 1 | import NewsHeader from './news_header'; 2 | import News1 from './news1'; 3 | import News2 from './news2'; 4 | 5 | 6 | //组件 7 | export default { 8 | template: ` 9 |
10 | 新闻 11 | 12 | 13 |
14 | ` 15 | } 16 | 17 | export let router=[ 18 | { 19 | path: '1', 20 | name: 'news1', 21 | components: { 22 | news_header: NewsHeader, 23 | default: News1 24 | } 25 | }, 26 | { 27 | path: '2', 28 | name: 'news2', 29 | components: { 30 | news_header: NewsHeader, 31 | default: News2 32 | } 33 | } 34 | ]; 35 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson14 child route/src/components/news1.js: -------------------------------------------------------------------------------- 1 | export default { 2 | template: ` 3 |
4 | 新闻1111 5 |
6 | ` 7 | } 8 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson14 child route/src/components/news2.js: -------------------------------------------------------------------------------- 1 | export default { 2 | template: ` 3 |
4 | 新闻22222 5 |
6 | ` 7 | } 8 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson14 child route/src/components/news_header.js: -------------------------------------------------------------------------------- 1 | export default { 2 | template: ` 3 |
4 | 新闻1 5 | 新闻2 6 |
7 | ` 8 | } 9 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson14 child route/src/router.js: -------------------------------------------------------------------------------- 1 | // 引入VueRouter模块 2 | import VueRouter from 'vue-router'; 3 | 4 | // 引入组件 5 | import Header from './components/header'; 6 | import Home from './components/home'; 7 | import News, { router as news_router } from './components/news'; 8 | 9 | export default new VueRouter({ 10 | routes: [ 11 | { 12 | path: '/index', // 路由的路径 13 | name: 'index', // 路由名称,可选属性,定义后可以用其实现跳转 14 | components: { // 通过components属性显示多个组件 15 | header: Header, // 命名视图,对应 16 | default: Home // 默认视图,对应 17 | } 18 | }, 19 | { 20 | path: '/news', 21 | name: 'news', 22 | components: { 23 | header: Header, 24 | default: News 25 | }, 26 | children: news_router 27 | } 28 | ] 29 | }) 30 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson14 child route/src/vm.js: -------------------------------------------------------------------------------- 1 | // 引入Vue的es module模块,使用vue-cli时,因为配置了alias,所以可以直接引用vue 2 | import Vue from 'vue/dist/vue.esm'; 3 | // 引入VueRouter模块 4 | import VueRouter from 'vue-router'; 5 | 6 | // 引入路由配置 7 | import router from './router'; 8 | 9 | // 引入项目样式表 10 | import '../css/main.css'; 11 | 12 | // 安装VueRouter插件 13 | Vue.use(VueRouter); 14 | 15 | // 配置Vue应用 16 | const vm=new Vue({ 17 | el: '#app', 18 | data: {}, 19 | router 20 | }); 21 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson14 child route/webpack.config.js: -------------------------------------------------------------------------------- 1 | const path=require('path'); 2 | 3 | module.exports={ 4 | mode: 'development', // 开发模式 5 | entry: './src/vm.js', // 入口文件配置 6 | output: { 7 | path: path.resolve(__dirname, 'dest'), // 输出文件夹 8 | filename: 'bundle.min.js' // 打包输出的文件名 9 | }, 10 | module: { 11 | rules: [ 12 | { // 处理CSS 13 | test: /\.css$/i, 14 | use: ['style-loader', 'css-loader'] 15 | } 16 | ] 17 | } 18 | }; 19 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson15 component/dest/448c34a56d699c29117adc64c43affeb.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chencl1986/Blog/60170ad67796c2f48526dae2e3078b2713b74482/Demos/Vue入门系列/lesson15 component/dest/448c34a56d699c29117adc64c43affeb.woff2 -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson15 component/dest/e18bbf611f2a2e43afc071aa2f4e1512.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chencl1986/Blog/60170ad67796c2f48526dae2e3078b2713b74482/Demos/Vue入门系列/lesson15 component/dest/e18bbf611f2a2e43afc071aa2f4e1512.ttf -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson15 component/dest/f4769f9bdb7466be65088239c12046d1.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chencl1986/Blog/60170ad67796c2f48526dae2e3078b2713b74482/Demos/Vue入门系列/lesson15 component/dest/f4769f9bdb7466be65088239c12046d1.eot -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson15 component/dest/fa2772327f55d8198301fdb8bcfc8158.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chencl1986/Blog/60170ad67796c2f48526dae2e3078b2713b74482/Demos/Vue入门系列/lesson15 component/dest/fa2772327f55d8198301fdb8bcfc8158.woff -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson15 component/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson15 component/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "component", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "webpack.config.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1", 8 | "start": "webpack-dev-server" 9 | }, 10 | "keywords": [], 11 | "author": "", 12 | "license": "ISC", 13 | "devDependencies": { 14 | "bootstrap": "^3.3.7", 15 | "css-loader": "^1.0.1", 16 | "file-loader": "^2.0.0", 17 | "style-loader": "^0.23.1", 18 | "vue": "^2.5.17", 19 | "webpack": "^4.26.1", 20 | "webpack-cli": "^3.1.2", 21 | "webpack-dev-server": "^3.1.10" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson15 component/src/cmp1.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue/dist/vue.esm'; 2 | 3 | // 通过Vue.component注册一个组件 4 | export default Vue.component('cmp1', { 5 | props: ['name', 'age', 'list'], // 定义要传入的props,在Vue中只有已定义的props才可以被组件接收到 6 | data(){ // 组件的data必须是函数,为了保证组件的data作用域独立 7 | return {a: 77, b: 55}; 8 | }, 9 | // 组件模板 10 | template: ` 11 |
12 | 姓名:{{name}}
13 | 年龄:{{age}}
14 |
    15 |
  • {{item}}
  • 16 |
17 |
18 | ` 19 | }); 20 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson15 component/src/css/my-dialog.css: -------------------------------------------------------------------------------- 1 | .my-dialog {width:400px; margin:100px auto 0;} 2 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson15 component/src/my-dialog.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue/dist/vue.esm'; 2 | import 'bootstrap/dist/css/bootstrap.css'; 3 | import './css/my-dialog.css'; 4 | 5 | export default Vue.component('my-dialog', { 6 | data(){ 7 | return {}; 8 | }, 9 | template: ` 10 |
11 |
12 | 13 |
14 |
15 | 16 |
17 |
18 | ` 19 | }); 20 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson15 component/webpack.config.js: -------------------------------------------------------------------------------- 1 | const path=require('path'); 2 | 3 | module.exports={ 4 | mode: 'development', 5 | entry: './src/vm.js', 6 | output: { 7 | path: path.resolve(__dirname, 'dest'), 8 | filename: 'bundle.js' 9 | }, 10 | module: { 11 | rules: [ 12 | {test: /\.css$/i, use: ['style-loader', 'css-loader']}, 13 | {test: /\.(eot|svg|ttf|woff|woff2)$/i, use: 'file-loader'} 14 | ] 15 | } 16 | }; 17 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson16 lifecycle/lifecycle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chencl1986/Blog/60170ad67796c2f48526dae2e3078b2713b74482/Demos/Vue入门系列/lesson16 lifecycle/lifecycle.png -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson17 组件间通信之一:通过组件实例通信/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson17 组件间通信之一:通过组件实例通信/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "component", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "webpack.config.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1", 8 | "start": "webpack-dev-server" 9 | }, 10 | "keywords": [], 11 | "author": "", 12 | "license": "ISC", 13 | "devDependencies": { 14 | "bootstrap": "^3.3.7", 15 | "css-loader": "^1.0.1", 16 | "file-loader": "^2.0.0", 17 | "style-loader": "^0.23.1", 18 | "vue": "^2.5.17", 19 | "webpack": "^4.26.1", 20 | "webpack-cli": "^3.1.2", 21 | "webpack-dev-server": "^3.1.10" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson17 组件间通信之一:通过组件实例通信/src/components/child.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue/dist/vue.esm'; 2 | 3 | export default Vue.component('parent', { 4 | props: ['parent'], 5 | data() { 6 | return { 7 | num1: 0, 8 | num2: 0, 9 | }; 10 | }, 11 | methods: { 12 | add() { 13 | this.num2++ 14 | }, 15 | addParent1() { 16 | this.parent.num1++ 17 | }, 18 | addParent2() { 19 | this.parent.add() 20 | }, 21 | }, 22 | template: ` 23 |
24 | 子级 25 | num1:{{num1}} 26 | num2:{{num2}} 27 |
28 |
29 |
30 | ` 31 | }); 32 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson17 组件间通信之一:通过组件实例通信/src/components/parent.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue/dist/vue.esm'; 2 | import Child from './child'; 3 | 4 | export default Vue.component('parent', { 5 | data() { 6 | return { 7 | num1: 0, 8 | num2: 0, 9 | }; 10 | }, 11 | components: { 12 | Child 13 | }, 14 | methods: { 15 | add() { 16 | this.num2++ 17 | }, 18 | addChild1() { 19 | this.$refs.child.num1++ 20 | }, 21 | addChild2() { 22 | this.$refs.child.add() 23 | }, 24 | }, 25 | template: ` 26 |
27 |
父级 28 | num1:{{num1}} 29 | num2:{{num2}} 30 |

31 | 32 |
33 | ` 34 | }); 35 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson17 组件间通信之一:通过组件实例通信/src/css/my-dialog.css: -------------------------------------------------------------------------------- 1 | .my-dialog {width:400px; margin:100px auto 0;} 2 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson17 组件间通信之一:通过组件实例通信/src/vm.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue/dist/vue.esm'; 2 | import Parent from './components/parent'; 3 | 4 | let vm=new Vue({ 5 | el: '#div1', 6 | data: { 7 | 8 | }, 9 | components: { 10 | Parent 11 | }, 12 | template: ` 13 |
14 | 15 |
16 | ` 17 | }) 18 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson17 组件间通信之一:通过组件实例通信/webpack.config.js: -------------------------------------------------------------------------------- 1 | const path=require('path'); 2 | 3 | module.exports={ 4 | mode: 'development', 5 | entry: './src/vm.js', 6 | output: { 7 | path: path.resolve(__dirname, 'dest'), 8 | filename: 'bundle.js' 9 | }, 10 | module: { 11 | rules: [ 12 | {test: /\.css$/i, use: ['style-loader', 'css-loader']}, 13 | {test: /\.(eot|svg|ttf|woff|woff2)$/i, use: 'file-loader'} 14 | ] 15 | } 16 | }; 17 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson18 组件间通信之二:通过事件通信/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson18 组件间通信之二:通过事件通信/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "component", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "webpack.config.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1", 8 | "start": "webpack-dev-server" 9 | }, 10 | "keywords": [], 11 | "author": "", 12 | "license": "ISC", 13 | "devDependencies": { 14 | "bootstrap": "^3.3.7", 15 | "css-loader": "^1.0.1", 16 | "file-loader": "^2.0.0", 17 | "style-loader": "^0.23.1", 18 | "vue": "^2.5.17", 19 | "webpack": "^4.26.1", 20 | "webpack-cli": "^3.1.2", 21 | "webpack-dev-server": "^3.1.10" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson18 组件间通信之二:通过事件通信/src/components/child.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue/dist/vue.esm'; 2 | 3 | export default Vue.component('parent', { 4 | props: ['parent'], 5 | data() { 6 | return { 7 | num: 0, 8 | }; 9 | }, 10 | methods: { 11 | addParent() { 12 | this.parent.$emit('add', 5) 13 | }, 14 | }, 15 | created() { 16 | this.$on('add', function (n) { 17 | this.num = this.num + n 18 | }) 19 | }, 20 | template: ` 21 |
22 | 子级 23 | num:{{num}} 24 |
25 |
26 | ` 27 | }); 28 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson18 组件间通信之二:通过事件通信/src/components/parent.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue/dist/vue.esm'; 2 | import Child from './child'; 3 | 4 | export default Vue.component('parent', { 5 | data() { 6 | return { 7 | num: 0, 8 | }; 9 | }, 10 | components: { 11 | Child 12 | }, 13 | created() { 14 | this.$on('add', function (n) { 15 | this.num = this.num + n 16 | }) 17 | }, 18 | methods: { 19 | addChild() { 20 | this.$refs.child.$emit('add', 5) 21 | }, 22 | }, 23 | template: ` 24 |
25 |
父级 26 | num:{{num}} 27 |
28 | 29 |
30 | ` 31 | }); 32 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson18 组件间通信之二:通过事件通信/src/css/my-dialog.css: -------------------------------------------------------------------------------- 1 | .my-dialog {width:400px; margin:100px auto 0;} 2 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson18 组件间通信之二:通过事件通信/src/vm.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue/dist/vue.esm'; 2 | import Parent from './components/parent'; 3 | 4 | let vm=new Vue({ 5 | el: '#div1', 6 | data: { 7 | 8 | }, 9 | components: { 10 | Parent 11 | }, 12 | template: ` 13 |
14 | 15 |
16 | ` 17 | }) 18 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson18 组件间通信之二:通过事件通信/webpack.config.js: -------------------------------------------------------------------------------- 1 | const path=require('path'); 2 | 3 | module.exports={ 4 | mode: 'development', 5 | entry: './src/vm.js', 6 | output: { 7 | path: path.resolve(__dirname, 'dest'), 8 | filename: 'bundle.js' 9 | }, 10 | module: { 11 | rules: [ 12 | {test: /\.css$/i, use: ['style-loader', 'css-loader']}, 13 | {test: /\.(eot|svg|ttf|woff|woff2)$/i, use: 'file-loader'} 14 | ] 15 | } 16 | }; 17 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson19 Vue 2.0组件开发模式/config/webpack.development.js: -------------------------------------------------------------------------------- 1 | const HtmlWebpackPlugin=require('html-webpack-plugin'); 2 | const VueLoaderPlugin=require('vue-loader/lib/plugin'); 3 | 4 | module.exports={ 5 | mode: 'development', 6 | output: { 7 | filename: 'bundle.js' 8 | }, 9 | devtool: 'source-map', 10 | plugins: [ 11 | new HtmlWebpackPlugin({ 12 | template: 'index.html' 13 | }), 14 | new VueLoaderPlugin() 15 | ] 16 | }; 17 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson19 Vue 2.0组件开发模式/config/webpack.production.js: -------------------------------------------------------------------------------- 1 | const path=require('path'); 2 | 3 | const HtmlWebpackPlugin=require('html-webpack-plugin'); 4 | const VueLoaderPlugin=require('vue-loader/lib/plugin'); 5 | 6 | module.exports={ 7 | mode: 'production', 8 | output: { 9 | path: path.resolve(__dirname, '../build'), 10 | filename: 'bundle.min.js' 11 | }, 12 | plugins: [ 13 | new HtmlWebpackPlugin({ 14 | template: 'index.html' 15 | }), 16 | new VueLoaderPlugin() 17 | ] 18 | }; 19 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson19 Vue 2.0组件开发模式/data/1.json: -------------------------------------------------------------------------------- 1 | {"name": "lee", "age": 18} 2 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson19 Vue 2.0组件开发模式/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson19 Vue 2.0组件开发模式/src/App.vue: -------------------------------------------------------------------------------- 1 | // 此处书写template模板,支持html等多种语言,等同于Vue.component中的template属性 2 | 13 | 14 | // 此处书写JavaScript代码,等同于Vue.component代码 15 | 30 | 31 | // 此处书写样式,支持css、less等其他语言 32 | 34 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson19 Vue 2.0组件开发模式/src/components/cmp.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | 15 | 16 | 18 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson19 Vue 2.0组件开发模式/src/components/index.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | 23 | 24 | 26 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson19 Vue 2.0组件开发模式/src/components/news.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | 15 | 16 | 18 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson19 Vue 2.0组件开发模式/src/css/base.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chencl1986/Blog/60170ad67796c2f48526dae2e3078b2713b74482/Demos/Vue入门系列/lesson19 Vue 2.0组件开发模式/src/css/base.css -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson19 Vue 2.0组件开发模式/src/index.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue'; 2 | // 主入口组件 3 | import App from './App.vue'; 4 | // 引入路由配置 5 | import router from './routers'; 6 | 7 | let vm=new Vue({ 8 | el: '#div1', 9 | data: {}, 10 | components: {App}, 11 | router, // 将路由表挂载到Vue实例,在组件中可以直接使用路由组件和功能 12 | template: ` 13 | 14 | ` 15 | }) 16 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson19 Vue 2.0组件开发模式/src/routers/index.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue'; 2 | import Router from 'vue-router'; 3 | 4 | // 引入页面组件 5 | import Index from '@/index.vue'; 6 | import News from '@/news.vue'; 7 | 8 | // 全局使用Router 9 | Vue.use(Router); 10 | 11 | // 配置路由 12 | export default new Router({ 13 | routes: [ 14 | { 15 | path: '/', 16 | name: 'index', 17 | component: Index 18 | }, 19 | { 20 | path: '/news', 21 | name: 'news', 22 | component: News 23 | } 24 | ] 25 | }) 26 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson19 Vue 2.0组件开发模式/webpack.config.js: -------------------------------------------------------------------------------- 1 | const path=require('path'); 2 | 3 | module.exports=function (env, argv){ 4 | env=env||{}; 5 | 6 | return { 7 | entry: './src/index', 8 | module: { 9 | rules: [ 10 | {test: /\.css$/i, use: ['vue-style-loader', 'css-loader']}, 11 | {test: /\.(eot|svg|ttf|woff|woff2)$/i, use: 'file-loader'}, 12 | {test: /\.vue$/i, use: 'vue-loader'}, 13 | {test: /\.less$/i, use: ['vue-style-loader', 'css-loader', 'less-loader']} 14 | ] 15 | }, 16 | resolve: { 17 | alias: { 18 | 'vue': 'vue/dist/vue.esm', 19 | '@': path.resolve(__dirname, 'src/components') 20 | } 21 | }, 22 | ...env.development?require('./config/webpack.development'):require('./config/webpack.production') 23 | }; 24 | }; 25 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson20 Vuex入门/.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-vue-jsx", "transform-runtime"], 12 | "env": { 13 | "test": { 14 | "presets": ["env", "stage-2"], 15 | "plugins": ["transform-vue-jsx", "transform-es2015-modules-commonjs", "dynamic-import-node"] 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson20 Vuex入门/.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 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson20 Vuex入门/.eslintignore: -------------------------------------------------------------------------------- 1 | /build/ 2 | /config/ 3 | /dist/ 4 | /*.js 5 | /test/unit/coverage/ 6 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson20 Vuex入门/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules/ 3 | /dist/ 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | /test/unit/coverage/ 8 | /test/e2e/reports/ 9 | selenium-debug.log 10 | 11 | # Editor directories and files 12 | .idea 13 | .vscode 14 | *.suo 15 | *.ntvs* 16 | *.njsproj 17 | *.sln 18 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson20 Vuex入门/.postcssrc.js: -------------------------------------------------------------------------------- 1 | // https://github.com/michael-ciniawsky/postcss-load-config 2 | 3 | module.exports = { 4 | "plugins": { 5 | "postcss-import": {}, 6 | "postcss-url": {}, 7 | // to edit target browsers: use "browserslist" field in package.json 8 | "autoprefixer": {} 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson20 Vuex入门/README.md: -------------------------------------------------------------------------------- 1 | # project1 2 | 3 | > A Vue.js project 4 | 5 | ## Build Setup 6 | 7 | ``` bash 8 | # install dependencies 9 | npm install 10 | 11 | # serve with hot reload at localhost:8080 12 | npm run dev 13 | 14 | # build for production with minification 15 | npm run build 16 | 17 | # build for production and view the bundle analyzer report 18 | npm run build --report 19 | 20 | # run unit tests 21 | npm run unit 22 | 23 | # run e2e tests 24 | npm run e2e 25 | 26 | # run all tests 27 | npm test 28 | ``` 29 | 30 | For a detailed explanation on how things work, check out the [guide](http://vuejs-templates.github.io/webpack/) and [docs for vue-loader](http://vuejs.github.io/vue-loader). 31 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson20 Vuex入门/build/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chencl1986/Blog/60170ad67796c2f48526dae2e3078b2713b74482/Demos/Vue入门系列/lesson20 Vuex入门/build/logo.png -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson20 Vuex入门/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 | module.exports = { 10 | loaders: utils.cssLoaders({ 11 | sourceMap: sourceMapEnabled, 12 | extract: isProduction 13 | }), 14 | cssSourceMap: sourceMapEnabled, 15 | cacheBusting: config.dev.cacheBusting, 16 | transformToRequire: { 17 | video: ['src', 'poster'], 18 | source: 'src', 19 | img: 'src', 20 | image: 'xlink:href' 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson20 Vuex入门/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 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson20 Vuex入门/config/prod.env.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | module.exports = { 3 | NODE_ENV: '"production"' 4 | } 5 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson20 Vuex入门/config/test.env.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | const merge = require('webpack-merge') 3 | const devEnv = require('./dev.env') 4 | 5 | module.exports = merge(devEnv, { 6 | NODE_ENV: '"testing"' 7 | }) 8 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson20 Vuex入门/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | project1 7 | 8 | 9 |
10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson20 Vuex入门/src/App.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | 12 | 13 | 16 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson20 Vuex入门/src/components/Cmp1.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | 19 | 20 | 22 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson20 Vuex入门/src/components/common/Table.vue: -------------------------------------------------------------------------------- 1 | 19 | 20 | 33 | 34 | 36 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson20 Vuex入门/src/router/index.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import Router from 'vue-router' 3 | import Index from '@/components/Index' 4 | 5 | Vue.use(Router) 6 | 7 | export default new Router({ 8 | routes: [ 9 | { 10 | path: '/', 11 | name: 'index', 12 | component: Index 13 | } 14 | ] 15 | }) 16 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson20 Vuex入门/static/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chencl1986/Blog/60170ad67796c2f48526dae2e3078b2713b74482/Demos/Vue入门系列/lesson20 Vuex入门/static/.gitkeep -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson20 Vuex入门/test/e2e/custom-assertions/elementCount.js: -------------------------------------------------------------------------------- 1 | // A custom Nightwatch assertion. 2 | // The assertion name is the filename. 3 | // Example usage: 4 | // 5 | // browser.assert.elementCount(selector, count) 6 | // 7 | // For more information on custom assertions see: 8 | // http://nightwatchjs.org/guide#writing-custom-assertions 9 | 10 | exports.assertion = function (selector, count) { 11 | this.message = 'Testing if element <' + selector + '> has count: ' + count 12 | this.expected = count 13 | this.pass = function (val) { 14 | return val === this.expected 15 | } 16 | this.value = function (res) { 17 | return res.value 18 | } 19 | this.command = function (cb) { 20 | var self = this 21 | return this.api.execute(function (selector) { 22 | return document.querySelectorAll(selector).length 23 | }, [selector], function (res) { 24 | cb.call(self, res) 25 | }) 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson20 Vuex入门/test/e2e/specs/test.js: -------------------------------------------------------------------------------- 1 | // For authoring Nightwatch tests, see 2 | // http://nightwatchjs.org/guide#usage 3 | 4 | module.exports = { 5 | 'default e2e tests': function (browser) { 6 | // automatically uses dev Server port from /config.index.js 7 | // default: http://localhost:8080 8 | // see nightwatch.conf.js 9 | const devServer = browser.globals.devServerURL 10 | 11 | browser 12 | .url(devServer) 13 | .waitForElementVisible('#app', 5000) 14 | .assert.elementPresent('.hello') 15 | .assert.containsText('h1', 'Welcome to Your Vue.js App') 16 | .assert.elementCount('img', 1) 17 | .end() 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson20 Vuex入门/test/unit/.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "jest": true 4 | }, 5 | "globals": { 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson20 Vuex入门/test/unit/jest.conf.js: -------------------------------------------------------------------------------- 1 | const path = require('path') 2 | 3 | module.exports = { 4 | rootDir: path.resolve(__dirname, '../../'), 5 | moduleFileExtensions: [ 6 | 'js', 7 | 'json', 8 | 'vue' 9 | ], 10 | moduleNameMapper: { 11 | '^@/(.*)$': '/src/$1' 12 | }, 13 | transform: { 14 | '^.+\\.js$': '/node_modules/babel-jest', 15 | '.*\\.(vue)$': '/node_modules/vue-jest' 16 | }, 17 | testPathIgnorePatterns: [ 18 | '/test/e2e' 19 | ], 20 | snapshotSerializers: ['/node_modules/jest-serializer-vue'], 21 | setupFiles: ['/test/unit/setup'], 22 | mapCoverage: true, 23 | coverageDirectory: '/test/unit/coverage', 24 | collectCoverageFrom: [ 25 | 'src/**/*.{js,vue}', 26 | '!src/main.js', 27 | '!src/router/index.js', 28 | '!**/node_modules/**' 29 | ] 30 | } 31 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson20 Vuex入门/test/unit/setup.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | 3 | Vue.config.productionTip = false 4 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson20 Vuex入门/test/unit/specs/HelloWorld.spec.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import HelloWorld from '@/components/HelloWorld' 3 | 4 | describe('HelloWorld.vue', () => { 5 | it('should render correct contents', () => { 6 | const Constructor = Vue.extend(HelloWorld) 7 | const vm = new Constructor().$mount() 8 | expect(vm.$el.querySelector('.hello h1').textContent) 9 | .toEqual('Welcome to Your Vue.js App') 10 | }) 11 | }) 12 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson20 Vuex入门/vuex.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chencl1986/Blog/60170ad67796c2f48526dae2e3078b2713b74482/Demos/Vue入门系列/lesson20 Vuex入门/vuex.png -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson21 Vuex Getter/.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-vue-jsx", "transform-runtime"], 12 | "env": { 13 | "test": { 14 | "presets": ["env", "stage-2"], 15 | "plugins": ["transform-vue-jsx", "transform-es2015-modules-commonjs", "dynamic-import-node"] 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson21 Vuex Getter/.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 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson21 Vuex Getter/.eslintignore: -------------------------------------------------------------------------------- 1 | /build/ 2 | /config/ 3 | /dist/ 4 | /*.js 5 | /test/unit/coverage/ 6 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson21 Vuex Getter/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules/ 3 | /dist/ 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | /test/unit/coverage/ 8 | /test/e2e/reports/ 9 | selenium-debug.log 10 | 11 | # Editor directories and files 12 | .idea 13 | .vscode 14 | *.suo 15 | *.ntvs* 16 | *.njsproj 17 | *.sln 18 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson21 Vuex Getter/.postcssrc.js: -------------------------------------------------------------------------------- 1 | // https://github.com/michael-ciniawsky/postcss-load-config 2 | 3 | module.exports = { 4 | "plugins": { 5 | "postcss-import": {}, 6 | "postcss-url": {}, 7 | // to edit target browsers: use "browserslist" field in package.json 8 | "autoprefixer": {} 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson21 Vuex Getter/README.md: -------------------------------------------------------------------------------- 1 | # project1 2 | 3 | > A Vue.js project 4 | 5 | ## Build Setup 6 | 7 | ``` bash 8 | # install dependencies 9 | npm install 10 | 11 | # serve with hot reload at localhost:8080 12 | npm run dev 13 | 14 | # build for production with minification 15 | npm run build 16 | 17 | # build for production and view the bundle analyzer report 18 | npm run build --report 19 | 20 | # run unit tests 21 | npm run unit 22 | 23 | # run e2e tests 24 | npm run e2e 25 | 26 | # run all tests 27 | npm test 28 | ``` 29 | 30 | For a detailed explanation on how things work, check out the [guide](http://vuejs-templates.github.io/webpack/) and [docs for vue-loader](http://vuejs.github.io/vue-loader). 31 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson21 Vuex Getter/build/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chencl1986/Blog/60170ad67796c2f48526dae2e3078b2713b74482/Demos/Vue入门系列/lesson21 Vuex Getter/build/logo.png -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson21 Vuex Getter/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 | module.exports = { 10 | loaders: utils.cssLoaders({ 11 | sourceMap: sourceMapEnabled, 12 | extract: isProduction 13 | }), 14 | cssSourceMap: sourceMapEnabled, 15 | cacheBusting: config.dev.cacheBusting, 16 | transformToRequire: { 17 | video: ['src', 'poster'], 18 | source: 'src', 19 | img: 'src', 20 | image: 'xlink:href' 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson21 Vuex Getter/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 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson21 Vuex Getter/config/prod.env.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | module.exports = { 3 | NODE_ENV: '"production"' 4 | } 5 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson21 Vuex Getter/config/test.env.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | const merge = require('webpack-merge') 3 | const devEnv = require('./dev.env') 4 | 5 | module.exports = merge(devEnv, { 6 | NODE_ENV: '"testing"' 7 | }) 8 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson21 Vuex Getter/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | project1 7 | 8 | 9 |
10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson21 Vuex Getter/src/App.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | 12 | 13 | 16 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson21 Vuex Getter/src/components/Cmp1.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | 19 | 20 | 22 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson21 Vuex Getter/src/components/common/Table.vue: -------------------------------------------------------------------------------- 1 | 19 | 20 | 33 | 34 | 36 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson21 Vuex Getter/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 Vue from 'vue' 4 | import App from './App' 5 | import router from './router' 6 | import store from './store' 7 | 8 | Vue.config.productionTip = false 9 | 10 | //bootstrap 11 | import 'bootstrap/dist/css/bootstrap.min.css'; 12 | import 'vue2-animate/dist/vue2-animate.min.css'; 13 | 14 | 15 | 16 | /* eslint-disable no-new */ 17 | new Vue({ 18 | el: '#app', 19 | router, 20 | store, 21 | components: { App }, 22 | template: '' 23 | }) 24 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson21 Vuex Getter/src/router/index.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import Router from 'vue-router' 3 | import Index from '@/components/Index' 4 | import Index2 from '@/components/Index2' 5 | 6 | Vue.use(Router) 7 | 8 | export default new Router({ 9 | routes: [ 10 | { 11 | path: '/index', 12 | name: 'index', 13 | component: Index 14 | }, 15 | { 16 | path: '/index2', 17 | name: 'index2', 18 | component: Index2 19 | } 20 | ] 21 | }) 22 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson21 Vuex Getter/src/store/index.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import Vuex from 'vuex' 3 | 4 | Vue.use(Vuex) 5 | 6 | // vuex3-声明store对象 7 | export default new Vuex.Store({ 8 | strict: process.env.NODE_ENV != 'production', // 严格模式:防止直接修改state 9 | state: { // 核心:数据 10 | a: 12, 11 | b: 5 12 | }, 13 | mutations: { 14 | addA (state, n) { 15 | state.a += n 16 | }, 17 | addB (state, n) { 18 | state.b += n 19 | } 20 | }, 21 | actions: { 22 | addA ({commit}, n) { 23 | commit('addA', n) 24 | }, 25 | addB ({commit}, n) { 26 | commit('addB', n) 27 | } 28 | }, 29 | getters: { 30 | count (state) { 31 | return state.a + state.b 32 | } 33 | } 34 | }) 35 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson21 Vuex Getter/static/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chencl1986/Blog/60170ad67796c2f48526dae2e3078b2713b74482/Demos/Vue入门系列/lesson21 Vuex Getter/static/.gitkeep -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson21 Vuex Getter/test/e2e/specs/test.js: -------------------------------------------------------------------------------- 1 | // For authoring Nightwatch tests, see 2 | // http://nightwatchjs.org/guide#usage 3 | 4 | module.exports = { 5 | 'default e2e tests': function (browser) { 6 | // automatically uses dev Server port from /config.index.js 7 | // default: http://localhost:8080 8 | // see nightwatch.conf.js 9 | const devServer = browser.globals.devServerURL 10 | 11 | browser 12 | .url(devServer) 13 | .waitForElementVisible('#app', 5000) 14 | .assert.elementPresent('.hello') 15 | .assert.containsText('h1', 'Welcome to Your Vue.js App') 16 | .assert.elementCount('img', 1) 17 | .end() 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson21 Vuex Getter/test/unit/.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "jest": true 4 | }, 5 | "globals": { 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson21 Vuex Getter/test/unit/jest.conf.js: -------------------------------------------------------------------------------- 1 | const path = require('path') 2 | 3 | module.exports = { 4 | rootDir: path.resolve(__dirname, '../../'), 5 | moduleFileExtensions: [ 6 | 'js', 7 | 'json', 8 | 'vue' 9 | ], 10 | moduleNameMapper: { 11 | '^@/(.*)$': '/src/$1' 12 | }, 13 | transform: { 14 | '^.+\\.js$': '/node_modules/babel-jest', 15 | '.*\\.(vue)$': '/node_modules/vue-jest' 16 | }, 17 | testPathIgnorePatterns: [ 18 | '/test/e2e' 19 | ], 20 | snapshotSerializers: ['/node_modules/jest-serializer-vue'], 21 | setupFiles: ['/test/unit/setup'], 22 | mapCoverage: true, 23 | coverageDirectory: '/test/unit/coverage', 24 | collectCoverageFrom: [ 25 | 'src/**/*.{js,vue}', 26 | '!src/main.js', 27 | '!src/router/index.js', 28 | '!**/node_modules/**' 29 | ] 30 | } 31 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson21 Vuex Getter/test/unit/setup.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | 3 | Vue.config.productionTip = false 4 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson21 Vuex Getter/test/unit/specs/HelloWorld.spec.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import HelloWorld from '@/components/HelloWorld' 3 | 4 | describe('HelloWorld.vue', () => { 5 | it('should render correct contents', () => { 6 | const Constructor = Vue.extend(HelloWorld) 7 | const vm = new Constructor().$mount() 8 | expect(vm.$el.querySelector('.hello h1').textContent) 9 | .toEqual('Welcome to Your Vue.js App') 10 | }) 11 | }) 12 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson22 mapState、mapActions、mapGetters/.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-vue-jsx", "transform-runtime"], 12 | "env": { 13 | "test": { 14 | "presets": ["env", "stage-2"], 15 | "plugins": ["transform-vue-jsx", "transform-es2015-modules-commonjs", "dynamic-import-node"] 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson22 mapState、mapActions、mapGetters/.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 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson22 mapState、mapActions、mapGetters/.eslintignore: -------------------------------------------------------------------------------- 1 | /build/ 2 | /config/ 3 | /dist/ 4 | /*.js 5 | /test/unit/coverage/ 6 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson22 mapState、mapActions、mapGetters/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules/ 3 | /dist/ 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | /test/unit/coverage/ 8 | /test/e2e/reports/ 9 | selenium-debug.log 10 | 11 | # Editor directories and files 12 | .idea 13 | .vscode 14 | *.suo 15 | *.ntvs* 16 | *.njsproj 17 | *.sln 18 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson22 mapState、mapActions、mapGetters/.postcssrc.js: -------------------------------------------------------------------------------- 1 | // https://github.com/michael-ciniawsky/postcss-load-config 2 | 3 | module.exports = { 4 | "plugins": { 5 | "postcss-import": {}, 6 | "postcss-url": {}, 7 | // to edit target browsers: use "browserslist" field in package.json 8 | "autoprefixer": {} 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson22 mapState、mapActions、mapGetters/README.md: -------------------------------------------------------------------------------- 1 | # project1 2 | 3 | > A Vue.js project 4 | 5 | ## Build Setup 6 | 7 | ``` bash 8 | # install dependencies 9 | npm install 10 | 11 | # serve with hot reload at localhost:8080 12 | npm run dev 13 | 14 | # build for production with minification 15 | npm run build 16 | 17 | # build for production and view the bundle analyzer report 18 | npm run build --report 19 | 20 | # run unit tests 21 | npm run unit 22 | 23 | # run e2e tests 24 | npm run e2e 25 | 26 | # run all tests 27 | npm test 28 | ``` 29 | 30 | For a detailed explanation on how things work, check out the [guide](http://vuejs-templates.github.io/webpack/) and [docs for vue-loader](http://vuejs.github.io/vue-loader). 31 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson22 mapState、mapActions、mapGetters/build/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chencl1986/Blog/60170ad67796c2f48526dae2e3078b2713b74482/Demos/Vue入门系列/lesson22 mapState、mapActions、mapGetters/build/logo.png -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson22 mapState、mapActions、mapGetters/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 | module.exports = { 10 | loaders: utils.cssLoaders({ 11 | sourceMap: sourceMapEnabled, 12 | extract: isProduction 13 | }), 14 | cssSourceMap: sourceMapEnabled, 15 | cacheBusting: config.dev.cacheBusting, 16 | transformToRequire: { 17 | video: ['src', 'poster'], 18 | source: 'src', 19 | img: 'src', 20 | image: 'xlink:href' 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson22 mapState、mapActions、mapGetters/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 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson22 mapState、mapActions、mapGetters/config/prod.env.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | module.exports = { 3 | NODE_ENV: '"production"' 4 | } 5 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson22 mapState、mapActions、mapGetters/config/test.env.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | const merge = require('webpack-merge') 3 | const devEnv = require('./dev.env') 4 | 5 | module.exports = merge(devEnv, { 6 | NODE_ENV: '"testing"' 7 | }) 8 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson22 mapState、mapActions、mapGetters/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | project1 7 | 8 | 9 |
10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson22 mapState、mapActions、mapGetters/src/App.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | 12 | 13 | 16 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson22 mapState、mapActions、mapGetters/src/components/Cmp1.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | 19 | 20 | 22 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson22 mapState、mapActions、mapGetters/src/components/common/Table.vue: -------------------------------------------------------------------------------- 1 | 19 | 20 | 33 | 34 | 36 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson22 mapState、mapActions、mapGetters/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 Vue from 'vue' 4 | import App from './App' 5 | import router from './router' 6 | import store from './store' 7 | 8 | Vue.config.productionTip = false 9 | 10 | //bootstrap 11 | import 'bootstrap/dist/css/bootstrap.min.css'; 12 | import 'vue2-animate/dist/vue2-animate.min.css'; 13 | 14 | 15 | 16 | /* eslint-disable no-new */ 17 | new Vue({ 18 | el: '#app', 19 | router, 20 | store, 21 | components: { App }, 22 | template: '' 23 | }) 24 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson22 mapState、mapActions、mapGetters/src/router/index.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import Router from 'vue-router' 3 | import Index from '@/components/Index' 4 | import Index2 from '@/components/Index2' 5 | 6 | Vue.use(Router) 7 | 8 | export default new Router({ 9 | routes: [ 10 | { 11 | path: '/index', 12 | name: 'index', 13 | component: Index 14 | }, 15 | { 16 | path: '/index2', 17 | name: 'index2', 18 | component: Index2 19 | } 20 | ] 21 | }) 22 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson22 mapState、mapActions、mapGetters/src/store/index.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import Vuex from 'vuex' 3 | 4 | Vue.use(Vuex) 5 | 6 | // vuex3-声明store对象 7 | export default new Vuex.Store({ 8 | strict: process.env.NODE_ENV !== 'production', // 严格模式:防止直接修改state 9 | state: { // 核心:数据 10 | a: 12, 11 | b: 5, 12 | users: [] 13 | }, 14 | mutations: { 15 | addA (state, n) { 16 | state.a += n 17 | }, 18 | addB (state, n) { 19 | state.b += n 20 | } 21 | }, 22 | actions: { 23 | addA ({commit}, n) { 24 | commit('addA', n) 25 | }, 26 | addB ({commit}, n) { 27 | commit('addB', n) 28 | } 29 | }, 30 | getters: { 31 | count (state) { 32 | return state.a + state.b 33 | } 34 | }, 35 | modules: { 36 | 37 | } 38 | }) 39 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson22 mapState、mapActions、mapGetters/static/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chencl1986/Blog/60170ad67796c2f48526dae2e3078b2713b74482/Demos/Vue入门系列/lesson22 mapState、mapActions、mapGetters/static/.gitkeep -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson22 mapState、mapActions、mapGetters/test/e2e/specs/test.js: -------------------------------------------------------------------------------- 1 | // For authoring Nightwatch tests, see 2 | // http://nightwatchjs.org/guide#usage 3 | 4 | module.exports = { 5 | 'default e2e tests': function (browser) { 6 | // automatically uses dev Server port from /config.index.js 7 | // default: http://localhost:8080 8 | // see nightwatch.conf.js 9 | const devServer = browser.globals.devServerURL 10 | 11 | browser 12 | .url(devServer) 13 | .waitForElementVisible('#app', 5000) 14 | .assert.elementPresent('.hello') 15 | .assert.containsText('h1', 'Welcome to Your Vue.js App') 16 | .assert.elementCount('img', 1) 17 | .end() 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson22 mapState、mapActions、mapGetters/test/unit/.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "jest": true 4 | }, 5 | "globals": { 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson22 mapState、mapActions、mapGetters/test/unit/jest.conf.js: -------------------------------------------------------------------------------- 1 | const path = require('path') 2 | 3 | module.exports = { 4 | rootDir: path.resolve(__dirname, '../../'), 5 | moduleFileExtensions: [ 6 | 'js', 7 | 'json', 8 | 'vue' 9 | ], 10 | moduleNameMapper: { 11 | '^@/(.*)$': '/src/$1' 12 | }, 13 | transform: { 14 | '^.+\\.js$': '/node_modules/babel-jest', 15 | '.*\\.(vue)$': '/node_modules/vue-jest' 16 | }, 17 | testPathIgnorePatterns: [ 18 | '/test/e2e' 19 | ], 20 | snapshotSerializers: ['/node_modules/jest-serializer-vue'], 21 | setupFiles: ['/test/unit/setup'], 22 | mapCoverage: true, 23 | coverageDirectory: '/test/unit/coverage', 24 | collectCoverageFrom: [ 25 | 'src/**/*.{js,vue}', 26 | '!src/main.js', 27 | '!src/router/index.js', 28 | '!**/node_modules/**' 29 | ] 30 | } 31 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson22 mapState、mapActions、mapGetters/test/unit/setup.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | 3 | Vue.config.productionTip = false 4 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson22 mapState、mapActions、mapGetters/test/unit/specs/HelloWorld.spec.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import HelloWorld from '@/components/HelloWorld' 3 | 4 | describe('HelloWorld.vue', () => { 5 | it('should render correct contents', () => { 6 | const Constructor = Vue.extend(HelloWorld) 7 | const vm = new Constructor().$mount() 8 | expect(vm.$el.querySelector('.hello h1').textContent) 9 | .toEqual('Welcome to Your Vue.js App') 10 | }) 11 | }) 12 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson23 Vuex异步Action/.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-vue-jsx", "transform-runtime"], 12 | "env": { 13 | "test": { 14 | "presets": ["env", "stage-2"], 15 | "plugins": ["transform-vue-jsx", "transform-es2015-modules-commonjs", "dynamic-import-node"] 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson23 Vuex异步Action/.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 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson23 Vuex异步Action/.eslintignore: -------------------------------------------------------------------------------- 1 | /build/ 2 | /config/ 3 | /dist/ 4 | /*.js 5 | /test/unit/coverage/ 6 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson23 Vuex异步Action/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules/ 3 | /dist/ 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | /test/unit/coverage/ 8 | /test/e2e/reports/ 9 | selenium-debug.log 10 | 11 | # Editor directories and files 12 | .idea 13 | .vscode 14 | *.suo 15 | *.ntvs* 16 | *.njsproj 17 | *.sln 18 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson23 Vuex异步Action/.postcssrc.js: -------------------------------------------------------------------------------- 1 | // https://github.com/michael-ciniawsky/postcss-load-config 2 | 3 | module.exports = { 4 | "plugins": { 5 | "postcss-import": {}, 6 | "postcss-url": {}, 7 | // to edit target browsers: use "browserslist" field in package.json 8 | "autoprefixer": {} 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson23 Vuex异步Action/README.md: -------------------------------------------------------------------------------- 1 | # project1 2 | 3 | > A Vue.js project 4 | 5 | ## Build Setup 6 | 7 | ``` bash 8 | # install dependencies 9 | npm install 10 | 11 | # serve with hot reload at localhost:8080 12 | npm run dev 13 | 14 | # build for production with minification 15 | npm run build 16 | 17 | # build for production and view the bundle analyzer report 18 | npm run build --report 19 | 20 | # run unit tests 21 | npm run unit 22 | 23 | # run e2e tests 24 | npm run e2e 25 | 26 | # run all tests 27 | npm test 28 | ``` 29 | 30 | For a detailed explanation on how things work, check out the [guide](http://vuejs-templates.github.io/webpack/) and [docs for vue-loader](http://vuejs.github.io/vue-loader). 31 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson23 Vuex异步Action/build/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chencl1986/Blog/60170ad67796c2f48526dae2e3078b2713b74482/Demos/Vue入门系列/lesson23 Vuex异步Action/build/logo.png -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson23 Vuex异步Action/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 | module.exports = { 10 | loaders: utils.cssLoaders({ 11 | sourceMap: sourceMapEnabled, 12 | extract: isProduction 13 | }), 14 | cssSourceMap: sourceMapEnabled, 15 | cacheBusting: config.dev.cacheBusting, 16 | transformToRequire: { 17 | video: ['src', 'poster'], 18 | source: 'src', 19 | img: 'src', 20 | image: 'xlink:href' 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson23 Vuex异步Action/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 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson23 Vuex异步Action/config/prod.env.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | module.exports = { 3 | NODE_ENV: '"production"' 4 | } 5 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson23 Vuex异步Action/config/test.env.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | const merge = require('webpack-merge') 3 | const devEnv = require('./dev.env') 4 | 5 | module.exports = merge(devEnv, { 6 | NODE_ENV: '"testing"' 7 | }) 8 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson23 Vuex异步Action/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | project1 7 | 8 | 9 |
10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson23 Vuex异步Action/server/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "server", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "keywords": [], 10 | "author": "", 11 | "license": "ISC", 12 | "devDependencies": { 13 | "koa": "^2.6.2", 14 | "koa-router": "^7.4.0", 15 | "koa-static": "^5.0.0" 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson23 Vuex异步Action/server/server.js: -------------------------------------------------------------------------------- 1 | const Koa=require('koa'); 2 | const static=require('koa-static'); 3 | 4 | let server=new Koa(); 5 | server.listen(8081); 6 | 7 | server.use(async (ctx, next)=>{ 8 | ctx.set('Access-Control-Allow-Origin', '*'); 9 | 10 | await next(); 11 | }); 12 | 13 | server.use(static('./static')); 14 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson23 Vuex异步Action/server/static/user.txt: -------------------------------------------------------------------------------- 1 | [{"id":3,"name":"lee","age":18,"online":true},{"id":5,"name":"zhangsan","age":22,"online":false},{"id":11,"name":"lisi","age":25,"online":true}] -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson23 Vuex异步Action/src/App.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | 12 | 13 | 16 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson23 Vuex异步Action/src/components/Cmp1.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | 19 | 20 | 22 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson23 Vuex异步Action/src/components/common/Table.vue: -------------------------------------------------------------------------------- 1 | 19 | 20 | 33 | 34 | 36 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson23 Vuex异步Action/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 Vue from 'vue' 4 | import App from './App' 5 | import router from './router' 6 | import store from './store' 7 | 8 | Vue.config.productionTip = false 9 | 10 | //bootstrap 11 | import 'bootstrap/dist/css/bootstrap.min.css'; 12 | import 'vue2-animate/dist/vue2-animate.min.css'; 13 | 14 | 15 | 16 | /* eslint-disable no-new */ 17 | new Vue({ 18 | el: '#app', 19 | router, 20 | store, 21 | components: { App }, 22 | template: '' 23 | }) 24 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson23 Vuex异步Action/src/router/index.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import Router from 'vue-router' 3 | import Index from '@/components/Index' 4 | import Index2 from '@/components/Index2' 5 | 6 | Vue.use(Router) 7 | 8 | export default new Router({ 9 | routes: [ 10 | { 11 | path: '/index', 12 | name: 'index', 13 | component: Index 14 | }, 15 | { 16 | path: '/index2', 17 | name: 'index2', 18 | component: Index2 19 | } 20 | ] 21 | }) 22 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson23 Vuex异步Action/src/store/mod_a.js: -------------------------------------------------------------------------------- 1 | export default { 2 | state: { 3 | str: 'store_a' 4 | }, 5 | mutations: { 6 | 'mod_a.setStr': function (state, s){ 7 | alert('a的setStr'); 8 | state.str=s; 9 | } 10 | }, 11 | actions: { 12 | 'mod_a.setStr': function ({commit}, s){ 13 | commit('mod_a.setStr', s); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson23 Vuex异步Action/src/store/mod_b.js: -------------------------------------------------------------------------------- 1 | export default { 2 | state: { 3 | str: 'store_b' 4 | }, 5 | mutations: { 6 | 'mod_b.setStr': function (state, s){ 7 | alert('b的setStr'); 8 | state.str=s; 9 | } 10 | }, 11 | actions: { 12 | 'mod_b.setStr': function ({commit}, s){ 13 | commit('mod_b.setStr', s); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson23 Vuex异步Action/static/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chencl1986/Blog/60170ad67796c2f48526dae2e3078b2713b74482/Demos/Vue入门系列/lesson23 Vuex异步Action/static/.gitkeep -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson23 Vuex异步Action/test/e2e/specs/test.js: -------------------------------------------------------------------------------- 1 | // For authoring Nightwatch tests, see 2 | // http://nightwatchjs.org/guide#usage 3 | 4 | module.exports = { 5 | 'default e2e tests': function (browser) { 6 | // automatically uses dev Server port from /config.index.js 7 | // default: http://localhost:8080 8 | // see nightwatch.conf.js 9 | const devServer = browser.globals.devServerURL 10 | 11 | browser 12 | .url(devServer) 13 | .waitForElementVisible('#app', 5000) 14 | .assert.elementPresent('.hello') 15 | .assert.containsText('h1', 'Welcome to Your Vue.js App') 16 | .assert.elementCount('img', 1) 17 | .end() 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson23 Vuex异步Action/test/unit/.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "jest": true 4 | }, 5 | "globals": { 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson23 Vuex异步Action/test/unit/jest.conf.js: -------------------------------------------------------------------------------- 1 | const path = require('path') 2 | 3 | module.exports = { 4 | rootDir: path.resolve(__dirname, '../../'), 5 | moduleFileExtensions: [ 6 | 'js', 7 | 'json', 8 | 'vue' 9 | ], 10 | moduleNameMapper: { 11 | '^@/(.*)$': '/src/$1' 12 | }, 13 | transform: { 14 | '^.+\\.js$': '/node_modules/babel-jest', 15 | '.*\\.(vue)$': '/node_modules/vue-jest' 16 | }, 17 | testPathIgnorePatterns: [ 18 | '/test/e2e' 19 | ], 20 | snapshotSerializers: ['/node_modules/jest-serializer-vue'], 21 | setupFiles: ['/test/unit/setup'], 22 | mapCoverage: true, 23 | coverageDirectory: '/test/unit/coverage', 24 | collectCoverageFrom: [ 25 | 'src/**/*.{js,vue}', 26 | '!src/main.js', 27 | '!src/router/index.js', 28 | '!**/node_modules/**' 29 | ] 30 | } 31 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson23 Vuex异步Action/test/unit/setup.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | 3 | Vue.config.productionTip = false 4 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson23 Vuex异步Action/test/unit/specs/HelloWorld.spec.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import HelloWorld from '@/components/HelloWorld' 3 | 4 | describe('HelloWorld.vue', () => { 5 | it('should render correct contents', () => { 6 | const Constructor = Vue.extend(HelloWorld) 7 | const vm = new Constructor().$mount() 8 | expect(vm.$el.querySelector('.hello h1').textContent) 9 | .toEqual('Welcome to Your Vue.js App') 10 | }) 11 | }) 12 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson24 Vuex Modules/.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-vue-jsx", "transform-runtime"], 12 | "env": { 13 | "test": { 14 | "presets": ["env", "stage-2"], 15 | "plugins": ["transform-vue-jsx", "transform-es2015-modules-commonjs", "dynamic-import-node"] 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson24 Vuex Modules/.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 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson24 Vuex Modules/.eslintignore: -------------------------------------------------------------------------------- 1 | /build/ 2 | /config/ 3 | /dist/ 4 | /*.js 5 | /test/unit/coverage/ 6 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson24 Vuex Modules/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules/ 3 | /dist/ 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | /test/unit/coverage/ 8 | /test/e2e/reports/ 9 | selenium-debug.log 10 | 11 | # Editor directories and files 12 | .idea 13 | .vscode 14 | *.suo 15 | *.ntvs* 16 | *.njsproj 17 | *.sln 18 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson24 Vuex Modules/.postcssrc.js: -------------------------------------------------------------------------------- 1 | // https://github.com/michael-ciniawsky/postcss-load-config 2 | 3 | module.exports = { 4 | "plugins": { 5 | "postcss-import": {}, 6 | "postcss-url": {}, 7 | // to edit target browsers: use "browserslist" field in package.json 8 | "autoprefixer": {} 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson24 Vuex Modules/README.md: -------------------------------------------------------------------------------- 1 | # project1 2 | 3 | > A Vue.js project 4 | 5 | ## Build Setup 6 | 7 | ``` bash 8 | # install dependencies 9 | npm install 10 | 11 | # serve with hot reload at localhost:8080 12 | npm run dev 13 | 14 | # build for production with minification 15 | npm run build 16 | 17 | # build for production and view the bundle analyzer report 18 | npm run build --report 19 | 20 | # run unit tests 21 | npm run unit 22 | 23 | # run e2e tests 24 | npm run e2e 25 | 26 | # run all tests 27 | npm test 28 | ``` 29 | 30 | For a detailed explanation on how things work, check out the [guide](http://vuejs-templates.github.io/webpack/) and [docs for vue-loader](http://vuejs.github.io/vue-loader). 31 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson24 Vuex Modules/build/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chencl1986/Blog/60170ad67796c2f48526dae2e3078b2713b74482/Demos/Vue入门系列/lesson24 Vuex Modules/build/logo.png -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson24 Vuex Modules/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 | module.exports = { 10 | loaders: utils.cssLoaders({ 11 | sourceMap: sourceMapEnabled, 12 | extract: isProduction 13 | }), 14 | cssSourceMap: sourceMapEnabled, 15 | cacheBusting: config.dev.cacheBusting, 16 | transformToRequire: { 17 | video: ['src', 'poster'], 18 | source: 'src', 19 | img: 'src', 20 | image: 'xlink:href' 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson24 Vuex Modules/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 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson24 Vuex Modules/config/prod.env.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | module.exports = { 3 | NODE_ENV: '"production"' 4 | } 5 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson24 Vuex Modules/config/test.env.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | const merge = require('webpack-merge') 3 | const devEnv = require('./dev.env') 4 | 5 | module.exports = merge(devEnv, { 6 | NODE_ENV: '"testing"' 7 | }) 8 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson24 Vuex Modules/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | project1 7 | 8 | 9 |
10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson24 Vuex Modules/server/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "server", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "keywords": [], 10 | "author": "", 11 | "license": "ISC", 12 | "devDependencies": { 13 | "koa": "^2.6.2", 14 | "koa-router": "^7.4.0", 15 | "koa-static": "^5.0.0" 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson24 Vuex Modules/server/server.js: -------------------------------------------------------------------------------- 1 | const Koa=require('koa'); 2 | const static=require('koa-static'); 3 | 4 | let server=new Koa(); 5 | server.listen(8081); 6 | 7 | server.use(async (ctx, next)=>{ 8 | ctx.set('Access-Control-Allow-Origin', '*'); 9 | 10 | await next(); 11 | }); 12 | 13 | server.use(static('./static')); 14 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson24 Vuex Modules/server/static/user.txt: -------------------------------------------------------------------------------- 1 | [{"id":3,"name":"lee","age":18,"online":true},{"id":5,"name":"zhangsan","age":22,"online":false},{"id":11,"name":"lisi","age":25,"online":true}] -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson24 Vuex Modules/src/App.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | 12 | 13 | 16 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson24 Vuex Modules/src/components/Cmp1.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | 19 | 20 | 22 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson24 Vuex Modules/src/components/common/Table.vue: -------------------------------------------------------------------------------- 1 | 19 | 20 | 33 | 34 | 36 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson24 Vuex Modules/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 Vue from 'vue' 4 | import App from './App' 5 | import router from './router' 6 | import store from './store' 7 | 8 | Vue.config.productionTip = false 9 | 10 | //bootstrap 11 | import 'bootstrap/dist/css/bootstrap.min.css'; 12 | import 'vue2-animate/dist/vue2-animate.min.css'; 13 | 14 | 15 | 16 | /* eslint-disable no-new */ 17 | new Vue({ 18 | el: '#app', 19 | router, 20 | store, 21 | components: { App }, 22 | template: '' 23 | }) 24 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson24 Vuex Modules/src/router/index.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import Router from 'vue-router' 3 | import Index from '@/components/Index' 4 | import Index2 from '@/components/Index2' 5 | 6 | Vue.use(Router) 7 | 8 | export default new Router({ 9 | routes: [ 10 | { 11 | path: '/index', 12 | name: 'index', 13 | component: Index 14 | }, 15 | { 16 | path: '/index2', 17 | name: 'index2', 18 | component: Index2 19 | } 20 | ] 21 | }) 22 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson24 Vuex Modules/src/store/mod_a.js: -------------------------------------------------------------------------------- 1 | export default { 2 | state: { 3 | str: 'store_a' 4 | }, 5 | mutations: { 6 | 'mod_a.setStr': function (state, s){ 7 | alert('a的setStr'); 8 | state.str=s; 9 | } 10 | }, 11 | actions: { 12 | 'mod_a.setStr': function ({commit}, s){ 13 | commit('mod_a.setStr', s); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson24 Vuex Modules/src/store/mod_b.js: -------------------------------------------------------------------------------- 1 | export default { 2 | state: { 3 | str: 'store_b' 4 | }, 5 | mutations: { 6 | 'mod_b.setStr': function (state, s){ 7 | alert('b的setStr'); 8 | state.str=s; 9 | } 10 | }, 11 | actions: { 12 | 'mod_b.setStr': function ({commit}, s){ 13 | commit('mod_b.setStr', s); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson24 Vuex Modules/static/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chencl1986/Blog/60170ad67796c2f48526dae2e3078b2713b74482/Demos/Vue入门系列/lesson24 Vuex Modules/static/.gitkeep -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson24 Vuex Modules/test/e2e/specs/test.js: -------------------------------------------------------------------------------- 1 | // For authoring Nightwatch tests, see 2 | // http://nightwatchjs.org/guide#usage 3 | 4 | module.exports = { 5 | 'default e2e tests': function (browser) { 6 | // automatically uses dev Server port from /config.index.js 7 | // default: http://localhost:8080 8 | // see nightwatch.conf.js 9 | const devServer = browser.globals.devServerURL 10 | 11 | browser 12 | .url(devServer) 13 | .waitForElementVisible('#app', 5000) 14 | .assert.elementPresent('.hello') 15 | .assert.containsText('h1', 'Welcome to Your Vue.js App') 16 | .assert.elementCount('img', 1) 17 | .end() 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson24 Vuex Modules/test/unit/.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "jest": true 4 | }, 5 | "globals": { 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson24 Vuex Modules/test/unit/jest.conf.js: -------------------------------------------------------------------------------- 1 | const path = require('path') 2 | 3 | module.exports = { 4 | rootDir: path.resolve(__dirname, '../../'), 5 | moduleFileExtensions: [ 6 | 'js', 7 | 'json', 8 | 'vue' 9 | ], 10 | moduleNameMapper: { 11 | '^@/(.*)$': '/src/$1' 12 | }, 13 | transform: { 14 | '^.+\\.js$': '/node_modules/babel-jest', 15 | '.*\\.(vue)$': '/node_modules/vue-jest' 16 | }, 17 | testPathIgnorePatterns: [ 18 | '/test/e2e' 19 | ], 20 | snapshotSerializers: ['/node_modules/jest-serializer-vue'], 21 | setupFiles: ['/test/unit/setup'], 22 | mapCoverage: true, 23 | coverageDirectory: '/test/unit/coverage', 24 | collectCoverageFrom: [ 25 | 'src/**/*.{js,vue}', 26 | '!src/main.js', 27 | '!src/router/index.js', 28 | '!**/node_modules/**' 29 | ] 30 | } 31 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson24 Vuex Modules/test/unit/setup.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | 3 | Vue.config.productionTip = false 4 | -------------------------------------------------------------------------------- /Demos/Vue入门系列/lesson24 Vuex Modules/test/unit/specs/HelloWorld.spec.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import HelloWorld from '@/components/HelloWorld' 3 | 4 | describe('HelloWorld.vue', () => { 5 | it('should render correct contents', () => { 6 | const Constructor = Vue.extend(HelloWorld) 7 | const vm = new Constructor().$mount() 8 | expect(vm.$el.querySelector('.hello h1').textContent) 9 | .toEqual('Welcome to Your Vue.js App') 10 | }) 11 | }) 12 | -------------------------------------------------------------------------------- /Demos/rc-form源码解析/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # production 12 | /build 13 | 14 | # misc 15 | .DS_Store 16 | .env.local 17 | .env.development.local 18 | .env.test.local 19 | .env.production.local 20 | 21 | npm-debug.log* 22 | yarn-debug.log* 23 | yarn-error.log* 24 | 25 | *.pptx 26 | *.xlsx 27 | -------------------------------------------------------------------------------- /Demos/rc-form源码解析/config-overrides.js: -------------------------------------------------------------------------------- 1 | const {override, fixBabelImports} = require('customize-cra') 2 | 3 | module.exports = override( 4 | fixBabelImports('import', { 5 | libraryName: 'antd', 6 | libraryDirectory: 'es', 7 | style: 'css', 8 | }), 9 | ); 10 | -------------------------------------------------------------------------------- /Demos/rc-form源码解析/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chencl1986/Blog/60170ad67796c2f48526dae2e3078b2713b74482/Demos/rc-form源码解析/public/favicon.ico -------------------------------------------------------------------------------- /Demos/rc-form源码解析/public/logo192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chencl1986/Blog/60170ad67796c2f48526dae2e3078b2713b74482/Demos/rc-form源码解析/public/logo192.png -------------------------------------------------------------------------------- /Demos/rc-form源码解析/public/logo512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chencl1986/Blog/60170ad67796c2f48526dae2e3078b2713b74482/Demos/rc-form源码解析/public/logo512.png -------------------------------------------------------------------------------- /Demos/rc-form源码解析/public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "React App", 3 | "name": "Create React App Sample", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | }, 10 | { 11 | "src": "logo192.png", 12 | "type": "image/png", 13 | "sizes": "192x192" 14 | }, 15 | { 16 | "src": "logo512.png", 17 | "type": "image/png", 18 | "sizes": "512x512" 19 | } 20 | ], 21 | "start_url": ".", 22 | "display": "standalone", 23 | "theme_color": "#000000", 24 | "background_color": "#ffffff" 25 | } 26 | -------------------------------------------------------------------------------- /Demos/rc-form源码解析/public/robots.txt: -------------------------------------------------------------------------------- 1 | # https://www.robotstxt.org/robotstxt.html 2 | User-agent: * 3 | -------------------------------------------------------------------------------- /Demos/rc-form源码解析/rc-form/.editorconfig: -------------------------------------------------------------------------------- 1 | # top-most EditorConfig file 2 | root = true 3 | 4 | # Unix-style newlines with a newline ending every file 5 | [*.{js,css}] 6 | end_of_line = lf 7 | insert_final_newline = true 8 | indent_style = space 9 | indent_size = 2 10 | -------------------------------------------------------------------------------- /Demos/rc-form源码解析/rc-form/.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | *.log 3 | .idea 4 | .ipr 5 | .iws 6 | *~ 7 | ~* 8 | *.diff 9 | *.patch 10 | *.bak 11 | .DS_Store 12 | Thumbs.db 13 | .project 14 | .*proj 15 | .svn 16 | *.swp 17 | *.swo 18 | *.pyc 19 | *.pyo 20 | node_modules 21 | .cache 22 | *.css 23 | build 24 | dist 25 | lib 26 | coverage 27 | yarn.lock -------------------------------------------------------------------------------- /Demos/rc-form源码解析/rc-form/.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | 3 | sudo: false 4 | 5 | node_js: 6 | - 11 7 | 8 | script: 9 | - | 10 | if [ "$TEST_TYPE" = test ]; then 11 | npm test 12 | else 13 | npm run $TEST_TYPE 14 | fi 15 | env: 16 | matrix: 17 | - TEST_TYPE=lint 18 | - TEST_TYPE=test 19 | - TEST_TYPE=coverage 20 | -------------------------------------------------------------------------------- /Demos/rc-form源码解析/rc-form/examples/across-router.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chencl1986/Blog/60170ad67796c2f48526dae2e3078b2713b74482/Demos/rc-form源码解析/rc-form/examples/across-router.html -------------------------------------------------------------------------------- /Demos/rc-form源码解析/rc-form/examples/async-init.html: -------------------------------------------------------------------------------- 1 | placeholder -------------------------------------------------------------------------------- /Demos/rc-form源码解析/rc-form/examples/dynamic-fields.html: -------------------------------------------------------------------------------- 1 | placeholder 2 | -------------------------------------------------------------------------------- /Demos/rc-form源码解析/rc-form/examples/dynamic.html: -------------------------------------------------------------------------------- 1 | placeholder -------------------------------------------------------------------------------- /Demos/rc-form源码解析/rc-form/examples/file-input.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chencl1986/Blog/60170ad67796c2f48526dae2e3078b2713b74482/Demos/rc-form源码解析/rc-form/examples/file-input.html -------------------------------------------------------------------------------- /Demos/rc-form源码解析/rc-form/examples/getFieldDecorator.html: -------------------------------------------------------------------------------- 1 | placeholder 2 | -------------------------------------------------------------------------------- /Demos/rc-form源码解析/rc-form/examples/input-array.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chencl1986/Blog/60170ad67796c2f48526dae2e3078b2713b74482/Demos/rc-form源码解析/rc-form/examples/input-array.html -------------------------------------------------------------------------------- /Demos/rc-form源码解析/rc-form/examples/modal.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chencl1986/Blog/60170ad67796c2f48526dae2e3078b2713b74482/Demos/rc-form源码解析/rc-form/examples/modal.html -------------------------------------------------------------------------------- /Demos/rc-form源码解析/rc-form/examples/nested-field.html: -------------------------------------------------------------------------------- 1 | placeholder 2 | -------------------------------------------------------------------------------- /Demos/rc-form源码解析/rc-form/examples/normalize.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chencl1986/Blog/60170ad67796c2f48526dae2e3078b2713b74482/Demos/rc-form源码解析/rc-form/examples/normalize.html -------------------------------------------------------------------------------- /Demos/rc-form源码解析/rc-form/examples/overview.html: -------------------------------------------------------------------------------- 1 | placeholder -------------------------------------------------------------------------------- /Demos/rc-form源码解析/rc-form/examples/parallel-form.html: -------------------------------------------------------------------------------- 1 | placeholder -------------------------------------------------------------------------------- /Demos/rc-form源码解析/rc-form/examples/promise-validate.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chencl1986/Blog/60170ad67796c2f48526dae2e3078b2713b74482/Demos/rc-form源码解析/rc-form/examples/promise-validate.html -------------------------------------------------------------------------------- /Demos/rc-form源码解析/rc-form/examples/react-native/expo.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chencl1986/Blog/60170ad67796c2f48526dae2e3078b2713b74482/Demos/rc-form源码解析/rc-form/examples/react-native/expo.jpg -------------------------------------------------------------------------------- /Demos/rc-form源码解析/rc-form/examples/redux.html: -------------------------------------------------------------------------------- 1 | placeholder -------------------------------------------------------------------------------- /Demos/rc-form源码解析/rc-form/examples/server-validate.html: -------------------------------------------------------------------------------- 1 | placeholder -------------------------------------------------------------------------------- /Demos/rc-form源码解析/rc-form/examples/setFieldsValue.html: -------------------------------------------------------------------------------- 1 | placeholder -------------------------------------------------------------------------------- /Demos/rc-form源码解析/rc-form/examples/start-end-date.html: -------------------------------------------------------------------------------- 1 | placeholder -------------------------------------------------------------------------------- /Demos/rc-form源码解析/rc-form/examples/styles.js: -------------------------------------------------------------------------------- 1 | export const regionStyle = { 2 | border: '1px solid red', 3 | marginTop: 10, 4 | padding: 10, 5 | }; 6 | 7 | export const errorStyle = { 8 | color: 'red', 9 | marginTop: 10, 10 | padding: 10, 11 | }; 12 | -------------------------------------------------------------------------------- /Demos/rc-form源码解析/rc-form/examples/suggest.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chencl1986/Blog/60170ad67796c2f48526dae2e3078b2713b74482/Demos/rc-form源码解析/rc-form/examples/suggest.html -------------------------------------------------------------------------------- /Demos/rc-form源码解析/rc-form/examples/validateFirst.html: -------------------------------------------------------------------------------- 1 | placeholder -------------------------------------------------------------------------------- /Demos/rc-form源码解析/rc-form/examples/validateTrigger.html: -------------------------------------------------------------------------------- 1 | placeholder -------------------------------------------------------------------------------- /Demos/rc-form源码解析/rc-form/index.js: -------------------------------------------------------------------------------- 1 | // export this package's api 2 | import { createForm, createFormField } from './src/'; 3 | export { createForm, createFormField }; 4 | -------------------------------------------------------------------------------- /Demos/rc-form源码解析/rc-form/scripts/index.js: -------------------------------------------------------------------------------- 1 | // export this package's api 2 | import createForm from '../src/createForm'; 3 | import createDOMForm from '../src/createDOMForm'; 4 | if (typeof window !== 'undefined') { 5 | window.RCForm = { createDOMForm, createForm }; 6 | } 7 | export { createDOMForm, createForm }; 8 | -------------------------------------------------------------------------------- /Demos/rc-form源码解析/rc-form/src/createFormField.js: -------------------------------------------------------------------------------- 1 | class Field { 2 | constructor(fields) { 3 | Object.assign(this, fields); 4 | } 5 | } 6 | 7 | export function isFormField(obj) { 8 | return obj instanceof Field; 9 | } 10 | 11 | export default function createFormField(field) { 12 | if (isFormField(field)) { 13 | return field; 14 | } 15 | return new Field(field); 16 | } 17 | -------------------------------------------------------------------------------- /Demos/rc-form源码解析/rc-form/src/index.js: -------------------------------------------------------------------------------- 1 | // export this package's api 2 | import createForm from './createForm'; 3 | import createFormField from './createFormField'; 4 | import formShape from './propTypes'; 5 | 6 | export { createFormField, formShape, createForm }; 7 | -------------------------------------------------------------------------------- /Demos/rc-form源码解析/rc-form/src/propTypes.js: -------------------------------------------------------------------------------- 1 | import PropTypes from 'prop-types'; 2 | 3 | const formShape = PropTypes.shape({ 4 | getFieldsValue: PropTypes.func, 5 | getFieldValue: PropTypes.func, 6 | getFieldInstance: PropTypes.func, 7 | setFieldsValue: PropTypes.func, 8 | setFields: PropTypes.func, 9 | setFieldsInitialValue: PropTypes.func, 10 | getFieldDecorator: PropTypes.func, 11 | getFieldProps: PropTypes.func, 12 | getFieldsError: PropTypes.func, 13 | getFieldError: PropTypes.func, 14 | isFieldValidating: PropTypes.func, 15 | isFieldsValidating: PropTypes.func, 16 | isFieldsTouched: PropTypes.func, 17 | isFieldTouched: PropTypes.func, 18 | isSubmitting: PropTypes.func, 19 | submit: PropTypes.func, 20 | validateFields: PropTypes.func, 21 | resetFields: PropTypes.func, 22 | }); 23 | 24 | export default formShape; 25 | -------------------------------------------------------------------------------- /Demos/rc-form源码解析/rc-form/tests/index.js: -------------------------------------------------------------------------------- 1 | const req = require.context('.', false, /\.spec\.js$/); 2 | req.keys().forEach(req); 3 | -------------------------------------------------------------------------------- /Demos/rc-form源码解析/rc-form/tests/setup.js: -------------------------------------------------------------------------------- 1 | global.requestAnimationFrame = global.requestAnimationFrame || function requestAnimationFrame(cb) { 2 | return setTimeout(cb, 0); 3 | }; 4 | 5 | const Enzyme = require('enzyme'); 6 | const Adapter = require('enzyme-adapter-react-16'); 7 | 8 | Enzyme.configure({ adapter: new Adapter() }); 9 | -------------------------------------------------------------------------------- /Demos/rc-form源码解析/src/App.css: -------------------------------------------------------------------------------- 1 | @import '~antd/dist/antd.css'; 2 | 3 | .app { 4 | display: flex; 5 | flex-direction: column; 6 | justify-content: center; 7 | align-items: center; 8 | padding-top: 100px; 9 | text-align: center; 10 | } 11 | 12 | .app p { 13 | margin-bottom: 13px; 14 | } 15 | 16 | .app .ant-btn { 17 | margin-bottom: 20px; 18 | } 19 | -------------------------------------------------------------------------------- /Demos/rc-form源码解析/src/App.test.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import App from './App'; 4 | 5 | it('renders without crashing', () => { 6 | const div = document.createElement('div'); 7 | ReactDOM.render(, div); 8 | ReactDOM.unmountComponentAtNode(div); 9 | }); 10 | -------------------------------------------------------------------------------- /Demos/rc-form源码解析/src/components/ShowTimer.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import moment from 'moment' 3 | import createTimer, {TimerProps} from '../utils/createTimer'; 4 | 5 | // 表单字段类型 6 | export interface Props extends TimerProps { 7 | 8 | } 9 | 10 | export class State { 11 | 12 | } 13 | 14 | export class ShowTimerComponent extends React.Component { 15 | 16 | constructor(props: Props) { 17 | super(props) 18 | 19 | this.state = new State() 20 | } 21 | 22 | render() { 23 | return ( 24 |

25 | {moment(this.props.time).format('YYYY-MM-DD HH:mm:ss')} 26 |

27 | ) 28 | } 29 | 30 | } 31 | 32 | // 导出用HOC创建的新组件 33 | const ShowTimer = createTimer(ShowTimerComponent) 34 | 35 | export default ShowTimer 36 | -------------------------------------------------------------------------------- /Demos/rc-form源码解析/src/index.css: -------------------------------------------------------------------------------- 1 | body { 2 | margin: 0; 3 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 4 | 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', 5 | sans-serif; 6 | -webkit-font-smoothing: antialiased; 7 | -moz-osx-font-smoothing: grayscale; 8 | } 9 | 10 | code { 11 | font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', 12 | monospace; 13 | } 14 | -------------------------------------------------------------------------------- /Demos/rc-form源码解析/src/index.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import './index.css'; 4 | import App from './App'; 5 | import * as serviceWorker from './serviceWorker'; 6 | 7 | ReactDOM.render(, document.getElementById('root')); 8 | 9 | // If you want your app to work offline and load faster, you can change 10 | // unregister() to register() below. Note this comes with some pitfalls. 11 | // Learn more about service workers: https://bit.ly/CRA-PWA 12 | serviceWorker.unregister(); 13 | -------------------------------------------------------------------------------- /Demos/rc-form源码解析/src/react-app-env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | -------------------------------------------------------------------------------- /Demos/rc-form源码解析/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es5", 4 | "lib": [ 5 | "dom", 6 | "dom.iterable", 7 | "esnext" 8 | ], 9 | "allowJs": true, 10 | "skipLibCheck": true, 11 | "esModuleInterop": true, 12 | "allowSyntheticDefaultImports": true, 13 | "strict": true, 14 | "forceConsistentCasingInFileNames": true, 15 | "experimentalDecorators": true, 16 | "module": "esnext", 17 | "moduleResolution": "node", 18 | "resolveJsonModule": true, 19 | "isolatedModules": true, 20 | "noEmit": true, 21 | "jsx": "react" 22 | }, 23 | "include": [ 24 | "src" 25 | ] 26 | } -------------------------------------------------------------------------------- /Demos/微信小程序入门系列/lesson03/app.js: -------------------------------------------------------------------------------- 1 | //app.js 2 | App({ 3 | onLaunch: function () { 4 | 5 | }, 6 | globalData: { 7 | 8 | } 9 | }) -------------------------------------------------------------------------------- /Demos/微信小程序入门系列/lesson03/app.json: -------------------------------------------------------------------------------- 1 | { 2 | "pages": [ 3 | "pages/index/index", 4 | "pages/logs/logs", 5 | "pages/login/login" 6 | ], 7 | "window": { 8 | "backgroundTextStyle": "light", 9 | "navigationBarBackgroundColor": "#fff", 10 | "navigationBarTitleText": "WeChat", 11 | "navigationBarTextStyle": "black" 12 | } 13 | } -------------------------------------------------------------------------------- /Demos/微信小程序入门系列/lesson03/app.wxss: -------------------------------------------------------------------------------- 1 | /**app.wxss**/ 2 | .container { 3 | height: 100%; 4 | display: flex; 5 | flex-direction: column; 6 | align-items: center; 7 | justify-content: space-between; 8 | padding: 200rpx 0; 9 | box-sizing: border-box; 10 | } 11 | -------------------------------------------------------------------------------- /Demos/微信小程序入门系列/lesson03/pages/index/index.js: -------------------------------------------------------------------------------- 1 | //index.js 2 | //获取应用实例 3 | const app = getApp() 4 | 5 | Page({ 6 | data: { 7 | name: 'lee', 8 | age: 18, 9 | arr: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], 10 | judge: true, 11 | staffA: { firstName: 'Hulk', lastName: 'Hu' }, 12 | staffB: { firstName: 'Shang', lastName: 'You' }, 13 | staffC: { firstName: 'Gideon', lastName: 'Lin' }, 14 | options: [{ id: 'male', value: 'male', name: '男' }, { id: 'female', value: 'female', name: '女' }], 15 | pickerSelected: 3 16 | }, 17 | onTap() { 18 | this.setData({ 19 | judge: !this.data.judge 20 | }) 21 | }, 22 | onPickerChange(event) { 23 | this.setData({ 24 | pickerSelected: event.detail.value 25 | }) 26 | }, 27 | }) 28 | -------------------------------------------------------------------------------- /Demos/微信小程序入门系列/lesson03/pages/index/index.json: -------------------------------------------------------------------------------- 1 | { 2 | "usingComponents": {} 3 | } -------------------------------------------------------------------------------- /Demos/微信小程序入门系列/lesson03/pages/index/index.wxss: -------------------------------------------------------------------------------- 1 | /**index.wxss**/ 2 | -------------------------------------------------------------------------------- /Demos/微信小程序入门系列/lesson03/pages/login/login.json: -------------------------------------------------------------------------------- 1 | { 2 | "usingComponents": {} 3 | } -------------------------------------------------------------------------------- /Demos/微信小程序入门系列/lesson03/pages/login/login.wxml: -------------------------------------------------------------------------------- 1 | 2 | pages/login/login.wxml 3 | -------------------------------------------------------------------------------- /Demos/微信小程序入门系列/lesson03/pages/login/login.wxss: -------------------------------------------------------------------------------- 1 | /* pages/login/login.wxss */ -------------------------------------------------------------------------------- /Demos/微信小程序入门系列/lesson03/pages/logs/logs.js: -------------------------------------------------------------------------------- 1 | //logs.js 2 | const util = require('../../utils/util.js') 3 | 4 | Page({ 5 | data: { 6 | logs: [] 7 | }, 8 | onLoad: function () { 9 | this.setData({ 10 | logs: (wx.getStorageSync('logs') || []).map(log => { 11 | return util.formatTime(new Date(log)) 12 | }) 13 | }) 14 | } 15 | }) 16 | -------------------------------------------------------------------------------- /Demos/微信小程序入门系列/lesson03/pages/logs/logs.json: -------------------------------------------------------------------------------- 1 | { 2 | "navigationBarTitleText": "查看启动日志", 3 | "usingComponents": {} 4 | } -------------------------------------------------------------------------------- /Demos/微信小程序入门系列/lesson03/pages/logs/logs.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | {{index + 1}}. {{log}} 5 | 6 | 7 | -------------------------------------------------------------------------------- /Demos/微信小程序入门系列/lesson03/pages/logs/logs.wxss: -------------------------------------------------------------------------------- 1 | .log-list { 2 | display: flex; 3 | flex-direction: column; 4 | padding: 40rpx; 5 | } 6 | .log-item { 7 | margin: 10rpx; 8 | } 9 | -------------------------------------------------------------------------------- /Demos/微信小程序入门系列/lesson03/project.config.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "项目配置文件", 3 | "packOptions": { 4 | "ignore": [] 5 | }, 6 | "setting": { 7 | "urlCheck": true, 8 | "es6": true, 9 | "postcss": true, 10 | "minified": true, 11 | "newFeature": true, 12 | "autoAudits": false 13 | }, 14 | "compileType": "miniprogram", 15 | "libVersion": "2.5.0", 16 | "appid": "wxb8ab9f7edfd76f4d", 17 | "projectname": "lesson03", 18 | "debugOptions": { 19 | "hidedInDevtools": [] 20 | }, 21 | "isGameTourist": false, 22 | "condition": { 23 | "search": { 24 | "current": -1, 25 | "list": [] 26 | }, 27 | "conversation": { 28 | "current": -1, 29 | "list": [] 30 | }, 31 | "game": { 32 | "currentL": -1, 33 | "list": [] 34 | }, 35 | "miniprogram": { 36 | "current": -1, 37 | "list": [] 38 | } 39 | } 40 | } -------------------------------------------------------------------------------- /Demos/微信小程序入门系列/lesson03/utils/util.js: -------------------------------------------------------------------------------- 1 | const formatTime = date => { 2 | const year = date.getFullYear() 3 | const month = date.getMonth() + 1 4 | const day = date.getDate() 5 | const hour = date.getHours() 6 | const minute = date.getMinutes() 7 | const second = date.getSeconds() 8 | 9 | return [year, month, day].map(formatNumber).join('/') + ' ' + [hour, minute, second].map(formatNumber).join(':') 10 | } 11 | 12 | const formatNumber = n => { 13 | n = n.toString() 14 | return n[1] ? n : '0' + n 15 | } 16 | 17 | module.exports = { 18 | formatTime: formatTime 19 | } 20 | -------------------------------------------------------------------------------- /Demos/微信小程序入门系列/lesson04/app.json: -------------------------------------------------------------------------------- 1 | { 2 | "pages":[ 3 | "pages/index/index", 4 | "pages/logs/logs" 5 | ], 6 | "window":{ 7 | "backgroundTextStyle":"light", 8 | "navigationBarBackgroundColor": "#fff", 9 | "navigationBarTitleText": "WeChat", 10 | "navigationBarTextStyle":"black" 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Demos/微信小程序入门系列/lesson04/app.wxss: -------------------------------------------------------------------------------- 1 | /**app.wxss**/ 2 | .container { 3 | height: 100%; 4 | display: flex; 5 | flex-direction: column; 6 | align-items: center; 7 | justify-content: space-between; 8 | padding: 200rpx 0; 9 | box-sizing: border-box; 10 | } 11 | -------------------------------------------------------------------------------- /Demos/微信小程序入门系列/lesson04/images/google.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chencl1986/Blog/60170ad67796c2f48526dae2e3078b2713b74482/Demos/微信小程序入门系列/lesson04/images/google.png -------------------------------------------------------------------------------- /Demos/微信小程序入门系列/lesson04/pages/index/index.json: -------------------------------------------------------------------------------- 1 | { 2 | "usingComponents": {} 3 | } -------------------------------------------------------------------------------- /Demos/微信小程序入门系列/lesson04/pages/index/index.wxss: -------------------------------------------------------------------------------- 1 | /**index.wxss**/ 2 | .userinfo { 3 | display: flex; 4 | flex-direction: column; 5 | align-items: center; 6 | } 7 | 8 | .userinfo-avatar { 9 | width: 128rpx; 10 | height: 128rpx; 11 | margin: 20rpx; 12 | border-radius: 50%; 13 | } 14 | 15 | .userinfo-nickname { 16 | color: #aaa; 17 | } 18 | 19 | .usermotto { 20 | margin-top: 200px; 21 | } -------------------------------------------------------------------------------- /Demos/微信小程序入门系列/lesson04/pages/logs/logs.js: -------------------------------------------------------------------------------- 1 | //logs.js 2 | const util = require('../../utils/util.js') 3 | 4 | Page({ 5 | data: { 6 | logs: [] 7 | }, 8 | onLoad: function () { 9 | this.setData({ 10 | logs: (wx.getStorageSync('logs') || []).map(log => { 11 | return util.formatTime(new Date(log)) 12 | }) 13 | }) 14 | } 15 | }) 16 | -------------------------------------------------------------------------------- /Demos/微信小程序入门系列/lesson04/pages/logs/logs.json: -------------------------------------------------------------------------------- 1 | { 2 | "navigationBarTitleText": "查看启动日志", 3 | "usingComponents": {} 4 | } -------------------------------------------------------------------------------- /Demos/微信小程序入门系列/lesson04/pages/logs/logs.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | {{index + 1}}. {{log}} 5 | 6 | 7 | -------------------------------------------------------------------------------- /Demos/微信小程序入门系列/lesson04/pages/logs/logs.wxss: -------------------------------------------------------------------------------- 1 | .log-list { 2 | display: flex; 3 | flex-direction: column; 4 | padding: 40rpx; 5 | } 6 | .log-item { 7 | margin: 10rpx; 8 | } 9 | -------------------------------------------------------------------------------- /Demos/微信小程序入门系列/lesson04/project.config.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "项目配置文件", 3 | "packOptions": { 4 | "ignore": [] 5 | }, 6 | "setting": { 7 | "urlCheck": false, 8 | "es6": true, 9 | "postcss": true, 10 | "minified": true, 11 | "newFeature": true, 12 | "autoAudits": false 13 | }, 14 | "compileType": "miniprogram", 15 | "libVersion": "2.5.0", 16 | "appid": "wxb8ab9f7edfd76f4d", 17 | "projectname": "lesson04", 18 | "debugOptions": { 19 | "hidedInDevtools": [] 20 | }, 21 | "isGameTourist": false, 22 | "condition": { 23 | "search": { 24 | "current": -1, 25 | "list": [] 26 | }, 27 | "conversation": { 28 | "current": -1, 29 | "list": [] 30 | }, 31 | "game": { 32 | "currentL": -1, 33 | "list": [] 34 | }, 35 | "miniprogram": { 36 | "current": -1, 37 | "list": [] 38 | } 39 | } 40 | } -------------------------------------------------------------------------------- /Demos/微信小程序入门系列/lesson04/utils/toast.js: -------------------------------------------------------------------------------- 1 | module.exports = function(title) { 2 | wx.showToast({ 3 | title, 4 | icon: 'none', 5 | duration: 3000 6 | }) 7 | } -------------------------------------------------------------------------------- /Demos/微信小程序入门系列/lesson04/utils/util.js: -------------------------------------------------------------------------------- 1 | const formatTime = date => { 2 | const year = date.getFullYear() 3 | const month = date.getMonth() + 1 4 | const day = date.getDate() 5 | const hour = date.getHours() 6 | const minute = date.getMinutes() 7 | const second = date.getSeconds() 8 | 9 | return [year, month, day].map(formatNumber).join('/') + ' ' + [hour, minute, second].map(formatNumber).join(':') 10 | } 11 | 12 | const formatNumber = n => { 13 | n = n.toString() 14 | return n[1] ? n : '0' + n 15 | } 16 | 17 | module.exports = { 18 | formatTime: formatTime 19 | } 20 | -------------------------------------------------------------------------------- /Demos/零碎的记录/解决火狐新窗口打开网页被拦截问题/prevented.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chencl1986/Blog/60170ad67796c2f48526dae2e3078b2713b74482/Demos/零碎的记录/解决火狐新窗口打开网页被拦截问题/prevented.png -------------------------------------------------------------------------------- /Images/rc-form源码解读/Demo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chencl1986/Blog/60170ad67796c2f48526dae2e3078b2713b74482/Images/rc-form源码解读/Demo.png -------------------------------------------------------------------------------- /Images/rc-form源码解读/form-demo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chencl1986/Blog/60170ad67796c2f48526dae2e3078b2713b74482/Images/rc-form源码解读/form-demo.png -------------------------------------------------------------------------------- /Images/rc-form源码解读/rc-form实现思路.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chencl1986/Blog/60170ad67796c2f48526dae2e3078b2713b74482/Images/rc-form源码解读/rc-form实现思路.png -------------------------------------------------------------------------------- /Images/rc-form源码解读/rc-form实现思路.xmind: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chencl1986/Blog/60170ad67796c2f48526dae2e3078b2713b74482/Images/rc-form源码解读/rc-form实现思路.xmind -------------------------------------------------------------------------------- /Images/rc-form源码解读/时间弹窗.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chencl1986/Blog/60170ad67796c2f48526dae2e3078b2713b74482/Images/rc-form源码解读/时间弹窗.png -------------------------------------------------------------------------------- /Images/如何成为有效学习的高手/如何成为有效学习的高手.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chencl1986/Blog/60170ad67796c2f48526dae2e3078b2713b74482/Images/如何成为有效学习的高手/如何成为有效学习的高手.png -------------------------------------------------------------------------------- /Images/如何成为有效学习的高手/如何成为有效学习的高手.xmind: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chencl1986/Blog/60170ad67796c2f48526dae2e3078b2713b74482/Images/如何成为有效学习的高手/如何成为有效学习的高手.xmind -------------------------------------------------------------------------------- /Images/得到邀请_20191001155932.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chencl1986/Blog/60170ad67796c2f48526dae2e3078b2713b74482/Images/得到邀请_20191001155932.png -------------------------------------------------------------------------------- /Images/得到邀请_20191001155932_444x658.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chencl1986/Blog/60170ad67796c2f48526dae2e3078b2713b74482/Images/得到邀请_20191001155932_444x658.png -------------------------------------------------------------------------------- /Images/得到邀请_20191001155932_50X50.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chencl1986/Blog/60170ad67796c2f48526dae2e3078b2713b74482/Images/得到邀请_20191001155932_50X50.png -------------------------------------------------------------------------------- /Images/得到邀请_20191001155932_tiny压缩.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chencl1986/Blog/60170ad67796c2f48526dae2e3078b2713b74482/Images/得到邀请_20191001155932_tiny压缩.png -------------------------------------------------------------------------------- /Images/怎样成为快速阅读的高手/怎样成为快速阅读的高手.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chencl1986/Blog/60170ad67796c2f48526dae2e3078b2713b74482/Images/怎样成为快速阅读的高手/怎样成为快速阅读的高手.png -------------------------------------------------------------------------------- /Images/怎样成为快速阅读的高手/怎样成为快速阅读的高手.xmind: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chencl1986/Blog/60170ad67796c2f48526dae2e3078b2713b74482/Images/怎样成为快速阅读的高手/怎样成为快速阅读的高手.xmind --------------------------------------------------------------------------------