本文翻译自:AngularJS ui-router login authentication

I am new to AngularJS, and I am a little confused of how I can use angular-"ui-router" in the following scenario: 我是AngularJS的新手,在以下情况下我对如何使用angular-“ ui-router”感到有些困惑:

I am building a web application which consists of two sections. 我正在构建一个包含两个部分的Web应用程序。 The first section is the homepage with its login and signup views, and the second section is the dashboard (after successful login). 第一部分是带有登录和注册视图的主页,第二部分是仪表板(成功登录后)。

I have created an index.html for the home section with its angular app and ui-router config to handle /login and /signup views, and there is another file dashboard.html for the dashboard section with its app and ui-router config to handle many sub views. 我已经使用它的角度应用程序和ui-router配置为home部分创建了一个index.html来处理/login/signup视图,并且对于它的app和ui-router配置来了dashboard部分的另一个文件dashboard.html处理许多子视图。

Now I finished the dashboard section and don't know how to combine the two sections with their different angular apps. 现在,我完成了仪表板部分,并且不知道如何将这两个部分与不同的角度应用程序结合起来。 How could I tell the home app to redirect to the dashboard app? 我如何告诉家用应用程序重定向到仪表板应用程序?


#1楼

参考:https://stackoom.com/question/1WYz1/AngularJS-UI路由器登录身份验证


#2楼

I think you need a service that handle the authentication process (and its storage). 我想你需要一个service是处理身份验证过程(及其存储)。

In this service you'll need some basic methods : 在此服务中,您需要一些基本方法:

  • isAuthenticated()
  • login()
  • logout()
  • etc ... 等...

This service should be injected in your controllers of each module : 该服务应该注入到每个模块的控制器中:

  • In your dashboard section, use this service to check if user is authenticated ( service.isAuthenticated() method) . 在仪表板部分中,使用此服务来检查用户是否已通过身份验证( service.isAuthenticated()方法)。 if not, redirect to /login 如果不是,请重定向到/ login
  • In your login section, just use the form data to authenticate the user through your service.login() method 在登录部分中,只需使用表单数据通过service.login()方法对用户进行身份验证

A good and robust example for this behavior is the project angular-app and specifically its security module which is based over the awesome HTTP Auth Interceptor Module 关于此行为的一个很好且强大的示例是angular-app项目,尤其是其安全模块 ,该模块基于出色的HTTP Auth拦截器模块

Hope this helps 希望这可以帮助


#3楼

I'm in the process of making a nicer demo as well as cleaning up some of these services into a usable module, but here's what I've come up with. 我正在做一个更好的演示,并将其中的一些服务清理到一个可用的模块中,但这是我想出的。 This is a complex process to work around some caveats, so hang in there. 要解决一些警告,这是一个复杂的过程,所以请坚持。 You'll need to break this down into several pieces. 您需要将其分解为几部分。

Take a look at this plunk . 看看这个pl 。

First, you need a service to store the user's identity. 首先,您需要一项服务来存储用户的身份。 I call this principal . 我称这个principal It can be checked to see if the user is logged in, and upon request, it can resolve an object that represents the essential information about the user's identity. 可以检查它是否查看用户是否登录,并且可以根据请求解析一个代表有关用户身份的基本信息的对象。 This can be whatever you need, but the essentials would be a display name, a username, possibly an email, and the roles a user belongs to (if this applies to your app). 这可以是您需要的任何内容,但必不可少的是显示名称,用户名(可能是电子邮件)以及用户所属的角色(如果这适用于您的应用程序)。 Principal also has methods to do role checks. Principal还具有进行角色检查的方法。

.factory('principal', ['$q', '$http', '$timeout',function($q, $http, $timeout) {var _identity = undefined,_authenticated = false;return {isIdentityResolved: function() {return angular.isDefined(_identity);},isAuthenticated: function() {return _authenticated;},isInRole: function(role) {if (!_authenticated || !_identity.roles) return false;return _identity.roles.indexOf(role) != -1;},isInAnyRole: function(roles) {if (!_authenticated || !_identity.roles) return false;for (var i = 0; i < roles.length; i++) {if (this.isInRole(roles[i])) return true;}return false;},authenticate: function(identity) {_identity = identity;_authenticated = identity != null;},identity: function(force) {var deferred = $q.defer();if (force === true) _identity = undefined;// check and see if we have retrieved the // identity data from the server. if we have, // reuse it by immediately resolvingif (angular.isDefined(_identity)) {deferred.resolve(_identity);return deferred.promise;}// otherwise, retrieve the identity data from the// server, update the identity object, and then // resolve.//           $http.get('/svc/account/identity', //                     { ignoreErrors: true })//                .success(function(data) {//                    _identity = data;//                    _authenticated = true;//                    deferred.resolve(_identity);//                })//                .error(function () {//                    _identity = null;//                    _authenticated = false;//                    deferred.resolve(_identity);//                });// for the sake of the demo, fake the lookup// by using a timeout to create a valid// fake identity. in reality,  you'll want // something more like the $http request// commented out above. in this example, we fake // looking up to find the user is// not logged invar self = this;$timeout(function() {self.authenticate(null);deferred.resolve(_identity);}, 1000);return deferred.promise;}};}
])

Second, you need a service that checks the state the user wants to go to, makes sure they're logged in (if necessary; not necessary for signin, password reset, etc.), and then does a role check (if your app needs this). 其次,您需要一项服务来检查用户想要进入的状态,确保他们已登录(如果需要;登录,密码重置等不需要),然后进行角色检查(如果您的应用是需要这个)。 If they are not authenticated, send them to the sign-in page. 如果未通过身份验证,请将其发送到登录页面。 If they are authenticated, but fail a role check, send them to an access denied page. 如果它们通过了身份验证,但未通过角色检查,请将其发送到拒绝访问页面。 I call this service authorization . 我称此服务authorization

.factory('authorization', ['$rootScope', '$state', 'principal',function($rootScope, $state, principal) {return {authorize: function() {return principal.identity().then(function() {var isAuthenticated = principal.isAuthenticated();if ($rootScope.toState.data.roles&& $rootScope.toState.data.roles.length > 0 && !principal.isInAnyRole($rootScope.toState.data.roles)){if (isAuthenticated) {// user is signed in but not// authorized for desired state$state.go('accessdenied');} else {// user is not authenticated. Stow// the state they wanted before you// send them to the sign-in state, so// you can return them when you're done$rootScope.returnToState= $rootScope.toState;$rootScope.returnToStateParams= $rootScope.toStateParams;// now, send them to the signin state// so they can log in$state.go('signin');}}});}};}
])

Now all you need to do is listen in on ui-router 's $stateChangeStart . 现在,您需要做的就是监听ui-router$stateChangeStart This gives you a chance to examine the current state, the state they want to go to, and insert your authorization check. 这使您有机会检查当前状态,他们想进入的状态并插入授权检查。 If it fails, you can cancel the route transition, or change to a different route. 如果失败,则可以取消路由转换,或更改为其他路由。

.run(['$rootScope', '$state', '$stateParams', 'authorization', 'principal',function($rootScope, $state, $stateParams, authorization, principal)
{$rootScope.$on('$stateChangeStart', function(event, toState, toStateParams){// track the state the user wants to go to; // authorization service needs this$rootScope.toState = toState;$rootScope.toStateParams = toStateParams;// if the principal is resolved, do an // authorization check immediately. otherwise,// it'll be done when the state it resolved.if (principal.isIdentityResolved()) authorization.authorize();});}]);

The tricky part about tracking a user's identity is looking it up if you've already authenticated (say, you're visiting the page after a previous session, and saved an auth token in a cookie, or maybe you hard refreshed a page, or dropped onto a URL from a link). 跟踪用户身份的棘手部分是如果您已通过身份验证,则查找该身份(例如,您在上一个会话后访问该页面,并将auth令牌保存在cookie中,或者您可能难以刷新页面,或者从链接拖放到URL上)。 Because of the way ui-router works, you need to do your identity resolve once, before your auth checks. 由于ui-router工作方式,您需要在身份验证之前进行一次身份解析。 You can do this using the resolve option in your state config. 您可以使用状态配置中的resolve选项来执行此操作。 I have one parent state for the site that all states inherit from, which forces the principal to be resolved before anything else happens. 对于所有状态都继承自该站点的站点,我有一个父状态,这将迫使主体在发生其他任何事情之前先进行解析。

$stateProvider.state('site', {'abstract': true,resolve: {authorize: ['authorization',function(authorization) {return authorization.authorize();}]},template: '<div ui-view />'
})

There's another problem here... resolve only gets called once. 这里还有另一个问题... resolve只被调用一次。 Once your promise for identity lookup completes, it won't run the resolve delegate again. 一旦您完成对身份查询的承诺,就不会再运行解析委托。 So we have to do your auth checks in two places: once pursuant to your identity promise resolving in resolve , which covers the first time your app loads, and once in $stateChangeStart if the resolution has been done, which covers any time you navigate around states. 因此,我们必须在两个地方进行身份验证检查:一次是根据您的身份承诺在resolveresolve ,这涵盖了您的应用程序的首次加载;一次是在$stateChangeStart如果解决方案已完成),它涵盖了您每次浏览的时间状态。

OK, so what have we done so far? 好,到目前为止,我们做了什么?

  1. We check to see when the app loads if the user is logged in. 如果用户已登录,我们会检查该应用何时加载。
  2. We track info about the logged in user. 我们跟踪有关登录用户的信息。
  3. We redirect them to sign in state for states that require the user to be logged in. 我们将它们重定向到需要用户登录的状态的登录状态。
  4. We redirect them to an access denied state if they do not have authorization to access it. 如果他们无权访问它们,我们会将它们重定向到拒绝访问状态。
  5. We have a mechanism to redirect users back to the original state they requested, if we needed them to log in. 如果需要用户登录,我们有一种机制可以将用户重定向回他们请求的原始状态。
  6. We can sign a user out (needs to be wired up in concert with any client or server code that manages your auth ticket). 我们可以注销用户(需要与管理您的身份验证票的任何客户端或服务器代码保持一致)。
  7. We don't need to send users back to the sign-in page every time they reload their browser or drop on a link. 每当用户重新加载浏览器或断开链接时,我们都不需要将用户带回到登录页面。

Where do we go from here? 我们从这里去哪里? Well, you can organize your states into regions that require sign in. You can require authenticated/authorized users by adding data with roles to these states (or a parent of them, if you want to use inheritance). 好吧,您可以将状态组织到需要登录的区域中。可以通过向这些状态(或如果要使用继承,则为它们的父级)添加具有roles data来要求经过身份验证/授权的用户。 Here, we restrict a resource to Admins: 在这里,我们将资源限制为管理员:

.state('restricted', {parent: 'site',url: '/restricted',data: {roles: ['Admin']},views: {'content@': {templateUrl: 'restricted.html'}}})

Now you can control state-by-state what users can access a route. 现在,您可以按状态控制哪些用户可以访问路由。 Any other concerns? 还有其他问题吗? Maybe varying only part of a view based on whether or not they are logged in? 也许仅根据视图是否登录而改变视图的一部分? No problem. 没问题。 Use the principal.isAuthenticated() or even principal.isInRole() with any of the numerous ways you can conditionally display a template or an element. 可以通过多种可有条件地显示模板或元素的方式中的任何一种,使用principal.isAuthenticated()principal.isInRole()

First, inject principal into a controller or whatever, and stick it to the scope so you can use it easily in your view: 首先,将principal注入控制器或其他任何东西,并将其粘贴到示波器上,以便可以在视图中轻松使用它:

.scope('HomeCtrl', ['$scope', 'principal', function($scope, principal)
{$scope.principal = principal;
});

Show or hide an element: 显示或隐藏元素:

<div ng-show="principal.isAuthenticated()">I'm logged in
</div>
<div ng-hide="principal.isAuthenticated()">I'm not logged in
</div>

Etc., so on, so forth. 等等,依此类推。 Anyways, in your example app, you would have a state for home page that would let unauthenticated users drop by. 无论如何,在示例应用程序中,您将具有主页状态,该状态将使未经身份验证的用户掉队。 They could have links to the sign-in or sign-up states, or have those forms built into that page. 他们可以具有指向登录或注册状态的链接,或者可以将那些表单内置到该页面中。 Whatever suits you. 任何适合您的。

The dashboard pages could all inherit from a state that requires the users to be logged in and, say, be a User role member. 仪表板页面都可以从要求用户登录并成为User角色成员的状态继承。 All the authorization stuff we've discussed would flow from there. 我们讨论过的所有授权内容都将从那里流淌。


#4楼

Here is how we got out of the infinite routing loop and still used $state.go instead of $location.path 这是我们摆脱无限路由循环并仍然使用$state.go而不是$location.path

if('401' !== toState.name) {if (principal.isIdentityResolved()) authorization.authorize();
}

#5楼

I Created this module to help make this process piece of cake 我创建了这个模块来帮助使这一过程变得轻松

You can do things like: 您可以执行以下操作:

$routeProvider.state('secret',{...permissions: {only: ['admin', 'god']}});

Or also 或者也

$routeProvider.state('userpanel',{...permissions: {except: ['not-logged-in']}});

It's brand new but worth checking out! 这是全新的,但值得一试!

https://github.com/Narzerus/angular-permission https://github.com/Narzerus/angular-permission


#6楼

The solutions posted so far are needlessly complicated, in my opinion. 我认为到目前为止发布的解决方案不必要地复杂。 There's a simpler way. 有一种更简单的方法。 The documentation of ui-router says listen to $locationChangeSuccess and use $urlRouter.sync() to check a state transition, halt it, or resume it. ui-router的文档说监听$locationChangeSuccess并使用$urlRouter.sync()检查状态转换,中止或恢复状态转换。 But even that actually doesn't work. 但这实际上是行不通的。

However, here are two simple alternatives. 但是,这里有两个简单的选择。 Pick one: 选一个:

Solution 1: listening on $locationChangeSuccess 解决方案1:监听$locationChangeSuccess

You can listen to $locationChangeSuccess and you can perform some logic, even asynchronous logic there. 您可以收听$locationChangeSuccess并且可以执行一些逻辑,甚至在那里的异步逻辑。 Based on that logic, you can let the function return undefined, which will cause the state transition to continue as normal, or you can do $state.go('logInPage') , if the user needs to be authenticated. 根据该逻辑,可以让函数返回未定义的状态,这将导致状态转换照常进行,或者,如果需要验证用户,可以执行$state.go('logInPage') Here's an example: 这是一个例子:

angular.module('App', ['ui.router'])// In the run phase of your Angular application  
.run(function($rootScope, user, $state) {// Listen to '$locationChangeSuccess', not '$stateChangeStart'$rootScope.$on('$locationChangeSuccess', function() {user.logIn().catch(function() {// log-in promise failed. Redirect to log-in page.$state.go('logInPage')})})
})

Keep in mind that this doesn't actually prevent the target state from loading, but it does redirect to the log-in page if the user is unauthorized. 请记住,这实际上并不能阻止加载目标状态,但是如果用户未经授权,它确实会重定向到登录页面。 That's okay since real protection is on the server, anyway. 没关系,因为无论如何服务器上都有真正的保护。

Solution 2: using state resolve 解决方案2:使用状态resolve

In this solution, you use ui-router resolve feature . 在此解决方案中,您将使用ui-router resolve功能 。

You basically reject the promise in resolve if the user is not authenticated and then redirect them to the log-in page. 如果用户未通过身份验证,您基本上会拒绝resolve承诺,然后将其重定向到登录页面。

Here's how it goes: 这是怎么回事:

angular.module('App', ['ui.router']).config(function($stateProvider) {$stateProvider.state('logInPage', {url: '/logInPage',templateUrl: 'sections/logInPage.html',controller: 'logInPageCtrl',}).state('myProtectedContent', {url: '/myProtectedContent',templateUrl: 'sections/myProtectedContent.html',controller: 'myProtectedContentCtrl',resolve: { authenticate: authenticate }}).state('alsoProtectedContent', {url: '/alsoProtectedContent',templateUrl: 'sections/alsoProtectedContent.html',controller: 'alsoProtectedContentCtrl',resolve: { authenticate: authenticate }})function authenticate($q, user, $state, $timeout) {if (user.isAuthenticated()) {// Resolve the promise successfullyreturn $q.when()} else {// The next bit of code is asynchronously tricky.$timeout(function() {// This code runs after the authentication promise has been rejected.// Go to the log-in page$state.go('logInPage')})// Reject the authentication promise to prevent the state from loadingreturn $q.reject()}}}
)

Unlike the first solution, this solution actually prevents the target state from loading. 与第一个解决方案不同,此解决方案实际上阻止了目标状态的加载。

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

相关文章

  1. 第26篇:AngularJS+ui-router实现一个超简单的登陆和跳转的二级路由demo

    1.页面结构介绍&#xff1a; 1&#xff09;index.html:页面入口文件&#xff1b; 2&#xff09;views文件夹下&#xff1a; login文件夹下&#xff1a;登陆页面和对应控制器&#xff1b; home文件夹下&#xff1a; home.html/home.js:二级路由页面和对应的控制器 adv/list…...

    2024/4/22 21:25:53
  2. 微信小程序UI组件 开发框架 实用库 经典demo

    UI组件 weui-wxss ★852 - 同微信原生视觉体验一致的基础样式库Wa-UI ★122 - 针对微信小程序整合的一套UI库wx-charts ★105 - 微信小程序图表工具wemark ★85 - 微信小程序Markdown渲染库WeZRender ★36 - 微信小程序Canvas增强组件wetoast ★21 - 仿照微信小程序提供的showT…...

    2024/4/20 19:54:10
  3. 【MVC】AngularJs+KendoUI开发报表Demo(导出Excel和折线图)

    废话写在最前面 做angular开发已经有很长一段时间了&#xff0c;它的优势已经不用赘述了&#xff0c;尤其是双向绑定和高度模块化&#xff0c;真是装逼利器&#xff0c;甚是好用... 至于KendoUi&#xff0c;接触时间不长&#xff0c;名字看上去是UI框架&#xff0c;但个人觉得…...

    2024/5/6 8:48:33
  4. IC卡的交易过程

    我还没有去看这方面的参考书,仅是自己的想法。在看其他资料之前,我想自己把这个问题相通。过程:1)IC卡接到金额变动信号2)识别是否为安全信号3)改变自身的金额难点在于,怎么知道这个信号是安全的,不是仿冒的?还有这个信号是不是重发的?要知道这个信号是不可仿冒的,那…...

    2024/4/21 4:09:13
  5. angular的DEMO(用来练习和顺便看看)

    inflector(辅助) 将用户输入的字符串转化成驼峰或者空格或者底线的小插件;这个是一个小的过滤器, 平常也是用不到的, 合格是过滤器的代码:运行下面代码app.filter("inflector", function() { var reg new RegExp("","gi"); …...

    2024/5/2 22:55:37
  6. angular8表单校验

    1.app.module.ts中注入&#xff1a; import { FormsModule, ReactiveFormsModule } from angular/forms; NgModule({declarations: [],imports: [FormsModule,ReactiveFormsModule] }) 2.app.component.ts中注入&#xff1a; import { FormGroup, FormControl, Validators …...

    2024/5/3 6:34:47
  7. html右键angular,html - Angular2禁用按钮

    html - Angular2禁用按钮我知道在angular2中我可以禁用一个按钮[ngStyle]属性&#xff0c;例如&#xff1a;Confirm但是我可以使用[ngStyle]或[ngStyle]吗&#xff1f; 像这样&#xff1a;Confirm谢谢。10个解决方案144 votes更新我很纳闷。 为什么不想使用Angular 2提供的ngCl…...

    2024/4/21 4:09:09
  8. angular路由的配置

    1、创建组件(命令行) ng g c components/spatialLocationMemorySpan 2、app.module.ts中进行引入 import { RouterModule,Routes } from angular/router; import { SpatialLocationMemorySpanComponent } from ./compontents/spatial-location-memory-span/spatial-locatio…...

    2024/5/3 5:31:02
  9. angular随笔

    app.module.ts文件分析 import { BrowserModule } from angular/platform-browser; // 浏览器解析模块 import { NgModule } from angular/core; // angular核心模块import { AppRoutingModule } from ./app-routing.module; // 路由模块 // 引入项目所需组件 import { AppCom…...

    2024/4/21 4:09:08
  10. angular 父组件异步获取数据后传值给子组件

    参考&#xff1a;https://www.cnblogs.com/fuzitu/p/9172728.html https://www.it1352.com/1551144.html 通过输入和输出属性 实现数据在父子组件的交互 在子组件内部使用input接受父组件传入数据&#xff0c;使用output传出数据到父组件 详细标准讲解参考官方文档 https://a…...

    2024/5/3 1:15:42
  11. angular1.0学习记录

    1、JS结构化框架 2、特性和特点&#xff1a; 1&#xff09;双向数据绑定 2&#xff09;声明式依赖注入 3&#xff09;解耦应用逻辑&#xff0c;数据模型和视图 4&#xff09;完善的页面指令 5&#xff09;定制表单验证 6&#xff09;Ajax封装 3、单页面应用&#xff08…...

    2024/4/27 6:26:45
  12. Angular入门02- Module模块、Controller控制器

    AngularJS中&#xff0c;模块是定义应用的最主要方式。模块包含了主要的应用代码。一个应用可以包含多个模块&#xff0c;每一个模块都包含了定义具体功能的代码。 即&#xff1a;angular.module() 用来注册一个应用模块 一、模块定义 AngularJS允许我们使用angular.module()方…...

    2024/5/3 8:35:46
  13. Angular(1)

    1.为什么要学习Angular? 使我们做单页面应用更加容易Angular自身有很多颠覆性的特性 改变了前端的编码方式 简化了我们的操作火,就业需要 2.Angular是什么? 一款非常优秀的前端高级JS框架由谷歌团队负责开发维护 3.学习Angular需要的知识储备 htmlcssjs 4.框架与库 &l…...

    2024/5/3 8:10:05
  14. AngularJS跳转刷新当前页面的问题

    路由部分 .state(page.xx, {url: /xx,templateUrl: xxxx.html,reload:true,})js部分 $state.go(page.xx,{},{reload:true}); 主要在于在路由端也要加上reload:true;...

    2024/5/3 9:17:35
  15. angular2 ChangeDetectorRef (变化检测器的引用)手动控制组件的变化检测行为

    Angular检测机制 监测到异步事件后是怎么判断是否需要更新视图呢&#xff1f;其实比较简单&#xff0c;Angular通过脏检查来判断是否需要更新视图。脏检查其实就是存储所有变量的值&#xff0c;每当可能有变量发生变化需要检查时&#xff0c;就将所有变量的旧值跟新值进行比较&…...

    2024/4/21 4:09:01
  16. AngularJS+Echarts利用Ajax实现数据动态刷新

    这个是最终版&#xff0c;删掉了之前写的&#xff0c;结合AngularJS &#xff0c;利用Ajax动态获取json数据&#xff0c;并动态刷新数据生成柱状图和饼图&#xff0c;当你修改json文件时&#xff0c;一旦保存即可立即加载出来&#xff0c;不用刷新整个页面&#xff0c;这也是aj…...

    2024/5/3 1:29:38
  17. angular-cli 总结

    NPM 版本要求 $ node -v$ npm -v其中 Node 版本需要 6.9.0&#xff0c;NPM 需要 3.0.0。 #安装安装 如果之前安装了&#xff0c;升级到最新版本&#xff1a; $ npm uninstall -g angular/cli$ npm cache clean$ npm install -g angular/clilatest#创建应用创建应用 新建项目…...

    2024/5/1 8:13:27
  18. angularjs ui-view加载刷新

    <li ui-sref-active"active" ui-sref{{childName.url[0]}} ui-sref-opts"{reload: true, notify: true}" ng-repeat"childName in childresource">...

    2024/5/1 19:27:38
  19. angular.js笔记

    document.ready 文档加载完毕&#xff0c;window.onload:整个页面加载完毕 jquery JS函数库 封装简化dom操作 angular JS结构化框架 主体不是dom 而是页面中动态的数据 做什么&#xff1a; 构建单页面应用&#xff08;spa&#xff09;,web app应用 SPA ( sigle page applicati…...

    2024/5/1 6:47:17
  20. angular 模板语法总结

    模板语法&#xff08;模板表达式&#xff09; 一&#xff1a;模板表达式 1.同一标签中 表达式中的上下文变量是由模板定义变量&#xff08;let等产生)、指令的上下文变量&#xff08;如果有&#xff09;和组件的属性叠加而成的。 模板变量是最优先的&#xff0c;其次是指令的…...

    2024/5/1 14:38:58

最新文章

  1. 如何使用 Java 读取 Excel、docx、pdf 和 txt 文件?

    如何使用 Java 读取 Excel、"doc"、"docx"、"pdf" 和 "txt" 文件。 在 Java 开发中&#xff0c;我们经常需要读取不同类型的文件&#xff0c;包括 Excel 表格文件、"doc" 和 "docx" 文档文件、PDF 文件以及纯文本…...

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

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

    2024/5/6 9:38:23
  3. 【Godot4自学手册】第三十五节摇杆控制开门

    本节主要实现&#xff0c;在地宫墙壁上安装一扇门&#xff0c;在核实安装一个开门的摇杆&#xff0c;攻击摇杆&#xff0c;打开这扇门&#xff0c;但是只能攻击一次&#xff0c;效果如下&#xff1a; 一、添加完善节点 切换到underground场景&#xff0c;先将TileMap修改一下…...

    2024/5/3 8:55:49
  4. 数字化时代多系统安全运维解决方案

    添加图片注释&#xff0c;不超过 140 字&#xff08;可选&#xff09; 添加图片注释&#xff0c;不超过 140 字&#xff08;可选&#xff09; 添加图片注释&#xff0c;不超过 140 字&#xff08;可选&#xff09; 添加图片注释&#xff0c;不超过 140 字&#xff08;可选&…...

    2024/5/6 6:47:26
  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/6 9:21:00
  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/6 1:40:42
  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