mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
fix env, sw, pwa
This commit is contained in:
@@ -0,0 +1 @@
|
|||||||
|
if('serviceWorker' in navigator) navigator.serviceWorker.register('/dev-sw.js?dev-sw', { scope: '/', type: 'module' })
|
||||||
@@ -15,3 +15,5 @@ contextBridge.exposeInMainWorld('defaultMediaIpfsGatewayUrl', 'http://localhost:
|
|||||||
// receive plebbit rpc auth key from main
|
// receive plebbit rpc auth key from main
|
||||||
ipcRenderer.on('plebbit-rpc-auth-key', (event, plebbitRpcAuthKey) => contextBridge.exposeInMainWorld('plebbitRpcAuthKey', plebbitRpcAuthKey));
|
ipcRenderer.on('plebbit-rpc-auth-key', (event, plebbitRpcAuthKey) => contextBridge.exposeInMainWorld('plebbitRpcAuthKey', plebbitRpcAuthKey));
|
||||||
ipcRenderer.send('get-plebbit-rpc-auth-key');
|
ipcRenderer.send('get-plebbit-rpc-auth-key');
|
||||||
|
|
||||||
|
contextBridge.exposeInMainWorld('electronApi', { isElectron: true });
|
||||||
+1
-1
@@ -127,7 +127,7 @@
|
|||||||
"appId": "plebchan.desktop",
|
"appId": "plebchan.desktop",
|
||||||
"productName": "plebchan",
|
"productName": "plebchan",
|
||||||
"beforePack": "electron/before-pack.js",
|
"beforePack": "electron/before-pack.js",
|
||||||
"afterAllArtifactBuild": "electron/after-all-artifact-build.js",
|
"afterAllArtifactBuild": "electron/after-all-artifact-build.cjs",
|
||||||
"extraResources": [
|
"extraResources": [
|
||||||
{
|
{
|
||||||
"from": "bin/${os}",
|
"from": "bin/${os}",
|
||||||
|
|||||||
@@ -228,7 +228,7 @@ const AccountSettings = () => {
|
|||||||
<button onClick={handleImportAccount}>{t('import')}</button> <button onClick={handleExportAccount}>{t('export')}</button>
|
<button onClick={handleImportAccount}>{t('import')}</button> <button onClick={handleExportAccount}>{t('export')}</button>
|
||||||
<div className={styles.warning}>
|
<div className={styles.warning}>
|
||||||
{t('stored_locally', {
|
{t('stored_locally', {
|
||||||
location: window.isElectron ? 'this desktop app' : isAndroid ? 'this mobile app' : window.location.hostname,
|
location: window.electronApi?.isElectron ? 'this desktop app' : isAndroid ? 'this mobile app' : window.location.hostname,
|
||||||
interpolation: { escapeValue: false },
|
interpolation: { escapeValue: false },
|
||||||
})}
|
})}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import { isChristmas } from '../../../lib/utils/time-utils';
|
|||||||
import Version from '../../version';
|
import Version from '../../version';
|
||||||
|
|
||||||
const commitRef = process.env.VITE_COMMIT_REF;
|
const commitRef = process.env.VITE_COMMIT_REF;
|
||||||
const isElectron = window.isElectron === true;
|
const isElectron = window.electronApi?.isElectron === true;
|
||||||
|
|
||||||
const CheckForUpdates = () => {
|
const CheckForUpdates = () => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|||||||
@@ -134,7 +134,7 @@ const PlebbitDataPathSettings = ({ plebbitDataPathRef }: SettingsProps) => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const isElectron = window.isElectron === true;
|
const isElectron = window.electronApi?.isElectron === true;
|
||||||
|
|
||||||
const PlebbitOptions = () => {
|
const PlebbitOptions = () => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|||||||
@@ -2,12 +2,11 @@ import { useTranslation } from 'react-i18next';
|
|||||||
import packageJson from '../../../package.json';
|
import packageJson from '../../../package.json';
|
||||||
|
|
||||||
const { version } = packageJson;
|
const { version } = packageJson;
|
||||||
const commitRef = process.env.VITE_COMMIT_REF;
|
const commitRef = import.meta.env.VITE_COMMIT_REF;
|
||||||
const isElectron = window.isElectron === true;
|
const isElectron = window.electronApi?.isElectron === true;
|
||||||
|
|
||||||
const Version = () => {
|
const Version = () => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<a
|
<a
|
||||||
@@ -15,7 +14,7 @@ const Version = () => {
|
|||||||
target='_blank'
|
target='_blank'
|
||||||
rel='noopener noreferrer'
|
rel='noopener noreferrer'
|
||||||
>
|
>
|
||||||
plebchan v{commitRef ? `${version}-dev (#${commitRef.slice(0, 7)})` : version}
|
v{commitRef ? `${version}#${commitRef.slice(0, 7)}` : version}
|
||||||
</a>
|
</a>
|
||||||
{isElectron && (
|
{isElectron && (
|
||||||
<>
|
<>
|
||||||
|
|||||||
Vendored
+9
@@ -0,0 +1,9 @@
|
|||||||
|
/// <reference types="vite/client" />
|
||||||
|
|
||||||
|
declare interface ImportMetaEnv {
|
||||||
|
readonly VITE_COMMIT_REF: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
declare interface ImportMeta {
|
||||||
|
readonly env: ImportMetaEnv;
|
||||||
|
}
|
||||||
Vendored
+12
@@ -4,4 +4,16 @@ declare global {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
declare global {
|
||||||
|
interface Window {
|
||||||
|
electronApi?: {
|
||||||
|
isElectron: boolean;
|
||||||
|
invoke: (channel: string, ...args: any[]) => Promise<any>;
|
||||||
|
getNotificationStatus: () => Promise<'granted' | 'denied' | 'not-determined' | 'not-supported'>;
|
||||||
|
getPlatform: () => Promise<NodeJS.Platform>;
|
||||||
|
testNotification: () => Promise<{ success: boolean; reason?: string }>;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export {};
|
export {};
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
/// <reference lib="webworker" />
|
||||||
|
/* eslint-disable no-restricted-globals */
|
||||||
|
|
||||||
|
import { clientsClaim } from 'workbox-core';
|
||||||
|
import { precacheAndRoute, cleanupOutdatedCaches } from 'workbox-precaching';
|
||||||
|
|
||||||
|
declare const self: ServiceWorkerGlobalScope;
|
||||||
|
|
||||||
|
// Precache all assets specified in the manifest
|
||||||
|
cleanupOutdatedCaches();
|
||||||
|
precacheAndRoute(self.__WB_MANIFEST);
|
||||||
|
|
||||||
|
// Standard SW lifecycle methods
|
||||||
|
self.skipWaiting();
|
||||||
|
clientsClaim();
|
||||||
@@ -36,6 +36,16 @@ export default defineConfig({
|
|||||||
}),
|
}),
|
||||||
VitePWA({
|
VitePWA({
|
||||||
registerType: 'autoUpdate',
|
registerType: 'autoUpdate',
|
||||||
|
strategies: 'injectManifest',
|
||||||
|
injectManifest: {
|
||||||
|
maximumFileSizeToCacheInBytes: 6000000,
|
||||||
|
},
|
||||||
|
srcDir: 'src',
|
||||||
|
filename: 'sw.ts',
|
||||||
|
devOptions: {
|
||||||
|
enabled: true,
|
||||||
|
type: 'module',
|
||||||
|
},
|
||||||
includeAssets: ['favicon.ico', 'robots.txt', 'apple-touch-icon.png'],
|
includeAssets: ['favicon.ico', 'robots.txt', 'apple-touch-icon.png'],
|
||||||
manifest: {
|
manifest: {
|
||||||
name: 'Seedit',
|
name: 'Seedit',
|
||||||
|
|||||||
Reference in New Issue
Block a user