jenkins 构建api

TL;DR There are lots of JavaScript frameworks out there and it can be overwhelming to keep up with all of them. SailsJs is a Node.js MVC framework. Currently, SailsJs has over 15,000 stars on GitHub. In this tutorial, I'll show you how easy it is to build a web application with SailsJs and add authentication to it. Check out the repo to get the code.

TL; DR那里有很多JavaScript框架,要跟上所有框架的工作可能会让人不知所措。 SailsJs是一个Node.js MVC框架。 目前,SailsJs在GitHub上拥有超过15,000个星星。 在本教程中,我将向您展示使用SailsJs构建Web应用程序并向其添加身份验证是多么容易。 查看仓库以获取代码。

SailsJs is a Node.js framework that is designed to emulate the familiar MVC pattern of frameworks like Ruby on Rails and Laravel, but with support for modern apps architecture such as building data-driven APIs and realtime apps. SailsJs saves you time and effort because it is designed for building practical, production-ready Node.js apps in a matter of weeks and ships with a lot of features out of the box. These features include the following:

SailsJs是一个Node.js框架,旨在模仿Ruby on Rails和Laravel等框架的熟悉的MVC模式,但支持现代应用程序体系结构,例如构建数据驱动的API和实时应用程序。 SailsJs节省了您的时间和精力,因为它旨在在数周内构建实用的,可投入生产的Node.js应用程序,并且具有许多现成的功能。 这些功能包括:

  • Waterline ORM

    水线ORM
  • Rest APIs Generator

    REST API生成器
  • WebSocket Support

    WebSocket支持
  • Policies ( Effective role-based access control)

    策略(基于角色的有效访问控制)
  • Flexible Asset Pipeline

    灵活资产管道

SailsJs makes good use of already written and well-tested modules from the JavaScript community. The documentation is very detailed, and there is a vibrant community of users and collaborators who engage on Gitter, Google Forum, and IRC.

SailsJs充分利用了JavaScript社区中已编写且经过测试的模块。 该文档非常详细,并且有一个活跃的用户和协作者社区,他们参与了Gitter , Google Forum和IRC 。

我们将构建什么:报价清单应用程序 ( What We'll Build: A Quote Listing App )

We'll be building a simple application that retrieves Chuck Norris quotes from a NodeJS backend with SailsJs. Scratch that, we’ll build our own Chuck Norris API. Once we add authentication to the app, all logged-in users will have the privilege of getting access to a set of private quotes.

我们将构建一个简单的应用程序,该应用程序使用SailsJsNodeJS后端检索Chuck Norris报价。 首先,我们将构建自己的Chuck Norris API。 将身份验证添加到应用程序后,所有登录的用户都将有权访问一组私人报价。

探索目录结构 ( Exploring the Directory Structure )

A typical SailsJS application has the following structure:

典型的SailsJS应用程序具有以下结构:

├── api │ ├── controllers │ ├── models │ ├── policies │ ├── responses │ └── services ├── assets │ ├── images │ ├── js │ │ └── dependencies │ ├── styles │ └── templates ├── config │ ├── env │ └── locales ├── node_modules │ ├── ejs │ ├── grunt │ ├── grunt-contrib-clean │ ├── rc │ ├── sails │ └── sails-disk ├── tasks │ ├── config │ └── register └── views

├──API│├──控制器│├──模型│├──策略│├──响应│└──服务├──资产│├──图像│├──js││└── ├──样式│└──模板├──配置│├──env│└──语言环境├──节点模块│├──ejs│├──grunt│├──grunt-contrib-clean│├── rc│├──风帆│└──风帆盘├──任务│├──配置│└──注册└──视图

The api directory constitutes the “M” and “C” in a typical MVC framework. In a nutshell,

api目录在典型的MVC框架中构成“ M”和“ C”。 简而言之,

  • Models query your database and return the necessary data.

    模型查询您的数据库并返回必要的数据。
  • Views are pages that render data. In SailsJs, they are .ejs template files.

    视图是呈现数据的页面。 在SailsJs中,它们是.ejs模板文件。
  • Controllers handle user requests, retrieve data from the models and pass them on to the views.

    控制器处理用户请求,从模型中检索数据,并将其传递给视图。
  • Policies are used to restrict access to certain parts of your app. It can be used for anything: HTTP Basic Auth, 3rd party Single Sign on, OAuth 2.0 or your own custom authorization scheme. ** Services** are more like helpers that you can write once and use anywhere in your app. They are globalised by default, so you don’t need to require them.

    策略用于限制对应用程序某些部分的访问。 它可以用于任何事物:HTTP基本身份验证,第三方单点登录,OAuth 2.0或您自己的自定义授权方案。 **服务**更像是助手,您可以编写一次并在应用程序中的任何位置使用。 默认情况下它们是全球化的,因此您不需要它们。

让我们开始吧。 ( Let's Get Started. )

SailsJs uses Npm to manage its dependencies. So, before using SailsJs, make sure you have node and npm installed on your machine. We can install the latest release of SailsJs from the command line like so:

SailsJs使用NPM来管理其依赖关系。 因此,在使用SailsJs之前,请确保已在计算机上安装了node和npm 。 我们可以从命令行安装最新版本的SailsJs ,如下所示:

npm -g install sails

Once it is installed, we can now create a new app from the command line like so:

安装之后,我们现在可以从命令行创建一个新应用,如下所示:

sails new appcd app
sails lift

sails lift starts the web server and points you to the url where the app is currently been served.

sails lift启动Web服务器,然后将您指向当前为该应用程序提供服务的URL。

Read more about the anatomy of a sails app here

在此处阅读更多有关Sails应用程序的剖析

设置路线 ( Setting Up the Routes )

Sailsjs has a beautiful way of quickly generating API routes and actions based on your application design called Blueprints. The SailsJs Blueprint API powers the restful API that is obtained anytime a model and controller is created. For example, if you create a Task.js model and TaskController.js controller file in your project, blueprints will give you the ability to visit this url /task/create?id=1&name=code to create a new task. The local sails-disk db is used by default, so you don’t even have to worry about a data store just yet. Wow, just awesome!!!!

Sailsjs具有一种漂亮的方法,可以根据您的应用程序设计(称为蓝图)快速生成API路由和操作。 SailsJs蓝图API支持在创建模型和控制器时就获得的Restful API。 例如,如果您在项目中创建Task.js模型和TaskController.js控制器文件,则蓝图将使您能够访问此url / task / create?id = 1&name = code来创建新任务。 默认情况下使用本地的sails-disk db,因此您甚至不必担心数据存储。 哇,真棒!

Blueprints are great for prototyping. They can be easily enabled and disabled anytime.

蓝图非常适合制作原型。 它们可以随时轻松启用和禁用。

SailsJs ships with a scaffolding tool that you can use to generate your controller and model files easily with for an api resource.

SailsJs附带了一个脚手架工具,您可以使用该工具轻松地为api资源生成控制器和模型文件。

Running the command above creates a Task.js model and a TaskController.js controller file. For this project, we’ll manually create our files and routes. Open up config/routes.js and add this to the routes like so:

运行上面的命令将创建一个Task.js模型和一个TaskController.js控制器文件。 对于此项目,我们将手动创建文件和路由。 打开config / routes.js并将其添加到路由中,如下所示:

'get /api/random-quote': 'QuoteController.getQuote',
'get /api/protected/random-quote': 'QuoteController.getProtectedQuote'

Once a user hits those routes, the QuoteController is invoked, then the respective actions are responsible for processing the incoming requests and returning a response back to the client. Next, let’s set it up!

一旦用户点击了这些路由,QuoteController就会被调用,然后各自的动作负责处理传入的请求并将响应返回给客户端。 接下来,让我们进行设置!

设置控制器 ( Setting Up the Controllers )

Open up api/controllers directory and create a QuoteController.js file like so:

打开api / controllers目录,并创建一个QuoteController.js文件,如下所示:

/*** QuoteController** @description :: Server-side logic for managing quotes* @help        :: See http://sailsjs.org/#!/documentation/concepts/Controllers*/module.exports = {getQuote: function(req, res) {return res.json({ quote: quoter.getRandomOne() });},getProtectedQuote: function(req, res) {return res.json({ quote: quoter.getRandomOne() });}
};

By convention, Sails controllers are Pascal-based. For example, you must define your controllers like the following: TaskController.js, ItemController.js. If you have experience with using ExpressJs, you will discover that the syntax is very familiar. Well, SailsJs is built on top of ExpressJs!

按照惯例,Sails控制器基于Pascal。 例如,您必须像以下那样定义控制器:TaskController.js,ItemController.js。 如果您有使用ExpressJ的经验,您会发现该语法非常熟悉。 好吧,SailsJs是基于ExpressJs构建的!

Note: You can also scaffold your controllers with action names like so:

注意:您还可以使用以下操作名称来构造控制器:

Now, where is quoter.getRandomOne coming from? quoter is a custom Sails service, getRandomOne is a method from the service. Let’s go ahead and create the service.

现在,quoter.getRandomOne来自哪里? quoter是自定义的Sails服务,getRandomOne是该服务中的方法。 让我们继续创建服务。

设置服务 ( Setting up the Service )

Services are simply functions( helpers ) that you can use anywhere in your app. They are globalized by default like I mentioned earlier. Open up api/services directory and create a quoter.js file like so:

服务只是您可以在应用程序中的任何位置使用的简单功能(助手)。 正如我前面提到的,它们默认情况下是全球化的。 打开api / services目录并创建一个quoter.js文件,如下所示:

var quotes = require('./quotes.json');module.exports.getRandomOne = function() {var totalAmount = quotes.length;var rand = Math.floor(Math.random() * totalAmount);return quotes[rand];
}

Create a quotes.json file within that directory and dump this array of quotes in it. It’s that simple!!!

在该目录中创建一个quotes.json文件,并将此引号数组转储到其中。 就这么简单!!!

Let’s test our API routes with Postman. In my opinion, Postman is one of the best tools on the planet for testing your APIs during development. Run sails lift from your console and put the API url in your postman like so:

让我们用Postman测试我们的API路由。 我认为,Postman是地球上用于在开发过程中测试API的最佳工具之一。 从控制台运行sails lift ,将API网址放入邮递员中,如下所示:

Do the same for /api/protected/random-quote. We can now access our quotes from these two routes. The next phase is to protect the second route /api/protected/random-quote. We need some form of Authorization that will run as a middleware to verify that a particular user can access that route. SailsJS has an inbuilt Access-control-logic system called Policies.

对/ api / protected / random-quote进行相同的操作。 现在,我们可以从这两条路线访问报价。 下一阶段是保护第二条路由/ api / protected / random-quote。 我们需要某种形式的授权,可以作为中间件运行,以验证特定用户可以访问该路由。 SailsJS有一个内置的访问控制逻辑系统,称为Policy。

设定政策 ( Setting Up Policies )

Policies are simply Sails way of authorizing and granting access control. They let you allow or deny access to your controllers. Open up api/policies directory and create the file isAuthenticated.js like so:

策略只是Sails授权和授予访问控制的方式。 它们允许您允许或拒绝对控制器的访问。 打开api / policies目录并创建文件isAuthenticated.js,如下所示:

/*** isAuthenticated**/
var jwt = require('express-jwt');var authCheck = jwt({secret: new Buffer('AUTH0_CLIENT_SECRET', 'base64'),audience: 'AUTH0_CLIENT_ID'
});module.exports = authCheck;

Make sure you quickly npm install express-jwt to ensure that module exists. Auth0 is an authentication and authorization platform that you can use to easily secure your APIs. When signing up for an account, you will need to give your app a domain name which cannot be changed later. Since you can have multiple apps under the same account, how you name your domain will depend on your situation. In most cases, it’s best to name it with something that is relevant to your organization, such as your company’s name. If it makes sense, you can also use your application’s name–it’s up to you.

确保您快速npm install express-jwt以确保该模块存在。 Auth0是可用于轻松保护API的身份验证和授权平台。 注册帐户时,您需要为您的应用提供一个域名,以后无法更改。 由于您可以在同一个帐户下拥有多个应用程序,因此如何命名域取决于您的情况。 在大多数情况下,最好使用与您的组织相关的名称来命名它,例如公司名称。 如果可行,您也可以使用应用程序的名称-由您自己决定。

Your Auth0 domain takes the pattern your-domain.auth0.com and is used when configuring the Auth0 tools that we’ll see below. Once you’ve signed up, you’ll be asked what kind of authentication you’d like for your application. It’s fine to leave the defaults in place, as you’ll be able to change them later. After you have signed up, head over to your dashboard to check things out. If you click the Apps / APIs link in the left sidebar, you’ll see that your account gets created with a Default App. Click the Default App to see your credentials and other details.

您的Auth0域采用的格式为your-domain.auth0.com,并在配置Auth0工具时使用,我们将在下面看到。 注册后,系统会询问您要对应用程序进行哪种身份验证。 可以保留默认值,因为以后可以更改它们。 注册后,转到仪表板签出内容。 如果单击左侧栏中的“应用程序/ API”链接,则会看到您的帐户是使用默认应用程序创建的。 单击默认应用程序以查看您的凭据和其他详细信息。

So, replace AUTH0_CLIENT_ID and AUTH0_CLIENT_SECRET with the real values. Next, we need to map the isAuthenticated policy to the QuoteController.

因此,将AUTH0_CLIENT_ID和AUTH0_CLIENT_SECRET替换为实际值。 接下来,我们需要将isAuthenticated策略映射到QuoteController。

Note: Allowed Callback URLS and Allowed Origins should also be filled with the proper URLS. If you are running on port 3000, it will be http://localhost:3000/

注意:“允许的回调URL”和“允许的来源”也应填写正确的URL。 如果您在端口3000上运行,它将为http:// localhost:3000 /

Open up config/policies.js and add this like so:

打开config / policies.js并像这样添加:

module.exports.policies = {/****************************************************************************                                                                          ** Default policy for all controllers and actions (`true` allows public     ** access)                                                                  **                                                                          ****************************************************************************/'*': true,QuoteController: {getProtectedQuote: 'isAuthenticated'}
};

Policies.js

Policies.js

So, the isAuthenticated policy will run just before the getProtectedQuote action of the QuoteController is invoked.

因此,isAuthenticated策略将在调用QuoteController的getProtectedQuote操作之前运行。

Now, try to access /api/protected/random-quote without a valid token!

现在,尝试在没有有效令牌的情况下访问/ api / protected / random-quote!

Note: Open up config/cors.js and make sure you it is configured like this to avoid CORS errors & preflight request errors.

注:打开配置/ cors.js并确保它被配置像这样以避免CORS错误和预检请求错误。

Aha!, We were denied access. Auth0 has secured our API. Next, let’s build the frontend to communicate with the API.

啊!,我们被拒绝了。 Auth0已保护我们的API。 接下来,让我们构建与API通信的前端。

建立前端 ( Build The Frontend )

We’ll use Angular 1.x to quickly build out the frontend to communicate with our quotes API.

我们将使用Angular 1.x快速构建前端以与我们的Quotes API通信。

Within the project directory, create a folder called angular. Move into the directory & run npm init to create a package.json file. Now, go ahead and install the following dependencies

在项目目录中,创建一个名为angular的文件夹。 移至目录并运行npm init来创建package.json文件。 现在,继续安装以下依赖项

# Angular related modules
npm install angular angular-material angular-ui-router angular-aria angular-animate# Auth0 related modules
npm install angular-jwt angular-storage auth0-angular# To serve the app (if not already installed)
npm install -g http-server

Next, let’s set up our app.js and index.html files to bootstrap the application. At this time we can let Angular know which modules we need access to from the dependencies we installed.

接下来,让我们设置app.js和index.html文件以引导应用程序。 此时,我们可以让Angular从安装的依赖项中知道我们需要访问哪些模块。

(function() {'use strict';angular.module('authApp', ['auth0', 'angular-storage', 'angular-jwt', 'ngMaterial', 'ui.router']).config(function($provide, authProvider, $urlRouterProvider, $stateProvider, $httpProvider, jwtInterceptorProvider) {authProvider.init({domain: 'YOUR_AUTH0_DOMAIN',clientID: 'YOUR_AUTH0_CLIENT_ID'});});
})();

Here we’ve configured authProvider from auth0-angular with our credentials from the dashboard. Of course, you’ll want to replace the values in the sample with your own credentials.

在这里,我们使用仪表板中的凭据从auth0-angular配置了authProvider。 当然,您需要使用自己的凭据替换示例中的值。

<!DOCTYPE html>
<html lang="en" ng-app="authApp">
<head><meta charset="UTF-8"><title>Get Chuck Norris Quotes</title><link rel="stylesheet" href="node_modules/angular-material/angular-material.css"><!-- Auth0 Lock script and AngularJS module --><script src="//cdn.auth0.com/js/lock-9.2.min.js"></script><!-- Setting the right viewport --><meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
</head>
<body><!-- TODO: create the toolbar and ui-view --><script src="node_modules/angular/angular.js"></script><script src="node_modules/angular-animate/angular-animate.js"></script><script src="node_modules/angular-aria/angular-aria.js"></script><script src="node_modules/angular-material/angular-material.js"></script><script src="node_modules/angular-jwt/dist/angular-jwt.js"></script><script src="node_modules/angular-storage/dist/angular-storage.js"></script><script src="node_modules/auth0-angular/build/auth0-angular.js"></script><script src="node_modules/angular-ui-router/release/angular-ui-router.js"></script>
</body>
</html>

Notice here that we’re bringing in the Auth0Lock widget script from Auth0’s CDN. This is the script that we’ll need to show the login box that Auth0 provides. By setting the viewport like we have, we make sure that the widget shows up properly on mobile devices.

请注意,这里是从Auth0的CDN引入Auth0Lock小部件脚本。 这是我们需要显示Auth0提供的登录框的脚本。 通过像我们一样设置视口,我们确保小部件在移动设备上正确显示。

设置工具栏 ( Set Up the Toolbar )

We will create a top navbar with Angular Material’s toolbar component. We’ll wrap this up into its own directive to keep things clean.

我们将使用Angular Material的工具栏组件创建一个顶部导航栏。 我们将其包装成自己的指令以保持环境整洁。

// components/toolbar/toolbar.dir.js

//组件/toolbar/toolbar.dir.js

(function() {'use strict';angular.module('authApp').directive('toolbar', toolbar);function toolbar() {return {templateUrl: 'components/toolbar/toolbar.tpl.html',controller: toolbarController,controllerAs: 'toolbar'}}function toolbarController(auth, store, $location) {var vm = this;vm.login = login;vm.logout = logout;vm.auth = auth;function login() {// The auth service has a signin method that// makes use of Auth0Lock. If authentication// is successful, the user's profile and token// are saved in local storage with the store serviceauth.signin({}, function(profile, token) {store.set('profile', profile);store.set('token', token);$location.path('/');}, function(error) {console.log(error);})}function logout() {// The signout method on the auth service// sets isAuthenticated to false but we// also need to remove the profile and// token from local storageauth.signout();store.remove('profile');store.remove('token');$location.path('/');}}})();

In the login method, auth.signin is responsible for opening Auth0’s Lock widget. This is awesome–with a single method, we have a fully-functioning login box! The callback gives us access to the user’s profile and JWT on a successful login or signup, and we need to store these in local storage for use later. The logout method simply removes the profile and token from local storage and uses auth.signout to set the user’s authentication state to false.

在登录方法中,auth.signin负责打开Auth0的Lock小部件。 太棒了–使用单一方法,我们将提供功能齐全的登录框! 回调使我们能够在成功登录或注册后访问用户的个人资料和JWT,我们需要将它们存储在本地存储中以备后用。 注销方法仅从本地存储中删除配置文件和令牌,并使用auth.signout将用户的身份验证状态设置为false。

We now need a template for this directive.

现在,我们需要此指令的模板。

<md-toolbar><div class="md-toolbar-tools"><h2><span>Get Chuck Norris Quotes</span></h2><span flex></span><md-buttonaria-label="Login"ng-if="!toolbar.auth.isAuthenticated"ng-click="toolbar.login()">Login</md-button><md-buttonui-sref="profile"ng-if="toolbar.auth.isAuthenticated"aria-label="Profile">Profile</md-button><md-buttonaria-label="Logout"ng-if="toolbar.auth.isAuthenticated"ng-click="toolbar.logout()">Logout</md-button></div>
</md-toolbar>

Notice here that we are conditionally showing and hiding the three buttons based on the user’s isAuthenticated state. Let’s now drop this directive into our index.html file to see it at work. At the same time, we’ll drop in some other scripts that we’ll need later.

注意这里我们基于用户的isAuthenticated状态有条件地显示和隐藏三个按钮。 现在,将该指令放入我们的index.html文件中,以查看其工作情况。 同时,我们将添加其他一些稍后需要的脚本。

<!--- index.html -->
...<body><toolbar></toolbar><div layout-padding><ui-view></ui-view></div>...<script src="app.js"></script><script src="components/toolbar/toolbar.dir.js"></script><script src="components/profile/profile.ctr.js"></script></body>
</html>
`

Start the server and navigate to http://localhost:8080/ . We can now test this out by clicking the Login button and either signing up for an account, or signing in with an account we create in our Auth0 dashboard.

启动服务器并导航到http:// localhost:8080 / 。 现在,我们可以通过单击“登录”按钮并注册一个帐户,或使用在Auth0信息中心中创建的帐户登录来进行测试。

Once authentication is complete, we can see that the profile and JWT for the user have been saved in localStorage. Now we can use these for the user’s profile area and to make authenticated requests.

身份验证完成后,我们可以看到该用户的配置文件和JWT已保存在localStorage中。 现在,我们可以将其用于用户的个人资料区域并发出经过身份验证的请求。

设置路由 ( Set Up Routing )

We’ll use UI Router. Let’s make a /profile route that will take the user to their profile page and simply display some of the data that is saved in localStorage. We want this route to be protected so that if the user isn’t authenticated, they aren’t able to navigate to it. We’ll also set up a /home route so that the user is redirected to somewhere meaningful if they are logged out. First, let’s set up our home and profile components.

我们将使用UI路由器。 让我们进行一个/ profile路由,该路由会将用户带到其个人资料页面,并仅显示保存在localStorage中的一些数据。 我们希望此路由受到保护,以便如果用户未通过身份验证,他们将无法导航到该路由。 我们还将设置/ home路由,以便在用户注销后将其重定向到有意义的地方。 首先,让我们设置家庭和个人资料组件。

<!-- components/home/home.tpl.html --><md-content><h1>Welcome to the Angular Auth app!</h1><h3>Login from the toolbar above to access your profile.</h3>
</md-content>

We’ll also set up the profile view and controller with methods to make HTTP calls to the SailsJS API.

我们还将通过使用方法对Profiles视图和控制器进行设置,以对SailsJS API进行HTTP调用。

<!-- components/profile/profile.tpl.html -->
<md-content class="md-padding" layout="column"><md-card><md-card-title><md-card-title-media><div class="md-media-lg card-media" layout-padding><img ng-src="{{ user.profile.picture }}"></div><md-card-actions layout="column" layout-align="end center"><md-button ng-click="user.getPublicQuote()">Get Public Quote </md-button><md-button ng-click="user.getSecretQuote()">Get Secret Quote</md-button></md-card-actions></md-card-title-media><md-card-title-text layout-padding><span class="md-headline">{{ user.profile.nickname }}</span><span class="md-subhead">{{ user.profile.email }}</span><h3>{{ user.message }}</h3></md-card-title-text></md-card-title></md-card>
</md-content>
// components/profile/profile.ctr.js(function() {'use strict';angular.module('authApp').controller('profileController', profileController);function profileController($http) {var vm = this;vm.getPublicQuote = getPublicQuote;vm.getSecretQuote = getSecretQuote;vm.message;vm.profile = JSON.parse(localStorage.getItem('profile'));// Makes a call to a public API route that// does not require authentication. We can// avoid sending the JWT as an Authorization// header with skipAuthorization: truefunction getPublicQuote() {$http.get('http://localhost:1337/api/random-quote', {skipAuthorization: true}).then(function(response) {vm.message = response.data.quote;});}// Makes a call to a private endpoint that does// require authentication. The JWT is automatically// sent with HTTP calls using jwtInterceptorProvider in app.jsfunction getSecretQuote() {$http.get('http://localhost:1337/api/protected/random-quote').then(function(response) {vm.message = response.data.quote;});}}})();

The next thing we need to do is set up our routing. At the same time, we’ll set some configuration that will automatically attach the JWT as an Authorization header when making HTTP calls.

我们需要做的下一件事是设置路由。 同时,我们将设置一些配置,这些配置将在进行HTTP调用时自动将JWT附加为Authorization标头。

// app.js

// app.js

....config(function(...) {...$urlRouterProvider.otherwise("/home");$stateProvider.state('home', {url: '/home',templateUrl: 'components/home/home.tpl.html'}).state('profile', {url: '/profile',templateUrl: 'components/profile/profile.tpl.html',controller: 'profileController as user'});jwtInterceptorProvider.tokenGetter = function(store) {return store.get('token');}$httpProvider.interceptors.push('jwtInterceptor');

Here we have provided some routing configuration for $stateProvider and have defaulted to the home state when the profile state isn’t matched. The jwtInterceptorProvider is the HTTP interceptor that takes care of attaching the user’s JWT as an Authorization header on each request. For any HTTP request that is made, Angular will intercept it before it goes out and attach whatever is returned from the tokenGetter function which, in this case, is the user’s JWT from local storage.

在这里,我们为$ stateProvider提供了一些路由配置,并且在配置文件状态不匹配时默认为原始状态。 jwtInterceptorProvider是HTTP拦截器,负责将用户的JWT作为每个请求的授权标头附加。 对于发出的任何HTTP请求,Angular都会在发出请求之前对其进行拦截,并附加从tokenGetter函数返回的任何内容,在本例中,该功能是用户从本地存储的JWT。

获取报价 ( Getting the Quotes )

Now, open a new console and make sure you are in the root directory of the sails project. Run sails lift to ensure the SailsJs server is running.

现在,打开一个新控制台,并确保您位于sails项目的根目录中。 运行sails lift ,以确保服务器运行的是SailsJs。

Log in, and click on the Profile page, then click on the Get Public Quotes and Get Private Quotes buttons. We can retrieve both set of quotes successfully.

登录,然后单击“个人资料”页面,然后单击“获取公共报价”和“获取私人报价”按钮。 我们可以成功检索两组报价。

At the bottom of the picture above, you can see how the token is attached with the Bearer to the Authorization header. It is sent on every request.

在上图的底部,您可以看到令牌与承载者如何附加到Authorization标头。 它根据每个请求发送。

在未经授权的请求下重定向用户 ( Redirect User on Unauthorized Request )

If a user makes a request to our API with an expired or invalid JWT,a blank screen will be presented to the user. Let’s use an HTTP interceptor to look for any 401 errors returned in responses and then redirect the user to the /home route if it finds any.

如果用户使用过期或无效的JWT向我们的API请求,则会向用户显示空白屏幕。 让我们使用HTTP拦截器查找响应中返回的任何401错误,然后将用户重定向到/ home路由(如果发现)。

// app.js

// app.js

....config(function(...) {...function redirect($q, $injector, auth, store, $location) {return {responseError: function(rejection) {if (rejection.status === 401) {auth.signout();store.remove('profile');store.remove('token');$location.path('/home')}return $q.reject(rejection);}}
}
$provide.factory('redirect', redirect);
$httpProvider.interceptors.push('redirect');

The redirect function is used to check for a rejection.status of 401 on any responses that come back from HTTP requests. If one is found, we use auth.signout to set isAuthenticated to false, remove the user’s profile and JWT, and take them to the home state.

重定向功能用于检查从HTTP请求返回的任何响应的401.status.status状态。 如果找到一个,我们使用auth.signout将isAuthenticated设置为false,删除用户的配置文件和JWT,并将它们带回原始状态。

设置页面刷新 ( Set Up Page Refreshing )

The last thing we need to take care of is page refreshing. Because everything we’ve done thus far relies on some state being persisted in the user’s browser, things will get messed up if they refresh the page. For example, if we log in and then refresh the page, the isAuthenticated boolean value that gets set on login isn’t persisted, and thus our Login button comes back, even though we are actually authenticated.

我们需要照顾的最后一件事是页面刷新。 因为到目前为止,我们所做的一切都依赖于用户浏览器中保持的某种状态,所以如果刷新页面,事情将会变得混乱。 例如,如果我们登录然后刷新页面,则登录时设置的isAuthenticated布尔值不会持久化,因此即使我们已通过身份验证,“登录”按钮也会返回。

We can fix this by doing a check for the user’s JWT on $locationChangeStart. // app.js

我们可以通过在$ locationChangeStart上检查用户的JWT来解决此问题。 // app.js

....run(function($rootScope, $state, auth, store, jwtHelper, $location) {$rootScope.$on('$locationChangeStart', function() {// Get the JWT that is saved in localStorage// and if it is there, check whether it is expired.// If it isn't, set the user's auth statevar token = store.get('token');if (token) {if (!jwtHelper.isTokenExpired(token)) {if (!auth.isAuthenticated) {auth.authenticate(store.get('profile'), token);}}}else {// Otherwise, redirect to the home route$location.path('/home');}});});...

The callback in $locationChangeStart gets evaluated every time the page is refreshed, or when a new URL is reached. Inside the callback we are looking for a saved JWT, and if there is one, we check whether it is expired. If the JWT isn’t expired, we set the user’s auth state with their profile and token. If the JWT is expired, we redirect to the home route. Normally, we would be able to test out these redirections by going to the /profile route and removing the JWT from localStorage. If we were to then send a request to the protected API endpoint, we would be redirected to the home route because no JWT would be sent with the request, resulting in a 401.

每次刷新页面或访问新URL时,都会评估$ locationChangeStart中的回调。 在回调内部,我们正在寻找一个已保存的JWT,如果有,请检查它是否已过期。 如果JWT没有过期,我们将使用其个人资料和令牌设置用户的身份验证状态。 如果JWT过期,我们将重定向到本地路由。 通常,我们可以通过转到/ profile路由并从localStorage中删除JWT来测试这些重定向。 如果随后将请求发送到受保护的API端点,则会将我们重定向到本地路由,因为不会随请求一起发送JWT,结果为401。

结论 ( Conclusion )

With the help of SailsJS, AngularJS and Auth0, we have been able to spin up a functional and secure API. We have also been able to build a complete app with authentication. When trying to flesh out APIs with ease, SailsJS is the go-to Nodejs framework.

借助SailsJS,AngularJS和Auth0,我们已经能够启动功能强大且安全的API。 我们还能够构建具有身份验证的完整应用程序。 当尝试轻松充实API时,SailsJS是首选的Nodejs框架。

翻译自: https://scotch.io/tutorials/build-a-sailsjs-app-from-api-to-authentication

jenkins 构建api

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

相关文章

  1. 前端插件链接集合

    插件 parallel.js: 前后端通用的一个并行库 zepto: 用于现代浏览器的兼容 jQuery 的库 totoro: 稳定的跨浏览器测试工具 TheaterJS: 一个用于模拟人输入状态的 JS 库 stellar.js: 前端用于实现异步滚动效果的库&#xff0c;现已不再维护 skrollr: 另一款实现一步滚动的开源库&…...

    2024/5/1 17:14:40
  2. 前端各部分面试题

    一、HTML部分常见问题 1、怎么让一个不定宽高的 DIV&#xff0c;垂直水平居中&#xff1f; 答&#xff1a;1&#xff09;使用 CSS 方法&#xff1a; 父盒子设置&#xff1a;display&#xff1a;table-cell&#xff1b; text-align&#xff1a;center&#xff1b;vertical-align…...

    2024/5/1 14:25:10
  3. 前端开发全面知识库

    转自&#xff1a;https://zhuanlan.zhihu.com/p/25604225&#xff0c; 阿里云云栖号&#xff0c;2017年 文章目录1 前言2 内容核心 CoreHTML5CSS3JSjQueryES6插件包管理工具 Package ManagersNPMBowerYarn编辑器 Text EditorsWebStormVScodeSublimeTextAtomHBuilderJS框架 JS F…...

    2024/5/1 10:28:41
  4. javascript MVC框架之 AngularJS 1.x 实用指南

    本文非AngularJS 1.X的入门级教程&#xff0c;很多细节可能会被无意识的忽略。AngularJS相比于Backbone要复杂不少&#xff0c;两者的设计思路也完全不同&#xff0c;更可以说是大相径庭。面对一个SPA项目的前端技术选型时&#xff0c;需要根据实际需要进行选择。本文更多的是给…...

    2024/5/1 14:49:28
  5. VUE 常见问题汇总

    问题汇总Q:安装超时(install timeout)方案有这么些:cnpm : 国内对npm的镜像版本/*cnpm website: https://npm.taobao.org/*/npm install -g cnpm --registryhttps://registry.npm.taobao.org// cnpm 的大多命令跟 npm 的是一致的,比如安装,卸载这些yarn 和 npm 改源大法使用 nr…...

    2024/5/1 10:02:40
  6. 学习资源整理

    ES6 http://es6.ruanyifeng.com/#docs/generator Javascript ArticleArticleJavascript深浅拷贝Javascript中的apply和call继承Javascript的jsonp原理Javascript监听触摸事件Javascript中的var self thisJavascript面向对象编程Javascript滑屏切换场景Javascript获取经纬度&am…...

    2024/5/1 12:17:24
  7. 前端百科

    Javascript ArticleArticleJavascript深浅拷贝Javascript中的apply和call继承Javascript的jsonp原理Javascript监听触摸事件Javascript中的var self thisJavascript面向对象编程Javascript滑屏切换场景Javascript获取经纬度&#xff0c;关于调用百度API的问题妙用Javascript运…...

    2024/4/30 16:01:29
  8. 前端知识全局汇总

    Javascript ArticleArticleJavascript深浅拷贝Javascript中的apply和call继承Javascript的jsonp原理Javascript监听触摸事件Javascript中的var self thisJavascript面向对象编程Javascript滑屏切换场景Javascript获取经纬度&#xff0c;关于调用百度API的问题妙用Javascript运…...

    2024/5/1 5:54:55
  9. 前端知识点百科大全

    Javascript https://github.com/Wscats/Good-text-ShareArticleArticleJavascript深浅拷贝Javascript中的apply和call继承前端程序员经常忽视的一个JavaScript面试题我如何用前端技术得到XXOO网站的VIPJavascript的jsonp原理Javascript监听触摸事件深入理解Javascript函数编程J…...

    2024/4/30 14:01:32
  10. HTML5实现屏幕手势解锁(转载)

    来源:https://github.com/lvming6816077/H5lockhttp://threejs.org/examples/http://www.inf.usi.ch/phd/wettel/codecity-download.html (JSCity&#xff1a;把源码可视化成建筑物的 JS 库)http://www.alloyteam.com/2015/07/html5-shi-xian-ping-mu-shou-shi-jie-suo/ (Web前…...

    2024/5/1 16:37:23
  11. Angular学习笔记-配置静态路由

    1.声明一个路由组件(app-routing.module.ts) 1.1 在新生成的项目声明 ng g <project name> --routing1.2 内部项目声明 ng generate module app-routing --flat --moduleapp2.app-routing.module.ts文件 同时他会在app.module里注入这个文件 3.Routers 路由配置 路…...

    2024/5/1 5:40:00
  12. angular 路由传参的方式

    1. 路由文件引入 // 第一步&#xff1a;引入Router对象 import {ActivatedRoute, Router} from angular/router;// 第二步&#xff1a;在构造函数中注入 constructor(private activateRoute: ActivatedRoute, private router: Router) { }传参的类型 get跳转和动态路由两种…...

    2024/5/1 15:43:59
  13. Angular6-路由-配置路由(常规路由+子路由+路由守卫)

    核心ts文件 app.module.ts 下方的HomeModule是新建的模块&#xff0c;也是要被加载的路由模块。 import {BrowserModule} from angular/platform-browser; import {enableProdMode, NgModule} from angular/core; import {AppComponent} from ./app.component; import {NgZor…...

    2024/4/21 3:51:41
  14. angular 路由模块 route

    转载自 http://www.ngui.cc/news/show-109.html 基础知识 导入路由模块 // ... import { RouterModule } from angular/router; NgModule({imports: [BrowserModule, FormsModule, HttpModule, RouterModule],declarations: [AppComponent, UserComponent, MembersComponen…...

    2024/5/1 12:05:20
  15. Angular实现路由缓存-(简单到我还没开始研究)

    前言 顾客就是上帝,为顾客解决需求&#xff0c;是我们打工人的责任。那么需求来了。 顾客要求在上一个页面操作后&#xff0c;状态依然保存。 注&#xff1a;可能本文内容不严谨 但是确实做了如下效果后&#xff0c;路由缓存就实现了&#xff0c;真的是很无脑&#xff0c;相当…...

    2024/5/1 13:07:52
  16. angular和JAVA实现aes、rsa加密解密,前后端交互,前端加解密和后端JAVA加解密实现

    今天实现了下AES和RSA加密解密&#xff0c;主要的功能是对前后端交互数据进行加密解密&#xff0c;为什么要用到两个算法呢&#xff0c;首先RSA默认的话加密长度是有限的100多个byte吧大约&#xff0c;并且需要公钥私钥&#xff0c;而AES加密没有限制只需要一个key就可以&#…...

    2024/5/1 8:39:59
  17. angular 8 学习记录

    1&#xff0c;安装Angular Cli、创建运行Angular项目 安装cnpm npm install -g cnpm --registryhttps://registry.npm.taobao.org 2、使用 npm/cnpm 命令安装angular/cli &#xff08;只需要安装一次&#xff09; npm install -g angular/cli 或者 cnpm install -g angul…...

    2024/5/1 6:52:19
  18. angular学习(十二)—— Directive

    转载请写明来源地址:http://blog.csdn.net/lastsweetop/article/details/55520140 directive介绍 directive是DOM元素上的标记,告诉angularjs的HTML编译器($complile)给DOM元素附加上一些特殊的行为,或者是改变DOM元素和它的子元素。 看到编译两个字,很多人会感到很懵…...

    2024/4/20 19:59:52
  19. pc 端 前端对接支付宝支付-前端获取支付宝返回的form 表单以及submit提交表单,自动跳转支付页面扫码支付

    项目中用到了微信扫码&#xff0c;支付宝扫码支付。前端调取支付宝接口&#xff08;后台进行了封装&#xff0c;没有直接调取支付宝接口&#xff09;。 调用接口返回数据中&#xff0c;会有一串form表单字符串返回&#xff0c;前端需要做的就是把这串form 表单字符串通过append…...

    2024/4/20 8:27:43
  20. 一元购宝倒计时之angularJs-$interval

    setInterval更新的数据不能够及时的在页面做更新显示&#xff0c;但angular自带的$interval可以做到&#xff0c;用法和setInterval完全一样&#xff0c;这里只做了秒倒计时&#xff0c;没有做分钟倒计时&#xff0c;另外timer对象为全局变量&#xff0c;在点击按钮和切换路由的…...

    2024/4/20 10:11:55

最新文章

  1. element-plus中使用el-switch时,用‘0,1’或者0,1来代替true,false绑定

    介绍 switch 开关默认用 true, false来绑定的&#xff0c;但是在实际的项目中&#xff0c;有时候根据后端的接口返回&#xff0c;也可能会用字符串0 和 1 &#xff0c;或者数字 0,1来代替; 具体实现如下 详情&#xff1a; 主要实现方式是通过使用el-switch组件里的 active-val…...

    2024/5/1 17:37:21
  2. 梯度消失和梯度爆炸的一些处理方法

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

    2024/3/20 10:50:27
  3. 01背包问题 小明的背包

    2.小明的背包1 - 蓝桥云课 (lanqiao.cn) #include <bits/stdc.h> using namespace std; const int N1010;//开始写的105 开小了 样例过了但最后只过了很少一部分 int n,m; int v[N],w[N]; int f[N][N];int main() {cin>>n>>m;for(int i1;i<n;i){cin>&…...

    2024/4/30 7:25:11
  4. Claude-3全解析:图片问答,专业写作能力显著领先GPT-4

    人工智能技术的飞速发展正在深刻改变着我们的工作和生活方式。作为一名资深的技术爱好者&#xff0c;我最近有幸体验了备受瞩目的AI助手Claude-3。这款由Anthropic公司推出的新一代智能工具展现出了非凡的实力&#xff0c;尤其在图像识别和专业写作领域的表现更是让人眼前一亮&…...

    2024/5/1 10:16:01
  5. 【外汇早评】美通胀数据走低,美元调整

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

    2024/5/1 17:30:59
  6. 【原油贵金属周评】原油多头拥挤,价格调整

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

    2024/4/30 18:14:14
  7. 【外汇周评】靓丽非农不及疲软通胀影响

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

    2024/4/29 2:29:43
  8. 【原油贵金属早评】库存继续增加,油价收跌

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

    2024/4/30 18:21:48
  9. 【外汇早评】日本央行会议纪要不改日元强势

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

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

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

    2024/4/27 14:22:49
  11. 【外汇早评】美欲与伊朗重谈协议

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

    2024/4/28 1:28:33
  12. 【原油贵金属早评】波动率飙升,市场情绪动荡

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

    2024/4/30 9:43:09
  13. 【原油贵金属周评】伊朗局势升温,黄金多头跃跃欲试

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

    2024/4/27 17:59:30
  14. 【原油贵金属早评】市场情绪继续恶化,黄金上破

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

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

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

    2024/4/28 1:34:08
  16. 【原油贵金属早评】贸易冲突导致需求低迷,油价弱势

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

    2024/4/26 19:03:37
  17. 氧生福地 玩美北湖(上)——为时光守候两千年

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

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

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

    2024/4/30 22:21:04
  19. 氧生福地 玩美北湖(下)——奔跑吧骚年!

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

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

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

    2024/4/27 23:24:42
  21. 「发现」铁皮石斛仙草之神奇功效用于医用面膜

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

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

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

    2024/4/30 9:42:22
  23. 广州械字号面膜生产厂家OEM/ODM4项须知!

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

    2024/4/30 9:43:22
  24. 械字号医用眼膜缓解用眼过度到底有无作用?

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

    2024/4/30 9:42:49
  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