Former-commit-id: 068a0d9a11392aa04d68d5c7441402bb35e09625
TangShanKaiPing
wanggang 5 years ago
parent be75b1f58a
commit fac3fe100e

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0" package="com.companyname.xamarinapp">
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="28" />
<application android:label="XamarinApp.Android"></application>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
</manifest>
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0" package="com.nbaxp.iot" android:installLocation="auto">
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="28" />
<application android:label="XamarinApp.Android"></application>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
</manifest>

@ -2,37 +2,37 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>UIDeviceFamily</key>
<array>
<integer>1</integer>
<integer>2</integer>
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>MinimumOSVersion</key>
<string>8.0</string>
<key>CFBundleDisplayName</key>
<string>XamarinApp</string>
<key>CFBundleIdentifier</key>
<string>com.companyname.XamarinApp</string>
<key>CFBundleVersion</key>
<string>1.0</string>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>CFBundleName</key>
<string>XamarinApp</string>
<key>XSAppIconAssets</key>
<string>Assets.xcassets/AppIcon.appiconset</string>
<key>UIDeviceFamily</key>
<array>
<integer>1</integer>
<integer>2</integer>
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>MinimumOSVersion</key>
<string>8.0</string>
<key>CFBundleDisplayName</key>
<string>XamarinApp</string>
<key>CFBundleIdentifier</key>
<string>com.nbaxp.iot</string>
<key>CFBundleVersion</key>
<string>1.0</string>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>CFBundleName</key>
<string>XamarinApp</string>
<key>XSAppIconAssets</key>
<string>Assets.xcassets/AppIcon.appiconset</string>
</dict>
</plist>

@ -0,0 +1,23 @@
using System.Runtime.InteropServices;
using Xamarin.Essentials;
using Xamarin.Forms;
using Xamarin.Forms.Platform.iOS;
using XamarinApp.iOS;
[assembly: ExportRenderer(typeof(WebView), typeof(CustomWebViewRenderer))]
namespace XamarinApp.iOS
{
public class CustomWebViewRenderer : WkWebViewRenderer
{
protected override void OnElementChanged(VisualElementChangedEventArgs e)
{
base.OnElementChanged(e);
if (e.NewElement != null)
{
CustomUserAgent = $"{DeviceInfo.Manufacturer}~{DeviceInfo.Model}~{Device.RuntimePlatform}~{(Device.Idiom == TargetIdiom.Tablet ? "ipad" : "iphone")}";
}
}
}
}

@ -62,9 +62,13 @@
<CodesignKey>iPhone Developer</CodesignKey>
<CodesignEntitlements>Entitlements.plist</CodesignEntitlements>
</PropertyGroup>
<PropertyGroup Condition=" '$(RunConfiguration)' == 'Default' ">
<AppExtensionDebugBundleId />
</PropertyGroup>
<ItemGroup>
<Compile Include="Main.cs" />
<Compile Include="AppDelegate.cs" />
<Compile Include="WkWebViewRenderer.cs" />
<None Include="Entitlements.plist" />
<None Include="Info.plist" />
<Compile Include="Properties\AssemblyInfo.cs" />

@ -9,7 +9,12 @@ namespace XamarinApp
public App()
{
InitializeComponent();
#if DEBUG
foreach (var res in this.GetType().Assembly.GetManifestResourceNames())
{
System.Diagnostics.Debug.WriteLine($"resource:{res} ");
}
#endif
MainPage = new MainPage();
}
@ -25,4 +30,4 @@ namespace XamarinApp
{
}
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

@ -5,8 +5,13 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
x:Class="XamarinApp.MainPage">
<AbsoluteLayout BackgroundColor="LightBlue">
<AbsoluteLayout BackgroundColor="LightBlue" AnchorX="0" AnchorY="0">
<WebView x:Name="webView" AbsoluteLayout.LayoutBounds="0,0,1,1" AbsoluteLayout.LayoutFlags="All" />
<ImageButton Source="options.png" BackgroundColor="Transparent" HorizontalOptions="Center" VerticalOptions="Center" WidthRequest="48" HeightRequest="48" AbsoluteLayout.LayoutBounds="1,1,48,48" AbsoluteLayout.LayoutFlags="PositionProportional" Clicked="ImageButton_Clicked" />
<ImageButton
x:Name="option"
Clicked="ImageButton_Clicked"
BackgroundColor="Transparent"
AbsoluteLayout.LayoutBounds="1,1,48,48"
AbsoluteLayout.LayoutFlags="PositionProportional" />
</AbsoluteLayout>
</ContentPage>

@ -15,6 +15,7 @@ namespace XamarinApp
public MainPage()
{
InitializeComponent();
this.option.Source = ImageSource.FromResource($"{this.GetType().Assembly.GetName().Name}.Images.options.png");
this._configFile = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "config.txt");
if (!File.Exists(this._configFile))
{
@ -43,9 +44,13 @@ namespace XamarinApp
private async Task SetBaseUrl()
{
this._baseUrl = await DisplayPromptAsync("服务器", "配置服务器地址", "确定", "取消", this._baseUrl, keyboard: Keyboard.Url, initialValue: this._baseUrl);
File.WriteAllText(this._configFile, this._baseUrl);
this.webView.Source = this._baseUrl;
var input = await DisplayPromptAsync("服务器", "配置服务器地址", "确定", "取消", this._baseUrl, keyboard: Keyboard.Url, initialValue: this._baseUrl);
if (!string.IsNullOrEmpty(input))
{
this._baseUrl = input;
File.WriteAllText(this._configFile, this._baseUrl);
this.webView.Source = this._baseUrl;
}
}
}
}

@ -10,6 +10,14 @@
<DebugSymbols>true</DebugSymbols>
</PropertyGroup>
<ItemGroup>
<None Remove="Images\options.png" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Images\options.png" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Xamarin.Forms" Version="4.5.0.396" />
<PackageReference Include="Xamarin.Essentials" Version="1.5.1" />

@ -29,6 +29,11 @@ namespace WebMVC
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
app.Use(async (context, next) =>
{
System.Console.WriteLine(context.Request.Headers["user-agent"]);
await next.Invoke();
});
}
else
{
@ -51,11 +56,6 @@ namespace WebMVC
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}");
});
app.Use(async (context, next) =>
{
await next.Invoke();
});
}
}
}

@ -29,6 +29,11 @@ namespace WebSPA
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
app.Use(async (context, next) =>
{
System.Console.WriteLine(context.Request.Headers["user-agent"]);
await next.Invoke();
});
}
else
{
@ -50,11 +55,6 @@ namespace WebSPA
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}");
});
app.Use(async (context, next) =>
{
await next.Invoke();
});
}
}
}

@ -33,11 +33,11 @@ http {
location / {
#proxy_set_header Host $host:$server_port;
proxy_pass http://localhost:5001/;
if ($http_user_agent ~* "(mobile|android|ipad|iphone|ipod|tablet)") {
#rewrite ^(.*) http://localhost:5002$1 permanent;
proxy_pass http://localhost:5002;
break;
}
proxy_pass http://localhost:5001/;
}
location ^~ /dfs/ {

Loading…
Cancel
Save