Skip to content

Commit 4647236

Browse files
committed
Demo4.4.0
1 parent 99456d4 commit 4647236

File tree

716 files changed

+92832
-734
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

716 files changed

+92832
-734
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,5 +349,4 @@ healthchecksdb
349349
MigrationBackup/
350350

351351
# 后添加
352-
Doc/
353352
gitconfig.txt
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#region 文件描述
2+
/******************************************************************************
3+
* 创建: Daoting
4+
* 摘要:
5+
* 日志: 2017-12-06 创建
6+
******************************************************************************/
7+
#endregion
8+
9+
#region 引用命名
10+
using Android.App;
11+
using Android.Content;
12+
using Android.Content.PM;
13+
using Android.Runtime;
14+
using Android.Views;
15+
using Dt.Base;
16+
using System;
17+
#endregion
18+
19+
namespace Dt.Demo
20+
{
21+
// 接收分享的内容
22+
[IntentFilter(
23+
new[] { Intent.ActionSend },
24+
Categories = new[] { Intent.CategoryDefault },
25+
DataMimeTypes = new[] { "image/*", "text/plain", "video/*", "audio/*", "*/*" })]
26+
27+
[Activity(
28+
MainLauncher = true,
29+
// 横竖屏模式改变、屏幕大小变化、键盘可用性改变时不重新启动activity
30+
ConfigurationChanges = ConfigChanges.Orientation | ConfigChanges.ScreenSize | ConfigChanges.KeyboardHidden,
31+
// 控制软键盘
32+
WindowSoftInputMode = SoftInput.AdjustPan | SoftInput.StateHidden)]
33+
public class MainActivity : BaseAppActivity
34+
{
35+
// styles.xml 中已设置不占用顶部状态栏和底部导航栏,windowTranslucentStatus windowTranslucentNavigation
36+
}
37+
38+
[Application(LargeHeap = true, HardwareAccelerated = true)]
39+
public class MainApplication : Microsoft.UI.Xaml.NativeApplication
40+
{
41+
public MainApplication(IntPtr javaReference, JniHandleOwnership transfer)
42+
: base(() => new App(), javaReference, transfer)
43+
{
44+
}
45+
}
46+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<resources>
3+
<style name="AppTheme" parent="Theme.MaterialComponents.Light">
4+
<!-- This removes the ActionBar -->
5+
<item name="android:windowFullscreen">false</item>
6+
<item name="windowActionBar">false</item>
7+
<item name="android:windowActionBar">false</item>
8+
<item name="windowNoTitle">true</item>
9+
<item name="android:windowNoTitle">true</item>
10+
11+
<!-- 适用Android5以上,应用不占用顶部状态栏和底部导航栏, 并设置状态栏透明 -->
12+
<!-- 状态栏显示的是android:windowBackground图片的颜色 -->
13+
<item name="android:windowTranslucentStatus">false</item>
14+
<item name="android:windowTranslucentNavigation">false</item>
15+
<item name="android:statusBarColor">#00FFFFFF</item>
16+
17+
<!-- uno_splash_color and uno_splash_image are generated by Uno.Resizetizer -->
18+
<!-- This property is used for the splash screen -->
19+
<item name="android:windowSplashScreenBackground">@color/uno_splash_color</item>
20+
<item name="android:windowBackground">@drawable/uno_splash_image</item>
21+
<item name="android:windowSplashScreenAnimatedIcon">@drawable/uno_splash_image</item>
22+
</style>
23+
<!-- uno使用 -->
24+
<style name="Theme.AppCompat.Translucent">
25+
<item name="android:windowIsTranslucent">true</item>
26+
<item name="android:windowAnimationStyle">@android:style/Animation</item>
27+
</style>
28+
</resources>
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<paths xmlns:android="http://schemas.android.com/apk/res/android">
3+
<files-path name="docs" path=".doc" />
4+
</paths>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# See this for more details: http://developer.xamarin.com/guides/android/advanced_topics/garbage_collection/
2+
MONO_GC_PARAMS=bridge-implementation=tarjan,nursery-size=32m,soft-heap-limit=256m

Demo/Common/Gtk/Program.cs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using System;
2+
using GLib;
3+
using Uno.UI.Runtime.Skia.Gtk;
4+
5+
namespace Dt.Demo
6+
{
7+
public class Program
8+
{
9+
public static void Main(string[] args)
10+
{
11+
ExceptionManager.UnhandledException += delegate (UnhandledExceptionArgs expArgs)
12+
{
13+
Console.WriteLine("GLIB UNHANDLED EXCEPTION" + expArgs.ExceptionObject.ToString());
14+
expArgs.ExitApplication = true;
15+
};
16+
17+
var host = new GtkHost(() => new App());
18+
host.Run();
19+
}
20+
}
21+
}

Demo/Common/Images/Logo.png

551 Bytes

Demo/Common/Note.txt

Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
/***************************************************************************************************/
2+
》 项目导入 Shared.props 定义的内容,方便支持多平台
3+
4+
》 UnoIcon:
5+
Include 背景svg
6+
ForegroundFile 前景svg
7+
ForegroundScale 前景缩放比例 0 ~ 1
8+
AndroidForegroundScale WasmForegroundScale WindowsForegroundScale IOSForegroundScale SkiaForegroundScale 覆盖ForegroundScale
9+
Color 背景色
10+
注意:win上svg路径不可使用相对路径,否则不报错不生成,app无法注册
11+
12+
》 UnoSplashScreen:
13+
Include 图片svg
14+
BaseSize 用作调整大小操作的基底的大小
15+
Color 背景色
16+
Scale 缩放比例
17+
AndroidScale IOSScale WindowsScale SkiaScale WasmScale 平台缩放比例,覆盖Scale
18+
19+
》 字体生成svg:开源 https://github.com/fontforge/fontforge/releases/ 安装,以管理员运行 run_fontforge.exe
20+
文件 > 执行脚本 SelectWorthOutputting(); foreach Export("svg"); endloop; > 选择“FF” > OK
21+
在安装目录下每个字生成一个svg文件
22+
Demo\Common\icon-svg.rar 为icon.ttf字库的svg文件
23+
24+
》 Images\*.png 文件链接方式,项目中用到的图片,作为内容生成,ms-appx:///Images/*.png
25+
26+
27+
28+
29+
30+
/*********************************************** Win ***********************************************/
31+
》 注意 Properties\PublishProfiles 下的配置文件,最初调试时因配置问题造成各种变量异常!
32+
33+
》 点击Toast自启动传参数:
34+
Package.appxmanifest 增加 desktop:Extension com:Extension 两节,见注释
35+
处理 AppNotificationManager.Default.NotificationInvoked 事件,在当前应用接收通知,否则会另外启动新应用实例!
36+
AppNotificationManager..Register 注册当前应用接收通知
37+
38+
》 发布:升级net8.0后需要先把 Directory.Build.props 和 当前项目csproj文件的 TargetFrameworks 改 TargetFramework,重启
39+
项目右键 -> 打包和发布 -> 将应用程序和应用商店关联 -> 创建应用程序包 -> 将 msix 文件上传到商店
40+
41+
42+
43+
44+
45+
/********************************************** Android **********************************************/
46+
》 项目目录说明:
47+
Android\Resources\values\styles.xml 定义样式参数
48+
Android\Resources\xml\file_paths.xml 共享路径配置
49+
\MainActivity.cs 入口
50+
51+
》 App标题定义有两处:AndroidManifest.xml AppStub.Title
52+
53+
》 生成apk:
54+
真机apk:选择 Release -> AndroidManifest.xml设置版本 -> 调整csproj文件的RuntimeIdentifier配置 -> 右键选择“发布...” -> apk文件在 bin\Release\net7.0-android\android-arm64\ 目录下
55+
虚拟机:选择 Release -> 调整csproj文件的RuntimeIdentifier为android-x64 -> Ctrl + F5 自动打包部署到虚拟机并运行
56+
也可用命令发布:
57+
dotnet publish -f:net7.0-android -c:Release
58+
59+
》 app必须引用所有用到的程序集项目,否则绑定类型使用反射方法,影响性能,uno警告提示:
60+
The Bindable attribute is missing and the type [T] is not known by the MetadataProvider. Reflection was used instead of the binding engine and generated static metadata. Add the Bindable attribute to prevent this message and performance issues.
61+
62+
63+
64+
65+
66+
/************************************************ Gtk ************************************************/
67+
》 控件样式中必须设置FontFamily,否则中文乱码
68+
69+
》 打包部署 https://mp.weixin.qq.com/s/lm5opxgR94__oFSM03vUPA
70+
71+
72+
73+
74+
75+
/************************************************ iOS ************************************************/
76+
》 项目目录说明:
77+
iOS\Assets.xcassets 图标资源,可通过控件样例的工具生成,在项目中不可见
78+
iOS\Resources 名称必须是 Resources,否则字体无法加载
79+
\Assets
80+
\Lottie *.json是lottie格式动画的json文件
81+
82+
-- 图片文件无需指定 BundleResource,生成操作默认“无”即可,会自动 BundleResource 到 Assets目录
83+
\[email protected] 启动图片,配合 LaunchScreen.storyboard 实现启动动画
84+
85+
\Fonts
86+
\icon.ttf 自定义矢量字体库,文件链接
87+
\uno-fluentui-assets.ttf uno用到的字体库,文件链接
88+
iOS\Info.plist App配置文件
89+
iOS\Entitlements.plist 需要权限列表
90+
iOS\LaunchScreen.storyboard 启动动画定义
91+
iOS目录下的资源为iOS专用
92+
\Main.cs 入口
93+
94+
》 资源文件的生成操作:BundleResource 和 Content(内容) 的区别
95+
它们的输出目录不同,参见:Dt.Shell.IOS\bin\Debug\net7.0-ios\iossimulator-x64\Dt.Shell.IOS.app
96+
BundleResource的资源文件输出目录省略 iOS\Resources 两级目录,Content的资源文件输出到完整目录
97+
如 iOS\Resources\Lottie\Dash.json 资源文件,
98+
BundleResource 时路径:ms-appx:///Lottie/Dash.json
99+
Content 时路径: ms-appx:///iOS/Resources/Lottie/Dash.json
100+
为了统一资源文件的路径,约定放在ms-appx:///Assets目录下,这就需要在iOS项目中资源文件放在iOS\Resources\Assets目录下
101+
102+
》 mac端生成后的位置:/Users/oysd/Library/Caches/Xamarin/mtbs/builds/Dt.Shell.iOS/
103+
104+
》 接收“分享”有两种情况实现,主要取决于发起“分享”的app的实现方式:
105+
1. 使用UIDocumentInterationController发起的分享,接收时只需要在Info.plist中配置CFBundleDocumentTypes,并在App.xaml.cs中重写OpenUrl,如app 文件;
106+
2. 使用UIActivityViewController发起的分享,接收时需要在独立的dll项目中实现Share Extension,iOS8.0 以后增加的方式,如 照片 邮箱;
107+
本系统只处理第一种情况!未实现“照片”中的接收分享功能
108+
109+
》 发布:选择Release + iPhone + 远程设备,生成前先确认Info.plist和iOS项目文件csproj中的版本相同,重新生成iOS项目,过程比较漫长,生成成功后使用命令发布,
110+
使用PowerShell切到iOS项目的路径下,运行:
111+
dotnet publish -f:net7.0-ios -c:Release
112+
113+
》 开发、调试、发布上架的详细过程参见《搬运工客户端手册.docx》
114+
115+
116+
117+
118+
119+
/************************************************ Wasm ***********************************************/
120+
》 AppManifest.js:自定义启动页logo、背景色、浏览器标题等
121+
122+
》 项目文件(*.csproj)中:
123+
EmbeddedResource 节点可以将js文件或css文件输出到网站 package_xxx 目录下,js文件在WasmScripts下,css文件在WasmCSS下
124+
Content 节点的内容文件输出到 package_xxx 的对应子目录下,也可以自定义目录如:<Content Include="Path\To\My\File.txt" UnoDeploy="Root" />
125+
https://platform.uno/docs/articles/external/uno.wasm.bootstrap/doc/features-additional-files.html
126+
WasmCSS WasmScripts目录名不可修改,uno用到
127+
128+
》 系统使用 RequireJS 加载模块、管理依赖关系,在WasmScripts下js文件中:
129+
define([],function(){}):第一个参数是模块依赖,如果需要依赖别的js或者css,就在第一个参数中指定,第二个是函数,当第一个参数中的所有依赖都加载成功后,然后才会该函数会被调用来定义该模块,因此该模块应该返回一个定义了本模块的object
130+
require([],function(){}):参数和define相同,只是不返回当前object
131+
132+
》 manifest.json 为PWA的清单描述
133+
LinkerConfig.xml 生成包时不参加裁剪的dll列表
134+
pwa目录是pwa用到的图片,可在 https://www.pwabuilder.com/imageGenerator 生成
135+
136+
》 Dt.BuildTools 功能:
137+
向项目添加默认字体文件、字体css、dt.js
138+
Release模式生成时处理PWA相关的后续工作
139+
140+
》 wasm不支持直连数据库,因启动时读取配置,不使用Config.json,使用Config.js
141+
UnoAppManifest.displayName 在AppManifest.js中设置
142+
DtConfig.server 在Config.js配置,AppManifest.js每次会动态生成,无法在其设置
143+
144+
》 跨域请求时boot服务和所有要访问的服务都必须为https
145+
146+
》 发布:选择Release -> 生成wasm项目 -> 生成完整的单页面静态网站:bin\Release\net7.0\dist -> 用boot服务承载静态网站(参见文档)
147+
生成时默认会为js css wasm clr格式的文件生成Brotli压缩文件(*.br),Uno的DevServer缺少自动下载同名br文件、PWA、允许跨域访问的功能
148+
启用PWA网站必须为https,且跨域请求的服务都为https

Demo/Common/Wasm/LinkerConfig.xml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<linker>
2+
<assembly fullname="Dt.Core" />
3+
<assembly fullname="Dt.Base" />
4+
<assembly fullname="Dt.Mgr" />
5+
<assembly fullname="Dt.MgrDemo" />
6+
<assembly fullname="Dt.UIDemo" />
7+
<assembly fullname="Dt.MgrDemo.Wasm" />
8+
<assembly fullname="Dt.UIDemo.Wasm" />
9+
10+
<assembly fullname="Uno.UI" />
11+
<assembly fullname="Microsoft.Extensions.Options" />
12+
<assembly fullname="System.Core">
13+
<!-- This is required by JSon.NET and any expression.Compile caller -->
14+
<type fullname="System.Linq.Expressions*" />
15+
</assembly>
16+
</linker>

Demo/Common/Wasm/Program.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+

2+
namespace Dt.Demo
3+
{
4+
public class Program
5+
{
6+
static App _app;
7+
8+
public static void Main(string[] args)
9+
{
10+
// 默认privider为 SQLite3Provider_e_sqlite3
11+
SQLitePCL.raw.SetProvider(new SQLitePCL.SQLite3Provider_sqlite3());
12+
Microsoft.UI.Xaml.Application.Start(_ => _app = new App());
13+
}
14+
}
15+
}

0 commit comments

Comments
 (0)