feat(工具箱): 添加“保持亮屏”工具

This commit is contained in:
2024-10-11 00:12:11 +08:00
parent 75f9985265
commit ef95e5ce73
3 changed files with 263 additions and 1 deletions

View File

@@ -195,8 +195,19 @@ export const toolList = [
{
id: 'other-tools',
title: '其他',
enabled: false,
enabled: true,
items: [
{
id: 'keep-screen-on',
component: 'Other/KeepScreenOn',
title: '保持亮屏',
iconClass: 'mdi mdi-monitor',
desc: '保持屏幕开启,不息屏,不休眠',
createdAt: '2024-10-13',
updatedAt: '2024-10-13',
version: '1',
enabled: true,
},
{
id: 'open-new-window',
component: 'Other/OpenNewWindow',

View File

@@ -4,6 +4,36 @@ import {
description as appDesc,
} from '@package-json';
/** 将十六进制颜色值转为灰度值 */
export function colorHexToGrayLevel(hex = '') {
let rgb = colorHexToRgb(hex);
return Math.round(rgb.r * 0.299 + rgb.g * 0.587 + rgb.b * 0.114);
}
/** 将十六进制颜色值转为 RGB */
export function colorHexToRgb(hex = '') {
// 去除可能存在的 '#' 字符
hex = hex.replace('#', '');
// 检查十六进制颜色值的长度,并根据长度决定如何处理
if (hex.length === 3) {
// 如果是简写形式,如 #FFF需要将其转换为完整形式 #FFFFFF
hex = hex.split('').map(char => char + char).join('');
}
// 分别解析出红色、绿色和蓝色的值
let r = parseInt(hex.slice(0, 2), 16);
let g = parseInt(hex.slice(2, 4), 16);
let b = parseInt(hex.slice(4, 6), 16);
return { r, g, b };
}
/**
* @description 更新页面标题
* @param {string} title