|
| 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 |
0 commit comments