import pinia from '~src/store/init'
import { useAppStore } from '~src/store'
import { decode, encode } from 'js-base64'
import { getObjVal, isNullES } from 'js-fast-way'

//初始变量
const store = useAppStore(pinia)

// 按钮权限
export const btnAuth = (key) => {
    try {
        const info = store.getButtonsVal(key)
        return !!getObjVal(info)
    } catch {
        return false
    }
}

// 跳转到PDF页面
export const toPdfPage = (url) => {
    if (isNullES(url)) {
        window.$message.warning('pdf地址为空')
        return
    }
    //newWindow('/#/pdf?code=' + encode(url))
    window.open('/#/pdf?code=' + encode(url), '_blank')
}

export { encode, decode }
