mirror of
				https://github.com/TriliumNext/Notes.git
				synced 2025-10-31 13:01:31 +08:00 
			
		
		
		
	entrypoint: add missing login entry point and port to TS
This commit is contained in:
		
							parent
							
								
									f6d9b42911
								
							
						
					
					
						commit
						dde24785b8
					
				
							
								
								
									
										32
									
								
								src/public/app/login.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										32
									
								
								src/public/app/login.ts
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,32 @@ | |||||||
|  | import "../stylesheets/bootstrap.scss"; | ||||||
|  | 
 | ||||||
|  | // @ts-ignore - module = undefined
 | ||||||
|  | // Required for correct loading of scripts in Electron
 | ||||||
|  | if (typeof module === 'object') {window.module = module; module = undefined;} | ||||||
|  | 
 | ||||||
|  | const device = getDeviceType() | ||||||
|  | console.log("Setting device cookie to:", device); | ||||||
|  | setCookie("trilium-device", device); | ||||||
|  | 
 | ||||||
|  | function setCookie(name: string, value?: string) { | ||||||
|  |     const date = new Date(Date.now() + 10 * 365 * 24 * 60 * 60 * 1000); | ||||||
|  |     const expires = "; expires=" + date.toUTCString(); | ||||||
|  | 
 | ||||||
|  |     document.cookie = name + "=" + (value || "")  + expires + "; path=/"; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | function getDeviceType() { | ||||||
|  |     if (window.location.search === '?desktop') return "desktop"; | ||||||
|  |     if (window.location.search === '?mobile') return "mobile"; | ||||||
|  |     return isMobile() ? "mobile" : "desktop"; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | // https://stackoverflow.com/a/73731646/944162
 | ||||||
|  | function isMobile() { | ||||||
|  |     const mQ = matchMedia?.('(pointer:coarse)'); | ||||||
|  |     if (mQ?.media === '(pointer:coarse)') return !!mQ.matches; | ||||||
|  | 
 | ||||||
|  |     if ('orientation' in window) return true; | ||||||
|  |     const userAgentsRegEx = /\b(Android|iPhone|iPad|iPod|Windows Phone|BlackBerry|webOS|IEMobile)\b/i | ||||||
|  |     return userAgentsRegEx.test(navigator.userAgent) | ||||||
|  | } | ||||||
| @ -46,36 +46,6 @@ | |||||||
| </div> | </div> | ||||||
| <script src="<%= appPath %>/login.js" crossorigin type="module"></script> | <script src="<%= appPath %>/login.js" crossorigin type="module"></script> | ||||||
| 
 | 
 | ||||||
| <script> |  | ||||||
|     // Required for correct loading of scripts in Electron |  | ||||||
|     if (typeof module === 'object') {window.module = module; module = undefined;} |  | ||||||
| 
 | 
 | ||||||
|     const device = getDeviceType() |  | ||||||
|     console.log("Setting device cookie to:", device); |  | ||||||
|     setCookie("trilium-device", device); |  | ||||||
| 
 |  | ||||||
|     function setCookie(name, value) { |  | ||||||
|         const date = new Date(Date.now() + 10 * 365 * 24 * 60 * 60 * 1000); |  | ||||||
|         const expires = "; expires=" + date.toUTCString(); |  | ||||||
| 
 |  | ||||||
|         document.cookie = name + "=" + (value || "")  + expires + "; path=/"; |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     function getDeviceType() { |  | ||||||
|         if (window.location.search === '?desktop') return "desktop"; |  | ||||||
|         if (window.location.search === '?mobile') return "mobile"; |  | ||||||
|         return isMobile() ? "mobile" : "desktop"; |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     // https://stackoverflow.com/a/73731646/944162 |  | ||||||
|     function isMobile() { |  | ||||||
|         const mQ = matchMedia?.('(pointer:coarse)'); |  | ||||||
|         if (mQ?.media === '(pointer:coarse)') return !!mQ.matches; |  | ||||||
| 
 |  | ||||||
|         if ('orientation' in window) return true; |  | ||||||
|         const userAgentsRegEx = /\b(Android|iPhone|iPad|iPod|Windows Phone|BlackBerry|webOS|IEMobile)\b/i |  | ||||||
|         return userAgentsRegEx.test(navigator.userAgent) |  | ||||||
|     } |  | ||||||
| </script> |  | ||||||
| </body> | </body> | ||||||
| </html> | </html> | ||||||
|  | |||||||
| @ -10,6 +10,7 @@ const config: Configuration = { | |||||||
|     mode: "production", |     mode: "production", | ||||||
|     entry: { |     entry: { | ||||||
|         setup: "./src/public/app/setup.js", |         setup: "./src/public/app/setup.js", | ||||||
|  |         login: "./src/public/app/login.js", | ||||||
|         mobile: "./src/public/app/mobile.js", |         mobile: "./src/public/app/mobile.js", | ||||||
|         desktop: "./src/public/app/desktop.js", |         desktop: "./src/public/app/desktop.js", | ||||||
|         share: "./src/public/app/share.js", |         share: "./src/public/app/share.js", | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Panagiotis Papadopoulos
						Panagiotis Papadopoulos