turi-create 相关问题


在普通的 create-react-app --template typescript 文件夹中安装 eslint 失败

我正在尝试将 eslint 安装到从 TypeScript 模板创建的普通 create-react-app 文件夹中。 我运行了以下命令: % npx create-react-app REDACTED --模板打字稿


create-react 应用程序的替代品是什么

我有一个基于 Create React App 构建的 React 项目,我正在探索替代构建工具。有哪些推荐的方法或工具可以从 Create React App 迁移出来?有什么经历或


如何通过exec os/exec执行sc create命令?

我如何通过exec.Command执行我的sc命令? 代码: cmd := exec.Command("cmd.exe", "sc", "create", "Simpler", "binpath="+os.Getenv("APPDATA")+"\Simpler\cc.exe", "显示名称=我的服务...


React 的“npm create vite@latest”问题:无法初始化项目

我在尝试使用命令 npm create vite@latest 创建新的 React 项目时遇到问题。尽管遵循文档并确保我拥有最新版本的...


Firebird DB 中没有执行访问过程的权限

我遵循手册中的规格: 我创建了一个角色:CREATE ROLE reader;。 用户已创建:CREATE USER voron PASSWORD 'somepassword'。 然后为了授予权限,我执行了以下操作: 格兰特


世博应用程序中缺少应用程序文件夹的路由

简化的expo路由器使用应用程序文件夹中的文件名来创建应用程序路由,但使用npx create-expo-app或npx create-expo-app@latest创建expo应用程序不会导致应用程序直接...


write() 和字符串方法的问题(python)

create = open("lol.balbes.txt", 'w') oldfile = open("mbox-short.txt") 对于旧文件中的行: 线=线.上 线 = str(线) 创建.write(行) 创建.close() 我


使用 create-next-app 启动新的 Next.js 14 应用程序时,为什么会出现与 favicon.ico 相关的“模块未找到”错误?

我运行了以下命令来启动一个新的 Next.js 应用程序: npx create-next-app@latest 但是 npm run dev 给了我以下错误: 找不到模块:无法解析 'C:\xxxxx\xxxxx\xxxxx\my-app\src pp\


在 SQL Developer 上运行创建表学生时出错:CREATE TABLE Students

创建表学生( 年号(4) NOT NULL, 学期 VARCHAR2(1) NOT NULL CONSTRAINT Stu_sem_ck CHECK (学期 IN ('1', '2', '3')), 部门 VARCHAR2(3) NOT NULL, 课程编号...


hierfstat pp.fis 置信区间不包括 Fis 估计值

我正在使用 hierfstat 通过 basic.stats 函数生成基本人口统计数据,并使用 boot.ppfis 生成置信区间: Mydata2indivs <- genind2hierfstat(A) # Create hierf...


带有 Tailwind 风格的 Sveltekit 套件

我正在尝试使用 svelte 打包库创建一个 Svelte 组件包(您可以使用 npm create svelte@latest 并选择 svelte 库进行设置。然后我在


安装pact-lang-api后Webpack/polyfill出错

在尝试连接刚刚使用 create-react-app 创建的 React 前端时,在将 pact-lang-api 导入应用程序后运行 npm run start 时收到此错误消息: ./


如何在 cockroachdb/postgresql 中执行相当于 ADD CONSTRAINT IF NOT EXISTS 的操作?

大多数 PostgreSQL 语句支持 IF NOT EXISTS 子句以允许幂等迁移,例如CREATE TABLE IF NOT EXISTS foo .... 但 ALTER TABLE ... ADD CONSTRAINT 不存在。我怎样才能写...


在 ASP.NET Core 7 WebAPI 上运行 React-App 构建

我有一个 ASP.NET Core 7 WebAPI,有很多路由,例如: domain.com/Api/Product/GetAll domain.com/Api/Product/Delete/ domain.com/Api/Product/Create ... 我有一个反应应用程序,我需要使用它


企业网络VPN:`ddev Composer create`导致“ssl证书问题:自签名证书”

我在 wsl2 下运行 ddev。我在 zscaler 代理后面。我能够将 zscaler 证书复制到 ubuntu“/usr/local/share/ca-certificates”并运行“sudo update-ca-certificates”...


React Router 为动态路由渲染错误组件的问题

我遇到了 React Router 的问题,使用动态参数导航到特定 URL 会渲染错误的组件。具体来说,当导航到 http://localhost:3001/Create/4 时,...


Flutter Firebase 设置和缺少 google_app_id。 Firebase 分析已禁用

我使用命令 flutter create test9_firebase_setup -a kotlin --platforms android 创建了一个新的 Flutter 应用程序。目标是连接到 firebase,并进行身份验证、分析和崩溃处理。 在我的


适合 postgresql12 的 vector.control 版本有哪些?

我在ubuntu上安装了postgresql12并创建了一个名为my_db的数据库。 但我想在 my_db 中安装矢量插件。 直接在my_db中使用命令CREATE EXTENSION向量;将会出现错误


使用 -u 1000:1000 选项进行 docker run 时,Jenkins docker sudo 错误

我有一个 docker 映像,可以在使用以下 DockerFile 创建的 Jenkins 管道中使用: # 根据 来自 ros:noetic # 用户 工作目录/home/用户 运行 useradd --create-home --shell /bin/bash 用户 \ &a...


当我尝试安装React时,我收到此错误如何修复它并安装React

npm 错误!代码 ENOTFOUND npm 错误!系统调用 getaddrinfo npm 错误!错误号 ENOTFOUND npm 错误!对 http://registry.npmjs.org/create-react-app 的网络请求失败,原因: getaddrinfo ENOTFOUND your_proxy...


在编写返回 jsx 的脚本时使用 .js 文件扩展名

我开始使用 React 作为我选择的 ui 框架。在我浏览文档时,我注意到当使用 create-react-app 脚本启动新的 React 样板时,他们使用了 .js


在 Visual Studio Code conda 环境中安装后出现“ModuleNotFoundError:没有名为 'tensorflow' 的模块”

我正在寻求在 VSCode 内的 anaconda3 python 笔记本中将tensorflow与conda结合使用。 在 Windows 10 机器上的 anaconda 终端中,我使用了以下命令: conda create --name deeplear...


添加plugin:@typescript-eslint/recommended-requiring-type-checking后,提示tsconfig中未包含该文件

我用 npx create-react-app my-app --template typescript 创建一个项目,然后我向其中添加打字稿类型检查,但我的 App.tsx 报告以下错误: 解析错误:ESLint 已配置...


错误:链接需要在项目的 Expo 配置(app.config.js 或 app.json)中进行构建时设置 `scheme`

我使用react-native expo bare-workflow创建了该项目 npx create-expo-app --template bare-minimum 创建项目后,我尝试将expo-router安装到项目中,一切都完成了


执行 npm install 时,使用 React-scripts 版本创建 React App 错误

对于我的 Create React 应用程序,我在执行 npm install 时收到以下错误 npm 错误!代码 ERESOLVE npm 错误! ERESOLVE 无法解析依赖关系树 npm 错误! npm 错误!解析时:[email protected]...


存档 Xcode 项目时出错:Sandbox: mkdir(23381) Deny(1) file-write-create

我目前正在尝试存档我的 xcode 项目,但收到此错误: 沙箱:mkdir(23381)拒绝(1)文件写入创建 有谁知道这个错误是什么意思?我没有使用 swift 或任何...


使用打字稿创建react-app css模块:无法解析.module.css

我正在尝试将CSS模块与打字稿和create-react-app反应应用程序一起使用。 我确实导入了'./App.modules.css';在我的 App.tsx 中,但出现错误: 找不到模块:无法解析'./App.modules.cs...


当我点击输入字段时,Flowbite 日期选择器不显示

我有一个 create-react-app 项目,我正在尝试将日期选择器添加到表单中。 我正在使用流咬合 然后我将插件和内容添加到 tailwind.config 文件中 插件:[ 要求('流...


更新到最新版本的 Node.js 后检测到可能的 EventEmitter 内存泄漏

我已经升级到最新的稳定版本的节点(20.9.0),现在每当我使用 npx create-react-app 或使用 vite 制作 React 应用程序时,它总是显示“可能的 eventEmitter 内存泄漏


/pharmcare/患者-create/处的值错误:“在使用此多对多关系之前,需要为字段“id”提供值。”

请帮助我解决我正在创建的名为 Pharmacare 的 Django 应用程序,解决我遇到的问题。我已经被这个值错误困住了两天了,我研究了如何在使用时解决它......


“拒绝应用 {link} 中的样式,因为其 MIME 类型不受支持且启用了严格的 MIME 检查。”在 Vue+Vuetify 应用程序中

我使用 vue-create-app 创建了一个 Vue+Vuetify 项目。在我的本地系统中,Vuetify 工作正常,但在 Gitlab 实时服务器上不起作用。并在实时应用程序中显示此错误消息: “拒绝应用...


Laravel POST 方法返回状态:405 不允许在 POST 方法上使用方法

请查找以下信息: NoteController.php 请查找以下信息: NoteController.php <?php namespace App\Http\Controllers; use App\Http\Requests\NoteRequest; use App\Models\Note; use Illuminate\Http\JsonResponse; class NoteController extends Controller { public function index():JsonResponse { $notes = Note::all(); return response()->json($notes, 200); } public function store(NoteRequest $request):JsonResponse { $note = Note::create( $request->all() ); return response()->json([ 'success' => true, 'data' => $note ], 201); } public function show($id):JsonResponse { $note = Note::find($id); return response()->json($note, 200); } public function update(NoteRequest $request, $id):JsonResponse { $note = Note::find($id); $note->update($request->all()); return response()->json([ 'success' => true, 'data' => $note, ], 200); } public function destroy($id):JsonResponse { Note::find($id)->delete(); return response()->json([ 'success' => true ], 200); } } NoteRequest.php <?php namespace App\Http\Requests; use Illuminate\Foundation\Http\FormRequest; class NoteRequest extends FormRequest { public function authorize() { return true; } public function rules() { return [ 'title', 'required|max:255|min:3', 'content', 'nullable|max:255|min:10', ]; } } Note.php(模型) <?php namespace App\Models; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; class Note extends Model { use HasFactory; protected $guarded = []; } api.php <?php use App\Http\Controllers\NoteController; use Illuminate\Support\Facades\Route; Route::prefix('v1')->group(function () { Route::resource('/note', NoteController::class); }); php artisan 路线:列表 GET|HEAD / ...................................................................................................................... POST _ignition/execute-solution ............... ignition.executeSolution › Spatie\LaravelIgnition › ExecuteSolutionController GET|HEAD _ignition/health-check ........................... ignition.healthCheck › Spatie\LaravelIgnition › HealthCheckController POST _ignition/update-config ........................ ignition.updateConfig › Spatie\LaravelIgnition › UpdateConfigController GET|HEAD api/v1/note .......................................................................... note.index › NoteController@index POST api/v1/note .......................................................................... note.store › NoteController@store GET|HEAD api/v1/note/create ................................................................. note.create › NoteController@create GET|HEAD api/v1/note/{note} ..................................................................... note.show › NoteController@show PUT|PATCH api/v1/note/{note} ................................................................. note.update › NoteController@update DELETE api/v1/note/{note} ............................................................... note.destroy › NoteController@destroy GET|HEAD api/v1/note/{note}/edit ................................................................ note.edit › NoteController@edit GET|HEAD sanctum/csrf-cookie .................................. sanctum.csrf-cookie › Laravel\Sanctum › CsrfCookieController@show 迅雷请求(同邮递员) JSON 请求 { "title": "Hello World", "content": "Lorem ipsum." } 尝试发出 JSON POST 请求并获取状态:405 方法不允许并且我正在使用 php artisan 服务,如果需要,我可以提供 GIT 项目。请告诉我。 您的验证规则看起来不正确。在您的 NoteRequest 类中,规则应该是一个关联数组,其中键是字段名称,值是验证规则。但是,在您的代码中,规则被定义为以逗号分隔的字符串列表。这可能会导致验证失败并返回 405 Method Not allowed 错误。 public function rules() { return [ 'title' => 'required|max:255|min:3', 'content' => 'nullable|max:255|min:10', ]; }


AnimationSet 未按预期执行顺序动画

如果我手动执行多个连续动画。它按预期工作。这是我的可行代码 扩展.xml 如果我手动执行多个连续动画。它按预期工作。这是我的可行代码 scale_up.xml <?xml version="1.0" encoding="utf-8"?> <scale xmlns:android="http://schemas.android.com/apk/res/android" android:fromXScale="1.0" android:fromYScale="1.0" android:toXScale="1.1" android:toYScale="1.1" android:pivotX="50%" android:pivotY="50%" android:fillAfter="true" android:interpolator="@android:anim/decelerate_interpolator" android:duration="@android:integer/config_shortAnimTime" /> scale_down.xml <?xml version="1.0" encoding="utf-8"?> <scale xmlns:android="http://schemas.android.com/apk/res/android" android:fromXScale="1.1" android:fromYScale="1.1" android:toXScale="1.0" android:toYScale="1.0" android:pivotX="50%" android:pivotY="50%" android:fillAfter="true" android:interpolator="@android:anim/decelerate_interpolator" android:duration="@android:integer/config_shortAnimTime" /> 手动执行连续动画 public void startAnimation(Button button) { // Define the scale up animation Animation scaleUpAnimation = AnimationUtils.loadAnimation(this, R.anim.scale_up); // Define the scale down animation Animation scaleDownAnimation = AnimationUtils.loadAnimation(this, R.anim.scale_down); scaleUpAnimation.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { button.startAnimation(scaleDownAnimation); } @Override public void onAnimationRepeat(Animation animation) { } }); button.startAnimation(scaleUpAnimation); } 结果 但是,如果我尝试使用 AnimationSet 替换上述代码,动画结果就会损坏。 public void startAnimation(Button button) { // Define the scale up animation Animation scaleUpAnimation = AnimationUtils.loadAnimation(this, R.anim.scale_up); // Define the scale down animation Animation scaleDownAnimation = AnimationUtils.loadAnimation(this, R.anim.scale_down); // Create an AnimationSet to combine both animations // (It makes no difference whether I am using true or false) AnimationSet animationSet = new AnimationSet(true); animationSet.addAnimation(scaleUpAnimation); animationSet.addAnimation(scaleDownAnimation); // Apply the animation to the button button.startAnimation(animationSet); } 使用AnimationSet的结果(动画不流畅) 我可以知道为什么AnimationSet不起作用吗?谢谢。 我们需要使用setStartOffset来延迟第二个动画的执行。这是解决上述问题的完整代码片段。 public void startAnimation(Button button) { int config_shortAnimTime = getResources().getInteger(android.R.integer.config_shortAnimTime); // Define the scale up animation ScaleAnimation scaleUpAnimation = new ScaleAnimation( 1f, 1.02f, 1f, 1.02f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f ); scaleUpAnimation.setInterpolator(new DecelerateInterpolator()); scaleUpAnimation.setDuration(config_shortAnimTime); scaleUpAnimation.setFillAfter(true); // Define the scale down animation ScaleAnimation scaleDownAnimation = new ScaleAnimation( 1.02f, 1f, 1.02f, 1f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f ); scaleDownAnimation.setInterpolator(new AccelerateInterpolator()); scaleDownAnimation.setDuration(config_shortAnimTime); scaleDownAnimation.setFillAfter(true); scaleDownAnimation.setStartOffset(scaleUpAnimation.getDuration()); // Create an AnimationSet to combine both animations AnimationSet animationSet = new AnimationSet(false); animationSet.addAnimation(scaleUpAnimation); animationSet.addAnimation(scaleDownAnimation); // Apply the animation to the button button.startAnimation(animationSet); }


为什么 Odoo 17 没有在 <notebook> 中为我的字段渲染标签?

我正在运行有关 Odoo 17 开发的教程,并为第 7 章中的练习创建了以下代码: 我正在运行有关 Odoo 17 开发的教程,并且我为第 7 章中的练习创建了此代码: <record id="estate_view_form" model="ir.ui.view"> <field name="name">estate.property.form</field> <field name="model">estate.property</field> <field name="arch" type="xml"> <form string="Estate Property" create="True"> <sheet> <group string="Info"> <field name="name" /> <field name="description" /> </group> <group string="Location"> <field name="postcode" /> </group> <notebook> <page string="Specs"> <field name="facades" /> <field name="garage" /> </page> </notebook> </sheet> </form> </field> </record> 它可以工作,但 <notebook> 中字段的标签未呈现。我尝试添加 string 属性,但这不起作用。 <notebook> 上的 文档没有提及任何有关此行为的信息。 IIRC 自从我使用的每个版本(6.1+)以来,你必须在 group 周围有一个 field 才能自动获取标签。


在这个curl api中将不记名授权令牌放在哪里

我正在使用 imageqrcode (https://imageqrcode.com/apidocumentation) 的新 api 功能来动态生成图像 QR 码,使用 php: 我正在使用 imageqrcode (https://imageqrcode.com/apidocumentation) 的新 api 功能来动态生成图像 QR 码,使用 php: <?php $api_key = 'xxxxxxxxxx'; //secret // instantiate data values $data = array( 'apikey' => $api_key, 'qrtype' => 'v1', 'color' => '000000', 'text' => 'https://wikipedia.com', ); // connect to api $url = 'https://app.imageqrcode.com/api/create/url'; $ch = curl_init($url); // Attach image file $imageFilePath = 'test1.jpg'; $imageFile = new CURLFile($imageFilePath, 'image/jpeg', 'file'); $data['file'] = $imageFile; curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); curl_close($ch); // Handle the response $result = json_decode($response, true); if ($result && isset($result['downloadURL'])) { // Successful request $download_url = $result['downloadURL']; echo "Download URL: $download_url"; } else { // Handle errors echo "Error: " . print_r($result, true); } ?> 在文档中显示有变量“serialkey”: 图片二维码API文档 API文档 生效日期:2023年11月15日 图像二维码 API 是一项接受 HTTPS 请求以生成图像或 gif 二维码的服务,主要由开发人员使用。 图像二维码 - URL JSON 请求(POST):https://app.imageqrcode.com/api/create/url apikey //你的apikey 序列号//你的序列号 qrtype //字符串,最少 2 个字符,最多 2 个字符v1 或 v2,v1 适用于 QR 类型 1,v2 适用于类型 2 color //数字,最小 6 位,最大 6 位,例如000000 为黑色 text //url,最少 15 个字符,最多 80 个字符https://yourwebsite.com file //图像文件 (jpg/jpeg/png),最大 1 MB 文件大小 现在没有信息将该序列密钥作为标准承载授权令牌放在哪里???如果没有此信息,我无法连接到 api 我尝试在没有不记名令牌的情况下连接它,因为我认为它可以匿名连接到 api,但也不起作用,我现在很困惑,因为我仍在学习 PHP 和 Laravel 看起来 serialkey 不是不记名令牌,而是一个应该与其他参数(如 apikey、qrtype、color、text 和 )一起包含在 POST 数据中的参数file。您可以在 PHP 代码的 serialkey 数组中包含 $data。 $data = array( 'apikey' => $api_key, 'serialkey' => 'your_serial_key', // Add this line 'qrtype' => 'v1', 'color' => '000000', 'text' => 'https://wikipedia.com', );


对于使用PHP的循环,我想使用PHP在数据库表中插入动态行,每行有10列

我有一个这样的数据库表 我想动态插入从 0000 到 0999 的数据,连续 10 个数据,如下所示 我正在尝试这样的事情 我有一个这样的数据库表 我想动态插入从 0000 到 0999 的数据,连续 10 个数据,如下所示 我正在尝试这样的事情 <?php for($i=0;$i<=999;$i++){ $num= str_pad($i, 4, "0", STR_PAD_LEFT); $x = 10; if ($i % $x == 0) { mysqli_query($con,"INSERT INTO `0000_0999` (`id`, `col1`, `col2`, `col3`, `col4`, `col5`, `col6`, `col7`, `col8`, `col9`, `col10`, `col11`) VALUES (NULL, '', '', '', '', '', '', '', '', '', '', '');") } } ?> 但我不知道如何传递列明智的数据。 您只需创建一个数组来保存每行的列值 对于每一行,您必须保存该列的值,您可以简单地创建一个数组来保存 并迭代循环并将数据插入数据库 使用此代码: for ($i = 0; $i <= 999; $i++) { $num = str_pad($i, 4, "0", STR_PAD_LEFT); // Create an array to hold column values for each row $rowData = array( 'col1' => '', 'col2' => '', 'col3' => '', 'col4' => '', 'col5' => '', 'col6' => '', 'col7' => '', 'col8' => '', 'col9' => '', 'col10' => '' ); // Convert the array values into a comma-separated string $values = "'" . implode("', '", $rowData) . "'"; // Your insert query $query = "INSERT INTO `0000_0999` (`id`, `col1`, `col2`, `col3`, `col4`, `col5`, `col6`, `col7`, `col8`, `col9`, `col10`, `col11`) VALUES (NULL, $values)";} 逐步解释 步骤 1 - 在此过程中,我创建了一个数组,并在该数组中设置了列值 步骤 2 - 我将数组值转换为字符串(逗号分隔) 第 3 步 - 插入值


ML.net - CreateTimeSeriesEngine

我正在使用 ML.net 进行时间序列分析项目。在这里我尝试预测欧元兑美元的交易汇率。我从 CSV 文件加载数据并使用内存数据创建 IDataView。 列表 我正在使用 ML.net 进行时间序列分析项目。在这里我尝试预测欧元兑美元的交易汇率。我从 CSV 文件加载数据并使用内存数据创建 IDataView。 List<RateData> infoList = new List<RateData>(); // populate list infoList = FileParser(infoList); IDataView data = mlContext.Data.LoadFromEnumerable<RateData>(infoList); 我设法像这样运行预测估计器 var forecastEstimator = mlContext.Forecasting.ForecastBySsa( outputColumnName: nameof(RatePrediction.CurrentRate), inputColumnName: nameof(RateData.HistoricalRate), windowSize: 14, seriesLength: numRateDataPoints, trainSize: numRateDataPoints, horizon: 1, confidenceLevel: 0.95f ); SsaForecastingTransformer forecaster = forecastEstimator.Fit(RateDataSeries); 然后我尝试创建这样的预测引擎 var ForecastEngine = Forecaster.CreateTimeSeriesEngine(mlContext); 这里我遇到了一些错误。 我的输入和输出类如下: public class RateData { public DateTime TransactionDate { get; set; } public float HistoricalRate { get; set; } } public class RatePrediction { public float CurrentRate; } 我有这样的错误 System.InvalidOperationException: Can't bind the IDataView column 'CurrentRate' of type 'Vector<Single, 1>' to field or property 'CurrentRate' of type 'System.Single'. at Microsoft.ML.Data.TypedCursorable`1..ctor(IHostEnvironment env, IDataView data, Boolean ignoreMissingColumns, InternalSchemaDefinition schemaDefn) at Microsoft.ML.Data.TypedCursorable`1.Create(IHostEnvironment env, IDataView data, Boolean ignoreMissingColumns, SchemaDefinition schemaDefinition) at Microsoft.ML.Transforms.TimeSeries.TimeSeriesPredictionEngine`2.PredictionEngineCore(IHostEnvironment env, InputRow`1 inputRow, IRowToRowMapper mapper, Boolean ignoreMissingColumns, SchemaDefinition outputSchemaDefinition, Action& disposer, IRowReadableAs`1& outputRow) at Microsoft.ML.PredictionEngineBase`2..ctor(IHostEnvironment env, ITransformer transformer, Boolean ignoreMissingColumns, SchemaDefinition inputSchemaDefinition, SchemaDefinition outputSchemaDefinition, Boolean ownsTransformer) at Microsoft.ML.Transforms.TimeSeries.TimeSeriesPredictionEngine`2..ctor(IHostEnvironment env, ITransformer transformer, Boolean ignoreMissingColumns, SchemaDefinition inputSchemaDefinition, SchemaDefinition outputSchemaDefinition) at Microsoft.ML.Transforms.TimeSeries.PredictionFunctionExtensions.CreateTimeSeriesEngine[TSrc,TDst](ITransformer transformer, IHostEnvironment env, Boolean ignoreMissingColumns, SchemaDefinition inputSchemaDefinition, SchemaDefinition outputSchemaDefinition) at USD_EURO_Conversion_rate.TimeSeriesModelHelper.FitAndSaveModel(MLContext mlContext, IDataView RateDataSeries, String outputModelPath) 预测类中的属性需要是float[]类型;向量/数组而不是单个值,例如 public class RatePrediction { public float[] CurrentRate; } 类似于此处的Microsoft 示例。


Pinia 对象在 Vue 中的 foreach 后失去反应性

我有这个嵌套的foreach BalanceItemList.vue ... 我有这个嵌套的 foreach BalanceItemList.vue <template> <div v-for="category in categoryItemsStore.balanceCategories" :key="category.id" class="mt-5"> <div class="border-black border-b bg-gray-200"> <span class="font-bold w-full">{{ category.name }}</span> </div> <div v-for="balanceItem in category.balance_items" :key="balanceItem.id"> {{ balanceItem.total = 500 }} <balance-item :balance-item="balanceItem" @update-balance-item="update"/> </div> <div> <balance-item-create :category="category.id" @create-balance-item="update"/> </div> <div v-if="categoryItemsStore.totals[category.id]" class="grid grid-cols-4-b t-2 ml-2"> <div :class="category.is_positive ? '': 'text-red-600' " class="col-start-4 border-t-2 border-black font-bold"> &euro;{{ categoryItemsStore.totals[category.id].total }} </div> </div> </div> </template> 我像这样检查了“balanceItem”的反应性 {{ balanceItem.total = 500 }} 它在商店中更新,但随后我有了我的平衡项目组件: BalanceItem.vue <script setup> import {reactive} from "vue"; import {useForm} from "@inertiajs/vue3"; import NumberInput from "@/Components/NumberInput.vue"; import {UseCategoryItemsStore} from "@/Stores/UseCategoryItemsStore.js"; const categoryItemStore = UseCategoryItemsStore() const props = defineProps({balanceItem: Object, errors: Object}) let item = reactive(props.balanceItem); const form = useForm(item); const emit = defineEmits(['update-balance-item']) const submit = () => { form.post(route('balance-item.update'), { preserveScroll: true, onSuccess: () => { props.balanceItem.total = 500 categoryItemStore.updateBalanceItemsTotals(form) emit('update-balance-item') } }) } </script> <template> <form @submit.prevent="submit"> <div class="grid grid-cols-4-b"> <span>{{ item.name }}</span> <NumberInput v-model="form.count" autofocus class=" mr-4 mt-1 block" type="number" @update:model-value="submit" /> <div :class="item.item_category.is_positive ? '' : 'text-red-600'" class="flex place-items-center"> <div class="pt-1 mr-1">&euro;</div> <NumberInput v-model="form.amount" :class="form.errors.amount ? 'border-red-600' : ''" autofocus class="mt-1 mr-4 w-5/6" type="text" @update:model-value="submit" /> </div> <div :class="item.item_category.is_positive ? '' : 'text-red-600'" class="flex place-items-center"> <div class="pt-1 mr-1 w-5/6">&euro;</div> <NumberInput v-model="form.total" autofocus class="mt-1 block" disabled style="max-width: 95%" type="text" /> </div> </div> </form> </template> 这是我测试反应性的商店。如果我增加输入的数字,则项目的计数保持不变 UseCategoryItemsStore.js import {defineStore} from "pinia"; import {ref} from "vue"; export const UseCategoryItemsStore = defineStore('UseCategoryItemsStore', () => { const balanceCategories = ref([]) const totals = ref([]) function getBalanceItems() { axios.get(route('balance-item.index')).then((response) => { balanceCategories.value = response.data // console.log(balanceCategories.value) }) } function getTotals() { axios.get(route('balance-item.totals')).then((response) => totals.value = response.data) } function getData() { getTotals() getBalanceItems() } function updateBalanceItemsTotals(selectedItem) { balanceCategories.value.forEach((category) => { category.balance_items.forEach((item) => { if (item.id === selectedItem.id) { // item.total = item.count * item.amount console.log(item) } }) }) } getTotals() getBalanceItems() return {balanceCategories, totals, getBalanceItems, getTotals, getData, updateBalanceItemsTotals} }) 在此测试中,我执行“props.balanceItem.total = 500”。但如果我检查商店,它不会更新。看来将“balanceItem”分配给一个道具会失去与我的 Pinia 商店的反应性。我可以使用“form.total = form.count * form.amount”手动更新我的表单,但这对我来说似乎很老套,我想使用 Pinia 商店的反应性。我考虑过根据“BalanceItem”获取 Pina 项目,但这似乎也很棘手。谁知道为什么失去反应性? 我有laravel 10.39、vue3.2.41和pinia 2.1.17惯性0.6.11。到目前为止我知道的所有最新版本。 我像这样更新我的表格和商店: <script setup> import {useForm} from "@inertiajs/vue3"; import NumberInput from "@/Components/NumberInput.vue"; import {UseCategoryItemsStore} from "@/Stores/UseCategoryItemsStore.js"; const categoryItemStore = UseCategoryItemsStore() const props = defineProps({balanceItem: Object, errors: Object}) let item = categoryItemStore.getItemById(props.balanceItem); let form = useForm(item); const emit = defineEmits(['update-balance-item']) const submit = () => { form.post(route('balance-item.update'), { preserveScroll: true, onSuccess: () => { item = categoryItemStore.updateItem(form) form = useForm(item) emit('update-balance-item') } }) } </script> 我将此功能添加到我的商店: import {defineStore} from "pinia"; import {ref} from "vue"; export const UseCategoryItemsStore = defineStore('UseCategoryItemsStore', () => { const balanceCategories = ref([]) const totals = ref([]) function getBalanceItems() { axios.get(route('balance-item.index')).then((response) => { balanceCategories.value = response.data // console.log(balanceCategories.value) }) } function getItemById(item) { let category = balanceCategories.value.find((category) => { return category.id === item.item_category_id }) return category.balance_items.find((item_from_store) => { return item_from_store.id === item.id }) } function updateItem(form) { const item = getItemById(form) item.count = form.count item.amount = form.amount item.total = item.count * item.amount return item } function getTotals() { axios.get(route('balance-item.totals')).then((response) => totals.value = response.data) } function getData() { getTotals() getBalanceItems() } getTotals() getBalanceItems() return {balanceCategories, totals, getBalanceItems, getTotals, getData, getItemById, updateItem} }) 假设如果帖子获得 200,我的表单值可用于更新商店和更新表单。这是我能想到的最好的


错误:在此 BlocBuilder<InternetBloc> Widget<InternetBloc, InternetState> 上方找不到正确的提供程序

我在尝试将 flutter_bloc 集成到 flutter 项目中时遇到错误。 错误:在此 BlocBuilder 上方找不到正确的 Provider 我在尝试将 flutter_bloc 集成到 flutter 项目中时遇到错误。 错误:在此 BlocBuilder Widget 上方找不到正确的提供者 这是我正在使用的代码示例。 internet_state.dart abstract class InternetState{} class InitialInternetState extends InternetState{} class LostConnectionInternetState extends InternetState{} class GainConnectionInternetState extends InternetState{} internet_event.dart abstract class InternetEvent{} class LostConnectionEvent extends InternetEvent{} class GainConnectionEvent extends InternetEvent{} internet_bloc.dart class InternetBloc extends Bloc<InternetEvent, InternetState>{ final Connectivity _connectivity = Connectivity(); StreamSubscription? streamSubscription; InternetBloc() : super(InitialInternetState()){ on<GainConnectionEvent>((event, emit) => emit(GainConnectionInternetState())); on<LostConnectionEvent>((event, emit) => emit(LostConnectionInternetState())); _connectivity.onConnectivityChanged.listen((event) { if(event == ConnectivityResult.mobile || event == ConnectivityResult.wifi){ add(GainConnectionEvent()); } else { add(LostConnectionEvent()); } }); } @override Future<void> close() { streamSubscription?.cancel(); return super.close(); } } main.dart class MyApp extends StatelessWidget { const MyApp({super.key}); @override Widget build(BuildContext context) { return MaterialApp( title: 'Flutter Demo', theme: ThemeData( colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple), useMaterial3: true, ), home: const MyHomePage(title: 'Flutter Demo Home Page'), ); } } class MyHomePage extends StatelessWidget { const MyHomePage({super.key, required this.title}); final String title; @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar(title: Text(title),), body: SafeArea( child: Center(child: BlocBuilder<InternetBloc, InternetState>( builder: (context, state) { return const Text("hello"); }, )), ),); } } 我明白了。 ======== 小部件库捕获异常====================================== =================== 构建 MediaQuery(MediaQueryData(size: Size(392.7, 783.3), devicePixelRatio: 2.8, textScaler: noscaling, platformBrightness: Brightness.light, padding: EdgeInsets.zero, viewPadding: EdgeInsets.zero, viewInsets: EdgeInsets 时抛出以下 ProviderNotFoundException。零,systemGestureInsets:EdgeInsets(29.8,24.0,29.8,8.0),alwaysUse24HourFormat:假,accessibleNavigation:假,highContrast:假,onOffSwitchLabels:假,disableAnimations:假,invertColors:假,boldText:假,navigationMode:传统,gestureSettings:DeviceGestureSettings (touchSlop:8.0),显示功能:[])): 错误:无法在此 BlocBuilder Widget 之上找到正确的提供程序 发生这种情况是因为您使用了不包含提供程序的 BuildContext 你的选择。有以下几种常见场景: 您在main.dart中添加了一个新的提供程序并执行了热重载。 要修复此问题,请执行热重启。 您尝试阅读的提供商处于不同的路线。 提供商具有“范围”。因此,如果您在路线中插入提供者,那么 其他路线将无法访问该提供商。 您使用了 BuildContext,它是您尝试读取的提供程序的祖先。 确保 BlocBuilder 位于您的 MultiProvider/Provider 下。 当您创建提供程序并尝试立即读取它时,通常会发生这种情况。 例如,代替: Widget build(BuildContext context) { return Provider<Example>( create: (_) => Example(), // Will throw a ProviderNotFoundError, because `context` is associated // to the widget that is the parent of `Provider<Example>` child: Text(context.watch<Example>().toString()), ); } 考虑使用builder,如下所示: Widget build(BuildContext context) { return Provider<Example>( create: (_) => Example(), // we use `builder` to obtain a new `BuildContext` that has access to the provider builder: (context, child) { // No longer throws return Text(context.watch<Example>().toString()); } ); } 如果这些解决方案都不起作用,请考虑在 StackOverflow 上寻求帮助: https://stackoverflow.com/questions/tagged/flutter The relevant error-causing widget was: SafeArea SafeArea:file:///Users/../Projects/flutterTest/bloc_test/lib/main.dart:37:13 When the exception was thrown, this was the stack: #0 Provider._inheritedElementOf (package:provider/src/provider.dart:343:7) #1 Provider.of (package:provider/src/provider.dart:293:30) #2 ReadContext.read (package:provider/src/provider.dart:649:21) #3 _BlocBuilderBaseState.initState (package:flutter_bloc/src/bloc_builder.dart:130:36) #4 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:5602:55) #5 ComponentElement.mount (package:flutter/src/widgets/framework.dart:5447:5) ... Normal element mounting (4 frames) #9 Element.inflateWidget (package:flutter/src/widgets/framework.dart:4326:16) #10 Element.updateChild (package:flutter/src/widgets/framework.dart:3831:20) #11 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5496:16) #12 Element.rebuild (package:flutter/src/widgets/framework.dart:5187:7) #13 ProxyElement.update (package:flutter/src/widgets/framework.dart:5800:5) #14 Element.updateChild (package:flutter/src/widgets/framework.dart:3815:15) #15 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6743:14) #16 Element.updateChild (package:flutter/src/widgets/framework.dart:3815:15) #17 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5496:16) #18 Element.rebuild (package:flutter/src/widgets/framework.dart:5187:7) #19 StatelessElement.update (package:flutter/src/widgets/framework.dart:5547:5) #20 Element.updateChild (package:flutter/src/widgets/framework.dart:3815:15) #21 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5496:16) #22 Element.rebuild (package:flutter/src/widgets/framework.dart:5187:7) #23 StatelessElement.update (package:flutter/src/widgets/framework.dart:5547:5) #24 Element.updateChild (package:flutter/src/widgets/framework.dart:3815:15) #25 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5496:16) #26 Element.rebuild (package:flutter/src/widgets/framework.dart:5187:7) #27 StatelessElement.update (package:flutter/src/widgets/framework.dart:5547:5) #28 Element.updateChild (package:flutter/src/widgets/framework.dart:3815:15) #29 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5496:16) #30 Element.rebuild (package:flutter/src/widgets/framework.dart:5187:7) #31 ProxyElement.update (package:flutter/src/widgets/framework.dart:5800:5) #32 Element.updateChild (package:flutter/src/widgets/framework.dart:3815:15) #33 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5496:16) #34 Element.rebuild (package:flutter/src/widgets/framework.dart:5187:7) #35 ProxyElement.update (package:flutter/src/widgets/framework.dart:5800:5) #36 Element.updateChild (package:flutter/src/widgets/framework.dart:3815:15) #37 Element.updateChildren (package:flutter/src/widgets/framework.dart:3964:32) #38 MultiChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6896:17) #39 Element.updateChild (package:flutter/src/widgets/framework.dart:3815:15) #40 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5496:16) #41 Element.rebuild (package:flutter/src/widgets/framework.dart:5187:7) #42 ProxyElement.update (package:flutter/src/widgets/framework.dart:5800:5) #43 Element.updateChild (package:flutter/src/widgets/framework.dart:3815:15) #44 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5496:16) #45 StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:5634:11) #46 Element.rebuild (package:flutter/src/widgets/framework.dart:5187:7) #47 StatefulElement.update (package:flutter/src/widgets/framework.dart:5657:5) #48 Element.updateChild (package:flutter/src/widgets/framework.dart:3815:15) #49 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5496:16) #50 StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:5634:11) #51 Element.rebuild (package:flutter/src/widgets/framework.dart:5187:7) #52 StatefulElement.update (package:flutter/src/widgets/framework.dart:5657:5) #53 Element.updateChild (package:flutter/src/widgets/framework.dart:3815:15) #54 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5496:16) #55 Element.rebuild (package:flutter/src/widgets/framework.dart:5187:7) #56 ProxyElement.update (package:flutter/src/widgets/framework.dart:5800:5) #57 Element.updateChild (package:flutter/src/widgets/framework.dart:3815:15) #58 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5496:16) #59 StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:5634:11) #60 Element.rebuild (package:flutter/src/widgets/framework.dart:5187:7) #61 StatefulElement.update (package:flutter/src/widgets/framework.dart:5657:5) #62 Element.updateChild (package:flutter/src/widgets/framework.dart:3815:15) #63 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6743:14) #64 Element.updateChild (package:flutter/src/widgets/framework.dart:3815:15) #65 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5496:16) #66 Element.rebuild (package:flutter/src/widgets/framework.dart:5187:7) #67 ProxyElement.update (package:flutter/src/widgets/framework.dart:5800:5) #68 Element.updateChild (package:flutter/src/widgets/framework.dart:3815:15) #69 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6743:14) #70 Element.updateChild (package:flutter/src/widgets/framework.dart:3815:15) #71 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5496:16) #72 StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:5634:11) #73 Element.rebuild (package:flutter/src/widgets/framework.dart:5187:7) #74 StatefulElement.update (package:flutter/src/widgets/framework.dart:5657:5) #75 Element.updateChild (package:flutter/src/widgets/framework.dart:3815:15) #76 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5496:16) #77 StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:5634:11) #78 Element.rebuild (package:flutter/src/widgets/framework.dart:5187:7) #79 StatefulElement.update (package:flutter/src/widgets/framework.dart:5657:5) #80 Element.updateChild (package:flutter/src/widgets/framework.dart:3815:15) #81 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5496:16) #82 Element.rebuild (package:flutter/src/widgets/framework.dart:5187:7) #83 ProxyElement.update (package:flutter/src/widgets/framework.dart:5800:5) #84 Element.updateChild (package:flutter/src/widgets/framework.dart:3815:15) #85 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5496:16) #86 Element.rebuild (package:flutter/src/widgets/framework.dart:5187:7) #87 ProxyElement.update (package:flutter/src/widgets/framework.dart:5800:5) #88 Element.updateChild (package:flutter/src/widgets/framework.dart:3815:15) #89 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5496:16) #90 Element.rebuild (package:flutter/src/widgets/framework.dart:5187:7) #91 ProxyElement.update (package:flutter/src/widgets/framework.dart:5800:5) #92 Element.updateChild (package:flutter/src/widgets/framework.dart:3815:15) #93 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5496:16) #94 StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:5634:11) #95 Element.rebuild (package:flutter/src/widgets/framework.dart:5187:7) #96 StatefulElement.update (package:flutter/src/widgets/framework.dart:5657:5) #97 Element.updateChild (package:flutter/src/widgets/framework.dart:3815:15) #98 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5496:16) #99 Element.rebuild (package:flutter/src/widgets/framework.dart:5187:7) #100 ProxyElement.update (package:flutter/src/widgets/framework.dart:5800:5) #101 Element.updateChild (package:flutter/src/widgets/framework.dart:3815:15) #102 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5496:16) #103 StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:5634:11) #104 Element.rebuild (package:flutter/src/widgets/framework.dart:5187:7) #105 StatefulElement.update (package:flutter/src/widgets/framework.dart:5657:5) #106 Element.updateChild (package:flutter/src/widgets/framework.dart:3815:15) #107 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5496:16) #108 Element.rebuild (package:flutter/src/widgets/framework.dart:5187:7) #109 BuildOwner.buildScope (package:flutter/src/widgets/framework.dart:2895:19) #110 WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:984:21) #111 RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:457:5) #112 SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1325:15) #113 SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:1255:9) #114 SchedulerBinding.scheduleWarmUpFrame.<anonymous closure> (package:flutter/src/scheduler/binding.dart:978:7) #118 _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:184:12) (elided 3 frames from class _Timer and dart:async-patch) ==================================================================================================== 我不想使用像 MultiProvider 这样的全局提供程序。 您应该在某处创建 InternetBloc 并提供它。 MultiProvider 本身并不是全局的,它只是多个。 更多信息在这里:https://bloclibrary.dev/#/flutterbloccoreconcepts?id=blocprovider 所以,如果您不想使用全局提供程序,它将看起来像这样: class MyHomePage extends StatelessWidget { const MyHomePage({super.key, required this.title}); final String title; @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text(title), ), body: SafeArea( child: Center( child: BlocProvider<InternetBloc>( create: ( context) => InternetBloc(), child: BlocBuilder<InternetBloc, InternetState>( builder: (context, state) { return const Text("hello"); }, ), ), ), ), ); } } 要使用 BlocBuilder,您需要在 Widget 树中放置一个 BlocProvider。最佳实践是将其放置得尽可能深。在您的情况下,只需将 BlocProvider 放在 BlocBuilder 之上。 此外 MultiProvider / MultiBlocProvider 不是全局 Provider。它只是一个提供多个 Provider/BlocProvider 的便捷小部件。 class MyHomePage extends StatelessWidget { const MyHomePage({super.key, required this.title}); final String title; @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text(title), ), body: SafeArea( child: Center( // Now everything below that can access the InternetBloc child: BlocProvider<InternetBloc>( create: (_) => InternetBloc(), child: BlocBuilder<InternetBloc, InternetState>( builder: (context, state) { return const Text("hello"); }, ), ), ), ), ); } }


Laravel 中的策略对我不起作用,这是我的代码

我无法让策略在我的 Laravel 项目中工作,我安装了一个新项目来从头开始测试,我有这个控制器: 我无法让策略在我的 Laravel 项目中工作,我安装了一个新项目来从头开始测试,我有这个控制器: <?php namespace App\Http\Controllers; use App\Http\Controllers\Controller; use Illuminate\Http\Request; use App\Models\User; class UserController extends Controller { public function index() { $this->authorize('viewAny', auth()->user()); return response("Hello world"); } } 本政策: <?php namespace App\Policies; use Illuminate\Auth\Access\Response; use App\Models\User; class UserPolicy { public function viewAny(User $user): bool { return true; } } 这是我的模型 <?php namespace App\Models; // use Illuminate\Contracts\Auth\MustVerifyEmail; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Foundation\Auth\User as Authenticatable; use Illuminate\Notifications\Notifiable; use Laravel\Sanctum\HasApiTokens; class User extends Authenticatable { use HasApiTokens, HasFactory, Notifiable; /** * The attributes that are mass assignable. * * @var array<int, string> */ protected $fillable = [ 'name', 'email', 'password', ]; /** * The attributes that should be hidden for serialization. * * @var array<int, string> */ protected $hidden = [ 'password', 'remember_token', ]; /** * The attributes that should be cast. * * @var array<string, string> */ protected $casts = [ 'email_verified_at' => 'datetime', 'password' => 'hashed', ]; } 我收到错误 403:此操作未经授权。我希望有人能帮助我解决我的问题。谢谢你 我也尝试过修改AuthServiceProvider文件,但没有任何改变。 必须在 App\Providers\AuthServiceProvider 中添加您的策略吗? protected $policies = [ User::class => UserPolicy::class ]; 您需要指定您正在使用的模型。具体来说,就是User。因此,传递当前登录的用户: $this->authorize('viewAny', auth()->user()); 此外,您正在尝试验证用户是否有权访问该页面。确保尝试访问该页面的人是用户,以便策略可以授权或不授权。 要在没有入门套件的情况下进行测试,请创建一个用户并使用它登录。 <?php namespace App\Http\Controllers; use Illuminate\Support\Facades\Auth; class UserController extends Controller { public function index() { $user = \App\Models\User::factory()->create(); Auth::login($user); $this->authorize('viewAny', auth()->user()); return response("Hello world"); } } 但是,如果您希望授予访客用户访问权限,您可以使用 ? 符号将 User 模型设为可选: public function viewAny(?User $user) { return true; }


MVC ASP.NET Core Identity,创建登录、注册操作。 AuthController

公共类AuthController:控制器 { SignInManager _signInManager { 获取; } UserManager _userManager { 获取; } 角色管理器 public class AuthController : Controller { SignInManager<AppUser> _signInManager { get; } UserManager<AppUser> _userManager { get; } RoleManager<IdentityRole> _roleManager { get; } public AuthController(SignInManager<AppUser> signInManager, UserManager<AppUser> userManager, RoleManager<IdentityRole> roleManager) { _signInManager = signInManager; _userManager = userManager; _roleManager = roleManager; } public IActionResult Login() { return View(); } [HttpPost] public async Task<IActionResult> Login(string? returnUrl,LoginVM vm) { AppUser user; if (!ModelState.IsValid) { return View(vm); } if (vm.UsernameOrEmail.Contains("@")) { user = await _userManager.FindByEmailAsync(vm.UsernameOrEmail); } else { user = await _userManager.FindByNameAsync(vm.UsernameOrEmail); } if (user == null) { ModelState.AddModelError("", "Username or password is wrong"); return View(vm); } var result = await _signInManager.PasswordSignInAsync(user, vm.Password, vm.IsRemember, true); if (!result.Succeeded) { if (result.IsLockedOut) { ModelState.AddModelError("", "Too many attempts wait until " + DateTime.Parse(user.LockoutEnd.ToString()).ToString("HH:mm")); } else { ModelState.AddModelError("", "Username or password is wrong"); } return View(vm); } if (returnUrl != null) { return LocalRedirect(returnUrl); } return RedirectToAction("Index","Home"); } public IActionResult Register() { return View(); } [HttpPost] public async Task<IActionResult> Register(RegisterVM vm) { if (!ModelState.IsValid) { return View(vm); } var user = new AppUser { Fullname = vm.Fullname, Email = vm.Email, UserName = vm.Username }; var result = await _userManager.CreateAsync(user, vm.Password); if (!result.Succeeded) { foreach (var error in result.Errors) { ModelState.AddModelError("", error.Description); } return View(vm); } var roleResult = await _userManager.AddToRoleAsync(user, Roles.Member.ToString()); if (!roleResult.Succeeded) { ModelState.AddModelError("", "Something went wrong. Please contact admin"); return View(vm); } return View(); } public async Task<IActionResult> Logout() { await _signInManager.SignOutAsync(); return RedirectToAction("Index", "Home"); } public async Task<bool> CreateRoles() { foreach (var item in Enum.GetValues(typeof(Roles))) { if (!await _roleManager.RoleExistsAsync(item.ToString())) { var result = await _roleManager.CreateAsync(new IdentityRole { Name = item.ToString() }); if (!result.Succeeded) { return false; } } } return true; } } } 所以,我在代码中搞乱了登录、注册和注销,现在这个 RoleManager 的事情让我摸不着头脑。我只是想为我的管理员用户提供一些额外的权力,但我有点不知道该怎么做。如果您能用简单的语言解释步骤或需要进行哪些更改来帮助我,那就太棒了。 我的目标是让管理员用户在我的系统中体验更好,您对此的建议非常有用。尝试了解 RoleManager 的事情以及如何为我的管理员用户提供更多能力。您直接的帮助可能会对我解决这个问题产生很大的影响! 定义管理员角色 创建管理员用户 更新注册流程: var roleResult =等待_userManager.AddToRoleAsync(用户,vm.IsAdmin? Roles.Admin.ToString() : Roles.Member.ToString()); 使用管理员角色: [授权(角色=“管理员”)] 公共 IActionResult AdminDashboard() { // 特定于管理的逻辑 } 5.提升管理能力: if (User.IsInRole("管理员")) { // 特定于管理的逻辑 } 中间件配置: services.AddIdentity() .AddRoles() .AddEntityFrameworkStores(); 7.创建角色方法: 公共无效配置(IApplicationBuilder 应用程序,IHostingEnvironment env) { // 其他中间件配置 // Create roles during application startup var authController = new AuthController(/* inject your dependencies here */); authController.CreateRoles().GetAwaiter().GetResult(); }


conda错误ssl证书:HTTPSConnectionPool(host=\'repo.anaconda.com\', port=443

无论我做什么,我都会收到此错误 C:\Users\MyPc>conda update --all 解决环境:失败 CondaHTTPError:URL 的 HTTP 000 连接失败 无论我做什么,我都会收到此错误 C:\Users\MyPc>conda update --all Solving environment: failed CondaHTTPError: HTTP 000 CONNECTION FAILED for url <https://repo.anaconda.com/pkgs/free/win-64/repodata.json.bz2> Elapsed: - An HTTP error occurred when trying to retrieve this URL. HTTP errors are often intermittent, and a simple retry will get you on your way. If your current network has https://www.anaconda.com blocked, please file a support request with your network engineering team. SSLError(MaxRetryError('HTTPSConnectionPool(host=\'repo.anaconda.com\', port=443): Max retries exceeded with url: /pkgs/free/win-64/repodata.json.bz2 (Caused by SSLError("Can\'t connect to HTTPS URL because the SSL module is not available."))')) 我已经搜索了所有互联网,重新安装了 anaconda 并做了建议中的任何操作,但这个问题仍然存在。 Windows 10 C:\Users\MyPc>anaconda --version anaconda 命令行客户端(版本 1.7.2) C:\Users\MyPc>conda --version 康达 4.5.12 就我而言,当我尝试运行此命令时,我收到了此类错误消息 conda install tensorflow 这是错误消息 CondaSSLError:OpenSSL 似乎在此计算机上不可用。下载并安装软件包需要 OpenSSL。 异常:HTTPSConnectionPool(主机='repo.anaconda.com',端口=443):超过最大重试次数,网址:/pkgs/main/win-64/current_repodata.json(由SSLError(“无法连接到HTTPS URL”)引起因为 SSL 模块不可用。")) 这就是解决方案 步骤01 进入你的anaconda3的安装路径 步骤02 现在转到此文件路径 anaconda3\Library\bin 步骤03 现在选择这个 DLL 文件并复制它 libcrypto-1_1-x64.dll libssl-1_1-x64.dll 步骤04 之后转到此文件路径并将其粘贴到该文件夹内部 anaconda3\DLLs 这个命令对我有用: conda config --set ssl_verify false 我也遇到了同样的问题,解决这个问题的方法是安装早期的 32 位版本的 Conda。由于某种原因,较新的 64 位版本似乎容易出现此错误。您可以在这里找到 Conda 的早期版本: https://repo.continuum.io/archive/ 您应该搜索仅具有 x86 而不是 x86_64 的 Anaconda3 版本。 我也遇到了同样的问题,简单的解决方案是: 从开始菜单打开anaconda navigator,然后运行CMD.exe提示符,然后从那里安装,就是这样。 在 C:\Users\xyz 目录中创建一个名为 .condarc 的文件,其中包含以下内容 频道: 默认值 ssl_verify:假 然后尝试创建虚拟环境: conda create -n envname python=x.x anaconda 祝你好运!


ASP.NET MVC 项目模板在移动设备上无法调整为 100%

我不明白为什么 Web .Net MVC 项目上的默认模板没有在移动设备中调整为 100% 宽度。 我在视图上使用数据表: @模型IEnumerable 我不明白为什么 Web .Net MVC 项目上的默认模板没有在移动设备中调整为 100% 宽度。 我在视图上使用数据表: @model IEnumerable<iziConference.Models.EventAttendee> <h2>Participantes.</h2> <br /> <button><a style="text-decoration: none" href='@Url.Action("Create", new { eventId = ViewBag.EventId })'>Criar Participante</a></button> <button id="at-btn-refresh"> Actualizar</button> <input id="eventId" type="hidden" value="@ViewBag.EventId"> <table id="at-attendees-list" cellpadding="10" border="1" class="row-border stripe"> <thead> <tr> <th>ID</th> <th>Tipo</th> <th>Nome</th> <th>Email</th> <th>Estado </th> </tr> </thead> <tbody> @foreach (var item in Model) { <tr id="[email protected]_Id"> <td style="padding: 5px"> @Html.DisplayFor(modelItem => item.Attendee.Id) </td> <td> @Html.DisplayFor(modelItem => item.AttendeeType) </td> <td> @Html.DisplayFor(modelItem => item.Attendee.Name) </td> <td> @Html.DisplayFor(modelItem => item.Attendee.Email) </td> <td> @if (item.IsActive) { <button id="[email protected]_Id" class="at-btn-active-state active" data-attendee-id="@item.Attendee_Id" data-attendee-name="@item.Attendee.Name" data-active-new-state="false" data-show-confirmation-alert="true">Desactivar</button> } else { <button id="[email protected]_Id" class="at-btn-active-state inactive" data-attendee-id="@item.Attendee_Id" data-attendee-name="@item.Attendee.Name" data-active-new-state="true" data-show-confirmation-alert="true">Activar</button> } </td> </tr> } </tbody> </table> 由脚本加载: var _atteendeesList = "at-attendees-list"; $("#" + _atteendeesList).DataTable({ "paging": false, "info": false, "language": { "search": "Pesquisar:", "info": "Participantes inscritos: _PAGES_" } }); 使用默认的_Layout.cshtml: <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title>izigo Conference - Gestor de Conteúdos</title> <link href="~/favicon.ico" rel="shortcut icon" type="image/x-icon" /> <meta name="viewport" content="width=device-width" /> @Styles.Render("~/Content/css") @Scripts.Render("~/bundles/modernizr") </head> <body> <header> <div class="content-wrapper"> <section id="login"> @Html.Partial(MVC.Account.Views._LoginPartial) </section> <div style="padding: 10px;"> @if (Request.IsAuthenticated) { <nav> <ul id="menu"> <li>@Html.ActionLink("Home", MVC.Home.Index())</li> <li>@Html.ActionLink("Participantes", MVC.Attendee.Index())</li> <li>@Html.ActionLink("Check-in", MVC.Checkin.Index())</li> </ul> </nav> } </div> </div> </header> <div id="body"> @RenderSection("featured", required: false) <section class="content-wrapper main-content clear-fix"> @RenderBody() </section> </div> <footer style="padding-left: 25px;"> <div class="content-wrapper"> <div class="float-left"> <p>&copy; @DateTime.Now.Year - <a href="https://www.izigo.pt/conference" target="_blank">izigo Conference</a> - <i>Powered by</i><a href="https://www.izigo.pt" target="_blank">izigo.pt</a></p> </div> </div> </footer> @Scripts.Render("~/bundles/jquery", "~/bundles/iziconference") @RenderSection("scripts", required: false) </body> </html> 研究了 dataTables 库的选项后,我找到了一个创建响应式解决方案的选项: 我已经包含了响应表结构和columnDefs的选项,以选择哪些选项在移动设备中保持可见: $("#" + _atteendeesList).DataTable({ "responsive": true, "columnDefs": [ { responsivePriority: 1, targets: 0 }, { responsivePriority: 2, targets: -1 } ], "paging": false, "info": false, "language": { "search": "Pesquisar:", "info": "Participantes inscritos: _PAGES_" } }); 我还必须在捆绑包中包含数据表扩展的 js 和 css 响应式库(可在此处下载:https://datatables.net/download/): bundles.Add(new ScriptBundle("~/bundles/iziconference").Include( "~/Content/Scripts/datatables.min.js", "~/Content/Scripts/dataTables.responsive.min.js")); // add-on bundles.Add(new StyleBundle("~/Content/css").Include( "~/Content/Styles/datatables.min.css", "~/Content/Styles/responsive.dataTables.min.css"));


表单响应:“无法处理请求 HTTP ERROR 500”。我做错了什么?

我尝试在网站上编写 php 表单,但收到错误 500。我无法弄清楚我做错了什么。你能看一下代码看看我做错了什么吗? PHP: 我尝试在网站上编写 php 表单,但收到错误 500。我无法弄清楚我做错了什么。你能看一下代码看看我做错了什么吗? PHP: <?php // define variables and set to empty values $name = $email = $phone = $enquiry = ""; if ( $_SERVER[ "REQUEST_METHOD" ] == "POST" ) { if ( empty( $_POST[ "name" ] ) ) { $nameErr = "Name is required"; } else { $name = test_input( $_POST[ "name" ] ); // check if name only contains letters and whitespace if ( !preg_match( "/^[a-zA-Z-' ]*$/", $name ) ) { $nameErr = "Only letters and white space allowed"; } } if ( empty( $_POST[ "email" ] ) ) { $emailErr = "Email is required"; } else { $email = test_input( $_POST[ "email" ] ); // check if e-mail address is well-formed if ( !filter_var( $email, FILTER_VALIDATE_EMAIL ) ) { $emailErr = "Invalid email format"; } } if ( empty( $_POST[ "phone" ] ) ) { $comment = ""; } else { $comment = test_input( $_POST[ "phone" ] ); } if ( empty( $_POST[ "enquiry" ] ) ) { $comment = ""; } else { $comment = test_input( $_POST[ "enquiry" ] ); } } // Create the email and send the message $destination = "[email protected]"; $subject = "Website Contact Form Enquiry: $name"; $body = "You have received a new message from your website contact form.\\n\\n"."Here are the details:\\n\\nName: $name\\n\\nEmail: $email\\n\\nPhone: $phone\\n\\nEnquiry:\\n$enquiry"; $header = "From: [email protected]\\n"; $headers = array(); $headers[] = "MIME-Version: 1.0"; $headers[] = "Content-type: text/plain; charset=iso-8859-1"; $headers[] = "From: " . $fromAddress; $headers[] = "Subject: " . $subject; $headers[] = "X-Mailer: PHP/".phpversion(); mail($destination, $subject, $message, implode("\r\n", $headers)); // mail($to,$subject,$msg,$headers); echo "Email successfully sent."; ?> HTML 格式: <form id="contact-form" method="post" action="/contact.php" role="form"> <div class="messages"></div> <div class="controls"> <div class="row"> <div class="col-md-10"> <div class="form-group"> <input id="form_name" type="text" name="name" class="form-control" placeholder="Name*" required="required" data-error="Your name is required." > <div class="help-block with-errors"></div> </div> </div> <div class="col-md-10"> <div class="form-group"> <input id="form_email" type="email" name="email" class="form-control" placeholder="Email*" required="required" data-error="Valid email is required." > <div class="help-block with-errors"></div> </div> </div> <div class="col-md-10"> <div class="form-group"> <input id="form_phone" type="text" name="phone" class="form-control" placeholder="Phone" > <div class="help-block with-errors"></div> </div> </div> </div> <div class="row"> <div class="col-md-10"> <div class="form-group"> <textarea id="form_enquiry" name="enquiry" class="form-control" placeholder="Enquiry*" rows="6" required="required" data-error="Please, leave us a message."></textarea> <div class="help-block with-errors"></div> </div> </div> <div class="col-md-12"> <input class="btn btn-large btn-primary centre mt-10" type="submit" value="Submit" > </div> </div> </div> </form> 我已按照其他人的指示使表单正常工作,但所做的更改仍然会出现错误。 这是一个简单的形式,但我似乎对我做错了什么缺乏了解。 请帮助我。 如果您查看发送邮件的行,这是一个硬行结尾,将 $headers 推到新行上吗?这将调用 500 错误。 查看 /var/log/apache2/error.log(如果您使用的是 Debian)或 /var/log/httpd/error.log(如果使用的是 RHEL 或类似系统)。 您的代码存在许多问题,但首先关注快乐的道路,然后让事情正常运行。


MatToolbar:尝试组合不同的工具栏模式

出现以下错误: MatToolbar:尝试组合不同的工具栏模式。显式指定多个 元素或仅将内容放置在 中 出现以下错误: MatToolbar:尝试组合不同的工具栏模式。要么显式指定多个 <mat-toolbar-row> 元素,要么仅将内容放置在单行的 <mat-toolbar> 中。 我的代码已经在 mat-toolbar 中应用了 mat-toolbar-row。然而,该错误仍然存在。 html文件的代码片段如下: <div class="wallpaper"> <mat-toolbar color="primary"> <mat-toolbar-row> <span>Welcome, User</span> <span class="example-fill-remaining-space"></span> <span class="align-center"></span> <span class="example-spacer"></span> <button mat-button>Create Incident </button> <a [routerLink]="['/closed']"><button mat-button style="color: white">Closed Incident</button></a> <span class="example-spacer"></span> <a [routerLink]="['/login']"><button mat-button>Logout</button></a> <img src="../../assets/hsbc_logo3.png" class="logo-hsbc"/> </mat-toolbar-row> <h1>INCIDENT MANAGEMENT SYSTEM</h1> </mat-toolbar> <h1>Welcome to Incident Management System</h1> <mat-card style="background: transparent"> <!-- Title of an Card --> <mat-card-title>Incident Details</mat-card-title> <mat-card-content> <form> <table > <tr> <td> <mat-form-field class="demo-full-width"> <mat-label >Description</mat-label> <textarea [(ngModel)]="incident.description" name="description" cdkTextareaAutosize cdkAutosizeMinRows="1" cdkAutosizeMaxRows="5" matInput></textarea> </mat-form-field> </td> <td> <h4>{{message}}</h4> </td> </tr> <tr> <td> <mat-form-field class="demo-full-width"> <input matInput [matDatepicker]="picker" placeholder="Incident Date" [(ngModel)]="incident.date" name="date" > <mat-datepicker-toggle matSuffix [for]="picker"></mat-datepicker-toggle> <mat-datepicker touchUi="true" #picker></mat-datepicker> </mat-form-field> </td> </tr> <tr> <td colspan="2"> <mat-form-field class="demo-full-width"> <input matInput placeholder="Incident Category" [(ngModel)]="incident.category" name="category"> </mat-form-field> </td> </tr> <tr> <td > <mat-form-field class="demo-full-width"> <mat-select placeholder="Application Owner" [(ngModel)]="incident.owner" name="owner"> <mat-option style="background-color:grey">-- Select--</mat-option> <mat-option style="background-color:cornsilk" value="1">BRV</mat-option> <mat-option style="background-color:cornsilk" value="2">FRTB</mat-option> <mat-option style="background-color:cornsilk" value="3">FSA</mat-option> </mat-select> </mat-form-field> </td> <td> <mat-form-field> <mat-select placeholder="Symphony Group" [(ngModel)]="incident.symphony_group" name="symphony_group"> <mat-option style="background-color:grey">-- Select --</mat-option> <mat-option style="background-color:cornsilk" value="1">MMO SheHacks</mat-option> <mat-option style="background-color: cornsilk" value="2">MMO IT INDIA</mat-option> </mat-select> </mat-form-field> </td> </tr> <tr> <td> <mat-form-field> <mat-select placeholder="Application" [(ngModel)]="incident.application" name="application"> <mat-option style="background-color:grey">-- Select--</mat-option> <mat-option style="background-color:cornsilk" value="1">BRV</mat-option> <mat-option style="background-color:cornsilk" value="2">FRTB</mat-option> <mat-option style="background-color:cornsilk" value="3">FSA</mat-option> </mat-select> </mat-form-field> </td> <td> <mat-form-field> <mat-select placeholder="Status" [(value)]="status" [(ngModel)]="incident.status" name="status"> <mat-option style="background-color:grey">-- Select --</mat-option> <mat-option style="background-color: green" value="1">Available</mat-option> <mat-option style="background-color: orange" value="2">Reduced</mat-option> <mat-option style="background-color: red" value="3">Unavailable</mat-option> </mat-select> </mat-form-field> </td> </tr> <tr> <td colspan="2"> </td> </tr> <tr> <td colspan="2" class="content-center"> <button style="margin:5px" mat-raised-button color="accent" (click)="submit()">Submit Incident</button> <button style="margin:5px" mat-raised-button color="accent" (click)="reset()">Clear</button> <button style="margin:5px" mat-raised-button color="accent">Raise BGCR</button> <button style="margin:5px" mat-raised-button color="accent">Raise Jira</button> </td> </tr> </table> </form> </mat-card-content> </mat-card> </div> 您需要移除 <h1>INCIDENT MANAGEMENT SYSTEM</h1> 或将其放入 <mat-toolbar-row> 内。 我无法在垫子工具栏中填充图像 有什么帮助吗?


© www.soinside.com 2019 - 2024. All rights reserved.