🐛 修复状态网络显示
This commit is contained in:
16
index.js
16
index.js
@@ -1,7 +1,6 @@
|
||||
import fs from 'node:fs'
|
||||
import Ver from './components/Version.js'
|
||||
import chalk from 'chalk'
|
||||
import { CPU } from './model/index.js'
|
||||
const files = fs.readdirSync('./plugins/yenai-plugin/apps').filter(file => file.endsWith('.js'))
|
||||
|
||||
let ret = []
|
||||
@@ -10,21 +9,6 @@ logger.info(chalk.rgb(253, 235, 255)('----ヾ( ̄▽ ̄)Bye~Bye~----'))
|
||||
logger.info(chalk.rgb(255, 207, 247)(`椰奶插件${Ver.ver}初始化~`))
|
||||
logger.info(chalk.rgb(253, 235, 255)('-------------------------'))
|
||||
|
||||
try {
|
||||
CPU.si = await import('systeminformation')
|
||||
} catch (error) {
|
||||
if (error.stack?.includes('Cannot find package')) {
|
||||
logger.warn('--------椰奶依赖缺失--------')
|
||||
logger.warn(`yenai-plugin 缺少依赖将无法使用 ${logger.yellow('椰奶状态')}`)
|
||||
logger.warn(`如需使用请运行:${logger.red('pnpm add systeminformation -w')}`)
|
||||
logger.warn('---------------------------')
|
||||
logger.debug(decodeURI(error.stack))
|
||||
} else {
|
||||
logger.error(`椰奶载入依赖错误:${logger.red('systeminformation')}`)
|
||||
logger.error(decodeURI(error.stack))
|
||||
}
|
||||
}
|
||||
|
||||
files.forEach((file) => {
|
||||
ret.push(import(`./apps/${file}`))
|
||||
})
|
||||
|
||||
20
model/CPU.js
20
model/CPU.js
@@ -14,8 +14,26 @@ export default new class OSUtils {
|
||||
this.init()
|
||||
}
|
||||
|
||||
async initDependence () {
|
||||
try {
|
||||
this.si = await import('systeminformation')
|
||||
return this.si
|
||||
} catch (error) {
|
||||
if (error.stack?.includes('Cannot find package')) {
|
||||
logger.warn('--------椰奶依赖缺失--------')
|
||||
logger.warn(`yenai-plugin 缺少依赖将无法使用 ${logger.yellow('椰奶状态')}`)
|
||||
logger.warn(`如需使用请运行:${logger.red('pnpm add systeminformation -w')}`)
|
||||
logger.warn('---------------------------')
|
||||
logger.debug(decodeURI(error.stack))
|
||||
} else {
|
||||
logger.error(`椰奶载入依赖错误:${logger.red('systeminformation')}`)
|
||||
logger.error(decodeURI(error.stack))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async init () {
|
||||
if (!this.si) return
|
||||
if (!await this.initDependence()) return
|
||||
// 初始化GPU获取
|
||||
if ((await this.si.graphics()).controllers.find(item => item.memoryUsed && item.memoryFree && item.utilizationGpu)) {
|
||||
this.isGPU = true
|
||||
|
||||
@@ -9,7 +9,7 @@ const Pixiv = {
|
||||
name: 'Pixiv',
|
||||
index: 5,
|
||||
urlMatcher: /(?:https?:\/\/)?(?:www\.)?pixiv\.net\/member_illust\.php\?mode=.+&illust_id=\d+/i,
|
||||
backupUrl: ({ data: { pixiv_id } }) => `https://www.pixiv.net/member_illust.php?mode=medium&illust_id=${pixiv_id}`,
|
||||
backupUrl: ({ data: { pixiv_id } }) => `https://www.pixiv.net/artworks/${pixiv_id}`,
|
||||
authorData: ({ member_id, member_name }) => ({
|
||||
authorName: member_name,
|
||||
authorUrl: `https://www.pixiv.net/users/${member_id}`
|
||||
|
||||
Reference in New Issue
Block a user