/*
 * @Author: your name
 * @Date: 2021-03-02 15:29:31
 * @LastEditTime: 2021-08-09 15:29:58
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit1
 * @FilePath: \vue3-element-admin\src\plugins\mock.js
 */
export default {
    install: async () => {
        const config = await import("@/config");
        if (config.default.pro_mock) {
            const Mock = (await import("mockjs")).default;
            const files = import.meta.glob("@/api/modules/*.js", { eager: true });
            Object.keys(files).forEach((key) => {
                let obj = files[key].default; // 重要：需要访问 .default
                Object.keys(obj).forEach((item) => {
                    if(obj[item].mock){
                        Mock.mock(
                            obj[item].url,
                            obj[item].type,
                            obj[item].response
                        );
                    }
                });
            });
        }
    },
};
