github桌面应用下载慢

GitHub's Electron framework (formerly known as Atom Shell) lets you write cross platform desktop application using HTML, CSS and JavaScript. It's a variant of io.js run-time which is focused on desktop applications instead of web servers.

GitHub的Electron框架(以前称为Atom Shell)使您可以使用HTML,CSS和JavaScript编写跨平台的桌面应用程序 。 它是io.js运行时的一种变体,它专注于桌面应用程序而不是Web服务器。

Electron's rich native APIs enables us to access native things directly from our pages with JavaScript.

Electron丰富的本机API使我们能够直接使用JavaScript从页面访问本机内容。

This tutorial shows us how to build a desktop application with Angular and Electron. The steps for this tutorial are as follows:

本教程向我们展示了如何使用Angular和Electron构建桌面应用程序。 本教程的步骤如下:

  1. Create a simple Electron application

    创建一个简单的电子应用程序
  2. Use Visual Studio Code Editor to manage our project and tasks

    使用Visual Studio代码编辑器管理我们的项目和任务
  3. Integrate an Angular Customer Manager App with Electron

    将Angular Customer Manager应用程序与Electron集成
  4. Use Gulp tasks to build our application and create installers

    使用Gulp任务来构建我们的应用程序并创建安装程序

创建电子应用程序 (Creating Your Electron Application)

To get started, install Node if you don't have it in your system already. Our application should be structured as follows:

首先,如果系统中尚未安装Node ,请安装它。 我们的应用程序的结构应如下:

project-structure

There are two package.json files in this project.

这个项目中有两个package.json文件。

  • For development

    The package.json directly inside the project root contains the configurations, dependiencies for your development environment and build scripts. These dependencies and package.json file will not be included inside the production build.

    为了发展

    直接在项目根目录下的package.json包含配置,开发环境和构建脚本的依赖关系。 这些依赖项和package.json文件不会包含在生产版本中。

  • For your application

    The package.json inside app folder is the manifest file for your application. So whenever you need to install npm dependencies to be used in your application directly, you should install it against this package.json

    为您的应用

    app文件夹中的package.json是您的应用程序的清单文件。 因此,每当需要安装直接在应用程序中使用的npm依赖项时,都应针对此package.json安装它

The format of package.json is exactly same as that of Node's module. Your application’s startup script should be specified in main property inside your app/package.json.

package.json的格式与Node模块的格式完全相同。 应用程序的启动脚本应在app / package.json内部的main属性中指定。

app/package.json might look like this:

app/package.json可能看起来像这样:

{ name: "AngularElectron", version: "0.0.0", main: "main.js" 
}

You can create both package.json files either by entering the npm init command. You can also manually create these files. Install npm dependencies that are required for packaging the application by entering following command in your command line prompt:

您可以通过输入npm init命令来创建两个package.json文件。 您也可以手动创建这些文件。 通过在命令行提示符下输入以下命令来安装打包应用程序所需的npm依赖项:

npm install --save-dev electron-prebuilt fs-jetpack asar rcedit Q

创建启动脚本 (Creating your Startup Script)

app/main.js is the entry point of our application. This script is responsible for creating the main window and handling the system events. main.js should look like the following:

app / main.js是我们应用程序的入口。 该脚本负责创建主窗口并处理系统事件。 main.js应该如下所示:

// app/main.js// Module to control application life.
var app = require('app'); // Module to create native browser window.
var BrowserWindow = require('browser-window');
var mainWindow = null;// Quit when all windows are closed.
app.on('window-all-closed', function () {if (process.platform != 'darwin') {app.quit();}
});// This method will be called when Electron has finished
// initialization and is ready to create browser windows.
app.on('ready', function () {// Create the browser window.mainWindow = new BrowserWindow({ width: 800, height: 600 });// and load the index.html of the app.mainWindow.loadUrl('file://' + __dirname + '/index.html');// Open the devtools.// mainWindow.openDevTools();// Emitted when the window is closed.mainWindow.on('closed', function () {// Dereference the window object, usually you would store windows// in an array if your app supports multi windows, this is the time// when you should delete the corresponding element.mainWindow = null;});});

来自DOM的本地访问 (Native access from the DOM)

As I mentioned above, Electron enables you to access local npm modules and native APIs directly from your web pages. Create your app/index.html file as follows:

如上所述,Electron使您可以直接从网页访问本地npm模块和本机API。 创建您的app/index.html文件,如下所示:

<html>
<body> <h1>Hello World!</h1>We are using Electron <script> document.write(process.versions['electron']) </script> on <script> document.write(process.platform) </script><script type="text/javascript"> var fs = require('fs');var file = fs.readFileSync('app/package.json'); document.write(file); </script></body> 
</html>

app/index.html is a simple HTML page. Here it reads your package.json using Node's fs (file system) module and writes the content into the document body.

app / index.html是一个简单HTML页面。 在这里,它使用Node的fs (文件系统)模块读取package.json并将内容写入文档主体。

运行应用程序 (Run the Application)

Once you have created the project structure, app/index.html, app/main.js, app/package.json , you'll probably want to try running your initial Electron application to test it and make sure it's working as expected.

一旦创建了项目结构app/index.htmlapp/main.jsapp/package.json ,您可能想要尝试运行初始的Electron应用程序以对其进行测试,并确保其按预期运行。

If you've installed electron-prebuilt globally in your system, you can run our application with following command:

如果您已在系统中全局安装了electron-prebuilt ,则可以使用以下命令运行我们的应用程序:

electron app

Here electron is the command to run electron shell and app is our application folder name. If you don't want to install Electron into your global npm modules, then run with your local modules installed into npm_modules folder as follows in your command line prompt:

这里的electron是运行电子外壳的命令,而app是我们的应用程序文件夹名称。 如果您不想将Electron安装到全局npm模块中,请在命令行提示符下将本地模块安装到npm_modules文件夹中运行:

"node_modules/.bin/electron" "./app"

While you could do it that way, I recommend you create a gulp task to run your application in your gulpfile.js, so that you can integrate your task into Visual Studio Code Editor which we will check in next section.

尽管可以这样做,但我建议您创建一个gulpfile.js 任务以在gulpfile.js运行您的应用程序,以便将您的任务集成到Visual Studio Code Editor中,我们将在下一部分中进行检查。

// get the dependencies
var gulp        = require('gulp'), childProcess  = require('child_process'), electron      = require('electron-prebuilt');// create the gulp task
gulp.task('run', function () { childProcess.spawn(electron, ['./app'], { stdio: 'inherit' }); 
});

Run your gulp task: gulp run Our application might looks like this:

运行您的gulp任务: gulp run我们的应用程序可能如下所示:

electron-app

使用Visual Studio代码配置开发环境 (Configuring Development Environment With Visual Studio Code)

Visual Studio Code is a cross platform code editor from Microsoft. Behind the scene of VS Code is Electron and Microsoft's proprietary monaco code editor. You can download Visual Studio Code here.

Visual Studio Code是Microsoft的跨平台代码编辑器。 VS Code的背后是Electron和微软专有的monaco代码编辑器。 您可以在此处下载Visual Studio Code。

Open your electron application in VS Code.

在VS Code中打开您的电子应用程序。

open-application

配置Visual Studio代码任务运行器 (Configure Visual Studio Code Task Runner)

Lots of tools exist to automate our tasks like building, packaging or testing our application. Mostly we run these tools from the command line. VS Code's built in task runner enables you to integrate your custom tasks into your project. You can run your grunt, gulp, MsBuild or any other tasks directly from within your project without moving to the command line.

存在许多工具可以自动化我们的任务,例如构建,打包或测试我们的应用程序。 通常,我们从命令行运行这些工具。 VS Code的内置任务运行器使您可以将自定义任务集成到项目中。 您可以直接在项目中运行grunt,gulp,MsBuild或任何其他任务,而无需移至命令行。

VS Code can detect your grunt and gulp tasks automaticaly. Press ctrl + shift + p then type Run Task followed by Enter.

VS Code可以自动检测您的咕unt声和吞咽任务。 按ctrl + shift + p然后键入Run Task然后按Enter

run-task

You will get all available tasks from your gulpfile.js or gruntfile.js.

您将从gulpfile.jsgruntfile.js获得所有可用任务。

Note that, you should have your gulpfile.js in root directory of your application.

请注意,您应该在应用程序的根目录中包含gulpfile.js

run-task-gulp

ctrl + shift + b will execute build task from your task runner. You can override this intergration using the task.json file. Press ctrl + shift + p then type Configure Task followed by Enter. This will create .setting folder and a task.json in your project . You need to configure the tasks in tasks.json if you want to do more than simply run the task. For example you might want to run the application when you press the Ctrl + Shift + B . To do this edit the task.json file as follows:

ctrl + shift + b将从任务运行器执行build任务。 您可以使用task.json文件覆盖此task.json 。 按ctrl + shift + p然后键入Configure Task然后按Enter 。 这将在您的项目中创建.setting文件夹和task.json。 如果您想做的不仅仅是运行任务,还需要在task.json中配置任务。 例如,当您按Ctrl + Shift + B时,可能要运行该应用程序。 为此,如下编辑task.json文件:

{ "version": "0.1.0", "command": "gulp", "isShellCommand": true, "args": [ "--no-color" ], "tasks": [ { "taskName": "run", "args": [], "isBuildCommand": true } ] 
}

Root section says that the command is gulp. You can have more tasks inside tasks section as you want. Setting isBuildCommand true for a task will bind the Ctrl + Shift + B to that task. Currently VS Code supports one top level task only.

根节说该命令是gulp 。 您可以根据需要在“ tasks部分中包含更多任务。 为任务设置isBuildCommand true会将Ctrl + Shift + B绑定到该任务。 当前,VS Code仅支持一项顶级任务。

Now if you press Ctrl + Shift + B, gulp run will be executed.

现在,如果您按Ctrl + Shift + B ,则将执行gulp run

You can read more about visual studio code tasks here

您可以在此处阅读有关Visual Studio代码任务的更多信息

调试电子应用 (Debugging Electron Application)

Open the debug panel and click configure button which will create a launch.json file inside .settings folder with debug configuration.

打开调试面板,然后单击配置按钮,这将在.settings文件夹中创建带有调试配置的launch.json文件。

debug

We don't need launch app.js configuration, so remove it.

我们不需要启动app.js配置,因此将其删除。

Now your launch.json should be as follows:

现在,您的launch.json应该如下所示:

{ "version": "0.1.0", // List of configurations. Add new configurations or edit existing ones. // ONLY "node" and "mono" are supported, change "type" to switch. "configurations": [{ "name": "Attach", "type": "node", // TCP/IP address. Default is "localhost". "address": "localhost", // Port to attach to."port": 5858, "sourceMaps": false } ] 
}

Change your gulp run task that we created before as follows, so that our electron will start in debug mode and will listen to port 5858:

如下更改您之前创建的gulp run任务,以使我们的电子设备以调试模式启动并侦听端口5858:

gulp.task('run', function () { childProcess.spawn(electron, ['--debug=5858','./app'], { stdio: 'inherit' }); 
});

In the debug panel choose "Attach" configuration and click run or press F5. After few seconds you should see the debug command panel in the top.

在调试面板中,选择“附加”配置,然后单击“运行”或按F5。 几秒钟后,您应该在顶部看到调试命令面板。

debug-star

创建AngularJS应用程序 (Creating the AngularJS Application)

New to AngularJS? Check out the official website here or some of the Scotch Angular tutorials.

AngularJS的新手? 在此处查看官方网站或一些Scotch Angular教程 。

This section explains how to create a simple Customer Manager application using AngularJS with a MySQL database as the backend. The goal of this application is not to highlight the core concepts of AngularJS but to demonstrate how to use the AngularJS and NodeJS together with MySQL backend inside GitHub Electron.

本节说明如何使用以MySQL数据库为后端的AngularJS创建简单的Customer Manager应用程序。 该应用程序的目的不是突出AngularJS的核心概念,而是演示如何在GitHub Electron中将AngularJS和NodeJS与MySQL后端一起使用。

Our Customer Manager application is as simple as the following:

我们的客户经理应用程序很简单,如下所示:

  • List the customers

    列出客户
  • Add New Customer

    添加新客户
  • Option to delete a customer

    选择删除客户
  • Search for the customer

    寻找客户

项目结构 (Project Structure)

Our application is located inside app folder, and the structure of the application is shown below.

我们的应用程序位于app文件夹内,其结构如下所示。

angular-project-structure

The home page is the app/index.html file. The app/scripts folder contains all the key scripts and views used in this application. There are several techniques that can be used for organizing application files.

主页是app/index.html文件。 app/scripts文件夹包含此应用程序中使用的所有关键脚本和视图。 有几种技术可用于组织应用程序文件。

Here I prefer scripts organized by features. Each feature has its own folder with templates and controllers inside the same folder. For more info on folder structure, read: AngularJS Best Practices: Directory Structure

在这里,我更喜欢按功能组织的脚本。 每个功能都有其自己的文件夹,并且同一文件夹中包含模板和控制器。 有关文件夹结构的更多信息,请阅读: AngularJS最佳实践:目录结构

Before get started with the AngularJS application, we're going to install client side dependencies using bower. Install Bower if you don't have it already. Change the current working directory to the root of the application in your terminal then install dependencies as follows from your command line prompt :

在开始使用AngularJS应用程序之前,我们将使用bower安装客户端依赖项。 如果尚未安装Bower ,请安装它。 将当前工作目录更改为终端中应用程序的根目录,然后在命令行提示符下按如下所示安装依赖项:

bower install angular angular-route angular-material --save

设置数据库 (Setting Up the Database)

For this demo I'll be using a database called customer-manager and a table called customers. Here is the dump of database so that you can get up and run quickly.

在本演示中,我将使用一个名为customer-manager的数据库和一个名为customers的表。 这是数据库的转储,因此您可以快速启动并运行。

CREATE TABLE `customer_manager`.`customers` ( `customer_id` INT NOT NULL AUTO_INCREMENT, `name` VARCHAR(45) NOT NULL, `address` VARCHAR(450) NULL, `city` VARCHAR(45) NULL, `country` VARCHAR(45) NULL, `phone` VARCHAR(45) NULL, `remarks` VARCHAR(500) NULL, PRIMARY KEY (`customer_id`) 
);

创建一个与MySQL交互的Angular服务 (Creating an Angular Service to Interact with MySQL)

Once you have your database and table ready, let's create an AngularJS service to access the data directly from this database. The service connects to database using node-mysql npm module - a NodeJs driver for MySql written in JavaScript. Install node-mysql module in your app/ folder where your Angular application resides.

准备好数据库和表后,让我们创建一个AngularJS服务以直接从该数据库访问数据。 该服务使用node-mysql npm模块连接到数据库,该模块是用JavaScript编写的MySql的NodeJs驱动程序。 在Angular应用程序所在的app /文件夹中安装node-mysql模块。

Note , we install node-mysql module inside app folder, not in the application root, as we need to include this module inside the final distribution.

注意,我们将node-mysql模块安装在app文件夹中,而不是在应用程序根目录中,因为我们需要将此模块包含在最终发行版中。

Change the current working directory to app folder in your command prompt install using following command.

使用以下命令在命令提示符安装中将当前工作目录更改为app文件夹。

npm install --save mysql

Our angular service - app/scripts/customer/customerService.js, should looks like following:

我们的角度服务-app / scripts / customer / customerService.js如下所示:

(function () {'use strict';var mysql = require('mysql');// Creates MySql database connectionvar connection = mysql.createConnection({host: "localhost",user: "root",password: "password",database: "customer_manager"});angular.module('app').service('customerService', ['$q', CustomerService]);function CustomerService($q) {return {getCustomers: getCustomers,getById: getCustomerById,getByName: getCustomerByName,create: createCustomer,destroy: deleteCustomer,update: updateCustomer};function getCustomers() {var deferred = $q.defer();var query = "SELECT * FROM customers";connection.query(query, function (err, rows) {if (err) deferred.reject(err);deferred.resolve(rows);});return deferred.promise;}function getCustomerById(id) {var deferred = $q.defer();var query = "SELECT * FROM customers WHERE customer_id = ?";connection.query(query, [id], function (err, rows) {if (err) deferred.reject(err);deferred.resolve(rows);});return deferred.promise;}function getCustomerByName(name) {var deferred = $q.defer();var query = "SELECT * FROM customers WHERE name LIKE  '" + name + "%'";connection.query(query, [name], function (err, rows) {if (err) deferred.reject(err);deferred.resolve(rows);});return deferred.promise;}function createCustomer(customer) {var deferred = $q.defer();var query = "INSERT INTO customers SET ?";connection.query(query, customer, function (err, res) if (err) deferred.reject(err);deferred.resolve(res.insertId);});return deferred.promise;}function deleteCustomer(id) {var deferred = $q.defer();var query = "DELETE FROM customers WHERE customer_id = ?";connection.query(query, [id], function (err, res) {if (err) deferred.reject(err);deferred.resolve(res.affectedRows);});return deferred.promise;}function updateCustomer(customer) {var deferred = $q.defer();var query = "UPDATE customers SET name = ? WHERE customer_id = ?";connection.query(query, [customer.name, customer.customer_id], function (err, res) {if (err) deferred.reject(err);deferred.resolve(res);});return deferred.promise;}}
})();

customerService is a simple custom angular service that provides basic CRUD operations on customers table . It uses node's mysql module directly inside the service. If you already have a remote data service, you can use it instead.

customerService是一个简单的自定义角度服务,可在customers表上提供基本的CRUD操作。 它直接在服务内部使用节点的mysql模块。 如果您已经拥有远程数据服务,则可以改用它。

控制器和模板 (Controller & Template)

OurcustomerControllerinsideapp/scripts/customer/customerController is as follows:

app / scripts / customer / customerController内部的customerController如下:

(function () {'use strict';angular.module('app').controller('customerController', ['customerService', '$q', '$mdDialog', CustomerController]);function CustomerController(customerService, $q, $mdDialog) {var self = this;self.selected = null;self.customers = [];self.selectedIndex = 0;self.filterText = null;self.selectCustomer = selectCustomer;self.deleteCustomer = deleteCustomer;self.saveCustomer = saveCustomer;self.createCustomer = createCustomer;self.filter = filterCustomer;// Load initial datagetAllCustomers();//----------------------// Internal functions //----------------------function selectCustomer(customer, index) {self.selected = angular.isNumber(customer) ? self.customers[customer] : customer;self.selectedIndex = angular.isNumber(customer) ? customer: index;}function deleteCustomer($event) {var confirm = $mdDialog.confirm().title('Are you sure?').content('Are you sure want to delete this customer?').ok('Yes').cancel('No').targetEvent($event);$mdDialog.show(confirm).then(function () {customerService.destroy(self.selected.customer_id).then(function (affectedRows) {self.customers.splice(self.selectedIndex, 1);});}, function () { });}function saveCustomer($event) {if (self.selected != null && self.selected.customer_id != null) {customerService.update(self.selected).then(function (affectedRows) {$mdDialog.show($mdDialog.alert().clickOutsideToClose(true).title('Success').content('Data Updated Successfully!').ok('Ok').targetEvent($event));});}else {//self.selected.customer_id = new Date().getSeconds();customerService.create(self.selected).then(function (affectedRows) {$mdDialog.show($mdDialog.alert().clickOutsideToClose(true).title('Success').content('Data Added Successfully!').ok('Ok').targetEvent($event));});}}function createCustomer() {self.selected = {};self.selectedIndex = null;}function getAllCustomers() {customerService.getCustomers().then(function (customers) {self.customers = [].concat(customers);self.selected = customers[0];});}function filterCustomer() {if (self.filterText == null || self.filterText == "") {getAllCustomers();}else {customerService.getByName(self.filterText).then(function (customers) {self.customers = [].concat(customers);self.selected = customers[0];});}}}})();

Our Customer template(app/scripts/customer/customer.html) uses angular material components to build user interface, and its is as follows:

我们的客户模板( app / scripts / customer / customer.html )使用角形材料组件来构建用户界面,其内容如下:

<div style="width:100%" layout="row"><md-sidenav class="site-sidenav md-sidenav-left md-whiteframe-z2"md-component-id="left"md-is-locked-open="$mdMedia('gt-sm')"><md-toolbar layout="row" class="md-whiteframe-z1"><h1>Customers</h1></md-toolbar><md-input-container style="margin-bottom:0"><label>Customer Name</label><input required name="customerName" ng-model="_ctrl.filterText" ng-change="_ctrl.filter()"></md-input-container><md-list><md-list-item ng-repeat="it in _ctrl.customers"><md-button ng-click="_ctrl.selectCustomer(it, $index)" ng-class="{'selected' : it === _ctrl.selected }">{{it.name}}</md-button></md-list-item></md-list></md-sidenav><div flex layout="column" tabIndex="-1" role="main" class="md-whiteframe-z2"><md-toolbar layout="row" class="md-whiteframe-z1"><md-button class="menu" hide-gt-sm ng-click="ul.toggleList()" aria-label="Show User List"><md-icon md-svg-icon="menu"></md-icon></md-button><h1>{{ _ctrl.selected.name }}</h1></md-toolbar><md-content flex id="content"><div layout="column" style="width:50%"><br /><md-content layout-padding class="autoScroll"><md-input-container><label>Name</label><input ng-model="_ctrl.selected.name" type="text"></md-input-container><md-input-container md-no-float><label>Email</label><input ng-model="_ctrl.selected.email" type="text"></md-input-container><md-input-container><label>Address</label><input ng-model="_ctrl.selected.address"  ng-required="true"></md-input-container><md-input-container md-no-float><label>City</label><input ng-model="_ctrl.selected.city" type="text" ></md-input-container><md-input-container md-no-float><label>Phone</label><input ng-model="_ctrl.selected.phone" type="text"></md-input-container></md-content><section layout="row" layout-sm="column" layout-align="center center" layout-wrap><md-button class="md-raised md-info" ng-click="_ctrl.createCustomer()">Add</md-button><md-button class="md-raised md-primary" ng-click="_ctrl.saveCustomer()">Save</md-button><md-button class="md-raised md-danger" ng-click="_ctrl.cancelEdit()">Cancel</md-button><md-button class="md-raised md-warn" ng-click="_ctrl.deleteCustomer()">Delete</md-button></section></div></md-content></div>
</div>

app.js contains module initialization script and application route config as follows:

app.js包含模块初始化脚本和应用程序路由配置,如下所示:

(function () {'use strict';var _templateBase = './scripts';angular.module('app', ['ngRoute','ngMaterial','ngAnimate']).config(['$routeProvider', function ($routeProvider) {$routeProvider.when('/', {templateUrl: _templateBase + '/customer/customer.html' ,controller: 'customerController',controllerAs: '_ctrl'});$routeProvider.otherwise({ redirectTo: '/' });}]);})();

Finally here is our index page app/index.html

最后是我们的索引页面app / index.html

<html lang="en" ng-app="app"><title>Customer Manager</title><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"gt;<meta name="description" content=""><meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no" /><!-- build:css assets/css/app.css --><link rel="stylesheet" href="../bower_components/angular-material/angular-material.css" /><link rel="stylesheet" href="assets/css/style.css" /><!-- endbuild -->
<body><ng-view></ng-view><!-- build:js scripts/vendor.js --><script src="../bower_components/angular/angular.js"></script><script src="../bower_components/angular-route/angular-route.js"></script><script src="../bower_components/angular-animate/angular-animate.js"></script><script src="../bower_components/angular-aria/angular-aria.js"></script><script src="../bower_components/angular-material/angular-material.js"></script><!-- endbuild --><!-- build:app scripts/app.js --><script src="./scripts/app.js"></script><script src="./scripts/customer/customerService.js"></script><script src="./scripts/customer/customerController.js"></script><!-- endbuild -->
</body>
</html>

Run your application using gulp run command or press Ctrl + Shif + B if you already configured VS Code task runner as above.

使用gulp run命令运行您的应用程序,或者按Ctrl + Shif + B如果您已按上述方式配置VS Code任务运行程序)。

angular-app

编译AngularJS应用程序 (Build the AngularJS Application)

To build our Angular application install gulp-uglify, gulp-minify-css and gulp-usemin packages.

要建立我们的角应用程序安装gulp-uglifygulp-minify-cssgulp-usemin包。

npm install --save gulp-uglify gulp-minify-css gulp-usemin

Open your gulpfile.js and import required modules

打开您的gulpfile.js并导入所需的模块

var childProcess = require('child_process'); var electron     = require('electron-prebuilt'); var gulp         = require('gulp'); var jetpack      = require('fs-jetpack'); var usemin       = require('gulp-usemin'); var uglify       = require('gulp-uglify');var projectDir = jetpack; var srcDir     = projectDir.cwd('./app'); var destDir    = projectDir.cwd('./build');

Clean build directory if it already exists.

清理构建目录(如果已存在)。

gulp.task('clean', function (callback) { return destDir.dirAsync('.', { empty: true }); 
});

Copy files into build directory, We don't need to copy the angular application code using copy function. usemin will do this for us in next section:

将文件复制到构建目录,我们不需要使用复制功能复制角度应用程序代码。 在下一部分中, usemin将为我们做到这一点:

gulp.task('copy', ['clean'], function () { return projectDir.copyAsync('app', destDir.path(), { overwrite: true, matching: [ './node_modules/**/*', '*.html', '*.css', 'main.js', 'package.json' ] }); 
});

Our build task takes our app/index.html with gulp.src() and then we pipe it to usemin. It then writes the output into build directory and replace references in index.html with optimized version of code.

我们的构建任务将我们的app / index.html与gulp.src()一起使用,然后将其通过管道传递给usemin。 然后,将输出写入构建目录,并使用优化的代码版本替换index.html中的引用。

Note: Don't forget to define usemin blocks inside app/index.html as follows:

注意:不要忘记在app / index.html中定义usemin块,如下所示:

<!-- build:js scripts/vendor.js -->
<script src="../bower_components/angular/angular.js"></script>
<script src="../bower_components/angular-route/angular-route.js"></script>
<script src="../bower_components/angular-animate/angular-animate.js"></script>
<script src="../bower_components/angular-aria/angular-aria.js"></script>
<script src="../bower_components/angular-material/angular-material.js"></script>
<!-- endbuild --><!-- build:app scripts/app.js -->
<script src="./scripts/app.js"></script>
<script src="./scripts/customer/customerService.js"></script>
<script src="./scripts/customer/customerController.js"></script>
<!-- endbuild -->

The build task should look as follows:

构建任务应如下所示:

gulp.task('build', ['copy'], function () { return gulp.src('./app/index.html') .pipe(usemin({ js: [uglify()] })) .pipe(gulp.dest('build/')); });

准备分发 (Preparing for Distribution)

In this section we will package our Electron application for production. Create your build script in root directory as build.windows.js. This script is intended to be used on Windows. For other platform you should create scripts specific to that platform and should run according to your platform.

在本节中,我们将打包我们的Electron应用程序以进行生产。 在根目录build.windows.js构建脚本创建为build.windows.js 。 该脚本旨在在Windows上使用。 对于其他平台,您应该创建特定于该平台的脚本,并应根据您的平台运行。

A typical electron distribution can be found inside node_modules/electron-prebuilt/dist directory. Here is our steps to build the electron application:

node_modules/electron-prebuilt/dist目录中可以找到典型的电子分布。 这是我们建立电子应用程序的步骤:

  • Our very first task to do is to copy electron distribution into our dist folder.

    我们要做的第一个任务是将电子分布复制到dist文件夹中。

  • Each electron distribution contains a default application inside dist/resources/default_app folder. We need to replace this application with our final angular application build.

    每个电子分布都在dist/resources/default_app文件夹中包含一个默认应用程序。 我们需要用最终的角度应用程序构建替换该应用程序。

  • To protect our application’s source code and resources from users, you can choose to package your app into an asar archive with little changes to your source code. An asar archive is a simple tar-like format that concatenate files into a single file, Electron can read arbitrary files from it without unpacking the whole file.

    为了保护我们应用程序的源代码和资源免受用户的侵害,您可以选择将应用程序打包到一个asar存档中,而对源代码的更改很少。 asar归档文件是一种简单的类似tar的格式,可将文件连接成一个文件,Electron可以从其中读取任意文件,而无需解压缩整个文件。

Note: this section describes about packaging in windows platform. All these steps are same for other platforms but paths and files used here is different for other platforms. You can get the full build scripts for OSx and linux here in github.

注意:本节介绍有关在Windows平台中打包的信息。 对于其他平台,所有这些步骤都是相同的,但是此处使用的路径和文件对于其他平台是不同的。 您可以在github中获得OSx和linux的完整构建脚本。

Install dependencies required to build the electron as following: npm install --save q asar fs-jetpack recedit.

安装构建电子所需的依赖项,如下所示: npm install --save q asar fs-jetpack recedit

Next initialize our build script as follows:

接下来,初始化构建脚本,如下所示:

var Q = require('q'); 
var childProcess = require('child_process'); 
var asar = require('asar'); 
var jetpack = require('fs-jetpack');
var projectDir;
var buildDir; 
var manifest; 
var appDir;function init() { // Project directory is the root of the applicationprojectDir = jetpack; // Build directory is our destination where the final build will be placed buildDir = projectDir.dir('./dist', { empty: true }); // angular application directory appDir = projectDir.dir('./build'); // angular application's package.json file manifest = appDir.read('./package.json', 'json'); return Q(); 
}

Here we use fs-jetpack node module for the file operation. It gives more flexibility on file operations.

在这里,我们使用fs-jetpack节点模块进行文件操作。 它为文件操作提供了更大的灵活性。

复制电子分布 (Copy Electron Distribution)

Copy the default electron distribution from electron-prebuilt/dist to our dist directory.

将默认的电子分布从electron-prebuilt/dist复制到我们的dist目录。

function copyElectron() { return projectDir.copyAsync('./node_modules/electron-prebuilt/dist', buildDir.path(), { overwrite: true }); 
}

清理默认应用程序 (Cleanup the Default Application)

You can find a default HTML application inside resources/default_app folder. We need to replace this application with our angular application. Remove it as follows:

您可以在resources/default_app文件夹中找到默认HTML应用程序。 我们需要用我们的角度应用程序替换该应用程序。 如下删除它:

Note: Here path is specific to windows platform. For other platforms process is same but path is different. In OSX it's Contents/Resources/default_app

注意:这里的路径特定于Windows平台。 对于其他平台,过程相同,但路径不同。 在OSX中,它是目录/资源/ default_app

function cleanupRuntime() { return buildDir.removeAsync('resources/default_app'); 
}

创建asar包 (Create asar package)

function createAsar() { var deferred = Q.defer(); asar.createPackage(appDir.path(), buildDir.path('resources/app.asar'), function () { deferred.resolve(); }); return deferred.promise; 
}

This combines all your angular application files into single asar package file. You can find the destination asar file in dist/resources/ directory.

这会将您所有的角度应用程序文件合并为单个asar软件包文件。 您可以在dist/resources/目录中找到目标asar文件。

用自己的资源替换应用程序资源 (Replace application resources with your own)

Next step is to replace the default electron icon with your own, update the product information and rename the application.

下一步是用您自己的图标替换默认的电子图标,更新产品信息并重命名应用程序。

function updateResources() {var deferred = Q.defer();// Copy your icon from resource folder into build folder.projectDir.copy('resources/windows/icon.ico', buildDir.path('icon.ico'));// Replace Electron icon for your own.var rcedit = require('rcedit');rcedit(buildDir.path('electron.exe'), {'icon': projectDir.path('resources/windows/icon.ico'),'version-string': {'ProductName': manifest.name,'FileDescription': manifest.description,}}, function (err) {if (!err) {deferred.resolve();}});return deferred.promise;
}
//Rename the electron exe 
function rename() {return buildDir.renameAsync('electron.exe', manifest.name + '.exe');
}

创建本机安装程序 (Creating Native Installers)

You can either use wix or NSIS to create windows installer. Here we use NSIS which is designed to be small and flexible as possible and is very suitable for internet distribution. With NSIS you can create such installers that are capable of doing everything that is needed to setup your software.

您可以使用wix或NSIS创建Windows安装程序。 在这里,我们使用NSIS,它设计得尽可能小巧,灵活,非常适合Internet分发。 使用NSIS,您可以创建这样的安装程序,它们能够执行设置软件所需的一切。

Create NSIS script in resources/windows/installer.nsis

在resources / windows / installer.nsis中创建NSIS脚本

!include LogicLib.nsh!include nsDialogs.nsh; --------------------------------; Variables; --------------------------------!define dest "{{dest}}"!define src "{{src}}"!define name "{{name}}"!define productName "{{productName}}"!define version "{{version}}"!define icon "{{icon}}"!define banner "{{banner}}"!define exec "{{productName}}.exe"!define regkey "Software\${productName}"!define uninstkey "Software\Microsoft\Windows\CurrentVersion\Uninstall\${productName}"!define uninstaller "uninstall.exe"; --------------------------------; Installation; --------------------------------SetCompressor lzmaName "${productName}"Icon "${icon}"OutFile "${dest}"InstallDir "$PROGRAMFILES\${productName}"InstallDirRegKey HKLM "${regkey}" ""CRCCheck onSilentInstall normalXPStyle onShowInstDetails nevershowAutoCloseWindow falseWindowIcon offCaption "${productName} Setup"; Don't add sub-captions to title barSubCaption 3 " "SubCaption 4 " "Page custom welcomePage instfilesVar ImageVar ImageHandleFunction .onInit; Extract banner image for welcome pageInitPluginsDirReserveFile "${banner}"File /oname=$PLUGINSDIR\banner.bmp "${banner}"FunctionEnd; Custom welcome pageFunction welcomensDialogs::Create 1018${NSD_CreateLabel} 185 1u 210 100% "Welcome to ${productName} version ${version} installer.$\r$\n$\r$\nClick install to begin."${NSD_CreateBitmap} 0 0 170 210 ""Pop $Image${NSD_SetImage} $Image $PLUGINSDIR\banner.bmp $ImageHandlensDialogs::Show${NSD_FreeImage} $ImageHandleFunctionEnd; Installation declarationsSection "Install"WriteRegStr HKLM "${regkey}" "Install_Dir" "$INSTDIR"WriteRegStr HKLM "${uninstkey}" "DisplayName" "${productName}"WriteRegStr HKLM "${uninstkey}" "DisplayIcon" '"$INSTDIR\icon.ico"'WriteRegStr HKLM "${uninstkey}" "UninstallString" '"$INSTDIR\${uninstaller}"'; Remove all application files copied by previous installationRMDir /r "$INSTDIR"SetOutPath $INSTDIR; Include all files from /build directoryFile /r "${src}\*"; Create start menu shortcutCreateShortCut "$SMPROGRAMS\${productName}.lnk" "$INSTDIR\${exec}" "" "$INSTDIR\icon.ico"WriteUninstaller "${uninstaller}"SectionEnd; --------------------------------; Uninstaller; --------------------------------ShowUninstDetails nevershowUninstallCaption "Uninstall ${productName}"UninstallText "Don't like ${productName} anymore? Hit uninstall button."UninstallIcon "${icon}"UninstPage custom un.confirm un.confirmOnLeaveUninstPage instfilesVar RemoveAppDataCheckboxVar RemoveAppDataCheckbox_State; Custom uninstall confirm pageFunction un.confirmnsDialogs::Create 1018${NSD_CreateLabel} 1u 1u 100% 24u "If you really want to remove ${productName} from your computer press uninstall button."${NSD_CreateCheckbox} 1u 35u 100% 10u "Remove also my ${productName} personal data"Pop $RemoveAppDataCheckboxnsDialogs::ShowFunctionEndFunction un.confirmOnLeave; Save checkbox state on page leave${NSD_GetState} $RemoveAppDataCheckbox $RemoveAppDataCheckbox_StateFunctionEnd; Uninstall declarationsSection "Uninstall"DeleteRegKey HKLM "${uninstkey}"DeleteRegKey HKLM "${regkey}"Delete "$SMPROGRAMS\${productName}.lnk"; Remove whole directory from Program FilesRMDir /r "$INSTDIR"; Remove also appData directory generated by your app if user checked this option${If} $RemoveAppDataCheckbox_State == ${BST_CHECKED}RMDir /r "$LOCALAPPDATA\${name}"${EndIf}SectionEnd

Create a function called createInstaller in your build.windows.js file as follows:

build.windows.js文件中创建一个名为createInstaller的函数,如下所示:

function createInstaller() {var deferred = Q.defer();function replace(str, patterns) {Object.keys(patterns).forEach(function (pattern) {console.log(pattern)var matcher = new RegExp('{{' + pattern + '}}', 'g');str = str.replace(matcher, patterns[pattern]);});return str;}var installScript = projectDir.read('resources/windows/installer.nsi');installScript = replace(installScript, {name: manifest.name,productName: manifest.name,version: manifest.version,src: buildDir.path(),dest: projectDir.path(),icon: buildDir.path('icon.ico'),setupIcon: buildDir.path('icon.ico'),banner: projectDir.path('resources/windows/banner.bmp'),});buildDir.write('installer.nsi', installScript);var nsis = childProcess.spawn('makensis', [buildDir.path('installer.nsi')], {stdio: 'inherit'});nsis.on('error', function (err) {if (err.message === 'spawn makensis ENOENT') {throw "Can't find NSIS. Are you sure you've installed it and"+ " added to PATH environment variable?";} else {throw err;}});nsis.on('close', function () {deferred.resolve();});return deferred.promise;}

You should have NSIS installed, and should be available in your path. creaeInstaller function reads installer script and execute it against NSIS runtim with makensis command.

您应该已经安装了NSIS,并且在您的路径中应该可用。 creaeInstaller函数读取安装程序脚本,并使用makensis命令针对NSIS runtim执行该脚本。

放在一起 (Putting It All Together)

Create a function to put all pieces together, then export it to be accessed from gulp task:

创建一个将所有部分放在一起的函数,然后将其导出以从gulp任务中进行访问:

function build() { return init().then(copyElectron) .then(cleanupRuntime) .then(createAsar) .then(updateResources) .then(rename) .then(createInstaller); }module.exports = { build: build };

Next create gulp task in gulpfile.js to execute this build script:

接下来在gulpfile.js创建gulpfile.js任务以执行以下构建脚本:

var release_windows = require('./build.windows'); var os = require('os'); gulp.task('build-electron', ['build'], function () { switch (os.platform()) { case 'darwin': // execute build.osx.js break; case 'linux': //execute build.linux.js break; case 'win32': return release_windows.build(); } 
});

You can have your final product by running:

您可以通过运行以下命令获得最终产品:

gulp build-electron

Your final electron application should be in dist folder and folder structure should be some thing similar to following.

您最终的电子应用程序应位于dist文件夹中,并且文件夹结构应类似于以下内容。

dist-structure

摘要 (Summary)

Electron is not just a native web view that let's you to wrap your web application into desktop application . It now includes automatic app updates, Windows installers, crash reporting, notifications, and other useful native app features — all exposed through JavaScript APIs.

Electron不仅是一种本地Web视图,还可以让您将Web应用程序包装到桌面应用程序中。 现在,它包括自动应用程序更新,Windows安装程序,崩溃报告,通知和其他有用的本机应用程序功能-所有这些功能都通过JavaScript API公开。

So far there is huge range of apps created using electron including chat apps, database explorers, map designers, collaborative design tools, and mobile prototyping apps.

到目前为止,有大量使用电子工具创建的应用程序,包括聊天应用程序,数据库浏览器,地图设计师,协作设计工具以及移动原型应用程序。

Here is some useful resources about Github Electron:

这是有关Github Electron的一些有用资源:

  • Official Site - http://electron.atom.io/

    官方网站-http://electron.atom.io/
  • Official Docs - https://github.com/atom/electron/tree/master/docs

    官方文档-https: //github.com/atom/electron/tree/master/docs
  • Awesome Electron - https://github.com/sindresorhus/awesome-electron

    真棒电子-https: //github.com/sindresorhus/awesome-electron
  • Electron boilerplate application - https://github.com/szwacz/electron-boilerplate

    电子样板应用程序-https: //github.com/szwacz/electron-boilerplate
  • Electron boilerplate with ReactJs - https://github.com/airtoxin/Electron-React-Boilerplate

    具有ReactJs的电子样板-https: //github.com/airtoxin/Electron-React-Boilerplate
  • https://github.com/chentsulin/electron-react-boilerplate

    https://github.com/chentsulin/electron-react-boilerplate

翻译自: https://scotch.io/tutorials/creating-desktop-applications-with-angularjs-and-github-electron

github桌面应用下载慢

查看全文
如若内容造成侵权/违法违规/事实不符,请联系编程学习网邮箱:809451989@qq.com进行投诉反馈,一经查实,立即删除!

相关文章

  1. serverless 简介

    前言 最近关于 Serverless 的讨论越来越多。看似与前端关系不大的 Serverless&#xff0c;其实早已和前端有了颇深渊源&#xff0c;并且将掀起新的前端技术变革。此次分享根据个人理解和总结&#xff0c;从前端开发模式在serverless的演进、Serverless 常见服务商提供的解决方…...

    2024/4/20 14:43:51
  2. 初学angular2的一些总结 1.)

    先从模块库中引入组件import {Component} from “angular2/core”;import {bootstrap} from “angular2/platform/browser”; 然后定义组件 Component({ Selector:’my-app’, 这里的my-app是html上自己写的节点Selector:’[my-app]’, 这里的my-app是节点属性<any my-app…...

    2024/4/20 19:45:18
  3. angular7+实现前端生成验证码 canvas画图

    html&#xff1a; <li class"_3001_12_verification_code" id"loginMaskLi"><label><input id"loginmask" type"text" placeholder"不区分大小写"> </label><span (click) "initVerifyCo…...

    2024/5/3 3:22:21
  4. angular2 复制

    https://developer.mozilla.org/zh-CN/docs/Web/API/Document 这是一篇mozilla 的开发者账户&#xff0c;里面写的很详细&#xff0c;包括document 和 windows 对象都提供了怎么样的方法 // 点击复制 cope_input(){ let copyHttp this.ElementRef.nativeElement.querySelect…...

    2024/5/3 22:46:31
  5. 使用NativeScript和Angular2构建跨平台APP

    使用NativeScript和Angular2构建跨平台APP 前言 “一次构建&#xff0c;多处运行”&#xff0c;跨平台APP 带着这股风潮把火烧到了前端&#xff0c;为开发者带来无尽的遐想。现有的流行跨平台框架有以下: 1. 基于单WebView的开发框架。开发者可以使用现有的最新 web 技术&…...

    2024/4/21 4:39:57
  6. 最新免费计算机编程视频教程

    最新免费计算机编程视频教程 https://www.youtube.com/channel/UCAEDC_Ku-K6zTVpGi6kLS1g 嵌入式驱动开发环境搭建初级 Java For Android Eclipse IDE 使用技巧 Android 编码规范及代码风格 SVN & Git 版本控制 Android App 开发环境搭建和配置 Android App开发起手式-Hell…...

    2024/5/5 4:01:50
  7. 【Angular】Angular从入门到实战视频教程第三章

    【背景】 最近恶补前端基础知识&#xff0c;记录一下~ 【内容】 3.1 路由内容介绍 学习内容&#xff1a; 1、了解路由的基础知识 2、子路由、保护路由和辅助路由 3、在在线拍卖&#xff08;Auction&#xff09;项目中添加路由 作用&#xff1a;为每一个页面提供一个URL 控制…...

    2024/4/21 4:39:56
  8. Angular2.0视频教程来了!(视频和PPT的链接都在底部)

    原 荐 Angular2.0视频教程来了&#xff01;&#xff08;视频和PPT的链接都在底部&#xff09; 收藏 大漠穷秋 发表于 3个月前 阅读 43092 收藏 482 点赞 51 评论 83 【粉丝福利】&#xff1a;web前端基础到高级实战免费在线直播教学>>> 各位道友大家好&#xff1…...

    2024/4/21 4:39:53
  9. 前端全套教程视频推荐

    本套视频教程包括多套前端视频教程,从初级到中级到高级到资深,应有尽有。可以从零基础开始挨着学习,也可以根据自己情况自由安排学习。这套教程是比较适合自学的人群进行学习的&#xff0c;而且也都是免费开源的&#xff0c;不用花钱就可以进行系统学习。 前端全套教程视频学习…...

    2024/5/5 5:34:18
  10. Angular 入门教程系列:32:统计图表G2

    G2是蚂蚁金服下的一款开源可视化的前端组件库&#xff0c;使用G2可以很简单地根据数据创建出统计图表&#xff0c;这篇文章中会使用简单的例子来创建一个柱状图&#xff0c;用于显示某一星期七天不断出现的bug数目。 安装g2 从版本3开始&#xff0c;data-set进行了分离&#…...

    2024/4/27 11:23:29
  11. Angular cli升级报错解决方案

    报错 Local workspace file (angular.json) could not be found. Error: Local workspace file (angular.json) could not be found.at WorkspaceLoader._getProjectWorkspaceFilePath (/Users/next/projects/ng-projects/nhwc-admin/node_modules/angular/cli/models/workspa…...

    2024/4/21 4:39:50
  12. angular 配置i18n

    1.安装 . npm install ngx-translate/core --save npm install ngx-translate/http-loader  2. 配置&#xff08;app.module.ts&#xff09; import { BrowserModule } from angular/platform-browser; import { Inject, LOCALE_ID, NgModule } from angular/core; import …...

    2024/4/29 15:25:36
  13. Angular7开荒----集成Less

    如果需要用Angular7创建Less项目时&#xff0c;可以在创建项目时选择Less: 如果需要对已有项目集成Less,那么需要做两件事&#xff1a; 1、修改后缀名-----》将*.css文件以及引用处的后缀名改为.less; 2、在angular.json文件的schematics中添加如下配置&#xff1a; 配置代码&…...

    2024/4/21 4:39:48
  14. angular中配置sass的方法

    方法一&#xff1a; 1. 利用cnpm工具安装sass依赖和loader cnpm install node-sass --save-dev cnpm install sass-loader --save-dev 2. 修改.angular-cli.json文件 "styles": [ "styles.scss" ], "defaults":{ "styleExt": &q…...

    2024/4/21 4:39:47
  15. angular调用arcgis js api(esri-loader方式)

    angular调用arcgis&#xff0c;用typescript&#xff0c;通过esri-loader调用。 目前还没用npm的方式安装arcgis-js-api&#xff0c;还是通过下载到本地的方式实现。 1、下载最新的arcgis-js-api 解压放在angular代码src\assets\lib\esri\4.7下&#xff0c;更改init.js文件和do…...

    2024/5/1 8:54:24
  16. Angular的JS 缓存问题

    问题描述&#xff1a;.net mvc ng 项目&#xff0c;每个component&#xff0c;html页面第一次加载后都会产生本地缓存&#xff0c;存储下来&#xff0c;导致新的页面改动不能及时刷新出来。 解决方案&#xff0c;.net项目中自带一个版本文件&#xff0c;需要自己发布项目时自己…...

    2024/5/1 6:27:53
  17. angular directive和 webpack html-loader

    问题&#xff1a; angular 的 directive支持使用template 和 templateUrl两种方式来指定模板 template的方式需要把html的内容放在js里&#xff0c;虽然有es6字符串可以换行&#xff0c; 少了编辑器对html的智能补全比较不爽 templateUrl的方式对于纯静态托管的angular项目比较…...

    2024/5/1 10:49:54
  18. angular5 配置使用sass

    1、利用npm工具安装sass依赖和loadercnpm/npm install node-sass --save-devcnpm/npm install sass-loader --save-dev 2、修改.angular-cli.json文件 "styles": ["styles.scss" ], "defaults":{"styleExt": "scss","c…...

    2024/5/1 16:19:35
  19. 在基于angular/cli搭建的angular2项目中集成systemjs加载器

    在学习angular2教程时&#xff0c;里面的“英雄编辑器”实例项目在模拟服务&#xff08;内存 Web API&#xff09;中获取和保存数据时用到了In-Memory Web API&#xff0c;那么怎么将In-Memory Web API添加到systemjs加载器中呢&#xff1f; 1.打开package.json,添加依赖包&am…...

    2024/5/1 12:53:44
  20. 在使用@angular/cli创建的angular项目上添加postcss等一系列移动端自适应插件

    首先使用yarn或npm安装 angular-builders/custom-webpack&#xff0c;然后安装postcss-loader post-px-to-viewport postcss-flexbugs-fixes postcss-preset-env viewport-units-buggyfill. 在根目录下新建webpack文件夹&#xff0c;建立webpack.config.js&#xff0c;建立…...

    2024/5/1 10:05:47

最新文章

  1. 【leetcode】二叉树的构造题目总结

    108. 将有序数组转换为二叉搜索树 /*** Definition for a binary tree node.* struct TreeNode {* int val;* TreeNode *left;* TreeNode *right;* TreeNode() : val(0), left(nullptr), right(nullptr) {}* TreeNode(int x) : val(x), left(nullptr), ri…...

    2024/5/5 11:52:05
  2. 梯度消失和梯度爆炸的一些处理方法

    在这里是记录一下梯度消失或梯度爆炸的一些处理技巧。全当学习总结了如有错误还请留言&#xff0c;在此感激不尽。 权重和梯度的更新公式如下&#xff1a; w w − η ⋅ ∇ w w w - \eta \cdot \nabla w ww−η⋅∇w 个人通俗的理解梯度消失就是网络模型在反向求导的时候出…...

    2024/3/20 10:50:27
  3. 【APUE】网络socket编程温度采集智能存储与上报项目技术------多路复用

    作者简介&#xff1a; 一个平凡而乐于分享的小比特&#xff0c;中南民族大学通信工程专业研究生在读&#xff0c;研究方向无线联邦学习 擅长领域&#xff1a;驱动开发&#xff0c;嵌入式软件开发&#xff0c;BSP开发 作者主页&#xff1a;一个平凡而乐于分享的小比特的个人主页…...

    2024/5/4 0:45:42
  4. 字符串匹配算法之BF与KMP算法

    目录 BF算法(暴力匹配算法) KMP算法 核心思想&#xff1a; next数组 next数组的优化 BF算法(暴力匹配算法) #include <assert.h> int BF(const char* str, const char* sub) {assert(str ! NULL && sub ! NULL);if (str NULL || sub NULL){return -1;}int…...

    2024/5/4 9:41:01
  5. 【外汇早评】美通胀数据走低,美元调整

    原标题:【外汇早评】美通胀数据走低,美元调整昨日美国方面公布了新一期的核心PCE物价指数数据,同比增长1.6%,低于前值和预期值的1.7%,距离美联储的通胀目标2%继续走低,通胀压力较低,且此前美国一季度GDP初值中的消费部分下滑明显,因此市场对美联储后续更可能降息的政策…...

    2024/5/4 23:54:56
  6. 【原油贵金属周评】原油多头拥挤,价格调整

    原标题:【原油贵金属周评】原油多头拥挤,价格调整本周国际劳动节,我们喜迎四天假期,但是整个金融市场确实流动性充沛,大事频发,各个商品波动剧烈。美国方面,在本周四凌晨公布5月份的利率决议和新闻发布会,维持联邦基金利率在2.25%-2.50%不变,符合市场预期。同时美联储…...

    2024/5/4 23:54:56
  7. 【外汇周评】靓丽非农不及疲软通胀影响

    原标题:【外汇周评】靓丽非农不及疲软通胀影响在刚结束的周五,美国方面公布了新一期的非农就业数据,大幅好于前值和预期,新增就业重新回到20万以上。具体数据: 美国4月非农就业人口变动 26.3万人,预期 19万人,前值 19.6万人。 美国4月失业率 3.6%,预期 3.8%,前值 3…...

    2024/5/4 23:54:56
  8. 【原油贵金属早评】库存继续增加,油价收跌

    原标题:【原油贵金属早评】库存继续增加,油价收跌周三清晨公布美国当周API原油库存数据,上周原油库存增加281万桶至4.692亿桶,增幅超过预期的74.4万桶。且有消息人士称,沙特阿美据悉将于6月向亚洲炼油厂额外出售更多原油,印度炼油商预计将每日获得至多20万桶的额外原油供…...

    2024/5/4 23:55:17
  9. 【外汇早评】日本央行会议纪要不改日元强势

    原标题:【外汇早评】日本央行会议纪要不改日元强势近两日日元大幅走强与近期市场风险情绪上升,避险资金回流日元有关,也与前一段时间的美日贸易谈判给日本缓冲期,日本方面对汇率问题也避免继续贬值有关。虽然今日早间日本央行公布的利率会议纪要仍然是支持宽松政策,但这符…...

    2024/5/4 23:54:56
  10. 【原油贵金属早评】欧佩克稳定市场,填补伊朗问题的影响

    原标题:【原油贵金属早评】欧佩克稳定市场,填补伊朗问题的影响近日伊朗局势升温,导致市场担忧影响原油供给,油价试图反弹。此时OPEC表态稳定市场。据消息人士透露,沙特6月石油出口料将低于700万桶/日,沙特已经收到石油消费国提出的6月份扩大出口的“适度要求”,沙特将满…...

    2024/5/4 23:55:05
  11. 【外汇早评】美欲与伊朗重谈协议

    原标题:【外汇早评】美欲与伊朗重谈协议美国对伊朗的制裁遭到伊朗的抗议,昨日伊朗方面提出将部分退出伊核协议。而此行为又遭到欧洲方面对伊朗的谴责和警告,伊朗外长昨日回应称,欧洲国家履行它们的义务,伊核协议就能保证存续。据传闻伊朗的导弹已经对准了以色列和美国的航…...

    2024/5/4 23:54:56
  12. 【原油贵金属早评】波动率飙升,市场情绪动荡

    原标题:【原油贵金属早评】波动率飙升,市场情绪动荡因中美贸易谈判不安情绪影响,金融市场各资产品种出现明显的波动。随着美国与中方开启第十一轮谈判之际,美国按照既定计划向中国2000亿商品征收25%的关税,市场情绪有所平复,已经开始接受这一事实。虽然波动率-恐慌指数VI…...

    2024/5/4 23:55:16
  13. 【原油贵金属周评】伊朗局势升温,黄金多头跃跃欲试

    原标题:【原油贵金属周评】伊朗局势升温,黄金多头跃跃欲试美国和伊朗的局势继续升温,市场风险情绪上升,避险黄金有向上突破阻力的迹象。原油方面稍显平稳,近期美国和OPEC加大供给及市场需求回落的影响,伊朗局势并未推升油价走强。近期中美贸易谈判摩擦再度升级,美国对中…...

    2024/5/4 23:54:56
  14. 【原油贵金属早评】市场情绪继续恶化,黄金上破

    原标题:【原油贵金属早评】市场情绪继续恶化,黄金上破周初中国针对于美国加征关税的进行的反制措施引发市场情绪的大幅波动,人民币汇率出现大幅的贬值动能,金融市场受到非常明显的冲击。尤其是波动率起来之后,对于股市的表现尤其不安。隔夜美国股市出现明显的下行走势,这…...

    2024/5/4 18:20:48
  15. 【外汇早评】美伊僵持,风险情绪继续升温

    原标题:【外汇早评】美伊僵持,风险情绪继续升温昨日沙特两艘油轮再次发生爆炸事件,导致波斯湾局势进一步恶化,市场担忧美伊可能会出现摩擦生火,避险品种获得支撑,黄金和日元大幅走强。美指受中美贸易问题影响而在低位震荡。继5月12日,四艘商船在阿联酋领海附近的阿曼湾、…...

    2024/5/4 23:54:56
  16. 【原油贵金属早评】贸易冲突导致需求低迷,油价弱势

    原标题:【原油贵金属早评】贸易冲突导致需求低迷,油价弱势近日虽然伊朗局势升温,中东地区几起油船被袭击事件影响,但油价并未走高,而是出于调整结构中。由于市场预期局势失控的可能性较低,而中美贸易问题导致的全球经济衰退风险更大,需求会持续低迷,因此油价调整压力较…...

    2024/5/4 23:55:17
  17. 氧生福地 玩美北湖(上)——为时光守候两千年

    原标题:氧生福地 玩美北湖(上)——为时光守候两千年一次说走就走的旅行,只有一张高铁票的距离~ 所以,湖南郴州,我来了~ 从广州南站出发,一个半小时就到达郴州西站了。在动车上,同时改票的南风兄和我居然被分到了一个车厢,所以一路非常愉快地聊了过来。 挺好,最起…...

    2024/5/4 23:55:06
  18. 氧生福地 玩美北湖(中)——永春梯田里的美与鲜

    原标题:氧生福地 玩美北湖(中)——永春梯田里的美与鲜一觉醒来,因为大家太爱“美”照,在柳毅山庄去寻找龙女而错过了早餐时间。近十点,向导坏坏还是带着饥肠辘辘的我们去吃郴州最富有盛名的“鱼头粉”。说这是“十二分推荐”,到郴州必吃的美食之一。 哇塞!那个味美香甜…...

    2024/5/4 23:54:56
  19. 氧生福地 玩美北湖(下)——奔跑吧骚年!

    原标题:氧生福地 玩美北湖(下)——奔跑吧骚年!让我们红尘做伴 活得潇潇洒洒 策马奔腾共享人世繁华 对酒当歌唱出心中喜悦 轰轰烈烈把握青春年华 让我们红尘做伴 活得潇潇洒洒 策马奔腾共享人世繁华 对酒当歌唱出心中喜悦 轰轰烈烈把握青春年华 啊……啊……啊 两…...

    2024/5/4 23:55:06
  20. 扒开伪装医用面膜,翻六倍价格宰客,小姐姐注意了!

    原标题:扒开伪装医用面膜,翻六倍价格宰客,小姐姐注意了!扒开伪装医用面膜,翻六倍价格宰客!当行业里的某一品项火爆了,就会有很多商家蹭热度,装逼忽悠,最近火爆朋友圈的医用面膜,被沾上了污点,到底怎么回事呢? “比普通面膜安全、效果好!痘痘、痘印、敏感肌都能用…...

    2024/5/5 8:13:33
  21. 「发现」铁皮石斛仙草之神奇功效用于医用面膜

    原标题:「发现」铁皮石斛仙草之神奇功效用于医用面膜丽彦妆铁皮石斛医用面膜|石斛多糖无菌修护补水贴19大优势: 1、铁皮石斛:自唐宋以来,一直被列为皇室贡品,铁皮石斛生于海拔1600米的悬崖峭壁之上,繁殖力差,产量极低,所以古代仅供皇室、贵族享用 2、铁皮石斛自古民间…...

    2024/5/4 23:55:16
  22. 丽彦妆\医用面膜\冷敷贴轻奢医学护肤引导者

    原标题:丽彦妆\医用面膜\冷敷贴轻奢医学护肤引导者【公司简介】 广州华彬企业隶属香港华彬集团有限公司,专注美业21年,其旗下品牌: 「圣茵美」私密荷尔蒙抗衰,产后修复 「圣仪轩」私密荷尔蒙抗衰,产后修复 「花茵莳」私密荷尔蒙抗衰,产后修复 「丽彦妆」专注医学护…...

    2024/5/4 23:54:58
  23. 广州械字号面膜生产厂家OEM/ODM4项须知!

    原标题:广州械字号面膜生产厂家OEM/ODM4项须知!广州械字号面膜生产厂家OEM/ODM流程及注意事项解读: 械字号医用面膜,其实在我国并没有严格的定义,通常我们说的医美面膜指的应该是一种「医用敷料」,也就是说,医用面膜其实算作「医疗器械」的一种,又称「医用冷敷贴」。 …...

    2024/5/4 23:55:01
  24. 械字号医用眼膜缓解用眼过度到底有无作用?

    原标题:械字号医用眼膜缓解用眼过度到底有无作用?医用眼膜/械字号眼膜/医用冷敷眼贴 凝胶层为亲水高分子材料,含70%以上的水分。体表皮肤温度传导到本产品的凝胶层,热量被凝胶内水分子吸收,通过水分的蒸发带走大量的热量,可迅速地降低体表皮肤局部温度,减轻局部皮肤的灼…...

    2024/5/4 23:54:56
  25. 配置失败还原请勿关闭计算机,电脑开机屏幕上面显示,配置失败还原更改 请勿关闭计算机 开不了机 这个问题怎么办...

    解析如下&#xff1a;1、长按电脑电源键直至关机&#xff0c;然后再按一次电源健重启电脑&#xff0c;按F8健进入安全模式2、安全模式下进入Windows系统桌面后&#xff0c;按住“winR”打开运行窗口&#xff0c;输入“services.msc”打开服务设置3、在服务界面&#xff0c;选中…...

    2022/11/19 21:17:18
  26. 错误使用 reshape要执行 RESHAPE,请勿更改元素数目。

    %读入6幅图像&#xff08;每一幅图像的大小是564*564&#xff09; f1 imread(WashingtonDC_Band1_564.tif); subplot(3,2,1),imshow(f1); f2 imread(WashingtonDC_Band2_564.tif); subplot(3,2,2),imshow(f2); f3 imread(WashingtonDC_Band3_564.tif); subplot(3,2,3),imsho…...

    2022/11/19 21:17:16
  27. 配置 已完成 请勿关闭计算机,win7系统关机提示“配置Windows Update已完成30%请勿关闭计算机...

    win7系统关机提示“配置Windows Update已完成30%请勿关闭计算机”问题的解决方法在win7系统关机时如果有升级系统的或者其他需要会直接进入一个 等待界面&#xff0c;在等待界面中我们需要等待操作结束才能关机&#xff0c;虽然这比较麻烦&#xff0c;但是对系统进行配置和升级…...

    2022/11/19 21:17:15
  28. 台式电脑显示配置100%请勿关闭计算机,“准备配置windows 请勿关闭计算机”的解决方法...

    有不少用户在重装Win7系统或更新系统后会遇到“准备配置windows&#xff0c;请勿关闭计算机”的提示&#xff0c;要过很久才能进入系统&#xff0c;有的用户甚至几个小时也无法进入&#xff0c;下面就教大家这个问题的解决方法。第一种方法&#xff1a;我们首先在左下角的“开始…...

    2022/11/19 21:17:14
  29. win7 正在配置 请勿关闭计算机,怎么办Win7开机显示正在配置Windows Update请勿关机...

    置信有很多用户都跟小编一样遇到过这样的问题&#xff0c;电脑时发现开机屏幕显现“正在配置Windows Update&#xff0c;请勿关机”(如下图所示)&#xff0c;而且还需求等大约5分钟才干进入系统。这是怎样回事呢&#xff1f;一切都是正常操作的&#xff0c;为什么开时机呈现“正…...

    2022/11/19 21:17:13
  30. 准备配置windows 请勿关闭计算机 蓝屏,Win7开机总是出现提示“配置Windows请勿关机”...

    Win7系统开机启动时总是出现“配置Windows请勿关机”的提示&#xff0c;没过几秒后电脑自动重启&#xff0c;每次开机都这样无法进入系统&#xff0c;此时碰到这种现象的用户就可以使用以下5种方法解决问题。方法一&#xff1a;开机按下F8&#xff0c;在出现的Windows高级启动选…...

    2022/11/19 21:17:12
  31. 准备windows请勿关闭计算机要多久,windows10系统提示正在准备windows请勿关闭计算机怎么办...

    有不少windows10系统用户反映说碰到这样一个情况&#xff0c;就是电脑提示正在准备windows请勿关闭计算机&#xff0c;碰到这样的问题该怎么解决呢&#xff0c;现在小编就给大家分享一下windows10系统提示正在准备windows请勿关闭计算机的具体第一种方法&#xff1a;1、2、依次…...

    2022/11/19 21:17:11
  32. 配置 已完成 请勿关闭计算机,win7系统关机提示“配置Windows Update已完成30%请勿关闭计算机”的解决方法...

    今天和大家分享一下win7系统重装了Win7旗舰版系统后&#xff0c;每次关机的时候桌面上都会显示一个“配置Windows Update的界面&#xff0c;提示请勿关闭计算机”&#xff0c;每次停留好几分钟才能正常关机&#xff0c;导致什么情况引起的呢&#xff1f;出现配置Windows Update…...

    2022/11/19 21:17:10
  33. 电脑桌面一直是清理请关闭计算机,windows7一直卡在清理 请勿关闭计算机-win7清理请勿关机,win7配置更新35%不动...

    只能是等着&#xff0c;别无他法。说是卡着如果你看硬盘灯应该在读写。如果从 Win 10 无法正常回滚&#xff0c;只能是考虑备份数据后重装系统了。解决来方案一&#xff1a;管理员运行cmd&#xff1a;net stop WuAuServcd %windir%ren SoftwareDistribution SDoldnet start WuA…...

    2022/11/19 21:17:09
  34. 计算机配置更新不起,电脑提示“配置Windows Update请勿关闭计算机”怎么办?

    原标题&#xff1a;电脑提示“配置Windows Update请勿关闭计算机”怎么办&#xff1f;win7系统中在开机与关闭的时候总是显示“配置windows update请勿关闭计算机”相信有不少朋友都曾遇到过一次两次还能忍但经常遇到就叫人感到心烦了遇到这种问题怎么办呢&#xff1f;一般的方…...

    2022/11/19 21:17:08
  35. 计算机正在配置无法关机,关机提示 windows7 正在配置windows 请勿关闭计算机 ,然后等了一晚上也没有关掉。现在电脑无法正常关机...

    关机提示 windows7 正在配置windows 请勿关闭计算机 &#xff0c;然后等了一晚上也没有关掉。现在电脑无法正常关机以下文字资料是由(历史新知网www.lishixinzhi.com)小编为大家搜集整理后发布的内容&#xff0c;让我们赶快一起来看一下吧&#xff01;关机提示 windows7 正在配…...

    2022/11/19 21:17:05
  36. 钉钉提示请勿通过开发者调试模式_钉钉请勿通过开发者调试模式是真的吗好不好用...

    钉钉请勿通过开发者调试模式是真的吗好不好用 更新时间:2020-04-20 22:24:19 浏览次数:729次 区域: 南阳 > 卧龙 列举网提醒您:为保障您的权益,请不要提前支付任何费用! 虚拟位置外设器!!轨迹模拟&虚拟位置外设神器 专业用于:钉钉,外勤365,红圈通,企业微信和…...

    2022/11/19 21:17:05
  37. 配置失败还原请勿关闭计算机怎么办,win7系统出现“配置windows update失败 还原更改 请勿关闭计算机”,长时间没反应,无法进入系统的解决方案...

    前几天班里有位学生电脑(windows 7系统)出问题了&#xff0c;具体表现是开机时一直停留在“配置windows update失败 还原更改 请勿关闭计算机”这个界面&#xff0c;长时间没反应&#xff0c;无法进入系统。这个问题原来帮其他同学也解决过&#xff0c;网上搜了不少资料&#x…...

    2022/11/19 21:17:04
  38. 一个电脑无法关闭计算机你应该怎么办,电脑显示“清理请勿关闭计算机”怎么办?...

    本文为你提供了3个有效解决电脑显示“清理请勿关闭计算机”问题的方法&#xff0c;并在最后教给你1种保护系统安全的好方法&#xff0c;一起来看看&#xff01;电脑出现“清理请勿关闭计算机”在Windows 7(SP1)和Windows Server 2008 R2 SP1中&#xff0c;添加了1个新功能在“磁…...

    2022/11/19 21:17:03
  39. 请勿关闭计算机还原更改要多久,电脑显示:配置windows更新失败,正在还原更改,请勿关闭计算机怎么办...

    许多用户在长期不使用电脑的时候&#xff0c;开启电脑发现电脑显示&#xff1a;配置windows更新失败&#xff0c;正在还原更改&#xff0c;请勿关闭计算机。。.这要怎么办呢&#xff1f;下面小编就带着大家一起看看吧&#xff01;如果能够正常进入系统&#xff0c;建议您暂时移…...

    2022/11/19 21:17:02
  40. 还原更改请勿关闭计算机 要多久,配置windows update失败 还原更改 请勿关闭计算机,电脑开机后一直显示以...

    配置windows update失败 还原更改 请勿关闭计算机&#xff0c;电脑开机后一直显示以以下文字资料是由(历史新知网www.lishixinzhi.com)小编为大家搜集整理后发布的内容&#xff0c;让我们赶快一起来看一下吧&#xff01;配置windows update失败 还原更改 请勿关闭计算机&#x…...

    2022/11/19 21:17:01
  41. 电脑配置中请勿关闭计算机怎么办,准备配置windows请勿关闭计算机一直显示怎么办【图解】...

    不知道大家有没有遇到过这样的一个问题&#xff0c;就是我们的win7系统在关机的时候&#xff0c;总是喜欢显示“准备配置windows&#xff0c;请勿关机”这样的一个页面&#xff0c;没有什么大碍&#xff0c;但是如果一直等着的话就要两个小时甚至更久都关不了机&#xff0c;非常…...

    2022/11/19 21:17:00
  42. 正在准备配置请勿关闭计算机,正在准备配置windows请勿关闭计算机时间长了解决教程...

    当电脑出现正在准备配置windows请勿关闭计算机时&#xff0c;一般是您正对windows进行升级&#xff0c;但是这个要是长时间没有反应&#xff0c;我们不能再傻等下去了。可能是电脑出了别的问题了&#xff0c;来看看教程的说法。正在准备配置windows请勿关闭计算机时间长了方法一…...

    2022/11/19 21:16:59
  43. 配置失败还原请勿关闭计算机,配置Windows Update失败,还原更改请勿关闭计算机...

    我们使用电脑的过程中有时会遇到这种情况&#xff0c;当我们打开电脑之后&#xff0c;发现一直停留在一个界面&#xff1a;“配置Windows Update失败&#xff0c;还原更改请勿关闭计算机”&#xff0c;等了许久还是无法进入系统。如果我们遇到此类问题应该如何解决呢&#xff0…...

    2022/11/19 21:16:58
  44. 如何在iPhone上关闭“请勿打扰”

    Apple’s “Do Not Disturb While Driving” is a potentially lifesaving iPhone feature, but it doesn’t always turn on automatically at the appropriate time. For example, you might be a passenger in a moving car, but your iPhone may think you’re the one dri…...

    2022/11/19 21:16:57