{"version":3,"file":"app.js","sources":["../../../../../src/sheep/store/app.js"],"sourcesContent":["import DiyApi from '@/sheep/api/promotion/diy'\r\nimport { defineStore } from 'pinia'\r\nimport $platform from '@/sheep/platform'\r\nimport $router from '@/sheep/router'\r\nimport user from './user'\r\nimport sys from './sys'\r\n\r\nconst app = defineStore({\r\n id: 'app',\r\n state: () => ({\r\n info: {\r\n // 应用信息\r\n name: '', // 商城名称\r\n logo: '', // logo\r\n version: '', // 版本号\r\n copyright: '', // 版权信息 I\r\n copytime: '', // 版权信息 II\r\n\r\n cdnurl: '', // 云存储域名\r\n filesystem: '', // 云存储平台\r\n },\r\n platform: {\r\n share: {\r\n methods: [], // 支持的分享方式\r\n forwardInfo: {}, // 默认转发信息\r\n posterInfo: {}, // 海报信息\r\n linkAddress: '', // 复制链接地址\r\n },\r\n bind_mobile: 0, // 登陆后绑定手机号提醒 (弱提醒,可手动关闭)\r\n },\r\n template: {\r\n // 店铺装修模板\r\n basic: {}, // 基本信息\r\n home: {\r\n // 首页模板\r\n style: {},\r\n data: [],\r\n },\r\n user: {\r\n // 个人中心模板\r\n style: {},\r\n data: [],\r\n },\r\n },\r\n shareInfo: {}, // 全局分享信息\r\n has_wechat_trade_managed: 0, // 小程序发货信息管理 0 没有 || 1 有\r\n }),\r\n actions: {\r\n // 获取Shopro应用配置和模板\r\n async init(templateId = null) {\r\n // 检查网络\r\n const networkStatus = await $platform.checkNetwork()\r\n if (!networkStatus) {\r\n $router.error('NetworkError')\r\n }\r\n\r\n // 加载装修配置\r\n await adaptTemplate(this.template, templateId)\r\n\r\n // TODO 芋艿:未来支持管理后台可配;对应 https://api.shopro.sheepjs.com/shop/api/init\r\n if (true) {\r\n this.info = {\r\n name: '芋道商城',\r\n logo: 'https://static.iocoder.cn/ruoyi-vue-pro-logo.png',\r\n version: '2.2.0',\r\n copyright: '全部开源,个人与企业可 100% 免费使用',\r\n copytime: 'Copyright© 2018-2024',\r\n\r\n cdnurl: 'https://file.sheepjs.com', // 云存储域名\r\n filesystem: 'qcloud', // 云存储平台\r\n }\r\n this.platform = {\r\n share: {\r\n methods: ['poster', 'link'],\r\n linkAddress: 'http://127.0.0.1:3000', // TODO 芋艿:可以考虑改到 .env 那\r\n posterInfo: {\r\n user_bg: '/static/img/shop/config/user-poster-bg.png',\r\n goods_bg: '/static/img/shop/config/goods-poster-bg.png',\r\n groupon_bg: '/static/img/shop/config/groupon-poster-bg.png',\r\n },\r\n },\r\n bind_mobile: 0,\r\n }\r\n this.has_wechat_trade_managed = 0\r\n\r\n // 加载主题\r\n const sysStore = sys()\r\n sysStore.setTheme()\r\n\r\n // 模拟用户登录\r\n const userStore = user()\r\n if (userStore.isLogin) {\r\n userStore.loginAfter()\r\n }\r\n return Promise.resolve(true)\r\n } else {\r\n $router.error('InitError', res.msg || '加载失败')\r\n }\r\n },\r\n },\r\n persist: {\r\n enabled: true,\r\n strategies: [\r\n {\r\n key: 'app-store',\r\n },\r\n ],\r\n },\r\n})\r\n\r\n// todo: @owen 先做数据适配,后期重构\r\nconst adaptTemplate = async (appTemplate, templateId) => {\r\n const { data: diyTemplate } = templateId\r\n ? // 查询指定模板,一般是预览时使用\r\n await DiyApi.getDiyTemplate(templateId)\r\n : await DiyApi.getUsedDiyTemplate()\r\n // 模板不存在\r\n if (!diyTemplate) {\r\n $router.error('TemplateError')\r\n return\r\n }\r\n\r\n const tabBar = diyTemplate?.property?.tabBar\r\n if (tabBar) {\r\n appTemplate.basic.tabbar = tabBar\r\n if (tabBar?.theme) {\r\n appTemplate.basic.theme = tabBar?.theme\r\n }\r\n }\r\n appTemplate.home = diyTemplate?.home\r\n appTemplate.user = diyTemplate?.user\r\n}\r\n\r\nexport default app\r\n"],"names":["defineStore","$platform","$router","sys","user","DiyApi"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAOK,MAAC,MAAMA,cAAAA,YAAY;AAAA,EACtB,IAAI;AAAA,EACJ,OAAO,OAAO;AAAA,IACZ,MAAM;AAAA;AAAA,MAEJ,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