我正在尝试使用 Framework

编程入门 行业动态 更新时间:2024-10-11 21:20:56
本文介绍了我正在尝试使用 Framework-7 Vuejs 创建一个应用程序.即使在使用 Firebase 退出应用程序后,我也想让我的用户保持登录状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

我想添加 Firebase 的代码我的 Framework-7 Vue.js 应用程序.这样用户甚至可以在退出应用程序后保持登录状态.

I want to add Firebase's code in my Framework-7 Vue.js app. So that a user can stay logged in even arter exiting the app.

    firebase.auth().onAuthStateChanged(function(user) {
  if (user) {
    storemit(setSignedIn, true)
  } else {
    storemit(setSignedIn, false)
  }
});

我需要在我的项目的 app.js 中添加这个:

I need to add this in my app.js of my project:

// Import Vue
import { createApp } from 'vue';

// Import Framework7
import Framework7 from 'framework7/lite-bundle';

// Import Framework7-Vue Plugin
import Framework7Vue, { registerComponents } from 'framework7-vue/bundle';

// Import Framework7 Styles
import 'framework7/framework7-bundle.css';

// Import Icons and App Custom Styles
import '../css/icons.css';
import '../css/app.css';

// Import App Component
import App from '../components/app.vue';
import store from '../pages/store/store';

// Init Framework7-Vue Plugin
Framework7.use(Framework7Vue);

// Init App
const app = createApp(App);

app.use(store)

// Register Framework7 Vue components
registerComponents(app);

// Mount the app
app.mount('#app');

有人可以帮我做这件事吗?谢谢

Can someone please help me to do this. Thanks

推荐答案

我正在使用 Vuex Persisted声明 包用于此类目的.添加非常简单.试试看.使用 Vuex Persisted State,您的 Vuex 存储将存储在 localStorage 中,因此用户在退出应用程序后不会被注销.

I am using Vuex Persisted State package for such purposes. It is quite simple to add. Try it out. With Vuex Persisted State your Vuex store will be stored in localStorage so the user won't be logged out after exiting the app.

这篇关于我正在尝试使用 Framework-7 Vuejs 创建一个应用程序.即使在使用 Firebase 退出应用程序后,我也想让我的用户保持登录状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

更多推荐

[db:关键词]

本文发布于:2023-04-27 02:49:41,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1146381.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Framework

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!