mirror of
https://github.com/MadeBaruna/paimon-moe.git
synced 2024-12-22 14:35:38 +01:00
Update firebase config
This commit is contained in:
parent
edc036f62f
commit
1cd1e40c77
4 changed files with 34 additions and 24 deletions
|
@ -46,23 +46,6 @@
|
|||
});
|
||||
window.localforage = localforage;
|
||||
await checkLocalSave();
|
||||
|
||||
if ('serviceWorker' in navigator && import.meta.env.PROD) {
|
||||
navigator.serviceWorker
|
||||
.register('/service-worker.js', {
|
||||
scope: 'firebase-cloud-messaging-push-scope',
|
||||
})
|
||||
.then(
|
||||
function (registration) {
|
||||
console.log('Service worker registration succeeded');
|
||||
},
|
||||
function (error) {
|
||||
console.log('Service worker registration failed:', error);
|
||||
},
|
||||
);
|
||||
} else {
|
||||
console.log('Service workers are not supported.');
|
||||
}
|
||||
});
|
||||
|
||||
$: segment = $page.url.pathname.substring(1).split('/')[0];
|
||||
|
|
|
@ -75,10 +75,8 @@ async function getToken() {
|
|||
console.log('request token');
|
||||
|
||||
try {
|
||||
const swRegistration = await navigator.serviceWorker.getRegistration('/firebase-cloud-messaging-push-scope');
|
||||
const token = await messaging.getToken({
|
||||
vapidKey: 'BA6niiIWa_QP2SXMTjS8gBtM3M7m0q0n0_ZWjECw3Z_iEFujzPG2VdAAvNFJ5btbgpEiRe2B80M4QKxRSxtmvDw',
|
||||
serviceWorkerRegistration: swRegistration,
|
||||
});
|
||||
|
||||
if (token) {
|
||||
|
|
|
@ -1,11 +1,40 @@
|
|||
import { resolve } from 'path';
|
||||
import { sveltekit } from '@sveltejs/kit/vite';
|
||||
import { build } from 'vite';
|
||||
|
||||
/** @type {import('vite').UserConfig} */
|
||||
const config = {
|
||||
plugins: [sveltekit()],
|
||||
/** @type {import('vite').Plugin} */
|
||||
const firebaseSwPlugin = {
|
||||
name: 'firebaseplugin',
|
||||
apply: 'build',
|
||||
enforce: 'post',
|
||||
buildEnd: async () => {
|
||||
const conf = {
|
||||
build: {
|
||||
sourcemap: true,
|
||||
lib: {
|
||||
entry: resolve(__dirname, 'src/firebase-messaging-sw.js'),
|
||||
formats: ['es'],
|
||||
},
|
||||
rollupOptions: {
|
||||
output: {
|
||||
entryFileNames: 'firebase-messaging-sw.js',
|
||||
},
|
||||
},
|
||||
outDir: resolve(__dirname, '.svelte-kit/output/client'),
|
||||
emptyOutDir: false,
|
||||
},
|
||||
configFile: false,
|
||||
};
|
||||
|
||||
await build(conf);
|
||||
},
|
||||
};
|
||||
|
||||
/** @type {import('vite').UserConfig} */
|
||||
const config = {
|
||||
build: {
|
||||
sourcemap: true,
|
||||
},
|
||||
plugins: [sveltekit(), firebaseSwPlugin],
|
||||
};
|
||||
|
||||
export default config;
|
||||
|
|
Loading…
Reference in a new issue