Files
yenai-plugin/model/State/FastFetch.js
2024-05-07 20:25:13 +08:00

28 lines
854 B
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { execSync } from "../../tools/index.js"
import { Config } from "../../components/index.js"
/**
* 获取FastFetch
* @param e
*/
export default async function getFastFetch(e) {
if (!isFeatureVisible(e.isPro)) return ""
let ret = await execSync("bash plugins/yenai-plugin/resources/state/state.sh")
if (ret.error) {
logger.error(`[Yenai-Plugin][状态]Error FastFetch 请检查是否使用git bash启动Yunzai-bot错误信息${ret.stderr}`)
return ""
}
return ret.stdout.trim()
}
function isFeatureVisible(isPro) {
const { showFastFetch } = Config.state
if (showFastFetch === true) return true
if (showFastFetch === "pro" && isPro) return true
if (showFastFetch === "default") {
if (!isPlatformWin() || isPro) return true
}
return false
}
function isPlatformWin() {
return process.platform === "win32"
}