// 以下代码在build时自动移除，无需手动注释
// #ifdef DEV
// import './user/tmp'
// #endif
import type { User } from './user/index.d'
// import router, { FilteredRoutesMap, asyncFilteredRoutes } from '~/router/index'

export const user = ref<User>(JSON.parse(localStorage.getItem('userInfo') ?? '{}'))

watch(
  () => user.value,
  (val) => {
    if (val === null)
      localStorage.removeItem('userInfo')
    // asyncFilteredRoutes.value.forEach((routes) => {
    //   router.removeRoute(routes.name!)
    // })
    // FilteredRoutesMap.value = null

    else
      localStorage.setItem('userInfo', JSON.stringify(val))
  },
)
export const webInfo = ref<{ js_code: string; js_desc: string; js_logo: string; js_title: string; default: { js_code: string; js_desc: string; js_logo: string; js_title: string } } | null>(JSON.parse(localStorage.getItem('webInfo')))

watch(
  () => webInfo.value,
  (val) => {
    if (val) {
      localStorage.setItem('webInfo', JSON.stringify(val))
    }
    else
      localStorage.removeItem('webInfo')
  },
)

