1 line
6.1 KiB
Plaintext
1 line
6.1 KiB
Plaintext
|
{"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
|