import { clog } from 'js-fast-way'
import config from '~src/config/index'

import { useAppStore } from '~src/store'

const store = useAppStore()

//控制台打印
export const HcLog = (name, tips, data) => {
    const title = store.barMenuName ?? ''
    if (config.isLog === 'auto') {
        if (import.meta.env.DEV) {
            clog(title, name, tips, data)
        }
    } else if (config.isLog === true) {
        clog(title, name, tips, data)
    }
}

//获取当前域名
export const getTopUrl = () => {
    return window.location.href.split('/#/')[0]
}

//设置系统名称
export const setAppName = (name) => {
    const title = window.document.title
    window.document.title = `${title}${name ? ' - ' + name : ''}`
}
