useSystemInit.hook.ts 639 B

1234567891011121314151617181920212223
  1. import { useSystemStore } from '@/store/modules/systemStore/systemStore'
  2. import { SystemStoreEnum } from '@/store/modules/systemStore/systemStore.d'
  3. import { ResultEnum } from '@/enums/httpEnum'
  4. import { ossUrlApi } from '@/api/path/'
  5. // * 初始化
  6. export const useSystemInit = async () => {
  7. const systemStore = useSystemStore()
  8. // 获取 OSS 信息
  9. const getOssUrl = async () => {
  10. const res = await ossUrlApi({}) as unknown as MyResponseType
  11. if (res.code === ResultEnum.SUCCESS) {
  12. systemStore.setItem(SystemStoreEnum.FETCH_INFO, {
  13. OSSUrl: res.data?.bucketURL
  14. })
  15. }
  16. }
  17. // 执行
  18. getOssUrl()
  19. }