import Mock from 'mockjs';
import { DEFAULT_USER_AVATAR } from '@/constants/avatar';
import setupMock, { successResponseWrap } from '@/mocks/setup';

setupMock({
  setup() {
    Mock.mock(/\/api\/user\/my-project\/list/, () => {
      const contributors = [
        {
          name: '\u79e6\u81fb\u5b87',
          email: 'qingzhenyu@arco.design',
          avatar:
            '//p1-arco.byteimg.com/tos-cn-i-uwbnlip3yd/a8c8cdb109cb051163646151a4a5083b.png~tplv-uwbnlip3yd-webp.webp',
        },
        {
          name: '\u4e8e\u6d9b',
          email: 'yuebao@arco.design',
          avatar:
            '//p1-arco.byteimg.com/tos-cn-i-uwbnlip3yd/a8c8cdb109cb051163646151a4a5083b.png~tplv-uwbnlip3yd-webp.webp',
        },
        {
          name: '\u5b81\u6ce2',
          email: 'ningbo@arco.design',
          avatar:
            '//p1-arco.byteimg.com/tos-cn-i-uwbnlip3yd/3ee5f13fb09879ecb5185e440cef6eb9.png~tplv-uwbnlip3yd-webp.webp',
        },
        {
          name: '\u90d1\u6666\u6708',
          email: 'zhengxiyue@arco.design',
          avatar:
            '//p1-arco.byteimg.com/tos-cn-i-uwbnlip3yd/8361eeb82904210b4f55fab888fe8416.png~tplv-uwbnlip3yd-webp.webp',
        },
        {
          name: '\u5b81\u6ce2',
          email: 'ningbo@arco.design',
          avatar:
            '//p1-arco.byteimg.com/tos-cn-i-uwbnlip3yd/3ee5f13fb09879ecb5185e440cef6eb9.png~tplv-uwbnlip3yd-webp.webp',
        },
      ];
      const units = [
        {
          name: '\u4f01\u4e1a\u7ea7\u4ea7\u54c1\u8bbe\u8ba1\u7cfb\u7edf',
          description: 'Arco Design System',
        },
        {
          name: '\u706b\u5c71\u5f15\u64ce\u667a\u80fd\u5e94\u7528',
          description: 'The Volcano Engine',
        },
        {
          name: 'OCR\u6587\u672c\u8bc6\u522b',
          description: 'OCR text recognition',
        },
        {
          name: '\u5185\u5bb9\u8d44\u6e90\u7ba1\u7406',
          description: 'Content resource management ',
        },
        {
          name: '\u4eca\u65e5\u5934\u6761\u5185\u5bb9\u7ba1\u7406',
          description: 'Toutiao content management',
        },
        {
          name: '\u667a\u80fd\u673a\u5668\u4eba',
          description: 'Intelligent Robot Project',
        },
      ];
      return successResponseWrap(
        new Array(6).fill(null).map((_item, index) => ({
          id: index,
          name: units[index].name,
          description: units[index].description,
          peopleNumber: Mock.Random.natural(10, 1000),
          contributors,
        })),
      );
    });

    Mock.mock(/\/api\/user\/latest-activity/, () => {
      return successResponseWrap(
        new Array(7).fill(null).map((_item, index) => ({
          id: index,
          title:
            '\u53d1\u5e03\u4e86\u9879\u76ee Arco Design System',
          description: '\u4f01\u4e1a\u7ea7\u4ea7\u54c1\u8bbe\u8ba1\u7cfb\u7edf',
          avatar: DEFAULT_USER_AVATAR,
        })),
      );
    });

    Mock.mock(/\/api\/user\/visits/, () => {
      return successResponseWrap([
        {
          name: '\u4e3b\u9875\u8bbf\u95ee\u91cf',
          visits: 5670,
          growth: 206.32,
        },
        {
          name: '\u9879\u76ee\u8bbf\u95ee\u91cf',
          visits: 5670,
          growth: 206.32,
        },
      ]);
    });

    Mock.mock(/\/api\/user\/project-and-team\/list/, () => {
      return successResponseWrap([
        { id: 1, content: '\u4ed6\u521b\u5efa\u7684\u9879\u76ee' },
        { id: 2, content: '\u4ed6\u53c2\u4e0e\u7684\u9879\u76ee' },
        { id: 3, content: '\u4ed6\u521b\u5efa\u7684\u56e2\u961f' },
        { id: 4, content: '\u4ed6\u52a0\u5165\u7684\u56e2\u961f' },
      ]);
    });

    Mock.mock(/\/api\/user\/my-team\/list/, () => {
      return successResponseWrap([
        {
          id: 1,
          avatar:
            '//p1-arco.byteimg.com/tos-cn-i-uwbnlip3yd/a8c8cdb109cb051163646151a4a5083b.png~tplv-uwbnlip3yd-webp.webp',
          name: '\u706b\u5c71\u5f15\u64ce\u667a\u80fd\u5e94\u7528\u56e2\u961f',
          peopleNumber: Mock.Random.natural(10, 100),
        },
        {
          id: 2,
          avatar:
            '//p1-arco.byteimg.com/tos-cn-i-uwbnlip3yd/3ee5f13fb09879ecb5185e440cef6eb9.png~tplv-uwbnlip3yd-webp.webp',
          name: '\u4f01\u4e1a\u7ea7\u4ea7\u54c1\u8bbe\u8ba1\u56e2\u961f',
          peopleNumber: Mock.Random.natural(5000, 6000),
        },
        {
          id: 3,
          avatar:
            '//p1-arco.byteimg.com/tos-cn-i-uwbnlip3yd/3ee5f13fb09879ecb5185e440cef6eb9.png~tplv-uwbnlip3yd-webp.webp',
          name: '\u524d\u7aef/UE\u5c0f\u5206\u961f',
          peopleNumber: Mock.Random.natural(10, 5000),
        },
        {
          id: 4,
          avatar:
            '//p1-arco.byteimg.com/tos-cn-i-uwbnlip3yd/8361eeb82904210b4f55fab888fe8416.png~tplv-uwbnlip3yd-webp.webp',
          name: '\u5185\u5bb9\u8bc6\u522b\u63d2\u4ef6\u5c0f\u5206\u961f',
          peopleNumber: Mock.Random.natural(10, 100),
        },
      ]);
    });
  },
});
