You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1 line
23 KiB
JavaScript
1 line
23 KiB
JavaScript
"use strict";(self.webpackChunkfurion=self.webpackChunkfurion||[]).push([[5624],{4583:(e,n,r)=>{r.r(n),r.d(n,{assets:()=>d,contentTitle:()=>c,default:()=>p,frontMatter:()=>t,metadata:()=>l,toc:()=>a});var i=r(5893),s=r(1151),o=r(4996);const t={id:"bs-to-cs",title:"34.7 \u53d1\u5e03\u684c\u9762\u7a0b\u5e8f\uff08WinForm/WPF\uff09",sidebar_label:"34.7 \u53d1\u5e03\u684c\u9762\u7a0b\u5e8f\uff08WinForm/WPF\uff09"},c=void 0,l={id:"bs-to-cs",title:"34.7 \u53d1\u5e03\u684c\u9762\u7a0b\u5e8f\uff08WinForm/WPF\uff09",description:"\u4ee5\u4e0b\u5185\u5bb9\u4ec5\u9650 Furion 4.8.7.28 + \u7248\u672c\u4f7f\u7528\u3002",source:"@site/docs/bs-to-cs.mdx",sourceDirName:".",slug:"/bs-to-cs",permalink:"/docs/bs-to-cs",draft:!1,unlisted:!1,editUrl:"https://gitee.com/dotnetchina/Furion/tree/v4/handbook/docs/bs-to-cs.mdx",tags:[],version:"current",lastUpdatedBy:"MonkSoul",lastUpdatedAt:1681178126,formattedLastUpdatedAt:"Apr 11, 2023",frontMatter:{id:"bs-to-cs",title:"34.7 \u53d1\u5e03\u684c\u9762\u7a0b\u5e8f\uff08WinForm/WPF\uff09",sidebar_label:"34.7 \u53d1\u5e03\u684c\u9762\u7a0b\u5e8f\uff08WinForm/WPF\uff09"},sidebar:"docs",previous:{title:"34.6 pm2 \u90e8\u7f72",permalink:"/docs/pm2"},next:{title:"35. \u6301\u7eed\u90e8\u7f72\u96c6\u6210",permalink:"/docs/category/devops"}},d={},a=[{value:"34.7.1 \u8fc1\u79fb\u6b65\u9aa4",id:"3471-\u8fc1\u79fb\u6b65\u9aa4",level:2},{value:"34.7.1.1 \u521b\u5efa <code>WinForm/WPF</code> \u9879\u76ee",id:"34711-\u521b\u5efa-winformwpf-\u9879\u76ee",level:3},{value:"34.7.1.2 \u521d\u59cb\u5316 <code>WinForm/WPF</code> \u914d\u7f6e",id:"34712-\u521d\u59cb\u5316-winformwpf-\u914d\u7f6e",level:3},{value:"34.7.1.3 \u6dfb\u52a0 <code>YourProject.Web.Core</code> \u5c42\u5f15\u7528",id:"34713-\u6dfb\u52a0-yourprojectwebcore-\u5c42\u5f15\u7528",level:3},{value:"34.7.1.4 \u62f7\u8d1d <code>YourProject.Web.Entry</code> \u5185\u5bb9",id:"34714-\u62f7\u8d1d-yourprojectwebentry-\u5185\u5bb9",level:3},{value:"34.7.2 \u914d\u7f6e <code>WinForm/WPF</code> \u9879\u76ee\u6587\u4ef6",id:"3472-\u914d\u7f6e-winformwpf-\u9879\u76ee\u6587\u4ef6",level:2},{value:"34.7.2.1 \u4fee\u6539 <code>Sdk</code> \u5c5e\u6027",id:"34721-\u4fee\u6539-sdk-\u5c5e\u6027",level:3},{value:"34.7.2.2 \u6dfb\u52a0 <code>MVC/Razor</code> \u652f\u6301",id:"34722-\u6dfb\u52a0-mvcrazor-\u652f\u6301",level:3},{value:"34.7.2.3 \u6dfb\u52a0 <code>wwwroot</code> \u9759\u6001\u53d1\u5e03\u914d\u7f6e",id:"34723-\u6dfb\u52a0-wwwroot-\u9759\u6001\u53d1\u5e03\u914d\u7f6e",level:3},{value:"34.7.2.4 \u5b8c\u6574\u914d\u7f6e",id:"34724-\u5b8c\u6574\u914d\u7f6e",level:3},{value:"37.7.3 \u5d4c\u5165 <code>WebView2</code>",id:"3773-\u5d4c\u5165-webview2",level:2},{value:"37.7.3.1 \u6dfb\u52a0 <code>WebView2</code> \u62d3\u5c55",id:"37731-\u6dfb\u52a0-webview2-\u62d3\u5c55",level:3},{value:"37.7.3.2 \u6dfb\u52a0 <code>WebView2</code> \u63a7\u4ef6\u5e76\u586b\u5145\u7a97\u53e3",id:"37732-\u6dfb\u52a0-webview2-\u63a7\u4ef6\u5e76\u586b\u5145\u7a97\u53e3",level:3},{value:"34.7.3.3 \u9884\u89c8\u6548\u679c",id:"34733-\u9884\u89c8\u6548\u679c",level:3},{value:"34.7.4 \u53d1\u5e03 <code>WinForm/WPF</code>",id:"3474-\u53d1\u5e03-winformwpf",level:2},{value:"34.7.4.1 \u542f\u52a8\u5c42\u6dfb\u52a0 <code>SingleFilePublish</code>",id:"34741-\u542f\u52a8\u5c42\u6dfb\u52a0-singlefilepublish",level:3},{value:"34.7.4.2 \u53d1\u5e03\u914d\u7f6e",id:"34742-\u53d1\u5e03\u914d\u7f6e",level:3},{value:"34.7.5 \u6253\u5305\u6210 <code>exe</code> \u6216 <code>msi</code>",id:"3475-\u6253\u5305\u6210-exe-\u6216-msi",level:2},{value:"34.7.6 \u53cd\u9988\u4e0e\u5efa\u8bae",id:"3476-\u53cd\u9988\u4e0e\u5efa\u8bae",level:2}];function u(e){const n={a:"a",admonition:"admonition",code:"code",h2:"h2",h3:"h3",li:"li",mdxAdmonitionTitle:"mdxAdmonitionTitle",p:"p",pre:"pre",strong:"strong",ul:"ul",...(0,s.a)(),...e.components};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(n.admonition,{title:"\u7248\u672c\u8bf4\u660e",type:"important",children:(0,i.jsxs)(n.p,{children:["\u4ee5\u4e0b\u5185\u5bb9\u4ec5\u9650 ",(0,i.jsx)(n.code,{children:"Furion 4.8.7.28 +"})," \u7248\u672c\u4f7f\u7528\u3002"]})}),"\n",(0,i.jsxs)(n.p,{children:[(0,i.jsx)(n.code,{children:"Furion"})," \u6846\u67b6\u7075\u6d3b\u7684\u67b6\u6784\u6a21\u5f0f\u4f7f\u5f97 ",(0,i.jsx)(n.code,{children:"Web"})," \u548c\u5404\u5ba2\u6237\u7aef\uff08",(0,i.jsx)(n.code,{children:"WinForm/WPF/Console"}),"\uff09 \u9879\u76ee\u4e4b\u95f4\u8fc1\u79fb\u53d8\u5f97\u975e\u5e38\u7b80\u5355\uff0c\u53ea\u9700\u8981\u6781\u5c11\u6570\u4fee\u6539\u5373\u53ef\u5b9e\u73b0\u65e0\u7f1d\u8fc1\u79fb\u3002"]}),"\n",(0,i.jsx)(n.p,{children:(0,i.jsxs)(n.strong,{children:["\u901a\u8fc7\u8fd9\u79cd\u65b9\u5f0f\u53ef\u4ee5\u5b9e\u73b0\u7c7b\u4f3c\u524d\u7aef\u7684 ",(0,i.jsx)(n.code,{children:"Electron/Tauri"})," \u6df7\u5408\u5f0f\u5f00\u53d1\u3002"]})}),"\n",(0,i.jsxs)(n.p,{children:["\u672c\u7ae0\u8282\u63d0\u4f9b\u5982\u4f55\u5c06 ",(0,i.jsx)(n.code,{children:"Web"})," \u9879\u76ee\u53d1\u5e03\uff08\u8fc1\u79fb\uff09\u5230 ",(0,i.jsx)(n.code,{children:"WinForm/WPF"})," \u4e2d\uff0c\u540c\u6837\u4e5f\u9002\u5408\u63a7\u5236\u53f0\u5e94\u7528\u7a0b\u5e8f\u3002"]}),"\n",(0,i.jsx)(n.h2,{id:"3471-\u8fc1\u79fb\u6b65\u9aa4",children:"34.7.1 \u8fc1\u79fb\u6b65\u9aa4"}),"\n",(0,i.jsxs)(n.h3,{id:"34711-\u521b\u5efa-winformwpf-\u9879\u76ee",children:["34.7.1.1 \u521b\u5efa ",(0,i.jsx)(n.code,{children:"WinForm/WPF"})," \u9879\u76ee"]}),"\n",(0,i.jsxs)(n.p,{children:["\u901a\u8fc7 ",(0,i.jsx)(n.code,{children:"Visual Studio"})," \u521b\u5efa ",(0,i.jsx)(n.code,{children:"WinForm/WPF"})," \u9879\u76ee\uff0c\u540c\u6837\u9002\u5408\u63a7\u5236\u53f0\u9879\u76ee\u3002"]}),"\n",(0,i.jsxs)(n.h3,{id:"34712-\u521d\u59cb\u5316-winformwpf-\u914d\u7f6e",children:["34.7.1.2 \u521d\u59cb\u5316 ",(0,i.jsx)(n.code,{children:"WinForm/WPF"})," \u914d\u7f6e"]}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.code,{children:"WinForm"})," \u521d\u59cb\u5316"]}),"\n"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cs",metastring:"showLineNumbers {3,8-9,12}",children:"namespace WinFormsApp1;\r\n\r\ninternal static class Program\r\n{\r\n [STAThread]\r\n private static void Main()\r\n {\r\n Serve.RunNative(RunOptions.Default); // \u9ed8\u8ba4 5000 \u7aef\u53e3\uff0c\u5982\u679c\u51fa\u73b0\u5360\u7528\uff0c\u63a8\u8350\u4f7f\u7528\u4e0b\u9762\u7684\u65b9\u5f0f\r\n // Serve.RunNative(RunOptions.Default, Serve.IdleHost.Urls); // \u968f\u673a\u7aef\u53e3\r\n\r\n ApplicationConfiguration.Initialize();\r\n Application.Run(Native.CreateInstance<Form1>());\r\n }\r\n}\n"})}),"\n",(0,i.jsxs)(n.admonition,{type:"tip",children:[(0,i.jsxs)(n.mdxAdmonitionTitle,{children:["\u5173\u4e8e ",(0,i.jsx)(n.code,{children:"Web"})," \u4e3b\u673a\u73af\u5883"]}),(0,i.jsxs)(n.p,{children:["\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u901a\u8fc7 ",(0,i.jsx)(n.code,{children:"WinForm"})," \u542f\u52a8 ",(0,i.jsx)(n.code,{children:"Web"})," \u4e3b\u673a\u73af\u5883\u603b\u662f\u4e3a ",(0,i.jsx)(n.code,{children:"Production"}),"\uff0c\u4f46\u5728\u5f00\u53d1\u9636\u6bb5\u53ef\u80fd\u4f1a\u51fa\u73b0\u914d\u7f6e\u52a0\u8f7d\u9519\u8bef\u95ee\u9898\uff0c\u8fd9\u65f6\u53ea\u9700\u8981\u6dfb\u52a0 ",(0,i.jsx)(n.code,{children:"ConfigureOptions"})," \u914d\u7f6e\u5373\u53ef\uff0c\u5982\uff1a"]}),(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cs",metastring:"showLineNumbers {2,4-5}",children:'Serve.RunNative(RunOptions.Default\r\n .ConfigureOptions(new WebApplicationOptions\r\n {\r\n // Debugger.IsAttached \u53ef\u5224\u65ad\u91ca\u653e\u4e3a Debug \u6a21\u5f0f\r\n EnvironmentName = Debugger.IsAttached ? "Development" : default\r\n }));\n'})})]}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.code,{children:"WPF"})," \u521d\u59cb\u5316"]}),"\n"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cs",metastring:"showLineNumbers {5,9-10,13-17}",children:"using System.Windows;\r\n\r\nnamespace WpfApp1;\r\n\r\npublic partial class App : Application\r\n{\r\n public App()\r\n {\r\n Serve.RunNative(RunOptions.Default); // \u9ed8\u8ba4 5000 \u7aef\u53e3\uff0c\u5982\u679c\u51fa\u73b0\u5360\u7528\uff0c\u63a8\u8350\u4f7f\u7528\u4e0b\u9762\u7684\u65b9\u5f0f\r\n // Serve.RunNative(RunOptions.Default, Serve.IdleHost.Urls); // \u968f\u673a\u7aef\u53e3\r\n }\r\n\r\n protected override void OnStartup(StartupEventArgs e)\r\n {\r\n Native.CreateInstance<MainWindow>().Show();\r\n base.OnStartup(e);\r\n }\r\n}\n"})}),"\n",(0,i.jsxs)(n.admonition,{type:"tip",children:[(0,i.jsxs)(n.mdxAdmonitionTitle,{children:["\u5173\u4e8e ",(0,i.jsx)(n.code,{children:"Web"})," \u4e3b\u673a\u73af\u5883"]}),(0,i.jsxs)(n.p,{children:["\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u901a\u8fc7 ",(0,i.jsx)(n.code,{children:"WPF"})," \u542f\u52a8 ",(0,i.jsx)(n.code,{children:"Web"})," \u4e3b\u673a\u73af\u5883\u603b\u662f\u4e3a ",(0,i.jsx)(n.code,{children:"Production"}),"\uff0c\u4f46\u5728\u5f00\u53d1\u9636\u6bb5\u53ef\u80fd\u4f1a\u51fa\u73b0\u914d\u7f6e\u52a0\u8f7d\u9519\u8bef\u95ee\u9898\uff0c\u8fd9\u65f6\u53ea\u9700\u8981\u6dfb\u52a0 ",(0,i.jsx)(n.code,{children:"ConfigureOptions"})," \u914d\u7f6e\u5373\u53ef\uff0c\u5982\uff1a"]}),(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cs",metastring:"showLineNumbers {2,4-5}",children:'Serve.RunNative(RunOptions.Default\r\n .ConfigureOptions(new WebApplicationOptions\r\n {\r\n // Debugger.IsAttached \u53ef\u5224\u65ad\u91ca\u653e\u4e3a Debug \u6a21\u5f0f\r\n EnvironmentName = Debugger.IsAttached ? "Development" : default\r\n }));\n'})})]}),"\n",(0,i.jsxs)(n.h3,{id:"34713-\u6dfb\u52a0-yourprojectwebcore-\u5c42\u5f15\u7528",children:["34.7.1.3 \u6dfb\u52a0 ",(0,i.jsx)(n.code,{children:"YourProject.Web.Core"})," \u5c42\u5f15\u7528"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-xml",metastring:"showLineNumbers {2}",children:'<ItemGroup>\r\n <ProjectReference Include="..\\Your.Web.Core\\Furion.Web.Core.csproj" />\r\n</ItemGroup>\n'})}),"\n",(0,i.jsxs)(n.h3,{id:"34714-\u62f7\u8d1d-yourprojectwebentry-\u5185\u5bb9",children:["34.7.1.4 \u62f7\u8d1d ",(0,i.jsx)(n.code,{children:"YourProject.Web.Entry"})," \u5185\u5bb9"]}),"\n",(0,i.jsxs)(n.p,{children:["\u5982\u679c\u6709 ",(0,i.jsx)(n.code,{children:"YourProject.Web.Entry"})," \u542f\u52a8\u5c42\u5305\u542b ",(0,i.jsx)(n.code,{children:"*.json"})," \u6587\u4ef6\u3001",(0,i.jsx)(n.code,{children:"Controllers"}),"\u3001",(0,i.jsx)(n.code,{children:"Views"})," \u3001",(0,i.jsx)(n.code,{children:"wwwroot"})," \u76ee\u5f55\u5219\u62f7\u8d1d\u5230 ",(0,i.jsx)(n.code,{children:"WinForm/WPF"})," \u4e2d"]}),"\n",(0,i.jsx)("img",{src:(0,o.Z)("img/n1.png")}),"\n",(0,i.jsxs)(n.h2,{id:"3472-\u914d\u7f6e-winformwpf-\u9879\u76ee\u6587\u4ef6",children:["34.7.2 \u914d\u7f6e ",(0,i.jsx)(n.code,{children:"WinForm/WPF"})," \u9879\u76ee\u6587\u4ef6"]}),"\n",(0,i.jsxs)(n.p,{children:["\u53cc\u51fb ",(0,i.jsx)(n.code,{children:"WinForm/WPF"})," \u9879\u76ee\u8fdb\u5165 ",(0,i.jsx)(n.code,{children:".csproj"})," \u6587\u4ef6\u7f16\u8f91\u3002"]}),"\n",(0,i.jsxs)(n.h3,{id:"34721-\u4fee\u6539-sdk-\u5c5e\u6027",children:["34.7.2.1 \u4fee\u6539 ",(0,i.jsx)(n.code,{children:"Sdk"})," \u5c5e\u6027"]}),"\n",(0,i.jsxs)(n.p,{children:["\u5c06 ",(0,i.jsx)(n.code,{children:'Sdk="Microsoft.NET.Sdk"'})," \u4fee\u6539\u4e3a ",(0,i.jsx)(n.code,{children:'Sdk="Microsoft.NET.Sdk.Razor"'})]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-xml",metastring:"showLineNumbers",children:'<Project Sdk="Microsoft.NET.Sdk.Razor">\n'})}),"\n",(0,i.jsxs)(n.h3,{id:"34722-\u6dfb\u52a0-mvcrazor-\u652f\u6301",children:["34.7.2.2 \u6dfb\u52a0 ",(0,i.jsx)(n.code,{children:"MVC/Razor"})," \u652f\u6301"]}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsx)(n.li,{children:(0,i.jsx)(n.code,{children:"WinForm"})}),"\n"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-xml",metastring:"showLineNumbers {1,9-11}",children:'<Project Sdk="Microsoft.NET.Sdk.Razor">\r\n\r\n\t<PropertyGroup>\r\n\t\t<OutputType>WinExe</OutputType>\r\n\t\t<TargetFramework>net7.0-windows</TargetFramework>\r\n\t\t<Nullable>enable</Nullable>\r\n\t\t<UseWindowsForms>true</UseWindowsForms>\r\n\t\t<ImplicitUsings>enable</ImplicitUsings>\r\n\t\t<SatelliteResourceLanguages>en-US</SatelliteResourceLanguages>\r\n\t\t<PublishReadyToRunComposite>true</PublishReadyToRunComposite>\r\n\t\t<AddRazorSupportForMvc>true</AddRazorSupportForMvc>\r\n\t</PropertyGroup>\r\n\r\n</Project>\n'})}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsx)(n.li,{children:(0,i.jsx)(n.code,{children:"WPF"})}),"\n"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-xml",metastring:"showLineNumbers {1,9-11}",children:'<Project Sdk="Microsoft.NET.Sdk.Razor">\r\n\r\n\t<PropertyGroup>\r\n\t\t<OutputType>WinExe</OutputType>\r\n\t\t<TargetFramework>net7.0-windows</TargetFramework>\r\n\t\t<Nullable>enable</Nullable>\r\n\t\t<ImplicitUsings>enable</ImplicitUsings>\r\n\t\t<UseWPF>true</UseWPF>\r\n\t\t<SatelliteResourceLanguages>en-US</SatelliteResourceLanguages>\r\n\t\t<PublishReadyToRunComposite>true</PublishReadyToRunComposite>\r\n\t\t<AddRazorSupportForMvc>true</AddRazorSupportForMvc>\r\n\t</PropertyGroup>\r\n\r\n</Project>\r\n\n'})}),"\n",(0,i.jsxs)(n.h3,{id:"34723-\u6dfb\u52a0-wwwroot-\u9759\u6001\u53d1\u5e03\u914d\u7f6e",children:["34.7.2.3 \u6dfb\u52a0 ",(0,i.jsx)(n.code,{children:"wwwroot"})," \u9759\u6001\u53d1\u5e03\u914d\u7f6e"]}),"\n",(0,i.jsxs)(n.p,{children:["\u5982\u679c ",(0,i.jsx)(n.code,{children:"YourProject.Web.Entry"})," \u5305\u542b ",(0,i.jsx)(n.code,{children:"wwwroot"})," \u76ee\u5f55\uff0c\u5219\u6dfb\u52a0\u4ee5\u4e0b\u914d\u7f6e\uff0c\u5426\u5219\u8df3\u8fc7\u3002"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-xml",metastring:"showLineNumbers",children:'<ItemGroup>\r\n\t<Content Update="wwwroot\\**\\*">\r\n\t\t<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>\r\n\t</Content>\r\n</ItemGroup>\n'})}),"\n",(0,i.jsx)(n.h3,{id:"34724-\u5b8c\u6574\u914d\u7f6e",children:"34.7.2.4 \u5b8c\u6574\u914d\u7f6e"}),"\n",(0,i.jsx)(n.p,{children:"\u5b8c\u6574\u7684\u914d\u7f6e\u5927\u6982\u5982\u4e0b\uff1a"}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsx)(n.li,{children:(0,i.jsx)(n.code,{children:"WinForm"})}),"\n"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-xml",metastring:"showLineNumbers {1,9-11,14-18,20-22}",children:'<Project Sdk="Microsoft.NET.Sdk.Razor">\r\n\r\n\t<PropertyGroup>\r\n\t\t<OutputType>WinExe</OutputType>\r\n\t\t<TargetFramework>net7.0-windows</TargetFramework>\r\n\t\t<Nullable>enable</Nullable>\r\n\t\t<UseWindowsForms>true</UseWindowsForms>\r\n\t\t<ImplicitUsings>enable</ImplicitUsings>\r\n\t\t<SatelliteResourceLanguages>en-US</SatelliteResourceLanguages>\r\n\t\t<PublishReadyToRunComposite>true</PublishReadyToRunComposite>\r\n\t\t<AddRazorSupportForMvc>true</AddRazorSupportForMvc>\r\n\t</PropertyGroup>\r\n\r\n\t<ItemGroup>\r\n\t\t<Content Update="wwwroot\\**\\*">\r\n\t\t\t<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>\r\n\t\t</Content>\r\n\t</ItemGroup>\r\n\r\n\t<ItemGroup>\r\n\t\t<ProjectReference Include="..\\Furion.Web.Core\\Furion.Web.Core.csproj" />\r\n\t</ItemGroup>\r\n\r\n</Project>\n'})}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsx)(n.li,{children:(0,i.jsx)(n.code,{children:"WPF"})}),"\n"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-xml",metastring:"showLineNumbers {1,9-11,14-18,20-22}",children:'<Project Sdk="Microsoft.NET.Sdk.Razor">\r\n\r\n <PropertyGroup>\r\n <OutputType>WinExe</OutputType>\r\n <TargetFramework>net7.0-windows</TargetFramework>\r\n <Nullable>enable</Nullable>\r\n <ImplicitUsings>enable</ImplicitUsings>\r\n <UseWPF>true</UseWPF>\r\n <SatelliteResourceLanguages>en-US</SatelliteResourceLanguages>\r\n\t\t<PublishReadyToRunComposite>true</PublishReadyToRunComposite>\r\n <AddRazorSupportForMvc>true</AddRazorSupportForMvc>\r\n </PropertyGroup>\r\n\r\n\t<ItemGroup>\r\n\t\t<Content Update="wwwroot\\**\\*">\r\n\t\t\t<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>\r\n\t\t</Content>\r\n\t</ItemGroup>\r\n\r\n\t<ItemGroup>\r\n\t\t<ProjectReference Include="..\\Furion.Web.Core\\Furion.Web.Core.csproj" />\r\n\t</ItemGroup>\r\n\r\n</Project>\r\n\n'})}),"\n",(0,i.jsxs)(n.h2,{id:"3773-\u5d4c\u5165-webview2",children:["37.7.3 \u5d4c\u5165 ",(0,i.jsx)(n.code,{children:"WebView2"})]}),"\n",(0,i.jsxs)(n.p,{children:["\u6211\u4eec\u53ef\u4ee5\u5728 ",(0,i.jsx)(n.code,{children:"WinForm/WinForm"})," \u5c42\u6dfb\u52a0 ",(0,i.jsx)(n.code,{children:"Microsoft.Web.WebView2"})," \u5305\uff0c\u7136\u540e\u5728\u7a97\u53e3\u4e2d\u6dfb\u52a0 ",(0,i.jsx)(n.code,{children:"WebView2"})," \u7ec4\u4ef6\uff0c\u5b9e\u73b0\u7c7b\u4f3c\u524d\u7aef ",(0,i.jsx)(n.code,{children:"Electron.js"})," \u6df7\u5408\u5f00\u53d1\u3002"]}),"\n",(0,i.jsxs)(n.h3,{id:"37731-\u6dfb\u52a0-webview2-\u62d3\u5c55",children:["37.7.3.1 \u6dfb\u52a0 ",(0,i.jsx)(n.code,{children:"WebView2"})," \u62d3\u5c55"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-bash",metastring:"showLineNumbers",children:"dotnet add package Microsoft.Web.WebView2\n"})}),"\n",(0,i.jsx)(n.admonition,{title:"\u7279\u522b\u6ce8\u610f",type:"caution",children:(0,i.jsx)(n.p,{children:(0,i.jsxs)(n.strong,{children:[(0,i.jsx)(n.code,{children:"Microsoft.Web.WebView2 v1.0.1722.32"})," \u7248\u672c\u5b58\u5728\u5f88\u4e25\u91cd\u95ee\u9898\uff08\u5fae\u8f6f\u9519\u8bef\u66f4\u65b0\uff09\uff0c\u6240\u4ee5\u907f\u514d\u5b89\u88c5\u8be5\u7248\u672c\u3002"]})})}),"\n",(0,i.jsxs)(n.h3,{id:"37732-\u6dfb\u52a0-webview2-\u63a7\u4ef6\u5e76\u586b\u5145\u7a97\u53e3",children:["37.7.3.2 \u6dfb\u52a0 ",(0,i.jsx)(n.code,{children:"WebView2"})," \u63a7\u4ef6\u5e76\u586b\u5145\u7a97\u53e3"]}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsx)(n.li,{children:(0,i.jsx)(n.code,{children:"WinForm"})}),"\n"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cs",metastring:"showLineNumbers {8,12-13}",children:"using Microsoft.AspNetCore.Hosting.Server;\r\nusing Microsoft.Extensions.Hosting;\r\n\r\nnamespace WinFormsApp1;\r\n\r\npublic partial class Form1 : Form\r\n{\r\n public Form1(IServer server)\t// \u6ce8\u5165 IServer \u670d\u52a1\uff0c\u83b7\u53d6 Web \u542f\u52a8\u5730\u5740/\u7aef\u53e3\r\n {\r\n InitializeComponent();\r\n\r\n webview.Dock = DockStyle.Fill;\r\n webview.Source = new Uri(server.GetServerAddress());\r\n }\r\n}\n"})}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsx)(n.li,{children:(0,i.jsx)(n.code,{children:"WPF"})}),"\n"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-xml",children:'<Wpf:WebView2 Name="webview" />\n'})}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cs",metastring:"showLineNumbers {9,12}",children:"using Microsoft.AspNetCore.Hosting.Server;\r\nusing Microsoft.Extensions.Hosting;\r\nusing System.Windows;\r\n\r\nnamespace WpfApp1;\r\n\r\npublic partial class MainWindow : Window\r\n{\r\n public MainWindow(IServer server) // \u6ce8\u5165 IServer \u670d\u52a1\uff0c\u83b7\u53d6 Web \u542f\u52a8\u5730\u5740/\u7aef\u53e3\r\n {\r\n InitializeComponent();\r\n webview.Source = new Uri(server.GetServerAddress());\r\n }\r\n}\n"})}),"\n",(0,i.jsx)(n.h3,{id:"34733-\u9884\u89c8\u6548\u679c",children:"34.7.3.3 \u9884\u89c8\u6548\u679c"}),"\n",(0,i.jsx)("img",{src:(0,o.Z)("img/n4.png")}),"\n",(0,i.jsx)("img",{src:(0,o.Z)("img/n2.png")}),"\n",(0,i.jsx)("br",{}),"\n",(0,i.jsx)("br",{}),"\n",(0,i.jsx)(n.p,{children:"\u76f8\u5173\u6280\u672f\u6587\u6863\uff1a"}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsx)(n.li,{children:(0,i.jsx)(n.a,{href:"https://learn.microsoft.com/zh-cn/microsoft-edge/webview2/get-started/winforms",children:"https://learn.microsoft.com/zh-cn/microsoft-edge/webview2/get-started/winforms"})}),"\n",(0,i.jsx)(n.li,{children:(0,i.jsx)(n.a,{href:"https://learn.microsoft.com/zh-cn/microsoft-edge/webview2/get-started/wpf",children:"https://learn.microsoft.com/zh-cn/microsoft-edge/webview2/get-started/wpf"})}),"\n"]}),"\n",(0,i.jsxs)(n.h2,{id:"3474-\u53d1\u5e03-winformwpf",children:["34.7.4 \u53d1\u5e03 ",(0,i.jsx)(n.code,{children:"WinForm/WPF"})]}),"\n",(0,i.jsxs)(n.h3,{id:"34741-\u542f\u52a8\u5c42\u6dfb\u52a0-singlefilepublish",children:["34.7.4.1 \u542f\u52a8\u5c42\u6dfb\u52a0 ",(0,i.jsx)(n.code,{children:"SingleFilePublish"})]}),"\n",(0,i.jsxs)(n.p,{children:["\u901a\u5e38\u684c\u9762\u8f6f\u4ef6\u90fd\u662f\u53d1\u5e03\u4e3a\u4e0d\u4f9d\u8d56\u73af\u5883\uff08\u72ec\u7acb\u53d1\u5e03\uff09\uff0c\u6240\u4ee5\u5728\u542f\u52a8\u5c42\u6dfb\u52a0 ",(0,i.jsx)(n.code,{children:"SingleFilePublish.cs"})," \u6587\u4ef6\u7f16\u8f91\u3002"]}),"\n",(0,i.jsx)(n.p,{children:(0,i.jsxs)(n.strong,{children:["\u8be6\u7ec6\u6559\u7a0b\u53ef\u67e5\u770b ",(0,i.jsx)(n.a,{href:"/docs/singlefile",children:"\u301034.5 \u5355\u6587\u4ef6\u53d1\u5e03\u3011"})]})}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cs",metastring:"showLineNumbers {4,6}",children:'using Furion;\r\nusing System.Reflection;\r\n\r\nnamespace WinFormsApp1;\r\n\r\npublic class SingleFilePublish : ISingleFilePublish\r\n{\r\n public Assembly[] IncludeAssemblies()\r\n {\r\n return Array.Empty<Assembly>();\r\n }\r\n\r\n public string[] IncludeAssemblyNames()\r\n {\r\n return new[]\r\n {\r\n "Furion.Application",\r\n "Furion.Core",\r\n "Furion.EntityFramework.Core",\r\n "Furion.Web.Core"\r\n };\r\n }\r\n}\r\n\n'})}),"\n",(0,i.jsx)(n.h3,{id:"34742-\u53d1\u5e03\u914d\u7f6e",children:"34.7.4.2 \u53d1\u5e03\u914d\u7f6e"}),"\n",(0,i.jsx)(n.p,{children:"\u53d1\u5e03\u53ef\u53c2\u8003\u4ee5\u4e0b\u914d\u7f6e\u5373\u53ef\u3002"}),"\n",(0,i.jsx)("img",{src:(0,o.Z)("img/n5.png")}),"\n",(0,i.jsx)(n.p,{children:"\u76f8\u5173\u6280\u672f\u6587\u6863\uff1a"}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsx)(n.li,{children:(0,i.jsx)(n.a,{href:"https://gitee.com/dotnetchina/Furion/tree/v4/samples",children:"Furion \u793a\u4f8b\u4ee3\u7801"})}),"\n"]}),"\n",(0,i.jsxs)(n.h2,{id:"3475-\u6253\u5305\u6210-exe-\u6216-msi",children:["34.7.5 \u6253\u5305\u6210 ",(0,i.jsx)(n.code,{children:"exe"})," \u6216 ",(0,i.jsx)(n.code,{children:"msi"})]}),"\n",(0,i.jsx)(n.p,{children:"\u53ef\u53c2\u8003\u4ee5\u4e0b\u6587\u6863\uff1a"}),"\n",(0,i.jsx)(n.p,{children:(0,i.jsx)(n.a,{href:"https://blog.csdn.net/xfy18317776108/article/details/122343091",children:"https://blog.csdn.net/xfy18317776108/article/details/122343091"})}),"\n",(0,i.jsx)(n.h2,{id:"3476-\u53cd\u9988\u4e0e\u5efa\u8bae",children:"34.7.6 \u53cd\u9988\u4e0e\u5efa\u8bae"}),"\n",(0,i.jsx)(n.admonition,{title:"\u4e0e\u6211\u4eec\u4ea4\u6d41",type:"note",children:(0,i.jsxs)(n.p,{children:["\u7ed9 Furion \u63d0 ",(0,i.jsx)(n.a,{href:"https://gitee.com/dotnetchina/Furion/issues/new?issue",children:"Issue"}),"\u3002"]})})]})}function p(e={}){const{wrapper:n}={...(0,s.a)(),...e.components};return n?(0,i.jsx)(n,{...e,children:(0,i.jsx)(u,{...e})}):u(e)}},1151:(e,n,r)=>{r.d(n,{Z:()=>c,a:()=>t});var i=r(7294);const s={},o=i.createContext(s);function t(e){const n=i.useContext(o);return i.useMemo((function(){return"function"==typeof e?e(n):{...n,...e}}),[n,e])}function c(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(s):e.components||s:t(e.components),i.createElement(o.Provider,{value:n},e.children)}}}]); |