28 lines
854 B
JavaScript
28 lines
854 B
JavaScript
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"
|
||
}
|