电信光猫 TEWA-708G 获取超级密码教程

我使用的是电信光猫 TEWA-708G,超级用户的密码已经不再是固定的了,是随机生成的,所以需要一些操作才能够获取到超级密码。

这个教程不能保证适用所有型号为 TEWA-708G 的光猫,因为通过搜索有些同型号的光猫使用的是 sessionKey 进行查找,有些则是以 set1_sessionKey_*** 进行查找,我的设备使用的是 set1_sessionKey_*** ,所以做一个记录:

1. 首先使用普通用户登录
用户名和密码在光猫的背面,登录地址:192.168.1.1:8080,用户名一般为 useradmin,并在光猫 USB 接口中插好 U 盘

2. 进入“设备管理页面”
点击“管理”—“设备管理”或访问:http://192.168.1.1:8080/MD_Device_user.html
一定要确认进入设备管理界面,这个界面连 USB 都给屏蔽了

“设备管理”页面

3. 查找 set1_sessionKey_***
按 F12 或在页面点右键→检查,然后在里面搜索 set1_sessionKey_,你会找到一个 set1_sessionKey_*** 之类的结果,把 *** 记下来

查找 set1_sessionKey_***,如图 *** 为“304”

4. 构造命令并执行
切换到 Console 窗口,在输入框中输入如下内容:location.assign("/usbbackup.cmd?action=backupeble&set1_sessionKey=set1_sessionKey_***") 然后回车

进入 Console 窗口输入上方代码

5. 备份配置
页面打开后,右键备份配置,点击“检查”,删除 disable 字段,此时可以看到按钮已从禁用状态转为可点击状态,现在可以点击“备份配置”正常备份了,点击之后页面会全白,那是正常的

删除 Button 的 disable 字段

6. 得到备份文件
U 盘上会生成一个名为 e8_Config_Backup 的文件夹,其下的 ctce8_TEWA-708G.cfg 就是路由器配置文件

查看 U 盘中是否已存在对应文件夹及配置文件

7. 解密文件
如果用记事本打开 ctce8_TEWA-708G.cfg,会是一堆乱码。要使用 xor(点击跳转) 或者 router pass view 打开配置文件,搜索 TeleComAccount 字段 ,下面的 Password 内即为超级密码

使用 xor 转换配置文件
搜索 TeleComAccount 字段,Password 内即为超级用户密码

8. 关闭启用周期上报
进入 Web 后台管理界面后,切换到“网络”—“远程管理”选项卡,清除勾选“启用周期上报”项,这样就彻底阻止了电信对光猫的远程控制功能

关闭“启用周期上报”

以上就是电信光猫 TEWA-708G 获取超级密码的整个教程,但不保证这个教程适用于这个光猫型号的所有设备,所以,如果按照上述操作发现无法获取超级密码则需要搜索其他获取方案。

引用

电信光猫TEWA-708G最新获取超级密码教程
天翼网关3.0(tewa-708g)续
电信光猫TEWA-708G最详细获取超级密码教程

基于 winston 实现 Nest.js 应用日志服务

Nest.js logo
Nest.js Logo

实现 Nest.js 应用日志服务有很多选择,较为出名的有:Log4jswinstonPino

这次就以 winston 为例,记录一下如何实现 Nest.js 应用日志服务。本文参考了搜索引擎中许多教程与案例,如果觉得有任何问题可以留言与我交流。

引入 winston

相关依赖:winston、nest-winston、winston-daily-rotate-file

pnpm install winston nest-winston winston-daily-rotate-file

winston-daily-rotate-file 用于实现日志文件的定期归档。由于应用日志量一般都非常大,因此需要定期自动对日志文件进行轮换、归档与删除。

配置 winston

app.module.ts

import {
  // ...
  Module,
} from '@nestjs/common';
import { WinstonModule } from 'nest-winston';
import * as winston from 'winston';
import 'winston-daily-rotate-file';
// ...

@Module({
  controllers: [],
  imports: [
    // ...
    WinstonModule.forRoot({
      transports: [
        new winston.transports.DailyRotateFile({
          dirname: `logs`, // 日志保存的目录
          filename: '%DATE%.log', // 日志名称,占位符 %DATE% 取值为 datePattern 值。
          datePattern: 'YYYY-MM-DD', // 日志轮换的频率,此处表示每天。
          zippedArchive: true, // 是否通过压缩的方式归档被轮换的日志文件。
          maxSize: '20m', // 设置日志文件的最大大小,m 表示 mb 。
          maxFiles: '14d', // 保留日志文件的最大天数,此处表示自动删除超过 14 天的日志文件。
          // 记录时添加时间戳信息
          format: winston.format.combine(
            winston.format.timestamp({
            	format: 'YYYY-MM-DD HH:mm:ss',
            }),
            winston.format.json(),
          ),
        }),
      ],
    }),
  ],
  // ...
})
export class AppModule { // ... }

在全局中间件、过滤器以及拦截器中记录日志

获取请求头信息的工具方法

getReqMainInfo.ts

import { Request } from 'express';

export const getReqMainInfo: (req: Request) => {
  [prop: string]: any;
} = req => {
  const { query, headers, url, method, body, connection } = req;

  // 获取 IP
  const xRealIp = headers['X-Real-IP'];
  const xForwardedFor = headers['X-Forwarded-For'];
  const { ip: cIp } = req;
  const { remoteAddress } = connection || {};
  const ip = xRealIp || xForwardedFor || cIp || remoteAddress;

  return {
    url,
    host: headers.host,
    ip,
    method,
    query,
    body,
  };
};

在全局中间件中记录日志

logger.middleware.ts

import { Inject, Injectable, NestMiddleware } from '@nestjs/common';
import { Request, Response, NextFunction } from 'express';
import { WINSTON_MODULE_PROVIDER } from 'nest-winston';
import { Logger } from 'winston';
import { getReqMainInfo } from '../../utils/getReqMainInfo';

@Injectable()
export default class LoggerMiddleware implements NestMiddleware {
  // 注入日志服务相关依赖
  constructor(
    @Inject(WINSTON_MODULE_PROVIDER) private readonly logger: Logger,
  ) {}

  use(req: Request, res: Response, next: NextFunction) {
    // 获取请求信息
    const {
      query,
      headers: { host },
      url,
      method,
      body,
    } = req;

    // 记录日志
    this.logger.info('route', {
      req: getReqMainInfo(req),
    });

    next();
  }
}

在全局异常过滤器中记录日志

uinify-exception.filter.ts

import {
  ArgumentsHost,
  Catch,
  ExceptionFilter,
  HttpException,
  HttpStatus,
  Inject,
} from '@nestjs/common';
import { Response, Request } from 'express';
import { WINSTON_MODULE_PROVIDER } from 'nest-winston';
import { Logger } from 'winston';
import { getReqMainInfo } from '../../utils/getReqMainInfo';

@Catch()
export default class UnifyExceptionFilter implements ExceptionFilter {
  // 注入日志服务相关依赖
  constructor(
    @Inject(WINSTON_MODULE_PROVIDER) private readonly logger: Logger,
  ) {}

  catch(exception: HttpException, host: ArgumentsHost) {
    const ctx = host.switchToHttp(); // 获取当前执行上下文
    const res = ctx.getResponse<Response>(); // 获取响应对象
    const req = ctx.getRequest<Request>(); // 获取请求对象
    const status =
      exception instanceof HttpException
        ? exception.getStatus()
        : HttpStatus.INTERNAL_SERVER_ERROR;

    const response = exception.getResponse();
    let msg =
      exception.message || (status >= 500 ? 'Service Error' : 'Client Error');
    if (Object.prototype.toString.call(response) === '[object Object]') {
      if (typeof response === 'string') {
        msg = response;
      }
    }
    const { query, headers, url, method, body } = req;

    // 记录日志(错误消息,错误码,请求信息等)
    this.logger.error(msg, {
      status,
      req: getReqMainInfo(req),
      // stack: exception.stack,
    });

    res.status(status >= 500 ? status : 200).json({ code: 1, msg });
  }
}

在响应拦截器中记录日志

unify-response.interceptor.ts

import {
  CallHandler,
  ExecutionContext,
  Inject,
  Injectable,
  NestInterceptor,
} from '@nestjs/common';
import { Observable } from 'rxjs';
import { map } from 'rxjs/operators';
import { Request } from 'express';
import { WINSTON_MODULE_PROVIDER } from 'nest-winston';
import { Logger } from 'winston';
import { getReqMainInfo } from '../../utils/getReqMainInfo';

@Injectable()
export class UnifyResponseInterceptor implements NestInterceptor {
  constructor(
    @Inject(WINSTON_MODULE_PROVIDER) private readonly logger: Logger,
  ) {}

  intercept(context: ExecutionContext, next: CallHandler): Observable<any> {
    const ctx = context.switchToHttp();
    const req = ctx.getRequest<Request>();

    return next.handle().pipe(
      map(data => {
        this.logger.info('response', {
          responseData: data,
          req: getReqMainInfo(req),
        });
        return {
          code: 0,
          data,
          msg: '成功',
        };
      }),
    );
  }
}

应用全局中间件、过滤器以及拦截器

app.module.ts

import {
  MiddlewareConsumer,
  Module,
  NestModule,
  RequestMethod,
} from '@nestjs/common';
import { APP_FILTER } from '@nestjs/core';
import { WinstonModule } from 'nest-winston';
import * as winston from 'winston';
import 'winston-daily-rotate-file';
import UnifyExceptionFilter from './common/uinify-exception.filter';
import logger from './common/logger.middleware';
// ...

@Module({
  // ...
  imports: [
    // ...
    WinstonModule.forRoot({
     // ...
    }),
  ],
  providers: [
    // ...
    // 应用全局过滤器
    {
      provide: APP_FILTER,
      useClass: UnifyExceptionFilter,
    },
    // 应用拦截器
    {
      provide: APP_INTERCEPTOR,
      useClass: UnifyResponseInterceptor,
    },
  ],
})
export class AppModule implements NestModule {
  // 应用全局中间件
  configure(consumer: MiddlewareConsumer) {
    consumer.apply(logger).forRoutes({ path: '*', method: RequestMethod.ALL });
  }
}

完成以上配置后,项目目录下就会包含访问及错误信息的日志文件。日志文件将每天自动归档压缩,超过 14 天的日志也将被自动删除。

引用

基于 Winston 实现 NestJS 应用日志服务
NestJS: Setting up file logging daily rotation with winston

Windows 相关知识操作及部分快捷键

之前机缘巧合,搜索了一下 Windows 相关知识,发现有一些知识和快捷键确实不了解,也从没注意到过,在此记录一下作为整理,如果你有其他关于 Windows 的相关知识和快捷键可以与我一同分享。

Windows 相关知识

1. 命令行访问带空格的目录时,必需要加引号,不然访问不到:

e.g. C:\>cd "Program Files\Java"

另最新版的 Windows 系统已经帮你处理了这块,按下 Tab 联想自动会加的,有时候就是用代码执行 bat 的时候需要注意这里。

2. Windows 中一些特殊单词不能作为文件名,例如 auxcom1com2prnconnul,如果你发现有软件用用户文件名作为配置文件夹名称,你可以把自己用户名改成上面那些单词,软件可能就会崩溃。

3. Windows 路径长度最多为 260 个字符。

4. Windows 创建一个没后缀名的文件需要在文件名称后面紧跟一个点,比如 .ignore. 系统会自动识别成 .ignore

5. 文件删除不掉提示被占用,可以通过资源监视器CPU关联句柄里搜索文件,然后结束进程。

6. 使用 PROGRA~1 代替 Program Files 。cmd 访问文件最快的办法是把文件用鼠标拖入 cmd 中。

7. Windows 软件闪退想找错误日志?运行里打开 eventvwr.exe

8. Windows 文件历史记录可以备份文件十分好用,Windows 自带的搜索可以设置搜索文件的内容(包括 TXT、Word、Excel 等文件内容)。

9. 按住 ctrl + shift + alt 再打开任务管理器,任务管理器会进入精简模式,便于在系统资源不足时使用任务管理器。任务管理器卡死崩溃,按 ctrl + shift + esc 可以让崩溃的任务管理器在 10 秒内重新启动。

10. 在开始菜单点关机重启时,按住 shift 键可以修改系统启动模式或进入高级恢复选项。

11. Windows 可以设置在重要操作时要求输入密码:组策略编辑器,Windows 组件,凭据用户界面—要求输入凭据的受信任路径,点击启用。系统 UAC 需要开最高。这样安装软件,修改系统重要设置都需要验证密码。

12. 电脑配置不高,你使用软件比较卡顿时,可以在任务管理器修改进程优先级。正常改为:高于正常。

13. 资源管理器中按住 Shift 键,再按鼠标右键会弹出带有“在此处打开 CMD/PowerShell 窗口”的菜单。

14. 选中文件上按住 Shift 点鼠标右键,菜单里会多出一项复制为路径。

15. Windows 下按住 alt 键双击文件夹会打开该文件夹的属性窗口。

16. 按住 Ctrl+Shift,再单击打开可执行程序,就会通过管理员模式打开。

17. 修改 hosts 文件时,可以按 Win + R 打开“运行”窗口,在输入框中输入 drivers 直接打开 C:\Windows\System32\drivers 目录,之后再自行打开 .\etc\hosts,比一层层目录点进去要省不少事。

18. Windows 系统盘下的 User 目录可以迁移到其他盘符中,具体操作可以看我之前发过的文章《改变 Windows 用户文件夹默认路径 C:/Users》。

Windows 快捷键

win + q (query) 搜索
win + w (write) 手写笔
win + e (explorer) 资源管理器
win + r (run) 运行
win + a (alert) 通知中心
win + s (search) 也是搜索
win + d (disappear) 老板键
win + f (feedback) 系统反馈
win + x 等同于右键点击开始菜单
win + c (cortana) 微软小娜
win + v 剪切板
win + h 语言输入
win + m (minimal) 最小化窗口
win + . emoji
win + ; emoji
win + i 设置
win + p (project) 投影
win + + 放大镜
win + d (desktop) 显示桌面
win + l (lock) 锁屏
win + t (taskbar) 任务栏上固定的应用
win + tab 虚拟桌面切换
win + ctrl + 左右键 切换虚拟桌面
win + shift + s 截图
ctrl + shift + Esc 任务管理器
ctrl + shift + Enter 以管理员权限启动
ctrl + l 激活地址栏,在地址栏中键入 PowerShell 即可自动打开已当前目录路径的 PowerShell
ctrl + w 关闭窗口

引用

Windows 下有哪些程序员平时不太了解,却很重要的知识?

租房笔记

该笔记同时在 GitHub 上的 rent-room-notes(点击跳转) 进行同步,如果你对此感兴趣可以在 GitHub 中提交 PR,与我一同维护。

更新时间:2023年8月11日

更新内容:

  • 调整段落;
  • 新增物品清单;

租房

地段

留意所在地的交通情况,是否靠近地铁站,上下班高峰期体验一下来回公司的交通,地铁公交站等交通设施超过 2 公里的不要考虑。
注意租的房屋附近周围有没有垃圾回收站,尽量不选。

房子

租房尽量提前自我确定并明确自己的需求。
如果可能,尽量检查以下内容:

光线

不要光线太好和太差的,不要早晚太晒的;
选好的房子最好两次看房(一次白天一次晚上),早上看光照,晚上看是否吵闹;

房屋

房间是否有霉味;
尽量不选临街房屋,最好晚上的时候感觉一下吵不吵,平时适不适合开窗户;
隔音效果如何(可以敲一敲墙壁);
房子里各个家电都试一遍是否完好;
注意角落里是否有损坏、漏水等情况;

卫生间

马桶上水、下水是否正常,水流够不够大;
热水器烧气还是用电,升温快不快,容量、安全问题;
老房子要特别注意下地漏有没有做防反味处理;

费用

签合同是看提前退租和转租;
水卡、电卡、气卡、 电梯费、垃圾费、管理费的缴费标准,物业取暖费是否是房东付;
查看水表是否是插卡式,如果是最好插卡看看电池是否还有电;

其它

如果有物品损坏,由谁来维修付款;
打开美团看一下周边外卖;

中介

一定要找正规、知名的租房中介,即使有坑,但比小中介好。
不要月付然后需要办信用之类那种房屋,宁愿季付。

房东

询问是否为二手房东。跟房东聊一下禁忌(比如不能带宠物),签约时要注意房东的身份。
如果从私人手里租房的话,不要怕麻烦,协议写的越详细越好。

室友

如果是和别人合租,条件允许的情况下可以友好的询问一下对方的职业,平时的生活作息、习惯等,如果条件不允许可以注意查看房子的公共区域是否整洁干净,从而大概判断。

物业

有一些社区、小区物业居委会那里也可以租到房子。

合同

合同一式两份,一份给租客,一份给房东。
除了条款外,双方的身份证复印件,房东的房产证复印件看一眼。
最后签名落款时也要写下身份证信息并盖手指印。
合同一定要打印出来签名盖章。退房时也要按照合约来,比如提前一个月告知房东是否续约,打扫干净房子,房东验房后及时退回押金。

签了合同再交定金!入住当天先将全屋拍照,视频留档。

物品清单

随身物品

  • 钱包
    • 身份证
    • 银行卡
    • 现金
  • 手机充电器
  • 充电宝
  • 耳机
  • 笔记本
    • 电源线
    • 鼠标
    • 耳机
    • U 盘
    • 移动硬盘

洗漱用品

  • 洗面奶
  • 洗发水
  • 电动牙刷
  • 充电线
  • 剃须刀
  • 充电器

生活用品

衣物

  • 上衣
  • 裤子
  • 内裤
  • 袜子
  • 睡衣、睡裤
  • 鞋子
  • 拖鞋
  • 衣挂
  • 衣架
  • 棉裤(冬季)
  • 羽绒服(冬季)

床上用品

  • 枕头
  • 被子
  • 被褥
  • 床单、被罩、枕套、枕巾

三餐饮食

  • 碗、盘
  • 筷子
  • 水果刀、菜刀

推荐一个正经的鼠标样式

Windows 自带的鼠标样式其实看着“中规中矩”,不说难看但是看习惯也就能用。macOS 的鼠标样式就很🉑。

之前搜索鼠标样式的时候去 GitHub 看了一下,果然还真有这么正经的鼠标样式 Apple Cursor

Open source macOS Cursors for Windows and Linux with HiDPI Support .

ful1e5/apple_cursor

Windows 和 Linux 如何安装 README 里都有写清楚,我尝试安装并启用,效果非常不错,很“细腻”。

如果你感兴趣的话也可以下载并安装尝试一下。

改变 Windows 用户文件夹默认路径 C:/Users

Windows 默认的总用户文件夹总是会在系统盘下,如果你的系统盘为 C 盘,则为: C:\Users ,许多默认文件夹也都会放在这里:

  • 文档、桌面、下载、图片、视频等文件夹都默认在这里,这些文件夹倒是可以改变位置
  • AppData 文件夹默认在用户根目录下,存储了大部分软件的数据、配置,无法被改变位置
  • .config / .ssh / .config / scoop 等配置目录也在用户根目录下,无法改变位置
  • 许多软件的默认数据位置

系统盘符:\Users\用户名\AppData 里面一般有三个文件夹,分别是 Local / LocalLow / Roaming ,简单地来说,都是用来存放软件的配置文件和临时文件的,里面有很多以软件名称或软件公司命名的文件夹,还有用户帐户的配置文件。随着系统使用时间的增加和安装软件的增多, AppData 占用的空间会越来越大。

上面这些目录会导致系统盘占用很大,即使其中有部分可以手动指派其它路径,但是每次指定都很麻烦,重装系统时候备份也不方便(用户目录里有许多细碎的小文件,备份非常慢),还不如将用户目录迁出系统盘,所有软件都用默认路径,多省事。

另外,修改了用户路径后,当安装软件只为用户安装时,默认的安装路径也会到你的用户目录所在盘,大大节省了系统盘空间。

安装 Windows 的时候修改默认用户路径(推荐)

正常安装 Windows

当 Windows 连接到网络的时候有时 Sysprep 会失败,所以建议全程关闭网络连接安装系统。安装系统的方法不多做介绍。安装系统重启后停留在选择地区的配置界面。

进入 Audit Mode(审计模式)

在系统配置选择地区的界面,按下 Ctrl + Shift + F3 ,这时 Windows 会重启,进入 Audit Mode ,然后显示一个 System Preparation Tool(系统准备工具) ,点击取消,将它关闭。

新建 relocate.xml

现在你可以将电脑连接到网络了。

接下来我们要使用 System Preparation Tool (Sysprep) 工具来设置用户路径。这个工具会执行一个 xml 文件中的配置(也就是 relocate.xml)。我们现在只需要一个非常简单的 xml配置文件,只需包含以下内容:

  • Windows 的版本(32 或 64 位)
  • 用户文件夹的新路径(例如 D:/Users

新建 relocate.xml ,并使用记事本打开拷贝以下代码:

<?xml version="1.0" encoding="utf-8"?>
<unattend xmlns="urn:schemas-microsoft-com:unattend">
	<settings pass="oobeSystem">
		<component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
			<FolderLocations>
				<ProfilesDirectory>D:\Users</ProfilesDirectory>
			</FolderLocations>
		</component>
	</settings>
</unattend>
警告,在操作之前,请先读一下这个:
1. Windows 以字母来标识盘符,但是当安装了 Windows 重启之后,本来你想把用户目录安装到 d 盘,但这个盘符可能会发生改变,比如变成了 e 盘,这个时候就会失败,所以一定要确定好盘符。
2. xml 文件保存到磁盘根目录(不能是 C 盘),例如我把它保存到了 D:\relocate.xml
3. 部分计算机在 Audit Mode 下因为缺少驱动,键盘无法使用,可以借助其他计算机编写,并拷贝,也可以完全用鼠标操作完成,看个人能力。

运行 Sysprep

以管理员身份运行 cmd,首先确保已停止 WMP Network Sharing Service 服务:

net stop wmpnetworksvc

然后运行以下命令:

%windir%\system32\sysprep\sysprep.exe /oobe /reboot /unattend:d:\relocate.xml

上述命令告诉系统从 Windows\System32\Sysprep 运行 Sysprep,执行 D:/relocate.xml 中的指令,为 OOBE (the firlst boot of newly installed Windows) 重启准备系统,最后重启。

完成

完成上述操作后,自动重启进入系统,检查 User 目录已经移动到了 D 盘。

在已经安装好的 Windows 系统上迁移用户目录

警告:操作之前,一定要先创建一个系统映像,做好备份。
对一个 OEM 预先安装的 Windows 使用 Sysprep 是非常危险的。电脑厂商可能有他们自己的 unattended answer file,这样可能就会忽略掉你的 unattended file。在这个过程中可能会出各种错误,所以不建议操作。
如果中途出错了,你的备份文件可以帮助你恢复。
这个操作非常有可能导致你的电脑恢复出厂设置。
警告****1703 或者更高版本,请不要禁用已存在的用户!!!
在 Win10 1703 或更高版本上,千万不要禁用现有用户,因为禁用现有用户可能会让你无法登录 Windows,进而需要重装。

新建 relocate.xml

按照上面说过的步骤新建一个 relocate.xml 文件。

运行 Sysprep

按照上面说过的步骤运行 Sysprep

OOBE

虽然你已经安装了 Windows,但是在 Sysprep 运行之后 OOBE 仍然会运行,这意味着你的电脑会经历初始化程序。

这里有两点需要注意:

  • Windows 要求你输入产品密钥,但是不需要去输入,单击跳过就可以了;
  • 之前的账户还会存在,但是 OOBE 会要求新建一个用户,如果新建的这个用户和已存在的用户名字相同,那就会发生错误。只需要新建一个随意的账户,之后,再把它删掉就可以了;

引用

Windows 如何删除右键菜单中的 “Git Gui Here”和“Git Bash Here”

今天重新安装了 Git 后,发现右击鼠标右侧多出了两个选项“Git Gui Here”和“Git Bash Here”。虽然这样证明我的 Git 已经成功安装了,但还是影响使用感受,遂上网寻找了一下相关的解决方案。

手动修改注册表

  1. Win + R 调出“运行”窗口,在搜索框中输入“regedit”打开注册表编辑器;
  2. 在打开的注册表中通过以下路径进行查找: Computer\HKEY_CLASSES_ROOT\Directory\Background\shell 。在下方就可以看到 git_guigit_shell 这两项内容,将其删除即可。
  3. 关闭注册表之后,在桌面上右击鼠标就能看到 “Git Gui Here”和“Git Bash Here”选项就已经被删除了。

直接使用管理员 CMD(命令提示符)执行删除

如果上述方法比较繁琐,可以尝试使用具有管理员权限的 CMD(命令提示符) 执行以下两条语句:

reg delete "HKEY_CLASSES_ROOT\Directory\Background\shell\git_gui" /f
reg delete "HKEY_CLASSES_ROOT\Directory\Background\shell\git_shell" /f

Debian 软件仓库镜像

一般情况下,将 /etc/apt/sources.list 文件中 Debian 默认的源地址 http://deb.debian.org/ 替换为镜像地址即可。

Debian Buster 以上版本默认支持 HTTPS 源。如果遇到无法拉取 HTTPS 源的情况,请先使用 HTTP 源并安装:

sudo apt install apt-transport-https ca-certificates

Debian Bookworm 12 软件仓库镜像源

清华大学开源软件镜像站

# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm main contrib non-free non-free-firmware
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm main contrib non-free non-free-firmware

deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-updates main contrib non-free non-free-firmware
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-updates main contrib non-free non-free-firmware

deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-backports main contrib non-free non-free-firmware
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-backports main contrib non-free non-free-firmware

# deb https://mirrors.tuna.tsinghua.edu.cn/debian-security bookworm-security main contrib non-free non-free-firmware
# # deb-src https://mirrors.tuna.tsinghua.edu.cn/debian-security bookworm-security main contrib non-free non-free-firmware

deb https://security.debian.org/debian-security bookworm-security main contrib non-free non-free-firmware
# deb-src https://security.debian.org/debian-security bookworm-security main contrib non-free non-free-firmware

阿里云镜像站

deb https://mirrors.aliyun.com/debian/ bookworm main non-free non-free-firmware contrib 
deb-src https://mirrors.aliyun.com/debian/ bookworm main non-free non-free-firmware contrib
deb https://mirrors.aliyun.com/debian-security/ bookworm-security main
deb-src https://mirrors.aliyun.com/debian-security/ bookworm-security main
deb https://mirrors.aliyun.com/debian/ bookworm-updates main non-free non-free-firmware contrib
deb-src https://mirrors.aliyun.com/debian/ bookworm-updates main non-free non-free-firmware contrib
deb https://mirrors.aliyun.com/debian/ bookworm-backports main non-free non-free-firmware contrib
deb-src https://mirrors.aliyun.com/debian/ bookworm-backports main non-free non-free-firmware contrib

腾讯云镜像站

deb https://mirrors.tencent.com/debian/ bookworm main non-free non-free-firmware contrib
deb-src https://mirrors.tencent.com/debian/ bookworm main non-free non-free-firmware contrib
deb https://mirrors.tencent.com/debian-security/ bookworm-security main
deb-src https://mirrors.tencent.com/debian-security/ bookworm-security main
deb https://mirrors.tencent.com/debian/ bookworm-updates main non-free non-free-firmware contrib
deb-src https://mirrors.tencent.com/debian/ bookworm-updates main non-free non-free-firmware contrib
deb https://mirrors.tencent.com/debian/ bookworm-backports main non-free non-free-firmware contrib
deb-src https://mirrors.tencent.com/debian/ bookworm-backports main non-free non-free-firmware contrib

网易镜像站

deb https://mirrors.163.com/debian/ bookworm main non-free non-free-firmware contrib
deb-src https://mirrors.163.com/debian/ bookworm main non-free non-free-firmware contrib
deb https://mirrors.163.com/debian-security/ bookworm-security main
deb-src https://mirrors.163.com/debian-security/ bookworm-security main
deb https://mirrors.163.com/debian/ bookworm-updates main non-free non-free-firmware contrib
deb-src https://mirrors.163.com/debian/ bookworm-updates main non-free non-free-firmware contrib
deb https://mirrors.163.com/debian/ bookworm-backports main non-free non-free-firmware contrib
deb-src https://mirrors.163.com/debian/ bookworm-backports main non-free non-free-firmware contrib

华为云镜像站

deb https://mirrors.huaweicloud.com/debian/ bookworm main non-free non-free-firmware contrib
deb-src https://mirrors.huaweicloud.com/debian/ bookworm main non-free non-free-firmware contrib
deb https://mirrors.huaweicloud.com/debian-security/ bookworm-security main
deb-src https://mirrors.huaweicloud.com/debian-security/ bookworm-security main
deb https://mirrors.huaweicloud.com/debian/ bookworm-updates main non-free non-free-firmware contrib
deb-src https://mirrors.huaweicloud.com/debian/ bookworm-updates main non-free non-free-firmware contrib
deb https://mirrors.huaweicloud.com/debian/ bookworm-backports main non-free non-free-firmware contrib
deb-src https://mirrors.huaweicloud.com/debian/ bookworm-backports main non-free non-free-firmware contrib

Debian Bullseye 11 软件仓库镜像源

网易镜像站

#http://mirrors.163.com/debian/为软件源也可以为其他的 bullseye为版本代号 main non-free contrib区别如下
deb https://mirrors.163.com/debian/ bullseye main non-free contrib
deb-src https://mirrors.163.com/debian/ bullseye main non-free contrib
deb https://mirrors.163.com/debian-security/ bullseye-security main
deb-src https://mirrors.163.com/debian-security/ bullseye-security main
deb https://mirrors.163.com/debian/ bullseye-updates main non-free contrib
deb-src https://mirrors.163.com/debian/ bullseye-updates main non-free contrib
deb https://mirrors.163.com/debian/ bullseye-backports main non-free contrib
deb-src https://mirrors.163.com/debian/ bullseye-backports main non-free contrib

腾讯云镜像站

deb https://mirrors.tencent.com/debian/ bullseye main non-free contrib
deb-src https://mirrors.tencent.com/debian/ bullseye main non-free contrib
deb https://mirrors.tencent.com/debian-security/ bullseye-security main
deb-src https://mirrors.tencent.com/debian-security/ bullseye-security main
deb https://mirrors.tencent.com/debian/ bullseye-updates main non-free contrib
deb-src https://mirrors.tencent.com/debian/ bullseye-updates main non-free contrib
deb https://mirrors.tencent.com/debian/ bullseye-backports main non-free contrib
deb-src https://mirrors.tencent.com/debian/ bullseye-backports main non-free contrib

阿里云镜像站

deb https://mirrors.aliyun.com/debian/ bullseye main non-free contrib
deb-src https://mirrors.aliyun.com/debian/ bullseye main non-free contrib
deb https://mirrors.aliyun.com/debian-security/ bullseye-security main
deb-src https://mirrors.aliyun.com/debian-security/ bullseye-security main
deb https://mirrors.aliyun.com/debian/ bullseye-updates main non-free contrib
deb-src https://mirrors.aliyun.com/debian/ bullseye-updates main non-free contrib
deb https://mirrors.aliyun.com/debian/ bullseye-backports main non-free contrib
deb-src https://mirrors.aliyun.com/debian/ bullseye-backports main non-free contrib

华为云镜像站

deb https://mirrors.huaweicloud.com/debian/ bullseye main non-free contrib
deb-src https://mirrors.huaweicloud.com/debian/ bullseye main non-free contrib
deb https://mirrors.huaweicloud.com/debian-security/ bullseye-security main
deb-src https://mirrors.huaweicloud.com/debian-security/ bullseye-security main
deb https://mirrors.huaweicloud.com/debian/ bullseye-updates main non-free contrib
deb-src https://mirrors.huaweicloud.com/debian/ bullseye-updates main non-free contrib
deb https://mirrors.huaweicloud.com/debian/ bullseye-backports main non-free contrib
deb-src https://mirrors.huaweicloud.com/debian/ bullseye-backports main non-free contrib

清华大学开源软件镜像站

# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye main contrib non-free
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye main contrib non-free

deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-updates main contrib non-free
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-updates main contrib non-free

deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-backports main contrib non-free
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-backports main contrib non-free

# deb https://mirrors.tuna.tsinghua.edu.cn/debian-security bullseye-security main contrib non-free
# # deb-src https://mirrors.tuna.tsinghua.edu.cn/debian-security bullseye-security main contrib non-free

deb https://security.debian.org/debian-security bullseye-security main contrib non-free
# deb-src https://security.debian.org/debian-security bullseye-security main contrib non-free

引用

Debian 软件仓库镜像使用帮助 —— 清华大学开源软件镜像站

从 npm 迁移到 pnpm

目前自己写的项目都是使用的是 npm,但是昨天偶然看到了介绍,想把自己的项目从 npm 替换为 pnpm,遂上网搜索了一下迁移教程。

介于 npm 与 pnpm 的区别,可以浏览我先前发布的文章:《npm、yarn、pnpm 各自区别》。

如何将 npm 迁移到 pnpm

需要执行以下步骤:

1. 卸载 npm

首先,将 npm 包从当前项目中卸载

rm -rf node_modules

2. 安装 pnpm

安装 pnpm ,以便可以在项目中使用它

npm install -g pnpm

3. 创建配置文件

在项目目录下创建 .npmrc 的文件

# pnpm 配置
shamefully-hoist=true
auto-install-peers=true
strict-peer-dependencies=false

4. 转换相关文件

package-lock.jsonyarn.lock 转成 pnpm-lock.yaml 文件,保证依赖版本不变

pnpm import

5. 安装依赖包

通过 pnpm 安装依赖包

pnpm install

最后,迁移完成!

在项目正常运行之后,可以删除原本的 package-lock.jsonyarn.lock 文件,保持项目的整洁。

微信小程序 rich-text 超过 2 行显示省略号

rich-text(富文本),如果想实现文本超过两行变成省略号,常规的 div 可以实现,但因为是在微信小程序中,同时使用的是 rich-text 返回的是富文本,所以不能简单的使用以下代码实现:

word-break: break-all;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
overflow: hidden;

因为富文本使用的 rich-text 回显的,想着直接对这个标签写上这个 CSS,发现也无法达到想要的效果。Android 真机可以正常显示,在模拟器上也能正常变成省略号,但 iOS 真机不兼容。

解决办法

在回显的 rich-text 中包裹一层 div,在这个包裹层中写上样式,就可达到超过两行隐藏的效果。

<rich-text style="word-wrap: break-word;word-break: break-all;" nodes="<div style='text-overflow:ellipsis; -webkit-box-orient:vertical;-webkit-line-clamp:2; overflow: hidden; display: -webkit-box;'>{{assetInfo.description}}</div>"></rich-text>

如上演示加粗部分就是需要手工增加的内容,手工在数据外加一层 div 包裹在外即可解决问题。