### List installed .NET project templates Source: https://github.com/zhontai/admin.core/blob/master/templates/gateway/content/README.md Command to display all available .NET project templates currently installed on the system. ```CLI dotnet new list ``` -------------------------------- ### Install .NET project template Source: https://github.com/zhontai/admin.core/blob/master/templates/gateway/content/README.md Commands to install a .NET project template, either by its name from a NuGet feed or directly from a local NuGet package file. ```CLI dotnet new install ZhonTai.Template.GateWay ``` ```CLI dotnet new install F:\zhontai\Admin.Core\templates\ZhonTai.Template.GateWay.1.0.0.nupkg ``` -------------------------------- ### Install Microsoft Tye Global Tool Source: https://github.com/zhontai/admin.core/blob/master/README.en.md Instructions to install the Microsoft Tye global tool using the .NET CLI, specifying a pre-release version and a custom NuGet package source for development builds. ```Bash dotnet tool install -g Microsoft.Tye --version "0.12.0-*" --add-source https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet6/nuget/v3/index.json ``` -------------------------------- ### Build for Production Source: https://github.com/zhontai/admin.core/blob/master/src/platform/ZhonTai.ApiUI/src/knife4j-vue/README.md Compiles and minifies the application's source code, preparing it for production deployment. ```Bash yarn run build ``` -------------------------------- ### Setup and Run ZhonTai Admin Core from Source Source: https://github.com/zhontai/admin.core/blob/master/README.en.md Instructions for cloning the ZhonTai Admin Core repository, opening the solution in Visual Studio, and running or publishing the project. This process requires .NET version 9.0 or higher. ```bash # Clone a project git clone https://github.com/zhontai/Admin.Core.git # Enter the project cd Admin.Core # Open the project Open the ZhonTai.sln solution # Run the project Set ZhonTai.Admin.Host as the startup project, press Ctrl + F5 to build and run the project directly without debugging Alternatively, navigate to the ZhonTai.Admin.Host directory in Command Prompt (cmd) and enter the dotnet run command to execute the project. # Package and Publish Select ZhonTai.Admin.Host, then right-click and choose Publish from the context menu. ``` -------------------------------- ### Create and Run New Project using ZhonTai Template Source: https://github.com/zhontai/admin.core/blob/master/README.en.md Steps to install the ZhonTai project template, create a new .NET project with specified configurations (e.g., company name, database type), and run the newly generated project. This method also requires .NET version 9.0 or higher. ```bash # Installation template dotnet new install ZhonTai.Template.App # View help dotnet new MyApp -h # New the project dotnet new MyApp -n MyCompanyName.MySys -at sys -ac sys -p 16010 -gp 16011 -db MySql # Run the project Set MyCompanyName.MySys.Host as the startup project, press Ctrl + F5 to compile and run the project directly (without debugging) Alternatively, navigate to the 'MyCompanyName.MySys.Host' directory in Command Prompt (cmd) and enter the 'dotnet run' command to execute the project. ``` -------------------------------- ### Run Development Server Source: https://github.com/zhontai/admin.core/blob/master/src/platform/ZhonTai.ApiUI/src/knife4j-vue/README.md Compiles and hot-reloads the application for development, providing a local server for testing changes. ```Bash yarn run serve ``` -------------------------------- ### Run Project Tests Source: https://github.com/zhontai/admin.core/blob/master/src/platform/ZhonTai.ApiUI/src/knife4j-vue/README.md Executes the project's defined test suite to ensure code quality and functionality. ```Bash yarn run test ``` -------------------------------- ### Lint and Fix Files Source: https://github.com/zhontai/admin.core/blob/master/src/platform/ZhonTai.ApiUI/src/knife4j-vue/README.md Analyzes source code for programmatic and stylistic errors, and automatically fixes them where possible. ```Bash yarn run lint ``` -------------------------------- ### Oracle SQL Script for Database and User Setup Source: https://github.com/zhontai/admin.core/blob/master/templates/app/content/MyApp.Host/ConfigCenter/createdbsql.txt This comprehensive script initializes an Oracle database. It begins by creating a temporary tablespace named 'admindb_temp' and a permanent tablespace named 'admindb', both configured with autoextend capabilities. Subsequently, it creates a new database user 'admin' with a specified password, assigning the newly created tablespaces as its default and temporary storage. Finally, it grants the 'connect', 'resource', and 'dba' roles to the 'admin' user, providing full access for application operations. ```SQL create temporary tablespace admindb_temp tempfile 'D:\Oracle\Data\admindb_temp.dbf' size 50m autoextend on next 50m maxsize 20480m extent management local; create tablespace admindb logging datafile 'D:\Oracle\Data\admindb.dbf' size 50m autoextend on next 50m maxsize 20480m extent management local; create user admin identified by password default tablespace admindb temporary tablespace admindb_temp; grant connect,resource,dba to admin; ``` -------------------------------- ### Uninstall .NET project template Source: https://github.com/zhontai/admin.core/blob/master/templates/gateway/content/README.md Command to remove an installed .NET project template from the system. ```CLI dotnet new uninstall ZhonTai.Template.GateWay ``` -------------------------------- ### Create new project from .NET template Source: https://github.com/zhontai/admin.core/blob/master/templates/gateway/content/README.md Command to create a new project instance using a specific .NET template, specifying the desired project name. ```CLI dotnet new MyGateWay -n MyCompanyName.GateWay ``` -------------------------------- ### Generate NuGet package for .NET template Source: https://github.com/zhontai/admin.core/blob/master/templates/gateway/content/README.md Command to create a NuGet package (.nupkg) from a .NET project template using a specified .nuspec file. This command should be executed from the template's root directory. ```CLI nuget pack F:\zhontai\Admin.Core\templates\gateway\templates.nuspec -NoDefaultExcludes ``` -------------------------------- ### JavaScript OAuth2 Client Implementation Source: https://github.com/zhontai/admin.core/blob/master/src/platform/ZhonTai.ApiUI/src/dist/oauth/oauth2.html This comprehensive JavaScript code defines an `OAuth2` class to manage the OAuth2 authentication flow. It includes methods for initialization (`init`), handling different grant types (`auth`, `implicit`, `authorizationCode`), and utility functions for parsing URL parameters (`getKey`) and string validation (`strNotBlank`). It stores authentication state and tokens in `localStorage` and interacts with a backend for the authorization code flow. ```JavaScript $(function(){ function OAuth2(url){ this.url=url; this.code=null; this.accessToken=null; this.tokenType=null; this.state=null; //缓存在localStorage中的对象 this.cacheValue=null; } OAuth2.prototype.init=function(){ var local=this.url; this.code=this.getKey("code",local,""); this.accessToken=this.getKey("access_token",local,""); this.tokenType=this.getKey("token_type",local,"Bearer"); this.state=this.getKey("state",local); if(window.localStorage){ var value=window.localStorage.getItem(this.state); if(this.strNotBlank(value)){ this.cacheValue=JSON.parse(value); } } } OAuth2.prototype.auth=function(){ if(this.strNotBlank(this.code)){ this.authorizationCode(); }else{ this.implicit(); } } OAuth2.prototype.getKey=function(key,str,defaultValue){ var reg=new RegExp(".*?"+key+"=(.*?)(&.*)?$","ig"); var val=defaultValue; if(reg.test(str)){ val=RegExp.$1; } return val; } OAuth2.prototype.strNotBlank=function(str){ var flag = false; if ( str != undefined &&str != null &&str != "") { flag = true; } return flag; } OAuth2.prototype.implicit=function(){ this.cacheValue.accessToken=this.tokenType+" "+this.accessToken; this.cacheValue.tokenType=this.tokenType; this.cacheValue.granted=true; window.localStorage.setItem(this.state,JSON.stringify(this.cacheValue)) window.close(); } OAuth2.prototype.authorizationCode=function(){ var that=this; console.log(this.cacheValue); var url=this.cacheValue.tokenUrl; var params={ "grant_type":"authorization_code", "code":this.code, "redirect_uri":decodeURIComponent(this.cacheValue.redirectUri), "client_id":this.cacheValue.clientId, "client_secret":this.cacheValue.clientSecret } $.post(url,params,function(data){ if(data!=null&&data!=undefined) { that.cacheValue.accessToken=data.token_type+" "+data.access_token; that.cacheValue.tokenType=data.token_type; that.cacheValue.granted=true; window.localStorage.setItem(that.state,JSON.stringify(that.cacheValue)) window.close(); } }) } var oauth=new OAuth2(window.location.href); oauth.init(); oauth.auth(); }) ``` -------------------------------- ### JavaScript OAuth2 Client-Side Authentication Flow Source: https://github.com/zhontai/admin.core/blob/master/src/platform/ZhonTai.ApiUI/src/knife4j-vue/public/oauth/oauth2.html This snippet defines an `OAuth2` class to manage client-side OAuth2 authentication. It initializes from the current URL, determines the grant type (implicit or authorization code), and handles token storage in `localStorage`. It includes utility methods for parsing URL parameters (`getKey`), checking string validity (`strNotBlank`), and performing POST requests for token exchange in the authorization code flow using jQuery. ```JavaScript $(function(){ function OAuth2(url){ this.url=url; this.code=null; this.accessToken=null; this.tokenType=null; this.state=null; //缓存在localStorage中的对象 this.cacheValue=null; } OAuth2.prototype.init=function(){ var local=this.url; this.code=this.getKey("code",local,""); this.accessToken=this.getKey("access_token",local,""); this.tokenType=this.getKey("token_type",local,"Bearer"); this.state=this.getKey("state",local); if(window.localStorage){ var value=window.localStorage.getItem(this.state); if(this.strNotBlank(value)){ this.cacheValue=JSON.parse(value); } } } OAuth2.prototype.auth=function(){ if(this.strNotBlank(this.code)){ this.authorizationCode(); }else{ this.implicit(); } } OAuth2.prototype.getKey=function(key,str,defaultValue){ var reg=new RegExp(".*?"+key+"=(.*?)(&.*)?$","ig"); var val=defaultValue; if(reg.test(str)){ val=RegExp.$1; } return val; } OAuth2.prototype.strNotBlank=function(str){ var flag = false; if ( str != undefined &&str != null &&str != "") { flag = true; } return flag; } OAuth2.prototype.implicit=function(){ this.cacheValue.accessToken=this.tokenType+" "+this.accessToken; this.cacheValue.tokenType=this.tokenType; this.cacheValue.granted=true; window.localStorage.setItem(this.state,JSON.stringify(this.cacheValue)) window.close(); } OAuth2.prototype.authorizationCode=function(){ var that=this; console.log(this.cacheValue); var url=this.cacheValue.tokenUrl; var params={ "grant_type":"authorization_code", "code":this.code, "redirect_uri":decodeURIComponent(this.cacheValue.redirectUri), "client_id":this.cacheValue.clientId, "client_secret":this.cacheValue.clientSecret } $.post(url,params,function(data){ if(data!=null&&data!=undefined) { that.cacheValue.accessToken=data.token_type+" "+data.access_token; that.cacheValue.tokenType=data.token_type; that.cacheValue.granted=true; window.localStorage.setItem(that.state,JSON.stringify(that.cacheValue)) window.close(); } }) } var oauth=new OAuth2(window.location.href); oauth.init(); oauth.auth(); }) ``` -------------------------------- ### Adjust Root Font Size Based on Viewport Width Source: https://github.com/zhontai/admin.core/blob/master/ui/zhontai.ui.admin.uniapp.vue2/index.html This JavaScript snippet listens for the 'DOMContentLoaded' event to ensure the HTML document is fully loaded. Once loaded, it calculates a new font size for the root HTML element (`document.documentElement`) by dividing the client's viewport width by 20, effectively making the font size responsive to the screen width. ```JavaScript document.addEventListener('DOMContentLoaded', function() { document.documentElement.style.fontSize = document.documentElement.clientWidth / 20 + 'px' }) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.