2025/8/11大约 13 分钟
常用的工作流操作
git cherry-pick --no-edit [commitId1] [commitId2] // 建议使用edit
git rebase -i [commitId]
:wq
`fatal: refusing to merge unrelated histories` 错误通常发生在尝试合并两个没有共同历史的 Git 仓库时。这个错误在子模块操作中也可能出现,特别是在你尝试更新或合并子模块时。
git pull origin main --allow-unrelated-histories
// 变基推送
git push --force-with-lease origin master
2024/12/2小于 1 分钟
HTML元素自动滚动
export class ScrollWrapper {
constructor(vm, { scrollDirection = 1, speed = 0.3, bodyWrapper } = {}) {
this.vm = vm;
this.scrollDirection = scrollDirection;
this.speed = speed;
this.bodyWrapper = bodyWrapper;
this.startScroll();
}
clearScroll() {
cancelAnimationFrame(this.animationId);
}
startScroll() {
this.vm.$nextTick(() => {
if (!this.bodyWrapper) return;
if (this.bodyWrapper.clientHeight >= this.bodyWrapper.scrollHeight) return;
this.bodyWrapper.addEventListener('scroll', () => this.scroll());
this.bodyWrapper.addEventListener('mouseenter', () => this.pauseScroll());
this.bodyWrapper.addEventListener('mouseleave', () => this.resumeScroll());
this.bodyWrapper.scrollTop = 0;
this.scrollDirection = 1;
this.pos = 0;
this.clearScroll();
this.startScrollFn();
});
}
startScrollFn() {
const step = () => {
if (this.bodyWrapper && !this.isPaused) {
this.pos += this.speed * this.scrollDirection;
this.bodyWrapper.scrollTop = this.pos;
if (this.bodyWrapper.scrollTop + this.bodyWrapper.clientHeight >= this.bodyWrapper.scrollHeight - 1) {
this.scrollDirection = -1;
}
if (this.bodyWrapper.scrollTop <= 0) {
this.scrollDirection = 1;
}
}
this.animationId = requestAnimationFrame(step);
};
this.animationId = requestAnimationFrame(step);
}
pauseScroll() {
this.isPaused = true;
}
resumeScroll() {
this.isPaused = false;
}
scroll() {
if (this.isPaused) {
this.pos = this.bodyWrapper.scrollTop;
}
}
}
this.bodyWrapper.scrollTop = this.pos;
此处由于HTMLElement取值scrollTop会取整,为了保证浮点数滚动,所以声明pos过渡
全排列算法
const func = (arr) => {
let len = arr.length,
res = [];
/**
* 【全排列算法】
* 说明:arrange用来对arr中的元素进行排列组合,将排列好的各个结果存在新数组中
* @param tempArr:排列好的元素
* @param leftArr:待排列元素
*/
let arrange = (tempArr, leftArr) => {
if (tempArr.length === len) {
// 这里就是递归结束的地方
// res.push(tempArr) // 得到全排列的每个元素都是数组
res.push(tempArr.join("")); // 得到全排列的每个元素都是字符串
} else {
leftArr.forEach((item, index) => {
let temp = [].concat(leftArr);
temp.splice(index, 1);
// 此时,第一个参数是当前分离出的元素所在数组;第二个参数temp是传入的leftArr去掉第一个后的结果
arrange(tempArr.concat(item), temp); // 这里使用了递归
});
}
};
arrange([], arr);
return res;
};
2024/6/2大约 2 分钟
跨平台调试
-
window下调试 iOS-Safari
实现真机调试主要是使用了 remotedebug-ios-webkit-adapter
安装scoopeWindows 命令行安装工具 Set-ExecutionPolicy RemoteSigned -scope CurrentUser iex (new-object net.webclient).downloadstring('https://get.scoop.sh')scoop bucket add extras scoop install ios-webkit-debug-proxy npm install -g vs-libimobile npm install remotedebug-ios-webkit-adapter -g- 进入 iPhone 中的 设置 > Safari 浏览器 > 高级 > Web 检查器,开启该选项。
- 打开 iTunes 并连接 iPhone,在 iPhone 弹框中选择信任该电脑。
- 打开命令行,执行以下命令,启动适配器:
remotedebug_ios_webkit_adapter --port=9000- 在 iPhone 中打开 Safari 浏览器,打开待调试页面。
- 打开 Chrome 浏览器,进入 chrome://inspect/#devices 页面,在 Discover network targets 选项添加 localhost:9000 配置。刷新页面,这时页面中会出现 'Remote Target' 列表,该列表展示了 iPhone 中打开的页面,点击 inspect,即可进行调试。(科学上网/edge)
2023/8/10大约 1 分钟
2023/3/10小于 1 分钟
2022/1/9大约 6 分钟
