starter nuxt ionic tailwind firebase
1.0.0
ดูเอกสาร Nuxt 3 เพื่อเรียนรู้เพิ่มเติม
เปลี่ยน package.json สำหรับการใช้ส่วนขยายไอออนิกและสร้างแอพสำหรับอุปกรณ์มือถือ
"scripts": {
"dev": "nuxi dev",
"build": "nuxi generate",
"ionic:build": "npm run build",
"ionic:serve": "npm run dev"
},
เปลี่ยน nuxt.config.ts สำหรับการใช้ส่วนขยายไอออนิกและสร้างแอพสำหรับอุปกรณ์มือถือคุณต้องตั้งค่า ssr:false และ auth:false สำหรับ Vurefire
export default defineNuxtConfig({
modules: ["@nuxtjs/ionic", "@nuxtjs/tailwindcss", "nuxt-vuefire"],
ssr: false,
vuefire: {
auth: false,
config: {
apiKey: process.env.FIREBASE_API_KEY,
projectId: process.env.FIREBASE_PROJECT_ID,
appId: process.env.FIREBASE_APP_ID,
},
},
ionic: {
css: {
utilities: true,
},
},
});
เปลี่ยน capacitor.config.ts สำหรับการใช้ส่วนขยายไอออนิกและสร้างแอพสำหรับอุปกรณ์มือถือคุณต้องตั้งค่า webdir เป็น dist
import { CapacitorConfig } from '@capacitor/cli'
const config: CapacitorConfig = {
appId: 'io.ionic.starter',
appName: 'nuxt-ionic-playground',
webDir: 'dist',
bundledWebRuntime: false,
}
export default config
เนื่องจากปัญหา Firebase เกี่ยวกับตัวเก็บประจุฉันจึงเขียน Composable Getauth ของตัวเองที่ต้องใช้เมื่อทำงานบนอุปกรณ์
import {
indexedDBLocalPersistence,
initializeAuth,
} from "firebase/auth";
import { getApp } from "firebase/app";
export const useFbAuth = () => {
let auth;
console.log("use persistence");
auth = initializeAuth(getApp(), {
persistence: indexedDBLocalPersistence,
});
return auth;
};