forked from mbk-lab/rui_orig
				
			Updated readme
This commit is contained in:
		
							parent
							
								
									d20407cf36
								
							
						
					
					
						commit
						c968c84e91
					
				
							
								
								
									
										21
									
								
								README-ru.md
								
								
								
								
							
							
						
						
									
										21
									
								
								README-ru.md
								
								
								
								
							|  | @ -21,28 +21,33 @@ | |||
| 	} | ||||
| 
 | ||||
| 	func main() { | ||||
| 		app := rui.NewApplication("Hello world", "icon.svg", createHelloWorldSession) | ||||
| 		app.Start("localhost:8000") | ||||
| 		rui.StartApp("localhost:8000", createHelloWorldSession, rui.AppParams{ | ||||
| 			Title: "Hello world", | ||||
| 			Icon:  "icon.svg", | ||||
| 		}) | ||||
| 	} | ||||
| 
 | ||||
| В функции main создается rui приложение и запускается основной цикл. | ||||
| При создании приложения задаются 3 параметра: имя приложения, имя иконки и функция createHelloWorldSession. | ||||
| Функция createHelloWorldSession создает структуру реализующую интерфейс SessionContent: | ||||
| В функции main вызывается функция StartApp. Она создает rui приложение и запускает его основной цикл. | ||||
| Функция StartApp имеет 3 параметра: | ||||
| 1) IP адрес по которому будет доступно приложение (в нашем примере это "localhost:8000") | ||||
| 2) Фуекция создает структуру реализующую интерфейс SessionContent | ||||
| 3) Дополнительные опциональные параметры (в нашем примере это заголовок и имя файла иконки) | ||||
| 
 | ||||
| Интерфейс SessionContent объявлен как: | ||||
| 
 | ||||
| 	type SessionContent interface { | ||||
| 		CreateRootView(session rui.Session) rui.View | ||||
| 	} | ||||
| 
 | ||||
| Для каждой новой сессии создается свой экземпляр структуры. | ||||
| 
 | ||||
| Функция CreateRootView интерфейса SessionContent создает корневой элемент. | ||||
| 
 | ||||
| Когда пользователь обращается к приложению набрав в браузере адрес "localhost:8000", то создается новая сессия, | ||||
| для нее создается новый экземпляр структуры helloWorldSession и в конце вызывается функция CreateRootView. | ||||
| Функция createRootView возвращает представление строки текста, создаваемое с помощью функции NewTextView. | ||||
| 
 | ||||
| Если вы хотите чтобы приложение было видно вне вашего компьютера, то поменяйте адрес в функции Start: | ||||
| 
 | ||||
| 	app.Start(rui.GetLocalIP() + ":80") | ||||
| 	rui.StartApp(rui.GetLocalIP() + ":80", ... | ||||
| 
 | ||||
| ## Используемые типы данных | ||||
| 
 | ||||
|  |  | |||
							
								
								
									
										18
									
								
								README.md
								
								
								
								
							
							
						
						
									
										18
									
								
								README.md
								
								
								
								
							|  | @ -21,13 +21,19 @@ and the browser is used as a thin client. WebSocket is used for client-server co | |||
| 	} | ||||
| 
 | ||||
| 	func main() { | ||||
| 		app := rui.NewApplication("Hello world", "icon.svg", createHelloWorldSession) | ||||
| 		app.Start("localhost:8000") | ||||
| 		rui.StartApp("localhost:8000", createHelloWorldSession, rui.AppParams{ | ||||
| 			Title:      "Hello world", | ||||
| 			Icon:       "icon.svg", | ||||
| 		}) | ||||
| 	} | ||||
| 
 | ||||
| In the main function, a rui application is created and the main loop is started. | ||||
| When creating an application, 3 parameters are set: the name of the application, the name of the icon, and the createHelloWorldSession function. | ||||
| The createHelloWorldSession function creates a structure that implements the SessionContent interface: | ||||
| In the main function, the StartApp function is called. It creates a rui app and runs its main loop. | ||||
| The StartApp function has 3 parameters: | ||||
| 1) IP address where the application will be available (in our example it is "localhost:8000") | ||||
| 2) The function creates a structure that implements the SessionContent interface | ||||
| 3) Additional optional parameters (in our example, this is the title and the icon file name) | ||||
| 
 | ||||
| The SessionContent interface is declared as: | ||||
| 
 | ||||
| 	type SessionContent interface { | ||||
| 		CreateRootView(session rui.Session) rui.View | ||||
|  | @ -42,7 +48,7 @@ The createRootView function returns a representation of a text that is created u | |||
| 
 | ||||
| If you want the application to be visible outside your computer, then change the address in the Start function: | ||||
| 
 | ||||
| 	app.Start(rui.GetLocalIP() + ":80") | ||||
| 	rui.StartApp(rui.GetLocalIP() + ":80", ... | ||||
| 
 | ||||
| ## Used data types | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue