import {t} from "@/lang";

export const fmtTitle = (title, now) => {
  const reg = /\$\{(.+?)\}/
  const reg_g = /\$\{(.+?)\}/g
  const result = title.match(reg_g)
  if (result) {
    result.forEach((item) => {
      const key = item.match(reg)[1]
      const value = now.params[key] || now.query[key]
      title = title.replace(item, value)
    })
  }
  console.log('面包屑', title, now)
  if (!title) return ''
  // 从语言包找，找不到就返回原来的中文（不报错、不空白）
  return t.value[title] || title
}
