update new config to can dev as web and application desktop at same time

This commit is contained in:
Kenta420 2024-01-14 22:02:03 +07:00
parent 4032baa8ab
commit edcccaaab9
10 changed files with 6831 additions and 63 deletions

View file

@ -9,15 +9,19 @@ ReactDOM.createRoot(document.getElementById('root')!).render(
</React.StrictMode>
)
// Remove Preload scripts loading
postMessage({ payload: 'removeLoading' }, '*')
console.log(import.meta.env.MODE)
// Use contextBridge
window.ipcRenderer.on('main-process-message', (_event, message) => {
console.log(message)
})
if (import.meta.env.MODE === 'electron') {
// Remove Preload scripts loading
postMessage({ payload: 'removeLoading' }, '*')
// Use deep link
window.ipcRenderer.on('deeplink', (_event, url) => {
console.log(url)
})
// Use contextBridge
window.ipcRenderer.on('main-process-message', (_event, message) => {
console.log(message)
})
// Use deep link
window.ipcRenderer.on('deeplink', (_event, url) => {
console.log(url)
})
}

View file

@ -7,7 +7,7 @@ const Home: React.FC = () => {
const loginWithGoogle = () => {
// if is web mode then use window.open
// if is electron mode then use ipcRenderer.send to use deep link method
if (import.meta.env.TAOBIN_RECIPE_MANAGER_MODE === 'web') {
if (import.meta.env.MODE === 'web') {
// open new window and listen to message from window.opener
const newWindow = window.open(
import.meta.env.TAOBIN_RECIPE_MANAGER_SERVER_URL,
@ -31,7 +31,7 @@ const Home: React.FC = () => {
return (
<div>
<h1>This is Home Page!!!</h1>
<h1>This is Home Page!!!!!!!</h1>
<button
onClick={loginWithGoogle}
className="bg-white px-4 py-2 border flex gap-2 border-slate-200 rounded-lg text-slate-700 hover:border-slate-400 hover:text-slate-900 hover:shadow transition duration-150"
@ -40,7 +40,7 @@ const Home: React.FC = () => {
className="w-6 h-6"
src={googleLogo}
alt="google logo"
loading="lazy"
loading="eager"
/>
<span>Login with @forth.co.th Google account</span>
</button>