Node源码安装
wget https://nodejs.org/dist/v12.16.3/node-v12.16.3.tar.gz
tar zxvf node-v12.16.3.tar.gz
cd node-v12.16.3
./configure
make
sudo make install
node —version
小于 1 分钟
wget https://nodejs.org/dist/v12.16.3/node-v12.16.3.tar.gz
tar zxvf node-v12.16.3.tar.gz
cd node-v12.16.3
./configure
make
sudo make install
node —version
package.json中对应版本前为^
符号,这样就可能存在本次安装的包版本有升级。
升级从左向右的第一个不为0的版本
注意:以上说法不一定正确,持保留意见。可能是版本升级
Syntax | Description | 版本示例 |
---|---|---|
New product | Start with 1.0.0 | 1.0.0 |
Patch release | Increment the third digit(位数) | 1.0.1 |
Minor (次要)release | Increment the middle digit and reset last digit to zero | 1.1.0 |
Major(重大) release | Increment the first digit and reset middle and last digits to zero | 2.0.0 |
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.2/install.sh | bash
在本地创建分支dev并切换到该分支
git checkout -b dev(本地分支名称) origin/dev(远程分支名称)
const waterMarkConfig = {
text: 'zhangzhengyi-张正义-特勤一队-0000000-142230199999999999',
opacity: 0.1,
xCount: 9,
yCount: 4,
angle: -30
}
const {innerHeight, innerWidth} = window
function createWaterMark() {
const {text, opacity, xCount, yCount, angle} = waterMarkConfig
const canvas = document.createElement('canvas');
canvas.width = innerWidth/xCount;
canvas.height = innerHeight/yCount;
const ctx = canvas.getContext('2d');
ctx.clearRect(0, 0, innerWidth/xCount, innerHeight/yCount);
ctx.fillStyle = '#000';
ctx.globalAlpha = opacity;
ctx.font = `16px serif`
ctx.rotate(Math.PI / 180 * angle);
const textArr = text.split('-')
const offsetTop = (innerHeight/yCount - textArr.length * 20)/2
for (let i = 0; i < textArr.length; i++) {
ctx.fillText(textArr[i], 0, offsetTop+20*i)
}
return canvas.toDataURL();
}
const watermakr = document.createElement('div');
watermakr.className = 'watermark';
watermakr.style.backgroundImage = `url(${createWaterMark()})`
document.body.appendChild(watermakr);
// 观察器的配置(需要观察什么变动)
const config = { attributes: true, childList: true, subtree: true };
// 当观察到变动时执行的回调函数
const callback = function (mutationsList, observer) {
// Use traditional 'for loops' for IE 11
for (let mutation of mutationsList) {
mutation.removedNodes.forEach(function (item) {
if (item === watermakr) {
console.log('发现被删除')
document.body.appendChild(watermakr);
}
});
}
};
// 监听元素
const targetNode = document.body;
// 创建一个观察器实例并传入回调函数
const observer = new MutationObserver(callback);
// 以上述配置开始观察目标节点
observer.observe(targetNode, config);