├── favicon.ico
├── day15-webpack
├── src
│ ├── less
│ │ ├── public.less
│ │ ├── main.less
│ │ └── iconfont.css
│ ├── js
│ │ ├── add.js
│ │ └── index.js
│ ├── img
│ │ ├── 01.jpg
│ │ └── 02.jpg
│ ├── font
│ │ ├── iconfont.ttf
│ │ ├── iconfont.woff
│ │ └── iconfont.woff2
│ └── index.html
├── build
│ ├── images
│ │ ├── 12b0a7ae.jpg
│ │ ├── b404c345.ttf
│ │ ├── 980ac82b.woff2
│ │ └── d09e5dd4.woff
│ ├── css
│ │ └── main.8023cccd.css
│ └── index.html
├── .eslintrc.js
└── package.json
├── day14-gulp
├── 02.gulp
│ ├── src
│ │ ├── less
│ │ │ ├── public.less
│ │ │ └── main.less
│ │ ├── js
│ │ │ ├── add.js
│ │ │ └── index.js
│ │ └── index.html
│ ├── build
│ │ ├── css
│ │ │ └── all.min.css
│ │ └── index.html
│ ├── dist
│ │ ├── css
│ │ │ └── all.css
│ │ ├── js
│ │ │ ├── add.js
│ │ │ └── index.js
│ │ └── index.html
│ └── package.json
└── 01.module
│ ├── 02.commonJS
│ ├── js
│ │ ├── add.js
│ │ ├── mins.js
│ │ ├── index.js
│ │ └── build.js
│ └── index.html
│ ├── 03.ES6模块化
│ ├── js
│ │ ├── add.js
│ │ ├── say.js
│ │ ├── utils.js
│ │ └── index.js
│ ├── index.html
│ └── build
│ │ ├── add.js
│ │ ├── say.js
│ │ └── utils.js
│ └── 01.没有模块化的时候
│ └── index.js
├── .gitignore
├── day13-登录注册
├── 04.强制缓存
│ ├── 01.jpg
│ ├── index.html
│ └── server.js
├── 02.登录注册cookie权限控制
│ ├── public
│ │ ├── img
│ │ │ ├── index.jpg
│ │ │ └── logo.png
│ │ └── css
│ │ │ ├── index.css
│ │ │ ├── login.css
│ │ │ └── register.css
│ ├── db
│ │ └── index.js
│ ├── models
│ │ └── userModel.js
│ ├── views
│ │ ├── index.html
│ │ └── center.html
│ ├── routers
│ │ ├── regRouter.js
│ │ ├── centerRouter.js
│ │ └── registerRouter.js
│ └── index.js
├── 03.登录注册session权限控制
│ ├── public
│ │ ├── img
│ │ │ ├── logo.png
│ │ │ └── index.jpg
│ │ └── css
│ │ │ ├── index.css
│ │ │ ├── login.css
│ │ │ └── register.css
│ ├── db
│ │ └── index.js
│ ├── routers
│ │ ├── centerRouter.js
│ │ ├── regRouter.js
│ │ ├── loginRouter.js
│ │ └── registerRouter.js
│ ├── models
│ │ └── userModel.js
│ └── views
│ │ ├── index.html
│ │ └── center.html
├── 01.storage
│ ├── 01.webStorage.js
│ ├── 02.localStoraged的使用.html
│ └── 03.sessionStoraged的使用.html
├── 05.协商缓存
│ ├── index.html
│ ├── 协商缓存过程.js
│ └── server.js
├── 03.session.js
└── 06.压缩
│ └── server.js
├── day12-登录注册
├── project
│ ├── img
│ │ ├── index.jpg
│ │ └── logo.png
│ ├── html
│ │ ├── center.html
│ │ ├── index.html
│ │ ├── login.html
│ │ └── register.html
│ └── css
│ │ ├── index.css
│ │ ├── login.css
│ │ └── register.css
├── 02.接口书写
│ ├── public
│ │ ├── img
│ │ │ ├── index.jpg
│ │ │ └── logo.png
│ │ └── css
│ │ │ ├── index.css
│ │ │ ├── login.css
│ │ │ └── register.css
│ ├── db
│ │ └── index.js
│ ├── models
│ │ └── userModel.js
│ └── views
│ │ ├── center.html
│ │ └── index.html
├── 03.路由管理
│ ├── public
│ │ ├── img
│ │ │ ├── index.jpg
│ │ │ └── logo.png
│ │ └── css
│ │ │ ├── index.css
│ │ │ ├── login.css
│ │ │ └── register.css
│ ├── db
│ │ └── index.js
│ ├── models
│ │ └── userModel.js
│ ├── views
│ │ ├── center.html
│ │ └── index.html
│ ├── routers
│ │ ├── regRouter.js
│ │ ├── loginRouter.js
│ │ └── registerRouter.js
│ └── index.js
├── 01.登录注册模块划分
│ ├── public
│ │ ├── img
│ │ │ ├── logo.png
│ │ │ └── index.jpg
│ │ └── css
│ │ │ ├── index.css
│ │ │ ├── login.css
│ │ │ └── register.css
│ ├── index.js
│ └── views
│ │ ├── center.html
│ │ ├── index.html
│ │ ├── login.html
│ │ └── register.html
└── 04.cookie.js
├── day05-promise
├── 晨测.md
├── 01.js
├── nodejs
│ ├── 01.我的第一个nodejs.js
│ └── 02.Global.js
├── 01.html
├── 10.动态import.html
├── 06.async和await.html
├── 05.resolve和reject方法.html
└── 07.async和await的返回值.html
├── day08-http课程
├── 晨测.md
├── 14.url地址输入到浏览器渲染的流程.js
├── 01.什么是http.js
├── 13.浏览器渲染流程.js
├── 05.MIME类型.js
├── 07.请求方式.js
├── 11.四次挥手.js
├── 10.三次握手.js
├── 09.OSI网络模型.js
├── 03.post请求.html
├── 08.状态码.js
├── 06.MIME类型服务器.js
└── 04.响应报文.js
├── 复习
├── 05.函数柯里化.js
├── 03.展开运算符.js
├── 04.阻止默认事件.html
├── 01.this指向.js
└── 02.绑定事件.html
├── readme.md
├── day06-node01
├── 05.nodejs模块化
│ ├── mins.js
│ ├── add.js
│ └── index.js
├── 02.微任务和宏任务.js
├── 04.node的函数.js
└── 01.nodeJS轮询机制.js
├── day10-ajax
└── 01.express
│ └── test.html
├── day09-MongoDB
├── 09.mongoose模块化
│ ├── db
│ │ └── index.js
│ ├── index.js
│ └── model
│ │ └── studentModel.js
├── 02.连接数据库.js
├── 03.创建约束对象.js
├── 08.mongoose的删除.js
├── 07.mongoose的改.js
├── 04.初始化文档内容.js
└── 06.mongoose的查.js
├── day07-node核心模块
├── 03.path
│ └── index.js
├── 06.fs
│ ├── 07.简单读取文件.js
│ ├── 01.同步写入.js
│ ├── 06.简单写入.js
│ ├── 09.流式读取.js
│ ├── 05.promisify解决异步回调.js
│ ├── 11.pipe简单流式读写.js
│ ├── 10.流式读写.js
│ ├── 08.流式写入.js
│ ├── 02.异步写入.js
│ ├── 03.异步写入解决回调地狱.js
│ └── 04.异步写入解决回调地狱封装.js
├── 05.crypto
│ └── index.js
├── 04.Events
│ └── index.js
├── 07.http
│ ├── 02.作为客户端.js
│ └── 01.服务器搭建.js
├── 01.Buffer
│ └── index.js
└── 02.process
│ └── index.js
├── npm命令.md
├── day01-ES5+
├── 15.flat.html
├── 17.copyWithin.html
├── 16.fill.html
├── 05.Object.create创建对象 copy.html
├── 01.严格模式.html
├── 11.filter方法.html
├── 数组练习
│ ├── 03.求数组最大最小值.html
│ ├── 05.击鼓传花.html
│ ├── 01.手写reverse.html
│ └── 03.任意进制转换.html
├── 04.json.html
├── 03.json案例.json
├── 13.reduce.html
├── 08.存取器属性.html
├── 09.forEach和map.html
├── 06.Object.create创建对象属性.html
└── 10.some和every.html
├── day03-ES6+
├── 01.属性名表达式.html
├── 12.回调地狱.html
├── 10.for.of.html
├── 02.Object静态方法.html
├── 08.iterator.html
├── 05.bigInt类型.html
└── 09.手写iterator.html
├── day02-ES6+
├── 12.函数参数默认值.html
├── 11.Array的静态方法.html
├── 13.函数的rest参数.html
├── 10.数组的扩展运算符.html
├── 03.for循环的let.html
├── 14.箭头函数写法.html
├── 07.模板字符串.html
├── 06.对象的解构赋值.html
├── 04.const常量.html
├── 02.let声明.html
└── 08.字符串新方法.html
├── day11-ajax
├── 06.请求拦截器
│ └── server.js
├── 03.jsonp
│ ├── server.js
│ ├── jquery的jsonp.html
│ ├── 练习.html
│ └── index.html
├── 07.取消请求
│ └── server.js
└── 04.cors跨域
│ ├── server.js
│ └── index.html
├── package.json
├── day16-promise手写
└── 01.promise构造函数.js
├── day17-react01
├── 01.我的第一个React.html
├── 02.jsx方式创建虚拟DOM.html
└── 03.纯js方式创建虚拟DOM.html
├── day18-react02
├── 01.不是函数式组件案例.html
├── 06.state状态引入.html
└── 04.class继承.html
├── day00-git
└── git练习.md
├── day21-react05
├── 脚手架.md
└── 03.getSnapshotBeforeUpdate.html
├── day20-react04
└── 01.react的event.html
└── day04-promise
├── 08.在then和catch中拿到成功和失败的值.html
├── 03.promise对象的值.html
├── 02.promise模拟请求基础写法.html
├── 07.练习.html
└── 06.then的第二个参数.html
/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nowLetsgo/goat0722/HEAD/favicon.ico
--------------------------------------------------------------------------------
/day15-webpack/src/less/public.less:
--------------------------------------------------------------------------------
1 | body {
2 | background-color: yellow;
3 | }
--------------------------------------------------------------------------------
/day14-gulp/02.gulp/src/less/public.less:
--------------------------------------------------------------------------------
1 | body {
2 | background-color: yellow;
3 | }
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | /node_modules
2 | *.mp4
3 | /day14-gulp/02.gulp/node_modules
4 | /day15-webpack/node_modules
--------------------------------------------------------------------------------
/day13-登录注册/04.强制缓存/01.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nowLetsgo/goat0722/HEAD/day13-登录注册/04.强制缓存/01.jpg
--------------------------------------------------------------------------------
/day15-webpack/src/js/add.js:
--------------------------------------------------------------------------------
1 | function add(a, b) {
2 | return a + b;
3 | }
4 |
5 | export default add;
--------------------------------------------------------------------------------
/day14-gulp/02.gulp/src/js/add.js:
--------------------------------------------------------------------------------
1 | function add(a, b) {
2 | return a + b;
3 | }
4 |
5 | export default add;
--------------------------------------------------------------------------------
/day15-webpack/src/img/01.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nowLetsgo/goat0722/HEAD/day15-webpack/src/img/01.jpg
--------------------------------------------------------------------------------
/day15-webpack/src/img/02.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nowLetsgo/goat0722/HEAD/day15-webpack/src/img/02.jpg
--------------------------------------------------------------------------------
/day12-登录注册/project/img/index.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nowLetsgo/goat0722/HEAD/day12-登录注册/project/img/index.jpg
--------------------------------------------------------------------------------
/day12-登录注册/project/img/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nowLetsgo/goat0722/HEAD/day12-登录注册/project/img/logo.png
--------------------------------------------------------------------------------
/day14-gulp/01.module/02.commonJS/js/add.js:
--------------------------------------------------------------------------------
1 | function add(a, b) {
2 | return a + b
3 | }
4 |
5 | module.exports = add;
--------------------------------------------------------------------------------
/day14-gulp/01.module/02.commonJS/js/mins.js:
--------------------------------------------------------------------------------
1 | function mins(a, b) {
2 | return a - b;
3 | }
4 | module.exports = mins;
--------------------------------------------------------------------------------
/day14-gulp/02.gulp/build/css/all.min.css:
--------------------------------------------------------------------------------
1 | #outer{width:300px;height:300px;background-color:pink}body{background-color:#ff0}
--------------------------------------------------------------------------------
/day14-gulp/02.gulp/src/less/main.less:
--------------------------------------------------------------------------------
1 | #outer {
2 | width: 300px;
3 | height: 300px;
4 | background-color: pink;
5 | }
--------------------------------------------------------------------------------
/day15-webpack/src/font/iconfont.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nowLetsgo/goat0722/HEAD/day15-webpack/src/font/iconfont.ttf
--------------------------------------------------------------------------------
/day15-webpack/src/font/iconfont.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nowLetsgo/goat0722/HEAD/day15-webpack/src/font/iconfont.woff
--------------------------------------------------------------------------------
/day15-webpack/src/font/iconfont.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nowLetsgo/goat0722/HEAD/day15-webpack/src/font/iconfont.woff2
--------------------------------------------------------------------------------
/day12-登录注册/02.接口书写/public/img/index.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nowLetsgo/goat0722/HEAD/day12-登录注册/02.接口书写/public/img/index.jpg
--------------------------------------------------------------------------------
/day12-登录注册/02.接口书写/public/img/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nowLetsgo/goat0722/HEAD/day12-登录注册/02.接口书写/public/img/logo.png
--------------------------------------------------------------------------------
/day12-登录注册/03.路由管理/public/img/index.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nowLetsgo/goat0722/HEAD/day12-登录注册/03.路由管理/public/img/index.jpg
--------------------------------------------------------------------------------
/day12-登录注册/03.路由管理/public/img/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nowLetsgo/goat0722/HEAD/day12-登录注册/03.路由管理/public/img/logo.png
--------------------------------------------------------------------------------
/day14-gulp/02.gulp/src/js/index.js:
--------------------------------------------------------------------------------
1 | import add from "./add";
2 |
3 | console.log("add", add(1, 1));
4 |
5 | console.log(1 === 2);
--------------------------------------------------------------------------------
/day15-webpack/build/images/12b0a7ae.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nowLetsgo/goat0722/HEAD/day15-webpack/build/images/12b0a7ae.jpg
--------------------------------------------------------------------------------
/day15-webpack/build/images/b404c345.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nowLetsgo/goat0722/HEAD/day15-webpack/build/images/b404c345.ttf
--------------------------------------------------------------------------------
/day05-promise/晨测.md:
--------------------------------------------------------------------------------
1 | ### 晨测
2 | - all allSettled race any方法解释
3 |
4 | - Promise.resolve和Promise.reject方法
5 |
6 | - async和await是什么?以及返回值
--------------------------------------------------------------------------------
/day12-登录注册/01.登录注册模块划分/public/img/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nowLetsgo/goat0722/HEAD/day12-登录注册/01.登录注册模块划分/public/img/logo.png
--------------------------------------------------------------------------------
/day15-webpack/build/images/980ac82b.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nowLetsgo/goat0722/HEAD/day15-webpack/build/images/980ac82b.woff2
--------------------------------------------------------------------------------
/day15-webpack/build/images/d09e5dd4.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nowLetsgo/goat0722/HEAD/day15-webpack/build/images/d09e5dd4.woff
--------------------------------------------------------------------------------
/day12-登录注册/01.登录注册模块划分/public/img/index.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nowLetsgo/goat0722/HEAD/day12-登录注册/01.登录注册模块划分/public/img/index.jpg
--------------------------------------------------------------------------------
/day13-登录注册/02.登录注册cookie权限控制/public/img/index.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nowLetsgo/goat0722/HEAD/day13-登录注册/02.登录注册cookie权限控制/public/img/index.jpg
--------------------------------------------------------------------------------
/day13-登录注册/02.登录注册cookie权限控制/public/img/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nowLetsgo/goat0722/HEAD/day13-登录注册/02.登录注册cookie权限控制/public/img/logo.png
--------------------------------------------------------------------------------
/day13-登录注册/03.登录注册session权限控制/public/img/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nowLetsgo/goat0722/HEAD/day13-登录注册/03.登录注册session权限控制/public/img/logo.png
--------------------------------------------------------------------------------
/day15-webpack/build/css/main.8023cccd.css:
--------------------------------------------------------------------------------
1 | #outer{background:url(../images/12b0a7ae.jpg) 50% no-repeat;height:300px;width:300px}body{background-color:#ff0}
--------------------------------------------------------------------------------
/day13-登录注册/03.登录注册session权限控制/public/img/index.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nowLetsgo/goat0722/HEAD/day13-登录注册/03.登录注册session权限控制/public/img/index.jpg
--------------------------------------------------------------------------------
/day08-http课程/晨测.md:
--------------------------------------------------------------------------------
1 | ### 晨测
2 | - 请求方式
3 |
4 | - 什么是HTTP
5 |
6 | - 状态码
7 |
8 | - 什么是三次握手:
9 |
10 | - 什么是四次挥手
11 |
12 | - 浏览器渲染流程
13 |
14 | - 浏览器输入url到渲染的过程
15 |
16 |
--------------------------------------------------------------------------------
/day14-gulp/02.gulp/dist/css/all.css:
--------------------------------------------------------------------------------
1 | #outer {
2 | width: 300px;
3 | height: 300px;
4 | background-color: pink;
5 | }
6 |
7 | body {
8 | background-color: yellow;
9 | }
10 |
--------------------------------------------------------------------------------
/day15-webpack/src/less/main.less:
--------------------------------------------------------------------------------
1 | #outer {
2 | width: 300px;
3 | height: 300px;
4 | // background-color: pink;
5 | background: url(../img/01.jpg) center center no-repeat;
6 | }
--------------------------------------------------------------------------------
/day05-promise/01.js:
--------------------------------------------------------------------------------
1 | console.log("hello 01.js");
2 | console.log("hello 01.js");
3 | console.log("hello 01.js");
4 | console.log("hello 01.js");
5 | console.log("hello 01.js");
6 | console.log("hello 01.js");
7 | console.log("hello 01.js");
--------------------------------------------------------------------------------
/复习/05.函数柯里化.js:
--------------------------------------------------------------------------------
1 | add(1)(2)(3)
2 |
3 | //add被称作为高阶函数
4 | //以下这种写法被称作为函数柯里化
5 | function add(a) {
6 | return function (b) {
7 | return function (c) {
8 | console.log(a + b + c)
9 | }
10 | }
11 | }
--------------------------------------------------------------------------------
/readme.md:
--------------------------------------------------------------------------------
1 | ## 这个是武汉0722前端课程代码
2 |
3 | #### 克隆地址
4 |
5 | - `https://gitee.com/nowletsgo/goat0722.git` gitee地址
6 | - `https://github.com/nowLetsgo/goat0722.git` github地址
7 |
8 | ### 好好学习 天天向上
9 | ### 祝你们人人20K
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/day08-http课程/14.url地址输入到浏览器渲染的流程.js:
--------------------------------------------------------------------------------
1 | /*
2 | 从输入url地址,到页面显示,经过了哪些步骤
3 | 1. DNS查询 / 解析:查询到主机地址
4 | 2. 建立连接:三次握手
5 | 3. 发送请求
6 | 4. 返回响应
7 | 5. 渲染页面
8 | 6. 断开连接:四次挥手
9 |
10 |
11 |
12 | */
--------------------------------------------------------------------------------
/day05-promise/nodejs/01.我的第一个nodejs.js:
--------------------------------------------------------------------------------
1 | console.log("hello");
2 | const a = 1;
3 | const data = {
4 | name: "laowang"
5 | }
6 |
7 | function fn() {
8 | console.log(1);
9 | }
10 | console.log(a + 4);
11 | console.log(data);
12 |
13 | fn()
--------------------------------------------------------------------------------
/day14-gulp/01.module/03.ES6模块化/js/add.js:
--------------------------------------------------------------------------------
1 | /*
2 | 默认暴露:
3 | - 当前模块只需要暴露一个功能,则可以选用默认暴露
4 | - 默认暴露在当前模块中只能暴露一个功能
5 | - 使用 export default XXX;
6 |
7 | */
8 |
9 | function add(a, b) {
10 | return a + b;
11 | }
12 |
13 | export default add;
--------------------------------------------------------------------------------
/day15-webpack/src/js/index.js:
--------------------------------------------------------------------------------
1 | import add from "./add";
2 | import '../less/main.less'
3 | import '../less/public.less'
4 | import '../less/iconfont.css'
5 |
6 | console.log("add", add(1, 1));
7 |
8 | console.log(1 === 2);
9 |
10 | const a = 1;
11 | console.log(a);
--------------------------------------------------------------------------------
/day14-gulp/02.gulp/dist/js/add.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 |
3 | Object.defineProperty(exports, "__esModule", {
4 | value: true
5 | });
6 | exports["default"] = void 0;
7 |
8 | function add(a, b) {
9 | return a + b;
10 | }
11 |
12 | var _default = add;
13 | exports["default"] = _default;
--------------------------------------------------------------------------------
/day14-gulp/02.gulp/dist/js/index.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 |
3 | var _add = _interopRequireDefault(require("./add"));
4 |
5 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
6 |
7 | console.log("add", (0, _add["default"])(1, 1));
8 | console.log(1 === 2);
--------------------------------------------------------------------------------
/day06-node01/05.nodejs模块化/mins.js:
--------------------------------------------------------------------------------
1 | function mins(a, b) {
2 | return a - b;
3 | }
4 |
5 | function say(con) {
6 | console.log("hello" + con);
7 | }
8 |
9 | //暴露多个内容1
10 | /* module.exports.mins = mins;
11 | module.exports.say = say; */
12 |
13 | //暴露多个内容2
14 | module.exports = {
15 | mins,
16 | say
17 | }
--------------------------------------------------------------------------------
/day13-登录注册/01.storage/01.webStorage.js:
--------------------------------------------------------------------------------
1 | /*
2 | Web Storage(本地存储):
3 | - 是H5的新特性之一,主要用来做本地存储,解决了cookie在存储的时候一定会发送给服务端的问题
4 | - 本地存储分为两种:localStorage(永久存储) sessionStorage(临时存储)
5 |
6 | - 特点:
7 | - 空间大小是5MB
8 | - 不会随着http发送
9 | - 操作非常简单
10 | - 低版本IE不兼容
11 |
12 |
13 | */
--------------------------------------------------------------------------------
/day14-gulp/02.gulp/build/index.html:
--------------------------------------------------------------------------------
1 |
Documenthello
--------------------------------------------------------------------------------
/day12-登录注册/02.接口书写/db/index.js:
--------------------------------------------------------------------------------
1 | const mongoose = require("mongoose");
2 | //连接数据库
3 | mongoose.connect("mongodb://127.0.0.1:27017/goat0722");
4 |
5 | //当数据库连接成功会触发mongoose.connection对象的open事件
6 | mongoose.connection.once("open", err => {
7 | if (err) {
8 | console.log("数据库连接失败", err);
9 | return;
10 | }
11 | console.log("数据库连接成功");
12 | })
--------------------------------------------------------------------------------
/day12-登录注册/03.路由管理/db/index.js:
--------------------------------------------------------------------------------
1 | const mongoose = require("mongoose");
2 | //连接数据库
3 | mongoose.connect("mongodb://127.0.0.1:27017/goat0722");
4 |
5 | //当数据库连接成功会触发mongoose.connection对象的open事件
6 | mongoose.connection.once("open", err => {
7 | if (err) {
8 | console.log("数据库连接失败", err);
9 | return;
10 | }
11 | console.log("数据库连接成功");
12 | })
--------------------------------------------------------------------------------
/day08-http课程/01.什么是http.js:
--------------------------------------------------------------------------------
1 | /*
2 | HTTP协议:
3 | - 协议是指计算机通信网络中两台计算机之间进行通信所必须共同遵守的规定或规则。
4 |
5 | - http(超文本传输协议),是用于从万维网服务器传输超文本到本地浏览器的传送协议。是互联网上应用最为广泛的一种网络协议。所有的 WWW 文件都必须遵守这个标准。
6 |
7 | - 客户端与服务端通信时传输的内容我们称之为报文。
8 |
9 | - HTTP就是一个通信规则,这个规则规定了客户端发送给服务器的报文格式,也规定了服务器发送给客户端的报文格式。客户端发送给服务器的称为“请求报文”,服务器发送给客户端的称为“响应报文”。
10 |
11 |
12 | */
--------------------------------------------------------------------------------
/day08-http课程/13.浏览器渲染流程.js:
--------------------------------------------------------------------------------
1 | /*
2 | 浏览器渲染流程
3 | - 构建DOM树,并下载其他资源
4 | - 构造样式树CSSOM,并将css转为标准样式
5 | - 根据DOM树和CSSOM树,构建渲染树(render Tree),主线程会计算出每个元素的位置信息以及盒子大小
6 | - 分层:渲染引擎主线程还需要为特定的阶段生成专用的图层,并生成一颗对应的图层树
7 | - 生成图层绘制指令:将每个图层的绘制拆分成多个绘制指令,传给合成线程
8 | - 栅格化:合成线程会将图层划分为图块
9 | - 合成和显示:将页面内容绘制到内存中,最后再将内存显示在屏幕上
10 |
11 | */
--------------------------------------------------------------------------------
/day10-ajax/01.express/test.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | Document
9 |
10 |
11 |
12 | 老哥 你真棒
13 |
14 |
15 |
--------------------------------------------------------------------------------
/day09-MongoDB/09.mongoose模块化/db/index.js:
--------------------------------------------------------------------------------
1 | const mongoose = require("mongoose");
2 | //连接数据库
3 | mongoose.connect("mongodb://127.0.0.1:27017/class0722");
4 |
5 | //当数据库连接成功会触发mongoose.connection对象的open事件
6 | mongoose.connection.once("open", err => {
7 | if (err) {
8 | console.log("数据库连接失败", err);
9 | return;
10 | }
11 | console.log("数据库连接成功");
12 | })
--------------------------------------------------------------------------------
/day13-登录注册/02.登录注册cookie权限控制/db/index.js:
--------------------------------------------------------------------------------
1 | const mongoose = require("mongoose");
2 | //连接数据库
3 | mongoose.connect("mongodb://127.0.0.1:27017/goat0722");
4 |
5 | //当数据库连接成功会触发mongoose.connection对象的open事件
6 | mongoose.connection.once("open", err => {
7 | if (err) {
8 | console.log("数据库连接失败", err);
9 | return;
10 | }
11 | console.log("数据库连接成功");
12 | })
--------------------------------------------------------------------------------
/day13-登录注册/03.登录注册session权限控制/db/index.js:
--------------------------------------------------------------------------------
1 | const mongoose = require("mongoose");
2 | //连接数据库
3 | mongoose.connect("mongodb://127.0.0.1:27017/goat0722");
4 |
5 | //当数据库连接成功会触发mongoose.connection对象的open事件
6 | mongoose.connection.once("open", err => {
7 | if (err) {
8 | console.log("数据库连接失败", err);
9 | return;
10 | }
11 | console.log("数据库连接成功");
12 | })
--------------------------------------------------------------------------------
/复习/03.展开运算符.js:
--------------------------------------------------------------------------------
1 | const arr = [1, 2, 3, 4, 5];
2 | const obj = {
3 | name: "laowang",
4 | pass: 123
5 | }
6 |
7 | console.log(...arr); // 1 2 3 4 5
8 | // console.log(...obj);
9 | console.log(...Object.entries(obj));
10 | console.log(...Object.keys(obj));
11 | console.log(...Object.values(obj));
12 |
13 | console.log({
14 | ...obj,
15 | hobby: "laowang"
16 | });
--------------------------------------------------------------------------------
/day07-node核心模块/03.path/index.js:
--------------------------------------------------------------------------------
1 | /*
2 | path:
3 | - 关于路径的操作
4 | - path.resolve(,,,):将多个路径拼成一个一个绝对路径
5 |
6 | */
7 | const path = require("path");
8 |
9 | // const filePath1 = path.resolve("../02.process/01.txt");
10 | // const filePath1 = path.resolve("../", "hello", "01.txt");
11 | const filePath1 = path.resolve(__dirname, "01.txt")
12 | console.log(filePath1);
--------------------------------------------------------------------------------
/day08-http课程/05.MIME类型.js:
--------------------------------------------------------------------------------
1 | /*
2 | MIME类型:
3 | text/plain:文本
4 | text/css:css文件
5 | text/html:html文件
6 | application/javascript:js文件
7 | application/x-www-form-urlEncoded:表单类型(user=laowang&pass=123)
8 |
9 | image/gif
10 | image/jpg
11 | image/png
12 |
13 | audio/mp3
14 | video/mp4
15 |
16 | */
--------------------------------------------------------------------------------
/day07-node核心模块/06.fs/07.简单读取文件.js:
--------------------------------------------------------------------------------
1 | const fs = require("fs");
2 | const path = require("path");
3 |
4 | const filePath = path.resolve(__dirname, "01.txt");
5 |
6 | fs.readFile(filePath, (err, data) => {
7 | if (err) {
8 | console.log("读取失败", err);
9 | return;
10 | }
11 |
12 | //回调函数的第二个参数data就是读取的内容
13 | console.log(data);
14 | console.log(data.toString());
15 | })
--------------------------------------------------------------------------------
/day07-node核心模块/06.fs/01.同步写入.js:
--------------------------------------------------------------------------------
1 | const fs = require("fs");
2 | const path = require("path");
3 |
4 | //获取被操作文件的路径
5 | const filePath = path.resolve(__dirname, "01.txt");
6 |
7 | //同步打开文件(同步的意思就是,线程会等到这个文件的打开才向下继续执行)
8 | //返回的就是这个文件的id
9 | const fd = fs.openSync(filePath, "a");
10 | console.log(fd);
11 |
12 | //同步写入
13 | fs.writeSync(fd, "锄禾日当午");
14 |
15 | //同步关闭
16 | fs.closeSync(fd);
17 |
18 |
19 |
--------------------------------------------------------------------------------
/day07-node核心模块/06.fs/06.简单写入.js:
--------------------------------------------------------------------------------
1 | const fs = require("fs");
2 | const path = require("path");
3 |
4 | const filePath = path.resolve(__dirname, "01.txt");
5 |
6 | //简单写入(参数1:文件路径 参数2:写入内容 参数3:配置对象 参数4:回调函数)
7 | fs.writeFile(filePath, "hhhh~", {
8 | flag: "a"
9 | }, err => {
10 | if (err) {
11 | console.log("err", err);
12 | return;
13 | }
14 | console.log("文件写入成功");
15 | })
--------------------------------------------------------------------------------
/day14-gulp/01.module/02.commonJS/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | Document
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/复习/04.阻止默认事件.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | Document
9 |
10 |
11 |
12 | 百度十下 你也不知道
13 |
14 |
15 |
--------------------------------------------------------------------------------
/day14-gulp/01.module/02.commonJS/js/index.js:
--------------------------------------------------------------------------------
1 | /*
2 | - 浏览器是不支持CommonJS规范的
3 | - 需要使用browserify来进行转换为浏览器识别的js代码
4 | - 需要安装browserify工具 npm i -g browserify
5 | - 使用browserify把当前CommonJS规范的入口文件进行编译为浏览器可识别的语法即可
6 | - browserify index.js -o build.js
7 |
8 |
9 | */
10 | const add = require('./add')
11 | const mins = require('./mins')
12 |
13 | console.log(add(2, 2))
14 | console.log(mins(10, 2))
--------------------------------------------------------------------------------
/day14-gulp/01.module/03.ES6模块化/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | Document
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/day15-webpack/.eslintrc.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | // eslint配置
3 | parserOptions: {
4 | ecmaVersion: 8, // es8
5 | sourceType: "module", // ECMAScript 模块
6 | },
7 | rules: {
8 | // error 和 2 代表错误
9 | // warn 和 1 代表警告
10 | // off 和 0 代表关闭
11 | semi: 0, // 分号
12 | "no-debugger": "warn",
13 | eqeqeq: "off", // 必须使用三个等号
14 | },
15 | };
--------------------------------------------------------------------------------
/day15-webpack/build/index.html:
--------------------------------------------------------------------------------
1 | Documenthello
111111
--------------------------------------------------------------------------------
/day14-gulp/01.module/03.ES6模块化/js/say.js:
--------------------------------------------------------------------------------
1 | /*
2 | 统一暴露:
3 | 直接在export后放对象,把需要暴露的功能放在对象中暴露出去
4 | 一般是暴露多个功能使用
5 |
6 | */
7 | function say1(con) {
8 | return "hello " + con;
9 | }
10 |
11 | function say2(con) {
12 | return "bye " + con
13 | }
14 |
15 | //统一暴露
16 | /* export {
17 | say1,
18 | say2
19 | } */
20 |
21 | //统一暴露的时候 起一个别名
22 | export {
23 | say1 as s1, //起别名
24 | say2
25 | }
--------------------------------------------------------------------------------
/day14-gulp/01.module/03.ES6模块化/build/add.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 |
3 | Object.defineProperty(exports, "__esModule", {
4 | value: true
5 | });
6 | exports["default"] = void 0;
7 |
8 | /*
9 | 默认暴露:
10 | - 当前模块只需要暴露一个功能,则可以选用默认暴露
11 | - 默认暴露在当前模块中只能暴露一个功能
12 | - 使用 export default XXX;
13 |
14 | */
15 | function add(a, b) {
16 | return a + b;
17 | }
18 |
19 | var _default = add;
20 | exports["default"] = _default;
--------------------------------------------------------------------------------
/day14-gulp/01.module/03.ES6模块化/js/utils.js:
--------------------------------------------------------------------------------
1 | /*
2 | 分别暴露:
3 | - 当一个模块中有多个功能需要暴露的时候,可以在声明语句前进行书写export进行暴露
4 | - 分别暴露可以暴露多个功能出去
5 |
6 | */
7 | let num = 1;
8 |
9 | export let count = 0;
10 |
11 | export const msg = {
12 | code: 10000,
13 | info: "hello world"
14 | }
15 |
16 | export function mins(a, b) {
17 | return a - b;
18 | }
19 |
20 | //以下写法错误,如果是分别暴露 则需要把export写在完整的声明语句前,如果是默认暴露 请添加default
21 | // export mins;
--------------------------------------------------------------------------------
/day15-webpack/src/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | Document
9 |
10 |
11 |
12 | hello
13 |
14 | 111111
15 |
16 |
17 |
--------------------------------------------------------------------------------
/day07-node核心模块/06.fs/09.流式读取.js:
--------------------------------------------------------------------------------
1 | const fs = require("fs");
2 | const path = require("path");
3 |
4 | const filePath = path.resolve(__dirname, "01.mp4")
5 |
6 | //想要流式读取某个文件内容 需要给某个文件创建可读流
7 | const rs = fs.createReadStream(filePath);
8 |
9 | //可读流读取之后会触发事件 data (data事件就是消费可读流了)
10 | rs.on("data", (chunk) => {
11 | //chunk就是每次读到的数据
12 | console.log(chunk);
13 | })
14 |
15 | //当流式读取完毕 则会触发end事件
16 | rs.on("end", () => {
17 | console.log("读完了");
18 | })
--------------------------------------------------------------------------------
/day08-http课程/07.请求方式.js:
--------------------------------------------------------------------------------
1 | /*
2 | 请求方式:
3 | - GET:查询数据,一般GET操作不会对数据产生影响(查)
4 | - POST:向服务器新增数据,例如文件上传,注册等等(增)
5 | - PUT:提交数据,用来修改某些数据(改)
6 | - DELETE:请求删除一些数据(删)
7 | - HEAD:和GET类似(只要响应头,不要报文体)
8 | - OPTIONS:预检请求,一般是浏览器主动发送检查服务器是否支持某个请求
9 |
10 | - GET和POST请求的区别
11 | - 参数位置:GET请求再URL上,POST在报文体内
12 | - 参数的安全性:GET较差,POST较好
13 | - 参数的长度:GET长度受限,POST不受限制
14 | - 缓存:GET请求默认读取缓存,POST不读取缓存
15 |
16 | */
--------------------------------------------------------------------------------
/day14-gulp/02.gulp/src/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | Document
9 |
10 |
11 |
12 |
13 |
14 | hello
15 |
16 |
17 |
--------------------------------------------------------------------------------
/day14-gulp/02.gulp/dist/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | Document
9 |
10 |
11 |
12 |
13 |
14 | hello
15 |
16 |
17 |
--------------------------------------------------------------------------------
/day08-http课程/11.四次挥手.js:
--------------------------------------------------------------------------------
1 | /*
2 | 四次挥手:
3 | - TCP的连接的拆除需要发送四个包,因此称为四次挥手
4 | - 四次挥手的目的:每个方向的关闭都需要请求和确认,因为客户端的断开请求的时候,服务端的数据并不一定发送发完毕,所以服务端不会把应答和请求一起发送,而是等数据发送完成之后才发送断开请求
5 | - 四次挥手的过程
6 | - 客户端向服务端发送断开请求,服务端接收请求
7 | - 发送的是Fin字段
8 | - 服务端向客户端发送断开应答,客户端接收
9 | - 发送ack字段
10 | - 当服务端的数据发送完成之后,再向客户端发送断开请求,客户端接收
11 | - 发送Fin字段
12 | - 客户端向服务端发送断开应答,服务端接收
13 | - 发送ack字段
14 |
15 | */
--------------------------------------------------------------------------------
/day13-登录注册/05.协商缓存/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | Document
9 |
10 |
11 |
12 |
13 |
14 |
15 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/day14-gulp/01.module/03.ES6模块化/build/say.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 |
3 | Object.defineProperty(exports, "__esModule", {
4 | value: true
5 | });
6 | exports.s1 = say1;
7 | exports.say2 = say2;
8 |
9 | /*
10 | 统一暴露:
11 | 直接在export后放对象,把需要暴露的功能放在对象中暴露出去
12 | 一般是暴露多个功能使用
13 |
14 | */
15 | function say1(con) {
16 | return "hello " + con;
17 | }
18 |
19 | function say2(con) {
20 | return "bye " + con;
21 | } //统一暴露
22 |
23 | /* export {
24 | say1,
25 | say2
26 | } */
27 | //统一暴露的时候 起一个别名
--------------------------------------------------------------------------------
/day07-node核心模块/05.crypto/index.js:
--------------------------------------------------------------------------------
1 | const crypto = require("crypto");
2 |
3 | //1.确定加密方式(消息摘要加密有多种 md5 sha1 sha256 sha512)
4 | const md5 = crypto.createHash('md5');
5 |
6 | //2.获取明文
7 | let pass = "jkl;'";
8 |
9 | //加盐
10 | pass += 'atguigu';
11 |
12 | //3.加密并转为16进制展示
13 | const result = md5.update(pass, 'utf8').digest('hex')
14 |
15 |
16 | console.log(result);
17 |
18 |
19 | //再次加密
20 | const md51 = crypto.createHash('md5');
21 | const result2 = md51.update(result, 'utf8').digest('hex')
22 | console.log(result2);
--------------------------------------------------------------------------------
/day08-http课程/10.三次握手.js:
--------------------------------------------------------------------------------
1 | /*
2 | 三次握手:
3 | - 在发送数据前,通信双方必须在彼此间建立一条连接
4 | - 所谓三次握手,是指建立一个TCP连接时,需要客户端和服务器总共发送3个数据包
5 | - 握三次手的目的是:双方确保对方的接收和发送的能力都正常
6 | - 三次握手的过程
7 | - 客户端向服务端发送请求数据包,服务端接收客户端的请求数据包(服务端认可客户端的发送能力正常)
8 | - 客户端发送的是syn字段(请求连接字段)
9 | - 服务端向客户端响应一个数据包(客户端认可服务端的接收和发送能力正常)
10 | - 服务端发送的是ack+syn字段(ack:应答字段)
11 | - 客户端收到服务端的数据包,并向服务端再次发送一个数据包(服务端认可客户端的接收能力正常)
12 | - 客户端发送的是ack字段
13 |
14 | */
--------------------------------------------------------------------------------
/day13-登录注册/05.协商缓存/协商缓存过程.js:
--------------------------------------------------------------------------------
1 | /*
2 | 协商缓存:
3 | - 客户端向服务端发送请求,请求某一个资源文件
4 | - 服务端向客户端响应当前的文件,并且在响应头中添加两个字段,分别是文件的唯一标识(eTag)和当前被请求文件的最后一次修改时间(last-modified)
5 | - 客户端接收到响应,还要处理关于协商缓存的信息,把文件的唯一标识和最后一次修改时间保存下来,并且还要修改字段名,把eTag更名为if-none-match,把last-modified更名为if-modified-since
6 | - 客户端再次请求资源,会携带if-none-match和if-modified-since字段
7 | - 服务端接收到请求后,会把if-none-match和自己的eTag进行比较,把if-modified-since和自己的last-modified进行比较,如果都相同,则直接响应304状态码,要求读取缓存。否则响应数据,并携带最新的eTag和last-modified
8 |
9 |
10 | */
--------------------------------------------------------------------------------
/day07-node核心模块/04.Events/index.js:
--------------------------------------------------------------------------------
1 | const EventEmitter = require("events");
2 |
3 | //创建一个子类 继承EventEmitter 在子类实例化对象上扩展自定义事件
4 | class myEvent extends EventEmitter {};
5 |
6 | //实例化子类
7 | const event = new myEvent();
8 |
9 | //注册一个事件(on也可以写作addListener),once是绑定一次性事件
10 | function fn() {
11 | console.log("hello");
12 | }
13 | event.on("hello", fn)
14 |
15 |
16 | //触发事件
17 | event.emit("hello")
18 |
19 | //解绑事件
20 | event.off("hello", fn);
21 |
22 | event.emit("hello")
23 | event.emit("hello")
24 | event.emit("hello")
--------------------------------------------------------------------------------
/day12-登录注册/04.cookie.js:
--------------------------------------------------------------------------------
1 | /*
2 | cookie:
3 | - 特点:
4 | - cookie保存在浏览器端,内存只有4kb,并且还有个数限制(个别浏览器限制50左右)
5 | - cookie是按照域名保存的
6 | - cookie会随着http请求发送到服务端,如果cookie过多可能造成服务端压力
7 | - cookie发送是明文发送的
8 |
9 | - cookie的流程
10 | - 客户端发送请求到服务端
11 | - 服务端返回成功响应,响应头携带cookie,cookie中保存用户的信息
12 | - 客户端接收到服务端的响应,并把cookie存放在了客户端储存
13 | - 客户端再次请求服务端,会自动的携带上所有的cookie,放在自己的请求头上
14 | - 服务端接收到的请求头中的cookie,判断是哪一个用户,从而作出对应响应
15 | */
--------------------------------------------------------------------------------
/day08-http课程/09.OSI网络模型.js:
--------------------------------------------------------------------------------
1 | /*
2 | OSI网络模型:
3 | 在理论上来说,OSI网络模型应该分为七层,但是在实际上使用过程中只需要五层,被称作为TCP/IP五层网络模型
4 | - 应用层:(HTTP协议在应用层)
5 | - 应用层:给用户的应用提供网络支持和网络访问
6 | - 表示层:负责对数据的加密和压缩等操作
7 | - 会话层:负责网络的建立
8 |
9 | - 传输层:
10 | - 提供了数据传输的接口(在数据上添加了TCP/IP头)
11 | - 对数据的检测和流量控制
12 |
13 | - 网络层:
14 | - 解决一个数据由一个计算的的ip如何发送到目标的计算机的过程
15 | - 在数据上添加了ip头部
16 |
17 | - 数据链路层/物理层
18 | - 将数据转化为电子的形式在传输设备上进行传播
19 |
20 |
21 | */
--------------------------------------------------------------------------------
/day07-node核心模块/06.fs/05.promisify解决异步回调.js:
--------------------------------------------------------------------------------
1 | const fs = require("fs");
2 | const path = require("path");
3 |
4 | //promisify工具 可以把异步的方法 变成返回promise对象的方法
5 | const {
6 | promisify
7 | } = require("util");
8 |
9 | //文件路径
10 | const filePath = path.resolve(__dirname, "01.txt");
11 |
12 |
13 | const open = promisify(fs.open);
14 | const write = promisify(fs.write);
15 | const close = promisify(fs.close);
16 |
17 | (async function () {
18 | const fd = await open(filePath, "a");
19 | await write(fd, "hhhhhh~");
20 | await close(fd)
21 | })()
--------------------------------------------------------------------------------
/day07-node核心模块/06.fs/11.pipe简单流式读写.js:
--------------------------------------------------------------------------------
1 | const fs = require("fs");
2 | const path = require("path");
3 |
4 | const filePath1 = path.resolve(__dirname, "01.mp4");
5 | const filePath2 = path.resolve(__dirname, "02.mp4");
6 |
7 |
8 | //创建可读流
9 | const rs = fs.createReadStream(filePath1);
10 | //创建可写流
11 | const ws = fs.createWriteStream(filePath2);
12 |
13 | //直接把可读流写入到可写流 并关闭可读流可写流
14 | rs.pipe(ws);
15 |
16 | //监听可写流是否被关闭
17 | ws.on("close", () => {
18 | console.log("可写流关闭");
19 | })
20 | rs.on("end", () => {
21 | console.log("可读流关闭");
22 | })
--------------------------------------------------------------------------------
/day08-http课程/03.post请求.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | Document
9 |
10 |
11 |
12 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/day07-node核心模块/07.http/02.作为客户端.js:
--------------------------------------------------------------------------------
1 | const http = require("http");
2 |
3 | //设置请求地址:
4 | const url = "http://127.0.0.1:3000"
5 | //设置请求
6 | const request = http.request(url, response => {
7 | //回调函数的参数response 就是响应的对象
8 |
9 | // console.log(response);
10 | //响应状态码
11 | console.log(response.statusCode);
12 |
13 | //node作为客户端请求到数据是可读流,需要使用可读流的是data事件来接受
14 | response.on("data", chunk => {
15 | console.log(chunk);
16 | console.log(chunk.toString());
17 | })
18 |
19 | });
20 |
21 |
22 | //发送请求
23 | request.end();
--------------------------------------------------------------------------------
/day09-MongoDB/09.mongoose模块化/index.js:
--------------------------------------------------------------------------------
1 | //引入连接数据库的模块(引入模块,模块会直接执行,如果模块没有暴露对象,可以不用接受)
2 | require("./db");
3 |
4 | //引入studentModel模块
5 | const studentModel = require("./model/studentModel");
6 |
7 | //查
8 | const re = studentModel.findOne({
9 | $where: function () {
10 | return this.hobby.includes("看书");
11 | }
12 | }, {
13 | name: 1,
14 | _id: 0
15 | })
16 |
17 | // console.log(re)
18 | re.then(value => {
19 | //find返回的promise对象的值是一个数组,包含的是查询到的一个或多个文档对象
20 | //findOne返回的promise对象的值是就是查询到的一个文档对象
21 | console.log("查询结果", value);
22 | })
--------------------------------------------------------------------------------
/day12-登录注册/project/html/center.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | Document
9 |
10 |
11 |
12 |
13 |
14 |
15 |

16 |
欢迎光临 888号为您服务
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/day15-webpack/src/less/iconfont.css:
--------------------------------------------------------------------------------
1 | @font-face {
2 | font-family: "iconfont";
3 | /* Project id 2781113 */
4 | src: url('../font/iconfont.woff2?t=1634888634253') format('woff2'),
5 | url('../font/iconfont.woff?t=1634888634253') format('woff'),
6 | url('../font/iconfont.ttf?t=1634888634253') format('truetype');
7 | }
8 |
9 | .iconfont {
10 | font-family: "iconfont" !important;
11 | font-size: 16px;
12 | font-style: normal;
13 | -webkit-font-smoothing: antialiased;
14 | -moz-osx-font-smoothing: grayscale;
15 | }
16 |
17 | .icon-lieri:before {
18 | content: "\e600";
19 | }
--------------------------------------------------------------------------------
/day12-登录注册/01.登录注册模块划分/index.js:
--------------------------------------------------------------------------------
1 | const express = require("express");
2 | const app = express();
3 | const path = require("path")
4 |
5 | //1.官方的静态资源中间件(服务器上的文件响应)
6 | //暴露views中的静态文件,直接可以在服务器的地址栏后添加对应的静态资源路径即可访问
7 | app.use("/",express.static(path.resolve(__dirname, "./views")))
8 | //暴露public中的静态文件,但是做了路径限制,在服务器地址后添加/public/+静态资源路径即可访问
9 | app.use("/public/", express.static(path.resolve(__dirname, "./public")))
10 |
11 | app.listen("8888", err => {
12 | if (err) {
13 | console.log("服务端错误", err);
14 | return;
15 | }
16 | console.log("服务端启动成功 http://192.168.19.38:8888");
17 | })
--------------------------------------------------------------------------------
/day12-登录注册/01.登录注册模块划分/views/center.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | Document
9 |
10 |
11 |
12 |
13 |
14 |
15 |

16 |
欢迎光临 888号为您服务
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/day09-MongoDB/02.连接数据库.js:
--------------------------------------------------------------------------------
1 | const mongoose = require("mongoose");
2 |
3 | /* //连接数据库,回调函数监听连接状态
4 | mongoose.connect("mongodb://127.0.0.1:27017/class0722", err => {
5 | if (err) {
6 | console.log("数据库连接失败", err);
7 | return;
8 | }
9 | console.log("数据库连接成功");
10 | }) */
11 |
12 |
13 | //连接数据库
14 | mongoose.connect("mongodb://127.0.0.1:27017/class0722");
15 |
16 | //当数据库连接成功会触发mongoose.connection对象的open事件
17 | mongoose.connection.once("open", err => {
18 | if (err) {
19 | console.log("数据库连接失败", err);
20 | return;
21 | }
22 | console.log("数据库连接成功");
23 | })
24 |
--------------------------------------------------------------------------------
/npm命令.md:
--------------------------------------------------------------------------------
1 | - npm init :初始化一个package.json
2 | - npm i jquery / npm i jquery --save /npm i jquery -S : 下载生产依赖的包
3 | - npm i jquery --save-dev /npm i jquery -D :下载开发依赖的包
4 | - npm i :下载所有package.json中依赖的包
5 | - npm i jquery@1:下载1版本的最新版
6 | - npm i jquery@1.1:下载1.1版本的最新版
7 | - npm i jquery@1.1.1:下载1.1.1版本
8 | - npm r jquery:删除jquery的包
9 |
10 | - npm i -g nodemon:全局安装某个包(全局的安装基本都是命令)
11 |
12 |
13 |
14 | - npm i yarn -g:下载yarn工具
15 | - yarn init -y :初始化package.json
16 | - yarn add jquery:下载生产依赖的包
17 | - yarn add jquery -D:下载开发依赖的包
18 | - yarn global add less:全局安装less工具
19 | - yarn remove jquery:删除某个包
20 | - yarn:下载所有依赖
--------------------------------------------------------------------------------
/day06-node01/02.微任务和宏任务.js:
--------------------------------------------------------------------------------
1 | /*
2 | 微任务和宏任务
3 | - 异步代码有优先级关系。有的优先级高先执行,有的优先级低后执行。
4 | - 分为宏任务(macrotask )和微任务(microtask )
5 | 宏任务:包括整体代码script,setTimeout,setInterval等等
6 | 微任务: Promise.then/catch/finally,process.nextTick,queueMicrotask
7 | - js引擎执行异步代码。会优先执行微任务,再执行宏任务
8 | - 执行过程
9 | - 执行栈选择最先进入队列的宏任务(一般都是script),执行其同步代码直至结束;
10 | - 检查是否存在微任务,有则会执行至微任务队列为空;
11 | - 执行宏任务中的异步代码
12 | - 执行过程中如果遇到微任务,就将它添加到微任务的任务队列中
13 | - 宏任务执行完毕后,立即执行当前微任务队列中的所有微任务(依次执行)
14 | - 开始下一个宏任务(从事件队列中获取)
15 |
16 |
17 | */
--------------------------------------------------------------------------------
/day13-登录注册/03.登录注册session权限控制/routers/centerRouter.js:
--------------------------------------------------------------------------------
1 | const express = require("express");
2 | const router = new express.Router();
3 |
4 | //引入userModel模块
5 | const userModel = require("../models/userModel");
6 |
7 | //个人中心权限管理接口
8 | router.post("/center", async (req, res) => {
9 | //权限判断
10 | console.log(req.session.user)
11 | if (req.session.user) {
12 | return res.json({
13 | code: 10000,
14 | msg: req.session.user.username
15 | })
16 | }
17 |
18 | res.json({
19 | code: 10001,
20 | msg: "没有权限,请重新登录"
21 | })
22 | })
23 |
24 | module.exports = router;
--------------------------------------------------------------------------------
/day14-gulp/01.module/03.ES6模块化/build/utils.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 |
3 | Object.defineProperty(exports, "__esModule", {
4 | value: true
5 | });
6 | exports.count = void 0;
7 | exports.mins = mins;
8 | exports.msg = void 0;
9 |
10 | /*
11 | 分别暴露:
12 | - 当一个模块中有多个功能需要暴露的时候,可以在声明语句前进行书写export进行暴露
13 | - 分别暴露可以暴露多个功能出去
14 |
15 | */
16 | var num = 1;
17 | var count = 0;
18 | exports.count = count;
19 | var msg = {
20 | code: 10000,
21 | info: "hello world"
22 | };
23 | exports.msg = msg;
24 |
25 | function mins(a, b) {
26 | return a - b;
27 | } //以下写法错误,如果是分别暴露 则需要把export写在完整的声明语句前,如果是默认暴露 请添加default
28 | // export mins;
--------------------------------------------------------------------------------
/day06-node01/04.node的函数.js:
--------------------------------------------------------------------------------
1 | /*
2 | 在nodeJS中,每一个JS模块都默认包裹了一层函数。
3 | - function (exports, require, module, __filename, __dirname) {}
4 | - 这个函数是所有模块都有的,node编译时往其中注入5个参数:
5 | - exports:代表当前模块暴露的对象
6 | - require:用来引入其他模块
7 | - module:当前模块的详细信息
8 | - __filename:代表当前文件的绝对路径
9 | - __dirname:代表但当前文件所在文件夹的绝对路径
10 | */
11 |
12 | //打印外层包裹的函数
13 | console.log(arguments.callee.toString());
14 | console.log("exports", exports);
15 | console.log("require", require);
16 | console.log("module", module);
17 | console.log("__filename", __filename);
18 | console.log("__dirname", __dirname);
--------------------------------------------------------------------------------
/day12-登录注册/02.接口书写/models/userModel.js:
--------------------------------------------------------------------------------
1 | const mongoose = require("mongoose");
2 | //创建某个集合的约束对象
3 | const userSchema = new mongoose.Schema({
4 | username: {
5 | type: String, //约束数据类型是String
6 | unique: true, //唯一的
7 | required: true, //必填项
8 | },
9 | password: {
10 | type: String, //约束数据类型是String
11 | required: true, //必填项
12 | }, //直接约束数据类型
13 | createTime: {
14 | type: Date,
15 | default: Date.now
16 | }
17 | })
18 |
19 |
20 |
21 | //3.根据约束对象创建对应的集合
22 | const userModel = mongoose.model("user", userSchema);
23 |
24 |
25 | //把创建好的model对象暴露出去
26 | module.exports = userModel;
--------------------------------------------------------------------------------
/day12-登录注册/03.路由管理/models/userModel.js:
--------------------------------------------------------------------------------
1 | const mongoose = require("mongoose");
2 | //创建某个集合的约束对象
3 | const userSchema = new mongoose.Schema({
4 | username: {
5 | type: String, //约束数据类型是String
6 | unique: true, //唯一的
7 | required: true, //必填项
8 | },
9 | password: {
10 | type: String, //约束数据类型是String
11 | required: true, //必填项
12 | }, //直接约束数据类型
13 | createTime: {
14 | type: Date,
15 | default: Date.now
16 | }
17 | })
18 |
19 |
20 |
21 | //3.根据约束对象创建对应的集合
22 | const userModel = mongoose.model("user", userSchema);
23 |
24 |
25 | //把创建好的model对象暴露出去
26 | module.exports = userModel;
--------------------------------------------------------------------------------
/day06-node01/05.nodejs模块化/add.js:
--------------------------------------------------------------------------------
1 | //定义一个模块
2 | function add(a, b) {
3 | return a + b;
4 | }
5 |
6 |
7 | /*
8 | 暴露:
9 | - 怎么暴露当前模块的对象或者方法呢?需要把被暴露的东西放在一个对象上
10 | - module.exports就是真正当前模块暴露的对象,只要把被暴露的内容放在module.exports上,就可以被暴露出去
11 | - exports默认指向module.exports对象的,所以给exports添加内容,也能被暴露出去,但是一旦修改exports的地址,不再指向module.exports,则exports对象将不代表暴露对象了
12 |
13 |
14 | */
15 |
16 | //暴露方式1:暴露的是一个对象 对象内有一个add方法
17 | // module.exports.add = add;
18 |
19 | //暴露方式2:直接把当前add暴露出去
20 | // module.exports = add;
21 |
22 |
23 | //暴露方式3:暴露的是一个对象 里边有add方法
24 | // exports.add = add;
25 |
26 | //这样是没有暴露出去的,因为并没有修改module.exports对象的内容
27 | exports = add;
--------------------------------------------------------------------------------
/day12-登录注册/02.接口书写/views/center.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | Document
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |

17 |
欢迎光临 888号为您服务
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/day12-登录注册/03.路由管理/views/center.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | Document
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |

17 |
欢迎光临 888号为您服务
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/day07-node核心模块/06.fs/10.流式读写.js:
--------------------------------------------------------------------------------
1 | const fs = require("fs");
2 | const path = require("path");
3 |
4 | const filePath1 = path.resolve(__dirname, "01.mp4");
5 | const filePath2 = path.resolve(__dirname, "02.mp4");
6 |
7 |
8 | //创建可读流
9 | const rs = fs.createReadStream(filePath1);
10 | //创建可写流
11 | const ws = fs.createWriteStream(filePath2);
12 |
13 |
14 | //data事件是消费可读流
15 | rs.on("data", chunk => {
16 | //向可写流写入读取的流式内容
17 | ws.write(chunk)
18 | })
19 |
20 | //监听可读流读取完毕
21 | rs.on("end", () => {
22 | console.log("可读流over");
23 | //关闭可写流
24 | ws.end();
25 | })
26 |
27 | //监听可写流是否被关闭
28 | ws.on("close", () => {
29 | console.log("可写流关闭");
30 | })
--------------------------------------------------------------------------------
/day13-登录注册/02.登录注册cookie权限控制/models/userModel.js:
--------------------------------------------------------------------------------
1 | const mongoose = require("mongoose");
2 | //创建某个集合的约束对象
3 | const userSchema = new mongoose.Schema({
4 | username: {
5 | type: String, //约束数据类型是String
6 | unique: true, //唯一的
7 | required: true, //必填项
8 | },
9 | password: {
10 | type: String, //约束数据类型是String
11 | required: true, //必填项
12 | }, //直接约束数据类型
13 | createTime: {
14 | type: Date,
15 | default: Date.now
16 | }
17 | })
18 |
19 |
20 |
21 | //3.根据约束对象创建对应的集合
22 | const userModel = mongoose.model("user", userSchema);
23 |
24 |
25 | //把创建好的model对象暴露出去
26 | module.exports = userModel;
--------------------------------------------------------------------------------
/day13-登录注册/03.登录注册session权限控制/models/userModel.js:
--------------------------------------------------------------------------------
1 | const mongoose = require("mongoose");
2 | //创建某个集合的约束对象
3 | const userSchema = new mongoose.Schema({
4 | username: {
5 | type: String, //约束数据类型是String
6 | unique: true, //唯一的
7 | required: true, //必填项
8 | },
9 | password: {
10 | type: String, //约束数据类型是String
11 | required: true, //必填项
12 | }, //直接约束数据类型
13 | createTime: {
14 | type: Date,
15 | default: Date.now
16 | }
17 | })
18 |
19 |
20 |
21 | //3.根据约束对象创建对应的集合
22 | const userModel = mongoose.model("user", userSchema);
23 |
24 |
25 | //把创建好的model对象暴露出去
26 | module.exports = userModel;
--------------------------------------------------------------------------------
/复习/01.this指向.js:
--------------------------------------------------------------------------------
1 | function fn() {
2 | console.log(this);
3 | }
4 |
5 | //1.函数默认调用---this指向window
6 | fn();
7 |
8 | //2.函数被上下文对象调用---this指向o
9 | const o = {
10 | f: function () {
11 | console.log(this);
12 | }
13 | }
14 | o.f();
15 |
16 |
17 | //3.隐式丢失--看丢失给的变量是怎么调用的
18 | const o2 = {
19 | f: fn
20 | }
21 | const f2 = o2.f;
22 | f2();
23 |
24 |
25 | //4.实例化调用--this指向实例化对象
26 | const o3 = new fn();
27 |
28 |
29 | //5.强制绑定---this指向强制绑定的对象
30 | fn.call(o3);
31 |
32 |
33 | //判断this指向
34 | //1.先看这个函数有没有被强制绑定(call apply bind)
35 | //2.再看这个函数没有被实例化(new 调用)
36 | //3.再看函数有没有上下文对象调用
37 | //4.其他都是指向window
38 | //5.箭头函数没有this,严格模式下函数默认调用 this指向undefined
--------------------------------------------------------------------------------
/day01-ES5+/15.flat.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | Document
9 |
10 |
11 |
12 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/day06-node01/05.nodejs模块化/index.js:
--------------------------------------------------------------------------------
1 | //引入模块
2 | //1.当暴露的是{add:fn}
3 | /* const {
4 | add
5 | } = require("./add");
6 | console.log(add);
7 | console.log(add(1, 2)); */
8 |
9 | //2.当暴露的是add的时候
10 | /* const add = require("./add");
11 | console.log(add);
12 | console.log(add(1, 1)); */
13 |
14 |
15 | /*
16 | 模块标识:
17 | - require()中书写引入的模块内容,叫做模块标识
18 | - 模块标识分为3中
19 | - 核心模块(node自带模块 直接引入即可) require('fs')
20 | - 第三方模块(别人写好的模块,我们下载之后 直接引入) npm i jquery / require("jquery")
21 | - 自定义模块(我们自己书写的模块,直接按照路径引入,可以省略后缀)(省略后缀自动会按照以下顺序添加:.js .json .node)
22 |
23 | */
24 |
25 |
26 | const fs = require("fs");
27 | console.log(fs.open);
--------------------------------------------------------------------------------
/day07-node核心模块/06.fs/08.流式写入.js:
--------------------------------------------------------------------------------
1 | const fs = require("fs");
2 | const path = require("path");
3 |
4 | const filePath = path.resolve(__dirname, "01.txt")
5 |
6 | //想要流式的写入,需要根据写入的文件创建可写流
7 | const ws = fs.createWriteStream(filePath);
8 |
9 |
10 | //使用可写流ws的write方法即可向可写流写入内容
11 | ws.write("锄禾日当午");
12 | ws.write("汗滴禾下土");
13 | ws.write("谁知盘中餐");
14 | ws.write("粒粒皆辛苦");
15 |
16 | //当写入完成以后关闭可写流
17 | ws.end() //关闭管道的开头
18 | ws.close() //关闭管道的末尾
19 |
20 |
21 | //事件监听
22 | //绑定open事件,当可写流打开的时候会自动的触发open事件
23 | ws.on("open", () => {
24 | console.log("文件已经打开");
25 | })
26 |
27 | //绑定可写流的关闭事件,当可写流关闭时会触发
28 | ws.on("close", () => {
29 | console.log("可写流关闭");
30 | ws.write("粒粒皆辛苦~");
31 | })
--------------------------------------------------------------------------------
/day01-ES5+/17.copyWithin.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | Document
9 |
10 |
11 |
12 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/day08-http课程/08.状态码.js:
--------------------------------------------------------------------------------
1 | /*
2 | 响应状态码:
3 | - 1XX:临时响应,还需要等待服务端继续操作
4 | - 100: 请求正常,还需要继续等待或者继续请求
5 | - 101: 需要服务器切换协议,继续等待
6 |
7 | - 2XX:成功处理了请求
8 | - 200: 服务器处理成功,并成功返回响应
9 | - 201: 服务器处理成功,并在服务器上创建了新的资源(一般是POST请求)
10 |
11 | - 3XX:表示需要后续操作才能完成
12 | - 301: 永久重定向
13 | - 302: 临时重定向
14 | - 304: 上次请求到现在请求,服务端资源没有发生修改,请读取缓存
15 |
16 | - 4XX:客户端错误
17 | - 400: 请求错误,服务端不认识客户端发送的语法
18 | - 401: 未授权的客户端访问,需要身份验证
19 | - 403: 服务端拒绝访问
20 | - 404: 服务器找不到你请求的网页
21 |
22 | - 5XX:服务端错误
23 | - 500: 服务端发生错误,无法完成请求
24 | - 503: 服务端宕机,无法使用
25 | */
--------------------------------------------------------------------------------
/day09-MongoDB/09.mongoose模块化/model/studentModel.js:
--------------------------------------------------------------------------------
1 | const mongoose = require("mongoose");
2 | //创建某个集合的约束对象
3 | const studentSchema = new mongoose.Schema({
4 | name: {
5 | type: String, //约束数据类型是String
6 | unique: true, //唯一的
7 | required: true, //必填项
8 | },
9 | age: Number, //直接约束数据类型
10 | sex: String,
11 | hobby: [String], //直接约束hobby的值是一个数组,数组的值必须是字符串
12 | createTime: {
13 | type: Date,
14 | default: Date.now
15 | }
16 | })
17 |
18 | console.log(studentSchema);
19 |
20 |
21 | //3.根据约束对象创建对应的集合
22 | const studentModel = mongoose.model("student", studentSchema);
23 | console.log(studentModel);
24 |
25 |
26 | //把创建好的model对象暴露出去
27 | module.exports = studentModel;
--------------------------------------------------------------------------------
/day07-node核心模块/01.Buffer/index.js:
--------------------------------------------------------------------------------
1 | /*
2 | Buffer:
3 | - 二进制流,专门保存二进制的数据
4 |
5 | */
6 |
7 | //创建一个长度为10的Buffer
8 | const buf1 = Buffer.alloc(10);
9 | console.log('buf1', buf1);
10 |
11 | //创建一个长度为10的Buffer 填充内容(如果填充不满则重复)
12 | const buf2 = Buffer.alloc(10, "atguigu");
13 | console.log('buf2', buf2);
14 |
15 | //创建一个长度为10的Buffer
16 | const buf3 = Buffer.allocUnsafe(10);
17 | console.log('buf3', buf3);
18 |
19 |
20 | //创建一个字符串对应的buffer
21 | const buf4 = Buffer.from("尚硅谷 atguigu");
22 | console.log('buf4', buf4); //
23 |
24 | //把Buffer转为字符串
25 | console.log(buf4.toString());
26 |
27 | //Buffer可以forEach
28 | buf4.forEach(item => {
29 | console.log(item);
30 | })
--------------------------------------------------------------------------------
/day01-ES5+/16.fill.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | Document
9 |
10 |
11 |
12 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/day12-登录注册/project/html/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | Document
9 |
10 |
11 |
12 |
13 |
14 |
15 |

16 |
尚硅谷学生管理系统
17 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/day05-promise/01.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 | Document
12 |
13 |
14 |
15 |
16 |
17 |
29 |
30 |
--------------------------------------------------------------------------------
/day12-登录注册/02.接口书写/views/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | Document
9 |
10 |
11 |
12 |
13 |
14 |
15 |

16 |
尚硅谷学生管理系统
17 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/day12-登录注册/03.路由管理/views/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | Document
9 |
10 |
11 |
12 |
13 |
14 |
15 |

16 |
尚硅谷学生管理系统
17 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/day12-登录注册/01.登录注册模块划分/views/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | Document
9 |
10 |
11 |
12 |
13 |
14 |
15 |

16 |
尚硅谷学生管理系统
17 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/day13-登录注册/03.session.js:
--------------------------------------------------------------------------------
1 | /*
2 | session:
3 | - session是服务端的存储
4 | - session设置过程
5 | - 客户端发送请求到服务端
6 | - 服务端验证请求成功后,在服务端创建一个session对象,然后再创建一个永远不会重复的sessionID,把当前的用户信息和sessionID全部存放在session对象中
7 | - 服务端向客户端返回响应,并在cookie中携带sessionID
8 | - 客户端收到的服务端的响应,并把sessionID存放在cookie中
9 | - 客户端再次请求服务端,cookie会随着http的请求头发送
10 | - 服务端接收到了客户端发送的cookie中的sessionID,去自身保存的session对象中查询是否存在该用户信息
11 | - 如果服务端验证存在该用户信息,则直接响应成功请求,否则进行失败响应,要求重新验证权限
12 |
13 | session和cookie的对比:
14 | - 安全性:cookie中可能会存放敏感信息,session是把敏感信息放在服务端,并把唯一的id放在了cookie中
15 | - 存放位置:cookie是客户端储存,session是服务端存储
16 | - session在服务端存储的时候会占用服务端资源,所以可以尝试把session对象放在数据库中
17 |
18 |
19 |
20 | */
--------------------------------------------------------------------------------
/day13-登录注册/02.登录注册cookie权限控制/views/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | Document
9 |
10 |
11 |
12 |
13 |
14 |
15 |

16 |
尚硅谷学生管理系统
17 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/day07-node核心模块/02.process/index.js:
--------------------------------------------------------------------------------
1 | /*
2 | process:
3 | - 进程
4 | - argv:返回一个数组,保存的是启动时的命令参数
5 | - 当node index.js启动的时候,第一个值是node.exe的目录,第二个值是被启动文件的目录
6 | - argv0:其实就是argv[0]
7 | - cwd():返回node进程的工作目录
8 | - exit():停止进程的执行
9 |
10 | */
11 | console.log(1);
12 | console.log(process.argv);
13 | console.log(process.argv0);
14 |
15 | //根据启动的指令不同,可以运行不同的内容
16 | if (process.argv[2] === "hello") {
17 | console.log("欢迎光临");
18 | } else if (process.argv[2] === "bye") {
19 | console.log("欢迎下次光临");
20 | }
21 |
22 | console.log("cwd", process.cwd()); //node工作目录
23 |
24 |
25 | let i = 0
26 | setInterval(() => {
27 | i++;
28 | console.log(i);
29 | if (i > 4) {
30 | process.exit();
31 | }
32 | },1000)
--------------------------------------------------------------------------------
/day13-登录注册/03.登录注册session权限控制/views/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | Document
9 |
10 |
11 |
12 |
13 |
14 |
15 |

16 |
尚硅谷学生管理系统
17 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/day12-登录注册/03.路由管理/routers/regRouter.js:
--------------------------------------------------------------------------------
1 | const express = require("express");
2 |
3 | //创建一个router对象
4 | const router = new express.Router();
5 |
6 | //正则验证中间件
7 | router.use((req, res, next) => {
8 | const {
9 | user,
10 | pass
11 | } = req.body;
12 |
13 | const userReg = /^[A-Z][A-Za-z0-9]{4,9}$/g;
14 | const passReg = /^\d{3,6}$/g;
15 | if (!userReg.test(user)) {
16 | return res.json({
17 | code: 10004,
18 | msg: "用户名应该是大写字母开头,后边字母数字,总共5-10位"
19 | })
20 | }
21 |
22 | if (!passReg.test(pass)) {
23 | return res.json({
24 | code: 10004,
25 | msg: "密码是3-6为的数字"
26 | })
27 | }
28 |
29 | next();
30 | })
31 |
32 | //把当前的router暴露出去
33 | module.exports = router;
--------------------------------------------------------------------------------
/day03-ES6+/01.属性名表达式.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | Document
9 |
10 |
11 |
12 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/day07-node核心模块/07.http/01.服务器搭建.js:
--------------------------------------------------------------------------------
1 | const http = require("http");
2 |
3 | let count = 0;
4 | //创建一个服务(接受一个回调函数,对请求和响应的处理)
5 | const server = http.createServer((request, response) => {
6 | //回调函数的两个参数分别是请求对象和响应对象
7 | count++;
8 | console.log("请求啦~", count)
9 |
10 | //在响应头中 返回响应格式Content-Type
11 | response.setHeader("Content-Type", "application/json;charset=utf-8")
12 |
13 | //返回响应
14 | response.end(`{
15 | name: "laowang"
16 | }`);
17 | // response.end("你是第" + count + "个");
18 | });
19 |
20 | //启动服务 并设置端口号和主机地址(localhost\127.0.0.1\192.168.19.35 )
21 | server.listen(3000, "127.0.0.1", (err) => {
22 | if (err) {
23 | console.log("err", err);
24 | return;
25 | }
26 |
27 | console.log("服务器启动成功 http://127.0.0.1:3000");
28 | })
--------------------------------------------------------------------------------
/day05-promise/nodejs/02.Global.js:
--------------------------------------------------------------------------------
1 | /*
2 | Global:
3 | - nodeJS的顶层对象
4 | - 拥有定时器 微任务 立即执行函数等方法
5 |
6 | - 在node端 js完全没有DOM、有个别的BOM(定时器等)、完全支持ES
7 |
8 |
9 | - setImmediate:立即执行函数,和setTimeout设置时间为0是一样的
10 |
11 | - queueMicrotask:设置微任务
12 |
13 | - process.nextTick():立即执行函数,是微任务,但是排在了微任务的第一梯队上(如果你想让一段代码在同步结束后立马执行,请使用他)
14 |
15 | */
16 | // console.log(global);
17 |
18 | //定时器
19 | setTimeout(() => {
20 | console.log(2);
21 | }, 0)
22 |
23 | //立即执行函数
24 | setImmediate(() => {
25 | console.log("setImmediate");
26 | })
27 |
28 | //微任务
29 | queueMicrotask(() => {
30 | console.log("queueMicrotask");
31 | })
32 |
33 | //立即执行函数
34 | process.nextTick(() => {
35 | console.log("process.nextTick");
36 | })
37 |
38 |
39 |
40 |
41 | console.log(1);
--------------------------------------------------------------------------------
/day14-gulp/02.gulp/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "gulp-test",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "index.js",
6 | "scripts": {
7 | "start": "gulp watch",
8 | "build": "gulp build"
9 | },
10 | "keywords": [],
11 | "author": "",
12 | "license": "ISC",
13 | "devDependencies": {
14 | "@babel/core": "^7.15.8",
15 | "@babel/preset-env": "^7.15.8",
16 | "gulp": "^4.0.2",
17 | "gulp-babel": "^8.0.0",
18 | "gulp-browserify": "^0.5.1",
19 | "gulp-connect": "^5.7.0",
20 | "gulp-jshint": "^2.1.0",
21 | "jshint": "^2.13.1"
22 | },
23 | "dependencies": {
24 | "gulp-concat": "^2.6.1",
25 | "gulp-cssmin": "^0.2.0",
26 | "gulp-htmlmin": "^5.0.1",
27 | "gulp-less": "^5.0.0",
28 | "gulp-rename": "^2.0.0",
29 | "gulp-uglify": "^3.0.2"
30 | }
31 | }
--------------------------------------------------------------------------------
/day12-登录注册/project/html/login.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | Document
9 |
10 |
11 |
12 |
13 |
14 |
15 |

16 |
尚硅谷学生管理系统注册账号
17 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/day05-promise/10.动态import.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | Document
9 |
10 |
11 |
12 |
13 |
14 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/day12-登录注册/01.登录注册模块划分/views/login.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | Document
9 |
10 |
11 |
12 |
13 |
14 |
15 |

16 |
尚硅谷学生管理系统注册账号
17 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/day08-http课程/06.MIME类型服务器.js:
--------------------------------------------------------------------------------
1 | const http = require("http");
2 | const path = require("path");
3 | const fs = require("fs")
4 |
5 | const server = http.createServer((req, res) => {
6 | /* //响应一个html
7 | const filePath = path.resolve(__dirname, "./03.post请求.html");
8 | res.setHeader("Content-Type", "text/html;charset=utf-8");
9 | fs.readFile(filePath, (err, data) => {
10 | res.end(data)
11 | }) */
12 |
13 | //响应一个mp4
14 | const filePath = path.resolve(__dirname, "./01.mp4");
15 | res.setHeader("Content-Type", "text/html");
16 | fs.readFile(filePath, (err, data) => {
17 | res.end(data)
18 | })
19 |
20 | })
21 |
22 | server.listen(3001, "localhost", (err) => {
23 | if (err) {
24 | console.log("服务器启动错误")
25 | return;
26 | }
27 |
28 | console.log("服务器启动成功 请访问 http://localhost:3001");
29 | })
--------------------------------------------------------------------------------
/day02-ES6+/12.函数参数默认值.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | Document
9 |
10 |
11 |
12 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/day13-登录注册/02.登录注册cookie权限控制/routers/regRouter.js:
--------------------------------------------------------------------------------
1 | const express = require("express");
2 |
3 | //创建一个router对象
4 | const router = new express.Router();
5 |
6 |
7 | //中间件函数封装
8 | function fn(req, res, next) {
9 | const {
10 | user,
11 | pass
12 | } = req.body;
13 |
14 | const userReg = /^[A-Z][A-Za-z0-9]{4,9}$/g;
15 | const passReg = /^\d{3,6}$/g;
16 | if (!userReg.test(user)) {
17 | return res.json({
18 | code: 10004,
19 | msg: "用户名应该是大写字母开头,后边字母数字,总共5-10位"
20 | })
21 | }
22 |
23 | if (!passReg.test(pass)) {
24 | return res.json({
25 | code: 10004,
26 | msg: "密码是3-6为的数字"
27 | })
28 | }
29 |
30 | next();
31 | }
32 |
33 | //正则验证中间件
34 | router.use("/login", fn)
35 | router.use("/register", fn)
36 |
37 | //把当前的router暴露出去
38 | module.exports = router;
--------------------------------------------------------------------------------
/day13-登录注册/03.登录注册session权限控制/routers/regRouter.js:
--------------------------------------------------------------------------------
1 | const express = require("express");
2 |
3 | //创建一个router对象
4 | const router = new express.Router();
5 |
6 |
7 | //中间件函数封装
8 | function fn(req, res, next) {
9 | const {
10 | user,
11 | pass
12 | } = req.body;
13 |
14 | const userReg = /^[A-Z][A-Za-z0-9]{4,9}$/g;
15 | const passReg = /^\d{3,6}$/g;
16 | if (!userReg.test(user)) {
17 | return res.json({
18 | code: 10004,
19 | msg: "用户名应该是大写字母开头,后边字母数字,总共5-10位"
20 | })
21 | }
22 |
23 | if (!passReg.test(pass)) {
24 | return res.json({
25 | code: 10004,
26 | msg: "密码是3-6为的数字"
27 | })
28 | }
29 |
30 | next();
31 | }
32 |
33 | //正则验证中间件
34 | router.use("/login", fn)
35 | router.use("/register", fn)
36 |
37 | //把当前的router暴露出去
38 | module.exports = router;
--------------------------------------------------------------------------------
/day07-node核心模块/06.fs/02.异步写入.js:
--------------------------------------------------------------------------------
1 | const fs = require("fs");
2 | const path = require("path");
3 |
4 | //文件路径
5 | const filePath = path.resolve(__dirname, "01.txt")
6 |
7 | //异步打开文件(回调函数的第一个参数是err,第二个参数是文件标识)
8 | fs.open(filePath, "a", (err, fd) => {
9 | //错误优先处理
10 | if (err) {
11 | console.log("err", err);
12 | return;
13 | }
14 |
15 | console.log(fd);
16 |
17 | //写入文件
18 | fs.write(fd, "汗滴禾下土", err => {
19 | if (err) {
20 | console.log("err", err)
21 | return;
22 | }
23 |
24 | console.log("文件写入成功");
25 |
26 |
27 | //关闭文件
28 | fs.close(fd, err => {
29 | if (err) {
30 | console.log("err", err);
31 | return;
32 | }
33 | console.log("文件关闭成功");
34 | })
35 | })
36 |
37 | })
38 |
39 | console.log("end");
--------------------------------------------------------------------------------
/day13-登录注册/04.强制缓存/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | Document
9 |
10 |
11 |
12 |
13 |
14 |
15 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/day11-ajax/06.请求拦截器/server.js:
--------------------------------------------------------------------------------
1 | const express = require("express");
2 | const app = express();
3 | const path = require("path")
4 |
5 |
6 | //登录get接口
7 | app.get("/login", (req, res) => {
8 | //拿到查询字符串
9 | const query = req.query;
10 | console.log(query);
11 |
12 |
13 | res.set("Access-Control-Allow-Origin", "*")
14 |
15 | //判断用户名和密码是否正确
16 | if (query.user === "laoli" && query.pass === '123456') {
17 | return res.json({
18 | code: 100001,
19 | msg: "登录成功",
20 | type: "GET"
21 | })
22 | }
23 |
24 | res.send({
25 | code: 100000,
26 | msg: "登录失败",
27 | type: "GET"
28 | })
29 | })
30 |
31 |
32 |
33 | app.listen("8888", (err) => {
34 | if (err) {
35 | console.log("服务器启动失败", err);
36 | return
37 | }
38 |
39 | console.log("服务器启动成功 http://192.168.19.35:8888")
40 | })
--------------------------------------------------------------------------------
/day03-ES6+/12.回调地狱.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | Document
9 |
10 |
11 |
12 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/day12-登录注册/project/html/register.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | Document
9 |
10 |
11 |
12 |
13 |
14 |
15 |

16 |
尚硅谷学生管理系统注册账号
17 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/day12-登录注册/01.登录注册模块划分/views/register.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | Document
9 |
10 |
11 |
12 |
13 |
14 |
15 |

16 |
尚硅谷学生管理系统注册账号
17 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/day12-登录注册/project/css/index.css:
--------------------------------------------------------------------------------
1 | * {
2 | margin: 0;
3 | padding: 0;
4 | }
5 |
6 | html,
7 | body {
8 | width: 100%;
9 | height: 100%;
10 | }
11 |
12 | .outer {
13 | height: 100%;
14 | background: url(../img/index.jpg) 0 0 no-repeat;
15 | background-size: cover;
16 | display: flex;
17 | justify-content: center;
18 | align-items: center;
19 |
20 | }
21 |
22 | .con {
23 | display: flex;
24 | justify-content: center;
25 | align-items: center;
26 | flex-direction: column;
27 | }
28 |
29 | .con h2 {
30 | color: #fff;
31 | font-size: 40px;
32 | margin: 30px 0;
33 | }
34 |
35 | .btns a {
36 | display: inline-block;
37 | width: 150px;
38 | height: 40px;
39 | background-color: rgba(255, 255, 255, .5);
40 | text-align: center;
41 | line-height: 40px;
42 | font-size: 20px;
43 | font-weight: bold;
44 | color: #333;
45 | text-decoration: none;
46 | }
--------------------------------------------------------------------------------
/day02-ES6+/11.Array的静态方法.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | Document
9 |
10 |
11 |
12 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/day03-ES6+/10.for.of.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | Document
9 |
10 |
11 |
12 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/day08-http课程/04.响应报文.js:
--------------------------------------------------------------------------------
1 | /*
2 | GET响应报文:
3 | //1.报文首行
4 | //协议版本 + 响应状态码 + 响应状态
5 | HTTP/1.1 200 OK
6 |
7 | //2.报文头
8 | //响应的数据格式
9 | Content-Type: application/json;charset=utf-8
10 | //响应的具体时间
11 | Date: Wed, 13 Oct 2021 03:28:22 GMT
12 | //保持长连接
13 | Connection: keep-alive
14 | //保持长连接的时间
15 | Keep-Alive: timeout=5
16 | //响应报文体的长度
17 | Content-Length: 31
18 |
19 | //3.报文空行
20 |
21 | //4.报文体
22 | {
23 | name: "laowang"
24 | }
25 |
26 | */
27 |
28 |
29 | /*
30 | POST响应报文:
31 | HTTP/1.1 200 OK
32 | Content-Type: application/json;charset=utf-8
33 | Date: Wed, 13 Oct 2021 03:24:17 GMT
34 | Connection: keep-alive
35 | Keep-Alive: timeout=5
36 | Content-Length: 31
37 |
38 | {
39 | name: "laowang"
40 | }
41 |
42 | */
--------------------------------------------------------------------------------
/day09-MongoDB/03.创建约束对象.js:
--------------------------------------------------------------------------------
1 | const mongoose = require("mongoose");
2 |
3 | //1.连接数据库
4 | mongoose.connect("mongodb://127.0.0.1:27017/class0722");
5 |
6 | //当数据库连接成功会触发mongoose.connection对象的open事件
7 | mongoose.connection.once("open", err => {
8 | if (err) {
9 | console.log("数据库连接失败", err);
10 | return;
11 | }
12 | console.log("数据库连接成功");
13 | })
14 |
15 |
16 | // 2.创建某个集合的约束对象
17 | const studentSchema = new mongoose.Schema({
18 | name: {
19 | type: String, //约束数据类型是String
20 | unique: true, //唯一的
21 | required: true, //必填项
22 | },
23 | age: Number, //直接约束数据类型
24 | sex: String,
25 | hobby: [String], //直接约束hobby的值是一个数组,数组的值必须是字符串
26 | createTime: {
27 | type: Date,
28 | default: Date.now
29 | }
30 | })
31 |
32 | console.log(studentSchema);
33 |
34 |
35 | //3.根据约束对象创建对应的集合
36 | const studentModel = mongoose.model("student", studentSchema);
37 | console.log(studentModel);
--------------------------------------------------------------------------------
/day12-登录注册/01.登录注册模块划分/public/css/index.css:
--------------------------------------------------------------------------------
1 | * {
2 | margin: 0;
3 | padding: 0;
4 | }
5 |
6 | html,
7 | body {
8 | width: 100%;
9 | height: 100%;
10 | }
11 |
12 | .outer {
13 | height: 100%;
14 | background: url('/public/img/index.jpg') 0 0 no-repeat;
15 | background-size: cover;
16 | display: flex;
17 | justify-content: center;
18 | align-items: center;
19 |
20 | }
21 |
22 | .con {
23 | display: flex;
24 | justify-content: center;
25 | align-items: center;
26 | flex-direction: column;
27 | }
28 |
29 | .con h2 {
30 | color: #fff;
31 | font-size: 40px;
32 | margin: 30px 0;
33 | }
34 |
35 | .btns a {
36 | display: inline-block;
37 | width: 150px;
38 | height: 40px;
39 | background-color: rgba(255, 255, 255, .5);
40 | text-align: center;
41 | line-height: 40px;
42 | font-size: 20px;
43 | font-weight: bold;
44 | color: #333;
45 | text-decoration: none;
46 | }
--------------------------------------------------------------------------------
/day12-登录注册/02.接口书写/public/css/index.css:
--------------------------------------------------------------------------------
1 | * {
2 | margin: 0;
3 | padding: 0;
4 | }
5 |
6 | html,
7 | body {
8 | width: 100%;
9 | height: 100%;
10 | }
11 |
12 | .outer {
13 | height: 100%;
14 | background: url('/public/img/index.jpg') 0 0 no-repeat;
15 | background-size: cover;
16 | display: flex;
17 | justify-content: center;
18 | align-items: center;
19 |
20 | }
21 |
22 | .con {
23 | display: flex;
24 | justify-content: center;
25 | align-items: center;
26 | flex-direction: column;
27 | }
28 |
29 | .con h2 {
30 | color: #fff;
31 | font-size: 40px;
32 | margin: 30px 0;
33 | }
34 |
35 | .btns a {
36 | display: inline-block;
37 | width: 150px;
38 | height: 40px;
39 | background-color: rgba(255, 255, 255, .5);
40 | text-align: center;
41 | line-height: 40px;
42 | font-size: 20px;
43 | font-weight: bold;
44 | color: #333;
45 | text-decoration: none;
46 | }
--------------------------------------------------------------------------------
/day12-登录注册/03.路由管理/public/css/index.css:
--------------------------------------------------------------------------------
1 | * {
2 | margin: 0;
3 | padding: 0;
4 | }
5 |
6 | html,
7 | body {
8 | width: 100%;
9 | height: 100%;
10 | }
11 |
12 | .outer {
13 | height: 100%;
14 | background: url('/public/img/index.jpg') 0 0 no-repeat;
15 | background-size: cover;
16 | display: flex;
17 | justify-content: center;
18 | align-items: center;
19 |
20 | }
21 |
22 | .con {
23 | display: flex;
24 | justify-content: center;
25 | align-items: center;
26 | flex-direction: column;
27 | }
28 |
29 | .con h2 {
30 | color: #fff;
31 | font-size: 40px;
32 | margin: 30px 0;
33 | }
34 |
35 | .btns a {
36 | display: inline-block;
37 | width: 150px;
38 | height: 40px;
39 | background-color: rgba(255, 255, 255, .5);
40 | text-align: center;
41 | line-height: 40px;
42 | font-size: 20px;
43 | font-weight: bold;
44 | color: #333;
45 | text-decoration: none;
46 | }
--------------------------------------------------------------------------------
/day02-ES6+/13.函数的rest参数.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | Document
9 |
10 |
11 |
12 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/day11-ajax/03.jsonp/server.js:
--------------------------------------------------------------------------------
1 | const express = require("express");
2 | const app = express();
3 |
4 | //登录get接口
5 | app.get("/login", (req, res) => {
6 | //拿到查询字符串
7 | const query = req.query;
8 | console.log(query);
9 |
10 | //判断用户名和密码是否正确
11 | if (query.user === "laoli" && query.pass === '123456') {
12 | const data = {
13 | code: 100001,
14 | msg: "登录成功",
15 | type: "GET"
16 | }
17 | //响应一段js代码,js代码的内容是调用了回调函数,并传入数据作为参数
18 | return res.send(`${query.callback}(${JSON.stringify(data)})`)
19 | }
20 |
21 | const data = {
22 | code: 10000,
23 | msg: "登录失败",
24 | type: "GET"
25 | }
26 | res.send(`${query.callback}(${JSON.stringify(data)})`)
27 | })
28 |
29 | app.listen("8888", (err) => {
30 | if (err) {
31 | console.log("服务器启动失败", err);
32 | return
33 | }
34 |
35 | console.log("服务器启动成功 http://192.168.19.35:8888")
36 | })
--------------------------------------------------------------------------------
/day13-登录注册/02.登录注册cookie权限控制/public/css/index.css:
--------------------------------------------------------------------------------
1 | * {
2 | margin: 0;
3 | padding: 0;
4 | }
5 |
6 | html,
7 | body {
8 | width: 100%;
9 | height: 100%;
10 | }
11 |
12 | .outer {
13 | height: 100%;
14 | background: url('/public/img/index.jpg') 0 0 no-repeat;
15 | background-size: cover;
16 | display: flex;
17 | justify-content: center;
18 | align-items: center;
19 |
20 | }
21 |
22 | .con {
23 | display: flex;
24 | justify-content: center;
25 | align-items: center;
26 | flex-direction: column;
27 | }
28 |
29 | .con h2 {
30 | color: #fff;
31 | font-size: 40px;
32 | margin: 30px 0;
33 | }
34 |
35 | .btns a {
36 | display: inline-block;
37 | width: 150px;
38 | height: 40px;
39 | background-color: rgba(255, 255, 255, .5);
40 | text-align: center;
41 | line-height: 40px;
42 | font-size: 20px;
43 | font-weight: bold;
44 | color: #333;
45 | text-decoration: none;
46 | }
--------------------------------------------------------------------------------
/day13-登录注册/03.登录注册session权限控制/public/css/index.css:
--------------------------------------------------------------------------------
1 | * {
2 | margin: 0;
3 | padding: 0;
4 | }
5 |
6 | html,
7 | body {
8 | width: 100%;
9 | height: 100%;
10 | }
11 |
12 | .outer {
13 | height: 100%;
14 | background: url('/public/img/index.jpg') 0 0 no-repeat;
15 | background-size: cover;
16 | display: flex;
17 | justify-content: center;
18 | align-items: center;
19 |
20 | }
21 |
22 | .con {
23 | display: flex;
24 | justify-content: center;
25 | align-items: center;
26 | flex-direction: column;
27 | }
28 |
29 | .con h2 {
30 | color: #fff;
31 | font-size: 40px;
32 | margin: 30px 0;
33 | }
34 |
35 | .btns a {
36 | display: inline-block;
37 | width: 150px;
38 | height: 40px;
39 | background-color: rgba(255, 255, 255, .5);
40 | text-align: center;
41 | line-height: 40px;
42 | font-size: 20px;
43 | font-weight: bold;
44 | color: #333;
45 | text-decoration: none;
46 | }
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "goat0722",
3 | "version": "1.0.0",
4 | "description": "- `https://gitee.com/nowletsgo/goat0722.git` gitee地址\r - `https://github.com/nowLetsgo/goat0722.git` github地址",
5 | "main": "index.js",
6 | "scripts": {
7 | "test": "echo \"Error: no test specified\" && exit 1"
8 | },
9 | "repository": {
10 | "type": "git",
11 | "url": "git@gitee.com:nowletsgo/goat0722.git"
12 | },
13 | "keywords": [],
14 | "author": "",
15 | "license": "ISC",
16 | "dependencies": {
17 | "connect-mongo": "^4.6.0",
18 | "cookie-parser": "^1.4.5",
19 | "etag": "^1.8.1",
20 | "express": "^4.17.1",
21 | "express-session": "^1.17.2",
22 | "md5": "^2.3.0",
23 | "mongoose": "^6.0.10"
24 | },
25 | "devDependencies": {
26 | "@babel/cli": "^7.15.7",
27 | "@babel/core": "^7.15.8",
28 | "@babel/preset-env": "^7.15.8"
29 | },
30 | "babel": {
31 | "presets": [
32 | "@babel/env"
33 | ]
34 | }
35 | }
--------------------------------------------------------------------------------
/day16-promise手写/01.promise构造函数.js:
--------------------------------------------------------------------------------
1 | function MyPromise(exector) {
2 | //保存当前this
3 | const _this = this;
4 |
5 | //MyPromise构造函数返回一个promise对象,拥有state和result属性
6 | //构造函数被实例化调用的时候本身就返回一个实例化对象
7 | //所以直接给this扩展state和result属性即可(构造函数的this指向实例化对象)
8 | _this.state = "pending";
9 | _this.result = undefined;
10 |
11 | function resolve(value) {
12 | //promise的状态只能由pending变成其他状态,否则将不会改变状态
13 | if (_this.state !== "pending") return;
14 |
15 | //当调用resolve的时候,改变MyPromise实例化对象的状态和值
16 | _this.state = "fulfilled";
17 | _this.result = value;
18 | }
19 |
20 | function reject(reason) {
21 | //promise的状态只能由pending变成其他状态,否则将不会改变状态
22 | if (_this.state !== "pending") return;
23 |
24 | //当调用reject的时候,改变MyPromise实例化对象的状态和值
25 | _this.state = "rejected";
26 | _this.result = reason;
27 | }
28 |
29 | //实例化构造函数的时候,会传递一个函数作为参数,我们内部要调用这个参数,并传入两个函数作为实参
30 | exector(resolve, reject);
31 | }
--------------------------------------------------------------------------------
/day14-gulp/01.module/01.没有模块化的时候/index.js:
--------------------------------------------------------------------------------
1 | /*
2 | 模块化最初的书写方式:
3 | 模块其实就是一个独立的功能
4 | 把功能封装在函数中,不同的函数就是模块
5 | 但是这种方式会出现函数命名冲突
6 |
7 | */
8 | function random() {
9 | //模块1
10 | }
11 |
12 | function sort() {
13 | //模块2
14 | }
15 |
16 | function checkType() {
17 | //模块3
18 | }
19 |
20 |
21 | /*
22 | 对象模块写法
23 | 把模块写成一个对象,所有模块的成员都在这个对象中
24 | 可能会被外部操作my的内容成员信息
25 |
26 | */
27 |
28 | const my = {
29 | num: 0,
30 | add() {
31 | //模块1
32 | },
33 | mins() {
34 | //模块2
35 | }
36 | }
37 |
38 | my.add();
39 |
40 |
41 | /*
42 | IIFE的写法
43 | 可以不暴露私有成员
44 |
45 |
46 | */
47 |
48 | const module1 = (function () {
49 | let num = 0;
50 | const timer1 = null;
51 |
52 | function add() {
53 |
54 | }
55 |
56 | function mins() {
57 |
58 | }
59 | return {
60 | add,
61 | mins
62 | }
63 | })()
64 |
65 | //使用
66 | const {
67 | add,
68 | mins
69 | } = module1;
--------------------------------------------------------------------------------
/day11-ajax/07.取消请求/server.js:
--------------------------------------------------------------------------------
1 | const express = require("express");
2 | const app = express();
3 | const path = require("path")
4 |
5 |
6 | //登录get接口
7 | app.get("/login", (req, res) => {
8 | setTimeout(() => {
9 | //拿到查询字符串
10 | const query = req.query;
11 | console.log(query);
12 |
13 |
14 | res.set("Access-Control-Allow-Origin", "*")
15 |
16 | //判断用户名和密码是否正确
17 | if (query.user === "laoli" && query.pass === '123456') {
18 | return res.json({
19 | code: 100001,
20 | msg: "登录成功",
21 | type: "GET"
22 | })
23 | }
24 |
25 | res.send({
26 | code: 100000,
27 | msg: "登录失败",
28 | type: "GET"
29 | })
30 | }, 5000)
31 | })
32 |
33 |
34 |
35 | app.listen("8888", (err) => {
36 | if (err) {
37 | console.log("服务器启动失败", err);
38 | return
39 | }
40 |
41 | console.log("服务器启动成功 http://192.168.19.35:8888")
42 | })
--------------------------------------------------------------------------------
/day01-ES5+/05.Object.create创建对象 copy.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | Document
9 |
10 |
11 |
12 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/day15-webpack/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "webpack-test",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "webpack.config.js",
6 | "scripts": {
7 | "dev": "webpack serve --config ./config/webpack.config.dev.js",
8 | "build": "webpack --config ./config/webpack.config.prod.js"
9 | },
10 | "keywords": [],
11 | "author": "",
12 | "license": "ISC",
13 | "devDependencies": {
14 | "@babel/core": "^7.15.8",
15 | "@babel/preset-env": "^7.15.8",
16 | "babel-loader": "^8.2.3",
17 | "css-loader": "^6.4.0",
18 | "css-minimizer-webpack-plugin": "^3.1.1",
19 | "eslint": "^8.0.1",
20 | "eslint-webpack-plugin": "^3.0.1",
21 | "html-webpack-plugin": "^5.4.0",
22 | "less": "^4.1.2",
23 | "less-loader": "^10.2.0",
24 | "mini-css-extract-plugin": "^2.4.3",
25 | "style-loader": "^3.3.1",
26 | "webpack": "^5.59.1",
27 | "webpack-cli": "^4.9.1",
28 | "webpack-dev-server": "^4.3.1"
29 | },
30 | "browserslist": [
31 | "> 1%",
32 | "last 2 versions"
33 | ]
34 | }
35 |
--------------------------------------------------------------------------------
/复习/02.绑定事件.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | Document
9 |
10 |
11 |
12 |
13 | hello
14 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/day17-react01/01.我的第一个React.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | Document
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/day18-react02/01.不是函数式组件案例.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | Document
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/day05-promise/06.async和await.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | Document
9 |
10 |
11 |
12 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/day17-react01/02.jsx方式创建虚拟DOM.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | Document
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 | 123
22 | 12
23 |
24 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/day02-ES6+/10.数组的扩展运算符.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | Document
9 |
10 |
11 |
12 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/day03-ES6+/02.Object静态方法.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | Document
9 |
10 |
11 |
12 |
43 |
44 |
45 |
--------------------------------------------------------------------------------
/day12-登录注册/03.路由管理/index.js:
--------------------------------------------------------------------------------
1 | const express = require("express");
2 | const app = express();
3 | const path = require("path")
4 |
5 | //连接数据库 及引入数据库的集合信息
6 | require("./db")
7 |
8 | //1.官方的静态资源中间件(服务器上的文件响应)
9 | //暴露views中的静态文件,直接可以在服务器的地址栏后添加对应的静态资源路径即可访问
10 | app.use(express.static(path.resolve(__dirname, "./views")))
11 | //暴露public中的静态文件,但是做了路径限制,在服务器地址后添加/public/+静态资源路径即可访问
12 | app.use("/public/", express.static(path.resolve(__dirname, "./public")))
13 |
14 | //2.处理post请求报文体的中间件(把报文体的内容放在req.body上)
15 | app.use("", express.urlencoded({
16 | extended: false
17 | }))
18 | app.use(express.json());
19 |
20 |
21 | //3.引入外部的功能路由模块
22 | const regRouter = require("./routers/regRouter");
23 | const loginRouter = require("./routers/loginRouter");
24 | const registerRouter = require("./routers/registerRouter");
25 |
26 | //4.把路由挂载在app上
27 | app.use(regRouter);
28 | app.use(loginRouter);
29 | app.use(registerRouter);
30 |
31 |
32 |
33 | app.listen("8888", err => {
34 | if (err) {
35 | console.log("服务端错误", err);
36 | return;
37 | }
38 | console.log("服务端启动成功 http://192.168.19.38:8888");
39 | })
--------------------------------------------------------------------------------
/day00-git/git练习.md:
--------------------------------------------------------------------------------
1 | 1. 项目经理要研发一个新的项目,首先初始化了项目解构和一个本地仓库,创建了两个分支,xiaowang和xiaoli,协同开发,并推送至远程仓库
2 |
3 | - `git init 仓库名`
4 | - `cd 仓库名`
5 | - `git add .`,`git commit -m '初始化'`:创建项目架构 并提交本地仓库
6 | - `git branch xiaowang`,`git branch xiaoli`:创建两个分支
7 | - `git remote add origin 远程地址`:把本地仓库和远程仓库关联
8 | - `git push -u origin --all`:把本地仓库推送至远程仓库
9 |
10 |
11 |
12 |
13 |
14 | 3. xiaoli开始第一天上班,拉取分支并开始工作
15 | - `git pull origin xiaoli:xiaoli`
16 | - `git checkout xiaoli`
17 | 4. xiaoli工作完成推送自己的分支到远程仓库
18 | - `git add .`,`git commit -m 'XXX'`:先本地提交
19 | - `git push -u origin xiaoli`:远程推送
20 |
21 |
22 |
23 | 5. xiaowang开始第一天上班,拉取分支并开始工作(和小李一样)
24 | 6. xiaowang工作完成推送自己的分支到远程仓库(和小李一样)
25 |
26 |
27 |
28 | 7. 项目经理合并xiaowang和xiaoli两个分支的内容,并完成当天的开发,更新远程仓库
29 | - 如果在master分支拉取其他分支,则会自动的合并到当前分支
30 | - 如果在当前分支拉取当前分支的更新,则不会合并到其他,需要手动合并到其他
31 | - `git pull origin xiaowang`
32 | - `git pull origin xiaoli`
33 | - 都合并到master后可能需要解决冲突,解决冲突后需要先提交到本地仓库
34 | - 推送已经合并好的master到远程仓库
35 |
36 |
37 |
38 | 8. 小李第二天开始上班开始工作
39 | - 在自己的分支上拉取master的更新并合并到自己的分支
40 | - `git pull origin master`
41 | 9. 小王第二天上班开始工作(和xiaoli一样)
--------------------------------------------------------------------------------
/day06-node01/01.nodeJS轮询机制.js:
--------------------------------------------------------------------------------
1 | /*
2 | nodeJS事件轮询机制:
3 | - JavaScript是单线程的, 那么nodejs是如何做到非阻塞呢,在nodejs内部使用了第三方库libuv,nodejs会把I/O等异步操作交由他处理,而nodejs主线程可以继续去处理其他的事情。
4 |
5 | - libuv会开启不同的线程去处理这些异步操作,处理完后,会把异步操作的回调函数放到nodejs的轮询队列中,nodejs会在适当的时候处理轮询队列中的回调函数,从而实现非阻塞。
6 |
7 | - nodeJS的轮询队列分为6个阶段,每个阶段都有一个 FIFO(先进先出) 队列来执行回调。通常情况下,当事件循环进入给定的阶段时,它将执行特定于该阶段的任何操作,然后在该阶段的队列中执行回调,直到队列用尽或最大回调数已执行。当该队列已用尽或达到回调限制,事件循环将移动到下一阶段
8 |
9 | - 六个阶段如下
10 | 1. timers阶段
11 | timers阶段用来处理setTimeout() 和 setInterval() 的回调函数
12 | 2. pending callbacks
13 | 这个阶段用来处理系统操作的回调函数(可以忽略)
14 | 3. idle prepare
15 | 此阶段是仅供nodejs内部操作调用,忽略
16 | 4. poll阶段
17 | 概述: 这个阶段主要用来处理如IO操作,网络请求等异步操作
18 | - 当进入poll阶段的时候,如果poll阶段不为空,则执行完或者到达最大执行数量,就会进入下一个阶段
19 | - 当进入poll阶段的时候,如果pll阶段为空,则一直等着回调函数进来,除非check阶段或者timers阶段有回调函数等待执行,才会进入下个阶段
20 |
21 | 5. check阶段
22 | 这个阶段用来处理setImmediate的回调函数
23 |
24 | 6. close callbacks阶段
25 | 概述: 这个阶段用来处理如socket的close类似的关闭事件
26 |
27 |
28 | */
--------------------------------------------------------------------------------
/day21-react05/脚手架.md:
--------------------------------------------------------------------------------
1 | # React脚手架
2 |
3 | ## 1. 什么是脚手架
4 |
5 | 1. xxx脚手架: 用来帮助程序员快速创建一个基于xxx库的模板项目
6 | 2. 包含了所有需要的配置(语法检查、jsx编译、devServer…)
7 | 3. 下载好了所有相关的依赖
8 | 4. 可以直接运行一个简单效果
9 | 5. react提供了一个用于创建react项目的脚手架库: create-react-app
10 | 6. 项目的整体技术架构为: react + webpack + es6 + eslint
11 | 7. 使用脚手架开发的项目的特点: 模块化, 组件化, 工程化
12 |
13 | ## 2. 创建react应用
14 |
15 | ### 2.1 创建项目并启动
16 |
17 | - 切换到想创项目的目录,使用命令:npx create-react-app hello
18 | - 进入项目文件夹:cd hello
19 | - 启动项目:npm start
20 |
21 | ### 2.2 react脚手架项目结构
22 |
23 | - public ---- 静态资源文件夹
24 | - favicon.icon ------ 网站页签图标
25 | - ***\*index.html\**** ***\*--------\**** ***\*主页面\****
26 | - logo192.png ------- logo图
27 | - logo512.png ------- logo图
28 | - manifest.json ----- 应用加壳的配置文件
29 | - robots.txt -------- 爬虫协议文件
30 | - src ---- 源码文件夹
31 | - App.css -------- App组件的样式
32 | - ***\*App.js\**** ***\*---------\**** ***\*App组件\****
33 | - App.test.js ---- 用于给App做测试
34 | - index.css ------ 样式
35 | - ***\*index.js\**** ***\*-\*******\*------\**** ***\*入口文件\*
36 | - logo.svg ------- logo图
37 | - reportWebVitals.js--- 页面性能分析文件(需要web-vitals库的支持)
38 | - setupTests.js---- 组件单元测试的文件(需要jest-dom库的支持)
--------------------------------------------------------------------------------
/day17-react01/03.纯js方式创建虚拟DOM.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | Document
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/day12-登录注册/project/css/login.css:
--------------------------------------------------------------------------------
1 | * {
2 | margin: 0;
3 | padding: 0;
4 | }
5 |
6 | html,
7 | body {
8 | width: 100%;
9 | height: 100%;
10 | }
11 |
12 | .outer {
13 | height: 100%;
14 | background: url(../img/index.jpg) 0 0 no-repeat;
15 | background-size: cover;
16 | display: flex;
17 | justify-content: center;
18 | align-items: center;
19 |
20 | }
21 |
22 | .con {
23 | display: flex;
24 | justify-content: center;
25 | align-items: center;
26 | flex-direction: column;
27 | }
28 |
29 | .con h2 {
30 | color: #fff;
31 | font-size: 40px;
32 | margin: 30px 0;
33 | }
34 |
35 | .ipts {
36 | display: flex;
37 | flex-direction: column;
38 | }
39 |
40 | .ipts input {
41 | box-sizing: border-box;
42 | width: 400px;
43 | height: 50px;
44 | font-size: 18px;
45 | background-color: transparent;
46 | color: #fff;
47 | border: 1px solid #fff;
48 | padding: 0 10px;
49 | margin-bottom: 10px;
50 | }
51 |
52 | #btn {
53 | width: 400px;
54 | height: 50px;
55 | background-color: rgba(255, 255, 255, .7);
56 | box-sizing: border-box;
57 | border: 1px solid #fff;
58 | }
--------------------------------------------------------------------------------
/day12-登录注册/project/css/register.css:
--------------------------------------------------------------------------------
1 | * {
2 | margin: 0;
3 | padding: 0;
4 | }
5 |
6 | html,
7 | body {
8 | width: 100%;
9 | height: 100%;
10 | }
11 |
12 | .outer {
13 | height: 100%;
14 | background: url(../img/index.jpg) 0 0 no-repeat;
15 | background-size: cover;
16 | display: flex;
17 | justify-content: center;
18 | align-items: center;
19 |
20 | }
21 |
22 | .con {
23 | display: flex;
24 | justify-content: center;
25 | align-items: center;
26 | flex-direction: column;
27 | }
28 |
29 | .con h2 {
30 | color: #fff;
31 | font-size: 40px;
32 | margin: 30px 0;
33 | }
34 |
35 | .ipts {
36 | display: flex;
37 | flex-direction: column;
38 | }
39 |
40 | .ipts input {
41 | box-sizing: border-box;
42 | width: 400px;
43 | height: 50px;
44 | font-size: 18px;
45 | background-color: transparent;
46 | color: #fff;
47 | border: 1px solid #fff;
48 | padding: 0 10px;
49 | margin-bottom: 10px;
50 | }
51 |
52 | #btn {
53 | width: 400px;
54 | height: 50px;
55 | background-color: rgba(255, 255, 255, .7);
56 | box-sizing: border-box;
57 | border: 1px solid #fff;
58 | }
--------------------------------------------------------------------------------
/day02-ES6+/03.for循环的let.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | Document
9 |
10 |
11 |
12 |
45 |
46 |
47 |
--------------------------------------------------------------------------------
/day13-登录注册/04.强制缓存/server.js:
--------------------------------------------------------------------------------
1 | const express = require("express");
2 | const app = express();
3 | const path = require("path");
4 | const fs = require("fs");
5 |
6 | app.get("/", (req, res) => {
7 | const filePath = path.resolve(__dirname, "./index.html");
8 | const rs = fs.createReadStream(filePath);
9 | rs.pipe(res)
10 | })
11 |
12 | app.get("/img", (req, res) => {
13 | const filePath = path.resolve(__dirname, "./01.jpg");
14 | const rs = fs.createReadStream(filePath);
15 | /*
16 | 强制缓存:
17 | - 强制缓存是向浏览器缓存查找请求结果,并根据请求结果来决定我们是否可以使用缓存的过程
18 | - 简单来讲,就是浏览器直接使用自己的缓存,不进行任何的请求
19 | - 强制缓存的设置过程
20 | - 客户端请求的时候,需要携带 Cache-Control请求头字段,值是 max-age=XXXX(秒数)
21 | - 服务端响应的时候,也需要携带 Cache-Contorl的响应头字段,值是max-age=XXXX(秒数)
22 | - 当下次再次请求的时候,判断自己是否符合强制缓存条件,如果符合,则直接读取缓存,如果不符合,则会走协商缓存
23 |
24 |
25 |
26 | */
27 | res.set("Cache-Control", "max-age=1000")
28 | rs.pipe(res)
29 | })
30 |
31 | app.listen(8888, err => {
32 | if (err) {
33 | console.log(err);
34 | return
35 | }
36 |
37 | console.log("服务器启动成功 http://192.168.19.38:8888")
38 | })
--------------------------------------------------------------------------------
/day12-登录注册/01.登录注册模块划分/public/css/login.css:
--------------------------------------------------------------------------------
1 | * {
2 | margin: 0;
3 | padding: 0;
4 | }
5 |
6 | html,
7 | body {
8 | width: 100%;
9 | height: 100%;
10 | }
11 |
12 | .outer {
13 | height: 100%;
14 | background: url(/public/img/index.jpg) 0 0 no-repeat;
15 | background-size: cover;
16 | display: flex;
17 | justify-content: center;
18 | align-items: center;
19 |
20 | }
21 |
22 | .con {
23 | display: flex;
24 | justify-content: center;
25 | align-items: center;
26 | flex-direction: column;
27 | }
28 |
29 | .con h2 {
30 | color: #fff;
31 | font-size: 40px;
32 | margin: 30px 0;
33 | }
34 |
35 | .ipts {
36 | display: flex;
37 | flex-direction: column;
38 | }
39 |
40 | .ipts input {
41 | box-sizing: border-box;
42 | width: 400px;
43 | height: 50px;
44 | font-size: 18px;
45 | background-color: transparent;
46 | color: #fff;
47 | border: 1px solid #fff;
48 | padding: 0 10px;
49 | margin-bottom: 10px;
50 | }
51 |
52 | #btn {
53 | width: 400px;
54 | height: 50px;
55 | background-color: rgba(255, 255, 255, .7);
56 | box-sizing: border-box;
57 | border: 1px solid #fff;
58 | }
--------------------------------------------------------------------------------
/day12-登录注册/02.接口书写/public/css/login.css:
--------------------------------------------------------------------------------
1 | * {
2 | margin: 0;
3 | padding: 0;
4 | }
5 |
6 | html,
7 | body {
8 | width: 100%;
9 | height: 100%;
10 | }
11 |
12 | .outer {
13 | height: 100%;
14 | background: url(/public/img/index.jpg) 0 0 no-repeat;
15 | background-size: cover;
16 | display: flex;
17 | justify-content: center;
18 | align-items: center;
19 |
20 | }
21 |
22 | .con {
23 | display: flex;
24 | justify-content: center;
25 | align-items: center;
26 | flex-direction: column;
27 | }
28 |
29 | .con h2 {
30 | color: #fff;
31 | font-size: 40px;
32 | margin: 30px 0;
33 | }
34 |
35 | .ipts {
36 | display: flex;
37 | flex-direction: column;
38 | }
39 |
40 | .ipts input {
41 | box-sizing: border-box;
42 | width: 400px;
43 | height: 50px;
44 | font-size: 18px;
45 | background-color: transparent;
46 | color: #fff;
47 | border: 1px solid #fff;
48 | padding: 0 10px;
49 | margin-bottom: 10px;
50 | }
51 |
52 | #btn {
53 | width: 400px;
54 | height: 50px;
55 | background-color: rgba(255, 255, 255, .7);
56 | box-sizing: border-box;
57 | border: 1px solid #fff;
58 | }
--------------------------------------------------------------------------------
/day12-登录注册/02.接口书写/public/css/register.css:
--------------------------------------------------------------------------------
1 | * {
2 | margin: 0;
3 | padding: 0;
4 | }
5 |
6 | html,
7 | body {
8 | width: 100%;
9 | height: 100%;
10 | }
11 |
12 | .outer {
13 | height: 100%;
14 | background: url(/public/img/index.jpg) 0 0 no-repeat;
15 | background-size: cover;
16 | display: flex;
17 | justify-content: center;
18 | align-items: center;
19 |
20 | }
21 |
22 | .con {
23 | display: flex;
24 | justify-content: center;
25 | align-items: center;
26 | flex-direction: column;
27 | }
28 |
29 | .con h2 {
30 | color: #fff;
31 | font-size: 40px;
32 | margin: 30px 0;
33 | }
34 |
35 | .ipts {
36 | display: flex;
37 | flex-direction: column;
38 | }
39 |
40 | .ipts input {
41 | box-sizing: border-box;
42 | width: 400px;
43 | height: 50px;
44 | font-size: 18px;
45 | background-color: transparent;
46 | color: #fff;
47 | border: 1px solid #fff;
48 | padding: 0 10px;
49 | margin-bottom: 10px;
50 | }
51 |
52 | #btn {
53 | width: 400px;
54 | height: 50px;
55 | background-color: rgba(255, 255, 255, .7);
56 | box-sizing: border-box;
57 | border: 1px solid #fff;
58 | }
--------------------------------------------------------------------------------
/day12-登录注册/03.路由管理/public/css/login.css:
--------------------------------------------------------------------------------
1 | * {
2 | margin: 0;
3 | padding: 0;
4 | }
5 |
6 | html,
7 | body {
8 | width: 100%;
9 | height: 100%;
10 | }
11 |
12 | .outer {
13 | height: 100%;
14 | background: url(/public/img/index.jpg) 0 0 no-repeat;
15 | background-size: cover;
16 | display: flex;
17 | justify-content: center;
18 | align-items: center;
19 |
20 | }
21 |
22 | .con {
23 | display: flex;
24 | justify-content: center;
25 | align-items: center;
26 | flex-direction: column;
27 | }
28 |
29 | .con h2 {
30 | color: #fff;
31 | font-size: 40px;
32 | margin: 30px 0;
33 | }
34 |
35 | .ipts {
36 | display: flex;
37 | flex-direction: column;
38 | }
39 |
40 | .ipts input {
41 | box-sizing: border-box;
42 | width: 400px;
43 | height: 50px;
44 | font-size: 18px;
45 | background-color: transparent;
46 | color: #fff;
47 | border: 1px solid #fff;
48 | padding: 0 10px;
49 | margin-bottom: 10px;
50 | }
51 |
52 | #btn {
53 | width: 400px;
54 | height: 50px;
55 | background-color: rgba(255, 255, 255, .7);
56 | box-sizing: border-box;
57 | border: 1px solid #fff;
58 | }
--------------------------------------------------------------------------------
/day12-登录注册/03.路由管理/public/css/register.css:
--------------------------------------------------------------------------------
1 | * {
2 | margin: 0;
3 | padding: 0;
4 | }
5 |
6 | html,
7 | body {
8 | width: 100%;
9 | height: 100%;
10 | }
11 |
12 | .outer {
13 | height: 100%;
14 | background: url(/public/img/index.jpg) 0 0 no-repeat;
15 | background-size: cover;
16 | display: flex;
17 | justify-content: center;
18 | align-items: center;
19 |
20 | }
21 |
22 | .con {
23 | display: flex;
24 | justify-content: center;
25 | align-items: center;
26 | flex-direction: column;
27 | }
28 |
29 | .con h2 {
30 | color: #fff;
31 | font-size: 40px;
32 | margin: 30px 0;
33 | }
34 |
35 | .ipts {
36 | display: flex;
37 | flex-direction: column;
38 | }
39 |
40 | .ipts input {
41 | box-sizing: border-box;
42 | width: 400px;
43 | height: 50px;
44 | font-size: 18px;
45 | background-color: transparent;
46 | color: #fff;
47 | border: 1px solid #fff;
48 | padding: 0 10px;
49 | margin-bottom: 10px;
50 | }
51 |
52 | #btn {
53 | width: 400px;
54 | height: 50px;
55 | background-color: rgba(255, 255, 255, .7);
56 | box-sizing: border-box;
57 | border: 1px solid #fff;
58 | }
--------------------------------------------------------------------------------
/day12-登录注册/01.登录注册模块划分/public/css/register.css:
--------------------------------------------------------------------------------
1 | * {
2 | margin: 0;
3 | padding: 0;
4 | }
5 |
6 | html,
7 | body {
8 | width: 100%;
9 | height: 100%;
10 | }
11 |
12 | .outer {
13 | height: 100%;
14 | background: url(/public/img/index.jpg) 0 0 no-repeat;
15 | background-size: cover;
16 | display: flex;
17 | justify-content: center;
18 | align-items: center;
19 |
20 | }
21 |
22 | .con {
23 | display: flex;
24 | justify-content: center;
25 | align-items: center;
26 | flex-direction: column;
27 | }
28 |
29 | .con h2 {
30 | color: #fff;
31 | font-size: 40px;
32 | margin: 30px 0;
33 | }
34 |
35 | .ipts {
36 | display: flex;
37 | flex-direction: column;
38 | }
39 |
40 | .ipts input {
41 | box-sizing: border-box;
42 | width: 400px;
43 | height: 50px;
44 | font-size: 18px;
45 | background-color: transparent;
46 | color: #fff;
47 | border: 1px solid #fff;
48 | padding: 0 10px;
49 | margin-bottom: 10px;
50 | }
51 |
52 | #btn {
53 | width: 400px;
54 | height: 50px;
55 | background-color: rgba(255, 255, 255, .7);
56 | box-sizing: border-box;
57 | border: 1px solid #fff;
58 | }
--------------------------------------------------------------------------------
/day13-登录注册/02.登录注册cookie权限控制/public/css/login.css:
--------------------------------------------------------------------------------
1 | * {
2 | margin: 0;
3 | padding: 0;
4 | }
5 |
6 | html,
7 | body {
8 | width: 100%;
9 | height: 100%;
10 | }
11 |
12 | .outer {
13 | height: 100%;
14 | background: url(/public/img/index.jpg) 0 0 no-repeat;
15 | background-size: cover;
16 | display: flex;
17 | justify-content: center;
18 | align-items: center;
19 |
20 | }
21 |
22 | .con {
23 | display: flex;
24 | justify-content: center;
25 | align-items: center;
26 | flex-direction: column;
27 | }
28 |
29 | .con h2 {
30 | color: #fff;
31 | font-size: 40px;
32 | margin: 30px 0;
33 | }
34 |
35 | .ipts {
36 | display: flex;
37 | flex-direction: column;
38 | }
39 |
40 | .ipts input {
41 | box-sizing: border-box;
42 | width: 400px;
43 | height: 50px;
44 | font-size: 18px;
45 | background-color: transparent;
46 | color: #fff;
47 | border: 1px solid #fff;
48 | padding: 0 10px;
49 | margin-bottom: 10px;
50 | }
51 |
52 | #btn {
53 | width: 400px;
54 | height: 50px;
55 | background-color: rgba(255, 255, 255, .7);
56 | box-sizing: border-box;
57 | border: 1px solid #fff;
58 | }
--------------------------------------------------------------------------------
/day13-登录注册/02.登录注册cookie权限控制/public/css/register.css:
--------------------------------------------------------------------------------
1 | * {
2 | margin: 0;
3 | padding: 0;
4 | }
5 |
6 | html,
7 | body {
8 | width: 100%;
9 | height: 100%;
10 | }
11 |
12 | .outer {
13 | height: 100%;
14 | background: url(/public/img/index.jpg) 0 0 no-repeat;
15 | background-size: cover;
16 | display: flex;
17 | justify-content: center;
18 | align-items: center;
19 |
20 | }
21 |
22 | .con {
23 | display: flex;
24 | justify-content: center;
25 | align-items: center;
26 | flex-direction: column;
27 | }
28 |
29 | .con h2 {
30 | color: #fff;
31 | font-size: 40px;
32 | margin: 30px 0;
33 | }
34 |
35 | .ipts {
36 | display: flex;
37 | flex-direction: column;
38 | }
39 |
40 | .ipts input {
41 | box-sizing: border-box;
42 | width: 400px;
43 | height: 50px;
44 | font-size: 18px;
45 | background-color: transparent;
46 | color: #fff;
47 | border: 1px solid #fff;
48 | padding: 0 10px;
49 | margin-bottom: 10px;
50 | }
51 |
52 | #btn {
53 | width: 400px;
54 | height: 50px;
55 | background-color: rgba(255, 255, 255, .7);
56 | box-sizing: border-box;
57 | border: 1px solid #fff;
58 | }
--------------------------------------------------------------------------------
/day13-登录注册/03.登录注册session权限控制/public/css/login.css:
--------------------------------------------------------------------------------
1 | * {
2 | margin: 0;
3 | padding: 0;
4 | }
5 |
6 | html,
7 | body {
8 | width: 100%;
9 | height: 100%;
10 | }
11 |
12 | .outer {
13 | height: 100%;
14 | background: url(/public/img/index.jpg) 0 0 no-repeat;
15 | background-size: cover;
16 | display: flex;
17 | justify-content: center;
18 | align-items: center;
19 |
20 | }
21 |
22 | .con {
23 | display: flex;
24 | justify-content: center;
25 | align-items: center;
26 | flex-direction: column;
27 | }
28 |
29 | .con h2 {
30 | color: #fff;
31 | font-size: 40px;
32 | margin: 30px 0;
33 | }
34 |
35 | .ipts {
36 | display: flex;
37 | flex-direction: column;
38 | }
39 |
40 | .ipts input {
41 | box-sizing: border-box;
42 | width: 400px;
43 | height: 50px;
44 | font-size: 18px;
45 | background-color: transparent;
46 | color: #fff;
47 | border: 1px solid #fff;
48 | padding: 0 10px;
49 | margin-bottom: 10px;
50 | }
51 |
52 | #btn {
53 | width: 400px;
54 | height: 50px;
55 | background-color: rgba(255, 255, 255, .7);
56 | box-sizing: border-box;
57 | border: 1px solid #fff;
58 | }
--------------------------------------------------------------------------------
/day13-登录注册/03.登录注册session权限控制/public/css/register.css:
--------------------------------------------------------------------------------
1 | * {
2 | margin: 0;
3 | padding: 0;
4 | }
5 |
6 | html,
7 | body {
8 | width: 100%;
9 | height: 100%;
10 | }
11 |
12 | .outer {
13 | height: 100%;
14 | background: url(/public/img/index.jpg) 0 0 no-repeat;
15 | background-size: cover;
16 | display: flex;
17 | justify-content: center;
18 | align-items: center;
19 |
20 | }
21 |
22 | .con {
23 | display: flex;
24 | justify-content: center;
25 | align-items: center;
26 | flex-direction: column;
27 | }
28 |
29 | .con h2 {
30 | color: #fff;
31 | font-size: 40px;
32 | margin: 30px 0;
33 | }
34 |
35 | .ipts {
36 | display: flex;
37 | flex-direction: column;
38 | }
39 |
40 | .ipts input {
41 | box-sizing: border-box;
42 | width: 400px;
43 | height: 50px;
44 | font-size: 18px;
45 | background-color: transparent;
46 | color: #fff;
47 | border: 1px solid #fff;
48 | padding: 0 10px;
49 | margin-bottom: 10px;
50 | }
51 |
52 | #btn {
53 | width: 400px;
54 | height: 50px;
55 | background-color: rgba(255, 255, 255, .7);
56 | box-sizing: border-box;
57 | border: 1px solid #fff;
58 | }
--------------------------------------------------------------------------------
/day01-ES5+/01.严格模式.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | Document
9 |
10 |
11 |
12 |
43 |
44 |
45 |
--------------------------------------------------------------------------------
/day07-node核心模块/06.fs/03.异步写入解决回调地狱.js:
--------------------------------------------------------------------------------
1 | const fs = require("fs");
2 | const path = require("path");
3 |
4 | //文件路径
5 | const filePath = path.resolve(__dirname, "01.txt");
6 |
7 | (async function () {
8 | const fd = await new Promise((resolve, reject) => {
9 | fs.open(filePath, "a", (err, fd) => {
10 | if (err) {
11 | return reject(err);
12 | }
13 | console.log("打开文件成功");
14 | resolve(fd);
15 | })
16 | })
17 |
18 | await new Promise((resolve, reject) => {
19 | fs.write(fd, "锄禾日当午", (err) => {
20 | if (err) {
21 | return reject(err);
22 | }
23 | console.log("写入成功");
24 | resolve()
25 | })
26 | })
27 |
28 |
29 | await new Promise((resolve, reject) => {
30 | fs.close(fd, err => {
31 | if (err) {
32 | return reject(err)
33 | }
34 | console.log("关闭成功");
35 | resolve()
36 | })
37 | })
38 |
39 | })()
40 | .then(() => {
41 | console.log("文件打开写入关闭一套结束");
42 | })
43 | .catch(reason => {
44 | console.log("文件操作出现了错误", reason);
45 | })
--------------------------------------------------------------------------------
/day14-gulp/01.module/02.commonJS/js/build.js:
--------------------------------------------------------------------------------
1 | (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i {
8 | if (err) {
9 | console.log("数据库连接失败", err);
10 | return;
11 | }
12 | console.log("数据库连接成功");
13 | })
14 |
15 |
16 | // 2.创建某个集合的约束对象
17 | const studentSchema = new mongoose.Schema({
18 | name: {
19 | type: String, //约束数据类型是String
20 | unique: true, //唯一的
21 | required: true, //必填项
22 | },
23 | age: Number, //直接约束数据类型
24 | sex: String,
25 | hobby: [String], //直接约束hobby的值是一个数组,数组的值必须是字符串
26 | createTime: {
27 | type: Date,
28 | default: Date.now
29 | }
30 | })
31 |
32 | // console.log(studentSchema);
33 |
34 |
35 | //3.根据约束对象创建对应的集合
36 | const studentModel = mongoose.model("student", studentSchema);
37 | // console.log(studentModel);
38 |
39 |
40 |
41 | //1.删除数据(deleteOne和deleteMany方法返回promise对象)
42 | const re = studentModel.deleteOne({
43 | age: 39
44 | })
45 |
46 | re.then(value => {
47 | //deleteOne方法返回的promise对象的值是 删除的结果反馈组成的对象
48 | console.log(value);
49 | })
--------------------------------------------------------------------------------
/day11-ajax/03.jsonp/jquery的jsonp.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | Document
9 |
10 |
11 |
12 |
13 |
24 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/day01-ES5+/11.filter方法.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | Document
9 |
10 |
11 |
12 |
49 |
50 |
51 |
--------------------------------------------------------------------------------
/day13-登录注册/02.登录注册cookie权限控制/routers/centerRouter.js:
--------------------------------------------------------------------------------
1 | const express = require("express");
2 | const router = new express.Router();
3 |
4 | //引入userModel模块
5 | const userModel = require("../models/userModel");
6 |
7 | //个人中心权限管理接口
8 | router.post("/center", async (req, res) => {
9 | console.log(req.cookies);
10 | //因为用户可能修改_id之后,在数据库查询的时候,会因为格式不对导致报错 需要处理错误
11 | try {
12 | //根据当前的cookie中保存的userID去数据库判断 是否存在该用户
13 | const findResult = await userModel.findOne({
14 | _id: req.cookies.user_id
15 | });
16 | console.log(findResult);
17 |
18 | //如果查询到用户信息了 则响应值
19 | if (findResult) {
20 | return res.json({
21 | code: 10000,
22 | msg: findResult.username //响应一个用户名出去
23 | })
24 | }
25 |
26 | //如果查询不到 则直接响应查询不到
27 | res.clearCookie("user_id")
28 | res.json({
29 | code: 10001,
30 | msg: "您没有权限请登录" //响应一个用户名出去
31 | })
32 | } catch (e) {
33 | //当登录失败,需要删除用户端保存的当前的cookie
34 | res.clearCookie("user_id")
35 | res.json({
36 | code: 10001,
37 | msg: "您没有权限请登录" //响应一个用户名出去
38 | })
39 | }
40 | })
41 |
42 | module.exports = router;
--------------------------------------------------------------------------------
/day20-react04/01.react的event.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | Document
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/day05-promise/05.resolve和reject方法.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | Document
9 |
10 |
11 |
12 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/day02-ES6+/14.箭头函数写法.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | Document
9 |
10 |
11 |
12 |
51 |
52 |
53 |
--------------------------------------------------------------------------------
/day09-MongoDB/07.mongoose的改.js:
--------------------------------------------------------------------------------
1 | const mongoose = require("mongoose");
2 |
3 | //1.连接数据库
4 | mongoose.connect("mongodb://127.0.0.1:27017/class0722");
5 |
6 | //当数据库连接成功会触发mongoose.connection对象的open事件
7 | mongoose.connection.once("open", err => {
8 | if (err) {
9 | console.log("数据库连接失败", err);
10 | return;
11 | }
12 | console.log("数据库连接成功");
13 | })
14 |
15 |
16 | // 2.创建某个集合的约束对象
17 | const studentSchema = new mongoose.Schema({
18 | name: {
19 | type: String, //约束数据类型是String
20 | unique: true, //唯一的
21 | required: true, //必填项
22 | },
23 | age: Number, //直接约束数据类型
24 | sex: String,
25 | hobby: [String], //直接约束hobby的值是一个数组,数组的值必须是字符串
26 | createTime: {
27 | type: Date,
28 | default: Date.now
29 | }
30 | })
31 |
32 | // console.log(studentSchema);
33 |
34 |
35 | //3.根据约束对象创建对应的集合
36 | const studentModel = mongoose.model("student", studentSchema);
37 | // console.log(studentModel);
38 |
39 |
40 |
41 | //1.修改数据(updateOne和updataMany方法返回promise对象)
42 | const re = studentModel.updateOne({
43 | age: {
44 | $gt: 120
45 | }
46 | }, {
47 | $set: {
48 | sex: "男"
49 | }
50 | })
51 |
52 | re.then(value => {
53 | //update方法返回的promise对象的值是 修改的结果反馈组成的对象
54 | console.log(value);
55 | })
--------------------------------------------------------------------------------
/day09-MongoDB/04.初始化文档内容.js:
--------------------------------------------------------------------------------
1 | const mongoose = require("mongoose");
2 |
3 | //1.连接数据库
4 | mongoose.connect("mongodb://127.0.0.1:27017/class0722");
5 |
6 | //当数据库连接成功会触发mongoose.connection对象的open事件
7 | mongoose.connection.once("open", err => {
8 | if (err) {
9 | console.log("数据库连接失败", err);
10 | return;
11 | }
12 | console.log("数据库连接成功");
13 | })
14 |
15 |
16 | // 2.创建某个集合的约束对象
17 | const studentSchema = new mongoose.Schema({
18 | name: {
19 | type: String, //约束数据类型是String
20 | unique: true, //唯一的
21 | required: true, //必填项
22 | },
23 | age: Number, //直接约束数据类型
24 | sex: String,
25 | hobby: [String], //直接约束hobby的值是一个数组,数组的值必须是字符串
26 | createTime: {
27 | type: Date,
28 | default: Date.now
29 | }
30 | })
31 |
32 | console.log(studentSchema);
33 |
34 |
35 | //3.根据约束对象创建对应的集合
36 | const studentModel = mongoose.model("student", studentSchema);
37 | console.log(studentModel);
38 |
39 | //4.初始化集合中的文档(直接实例化某个集合即可,里边传入对应的文档)
40 | new studentModel({
41 | name: "yangnie",
42 | age: 37,
43 | sex: "男",
44 | hobby: ["打台球", "打麻将", "打CF"],
45 | // createTime: Date.now()
46 | }).save(err => {
47 | if (err) {
48 | console.log(err);
49 | return;
50 | }
51 | console.log("student集合数据初始化成功");
52 | })
--------------------------------------------------------------------------------
/day01-ES5+/数组练习/03.求数组最大最小值.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | Document
9 |
10 |
11 |
12 |
43 |
44 |
45 |
--------------------------------------------------------------------------------
/day12-登录注册/03.路由管理/routers/loginRouter.js:
--------------------------------------------------------------------------------
1 | const express = require("express");
2 | const router = new express.Router();
3 |
4 | //引入userModel模块
5 | const userModel = require("../models/userModel");
6 |
7 | //引入md5模块
8 | const md5 = require("md5");
9 |
10 | //登录接口
11 | /*
12 | 接口文档:
13 | url:"/login",
14 | method:"POST",
15 | 请求字段:
16 | user:用户名 Str
17 | pass:密码 Str
18 | 响应字段:
19 | code:状态代码 10000:成功 10001:失败
20 | msg:响应状态
21 | */
22 |
23 | router.post("/login", async (req, res) => {
24 | //拿到请求数据
25 | const {
26 | user,
27 | pass
28 | } = req.body;
29 |
30 | //去数据库查找是否有该用户
31 | const findResult = await userModel.findOne({
32 | username: user
33 | })
34 |
35 | //如果数据库没有该用户 则findResult 返回null
36 | if (!findResult) {
37 | return res.json({
38 | code: 10001,
39 | msg: "用户名不存在"
40 | })
41 | }
42 |
43 | //如果存在该用户,则findResult就是查询的结果,判断用户输入的密码和结果是否一致
44 | if (md5(pass) !== findResult.password) {
45 | return res.json({
46 | code: 10002,
47 | msg: "密码错误"
48 | })
49 | }
50 |
51 | //登录成功
52 | res.json({
53 | code: 10000,
54 | msg: "登录成功"
55 | })
56 | })
57 |
58 | module.exports = router
--------------------------------------------------------------------------------
/day01-ES5+/数组练习/05.击鼓传花.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | Document
9 |
10 |
11 |
12 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/day03-ES6+/08.iterator.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | Document
9 |
10 |
11 |
12 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/day13-登录注册/02.登录注册cookie权限控制/index.js:
--------------------------------------------------------------------------------
1 | const express = require("express");
2 | const app = express();
3 | const path = require("path")
4 |
5 | //连接数据库 及引入数据库的集合信息
6 | require("./db")
7 |
8 | //1.官方的静态资源中间件(服务器上的文件响应)
9 | //暴露views中的静态文件,直接可以在服务器的地址栏后添加对应的静态资源路径即可访问
10 | app.use(express.static(path.resolve(__dirname, "./views")))
11 | //暴露public中的静态文件,但是做了路径限制,在服务器地址后添加/public/+静态资源路径即可访问
12 | app.use("/public/", express.static(path.resolve(__dirname, "./public")))
13 |
14 | //2.处理post请求报文体的中间件(把报文体的内容放在req.body上)
15 | app.use("", express.urlencoded({
16 | extended: false
17 | }))
18 | app.use(express.json());
19 |
20 | //引入cookie处理的第三方中间件
21 | const cookieParser = require('cookie-parser')
22 | //挂载在app上
23 | app.use(cookieParser())
24 |
25 |
26 | //3.引入外部的功能路由模块
27 | const regRouter = require("./routers/regRouter");
28 | const loginRouter = require("./routers/loginRouter");
29 | const registerRouter = require("./routers/registerRouter");
30 | const centerRouter = require("./routers/centerRouter");
31 |
32 | //4.把路由挂载在app上
33 | app.use(regRouter);
34 | app.use(loginRouter);
35 | app.use(registerRouter);
36 | app.use(centerRouter);
37 |
38 |
39 |
40 | app.listen("8888", err => {
41 | if (err) {
42 | console.log("服务端错误", err);
43 | return;
44 | }
45 | console.log("服务端启动成功 http://192.168.19.38:8888");
46 | })
--------------------------------------------------------------------------------
/day01-ES5+/04.json.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | Document
9 |
10 |
11 |
12 |
49 |
50 |
51 |
--------------------------------------------------------------------------------
/day02-ES6+/07.模板字符串.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | Document
9 |
10 |
11 |
12 |
13 |
我是老李
14 |
大家好,我今年18岁,成年,热爱写代码
15 |
我现在在学习html
16 |
17 |
55 |
56 |
57 |
--------------------------------------------------------------------------------
/day01-ES5+/03.json案例.json:
--------------------------------------------------------------------------------
1 | {
2 | "person": [{
3 | "name": "张三",
4 | "age": 18,
5 | "sex": "男",
6 | "hobby": ["唱", "跳", "rap", "篮球"]
7 | }, {
8 | "name": "张三",
9 | "age": 18,
10 | "sex": "男",
11 | "hobby": ["唱", "跳", "rap", "篮球"]
12 | }, {
13 | "name": "张三",
14 | "age": 18,
15 | "sex": "男",
16 | "hobby": ["唱", "跳", "rap", "篮球"]
17 | }, {
18 | "name": "张三",
19 | "age": 18,
20 | "sex": "男",
21 | "hobby": ["唱", "跳", "rap", "篮球"]
22 | }, {
23 | "name": "张三",
24 | "age": 18,
25 | "sex": "男",
26 | "hobby": ["唱", "跳", "rap", "篮球"]
27 | }, {
28 | "name": "张三",
29 | "age": 18,
30 | "sex": "男",
31 | "hobby": ["唱", "跳", "rap", "篮球"]
32 | }, {
33 | "name": "张三",
34 | "age": 18,
35 | "sex": "男",
36 | "hobby": ["唱", "跳", "rap", "篮球"]
37 | }, {
38 | "name": "张三",
39 | "age": 18,
40 | "sex": "男",
41 | "hobby": ["唱", "跳", "rap", "篮球"]
42 | }, {
43 | "name": "张三",
44 | "age": 18,
45 | "sex": "男",
46 | "hobby": ["唱", "跳", "rap", "篮球"]
47 | }, {
48 | "name": "张三",
49 | "age": 18,
50 | "sex": "男",
51 | "hobby": ["唱", "跳", "rap", "篮球"]
52 | }]
53 | }
--------------------------------------------------------------------------------
/day04-promise/08.在then和catch中拿到成功和失败的值.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | Document
9 |
10 |
11 |
12 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/day09-MongoDB/06.mongoose的查.js:
--------------------------------------------------------------------------------
1 | const mongoose = require("mongoose");
2 |
3 | //1.连接数据库
4 | mongoose.connect("mongodb://127.0.0.1:27017/class0722");
5 |
6 | //当数据库连接成功会触发mongoose.connection对象的open事件
7 | mongoose.connection.once("open", err => {
8 | if (err) {
9 | console.log("数据库连接失败", err);
10 | return;
11 | }
12 | console.log("数据库连接成功");
13 | })
14 |
15 |
16 | // 2.创建某个集合的约束对象
17 | const studentSchema = new mongoose.Schema({
18 | name: {
19 | type: String, //约束数据类型是String
20 | unique: true, //唯一的
21 | required: true, //必填项
22 | },
23 | age: Number, //直接约束数据类型
24 | sex: String,
25 | hobby: [String], //直接约束hobby的值是一个数组,数组的值必须是字符串
26 | createTime: {
27 | type: Date,
28 | default: Date.now
29 | }
30 | })
31 |
32 | // console.log(studentSchema);
33 |
34 |
35 | //3.根据约束对象创建对应的集合
36 | const studentModel = mongoose.model("student", studentSchema);
37 | // console.log(studentModel);
38 |
39 |
40 |
41 | //1.查询数据(find方法返回promise对象)
42 | const re = studentModel.findOne({
43 | $where: function () {
44 | return this.hobby.includes("看书");
45 | }
46 | }, {
47 | name: 1,
48 | _id: 0
49 | })
50 |
51 | // console.log(re)
52 | re.then(value => {
53 | //find返回的promise对象的值是一个数组,包含的是查询到的一个或多个文档对象
54 | //findOne返回的promise对象的值是就是查询到的一个文档对象
55 | console.log("查询结果", value);
56 | })
--------------------------------------------------------------------------------
/day07-node核心模块/06.fs/04.异步写入解决回调地狱封装.js:
--------------------------------------------------------------------------------
1 | const fs = require("fs");
2 | const path = require("path");
3 |
4 | //文件路径
5 | const filePath = path.resolve(__dirname, "01.txt");
6 |
7 | function open(filePath) {
8 | return new Promise((resolve, reject) => {
9 | fs.open(filePath, "a", (err, fd) => {
10 | if (err) {
11 | return reject(err);
12 | }
13 | console.log("打开文件成功");
14 | resolve(fd);
15 | })
16 | })
17 | }
18 |
19 | function write(fd, con) {
20 | return new Promise((resolve, reject) => {
21 | fs.write(fd, con, (err) => {
22 | if (err) {
23 | return reject(err);
24 | }
25 | console.log("写入成功");
26 | resolve()
27 | })
28 | })
29 | }
30 |
31 | function close(fd) {
32 | return new Promise((resolve, reject) => {
33 | fs.close(fd, err => {
34 | if (err) {
35 | return reject(err)
36 | }
37 | console.log("关闭成功");
38 | resolve()
39 | })
40 | })
41 | }
42 |
43 | (async function () {
44 | const fd = await open(filePath);
45 | await write(fd, "汗滴禾下土");
46 | await close(fd);
47 | })()
48 | .then(() => {
49 | console.log("文件打开写入关闭一套结束");
50 | })
51 | .catch(reason => {
52 | console.log("文件操作出现了错误", reason);
53 | })
--------------------------------------------------------------------------------
/day01-ES5+/13.reduce.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | Document
9 |
10 |
11 |
12 |
48 |
49 |
50 |
--------------------------------------------------------------------------------
/day01-ES5+/数组练习/01.手写reverse.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | Document
9 |
10 |
11 |
12 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/day01-ES5+/数组练习/03.任意进制转换.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | Document
9 |
10 |
11 |
12 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/day11-ajax/04.cors跨域/server.js:
--------------------------------------------------------------------------------
1 | const express = require("express");
2 | const app = express();
3 | const path = require("path")
4 |
5 | //登录页面
6 | app.get("/", (req, res) => {
7 | const filePath = path.resolve(__dirname, 'index.html');
8 | res.sendFile(filePath)
9 | })
10 |
11 |
12 | //登录get接口
13 | app.get("/login", (req, res) => {
14 | //拿到查询字符串
15 | const query = req.query;
16 | console.log(query);
17 | // console.log(req);
18 | //获取请求的请求源
19 | const origin = req.headers.origin;
20 | //把白名单放在数组中
21 | const arr = ["http://127.0.0.1:5400", "http://127.0.0.1:5500", "http://127.0.0.1:5600", "http://127.0.0.1:5700"]
22 | //判断请求源在不在白名单里
23 | if (arr.includes(origin)) {
24 | //如果请求源在白名单中,则直接把当前的请求源设置为跨域
25 | //设置一个可跨域的header:
26 | res.set("Access-Control-Allow-Origin", origin)
27 | }
28 |
29 | //判断用户名和密码是否正确
30 | if (query.user === "laoli" && query.pass === '123456') {
31 | return res.json({
32 | code: 100001,
33 | msg: "登录成功",
34 | type: "GET"
35 | })
36 | }
37 |
38 | res.send({
39 | code: 100000,
40 | msg: "登录失败",
41 | type: "GET"
42 | })
43 | })
44 |
45 |
46 |
47 | app.listen("8888", (err) => {
48 | if (err) {
49 | console.log("服务器启动失败", err);
50 | return
51 | }
52 |
53 | console.log("服务器启动成功 http://192.168.19.35:8888")
54 | })
--------------------------------------------------------------------------------
/day02-ES6+/06.对象的解构赋值.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | Document
9 |
10 |
11 |
12 |
62 |
63 |
64 |
--------------------------------------------------------------------------------
/day04-promise/03.promise对象的值.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | Document
9 |
10 |
11 |
12 |
55 |
56 |
57 |
--------------------------------------------------------------------------------
/day13-登录注册/05.协商缓存/server.js:
--------------------------------------------------------------------------------
1 | const express = require("express");
2 | const app = express();
3 | const path = require("path");
4 | const fs = require("fs");
5 | const etag = require("etag")
6 | const {
7 | promisify
8 | } = require("util");
9 |
10 | app.get("/", async (req, res) => {
11 | const filePath = path.resolve(__dirname, "./index.html");
12 |
13 | //接到请求头中的if-none-match和if-modified-since
14 | const ifNoneMatch = req.headers['if-none-match'];
15 | const ifModifiedSince = req.headers['if-modified-since'];
16 |
17 |
18 |
19 | //获取服务端文件的唯一标识和文件的最后一次修改时间
20 | const eTag = etag(filePath);
21 |
22 | //获取服务端文件的最后一次修改时间
23 | const stat = promisify(fs.stat); //把stat方法转换成返回promise对象的方法
24 | const fileDetail = await stat(filePath);
25 | const lastModified = fileDetail.mtime.toGMTString(); //获取最后一次修改时间 并转为标准时间字符串
26 | console.log(eTag, lastModified)
27 |
28 | //判断是否读取缓存
29 | if (ifNoneMatch === eTag && ifModifiedSince === lastModified) {
30 | //读取缓存
31 | res.status(304);
32 | return res.end();
33 | }
34 |
35 |
36 | //响应之前设置协商缓存的响应头
37 | res.set("ETag", eTag);
38 | res.set("Last-Modified", lastModified);
39 | //响应文件
40 | res.sendFile(filePath)
41 |
42 | })
43 |
44 |
45 | app.listen(8888, err => {
46 | if (err) {
47 | console.log(err);
48 | return
49 | }
50 |
51 | console.log("服务器启动成功 http://192.168.19.38:8888")
52 | })
--------------------------------------------------------------------------------
/day02-ES6+/04.const常量.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | Document
9 |
10 |
11 |
12 |
52 |
53 |
54 |
--------------------------------------------------------------------------------
/day13-登录注册/01.storage/02.localStoraged的使用.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | Document
9 |
10 |
11 |
12 |
13 |
14 |
15 |
45 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/day13-登录注册/03.登录注册session权限控制/routers/loginRouter.js:
--------------------------------------------------------------------------------
1 | const express = require("express");
2 | const router = new express.Router();
3 |
4 | //引入userModel模块
5 | const userModel = require("../models/userModel");
6 |
7 | //引入md5模块
8 | const md5 = require("md5");
9 |
10 | //登录接口
11 | /*
12 | 接口文档:
13 | url:"/login",
14 | method:"POST",
15 | 请求字段:
16 | user:用户名 Str
17 | pass:密码 Str
18 | 响应字段:
19 | code:状态代码 10000:成功 10001:失败
20 | msg:响应状态
21 | */
22 |
23 | router.post("/login", async (req, res) => {
24 | //拿到请求数据
25 | const {
26 | user,
27 | pass
28 | } = req.body;
29 |
30 | //去数据库查找是否有该用户
31 | const findResult = await userModel.findOne({
32 | username: user
33 | })
34 |
35 | //如果数据库没有该用户 则findResult 返回null
36 | if (!findResult) {
37 | return res.json({
38 | code: 10001,
39 | msg: "用户名不存在"
40 | })
41 | }
42 |
43 | //如果存在该用户,则findResult就是查询的结果,判断用户输入的密码和结果是否一致
44 | if (md5(pass) !== findResult.password) {
45 | return res.json({
46 | code: 10002,
47 | msg: "密码错误"
48 | })
49 | }
50 |
51 | //当登录成功的时候,设置session
52 | //给session扩展一个user为用户信息
53 | req.session.user = findResult;
54 |
55 | //登录成功
56 | res.json({
57 | code: 10000,
58 | msg: "登录成功"
59 | })
60 | })
61 |
62 | module.exports = router
--------------------------------------------------------------------------------
/day03-ES6+/05.bigInt类型.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | Document
9 |
10 |
11 |
12 |
52 |
53 |
54 |
--------------------------------------------------------------------------------
/day03-ES6+/09.手写iterator.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | Document
9 |
10 |
11 |
12 |
47 |
48 |
49 |
--------------------------------------------------------------------------------
/day11-ajax/03.jsonp/练习.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | Document
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/day01-ES5+/08.存取器属性.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | Document
9 |
10 |
11 |
12 |
47 |
48 |
49 |
--------------------------------------------------------------------------------
/day04-promise/02.promise模拟请求基础写法.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | Document
9 |
10 |
11 |
12 |
61 |
62 |
63 |
--------------------------------------------------------------------------------
/day01-ES5+/09.forEach和map.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | Document
9 |
10 |
11 |
12 |
59 |
60 |
61 |
--------------------------------------------------------------------------------
/day13-登录注册/06.压缩/server.js:
--------------------------------------------------------------------------------
1 | const express = require("express");
2 | const app = express();
3 | const path = require("path");
4 | const fs = require("fs");
5 | const zlib = require("zlib")
6 |
7 | app.get("/", async (req, res) => {
8 |
9 | const filePath = path.resolve(__dirname, "./index.html")
10 | const rs = fs.createReadStream(filePath);
11 | //查看支持的压缩格式
12 | const accpetEncoding = req.headers['accept-encoding'];
13 | console.log(accpetEncoding)
14 |
15 | //根据客户端的支持的格式来进行不同的压缩
16 | if (accpetEncoding.includes("gzip")) {
17 | //zlib.createGzip()//创建一个gzip压缩的盒子,能够被流式写入
18 | const gzipFile = rs.pipe(zlib.createGzip()) //返回一个gizp压缩格式的可读流
19 |
20 | //告诉客户端我响应的压缩格式是什么
21 | res.set("content-encoding", "gzip")
22 | //把压缩好的文件写入到响应中
23 | return gzipFile.pipe(res) //22.1kb
24 | }
25 |
26 | //根据客户端的支持的格式来进行不同的压缩
27 | if (accpetEncoding.includes("deflate")) {
28 | //zlib.createDeflate()//创建一个gzip压缩的盒子,能够被流式写入
29 | const gzipFile = rs.pipe(zlib.createDeflate()) //返回一个gizp压缩格式的可读流
30 |
31 | //告诉客户端我响应的压缩格式是什么
32 | res.set("content-encoding", "deflate")
33 | //把压缩好的文件写入到响应中
34 | return gzipFile.pipe(res) //22.1kb
35 | }
36 |
37 |
38 | //没有压缩的响应
39 | rs.pipe(res) //99.1kb
40 | })
41 |
42 |
43 | app.listen(8888, err => {
44 | if (err) {
45 | console.log(err);
46 | return
47 | }
48 |
49 | console.log("服务器启动成功 http://192.168.19.38:8888")
50 | })
--------------------------------------------------------------------------------
/day12-登录注册/03.路由管理/routers/registerRouter.js:
--------------------------------------------------------------------------------
1 | const express = require("express");
2 | const router = new express.Router();
3 |
4 | //引入userModel模块
5 | const userModel = require("../models/userModel");
6 |
7 | //引入md5模块
8 | const md5 = require("md5");
9 |
10 | //注册接口
11 | /*
12 | 接口文档:
13 | url:"/register",
14 | method:"POST",
15 | 请求字段:
16 | user:用户名 Str
17 | pass:密码 Str
18 | 响应字段:
19 | code:状态代码 10000:成功 10001:失败
20 | msg:响应状态
21 | */
22 | router.post("/register", async (req, res) => {
23 | //拿到用户注册请求的账号和密码
24 | const {
25 | user,
26 | pass
27 | } = req.body;
28 | // console.log(user, pass)
29 |
30 | //根据当前的user 去数据库查询是否有该用户名存在
31 | //如果查询到,则响应当前查询的到文档组成的对象,否则响应一个null
32 | const findResult = await userModel.findOne({
33 | username: user
34 | })
35 | // console.log(findResult)
36 |
37 |
38 | //如果查询存在当前用户名(也就是findResult是个对象),则直接响应 用户名已经存在的结果
39 | if (findResult) {
40 | return res.json({
41 | code: 10001,
42 | msg: "用户名已经存在,请重新输入"
43 | })
44 | }
45 |
46 | //当查询的用户名不存在(也就是findResult是null的时候),则向数据库添加数据
47 | const createResult = await userModel.create({
48 | username: user,
49 | password: md5(pass),
50 | createTime: new Date()
51 | })
52 |
53 | //添加好数据之后,响应给用户注册成功
54 | res.json({
55 | code: 10000,
56 | msg: "注册成功"
57 | })
58 |
59 | })
60 |
61 | module.exports = router
--------------------------------------------------------------------------------
/day13-登录注册/02.登录注册cookie权限控制/routers/registerRouter.js:
--------------------------------------------------------------------------------
1 | const express = require("express");
2 | const router = new express.Router();
3 |
4 | //引入userModel模块
5 | const userModel = require("../models/userModel");
6 |
7 | //引入md5模块
8 | const md5 = require("md5");
9 |
10 | //注册接口
11 | /*
12 | 接口文档:
13 | url:"/register",
14 | method:"POST",
15 | 请求字段:
16 | user:用户名 Str
17 | pass:密码 Str
18 | 响应字段:
19 | code:状态代码 10000:成功 10001:失败
20 | msg:响应状态
21 | */
22 | router.post("/register", async (req, res) => {
23 | //拿到用户注册请求的账号和密码
24 | const {
25 | user,
26 | pass
27 | } = req.body;
28 | // console.log(user, pass)
29 |
30 | //根据当前的user 去数据库查询是否有该用户名存在
31 | //如果查询到,则响应当前查询的到文档组成的对象,否则响应一个null
32 | const findResult = await userModel.findOne({
33 | username: user
34 | })
35 | // console.log(findResult)
36 |
37 |
38 | //如果查询存在当前用户名(也就是findResult是个对象),则直接响应 用户名已经存在的结果
39 | if (findResult) {
40 | return res.json({
41 | code: 10001,
42 | msg: "用户名已经存在,请重新输入"
43 | })
44 | }
45 |
46 | //当查询的用户名不存在(也就是findResult是null的时候),则向数据库添加数据
47 | const createResult = await userModel.create({
48 | username: user,
49 | password: md5(pass),
50 | createTime: new Date()
51 | })
52 |
53 | //添加好数据之后,响应给用户注册成功
54 | res.json({
55 | code: 10000,
56 | msg: "注册成功"
57 | })
58 |
59 | })
60 |
61 | module.exports = router
--------------------------------------------------------------------------------
/day13-登录注册/03.登录注册session权限控制/routers/registerRouter.js:
--------------------------------------------------------------------------------
1 | const express = require("express");
2 | const router = new express.Router();
3 |
4 | //引入userModel模块
5 | const userModel = require("../models/userModel");
6 |
7 | //引入md5模块
8 | const md5 = require("md5");
9 |
10 | //注册接口
11 | /*
12 | 接口文档:
13 | url:"/register",
14 | method:"POST",
15 | 请求字段:
16 | user:用户名 Str
17 | pass:密码 Str
18 | 响应字段:
19 | code:状态代码 10000:成功 10001:失败
20 | msg:响应状态
21 | */
22 | router.post("/register", async (req, res) => {
23 | //拿到用户注册请求的账号和密码
24 | const {
25 | user,
26 | pass
27 | } = req.body;
28 | // console.log(user, pass)
29 |
30 | //根据当前的user 去数据库查询是否有该用户名存在
31 | //如果查询到,则响应当前查询的到文档组成的对象,否则响应一个null
32 | const findResult = await userModel.findOne({
33 | username: user
34 | })
35 | // console.log(findResult)
36 |
37 |
38 | //如果查询存在当前用户名(也就是findResult是个对象),则直接响应 用户名已经存在的结果
39 | if (findResult) {
40 | return res.json({
41 | code: 10001,
42 | msg: "用户名已经存在,请重新输入"
43 | })
44 | }
45 |
46 | //当查询的用户名不存在(也就是findResult是null的时候),则向数据库添加数据
47 | const createResult = await userModel.create({
48 | username: user,
49 | password: md5(pass),
50 | createTime: new Date()
51 | })
52 |
53 | //添加好数据之后,响应给用户注册成功
54 | res.json({
55 | code: 10000,
56 | msg: "注册成功"
57 | })
58 |
59 | })
60 |
61 | module.exports = router
--------------------------------------------------------------------------------
/day14-gulp/01.module/03.ES6模块化/js/index.js:
--------------------------------------------------------------------------------
1 | /*
2 | ES6模块化编译
3 | - 使用babel把ES6模块化语法编译为CommonJS模块化
4 | - 使用browserify把CommonJS模块化编译为浏览器识别的语法
5 |
6 | - babel的使用
7 | - npm install --save-dev @babel/core @babel/cli @babel/preset-env
8 | - @babel/core:babel的核心包
9 | - @babel/cli:babel的命令包
10 | - @babel/preset-env:babel的预设包
11 | - 在package.json中配置预设
12 | "babel": {
13 | "presets": [
14 | "@babel/env"
15 | ]
16 | }
17 | - 使用babel的命令把js文件夹中所有ES6模块化的文件编译为CommonJS的模块化规范
18 | - npx babel 目标文件夹 -d 新文件夹(npx是启动本地命令)
19 | - 使用browserify把babel编译出来的CommonJS规范的入口文件代码编译为浏览器识别的代码
20 |
21 |
22 | */
23 |
24 |
25 |
26 | /*
27 | 引入模块统一使用 import XXX from XXX来引入
28 | as:起别名
29 |
30 | */
31 |
32 | /*
33 | 引入默认暴露的功能
34 | */
35 | import add from './add';
36 | console.log("add", add(1, 1));
37 |
38 |
39 | /*
40 | 引入分别暴露模块(必须使用解构赋值的形式来引入),因为分别暴露最终暴露的是一个对象
41 |
42 | */
43 | import {
44 | count,
45 | msg as m1, //如果msg和其他变量冲突,可以起一个别名
46 | mins
47 | } from './utils'
48 | console.log("count,m1,mins", count, m1, mins(3, 1));
49 |
50 |
51 |
52 | /*
53 | 引入统一暴露模块(一般也是使用解构赋值的形式接受)
54 |
55 | */
56 | import {
57 | s1,
58 | say2,
59 | } from './say'
60 | console.log("s1,say2", s1("laoli"), say2("laoli"));
61 |
62 |
63 | /*
64 | 假如真的不想用解构赋值,我们可以直接用一个对象接收住分别暴露和统一暴露的内容
65 | */
66 | import * as say from './say'
67 |
68 | console.log("say", say)
--------------------------------------------------------------------------------
/day01-ES5+/06.Object.create创建对象属性.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | Document
9 |
10 |
11 |
12 |
58 |
59 |
60 |
--------------------------------------------------------------------------------
/day02-ES6+/02.let声明.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | Document
9 |
10 |
11 |
12 |
57 |
58 |
59 |
--------------------------------------------------------------------------------
/day01-ES5+/10.some和every.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | Document
9 |
10 |
11 |
12 |
55 |
56 |
57 |
--------------------------------------------------------------------------------
/day11-ajax/04.cors跨域/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | Document
9 |
10 |
11 |
12 |
13 |
24 |
47 |
48 |
49 |
--------------------------------------------------------------------------------
/day11-ajax/03.jsonp/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | Document
9 |
10 |
11 |
12 |
23 |
48 |
49 |
50 |
--------------------------------------------------------------------------------
/day13-登录注册/02.登录注册cookie权限控制/views/center.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | Document
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |

17 |
欢迎光临 888号为您服务
18 |
19 |
20 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/day13-登录注册/03.登录注册session权限控制/views/center.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | Document
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |

17 |
欢迎光临 888号为您服务
18 |
19 |
20 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/day04-promise/07.练习.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | Document
9 |
10 |
11 |
12 |
52 |
53 |
54 |
--------------------------------------------------------------------------------
/day18-react02/06.state状态引入.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | Document
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
50 |
51 |
52 |
--------------------------------------------------------------------------------
/day18-react02/04.class继承.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | Document
9 |
10 |
11 |
12 |
56 |
57 |
58 |
--------------------------------------------------------------------------------
/day04-promise/06.then的第二个参数.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | Document
9 |
10 |
11 |
12 |
56 |
57 |
58 |
--------------------------------------------------------------------------------
/day05-promise/07.async和await的返回值.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | Document
9 |
10 |
11 |
12 |
50 |
51 |
52 |
--------------------------------------------------------------------------------
/day02-ES6+/08.字符串新方法.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | Document
9 |
10 |
11 |
12 |
58 |
59 |
60 |
--------------------------------------------------------------------------------
/day13-登录注册/01.storage/03.sessionStoraged的使用.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | Document
9 |
10 |
11 |
12 |
13 |
14 |
15 |
51 |
52 |
53 |
--------------------------------------------------------------------------------
/day21-react05/03.getSnapshotBeforeUpdate.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Document
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
54 |
55 |
56 |
--------------------------------------------------------------------------------