import { createApp } from 'vue'; 
 | 
  
 | 
import '@nutui/nutui-taro/dist/style.css'; 
 | 
import './app.scss'; 
 | 
  
 | 
import { setupStore } from '@/stores'; 
 | 
  
 | 
import { useSystemStore } from '@/stores/modules/system'; 
 | 
import { useUserStore } from '@/stores/modules/user'; 
 | 
import Taro from '@tarojs/taro'; 
 | 
import { VueQueryPlugin, VueQueryPluginOptions } from '@tanstack/vue-query'; 
 | 
import { myClient } from '@/constants/query'; 
 | 
import { VueLifeRechargePlugin } from '@life-payment/core-vue'; 
 | 
import { blLifeRecharge, LifeRechargeOptions } from '@/utils/blLifeRecharge'; 
 | 
import { isWeChat } from '@/utils/env'; 
 | 
  
 | 
window.uni = Taro; 
 | 
  
 | 
function updateVersions() { 
 | 
  const updateManager = Taro.getUpdateManager(); 
 | 
  updateManager.onCheckForUpdate(function (_res) { 
 | 
    // 请求完新版本信息的回调 
 | 
  }); 
 | 
  updateManager.onUpdateReady(function () { 
 | 
    Taro.showModal({ 
 | 
      title: '更新提示', 
 | 
      content: '新版本已经准备好,是否重启应用?', 
 | 
      success: function (res) { 
 | 
        if (res.confirm) { 
 | 
          // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启 
 | 
          updateManager.applyUpdate(); 
 | 
        } 
 | 
      }, 
 | 
    }); 
 | 
  }); 
 | 
  updateManager.onUpdateFailed(function () { 
 | 
    // 新的版本下载失败 
 | 
    Taro.showToast({ 
 | 
      title: '新的版本下载失败,请重新进入', 
 | 
      icon: 'none', 
 | 
      duration: 2000, 
 | 
    }); 
 | 
  }); 
 | 
} 
 | 
  
 | 
const App = createApp({ 
 | 
  // 可以使用所有的 Vue 生命周期方法 
 | 
  
 | 
  mounted() {}, 
 | 
  
 | 
  // 对应 onLaunch 
 | 
  onLaunch(options) { 
 | 
    if (options.query?.channelId) { 
 | 
      console.log('options: ', options); 
 | 
      blLifeRecharge.accountModel.setChannlesNum(options.query.channelId); 
 | 
    } 
 | 
    // 如果是收藏进入 
 | 
    if (options.query.collect) { 
 | 
      Taro.reLaunch({ 
 | 
        url: '/pages/index/index', 
 | 
      }); 
 | 
      return; 
 | 
    } 
 | 
    // 将启动参数放进到全局去 
 | 
    const system = useSystemStore(); 
 | 
    system.init(options); 
 | 
    system.setInfo(Taro.getSystemInfoSync()); 
 | 
  }, 
 | 
  
 | 
  // 对应 onShow 
 | 
  onShow(options) { 
 | 
    if (isWeChat) { 
 | 
      updateVersions(); 
 | 
    } 
 | 
  }, 
 | 
  
 | 
  // 对应 onHide 
 | 
  onHide() {}, 
 | 
  // 入口组件不需要实现 render 方法,即使实现了也会被 taro 所覆盖 
 | 
}); 
 | 
  
 | 
setupStore(App); 
 | 
  
 | 
import { IconFont } from '@nutui/icons-vue-taro'; 
 | 
  
 | 
App.component('IconFont', IconFont); // 全局组件 
 | 
  
 | 
const vueQueryPluginOptions: VueQueryPluginOptions = { 
 | 
  queryClient: myClient, 
 | 
}; 
 | 
  
 | 
App.use(VueQueryPlugin, vueQueryPluginOptions); 
 | 
  
 | 
App.use(VueLifeRechargePlugin, { 
 | 
  blLifeRecharge, 
 | 
  // options: LifeRechargeOptions, 
 | 
}); 
 | 
  
 | 
export default App; 
 |