mirror of
				https://github.com/lxsang/antos-frontend.git
				synced 2025-10-31 02:15:47 +01:00 
			
		
		
		
	fix resource load
This commit is contained in:
		| @@ -102,32 +102,27 @@ self.OS.GUI = | ||||
|         _GUI.launch app, args | ||||
|  | ||||
|     loadApp: (app, ok, err) -> | ||||
|         path = "packages/#{app}/" | ||||
|         _API.script path + "main.js", | ||||
|             (d) -> | ||||
|         path = "os:///packages/#{app}" | ||||
|         path = _OS.setting.system.packages[app].path if _OS.setting.system.packages[app].path | ||||
|         js = path + "/main.js" | ||||
|         js.asFileHandler().read (d) -> | ||||
|                 #load css file | ||||
|                 _API.get "#{path}main.css", | ||||
|                     () -> | ||||
|                         $ '<link>', { rel: 'stylesheet', type: 'text/css', 'href': "#{path}main.css" } | ||||
|                 css =  "#{path}/main.css" | ||||
|                 css.asFileHandler().onready (d) -> | ||||
|                     $ '<link>', { rel: 'stylesheet', type: 'text/css', 'href': "#{_API.handler.get}/#{css}" } | ||||
|                         .appendTo 'head' | ||||
|                 , () -> | ||||
|                 #launch | ||||
|                 if _OS.APP[app] | ||||
|                     # load app meta data | ||||
|                     _API.get "#{path}package.json", | ||||
|                         (data) -> | ||||
|                     "#{path}/package.json".asFileHandler().read (data) -> | ||||
|                         data.path = path | ||||
|                         _OS.APP[app].meta = data | ||||
|                         ok app | ||||
|                         , (e, s) -> | ||||
|                             _courrier.osfail "Cannot read application metadata: #{app}", e, s | ||||
|                             err e, s | ||||
|                     , "json" | ||||
|                 else | ||||
|                     ok app | ||||
|             , (e, s) -> | ||||
|                 #BUG report here | ||||
|                 _courrier.osfail "Cannot load application script: #{app}", e, s | ||||
|                 console.log "bug report", e, s, path | ||||
|                 err e,s | ||||
|             , "script" | ||||
|     launch: (app, args) -> | ||||
|         if not _OS.APP[app] | ||||
|             # first load it | ||||
| @@ -147,7 +142,8 @@ self.OS.GUI = | ||||
|             iconclass: meta.iconclass || "" | ||||
|             app: app | ||||
|             onbtclick: () -> app.toggle() | ||||
|         data.icon = "packages/#{meta.app}/#{meta.icon}" if meta.icon | ||||
|         # TODO: this path is not good, need to create a blob of it | ||||
|         data.icon = "#{_API.handler.get}/#{meta.path}/#{meta.icon}" if meta.icon | ||||
|         # TODO: add default app icon class in system setting | ||||
|         # so that it can be themed | ||||
|         data.iconclass = "fa fa-cogs" if (not meta.icon) and (not meta.iconclass) | ||||
| @@ -369,9 +365,9 @@ self.OS.GUI = | ||||
|                     "CoreServices/Spotlight", | ||||
|                     "CoreServices/Calendar" | ||||
|                 ] | ||||
|                 #_GUI.launch "DummyApp" | ||||
|  | ||||
|         # startup application here | ||||
|         _courrier.observable.one "desktoploaded", () -> | ||||
|             console.log "startup app" | ||||
|             _GUI.launch "DummyApp" | ||||
|             #_GUI.launch "DummyApp" | ||||
|             #_GUI.launch "NotePad" | ||||
| @@ -1,4 +1,6 @@ | ||||
| self.OS.API.handler = | ||||
|     get: "lua-api/fs/get" | ||||
|      | ||||
|     scandir: (p, c ) -> | ||||
|         path = "lua-api/fs/scandir" | ||||
|         _API.post path, { path: p }, c, (e, s) -> | ||||
| @@ -13,11 +15,11 @@ self.OS.API.handler = | ||||
|         _API.post path, { path: p }, c, (e, s) -> | ||||
|             _courrier.osfail "Fail to get file metadata: #{p}", e, s | ||||
|  | ||||
|     readfile: (p, c) -> | ||||
|     readfile: (p, c, t) -> | ||||
|         path = "lua-api/fs/get/" | ||||
|         _API.get path + p, c, (e, s) -> | ||||
|             _courrier.osfail "Fail to read file: #{p}", e, s | ||||
|         , "text" | ||||
|         , t | ||||
|  | ||||
|     move: (s, d, c) -> | ||||
|         path = "lua-api/fs/move" | ||||
|   | ||||
| @@ -68,9 +68,9 @@ class BasicFileHandler | ||||
|             me.ready = true | ||||
|             f() | ||||
|  | ||||
|     read: (f) -> | ||||
|     read: (f, t) -> | ||||
|         me = @ | ||||
|         @onready (() -> me.action "read", null, f) | ||||
|         @onready (() -> me.action "read", t, f) | ||||
|  | ||||
|     write: (d, f) -> | ||||
|         me = @ | ||||
| @@ -136,7 +136,7 @@ class RemoteFileHandler extends self.OS.API.VFS.BasicFileHandler | ||||
|             when "read" | ||||
|                 return _API.handler.scandir @path, f if @info.type is "dir" | ||||
|                 #read the file | ||||
|                 _API.handler.readfile @path, f | ||||
|                 _API.handler.readfile @path, f, if p then p else "text" | ||||
|             when "mk" | ||||
|                 return f { error: "#{@path} is not a directory" } if @info.type is "file" | ||||
|                 _API.handler.mkdir "#{@path}/#{p}", f | ||||
|   | ||||
| @@ -4,7 +4,7 @@ jsfiles = | ||||
|  | ||||
| cssfiles = main.css | ||||
|  | ||||
| copyfiles = scheme.html package.json | ||||
| copyfiles = scheme.html package.json icon.png | ||||
|  | ||||
|  | ||||
| PKG_NAME=DummyApp | ||||
|   | ||||
							
								
								
									
										
											BIN
										
									
								
								src/packages/DummyApp/icon.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								src/packages/DummyApp/icon.png
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| After Width: | Height: | Size: 1.3 KiB | 
| @@ -0,0 +1,7 @@ | ||||
| .dummyapp-icon { | ||||
|     background-image: url("icon.png"); | ||||
|     background-color: blueviolet; | ||||
|     display: block; | ||||
|     width: 32px; | ||||
|     height: 32px; | ||||
| } | ||||
		Reference in New Issue
	
	Block a user