├── CNAME ├── docs └── CNAME ├── node-cors ├── parcel-demo │ ├── index.js │ ├── .proxyrc │ ├── package.json │ └── index.html ├── vue-cli2-demo │ ├── static │ │ └── .gitkeep │ ├── config │ │ ├── prod.env.js │ │ ├── dev.env.js │ │ └── index.js │ ├── build │ │ ├── logo.png │ │ ├── vue-loader.conf.js │ │ ├── build.js │ │ ├── check-versions.js │ │ ├── webpack.base.conf.js │ │ ├── utils.js │ │ └── webpack.dev.conf.js │ ├── src │ │ ├── assets │ │ │ └── logo.png │ │ ├── main.js │ │ ├── App.vue │ │ └── components │ │ │ └── HelloWorld.vue │ ├── .editorconfig │ ├── .gitignore │ ├── .babelrc │ ├── .postcssrc.js │ ├── README.md │ ├── index.html │ └── package.json ├── webpack │ ├── index.js │ ├── package.json │ ├── webpack.config.js │ └── webpack.html ├── name │ ├── b.html │ ├── c.html │ ├── server.js │ └── a.html ├── README.md ├── hash │ ├── b.html │ ├── a.html │ ├── c.html │ └── server.js ├── vue-cli3-demo │ ├── babel.config.js │ ├── public │ │ ├── favicon.ico │ │ └── index.html │ ├── src │ │ ├── assets │ │ │ └── logo.png │ │ ├── main.js │ │ ├── App.vue │ │ └── components │ │ │ └── HelloWorld.vue │ ├── vue.config.js │ ├── .gitignore │ ├── README.md │ └── package.json ├── websocket │ ├── server.js │ └── index.html ├── jsonp │ ├── server.js │ └── index.html ├── postMessage │ ├── server.js │ ├── another.html │ └── index.html ├── cors-any │ ├── server.js │ └── index.html ├── package.json ├── charles │ └── index.html ├── nginx │ └── index.html ├── index.html ├── normal-server.js ├── server.js └── client.js ├── webpack ├── loaders │ ├── README.md │ └── example-01 │ │ ├── .gitignore │ │ ├── aa.muji │ │ ├── index.js │ │ ├── webpack.config-2.js │ │ ├── package.json │ │ ├── webpack.config.js │ │ └── loaders │ │ └── myLoader.js ├── README.md └── optimization.splitChunks.chunks │ ├── .babelrc │ ├── src │ ├── b.js │ └── a.js │ ├── webpack.config-async.js │ ├── webpack.config-initial.js │ ├── webpack.config-all.js │ ├── package.json │ ├── dist-all │ ├── b.bundle.js │ └── a.bundle.js │ └── dist-initial │ └── a.bundle.js ├── node-rpc-rest ├── README.md ├── rpc │ ├── gen-nodejs │ │ └── hello_types.js │ ├── package.json │ ├── client.js │ ├── hello.thrift │ └── server.js └── rest │ ├── index.js │ ├── package.json │ └── request.js ├── file-download ├── static │ ├── demo.js │ ├── demo.sh │ ├── 360_0388.jpg │ ├── 1597375650384.jpg │ └── index.html ├── README.md ├── example │ ├── download-multiple │ │ ├── simple.html │ │ └── script.js │ ├── download-backend │ │ ├── direct.html │ │ ├── a-download.html │ │ ├── a-download-base64.html │ │ └── a-download-cors.html │ ├── download-experiment │ │ └── index.html │ ├── download-frontend │ │ ├── docx-simple.html │ │ ├── json-text.html │ │ ├── docx-images.html │ │ ├── excel-simple.html │ │ ├── excel-element-ui.html │ │ └── word-excel.html │ ├── download-ios │ │ └── index.html │ └── js │ │ └── utils.js ├── package.json └── server.js ├── ansi-code ├── build.sh ├── demo │ ├── dist │ │ └── main.js │ ├── index.html │ ├── src │ │ └── index.js │ └── package.json ├── index.js ├── package-lock.json ├── package.json ├── index-2.js └── code.html ├── node-upload-stream ├── html │ ├── README.md │ ├── file.html │ ├── file-normal.html │ ├── blob.html │ ├── arraybuffer.html │ ├── formdata.html │ └── base64.html ├── koa │ ├── README.md │ ├── package.json │ └── index.js ├── node │ ├── README.md │ ├── buffer.js │ ├── request-error.js │ ├── request.js │ ├── form-data.js │ └── stream.js ├── node-server │ ├── README.md │ └── node-upload.js ├── README.md ├── 1.png ├── package.json └── .gitignore ├── wechat-feces ├── bomb.png ├── feces.png ├── 2-1-lottie.html ├── 1-1-animation.html ├── 1-2-animation.html ├── 2-2-lottie.html └── 3-1-feces-2.html ├── react-abort ├── public │ ├── robots.txt │ ├── favicon.ico │ ├── logo192.png │ ├── logo512.png │ ├── manifest.json │ └── index.html ├── src │ ├── setupTests.js │ ├── App.test.js │ ├── index.css │ ├── index.js │ ├── App.css │ ├── pages │ │ ├── Home.js │ │ ├── Posts-1.js │ │ ├── Users-1.js │ │ ├── Posts.js │ │ └── Users.js │ ├── App.js │ └── logo.svg ├── README.md ├── .gitignore └── package.json ├── watermark ├── demo │ ├── qiufeng.png │ ├── water-gao.jpg │ ├── water-yuan.jpeg │ ├── qiufeng-encode.png │ ├── qiufeng-super.png │ ├── demo.html │ ├── canvas-compare.html │ ├── canvas.html │ ├── svg.html │ ├── canvas-observe.html │ └── element.html ├── README.md ├── package.json └── index.js ├── css-margin ├── README.md ├── block-normal.html ├── begin-problem-2.html ├── pseudo-classes.html ├── begin-problem-1.html ├── block-fixed.html ├── block-absolute.html ├── computed.js ├── pseudo-elements.html ├── block-absolue-fixed-extra.html ├── collapsing-margin-no-case4.html ├── collapsing-margin-computed.html ├── in-flow.html ├── collapsing-margin-no-case3.html └── collapsing-margin-demo.html ├── README.md ├── confetti ├── README.md ├── 四边形.html ├── 旋转.html ├── 运动轨迹.html └── 轨迹加旋转.html ├── .gitignore ├── guide ├── README.md ├── index.html ├── canvas.html └── box-shadow.html └── white-board ├── index.html └── canvas.js /CNAME: -------------------------------------------------------------------------------- 1 | example.qiufeng.blue -------------------------------------------------------------------------------- /docs/CNAME: -------------------------------------------------------------------------------- 1 | example.qiufeng.blue -------------------------------------------------------------------------------- /node-cors/parcel-demo/index.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /webpack/loaders/README.md: -------------------------------------------------------------------------------- 1 | webpack -------------------------------------------------------------------------------- /node-rpc-rest/README.md: -------------------------------------------------------------------------------- 1 | # node 服务间通讯方案 -------------------------------------------------------------------------------- /file-download/static/demo.js: -------------------------------------------------------------------------------- 1 | console.log(1); -------------------------------------------------------------------------------- /node-cors/vue-cli2-demo/static/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /node-cors/webpack/index.js: -------------------------------------------------------------------------------- 1 | console.log(1111) -------------------------------------------------------------------------------- /ansi-code/build.sh: -------------------------------------------------------------------------------- 1 | cd demo 2 | 3 | npx webpack -------------------------------------------------------------------------------- /file-download/static/demo.sh: -------------------------------------------------------------------------------- 1 | echo "秋风的笔记" 2 | -------------------------------------------------------------------------------- /node-upload-stream/html/README.md: -------------------------------------------------------------------------------- 1 | ## 请求端-浏览器端 -------------------------------------------------------------------------------- /node-upload-stream/koa/README.md: -------------------------------------------------------------------------------- 1 | ## 文件上传测试服务器 -------------------------------------------------------------------------------- /node-upload-stream/node/README.md: -------------------------------------------------------------------------------- 1 | ## 请求端-node端 -------------------------------------------------------------------------------- /node-cors/name/b.html: -------------------------------------------------------------------------------- 1 |
2 | 123 3 |
-------------------------------------------------------------------------------- /node-upload-stream/node-server/README.md: -------------------------------------------------------------------------------- 1 | ## 接收端-node实现 -------------------------------------------------------------------------------- /webpack/loaders/example-01/.gitignore: -------------------------------------------------------------------------------- 1 | dist 2 | package-lock.json -------------------------------------------------------------------------------- /node-cors/name/c.html: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /node-cors/README.md: -------------------------------------------------------------------------------- 1 | ## 跨域demo 2 | 3 | 文章地址: https://qiufeng.blue/frontend/cors.html -------------------------------------------------------------------------------- /webpack/loaders/example-01/aa.muji: -------------------------------------------------------------------------------- 1 | name: 秋风 2 | title: 前端工程师 3 | 4 | hello 5 | 6 | -------------------------------------------------------------------------------- /node-upload-stream/README.md: -------------------------------------------------------------------------------- 1 | ## 文件上传示例 2 | 3 | 文章地址: https://qiufeng.blue/node/upload.html -------------------------------------------------------------------------------- /webpack/README.md: -------------------------------------------------------------------------------- 1 | # webpack 相关学习资料 2 | 3 | 1.webpack loader 相关 4 | 5 | 2.webpack plugin 相关 6 | -------------------------------------------------------------------------------- /wechat-feces/bomb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hua1995116/node-demo/HEAD/wechat-feces/bomb.png -------------------------------------------------------------------------------- /node-cors/hash/b.html: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /node-cors/parcel-demo/.proxyrc: -------------------------------------------------------------------------------- 1 | { 2 | "/api": { 3 | "target": "http://localhost:8080" 4 | } 5 | } -------------------------------------------------------------------------------- /webpack/loaders/example-01/index.js: -------------------------------------------------------------------------------- 1 | import { name } from './aa.muji' 2 | 3 | console.log(11, name); -------------------------------------------------------------------------------- /wechat-feces/feces.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hua1995116/node-demo/HEAD/wechat-feces/feces.png -------------------------------------------------------------------------------- /node-upload-stream/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hua1995116/node-demo/HEAD/node-upload-stream/1.png -------------------------------------------------------------------------------- /react-abort/public/robots.txt: -------------------------------------------------------------------------------- 1 | # https://www.robotstxt.org/robotstxt.html 2 | User-agent: * 3 | Disallow: 4 | -------------------------------------------------------------------------------- /watermark/demo/qiufeng.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hua1995116/node-demo/HEAD/watermark/demo/qiufeng.png -------------------------------------------------------------------------------- /watermark/demo/water-gao.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hua1995116/node-demo/HEAD/watermark/demo/water-gao.jpg -------------------------------------------------------------------------------- /css-margin/README.md: -------------------------------------------------------------------------------- 1 | 重拾css[一]伪元素、包含块和高度坍塌示例 2 | 3 | 文章地址: https://qiufeng.blue/frontend/collapsing-margins.html 4 | -------------------------------------------------------------------------------- /react-abort/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hua1995116/node-demo/HEAD/react-abort/public/favicon.ico -------------------------------------------------------------------------------- /react-abort/public/logo192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hua1995116/node-demo/HEAD/react-abort/public/logo192.png -------------------------------------------------------------------------------- /react-abort/public/logo512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hua1995116/node-demo/HEAD/react-abort/public/logo512.png -------------------------------------------------------------------------------- /watermark/demo/water-yuan.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hua1995116/node-demo/HEAD/watermark/demo/water-yuan.jpeg -------------------------------------------------------------------------------- /webpack/optimization.splitChunks.chunks/.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "plugins": ["@babel/plugin-syntax-dynamic-import"] 3 | } -------------------------------------------------------------------------------- /file-download/static/360_0388.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hua1995116/node-demo/HEAD/file-download/static/360_0388.jpg -------------------------------------------------------------------------------- /node-cors/vue-cli2-demo/config/prod.env.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | module.exports = { 3 | NODE_ENV: '"production"' 4 | } 5 | -------------------------------------------------------------------------------- /watermark/demo/qiufeng-encode.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hua1995116/node-demo/HEAD/watermark/demo/qiufeng-encode.png -------------------------------------------------------------------------------- /watermark/demo/qiufeng-super.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hua1995116/node-demo/HEAD/watermark/demo/qiufeng-super.png -------------------------------------------------------------------------------- /file-download/static/1597375650384.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hua1995116/node-demo/HEAD/file-download/static/1597375650384.jpg -------------------------------------------------------------------------------- /node-cors/vue-cli2-demo/build/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hua1995116/node-demo/HEAD/node-cors/vue-cli2-demo/build/logo.png -------------------------------------------------------------------------------- /node-cors/vue-cli3-demo/babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | presets: [ 3 | '@vue/cli-plugin-babel/preset' 4 | ] 5 | } 6 | -------------------------------------------------------------------------------- /node-cors/vue-cli2-demo/src/assets/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hua1995116/node-demo/HEAD/node-cors/vue-cli2-demo/src/assets/logo.png -------------------------------------------------------------------------------- /node-cors/vue-cli3-demo/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hua1995116/node-demo/HEAD/node-cors/vue-cli3-demo/public/favicon.ico -------------------------------------------------------------------------------- /node-cors/vue-cli3-demo/src/assets/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hua1995116/node-demo/HEAD/node-cors/vue-cli3-demo/src/assets/logo.png -------------------------------------------------------------------------------- /ansi-code/demo/dist/main.js: -------------------------------------------------------------------------------- 1 | document.body.appendChild(function(){const e=document.createElement("div");return e.innerHTML=_.join(["Hello","webpack"]," "),e}()); -------------------------------------------------------------------------------- /watermark/README.md: -------------------------------------------------------------------------------- 1 | # 水印详解 2 | 3 | 4 | [div 明水印实现](./demo/element.html) 5 | 6 | [canvas 明水印实现](./demo/canvas.html) 7 | 8 | [svg 明水印实现](./demo/svg.html) 9 | 10 | [暗水印实现](./demo/canvas-dark-watermark.html) -------------------------------------------------------------------------------- /node-cors/vue-cli3-demo/src/main.js: -------------------------------------------------------------------------------- 1 | // import Vue from 'vue' 2 | // import App from './App.vue' 3 | 4 | // Vue.config.productionTip = false 5 | 6 | // new Vue({ 7 | // render: h => h(App), 8 | // }).$mount('#app') 9 | -------------------------------------------------------------------------------- /webpack/optimization.splitChunks.chunks/src/b.js: -------------------------------------------------------------------------------- 1 | //b.js 2 | import { findIndex } from "lodash"; 3 | import dayjs from "dayjs"; 4 | 5 | dayjs(new Date()); 6 | 7 | findIndex([1, 2, 3]); 8 | console.log("My app is running"); -------------------------------------------------------------------------------- /node-cors/vue-cli2-demo/config/dev.env.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | const merge = require('webpack-merge') 3 | const prodEnv = require('./prod.env') 4 | 5 | module.exports = merge(prodEnv, { 6 | NODE_ENV: '"development"' 7 | }) 8 | -------------------------------------------------------------------------------- /node-cors/vue-cli2-demo/.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | charset = utf-8 5 | indent_style = space 6 | indent_size = 2 7 | end_of_line = lf 8 | insert_final_newline = true 9 | trim_trailing_whitespace = true 10 | -------------------------------------------------------------------------------- /node-cors/hash/a.html: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /node-cors/vue-cli3-demo/vue.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | devServer: { 3 | port: 8000, 4 | proxy: { 5 | '/api': { 6 | target: 'http://localhost:8080', 7 | } 8 | } 9 | } 10 | } -------------------------------------------------------------------------------- /node-cors/vue-cli2-demo/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules/ 3 | /dist/ 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | 8 | # Editor directories and files 9 | .idea 10 | .vscode 11 | *.suo 12 | *.ntvs* 13 | *.njsproj 14 | *.sln 15 | -------------------------------------------------------------------------------- /node-cors/websocket/server.js: -------------------------------------------------------------------------------- 1 | const WebSocket = require("ws"); 2 | const server = new WebSocket.Server({ port: 8080 }); 3 | server.on("connection", function (socket) { 4 | socket.on("message", function (data) { 5 | socket.send(data); 6 | }); 7 | }); 8 | -------------------------------------------------------------------------------- /webpack/optimization.splitChunks.chunks/src/a.js: -------------------------------------------------------------------------------- 1 | //a.js 2 | import { findIndex } from "lodash"; 3 | 4 | if(some_condition_is_true){ 5 | import ("dayjs").then((e) => {console.log(e)}) 6 | } 7 | 8 | findIndex([1, 2, 3]); 9 | console.log("My app is running"); -------------------------------------------------------------------------------- /node-cors/hash/c.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /file-download/README.md: -------------------------------------------------------------------------------- 1 | # 文件下载 demo 示例库 2 | 3 | 在线预览 4 | 5 | 本地启动 6 | 7 | ```bash 8 | npm install 9 | 10 | node server.js 11 | 12 | ``` 13 | 14 | 打开 http://localhost:8888/example/index.html 15 | 16 | 17 | 示例如下 18 | 19 | ![](https://s3.qiufengh.com/blog/前端文件下载.png) 20 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 相关示例 2 | 3 | [node文件上传详解](./node-upload-stream/README.md) 4 | 5 | [node-rpc调用详解](./node-rpc/README.md) 6 | 7 | [跨域 demo](./node-cors/README.md) 8 | 9 | [重拾css[一]伪元素、包含块和高度坍塌](./css-margin/README.md) 10 | 11 | [React Hooks中这样写HTTP请求可以避免内存泄漏](./react-abort/README.md) 12 | -------------------------------------------------------------------------------- /react-abort/src/setupTests.js: -------------------------------------------------------------------------------- 1 | // jest-dom adds custom jest matchers for asserting on DOM nodes. 2 | // allows you to do things like: 3 | // expect(element).toHaveTextContent(/react/i) 4 | // learn more: https://github.com/testing-library/jest-dom 5 | import '@testing-library/jest-dom/extend-expect'; 6 | -------------------------------------------------------------------------------- /ansi-code/demo/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Getting Started 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /node-cors/vue-cli2-demo/.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | ["env", { 4 | "modules": false, 5 | "targets": { 6 | "browsers": ["> 1%", "last 2 versions", "not ie <= 8"] 7 | } 8 | }], 9 | "stage-2" 10 | ], 11 | "plugins": ["transform-vue-jsx", "transform-runtime"] 12 | } 13 | -------------------------------------------------------------------------------- /node-cors/vue-cli2-demo/.postcssrc.js: -------------------------------------------------------------------------------- 1 | // https://github.com/michael-ciniawsky/postcss-load-config 2 | 3 | module.exports = { 4 | "plugins": { 5 | "postcss-import": {}, 6 | "postcss-url": {}, 7 | // to edit target browsers: use "browserslist" field in package.json 8 | "autoprefixer": {} 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /react-abort/src/App.test.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { render } from '@testing-library/react'; 3 | import App from './App'; 4 | 5 | test('renders learn react link', () => { 6 | const { getByText } = render(); 7 | const linkElement = getByText(/learn react/i); 8 | expect(linkElement).toBeInTheDocument(); 9 | }); 10 | -------------------------------------------------------------------------------- /confetti/README.md: -------------------------------------------------------------------------------- 1 | # 微信8.0表情特效-🎉礼花(confetti) 2 | 3 | ### websocket特效预览 4 | 5 | ![](https://s3.qiufengh.com/blog/2021-02-06-12.22.12.gif) 6 | 7 | 在线地址: https://qiufengh.com/ 8 | 9 | 10 | ### 特效预览 11 | ![](https://s3.qiufengh.com/blog/2021-02-05-21.32.43.gif) 12 | 13 | 14 | ### 文章讲解地址: 15 | 16 | https://juejin.cn/post/6926010284578603021 -------------------------------------------------------------------------------- /node-cors/vue-cli3-demo/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules 3 | /dist 4 | 5 | # local env files 6 | .env.local 7 | .env.*.local 8 | 9 | # Log files 10 | npm-debug.log* 11 | yarn-debug.log* 12 | yarn-error.log* 13 | 14 | # Editor directories and files 15 | .idea 16 | .vscode 17 | *.suo 18 | *.ntvs* 19 | *.njsproj 20 | *.sln 21 | *.sw? 22 | -------------------------------------------------------------------------------- /ansi-code/demo/src/index.js: -------------------------------------------------------------------------------- 1 | function component() { 2 | const element = document.createElement('div'); 3 | 4 | // Lodash, currently included via a script, is required for this line to work 5 | element.innerHTML = _.join(['Hello', 'webpack'], ' '); 6 | 7 | return element; 8 | } 9 | 10 | document.body.appendChild(component()); -------------------------------------------------------------------------------- /node-rpc-rest/rpc/gen-nodejs/hello_types.js: -------------------------------------------------------------------------------- 1 | // 2 | // Autogenerated by Thrift Compiler (0.11.0) 3 | // 4 | // DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING 5 | // 6 | "use strict"; 7 | 8 | var thrift = require('thrift'); 9 | var Thrift = thrift.Thrift; 10 | var Q = thrift.Q; 11 | 12 | 13 | var ttypes = module.exports = {}; 14 | -------------------------------------------------------------------------------- /node-cors/jsonp/server.js: -------------------------------------------------------------------------------- 1 | const Koa = require('koa'); 2 | const fs = require('fs'); 3 | const app = new Koa(); 4 | 5 | app.use(async (ctx, next) => { 6 | if (ctx.path === '/api/jsonp') { 7 | const { cb, msg } = ctx.query; 8 | ctx.body = `${cb}(${JSON.stringify({msg})})` 9 | return; 10 | } 11 | }) 12 | 13 | app.listen(8080); -------------------------------------------------------------------------------- /node-cors/webpack/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "webpack", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "webpack": "../node_modules/.bin/webpack-dev-server" 8 | }, 9 | "keywords": [], 10 | "author": "hua1995116 (https://github.com/hua1995116)", 11 | "license": "MIT" 12 | } 13 | -------------------------------------------------------------------------------- /node-cors/postMessage/server.js: -------------------------------------------------------------------------------- 1 | const Koa = require("koa"); 2 | const fs = require("fs"); 3 | const path = require('path'); 4 | const app = new Koa(); 5 | 6 | app.use(async (ctx, next) => { 7 | if (ctx.method === "GET" && ctx.path === "/") { 8 | ctx.body = fs.readFileSync(path.join(__dirname, "./another.html")).toString(); 9 | } 10 | }); 11 | 12 | app.listen(8080); 13 | -------------------------------------------------------------------------------- /node-rpc-rest/rest/index.js: -------------------------------------------------------------------------------- 1 | const Koa = require('koa'); 2 | const router = require('koa-router')(); 3 | const app = new Koa(); 4 | 5 | router.get('/v1/getList', async (ctx) => { 6 | ctx.body = { 7 | data: [{ user: 'qiufeng', age: 18 }], 8 | msg: 'success', 9 | errno: 0 10 | } 11 | }); 12 | 13 | app.use(router.routes()); 14 | 15 | app.listen(3000); -------------------------------------------------------------------------------- /react-abort/README.md: -------------------------------------------------------------------------------- 1 | # react 取消 web 请求示例 2 | 3 | react-abort/src/App.js 4 | 5 | 内存泄露模式 6 | ```js 7 | import Users from './pages/Users-1' 8 | import Posts from './pages/Posts-1' 9 | 10 | ``` 11 | 12 | 内存不泄露模式 13 | ```js 14 | import Users from './pages/Users' 15 | import Posts from './pages/Posts' 16 | ``` 17 | 18 | 原文地址: https://qiufeng.blue/frontend/cancel-react-hooks-request.html -------------------------------------------------------------------------------- /ansi-code/index.js: -------------------------------------------------------------------------------- 1 | const { spawn } = require('child_process'); 2 | const cmd = spawn('sh', ['build.sh']); 3 | 4 | cmd.stdout.on('data', (data) => { 5 | console.log(`stdout: ${data}`); 6 | }); 7 | 8 | cmd.stderr.on('data', (data) => { 9 | console.log(`stderr: ${data}`); 10 | }); 11 | 12 | cmd.on('close', (code) => { 13 | console.log(`child process exited with code ${code}`); 14 | }); -------------------------------------------------------------------------------- /node-cors/hash/server.js: -------------------------------------------------------------------------------- 1 | const Koa = require("koa"); 2 | const fs = require("fs"); 3 | const path = require("path"); 4 | const app = new Koa(); 5 | 6 | app.use(async (ctx, next) => { 7 | console.log(ctx.path); 8 | if (ctx.method === "GET" && ctx.path === "/hash/c.html") { 9 | ctx.body = fs.readFileSync(path.join(__dirname, "./c.html")).toString(); 10 | } 11 | }); 12 | 13 | app.listen(8080); 14 | -------------------------------------------------------------------------------- /node-cors/name/server.js: -------------------------------------------------------------------------------- 1 | const Koa = require("koa"); 2 | const fs = require("fs"); 3 | const path = require("path"); 4 | const app = new Koa(); 5 | 6 | app.use(async (ctx, next) => { 7 | console.log(ctx.path); 8 | if (ctx.method === "GET" && ctx.path === "/name/c.html") { 9 | ctx.body = fs.readFileSync(path.join(__dirname, "./c.html")).toString(); 10 | } 11 | }); 12 | 13 | app.listen(8080); 14 | -------------------------------------------------------------------------------- /node-upload-stream/node/buffer.js: -------------------------------------------------------------------------------- 1 | function streamToBuffer(stream) { 2 | return new Promise((resolve, reject) => { 3 | const buffers = []; 4 | stream.on('error', reject); 5 | stream.on('data', (data) => buffers.push(data)) 6 | stream.on('end', () => resolve(Buffer.concat(buffers))) 7 | }); 8 | } 9 | 10 | const b64string = 123; 11 | const buf = Buffer.from(b64string, 'base64'); -------------------------------------------------------------------------------- /node-upload-stream/node/request-error.js: -------------------------------------------------------------------------------- 1 | const fs = require('fs'); 2 | const path = require('path'); 3 | const request = require('request'); 4 | 5 | const stream = fs.readFileSync(path.join(__dirname, '../1.png')); 6 | 7 | request.post({ 8 | url: 'http://localhost:7787/files', 9 | formData: { 10 | file: stream, 11 | } 12 | }, (err, res, body) => { 13 | console.log(body); 14 | }) -------------------------------------------------------------------------------- /ansi-code/package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ansi-code", 3 | "version": "1.0.0", 4 | "lockfileVersion": 1, 5 | "requires": true, 6 | "dependencies": { 7 | "ansi-color-parse": { 8 | "version": "0.1.4", 9 | "resolved": "https://registry.nlark.com/ansi-color-parse/download/ansi-color-parse-0.1.4.tgz", 10 | "integrity": "sha1-T19icPmT4WByieI2XsPm3nHy548=" 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /ansi-code/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ansi-code", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "keywords": [], 10 | "author": "hua1995116 (https://github.com/hua1995116)", 11 | "license": "MIT", 12 | "dependencies": { 13 | "ansi-color-parse": "^0.1.4" 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /node-cors/vue-cli2-demo/src/main.js: -------------------------------------------------------------------------------- 1 | // The Vue build version to load with the `import` command 2 | // (runtime-only or standalone) has been set in webpack.base.conf with an alias. 3 | // import Vue from 'vue' 4 | // import App from './App' 5 | 6 | // Vue.config.productionTip = false 7 | 8 | // /* eslint-disable no-new */ 9 | // new Vue({ 10 | // el: '#app', 11 | // components: { App }, 12 | // template: '' 13 | // }) 14 | -------------------------------------------------------------------------------- /react-abort/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # production 12 | /build 13 | 14 | # misc 15 | .DS_Store 16 | .env.local 17 | .env.development.local 18 | .env.test.local 19 | .env.production.local 20 | 21 | npm-debug.log* 22 | yarn-debug.log* 23 | yarn-error.log* 24 | -------------------------------------------------------------------------------- /watermark/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "watermark", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "keywords": [], 10 | "author": "hua1995116 (https://github.com/hua1995116)", 11 | "license": "MIT", 12 | "dependencies": { 13 | "@alicloud/pop-core": "^1.7.10" 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /node-cors/parcel-demo/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "parcel-demo", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "keywords": [], 10 | "author": "hua1995116 (https://github.com/hua1995116)", 11 | "license": "MIT", 12 | "dependencies": { 13 | "parcel": "^2.0.0-alpha.3.2" 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /node-upload-stream/html/file.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Document 7 | 8 | 9 |
10 | 11 | 12 |
13 | 14 | -------------------------------------------------------------------------------- /webpack/loaders/example-01/webpack.config-2.js: -------------------------------------------------------------------------------- 1 | const path = require("path"); 2 | 3 | module.exports = { 4 | entry: "./index.js", 5 | output: { 6 | path: path.resolve(__dirname, "dist"), 7 | filename: "bundle.js", 8 | }, 9 | module: { 10 | rules: [{ 11 | test: /\.muji$/, 12 | use: [ 13 | { 14 | loader: path.resolve("./loaders/myLoader.js"), 15 | } 16 | ] 17 | }] 18 | }, 19 | }; 20 | -------------------------------------------------------------------------------- /ansi-code/demo/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "demo", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "keywords": [], 10 | "author": "hua1995116 (https://github.com/hua1995116)", 11 | "license": "MIT", 12 | "devDependencies": { 13 | "webpack": "^5.53.0", 14 | "webpack-cli": "^4.8.0" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /node-rpc-rest/rpc/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "rpc", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "client.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1", 8 | "start": "node server.js" 9 | }, 10 | "keywords": [], 11 | "author": "hua1995116 (https://github.com/hua1995116)", 12 | "license": "MIT", 13 | "dependencies": { 14 | "thrift": "^0.12.0" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /node-cors/vue-cli3-demo/README.md: -------------------------------------------------------------------------------- 1 | # vue-cli3-demo 2 | 3 | ## Project setup 4 | ``` 5 | npm install 6 | ``` 7 | 8 | ### Compiles and hot-reloads for development 9 | ``` 10 | npm run serve 11 | ``` 12 | 13 | ### Compiles and minifies for production 14 | ``` 15 | npm run build 16 | ``` 17 | 18 | ### Lints and fixes files 19 | ``` 20 | npm run lint 21 | ``` 22 | 23 | ### Customize configuration 24 | See [Configuration Reference](https://cli.vuejs.org/config/). 25 | -------------------------------------------------------------------------------- /node-upload-stream/node/request.js: -------------------------------------------------------------------------------- 1 | const fs = require('fs'); 2 | const path = require('path'); 3 | const request = require('request'); 4 | 5 | const stream = fs.createReadStream(path.join(__dirname, '../1.png')); 6 | 7 | request.post({ 8 | url: 'http://localhost:7787/files', 9 | formData: { 10 | file: { 11 | value: stream, 12 | options: { 13 | filename: '1.png' 14 | } 15 | }, 16 | } 17 | }); -------------------------------------------------------------------------------- /webpack/loaders/example-01/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "example-01", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "build": "webpack" 8 | }, 9 | "keywords": [], 10 | "author": "hua1995116 (https://github.com/hua1995116)", 11 | "license": "MIT", 12 | "devDependencies": { 13 | "loader-utils": "^2.0.0", 14 | "webpack": "^5.56.0", 15 | "webpack-cli": "^4.8.0" 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /node-rpc-rest/rest/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "rest", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "keywords": [], 10 | "author": "hua1995116 (https://github.com/hua1995116)", 11 | "license": "MIT", 12 | "dependencies": { 13 | "axios": "^0.19.2", 14 | "koa": "^2.11.0", 15 | "koa-router": "^8.0.8" 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /file-download/example/download-multiple/simple.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 分片加载 8 | 9 | 10 | 11 |

由于仓库容量问题,请随意放一个 mp4 文件至 static/ 目录下,重命名为 CSS.mp4 ,即可展示例子。

12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /node-upload-stream/html/file-normal.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Document 7 | 8 | 9 |
10 | 11 | 12 |
13 | 14 | -------------------------------------------------------------------------------- /node-cors/postMessage/another.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | inner 8 | 9 | 10 | 11 |
hello
12 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /file-download/example/download-backend/direct.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Document 7 | 8 | 9 | 10 | 15 | 16 | -------------------------------------------------------------------------------- /node-upload-stream/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "node-upload-demo", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "keywords": [], 10 | "author": "hua1995116 (https://github.com/hua1995116)", 11 | "license": "MIT", 12 | "devDependencies": { 13 | "request": "^2.88.2" 14 | }, 15 | "dependencies": { 16 | "form-data": "^3.0.0" 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /react-abort/src/index.css: -------------------------------------------------------------------------------- 1 | body { 2 | margin: 0; 3 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 4 | 'Helvetica Neue', sans-serif; 5 | -webkit-font-smoothing: antialiased; 6 | -moz-osx-font-smoothing: grayscale; 7 | } 8 | 9 | code { 10 | font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', monospace; 11 | } 12 | 13 | a { 14 | color: inherit; 15 | } 16 | 17 | iframe body { 18 | margin: 0; 19 | } -------------------------------------------------------------------------------- /node-cors/name/a.html: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /node-upload-stream/koa/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "koa-server", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "keywords": [], 10 | "author": "hua1995116 (https://github.com/hua1995116)", 11 | "license": "MIT", 12 | "dependencies": { 13 | "koa": "^2.11.0", 14 | "koa-body": "^4.1.1", 15 | "koa-cors": "0.0.16", 16 | "koa-router": "^8.0.8" 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /webpack/loaders/example-01/webpack.config.js: -------------------------------------------------------------------------------- 1 | const path = require("path"); 2 | 3 | module.exports = { 4 | entry: "./index.js", 5 | output: { 6 | path: path.resolve(__dirname, "dist"), 7 | filename: "bundle.js", 8 | }, 9 | module: { 10 | rules: [{ 11 | test: /\.muji$/, 12 | use: [ 13 | { 14 | loader: "myLoader", 15 | } 16 | ] 17 | }] 18 | }, 19 | resolveLoader: { 20 | modules: ["node_modules", path.resolve(__dirname, "loaders")], 21 | }, 22 | }; 23 | -------------------------------------------------------------------------------- /css-margin/block-normal.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Document 7 | 16 | 17 | 18 |
19 |
20 |
21 | 22 | -------------------------------------------------------------------------------- /file-download/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "file-download", 3 | "version": "1.0.0", 4 | "description": "", 5 | "scripts": { 6 | "test": "echo \"Error: no test specified\" && exit 1" 7 | }, 8 | "keywords": [], 9 | "author": "hua1995116 (https://github.com/hua1995116)", 10 | "license": "MIT", 11 | "dependencies": { 12 | "koa": "^2.13.0", 13 | "koa-body": "^4.2.0", 14 | "koa-mount": "^4.0.0", 15 | "koa-router": "^9.4.0", 16 | "koa-static": "^5.0.0", 17 | "mime": "^2.4.6" 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /node-rpc-rest/rest/request.js: -------------------------------------------------------------------------------- 1 | const Koa = require('koa'); 2 | const axios = require('axios'); 3 | const router = require('koa-router')(); 4 | const app = new Koa(); 5 | 6 | router.get('/v1/getSuperList', async (ctx) => { 7 | const result = await axios.get('http://127.0.0.1:3000/v1/getList'); 8 | console.log(result); 9 | ctx.body = { 10 | data: result.data.data.map(item => ({...item, github: 'hua1995116'})), 11 | msg: 'success', 12 | errno: 0 13 | } 14 | }); 15 | 16 | app.use(router.routes()); 17 | 18 | app.listen(3001); -------------------------------------------------------------------------------- /node-cors/cors-any/server.js: -------------------------------------------------------------------------------- 1 | // Listen on a specific host via the HOST environment variable 2 | var host = process.env.HOST || '0.0.0.0'; 3 | // Listen on a specific port via the PORT environment variable 4 | var port = process.env.PORT || 7777; 5 | 6 | var cors_proxy = require('cors-anywhere'); 7 | cors_proxy.createServer({ 8 | originWhitelist: [], // Allow all origins 9 | requireHeader: ['origin', 'x-requested-with'], 10 | removeHeaders: [] 11 | }).listen(port, host, function() { 12 | console.log('Running CORS Anywhere on ' + host + ':' + port); 13 | }); -------------------------------------------------------------------------------- /node-cors/websocket/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | websocket 8 | 9 | 10 | 11 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /node-cors/vue-cli2-demo/README.md: -------------------------------------------------------------------------------- 1 | # vue-cli2-demo2 2 | 3 | > A Vue.js project 4 | 5 | ## Build Setup 6 | 7 | ``` bash 8 | # install dependencies 9 | npm install 10 | 11 | # serve with hot reload at localhost:8080 12 | npm run dev 13 | 14 | # build for production with minification 15 | npm run build 16 | 17 | # build for production and view the bundle analyzer report 18 | npm run build --report 19 | ``` 20 | 21 | For a detailed explanation on how things work, check out the [guide](http://vuejs-templates.github.io/webpack/) and [docs for vue-loader](http://vuejs.github.io/vue-loader). 22 | -------------------------------------------------------------------------------- /react-abort/src/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import './index.css'; 4 | import App from './App'; 5 | import * as serviceWorker from './serviceWorker'; 6 | 7 | ReactDOM.render( 8 | 9 | 10 | , 11 | document.getElementById('root') 12 | ); 13 | 14 | // If you want your app to work offline and load faster, you can change 15 | // unregister() to register() below. Note this comes with some pitfalls. 16 | // Learn more about service workers: https://bit.ly/CRA-PWA 17 | serviceWorker.unregister(); 18 | -------------------------------------------------------------------------------- /file-download/static/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 分片流传输 4 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /node-cors/vue-cli2-demo/src/App.vue: -------------------------------------------------------------------------------- 1 | 7 | 8 | 18 | 19 | 29 | -------------------------------------------------------------------------------- /css-margin/begin-problem-2.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Document 8 | 19 | 20 | 21 | 22 |
23 |
24 |
25 | 26 | -------------------------------------------------------------------------------- /css-margin/pseudo-classes.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Document 8 | 16 | 17 | 18 | 19 |
20 |

21 | This is a somewhat long HTML 22 | paragraph that will be broken into several 23 | lines. 24 |

25 |
26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /node-cors/webpack/webpack.config.js: -------------------------------------------------------------------------------- 1 | const path = require("path"); 2 | const HtmlWebpackPlugin = require("html-webpack-plugin"); 3 | 4 | module.exports = { 5 | entry: { 6 | index: "./index.js", 7 | }, 8 | output: { 9 | filename: "bundle.js", 10 | path: path.resolve(__dirname, "dist"), 11 | }, 12 | devServer: { 13 | port: 8000, 14 | proxy: { 15 | '/api': { 16 | target: 'http://localhost:8080', 17 | } 18 | } 19 | }, 20 | plugins: [ 21 | new HtmlWebpackPlugin({ 22 | filename: "index.html", 23 | template: "webpack.html" 24 | }), 25 | ], 26 | }; 27 | -------------------------------------------------------------------------------- /css-margin/begin-problem-1.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Document 8 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | -------------------------------------------------------------------------------- /react-abort/public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "React App", 3 | "name": "Create React App Sample", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | }, 10 | { 11 | "src": "logo192.png", 12 | "type": "image/png", 13 | "sizes": "192x192" 14 | }, 15 | { 16 | "src": "logo512.png", 17 | "type": "image/png", 18 | "sizes": "512x512" 19 | } 20 | ], 21 | "start_url": ".", 22 | "display": "standalone", 23 | "theme_color": "#000000", 24 | "background_color": "#ffffff" 25 | } 26 | -------------------------------------------------------------------------------- /wechat-feces/2-1-lottie.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 17 | 18 | -------------------------------------------------------------------------------- /css-margin/block-fixed.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Document 8 | 21 | 22 | 23 | 24 |
25 |
26 |
27 |
28 |
29 | 30 | 31 | -------------------------------------------------------------------------------- /css-margin/block-absolute.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Document 8 | 21 | 22 | 23 | 24 |
25 |
26 |
27 |
28 |
29 | 30 | 31 | -------------------------------------------------------------------------------- /node-cors/postMessage/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | index 8 | 9 | 10 | 11 | 12 | 13 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /webpack/loaders/example-01/loaders/myLoader.js: -------------------------------------------------------------------------------- 1 | // import { getOptions } from "loader-utils"; 2 | // import validateOptions from 'schema-utils'; 3 | const { getOptions } = require("loader-utils"); 4 | 5 | // const schema = { 6 | // type: 'object', 7 | // properties: { 8 | // test: { 9 | // type: 'string' 10 | // } 11 | // } 12 | // } 13 | 14 | module.exports = function (source) { 15 | const options = getOptions(this); 16 | 17 | const lines = source.split('\n'); 18 | let str = ``; 19 | if (lines[0].indexOf('name') === 0) { 20 | str = `export const name = "${lines[0].split(":")[1]}"` 21 | } 22 | return str; 23 | } 24 | -------------------------------------------------------------------------------- /css-margin/computed.js: -------------------------------------------------------------------------------- 1 | function computed(AllList) { 2 | const PositiveList = AllList.filter((item) => item >= 0); 3 | const NegativeList = AllList.filter((item) => item <= 0); 4 | const AllPositive = AllList.every((item) => item >= 0); 5 | const AllNegative = AllList.every((item) => item <= 0); 6 | if (AllNegative) { 7 | return Math.min(...AllList); 8 | } else if (AllPositive) { 9 | return Math.max(...AllList); 10 | } else { 11 | const maxPositive = Math.max(...PositiveList); 12 | const minNegative = Math.min(...NegativeList); 13 | return maxPositive + minNegative; 14 | } 15 | } 16 | 17 | console.log(computed([100, 10, -20])); 18 | -------------------------------------------------------------------------------- /css-margin/pseudo-elements.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Document 8 | 17 | 18 | 19 | 20 |
21 |

22 | This is a somewhat long HTML 23 | paragraph that will be broken into several 24 | lines. 25 |

26 |
27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /node-cors/vue-cli3-demo/src/App.vue: -------------------------------------------------------------------------------- 1 | 7 | 8 | 18 | 19 | 29 | -------------------------------------------------------------------------------- /node-rpc-rest/rpc/client.js: -------------------------------------------------------------------------------- 1 | var thrift = require('thrift'); 2 | var helloSvc = require('./gen-nodejs/HelloSvc.js'); 3 | 4 | var options = { 5 | transport: thrift.TBufferedTransport, 6 | protocol: thrift.TJSONProtocol, 7 | path: "/hello", 8 | headers: {"Connection": "close"}, 9 | https: false 10 | }; 11 | 12 | var connection = thrift.createHttpConnection("localhost", 9090, options); 13 | var client = thrift.createHttpClient(helloSvc, connection); 14 | 15 | connection.on("error", function(err) { 16 | console.log("Error: " + err); 17 | }); 18 | 19 | client.hello_func(function(error, result) { 20 | console.log("Msg from server: " + result); 21 | }); 22 | -------------------------------------------------------------------------------- /node-upload-stream/node/form-data.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | const FormData = require('form-data'); 3 | const fs = require('fs'); 4 | const http = require('http'); 5 | 6 | const form = new FormData(); 7 | 8 | form.append('file', fs.readFileSync(path.join(__dirname, '../1.png')), { 9 | filename: '1.png', 10 | contentType: 'image/jpeg', 11 | }); 12 | 13 | const request = http.request({ 14 | method: 'post', 15 | host: 'localhost', 16 | port: '7787', 17 | path: '/files', 18 | headers: form.getHeaders() 19 | }); 20 | 21 | form.pipe(request); 22 | 23 | request.on('response', function(res) { 24 | console.log(res.statusCode); 25 | }); -------------------------------------------------------------------------------- /webpack/optimization.splitChunks.chunks/webpack.config-async.js: -------------------------------------------------------------------------------- 1 | const path = require("path"); 2 | 3 | module.exports = { 4 | entry: { 5 | a: "./src/a.js", 6 | b: "./src/b.js", 7 | }, 8 | output: { 9 | path: path.resolve(__dirname, "dist-async"), 10 | filename: "[name].bundle.js", 11 | chunkFilename: '[name].js' 12 | }, 13 | module: { 14 | rules: [ 15 | { 16 | test: /\.(js|jsx)$/, 17 | exclude: /node_modules/, 18 | use: { 19 | loader: "babel-loader" 20 | } 21 | } 22 | ] 23 | }, 24 | optimization: { 25 | splitChunks: { 26 | chunks: "async", 27 | } 28 | } 29 | }; 30 | -------------------------------------------------------------------------------- /webpack/optimization.splitChunks.chunks/webpack.config-initial.js: -------------------------------------------------------------------------------- 1 | const path = require("path"); 2 | 3 | module.exports = { 4 | entry: { 5 | a: "./src/a.js", 6 | b: "./src/b.js", 7 | }, 8 | output: { 9 | path: path.resolve(__dirname, "dist-initial"), 10 | filename: "[name].bundle.js", 11 | chunkFilename: '[name].js' 12 | }, 13 | module: { 14 | rules: [ 15 | { 16 | test: /\.(js|jsx)$/, 17 | exclude: /node_modules/, 18 | use: { 19 | loader: "babel-loader" 20 | } 21 | } 22 | ] 23 | }, 24 | optimization: { 25 | splitChunks: { 26 | chunks: "initial" 27 | } 28 | } 29 | }; 30 | -------------------------------------------------------------------------------- /node-cors/vue-cli2-demo/build/vue-loader.conf.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | const utils = require('./utils') 3 | const config = require('../config') 4 | const isProduction = process.env.NODE_ENV === 'production' 5 | const sourceMapEnabled = isProduction 6 | ? config.build.productionSourceMap 7 | : config.dev.cssSourceMap 8 | 9 | module.exports = { 10 | loaders: utils.cssLoaders({ 11 | sourceMap: sourceMapEnabled, 12 | extract: isProduction 13 | }), 14 | cssSourceMap: sourceMapEnabled, 15 | cacheBusting: config.dev.cacheBusting, 16 | transformToRequire: { 17 | video: ['src', 'poster'], 18 | source: 'src', 19 | img: 'src', 20 | image: 'xlink:href' 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /node-cors/webpack/webpack.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | dmeo 7 | 8 | 9 | 10 | 11 | 12 | 21 | 22 | -------------------------------------------------------------------------------- /webpack/optimization.splitChunks.chunks/webpack.config-all.js: -------------------------------------------------------------------------------- 1 | const path = require("path"); 2 | 3 | module.exports = { 4 | entry: { 5 | a: "./src/a.js", 6 | b: "./src/b.js", 7 | }, 8 | output: { 9 | path: path.resolve(__dirname, "dist-all"), 10 | filename: "[name].bundle.js", 11 | chunkFilename: '[name].js' 12 | }, 13 | module: { 14 | rules: [ 15 | { 16 | test: /\.(js|jsx)$/, 17 | exclude: /node_modules/, 18 | use: { 19 | loader: "babel-loader" 20 | } 21 | } 22 | ] 23 | }, 24 | optimization: { 25 | splitChunks: { 26 | chunks: "all", 27 | minSize: 0, 28 | } 29 | } 30 | }; 31 | -------------------------------------------------------------------------------- /css-margin/block-absolue-fixed-extra.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Document 8 | 22 | 23 | 24 | 25 |
26 |
27 |
28 |
29 |
30 | 31 | 32 | -------------------------------------------------------------------------------- /css-margin/collapsing-margin-no-case4.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Document 8 | 21 | 22 | 23 | 24 |
25 |
26 |
27 |
为了看间距效果
28 | 29 | 30 | -------------------------------------------------------------------------------- /node-cors/parcel-demo/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | dmeo 7 | 8 | 9 | 10 | 11 | 12 | 13 | 22 | 23 | -------------------------------------------------------------------------------- /file-download/example/download-backend/a-download.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Document 7 | 8 | 9 | 10 | 11 | 21 | 22 | -------------------------------------------------------------------------------- /css-margin/collapsing-margin-computed.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Document 8 | 22 | 23 | 24 | 25 |
26 |
hello1
27 |
hello2
28 |
29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /node-cors/cors-any/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | dmeo 7 | 8 | 9 | 10 | 11 | 12 | 21 | 22 | -------------------------------------------------------------------------------- /css-margin/in-flow.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Document 8 | 28 | 29 | 30 | 31 |
32 |
33 |
看出了啥
34 |
35 | 36 | 37 | -------------------------------------------------------------------------------- /node-cors/vue-cli2-demo/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | vue-cli2-demo2 7 | 8 | 9 |
10 | 11 | 12 | 13 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /node-cors/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "koa-server", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "client": "node client.js", 8 | "server": "node server.js", 9 | "normal-server": "node normaol-server.js" 10 | }, 11 | "keywords": [], 12 | "author": "hua1995116 (https://github.com/hua1995116)", 13 | "license": "MIT", 14 | "dependencies": { 15 | "cors-anywhere": "^0.4.1", 16 | "koa": "^2.11.0", 17 | "koa-body": "^4.1.1", 18 | "koa-cors": "0.0.16", 19 | "koa-mount": "^4.0.0", 20 | "koa-router": "^8.0.8", 21 | "koa-static": "^5.0.0", 22 | "mime": "^2.4.6" 23 | }, 24 | "devDependencies": { 25 | "html-webpack-plugin": "^4.2.0", 26 | "webpack": "^4.42.1", 27 | "webpack-cli": "^3.3.11", 28 | "webpack-dev-server": "^3.10.3", 29 | "ws": "^7.2.3" 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /watermark/demo/demo.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | demo 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 |
2244
5779
10101212
14141616
37 | 38 | 39 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Windows image file caches 2 | Thumbs.db 3 | ehthumbs.db 4 | 5 | # Folder config file 6 | Desktop.ini 7 | 8 | # Recycle Bin used on file shares 9 | $RECYCLE.BIN/ 10 | 11 | # Windows Installer files 12 | *.cab 13 | *.msi 14 | *.msm 15 | *.msp 16 | 17 | # Windows shortcuts 18 | *.lnk 19 | 20 | # ========================= 21 | # Operating System Files 22 | # ========================= 23 | 24 | # OSX 25 | # ========================= 26 | 27 | .DS_Store 28 | .AppleDouble 29 | .LSOverride 30 | 31 | # Thumbnails 32 | ._* 33 | 34 | # Files that might appear in the root of a volume 35 | .DocumentRevisions-V100 36 | .fseventsd 37 | .Spotlight-V100 38 | .TemporaryItems 39 | .Trashes 40 | .VolumeIcon.icns 41 | 42 | # Directories potentially created on remote AFP share 43 | .AppleDB 44 | .AppleDesktop 45 | Network Trash Folder 46 | Temporary Items 47 | .apdisk 48 | node_modules 49 | happy-file 50 | .parcel-cache -------------------------------------------------------------------------------- /node-upload-stream/.gitignore: -------------------------------------------------------------------------------- 1 | # Windows image file caches 2 | Thumbs.db 3 | ehthumbs.db 4 | 5 | # Folder config file 6 | Desktop.ini 7 | 8 | # Recycle Bin used on file shares 9 | $RECYCLE.BIN/ 10 | 11 | # Windows Installer files 12 | *.cab 13 | *.msi 14 | *.msm 15 | *.msp 16 | 17 | # Windows shortcuts 18 | *.lnk 19 | 20 | # ========================= 21 | # Operating System Files 22 | # ========================= 23 | 24 | # OSX 25 | # ========================= 26 | 27 | .DS_Store 28 | .AppleDouble 29 | .LSOverride 30 | 31 | # Thumbnails 32 | ._* 33 | 34 | # Files that might appear in the root of a volume 35 | .DocumentRevisions-V100 36 | .fseventsd 37 | .Spotlight-V100 38 | .TemporaryItems 39 | .Trashes 40 | .VolumeIcon.icns 41 | 42 | # Directories potentially created on remote AFP share 43 | .AppleDB 44 | .AppleDesktop 45 | Network Trash Folder 46 | Temporary Items 47 | .apdisk 48 | node_modules 49 | happy-file -------------------------------------------------------------------------------- /file-download/example/download-backend/a-download-base64.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Document 7 | 8 | 9 | 10 | 11 | 25 | 26 | -------------------------------------------------------------------------------- /node-upload-stream/html/blob.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Document 7 | 8 | 9 | 10 | 11 | 12 | 28 | 29 | -------------------------------------------------------------------------------- /webpack/optimization.splitChunks.chunks/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "optimization.splitChunks.chunks", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "a.js", 6 | "scripts": { 7 | "build:initial": "webpack --config webpack.config-initial.js", 8 | "build:async": "webpack --config webpack.config-async.js", 9 | "build:all": "webpack --config webpack.config-all.js", 10 | "build": "npm-run-all --parallel build:*" 11 | }, 12 | "keywords": [], 13 | "author": "hua1995116 (https://github.com/hua1995116)", 14 | "license": "MIT", 15 | "devDependencies": { 16 | "@babel/plugin-syntax-dynamic-import": "^7.8.3", 17 | "babel-loader": "^8.2.2", 18 | "npm-run-all": "^4.1.5", 19 | "webpack": "^4.28.4", 20 | "webpack-cli": "^3.3.12" 21 | }, 22 | "dependencies": { 23 | "@babel/core": "^7.15.8", 24 | "dayjs": "^1.10.7", 25 | "lodash": "^4.17.21" 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /node-cors/charles/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | dmeo 7 | 8 | 9 | 10 | 11 | 12 | 21 | 31 | 32 | -------------------------------------------------------------------------------- /node-cors/nginx/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | dmeo 7 | 8 | 9 | 10 | 11 | 12 | 21 | 31 | 32 | -------------------------------------------------------------------------------- /react-abort/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "react-hooks-abort-request", 3 | "version": "0.1.0", 4 | "private": true, 5 | "dependencies": { 6 | "@testing-library/jest-dom": "^4.2.4", 7 | "@testing-library/react": "^9.3.2", 8 | "@testing-library/user-event": "^7.1.2", 9 | "react": "^16.13.1", 10 | "react-dom": "^16.13.1", 11 | "react-router-dom": "^5.2.0", 12 | "react-scripts": "3.4.1" 13 | }, 14 | "scripts": { 15 | "start": "react-scripts start", 16 | "build": "react-scripts build", 17 | "test": "react-scripts test", 18 | "eject": "react-scripts eject" 19 | }, 20 | "eslintConfig": { 21 | "extends": "react-app" 22 | }, 23 | "homepage": ".", 24 | "browserslist": { 25 | "production": [ 26 | ">0.2%", 27 | "not dead", 28 | "not op_mini all" 29 | ], 30 | "development": [ 31 | "last 1 chrome version", 32 | "last 1 firefox version", 33 | "last 1 safari version" 34 | ] 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /guide/README.md: -------------------------------------------------------------------------------- 1 | # 前端新手引导库 2 | 3 | ### z-index 实现 4 | [z-index 实现](./index.html) 5 | 6 | ### canvas 实现 7 | [canvas 实现](./canvas.html) 8 | 9 | ### box-shadow 实现 10 | [box-shadow 实现](./box-shadow.html) 11 | 12 | ## 相关文章 13 | 14 | 从王者荣耀里我学会的前端新手指引 : https://juejin.im/post/6891053442530279432 15 | 16 | ## 开源项目 17 | 18 | **[jquery-pagewalkthrough](https://github.com/jwarby/jquery-pagewalkthrough)** 19 | 20 | 优势: 手绘风,适用于特定的网站风格。 21 | 22 | 缺点: 需要依赖 jQuery。 23 | 24 | ![image-20201103112705958](https://s3.qiufengh.com/blog/image-20201103112705958.png) 25 | 26 | **[intro.js](https://github.com/usablica/intro.js)** 27 | 28 | 优势: 拥有丰富的蒙层引导示例,可自定义主题 29 | 30 | 缺点: 个人免费,商业需要付费。 31 | 32 | ![image-20201103112854822](https://s3.qiufengh.com/blog/image-20201103112854822.png) 33 | 34 | **[driver.js](https://github.com/kamranahmedse/driver.js)** 35 | 36 | 优势: MIT 开源,拥有与 intro.js 差不多的功能。 37 | 38 | 缺点: 示例没有 intro.js 丰富。 39 | 40 | ![image-20201103113117404](https://s3.qiufengh.com/blog/image-20201103113117404.png) 41 | -------------------------------------------------------------------------------- /file-download/example/download-experiment/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 秋风的笔记-download-playground 8 | 9 | 10 | 11 | 12 |

13 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /node-rpc-rest/rpc/hello.thrift: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | service HelloSvc { 20 | string hello_func(), 21 | } 22 | 23 | service TimesTwo { 24 | i64 dbl(1: i64 val), 25 | } -------------------------------------------------------------------------------- /node-cors/jsonp/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | dmeo 8 | 9 | 10 | 11 | 16 | 17 | 18 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /node-upload-stream/node/stream.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | const fs = require('fs'); 3 | const http = require('http'); 4 | // 定义一个分隔符,要确保唯一性 5 | const boundaryKey = '-------------------------461591080941622511336662'; 6 | const request = http.request({ 7 | method: 'post', 8 | host: 'localhost', 9 | port: '7787', 10 | path: '/files', 11 | headers: { 12 | 'Content-Type': 'multipart/form-data; boundary=' + boundaryKey, // 在请求头上加上分隔符 13 | 'Connection': 'keep-alive' 14 | } 15 | }); 16 | // 写入内容头部 17 | request.write( 18 | `--${boundaryKey}\r\nContent-Disposition: form-data; name="file"; filename="1.png"\r\nContent-Type: image/jpeg\r\n\r\n` 19 | ); 20 | // 写入内容 21 | const fileStream = fs.createReadStream(path.join(__dirname, '../1.png')); 22 | fileStream.pipe(request, { end: false }); 23 | fileStream.on('end', function () { 24 | // 写入尾部 25 | request.end('\r\n--' + boundaryKey + '--' + '\r\n'); 26 | }); 27 | request.on('response', function(res) { 28 | console.log(res.statusCode); 29 | }); -------------------------------------------------------------------------------- /white-board/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | white-board 8 | 33 | 34 | 35 |
36 |

白板示例

37 | 38 |
39 | 40 | 41 | -------------------------------------------------------------------------------- /file-download/example/download-frontend/docx-simple.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | doc 7 | 8 | 9 |
10 |

welcome

11 |

秋风的笔记

12 |
13 | 14 | 28 | 29 | -------------------------------------------------------------------------------- /file-download/example/download-ios/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | download-ios 7 | 8 | 9 | 10 | 11 | 29 | 30 | -------------------------------------------------------------------------------- /node-cors/vue-cli3-demo/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "vue-cli3-demo", 3 | "version": "0.1.0", 4 | "private": true, 5 | "scripts": { 6 | "serve": "vue-cli-service serve", 7 | "build": "vue-cli-service build", 8 | "lint": "vue-cli-service lint" 9 | }, 10 | "dependencies": { 11 | "core-js": "^3.6.4", 12 | "vue": "^2.6.11" 13 | }, 14 | "devDependencies": { 15 | "@vue/cli-plugin-babel": "~4.3.0", 16 | "@vue/cli-plugin-eslint": "~4.3.0", 17 | "@vue/cli-service": "~4.3.0", 18 | "babel-eslint": "^10.1.0", 19 | "eslint": "^6.7.2", 20 | "eslint-plugin-vue": "^6.2.2", 21 | "vue-template-compiler": "^2.6.11" 22 | }, 23 | "eslintConfig": { 24 | "root": true, 25 | "env": { 26 | "node": true 27 | }, 28 | "extends": [ 29 | "plugin:vue/essential", 30 | "eslint:recommended" 31 | ], 32 | "parserOptions": { 33 | "parser": "babel-eslint" 34 | }, 35 | "rules": {} 36 | }, 37 | "browserslist": [ 38 | "> 1%", 39 | "last 2 versions", 40 | "not dead" 41 | ] 42 | } 43 | -------------------------------------------------------------------------------- /node-cors/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | dmeo 7 | 8 | 9 | 10 | 11 | 12 | 25 | 35 | 36 | -------------------------------------------------------------------------------- /file-download/example/download-backend/a-download-cors.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Document 8 | 9 | 10 | 11 | 12 | 13 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /node-upload-stream/html/arraybuffer.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Document 7 | 8 | 9 | 10 | 11 | 12 | 25 | 26 | -------------------------------------------------------------------------------- /react-abort/src/App.css: -------------------------------------------------------------------------------- 1 | .App { 2 | width: 100%; 3 | height: 100%; 4 | background-color: #000000; 5 | display: grid; 6 | grid-template-columns: 280px auto; 7 | height: 100vh; 8 | overflow: hidden; 9 | } 10 | 11 | .App__sidebar { 12 | padding: 10px; 13 | height: 100%; 14 | box-sizing: border-box; 15 | background-color: rgb(33, 33, 33); 16 | color: #ffffff; 17 | } 18 | 19 | .App__sidebar ul { 20 | padding: 0; 21 | margin: 0; 22 | display: flex; 23 | flex-direction: column; 24 | } 25 | 26 | .App__sidebar ul a { 27 | color: rgb(170, 170, 170); 28 | text-decoration: underline; 29 | padding: 10px 10px; 30 | display: block; 31 | } 32 | 33 | .App__page { 34 | display: block; 35 | padding: 10px 20px; 36 | min-height: 100%; 37 | overflow-y: auto; 38 | overflow-x: hidden; 39 | color: #ffffff; 40 | } 41 | 42 | .App__page h1 { 43 | margin: 0; 44 | } 45 | 46 | .App__page p { 47 | margin: 20px 0; 48 | } 49 | 50 | .list { 51 | display: flex; 52 | flex-direction: column; 53 | padding: 20px 0; 54 | } 55 | 56 | .list > .listitem { 57 | margin: 10px; 58 | width: 100%; 59 | padding: 10px 0; 60 | } 61 | -------------------------------------------------------------------------------- /file-download/example/download-frontend/json-text.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | file-dowanload 8 | 9 | 10 | 11 | 12 | 13 |

14 | 19 | 20 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /ansi-code/index-2.js: -------------------------------------------------------------------------------- 1 | const { spawn } = require('child_process'); 2 | const {parseAnsi, ansi2html, parseHtml} = require('ansi-color-parse'); 3 | 4 | // const str = "\u001b[34mHello\u001b[39m World\u001b[31m!\u001b[39m"; 5 | 6 | // const parseList = parseAnsi(str); 7 | 8 | // console.log(parseList); 9 | // [ { foreground: 'blue', text: 'Hello' }, 10 | // { text: ' World' }, 11 | // { foreground: 'red', text: '!' } ] 12 | 13 | // console.log(ansi2html(parseList)); 14 | // Hello World! 15 | 16 | const cmd = spawn('sh', ['build.sh']); 17 | 18 | let text = ""; 19 | 20 | cmd.stdout.on('data', (data) => { 21 | console.log(`stdout: ${data}`); 22 | text += (data.toString()); 23 | }); 24 | 25 | cmd.stderr.on('data', (data) => { 26 | console.log(`stderr: ${data}`); 27 | text += (data.toString()); 28 | }); 29 | 30 | cmd.on('close', (code) => { 31 | // console.log((text)); 32 | const parseList = parseAnsi(text); 33 | // console.log(parseList); 34 | console.log("
"+ ansi2html(parseList, '
') + "
"); 35 | // console.log(`child process exited with code ${code}`); 36 | 37 | }); -------------------------------------------------------------------------------- /watermark/index.js: -------------------------------------------------------------------------------- 1 | const { RPCClient } = require("@alicloud/pop-core"); 2 | var client = new RPCClient({ 3 | endpoint: "http://imm.cn-shenzhen.aliyuncs.com", 4 | accessKeyId: '', 5 | accessKeySecret: '', 6 | apiVersion: "2017-09-06", 7 | }); 8 | (async () => { 9 | try { 10 | // var params = { 11 | // Project: "test-project", 12 | // ImageUri: "oss://watermark-shenzheng/source/1605680005172.jpg", 13 | // TargetUri: "oss://watermark-shenzheng/dist/1605680005172-out1.jpg", 14 | // Content: "秋风", 15 | // Model: "DWT" 16 | // }; 17 | // var result = await client.request("EncodeBlindWatermark", params); 18 | var params = { 19 | Project: "test-project", 20 | ImageUri: "oss://watermark-shenzheng/dist/1605680005172-out-scale.jpg", 21 | TargetUri: "oss://watermark-shenzheng/dist/1605680005172-out-decode-scale.jpg", 22 | Model: "DWT" 23 | }; 24 | var result = await client.request("DecodeBlindWatermark", params); 25 | 26 | console.log(result); 27 | } catch (err) { 28 | console.log(err); 29 | } 30 | })() -------------------------------------------------------------------------------- /node-upload-stream/html/formdata.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Document 7 | 8 | 9 | 10 | 11 | 12 | 36 | 37 | -------------------------------------------------------------------------------- /node-upload-stream/html/base64.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Document 7 | 8 | 9 | 10 | 11 | 12 | 30 | 31 | -------------------------------------------------------------------------------- /react-abort/src/pages/Home.js: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | // import Gist from 'react-gist' 3 | import { Link } from 'react-router-dom' 4 | 5 | function Home() { 6 | return ( 7 | <> 8 |

Home

9 |

10 | Open the console developer and switch page very rapidly to{' '} 11 | 12 | /users 13 | {' '} 14 | and{' '} 15 | 16 | /posts 17 | {' '} 18 | and back to the homepage. 19 |

20 |

21 | Learn more here:{' '} 22 | 23 | 24 | 🍦 25 | {' '} 26 | Cancel Properly HTTP Requests in React Hooks and avoid Memory Leaks{' '} 27 | 28 | 🚨 29 | 30 | 31 |

32 |

Source code:

33 | {/* */} 34 | 35 | ) 36 | } 37 | 38 | export default Home 39 | -------------------------------------------------------------------------------- /node-cors/normal-server.js: -------------------------------------------------------------------------------- 1 | const Koa = require('koa'); 2 | const router = require('koa-router')(); 3 | const koaBody = require('koa-body'); 4 | const fs = require('fs'); 5 | const app = new Koa(); 6 | const token = 'dwqwqe1231'; 7 | 8 | app.use(async (ctx, next) => { 9 | console.log(ctx.path); 10 | if (ctx.path === '/api/login') { 11 | await next(); 12 | return; 13 | } 14 | const cookies = ctx.cookies.get('token'); 15 | console.log(cookies); 16 | if (cookies && cookies === token) { 17 | await next(); 18 | return; 19 | } 20 | ctx.body = { 21 | code: 401, 22 | msg: '权限错误', 23 | } 24 | return; 25 | }) 26 | 27 | // app.use(cors()); 28 | app.use(koaBody({ multipart: true })); 29 | 30 | router.get('/api/corslist', async (ctx) => { 31 | ctx.body = { 32 | data: [{name: '秋风的笔记'}] 33 | } 34 | }) 35 | 36 | router.post('/api/login', async (ctx) => { 37 | ctx.cookies.set('token', token, { 38 | expires: new Date(+new Date() + 1000 * 60 * 60 * 24 * 7), 39 | }) 40 | ctx.body = { 41 | msg: '成功', 42 | code: 0 43 | }; 44 | } 45 | ); 46 | 47 | app.use(router.routes()); 48 | 49 | app.listen(8080); -------------------------------------------------------------------------------- /node-rpc-rest/rpc/server.js: -------------------------------------------------------------------------------- 1 | var thrift = require('thrift'); 2 | var helloSvc = require('./gen-nodejs/HelloSvc'); 3 | 4 | //ServiceHandler: Implement the hello service 5 | var helloHandler = { 6 | hello_func: function (result) { 7 | console.log("Received Hello call"); 8 | result(null, "Hello from Node.js"); 9 | } 10 | }; 11 | 12 | //ServiceOptions: The I/O stack for the service 13 | var helloSvcOpt = { 14 | handler: helloHandler, 15 | processor: helloSvc, 16 | protocol: thrift.TJSONProtocol, 17 | transport: thrift.TBufferedTransport 18 | }; 19 | 20 | //ServerOptions: Define server features 21 | var serverOpt = { 22 | services: { 23 | "/hello": helloSvcOpt 24 | } 25 | } 26 | 27 | //Create and start the web server 28 | var port = 9090; 29 | thrift.createWebServer(serverOpt).listen(port); 30 | console.log("Http/Thrift Server running on port: " + port); -------------------------------------------------------------------------------- /node-cors/vue-cli3-demo/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | <%= htmlWebpackPlugin.options.title %> 9 | 10 | 11 | 14 |
15 | 16 | 17 | 18 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /react-abort/src/App.js: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import { BrowserRouter as Router, Switch, Route, Link } from 'react-router-dom' 3 | import Users from './pages/Users-1' 4 | import Posts from './pages/Posts-1' 5 | // import Users from './pages/Users' 6 | // import Posts from './pages/Posts' 7 | import Home from './pages/Home' 8 | import './App.css' 9 | 10 | export default function App() { 11 | return ( 12 | 13 |
14 | 27 |
28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 |
40 |
41 |
42 | ) 43 | } -------------------------------------------------------------------------------- /watermark/demo/canvas-compare.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | canvas-dark-watermark 8 | 9 | 10 | 11 | 12 | 13 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /node-cors/vue-cli2-demo/build/build.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | require('./check-versions')() 3 | 4 | process.env.NODE_ENV = 'production' 5 | 6 | const ora = require('ora') 7 | const rm = require('rimraf') 8 | const path = require('path') 9 | const chalk = require('chalk') 10 | const webpack = require('webpack') 11 | const config = require('../config') 12 | const webpackConfig = require('./webpack.prod.conf') 13 | 14 | const spinner = ora('building for production...') 15 | spinner.start() 16 | 17 | rm(path.join(config.build.assetsRoot, config.build.assetsSubDirectory), err => { 18 | if (err) throw err 19 | webpack(webpackConfig, (err, stats) => { 20 | spinner.stop() 21 | if (err) throw err 22 | process.stdout.write(stats.toString({ 23 | colors: true, 24 | modules: false, 25 | children: false, // If you are using ts-loader, setting this to true will make TypeScript errors show up during build. 26 | chunks: false, 27 | chunkModules: false 28 | }) + '\n\n') 29 | 30 | if (stats.hasErrors()) { 31 | console.log(chalk.red(' Build failed with errors.\n')) 32 | process.exit(1) 33 | } 34 | 35 | console.log(chalk.cyan(' Build complete.\n')) 36 | console.log(chalk.yellow( 37 | ' Tip: built files are meant to be served over an HTTP server.\n' + 38 | ' Opening index.html over file:// won\'t work.\n' 39 | )) 40 | }) 41 | }) 42 | -------------------------------------------------------------------------------- /react-abort/src/pages/Posts-1.js: -------------------------------------------------------------------------------- 1 | import React, { useState, useEffect, useCallback } from 'react' 2 | 3 | function Posts() { 4 | const [isLoading, setIsLoading] = useState(true) 5 | const [posts, setPosts] = useState([]) 6 | 7 | const fetchPosts = useCallback(async () => { 8 | try { 9 | // Imagine that the fetch is going to take 3 seconds to finish 10 | await new Promise(resolve => setTimeout(resolve, 3000)) 11 | const response = await fetch('https://jsonplaceholder.typicode.com/posts') 12 | const posts = await response.json() 13 | setPosts(posts) 14 | } catch (error) { 15 | console.error(error) 16 | } finally { 17 | setIsLoading(false) 18 | } 19 | }, []) 20 | 21 | useEffect(() => { 22 | fetchPosts() 23 | }, [fetchPosts]) 24 | 25 | return ( 26 | <> 27 |

Posts

28 |
29 | {isLoading ? ( 30 |

Loading...

31 | ) : ( 32 | posts.map(post => ( 33 |
34 |

35 | #{post.id} 36 |

37 |

38 | Title: {post.title} 39 |

40 |

41 | Body: {post.body} 42 |

43 |
44 | )) 45 | )} 46 |
47 | 48 | ) 49 | } 50 | 51 | export default Posts -------------------------------------------------------------------------------- /node-upload-stream/koa/index.js: -------------------------------------------------------------------------------- 1 | const Koa = require('koa'); 2 | const router = require('koa-router')(); 3 | const koaBody = require('koa-body'); 4 | const stream = require('stream'); 5 | const fs = require('fs'); 6 | const cors = require('koa-cors'); 7 | const app = new Koa(); 8 | 9 | app.use(koaBody({ multipart: true })); 10 | app.use(cors()); 11 | 12 | app.use(async (ctx, next) => { 13 | console.log('url==', ctx.url); 14 | await next(); 15 | }); 16 | 17 | router.post('/files', async (ctx) => { 18 | if (!ctx.request.files) { 19 | ctx.body = { 20 | code: 888, 21 | msg: '文件不存在' 22 | } 23 | return; 24 | } 25 | const keys = Object.keys(ctx.request.files); 26 | console.log(ctx.request.files); 27 | if (keys.length == 0) { 28 | ctx.body = { 29 | code: 888, 30 | msg: '文件不存在' 31 | } 32 | return; 33 | } 34 | for (let i = 0; i < keys.length; i++) { 35 | if (typeof ctx.request.files[keys[i]] !== 'object') { 36 | ctx.body = { 37 | code: 999, 38 | msg: '文件格式错误' 39 | } 40 | return; 41 | } 42 | } 43 | fs.ReadStream(ctx.request.files.file.path).pipe(fs.WriteStream(ctx.request.files.file.name)) 44 | ctx.body = { 45 | msg: '文件上传成功', 46 | code: 0 47 | }; 48 | } 49 | ); 50 | 51 | app.use(router.routes()); 52 | 53 | app.listen(7787); -------------------------------------------------------------------------------- /react-abort/src/pages/Users-1.js: -------------------------------------------------------------------------------- 1 | import React, { useState, useEffect, useCallback } from 'react' 2 | 3 | function Users() { 4 | const [isLoading, setIsLoading] = useState(true) 5 | const [users, setUsers] = useState([]) 6 | 7 | const fetchUsers = useCallback(async () => { 8 | try { 9 | // Imagine that the fetch is going to take 3 seconds to load 10 | await new Promise(resolve => setTimeout(resolve, 3000)) 11 | const response = await fetch('https://jsonplaceholder.typicode.com/users') 12 | const users = await response.json() 13 | setUsers(users) 14 | } catch (error) { 15 | console.error(error) 16 | } finally { 17 | setIsLoading(false) 18 | } 19 | }, []) 20 | 21 | useEffect(() => { 22 | fetchUsers() 23 | }, [fetchUsers]) 24 | 25 | return ( 26 | <> 27 |

Users

28 |
29 | {isLoading ? ( 30 |

Loading...

31 | ) : ( 32 | users.map(user => ( 33 |
34 |

35 | #{user.id} 36 |

37 |

38 | Name: {user.name} 39 |

40 |

41 | Username: {user.username} 42 |

43 |
44 | )) 45 | )} 46 |
47 | 48 | ) 49 | } 50 | 51 | export default Users 52 | -------------------------------------------------------------------------------- /watermark/demo/canvas.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | element-watermark 8 | 19 | 20 | 21 | 22 |
23 |

秋风

24 |

hello

25 | 26 |
27 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /css-margin/collapsing-margin-no-case3.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Document 8 | 38 | 39 | 40 | 41 |
42 |
43 |
44 | lorem ipsum 45 |
46 |
47 |
48 | after 49 |
50 |
51 |
52 |
53 |
54 | lorem ipsum 55 |
56 |
57 |
58 | after 59 |
60 | 61 | 62 | 63 | -------------------------------------------------------------------------------- /node-cors/vue-cli2-demo/build/check-versions.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | const chalk = require('chalk') 3 | const semver = require('semver') 4 | const packageConfig = require('../package.json') 5 | const shell = require('shelljs') 6 | 7 | function exec (cmd) { 8 | return require('child_process').execSync(cmd).toString().trim() 9 | } 10 | 11 | const versionRequirements = [ 12 | { 13 | name: 'node', 14 | currentVersion: semver.clean(process.version), 15 | versionRequirement: packageConfig.engines.node 16 | } 17 | ] 18 | 19 | if (shell.which('npm')) { 20 | versionRequirements.push({ 21 | name: 'npm', 22 | currentVersion: exec('npm --version'), 23 | versionRequirement: packageConfig.engines.npm 24 | }) 25 | } 26 | 27 | module.exports = function () { 28 | const warnings = [] 29 | 30 | for (let i = 0; i < versionRequirements.length; i++) { 31 | const mod = versionRequirements[i] 32 | 33 | if (!semver.satisfies(mod.currentVersion, mod.versionRequirement)) { 34 | warnings.push(mod.name + ': ' + 35 | chalk.red(mod.currentVersion) + ' should be ' + 36 | chalk.green(mod.versionRequirement) 37 | ) 38 | } 39 | } 40 | 41 | if (warnings.length) { 42 | console.log('') 43 | console.log(chalk.yellow('To use this template, you must update following to modules:')) 44 | console.log() 45 | 46 | for (let i = 0; i < warnings.length; i++) { 47 | const warning = warnings[i] 48 | console.log(' ' + warning) 49 | } 50 | 51 | console.log() 52 | process.exit(1) 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /file-download/example/js/utils.js: -------------------------------------------------------------------------------- 1 | export function downloadDirect(url) { 2 | const aTag = document.createElement('a'); 3 | aTag.download = url.split('/').pop(); 4 | aTag.href = url; 5 | aTag.click() 6 | } 7 | 8 | export function downloadByContent(content, filename, type) { 9 | const aTag = document.createElement('a'); 10 | aTag.download = filename; 11 | const blob = new Blob([content], { type }); 12 | const blobUrl = URL.createObjectURL(blob); 13 | aTag.href = blobUrl; 14 | aTag.click(); 15 | URL.revokeObjectURL(blob); 16 | } 17 | 18 | export function downloadByDataURL(content, filename, type) { 19 | const aTag = document.createElement('a'); 20 | aTag.download = filename; 21 | const dataUrl = `data:${type};base64,${window.btoa(unescape(encodeURIComponent(content)))}`; 22 | aTag.href = dataUrl; 23 | aTag.click(); 24 | } 25 | 26 | export function downloadByBlob(blob, filename) { 27 | const aTag = document.createElement('a'); 28 | aTag.download = filename; 29 | const blobUrl = URL.createObjectURL(blob); 30 | aTag.href = blobUrl; 31 | aTag.click(); 32 | URL.revokeObjectURL(blob); 33 | } 34 | 35 | export function base64ToBlob(base64, type) { 36 | const byteCharacters = atob(base64); 37 | const byteNumbers = new Array(byteCharacters.length); 38 | for (let i = 0; i < byteCharacters.length; i++) { 39 | byteNumbers[i] = byteCharacters.charCodeAt(i); 40 | } 41 | const buffer = Uint8Array.from(byteNumbers); 42 | const blob = new Blob([buffer], { type }); 43 | return blob; 44 | } 45 | -------------------------------------------------------------------------------- /watermark/demo/svg.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | element-watermark 8 | 19 | 20 | 21 | 22 |
23 |

秋风

24 |

hello

25 | 26 |
27 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /wechat-feces/1-1-animation.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | cdn-animation 9 | 10 | 11 | 12 | 13 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /webpack/optimization.splitChunks.chunks/dist-all/b.bundle.js: -------------------------------------------------------------------------------- 1 | !function(e){function n(n){for(var t,i,f=n[0],l=n[1],a=n[2],p=0,s=[];p 2 | 3 | 4 | 5 | 6 | 7 | 8 | Document 9 | 31 | 32 | 33 | 34 | 35 |
asset main.js 132 bytes [compared for emit] [minimized] (name: main)
./src/index.js 289 bytes [built] [code generated]
WARNING in configuration
The 'mode' option has not been set, webpack will fallback to 'production' for this value.
Set 'mode' option to 'development' or 'production' to enable defaults for each environment.
You can also set it to 'none' to disable any default behavior. Learn more: https://webpack.js.org/configuration/mode/
webpack 5.53.0 compiled with 1 warning in 255 ms
36 |
37 | 38 | 39 | -------------------------------------------------------------------------------- /node-cors/server.js: -------------------------------------------------------------------------------- 1 | const Koa = require('koa'); 2 | const router = require('koa-router')(); 3 | const koaBody = require('koa-body'); 4 | const fs = require('fs'); 5 | // const cors = require('koa-cors'); 6 | const app = new Koa(); 7 | const token = 'dwqwqe1231'; 8 | 9 | app.use(async (ctx, next) => { 10 | ctx.set('Access-Control-Max-Age', 600); 11 | ctx.set('Access-Control-Allow-Origin', ctx.headers.origin); 12 | ctx.set('Access-Control-Allow-Credentials', true) 13 | ctx.set('Access-Control-Request-Method', 'PUT,POST,GET,DELETE,OPTIONS') 14 | ctx.set('Access-Control-Allow-Headers', 'Origin, X-Requested-With, Content-Type, Accept, cc') 15 | if (ctx.method === 'OPTIONS') { 16 | ctx.status = 204; 17 | return; 18 | } 19 | await next(); 20 | }); 21 | 22 | app.use(async (ctx, next) => { 23 | if (ctx.path === '/api/login') { 24 | await next(); 25 | return; 26 | } 27 | const cookies = ctx.cookies.get('token'); 28 | console.log(cookies); 29 | if (cookies && cookies === token) { 30 | await next(); 31 | return; 32 | } 33 | ctx.body = { 34 | code: 401, 35 | msg: '权限错误', 36 | } 37 | return; 38 | }) 39 | 40 | // app.use(cors()); 41 | app.use(koaBody({ multipart: true })); 42 | 43 | router.get('/api/corslist', async (ctx) => { 44 | ctx.body = { 45 | data: [{name: '秋风的笔记'}] 46 | } 47 | }) 48 | 49 | router.post('/api/login', async (ctx) => { 50 | ctx.cookies.set('token', token, { 51 | expires: new Date(+new Date() + 1000 * 60 * 60 * 24 * 7), 52 | }) 53 | ctx.body = { 54 | msg: '成功', 55 | code: 0 56 | }; 57 | } 58 | ); 59 | 60 | app.use(router.routes()); 61 | 62 | app.listen(8080); -------------------------------------------------------------------------------- /node-cors/client.js: -------------------------------------------------------------------------------- 1 | const Koa = require("koa"); 2 | const fs = require("fs"); 3 | const app = new Koa(); 4 | 5 | app.use(async (ctx, next) => { 6 | if (ctx.method === "GET" && ctx.path === "/") { 7 | ctx.body = fs.readFileSync("./index.html").toString(); 8 | } 9 | 10 | if (ctx.method === "GET" && ctx.path === "/charles") { 11 | ctx.body = fs.readFileSync("./charles/index.html").toString(); 12 | } 13 | 14 | if (ctx.method === "GET" && ctx.path === "/nginx") { 15 | ctx.body = fs.readFileSync("./nginx/index.html").toString(); 16 | } 17 | 18 | if (ctx.method === "GET" && ctx.path === "/jsonp") { 19 | ctx.body = fs.readFileSync("./jsonp/index.html").toString(); 20 | } 21 | 22 | if (ctx.method === "GET" && ctx.path === "/websocket") { 23 | ctx.body = fs.readFileSync("./websocket/index.html").toString(); 24 | } 25 | 26 | if (ctx.method === "GET" && ctx.path === "/postMessage") { 27 | ctx.body = fs.readFileSync("./postMessage/index.html").toString(); 28 | } 29 | 30 | if (ctx.method === "GET" && ctx.path === "/hash/a.html") { 31 | ctx.body = fs.readFileSync("./hash/a.html").toString(); 32 | } 33 | if (ctx.method === "GET" && ctx.path === "/hash/b.html") { 34 | ctx.body = fs.readFileSync("./hash/b.html").toString(); 35 | } 36 | 37 | if (ctx.method === "GET" && ctx.path === "/name/a.html") { 38 | ctx.body = fs.readFileSync("./name/a.html").toString(); 39 | } 40 | if (ctx.method === "GET" && ctx.path === "/name/b.html") { 41 | ctx.body = fs.readFileSync("./name/b.html").toString(); 42 | } 43 | 44 | 45 | if (ctx.method === "GET" && ctx.path === "/cors-any") { 46 | ctx.body = fs.readFileSync("./cors-any/index.html").toString(); 47 | } 48 | }); 49 | 50 | app.listen(8000); 51 | -------------------------------------------------------------------------------- /confetti/四边形.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | demo 8 | 9 | 17 | 18 | 19 | 20 | 58 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /file-download/example/download-frontend/docx-images.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 44 | 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /react-abort/src/pages/Posts.js: -------------------------------------------------------------------------------- 1 | import React, { useState, useEffect, useCallback } from 'react' 2 | 3 | function Posts() { 4 | const [isLoading, setIsLoading] = useState(true) 5 | const [posts, setPosts] = useState([]) 6 | 7 | const fetchPosts = useCallback(async controller => { 8 | try { 9 | // Imagine that the fetch is going to take 3 seconds to finish 10 | await new Promise(resolve => setTimeout(resolve, 3000)) 11 | const response = await fetch('https://jsonplaceholder.typicode.com/posts', { signal: controller.signal }) 12 | const posts = await response.json() 13 | setPosts(posts) 14 | } catch (error) { 15 | // When abort() is called, the fetch() promise rejects with an AbortError. 16 | if (error.name === 'AbortError') { 17 | // It's ok, don't do anything 18 | console.log('Request aborted!') 19 | } else { 20 | console.error(error) 21 | } 22 | } finally { 23 | if (!controller.signal.aborted) { 24 | setIsLoading(false) 25 | } 26 | } 27 | }, []) 28 | 29 | useEffect(() => { 30 | const controller = new AbortController() 31 | fetchPosts(controller) 32 | return () => controller.abort() 33 | }, [fetchPosts]) 34 | 35 | return ( 36 | <> 37 |

Posts

38 |
39 | {isLoading ? ( 40 |

Loading...

41 | ) : ( 42 | posts.map(post => ( 43 |
44 |

45 | #{post.id} 46 |

47 |

48 | Title: {post.title} 49 |

50 |

51 | Body: {post.body} 52 |

53 |
54 | )) 55 | )} 56 |
57 | 58 | ) 59 | } 60 | 61 | export default Posts -------------------------------------------------------------------------------- /wechat-feces/1-2-animation.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | cdn-animation 9 | 10 | 11 | 12 | 13 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /react-abort/src/pages/Users.js: -------------------------------------------------------------------------------- 1 | import React, { useState, useEffect, useCallback } from 'react' 2 | 3 | function Users() { 4 | const [isLoading, setIsLoading] = useState(true) 5 | const [users, setUsers] = useState([]) 6 | 7 | const fetchUsers = useCallback(async controller => { 8 | try { 9 | // Imagine that the fetch is going to take 3 seconds to load 10 | await new Promise(resolve => setTimeout(resolve, 3000)) 11 | const response = await fetch('https://jsonplaceholder.typicode.com/users', { signal: controller.signal }) 12 | const users = await response.json() 13 | setUsers(users) 14 | } catch (error) { 15 | // When abort() is called, the fetch() promise rejects with an AbortError. 16 | if (error.name === 'AbortError') { 17 | // It's ok, don't do anything 18 | console.log('Request aborted!') 19 | } else { 20 | console.error(error) 21 | } 22 | } finally { 23 | if (!controller.signal.aborted) { 24 | setIsLoading(false) 25 | } 26 | } 27 | }, []) 28 | 29 | useEffect(() => { 30 | const controller = new AbortController() 31 | fetchUsers(controller) 32 | return () => controller.abort() 33 | }, [fetchUsers]) 34 | 35 | return ( 36 | <> 37 |

Users

38 |
39 | {isLoading ? ( 40 |

Loading...

41 | ) : ( 42 | users.map(user => ( 43 |
44 |

45 | #{user.id} 46 |

47 |

48 | Name: {user.name} 49 |

50 |

51 | Username: {user.username} 52 |

53 |
54 | )) 55 | )} 56 |
57 | 58 | ) 59 | } 60 | 61 | export default Users 62 | -------------------------------------------------------------------------------- /react-abort/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 12 | 13 | 17 | 18 | 27 | React App 28 | 29 | 30 | 31 |
32 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /css-margin/collapsing-margin-demo.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Document 8 | 56 | 57 | 58 | 59 |
60 |
我直接从顶部开始了
61 |
62 |
63 |
64 |
65 |
我和底下之间距离为50px
66 |
我和顶上之间距离为50px
67 |
68 |
69 |
70 |
71 |
底部和父元素被合并了
72 |
73 |
距离顶上50px
74 |
75 |
76 |
77 |

它把自己给合并了,距离底下30px

78 |
79 |

它把自己给合并了, 距离顶上30px

80 |
81 | 82 | 83 | 84 | 85 | -------------------------------------------------------------------------------- /node-cors/vue-cli2-demo/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "vue-cli2-demo2", 3 | "version": "1.0.0", 4 | "description": "A Vue.js project", 5 | "author": "huayifeng <461249104@qq.com>", 6 | "private": true, 7 | "scripts": { 8 | "dev": "webpack-dev-server --inline --progress --config build/webpack.dev.conf.js", 9 | "start": "npm run dev", 10 | "build": "node build/build.js" 11 | }, 12 | "dependencies": { 13 | "vue": "^2.5.2" 14 | }, 15 | "devDependencies": { 16 | "autoprefixer": "^7.1.2", 17 | "babel-core": "^6.22.1", 18 | "babel-helper-vue-jsx-merge-props": "^2.0.3", 19 | "babel-loader": "^7.1.1", 20 | "babel-plugin-syntax-jsx": "^6.18.0", 21 | "babel-plugin-transform-runtime": "^6.22.0", 22 | "babel-plugin-transform-vue-jsx": "^3.5.0", 23 | "babel-preset-env": "^1.3.2", 24 | "babel-preset-stage-2": "^6.22.0", 25 | "chalk": "^2.0.1", 26 | "copy-webpack-plugin": "^4.0.1", 27 | "css-loader": "^0.28.0", 28 | "extract-text-webpack-plugin": "^3.0.0", 29 | "file-loader": "^1.1.4", 30 | "friendly-errors-webpack-plugin": "^1.6.1", 31 | "html-webpack-plugin": "^2.30.1", 32 | "node-notifier": "^5.1.2", 33 | "optimize-css-assets-webpack-plugin": "^3.2.0", 34 | "ora": "^1.2.0", 35 | "portfinder": "^1.0.13", 36 | "postcss-import": "^11.0.0", 37 | "postcss-loader": "^2.0.8", 38 | "postcss-url": "^7.2.1", 39 | "rimraf": "^2.6.0", 40 | "semver": "^5.3.0", 41 | "shelljs": "^0.7.6", 42 | "uglifyjs-webpack-plugin": "^1.1.1", 43 | "url-loader": "^0.5.8", 44 | "vue-loader": "^13.3.0", 45 | "vue-style-loader": "^3.0.1", 46 | "vue-template-compiler": "^2.5.2", 47 | "webpack": "^3.6.0", 48 | "webpack-bundle-analyzer": "^2.9.0", 49 | "webpack-dev-server": "^2.9.1", 50 | "webpack-merge": "^4.1.0" 51 | }, 52 | "engines": { 53 | "node": ">= 6.0.0", 54 | "npm": ">= 3.0.0" 55 | }, 56 | "browserslist": [ 57 | "> 1%", 58 | "last 2 versions", 59 | "not ie <= 8" 60 | ] 61 | } 62 | -------------------------------------------------------------------------------- /node-upload-stream/node-server/node-upload.js: -------------------------------------------------------------------------------- 1 | const fs = require('fs'); 2 | const http = require('http'); 3 | const querystring = require('querystring'); 4 | const server = http.createServer((req, res) => { 5 | if (req.url === "/files" && req.method.toLowerCase() === "post") { 6 | parseFile(req, res) 7 | } 8 | }) 9 | function parseFile(req, res) { 10 | req.setEncoding("binary"); 11 | let body = ""; 12 | let fileName = ""; 13 | // 边界字符 14 | let boundary = req.headers['content-type'] 15 | .split('; ')[1] 16 | .replace("boundary=", "") 17 | 18 | req.on("data", function(chunk) { 19 | body += chunk; 20 | }); 21 | req.on("end", function() { 22 | // 按照分解符切分 23 | const list = body.split(boundary); 24 | let contentType = ''; 25 | let fileName = ''; 26 | for (let i = 0; i < list.length; i++) { 27 | if (list[i].includes('Content-Disposition')) { 28 | const data = list[i].split('\r\n'); 29 | for (let j = 0; j < data.length; j++) { 30 | // 从头部拆分出名字和类型 31 | if (data[j].includes('Content-Disposition')) { 32 | const info = data[j].split(':')[1].split(';'); 33 | fileName = info[info.length - 1].split('=')[1].replace(/"/g, ''); 34 | console.log(fileName); 35 | } 36 | if (data[j].includes('Content-Type')) { 37 | contentType = data[j]; 38 | console.log(data[j].split(':')[1]); 39 | } 40 | } 41 | } 42 | } 43 | // 去除前面的请求头 44 | const start = body.toString().indexOf(contentType) + contentType.length + 4; // 有多\r\n\r\n 45 | const startBinary = body.toString().substring(start); 46 | const end = startBinary.indexOf("--" + boundary + "--") - 2; // 前面有多\r\n 47 | // 去除后面的分隔符 48 | const binary = startBinary.substring(0, end); 49 | const bufferData = Buffer.from(binary, "binary"); 50 | fs.writeFile(fileName, bufferData, function(err) { 51 | res.end("sucess"); 52 | }); 53 | ; 54 | }) 55 | } 56 | 57 | server.listen(7787) 58 | -------------------------------------------------------------------------------- /file-download/example/download-frontend/excel-simple.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 下载excel 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 |
title1title2title3title4title5
秋风的笔记秋风的笔记秋风的笔记秋风的笔记秋风的笔记
66666
66666
43 | 44 | 45 | 59 | 60 | -------------------------------------------------------------------------------- /file-download/example/download-frontend/excel-element-ui.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Document 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 28 | 29 |
30 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /white-board/canvas.js: -------------------------------------------------------------------------------- 1 | var canvas; 2 | var context; 3 | var tool; 4 | // 窗口准备好之后进行初始化工作 5 | 6 | if (window.addEventListener) { 7 | window.addEventListener('load', 8 | init(), 9 | false); 10 | } 11 | 12 | // 初始化canvas 13 | function init() { 14 | 15 | canvas = document.getElementById('canvas'); 16 | if (!canvas) { 17 | return; 18 | } 19 | if (!canvas.getContext) { 20 | return; 21 | } 22 | 23 | // 初始化画布 24 | context = canvas.getContext('2d'); 25 | if (!context) { 26 | return; 27 | } 28 | 29 | // 绘制背景, 不然的话没有背景,transparent 30 | context.fillStyle = '#fff'; 31 | context.fillRect(0, 0, canvas.width, canvas.height); 32 | 33 | // 初始化画笔 34 | tool = new toolPencil(); 35 | 36 | /** 37 | * 监听鼠标移动事件,进行绘图 38 | */ 39 | canvas.addEventListener('mousedown', evCanvas, false); 40 | canvas.addEventListener('mousemove', evCanvas, false); 41 | canvas.addEventListener('mouseup', evCanvas, false); 42 | 43 | } 44 | 45 | /** 46 | * 画笔构造函数 47 | * @returns {toolPencil} 48 | */ 49 | function toolPencil() { 50 | var tool = this; 51 | this.started = false; 52 | /** 53 | * 监听鼠标摁下事件 54 | */ 55 | this.mousedown = function (ev) { 56 | /** 57 | * 开始绘制 58 | */ 59 | ev.preventDefault(); 60 | context.beginPath(); 61 | context.moveTo(ev._x, ev._y); 62 | tool.started = true; 63 | }; 64 | 65 | /** 66 | * 如果已经开始绘制,监听鼠标移动,继续绘制 67 | */ 68 | this.mousemove = function (ev) { 69 | if (tool.started) { 70 | context.lineTo(ev._x, ev._y); 71 | context.stroke(); 72 | } 73 | }; 74 | 75 | /** 76 | * 结束绘制. 77 | */ 78 | this.mouseup = function (ev) { 79 | if (tool.started) { 80 | tool.mousemove(ev); 81 | tool.started = false; 82 | } 83 | }; 84 | } 85 | 86 | /** 87 | * 处理鼠标移动位置相对于画布的位置 88 | * 89 | * @param ev 90 | */ 91 | function evCanvas(ev) { 92 | var x, y; 93 | if (ev.offsetX || ev.offsetY == 0) { 94 | ev._x = ev.offsetX; 95 | ev._y = ev.offsetY; 96 | } 97 | /** 98 | * 执行三个监听函数 mousedown, mouseup, mousemove 99 | */ 100 | var func = tool[ev.type]; 101 | if (func) { 102 | func(ev); 103 | } 104 | } -------------------------------------------------------------------------------- /node-cors/vue-cli3-demo/src/components/HelloWorld.vue: -------------------------------------------------------------------------------- 1 | 32 | 33 | 41 | 42 | 43 | 59 | -------------------------------------------------------------------------------- /webpack/optimization.splitChunks.chunks/dist-all/a.bundle.js: -------------------------------------------------------------------------------- 1 | !function(e){function n(n){for(var r,i,c=n[0],a=n[1],l=n[2],s=0,p=[];s{console.log(e)}),Object(r.findIndex)([1,2,3]),console.log("My app is running")}}); -------------------------------------------------------------------------------- /webpack/optimization.splitChunks.chunks/dist-initial/a.bundle.js: -------------------------------------------------------------------------------- 1 | !function(e){function n(n){for(var r,i,c=n[0],a=n[1],l=n[2],s=0,p=[];s{console.log(e)}),Object(r.findIndex)([1,2,3]),console.log("My app is running")}}); -------------------------------------------------------------------------------- /node-cors/vue-cli2-demo/config/index.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | // Template version: 1.3.1 3 | // see http://vuejs-templates.github.io/webpack for documentation. 4 | 5 | const path = require('path') 6 | 7 | module.exports = { 8 | dev: { 9 | 10 | // Paths 11 | assetsSubDirectory: 'static', 12 | assetsPublicPath: '/', 13 | proxyTable: { 14 | '/api': { 15 | target: 'http://localhost:8080', 16 | } 17 | }, 18 | 19 | // Various Dev Server settings 20 | host: 'localhost', // can be overwritten by process.env.HOST 21 | port: 8000, // can be overwritten by process.env.PORT, if port is in use, a free one will be determined 22 | autoOpenBrowser: false, 23 | errorOverlay: true, 24 | notifyOnErrors: true, 25 | poll: false, // https://webpack.js.org/configuration/dev-server/#devserver-watchoptions- 26 | 27 | 28 | /** 29 | * Source Maps 30 | */ 31 | 32 | // https://webpack.js.org/configuration/devtool/#development 33 | devtool: 'cheap-module-eval-source-map', 34 | 35 | // If you have problems debugging vue-files in devtools, 36 | // set this to false - it *may* help 37 | // https://vue-loader.vuejs.org/en/options.html#cachebusting 38 | cacheBusting: true, 39 | 40 | cssSourceMap: true 41 | }, 42 | 43 | build: { 44 | // Template for index.html 45 | index: path.resolve(__dirname, '../dist/index.html'), 46 | 47 | // Paths 48 | assetsRoot: path.resolve(__dirname, '../dist'), 49 | assetsSubDirectory: 'static', 50 | assetsPublicPath: '/', 51 | 52 | /** 53 | * Source Maps 54 | */ 55 | 56 | productionSourceMap: true, 57 | // https://webpack.js.org/configuration/devtool/#production 58 | devtool: '#source-map', 59 | 60 | // Gzip off by default as many popular static hosts such as 61 | // Surge or Netlify already gzip all static assets for you. 62 | // Before setting to `true`, make sure to: 63 | // npm install --save-dev compression-webpack-plugin 64 | productionGzip: false, 65 | productionGzipExtensions: ['js', 'css'], 66 | 67 | // Run the build command with an extra argument to 68 | // View the bundle analyzer report after build finishes: 69 | // `npm run build --report` 70 | // Set to `true` or `false` to always turn it on or off 71 | bundleAnalyzerReport: process.env.npm_config_report 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /watermark/demo/canvas-observe.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | element-watermark 8 | 19 | 20 | 21 | 22 |
23 |

秋风

24 |

hello

25 |
26 | 67 | 68 | 69 | -------------------------------------------------------------------------------- /node-cors/vue-cli2-demo/build/webpack.base.conf.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | const path = require('path') 3 | const utils = require('./utils') 4 | const config = require('../config') 5 | const vueLoaderConfig = require('./vue-loader.conf') 6 | 7 | function resolve (dir) { 8 | return path.join(__dirname, '..', dir) 9 | } 10 | 11 | 12 | 13 | module.exports = { 14 | context: path.resolve(__dirname, '../'), 15 | entry: { 16 | app: './src/main.js' 17 | }, 18 | output: { 19 | path: config.build.assetsRoot, 20 | filename: '[name].js', 21 | publicPath: process.env.NODE_ENV === 'production' 22 | ? config.build.assetsPublicPath 23 | : config.dev.assetsPublicPath 24 | }, 25 | resolve: { 26 | extensions: ['.js', '.vue', '.json'], 27 | alias: { 28 | 'vue$': 'vue/dist/vue.esm.js', 29 | '@': resolve('src'), 30 | } 31 | }, 32 | module: { 33 | rules: [ 34 | { 35 | test: /\.vue$/, 36 | loader: 'vue-loader', 37 | options: vueLoaderConfig 38 | }, 39 | { 40 | test: /\.js$/, 41 | loader: 'babel-loader', 42 | include: [resolve('src'), resolve('test'), resolve('node_modules/webpack-dev-server/client')] 43 | }, 44 | { 45 | test: /\.(png|jpe?g|gif|svg)(\?.*)?$/, 46 | loader: 'url-loader', 47 | options: { 48 | limit: 10000, 49 | name: utils.assetsPath('img/[name].[hash:7].[ext]') 50 | } 51 | }, 52 | { 53 | test: /\.(mp4|webm|ogg|mp3|wav|flac|aac)(\?.*)?$/, 54 | loader: 'url-loader', 55 | options: { 56 | limit: 10000, 57 | name: utils.assetsPath('media/[name].[hash:7].[ext]') 58 | } 59 | }, 60 | { 61 | test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/, 62 | loader: 'url-loader', 63 | options: { 64 | limit: 10000, 65 | name: utils.assetsPath('fonts/[name].[hash:7].[ext]') 66 | } 67 | } 68 | ] 69 | }, 70 | node: { 71 | // prevent webpack from injecting useless setImmediate polyfill because Vue 72 | // source contains it (although only uses it if it's native). 73 | setImmediate: false, 74 | // prevent webpack from injecting mocks to Node native modules 75 | // that does not make sense for the client 76 | dgram: 'empty', 77 | fs: 'empty', 78 | net: 'empty', 79 | tls: 'empty', 80 | child_process: 'empty' 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /node-cors/vue-cli2-demo/src/components/HelloWorld.vue: -------------------------------------------------------------------------------- 1 | 85 | 86 | 96 | 97 | 98 | 114 | -------------------------------------------------------------------------------- /watermark/demo/element.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | element-watermark 8 | 9 | 10 | 11 | 12 |
13 |

秋风

14 |

hello

15 |
16 | 73 | 74 | 75 | -------------------------------------------------------------------------------- /react-abort/src/logo.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /node-cors/vue-cli2-demo/build/utils.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | const path = require('path') 3 | const config = require('../config') 4 | const ExtractTextPlugin = require('extract-text-webpack-plugin') 5 | const packageConfig = require('../package.json') 6 | 7 | exports.assetsPath = function (_path) { 8 | const assetsSubDirectory = process.env.NODE_ENV === 'production' 9 | ? config.build.assetsSubDirectory 10 | : config.dev.assetsSubDirectory 11 | 12 | return path.posix.join(assetsSubDirectory, _path) 13 | } 14 | 15 | exports.cssLoaders = function (options) { 16 | options = options || {} 17 | 18 | const cssLoader = { 19 | loader: 'css-loader', 20 | options: { 21 | sourceMap: options.sourceMap 22 | } 23 | } 24 | 25 | const postcssLoader = { 26 | loader: 'postcss-loader', 27 | options: { 28 | sourceMap: options.sourceMap 29 | } 30 | } 31 | 32 | // generate loader string to be used with extract text plugin 33 | function generateLoaders (loader, loaderOptions) { 34 | const loaders = options.usePostCSS ? [cssLoader, postcssLoader] : [cssLoader] 35 | 36 | if (loader) { 37 | loaders.push({ 38 | loader: loader + '-loader', 39 | options: Object.assign({}, loaderOptions, { 40 | sourceMap: options.sourceMap 41 | }) 42 | }) 43 | } 44 | 45 | // Extract CSS when that option is specified 46 | // (which is the case during production build) 47 | if (options.extract) { 48 | return ExtractTextPlugin.extract({ 49 | use: loaders, 50 | fallback: 'vue-style-loader' 51 | }) 52 | } else { 53 | return ['vue-style-loader'].concat(loaders) 54 | } 55 | } 56 | 57 | // https://vue-loader.vuejs.org/en/configurations/extract-css.html 58 | return { 59 | css: generateLoaders(), 60 | postcss: generateLoaders(), 61 | less: generateLoaders('less'), 62 | sass: generateLoaders('sass', { indentedSyntax: true }), 63 | scss: generateLoaders('sass'), 64 | stylus: generateLoaders('stylus'), 65 | styl: generateLoaders('stylus') 66 | } 67 | } 68 | 69 | // Generate loaders for standalone style files (outside of .vue) 70 | exports.styleLoaders = function (options) { 71 | const output = [] 72 | const loaders = exports.cssLoaders(options) 73 | 74 | for (const extension in loaders) { 75 | const loader = loaders[extension] 76 | output.push({ 77 | test: new RegExp('\\.' + extension + '$'), 78 | use: loader 79 | }) 80 | } 81 | 82 | return output 83 | } 84 | 85 | exports.createNotifierCallback = () => { 86 | const notifier = require('node-notifier') 87 | 88 | return (severity, errors) => { 89 | if (severity !== 'error') return 90 | 91 | const error = errors[0] 92 | const filename = error.file && error.file.split('!').pop() 93 | 94 | notifier.notify({ 95 | title: packageConfig.name, 96 | message: severity + ': ' + error.name, 97 | subtitle: filename || '', 98 | icon: path.join(__dirname, 'logo.png') 99 | }) 100 | } 101 | } 102 | -------------------------------------------------------------------------------- /file-download/example/download-multiple/script.js: -------------------------------------------------------------------------------- 1 | var m = 1024 * 1024 * 10; // 分片大小 2 | var url = 3 | "https://vodm0pihssv.vod.126.net/edu-video/nos/mp4/2017/10/10/1007299069_2cddd54a92e344639ad9669a2e0109ed_sd.mp4"; // 下载url 4 | var donwloadName = "3.mp4"; // 下载文件名 5 | const script = document.createElement("script"); 6 | script.src = "https://cdn.bootcss.com/axios/0.19.2/axios.min.js"; 7 | document.body.appendChild(script); 8 | 9 | function downloadDirect(url) { 10 | console.time("直接下载1"); 11 | const req = new XMLHttpRequest(); 12 | req.open("GET", url, true); 13 | req.responseType = "blob"; 14 | req.onload = function (oEvent) { 15 | const content = req.response; 16 | const aTag = document.createElement("a"); 17 | aTag.download = donwloadName; 18 | const blob = new Blob([content]); 19 | const blobUrl = URL.createObjectURL(blob); 20 | aTag.href = blobUrl; 21 | aTag.click(); 22 | URL.revokeObjectURL(blob); 23 | console.timeEnd("直接下载1"); 24 | }; 25 | req.send(); 26 | } 27 | 28 | // 直接下载 29 | downloadDirect(url); 30 | // 多线程下载 31 | axios({ 32 | url, 33 | method: "head", 34 | }).then((res) => { 35 | console.time("并发下载1"); 36 | const size = Number(res.headers["content-length"]); 37 | const length = parseInt(size / m); 38 | const arr = []; 39 | let count = 0; 40 | function downloadRange(url, start, end, i) { 41 | return new Promise((resolve, reject) => { 42 | const req = new XMLHttpRequest(); 43 | req.open("GET", url, true); 44 | req.setRequestHeader("range", `bytes=${start}-${end}`); 45 | req.responseType = "blob"; 46 | req.onload = function (oEvent) { 47 | req.response.arrayBuffer().then((res) => { 48 | count++; 49 | console.log(`下载百分比${((count / length) * 100).toFixed(2)}`); 50 | resolve({ 51 | i, 52 | buffer: res, 53 | }); 54 | }); 55 | }; 56 | req.send(); 57 | }); 58 | } 59 | // 合并buffer 60 | function concatenate(resultConstructor, arrays) { 61 | let totalLength = 0; 62 | for (let arr of arrays) { 63 | totalLength += arr.length; 64 | } 65 | let result = new resultConstructor(totalLength); 66 | let offset = 0; 67 | for (let arr of arrays) { 68 | result.set(arr, offset); 69 | offset += arr.length; 70 | } 71 | return result; 72 | } 73 | 74 | for (let i = 0; i <= length; i++) { 75 | let start = i * m; 76 | let end = (i == length) ? size - 1 : (i + 1) * m - 1; 77 | arr.push(downloadRange(url, start, end, i)) 78 | } 79 | Promise.all(arr).then((res) => { 80 | const arrBufferList = res 81 | .sort((item) => item.i - item.i) 82 | .map((item) => new Uint8Array(item.buffer)); 83 | count = 0; 84 | const allBuffer = concatenate(Uint8Array, arrBufferList); 85 | const blob = new Blob([allBuffer], { type: "image/jpeg" }); 86 | const blobUrl = URL.createObjectURL(blob); 87 | const aTag = document.createElement("a"); 88 | aTag.download = donwloadName; 89 | aTag.href = blobUrl; 90 | aTag.click(); 91 | URL.revokeObjectURL(blob); 92 | console.timeEnd("并发下载1"); 93 | }); 94 | }); 95 | -------------------------------------------------------------------------------- /node-cors/vue-cli2-demo/build/webpack.dev.conf.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | const utils = require('./utils') 3 | const webpack = require('webpack') 4 | const config = require('../config') 5 | const merge = require('webpack-merge') 6 | const path = require('path') 7 | const baseWebpackConfig = require('./webpack.base.conf') 8 | const CopyWebpackPlugin = require('copy-webpack-plugin') 9 | const HtmlWebpackPlugin = require('html-webpack-plugin') 10 | const FriendlyErrorsPlugin = require('friendly-errors-webpack-plugin') 11 | const portfinder = require('portfinder') 12 | 13 | const HOST = process.env.HOST 14 | const PORT = process.env.PORT && Number(process.env.PORT) 15 | 16 | const devWebpackConfig = merge(baseWebpackConfig, { 17 | module: { 18 | rules: utils.styleLoaders({ sourceMap: config.dev.cssSourceMap, usePostCSS: true }) 19 | }, 20 | // cheap-module-eval-source-map is faster for development 21 | devtool: config.dev.devtool, 22 | 23 | // these devServer options should be customized in /config/index.js 24 | devServer: { 25 | clientLogLevel: 'warning', 26 | historyApiFallback: { 27 | rewrites: [ 28 | { from: /.*/, to: path.posix.join(config.dev.assetsPublicPath, 'index.html') }, 29 | ], 30 | }, 31 | hot: true, 32 | contentBase: false, // since we use CopyWebpackPlugin. 33 | compress: true, 34 | host: HOST || config.dev.host, 35 | port: PORT || config.dev.port, 36 | open: config.dev.autoOpenBrowser, 37 | overlay: config.dev.errorOverlay 38 | ? { warnings: false, errors: true } 39 | : false, 40 | publicPath: config.dev.assetsPublicPath, 41 | proxy: config.dev.proxyTable, 42 | quiet: true, // necessary for FriendlyErrorsPlugin 43 | watchOptions: { 44 | poll: config.dev.poll, 45 | } 46 | }, 47 | plugins: [ 48 | new webpack.DefinePlugin({ 49 | 'process.env': require('../config/dev.env') 50 | }), 51 | new webpack.HotModuleReplacementPlugin(), 52 | new webpack.NamedModulesPlugin(), // HMR shows correct file names in console on update. 53 | new webpack.NoEmitOnErrorsPlugin(), 54 | // https://github.com/ampedandwired/html-webpack-plugin 55 | new HtmlWebpackPlugin({ 56 | filename: 'index.html', 57 | template: 'index.html', 58 | inject: true 59 | }), 60 | // copy custom static assets 61 | new CopyWebpackPlugin([ 62 | { 63 | from: path.resolve(__dirname, '../static'), 64 | to: config.dev.assetsSubDirectory, 65 | ignore: ['.*'] 66 | } 67 | ]) 68 | ] 69 | }) 70 | 71 | module.exports = new Promise((resolve, reject) => { 72 | portfinder.basePort = process.env.PORT || config.dev.port 73 | portfinder.getPort((err, port) => { 74 | if (err) { 75 | reject(err) 76 | } else { 77 | // publish the new Port, necessary for e2e tests 78 | process.env.PORT = port 79 | // add port to devServer config 80 | devWebpackConfig.devServer.port = port 81 | 82 | // Add FriendlyErrorsPlugin 83 | devWebpackConfig.plugins.push(new FriendlyErrorsPlugin({ 84 | compilationSuccessInfo: { 85 | messages: [`Your application is running here: http://${devWebpackConfig.devServer.host}:${port}`], 86 | }, 87 | onErrors: config.dev.notifyOnErrors 88 | ? utils.createNotifierCallback() 89 | : undefined 90 | })) 91 | 92 | resolve(devWebpackConfig) 93 | } 94 | }) 95 | }) 96 | -------------------------------------------------------------------------------- /wechat-feces/2-2-lottie.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | cdn-animation 9 | 10 | 11 | 12 | 26 | 27 |
28 | 29 | 89 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /guide/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Novice guide 8 | 9 | 74 | 75 | 76 | 77 |

秋风的笔记

78 |
79 | JavaScript 80 | Node.js 81 | Webpack 82 | React 83 | Vue 84 | Nginx 85 | ... 86 |
87 |
88 |
89 |
90 | 秋风的技能 91 |
92 |
93 | 105 | 106 | 107 | -------------------------------------------------------------------------------- /guide/canvas.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Novice guide 8 | 9 | 54 | 55 | 56 | 57 |

秋风的笔记

58 |
59 | JavaScript 60 | Node.js 61 | Webpack 62 | React 63 | Vue 64 | Nginx 65 | ... 66 |
67 | 68 |
69 |
70 | 秋风的技能 71 |
72 |
73 | 101 | 102 | 103 | -------------------------------------------------------------------------------- /guide/box-shadow.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Novice guide 8 | 9 | 81 | 82 | 83 | 84 |

秋风的笔记

85 |
86 | JavaScript 87 | Node.js 88 | Webpack 89 | React 90 | Vue 91 | Nginx 92 | ... 93 |
94 | 95 |
96 |
97 | 秋风的技能 98 |
99 |
100 | 112 | 113 | 114 | -------------------------------------------------------------------------------- /wechat-feces/3-1-feces-2.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | cdn-animation 9 | 10 | 11 | 12 | 30 | 31 | 32 | 33 | 34 | 97 | 98 | 99 | -------------------------------------------------------------------------------- /file-download/example/download-frontend/word-excel.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Document 7 | 8 | 9 |
10 |

hello

11 |

秋风的笔记

12 |
13 | 导出word 14 | 15 |

16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 |
title1title2title3title4title5
12345
12345
12345
51 | 导出excel 52 | 118 | 119 | -------------------------------------------------------------------------------- /confetti/旋转.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | demo 8 | 9 | 17 | 18 | 19 | 20 | 138 | 139 | 140 | 141 | -------------------------------------------------------------------------------- /confetti/运动轨迹.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | demo 8 | 9 | 17 | 18 | 19 | 20 | 138 | 139 | 140 | 141 | -------------------------------------------------------------------------------- /confetti/轨迹加旋转.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | demo 8 | 9 | 17 | 18 | 19 | 20 | 138 | 139 | 140 | 141 | -------------------------------------------------------------------------------- /file-download/server.js: -------------------------------------------------------------------------------- 1 | const Koa = require('koa'); 2 | const router = require('koa-router')(); 3 | const koaBody = require('koa-body'); 4 | const fs = require('fs'); 5 | const path = require('path'); 6 | const mime = require('mime'); 7 | const serve = require('koa-static'); 8 | const mount = require('koa-mount'); 9 | const app = new Koa(); 10 | 11 | function getRange(range) { 12 | var match = /bytes=([0-9]*)-([0-9]*)/.exec(range); 13 | const requestRange = {}; 14 | if (match) { 15 | if (match[1]) requestRange.start = Number(match[1]); 16 | if (match[2]) requestRange.end = Number(match[2]); 17 | } 18 | return requestRange; 19 | } 20 | 21 | app.use(async (ctx, next) => { 22 | ctx.set('Access-Control-Max-Age', 600); 23 | ctx.set('Access-Control-Allow-Origin', ctx.headers.origin); 24 | ctx.set('Access-Control-Allow-Credentials', true) 25 | ctx.set('Access-Control-Request-Method', 'PUT,POST,GET,DELETE,OPTIONS') 26 | ctx.set('Access-Control-Allow-Headers', 'Origin, X-Requested-With, Content-Type, Accept, range') 27 | if (ctx.method === 'OPTIONS') { 28 | ctx.status = 204; 29 | return; 30 | } 31 | await next(); 32 | }); 33 | 34 | 35 | app.use(mount('/static', serve('static'))); 36 | 37 | app.use(mount('/example', serve('example'))); 38 | 39 | app.use(koaBody({ multipart: true })); 40 | 41 | router.get('/api/download', async (ctx) => { 42 | const { filename } = ctx.query; 43 | const fStats = fs.statSync(path.join(__dirname, './static/', filename)); 44 | ctx.set({ 45 | 'Content-Type': 'application/octet-stream', 46 | 'Content-Disposition': `attachment; filename=${filename}`, 47 | 'Content-Length': fStats.size 48 | }); 49 | ctx.body = fs.readFileSync(path.join(__dirname, './static/', filename)); 50 | }) 51 | 52 | router.get('/api/downloadUrl', async (ctx) => { 53 | const { filename } = ctx.query; 54 | ctx.body = { 55 | code: 0, 56 | data: { 57 | url: 'http://localhost:8888/static/1597375650384.jpg', 58 | } 59 | } 60 | }) 61 | 62 | router.head('/api/rangeFile', async (ctx) => { 63 | console.log(111); 64 | const { filename } = ctx.query; 65 | const stats = fs.statSync(path.join(__dirname, './static/', filename)); 66 | console.log(stats.size); 67 | ctx.set('Content-Length', stats.size); 68 | ctx.length = stats.size; 69 | ctx.status = 200; 70 | return; 71 | }) 72 | 73 | router.get('/api/rangeFile', async(ctx) => { 74 | const { filename } = ctx.query; 75 | const { size } = fs.statSync(path.join(__dirname, './static/', filename)); 76 | const range = ctx.headers['range']; 77 | if (!range) { 78 | ctx.set('Accept-Ranges', 'bytes'); 79 | ctx.body = fs.readFileSync(path.join(__dirname, './static/', filename)); 80 | return; 81 | } 82 | const { start, end } = getRange(range); 83 | if (start >= size || end >= size) { 84 | ctx.response.status = 416; 85 | ctx.body = ''; 86 | return; 87 | } 88 | ctx.response.status = 206; 89 | ctx.set('Accept-Ranges', 'bytes'); 90 | ctx.set('Content-Range', `bytes ${start}-${end ? end : size - 1}/${size}`); 91 | ctx.body = fs.createReadStream(path.join(__dirname, './static/', filename), { start, end }); 92 | }) 93 | 94 | router.get('/api/base64', async (ctx) => { 95 | const { filename } = ctx.query; 96 | const content = fs.readFileSync(path.join(__dirname, './static/', filename)); 97 | const fStats = fs.statSync(path.join(__dirname, './static/', filename)); 98 | console.log(fStats); 99 | ctx.body = { 100 | code: 0, 101 | data: { 102 | base64: content.toString('base64'), 103 | filename, 104 | type: mime.getType(filename) 105 | } 106 | } 107 | }) 108 | 109 | 110 | router.get('/api/corslist', async (ctx) => { 111 | ctx.body = { 112 | data: [{name: '秋风的笔记'}] 113 | } 114 | }) 115 | 116 | 117 | 118 | app.use(router.routes()); 119 | 120 | app.listen(8888); --------------------------------------------------------------------------------