Former-commit-id: f266ec0b3d7fe031c5ae3e148d0e04e916bbc615
TangShanKaiPing
wanggang 5 years ago
parent 7fb9fdaf86
commit be75b1f58a

Binary file not shown.

@ -1,5 +1,6 @@
using System; using System;
using System.ComponentModel; using System.ComponentModel;
using System.IO;
using System.Threading.Tasks; using System.Threading.Tasks;
using Xamarin.Forms; using Xamarin.Forms;
@ -8,11 +9,18 @@ namespace XamarinApp
[DesignTimeVisible(false)] [DesignTimeVisible(false)]
public partial class MainPage : ContentPage public partial class MainPage : ContentPage
{ {
private string _configFile;
private string _baseUrl = "http://192.168.1.8"; private string _baseUrl = "http://192.168.1.8";
public MainPage() public MainPage()
{ {
InitializeComponent(); InitializeComponent();
this._configFile = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "config.txt");
if (!File.Exists(this._configFile))
{
File.WriteAllText(this._configFile, this._baseUrl);
}
this.webView.Source = this._baseUrl;
this.Appearing += MainPage_Appearing; this.Appearing += MainPage_Appearing;
} }
@ -35,7 +43,8 @@ namespace XamarinApp
private async Task SetBaseUrl() private async Task SetBaseUrl()
{ {
this._baseUrl = await DisplayPromptAsync("服务器", "配置服务器地址", "确定", "取消", this._baseUrl ?? "http://example.com", keyboard: Keyboard.Url, initialValue: this._baseUrl); this._baseUrl = await DisplayPromptAsync("服务器", "配置服务器地址", "确定", "取消", this._baseUrl, keyboard: Keyboard.Url, initialValue: this._baseUrl);
File.WriteAllText(this._configFile, this._baseUrl);
this.webView.Source = this._baseUrl; this.webView.Source = this._baseUrl;
} }
} }

Binary file not shown.
Loading…
Cancel
Save