添加一些标题文字 (#11)

This commit is contained in:
2y8e9h22 2023-03-08 14:10:45 +08:00 committed by GitHub
parent d5ecb84146
commit 5216f6fc0a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 28 additions and 1 deletions

View File

@ -8,6 +8,7 @@ import yaml from 'yaml'
let path = './config/config/qq.yaml'
// 异步函数来读取 yaml 文件
/*
async function getQQ () {
function getQQPromise () {
// eslint-disable-next-line no-async-promise-executor
@ -29,9 +30,35 @@ async function getQQ () {
console.log(err)
})
}
*/
// 添加一些多余的标题内容
let title = 'Miao-Yunzai'
let qq = await fs.promises.readFile('./config/config/qq.yaml', 'UTF-8').then(yaml.parse).catch(() => null)
if (qq) {
title += `@${qq.qq || '首次启动'}`
switch (qq.platform) {
case 1:
title += ' 安卓手机'
break
case 2:
title += ' aPad'
break
case 3:
title += ' 安卓手表'
break
case 4:
title += ' MacOS'
break
case 5:
title += ' iPad'
}
}
/** 设置标题 */
process.title = `Miao-Yunzai ${(await getQQ()).qq === null ? '首次启动' : (await getQQ()).qq} ${(await getQQ()).platform === 1 ? '安卓手机' : (await getQQ()).platform === 2 ? 'aPad' : (await getQQ()).platform === 3 ? '安卓手表' : (await getQQ()).platform === 4 ? 'MacOS' : (await getQQ()).platform === 5 ? 'iPad' : 'Null'}`
process.title = title
// process.title = `Miao-Yunzai ${(await getQQ()).qq === null ? '首次启动' : (await getQQ()).qq} ${(await getQQ()).platform === 1 ? '安卓手机' : (await getQQ()).platform === 2 ? 'aPad' : (await getQQ()).platform === 3 ? '安卓手表' : (await getQQ()).platform === 4 ? 'MacOS' : (await getQQ()).platform === 5 ? 'iPad' : 'Null'}`
/** 设置时区 */
process.env.TZ = 'Asia/Shanghai'