global.js 407 B

123456789101112131415161718192021
  1. import { ref, reactive, watch } from 'vue'
  2. import { list as fetchUsers } from '@/api/user'
  3. // todo 缓存所有用户信息
  4. export function loadAllUsers () {
  5. const allUsers = ref([])
  6. const getAllUsers = async () => {
  7. const res = await fetchUsers({ page_size: 9999 }).catch(_ => false)
  8. if (res) {
  9. allUsers.value = res.data.list
  10. }
  11. }
  12. return {
  13. allUsers,
  14. getAllUsers,
  15. }
  16. }