|
|
|
@ -1,5 +1,6 @@
|
|
|
|
|
using System;
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using Xamarin.Forms;
|
|
|
|
|
|
|
|
|
@ -8,11 +9,18 @@ namespace XamarinApp
|
|
|
|
|
[DesignTimeVisible(false)]
|
|
|
|
|
public partial class MainPage : ContentPage
|
|
|
|
|
{
|
|
|
|
|
private string _configFile;
|
|
|
|
|
private string _baseUrl = "http://192.168.1.8";
|
|
|
|
|
|
|
|
|
|
public MainPage()
|
|
|
|
|
{
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -35,7 +43,8 @@ namespace XamarinApp
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|