app.js 357 B

123456789101112131415161718192021
  1. import { defineStore } from 'pinia'
  2. import { ref } from 'vue'
  3. export const useAppStore = defineStore('app',
  4. () => {
  5. const title = ref(import.meta.env.VITE_APP_TITLE) // 标题
  6. const setTitle = (txt) => {
  7. title.value = txt
  8. }
  9. return {
  10. title,
  11. setTitle
  12. }
  13. },
  14. {
  15. persist: true, // ref() 持久化响应
  16. }
  17. )