hamiltonian-path 相关问题


使用powershell如何添加带有一个标题栏的内容

代码: $path = 'C:\Users\Desktop\Test.csv' 如果(测试路径 $path) { 删除项目 $path -verbose } else { Write-Host "$path 未找到" } [System.Reflection.Assembly]::LoadWithPartialName(&...


如何停止渲染 app.js 中的组件

}> } /> <SideBar /> <Routes> <Route path='/' element={<Body />}> <Route path='/' element={<Home />} /> <Route path='setting' element={<Setting />} /> </Route> <Route path='/service' element={<ServiceLayout />}> <Route path='/service' element={<Service />} /> </Route> </Routes> <Article /> </div> 我不想在服务组件中渲染文章组件。我怎么做?请帮助我。 Article组件无条件在路由内容下渲染。 <div className='App'> <SideBar /> <Routes> <Route element={<Body />}> <Route path='/' element={<Home />} /> <Route path='setting' element={<Setting />} /> </Route> <Route path='/service' element={<ServiceLayout />}> <Route index element={<Service />} /> </Route> </Routes> <Article /> // <-- always rendered! </div> 简单的解决方案就是从 JSX 中删除 Article: <div className='App'> <SideBar /> <Routes> <Route element={<Body />}> <Route path='/' element={<Home />} /> <Route path='setting' element={<Setting />} /> </Route> <Route path='/service' element={<ServiceLayout />}> <Route index element={<Service />} /> </Route> </Routes> {/* <Article /> removed */} </div> 但这可能不是您真正想要的。另一种选择是有条件地在路线上渲染它。 示例: <div className='App'> <SideBar /> <Routes> <Route element={<Body />}> <Route path='/' element={<Home />} /> <Route path='setting' element={<Setting />} /> </Route> <Route path='service' element={<ServiceLayout />}> <Route index element={<Service />} /> </Route> </Routes> <Route path='article' element={<Article /> } /> // <-- only on "/article" path </div>


React中react-router-dom最新版本如何实现延迟加载

我想使用Typescript在React中实现延迟加载。我收到打字稿错误。 常量应用程序 = () => { 返回 ( 我想使用 Typescript 在 React 中实现延迟加载。我收到打字稿错误。 const App = () => { return ( <RouterProvider router={createBrowserRouter( createRoutesFromElements( <Route> <Route path="/" element={<Outlet/>}> <Route index element={<Home />} /> <Route path="contact" element={<Contact />} /> <Route path="about" element={<About />} /> <Route path="*" element={<Navigate to="/" replace />} /> </Route> </Route> ) )} /> ) }; export default App; 下面的代码不起作用 <Route> <Route path="/" element={<Outlet/>}> <Route index lazy={() => import("./Home")} /> <Route path="contact" lazy={() => import("./Contact")} /> <Route path="about" lazy={() => import("./About")} /> <Route path="*" element={<Navigate to="/" replace />} /> </Route> </Route> const Home= lazy(() => import("./screens/home")); const About= lazy(() => import("./screens/about")); <Route> <Route path="/" element={<Outlet/>}> <Route index element={<Suspense fallback={<div>Loading...</div>}> <Home/> </Suspense> /> } /> <Route path="about" element={<Suspense fallback={<div>Loading...</div>}> <About/> </Suspense> /> } /> <Route path="*" element={<Navigate to="/" replace />} /> </Route> </Route>


filesystem::copy 返回无效参数,但参数是现有的 fs::path 变量

我正在使用 std::filesystem (fs) 库处理项目中的文件。我存储为 fs::path 变量的所有路径。我的代码是: int main(){ std::filesystem::path root_dir = "/home/xyz/study/


“Google play 应用程序 - 签名问题”NoSuchAlgorithmException 异常

运行以下命令时出现以下错误 java -jar pepk.jar --keystore=foo.keystore --alias=foo --output=encrypted_private_key_path --rsa-aes-encryption --encryption-key-path=/path/to/


是否可以将 Path 参数传递到 FastAPI 依赖函数中?

是否有 FastAPI“依赖项”来解释 Path 参数? 我有很多形式的函数: @app.post("/item/{item_id}/process", response_class=ProcessRespon...


以 REST 下载方式流式传输资源

因此,我有一个 REST 端点,用于从前端后端 (BFF) 下载文件: @Path("/附件") 公共接口 AttachmentApi { @得到 @Path("/{id}") @Pro...


通过 github 操作创建 EC2 AMI 时出现错误:exec: "session-manager-plugin": $PATH 中找不到可执行文件

==> learn-packer.amazon-ebs.ubuntu:exec:“session-manager-plugin”:在 $PATH 中找不到可执行文件 learn-packer.amazon-ebs.ubuntu:启动 portForwarding 会话“Amy-


exec:“com.docker.cli”:在$PATH中找不到可执行文件

仅在其中一个容器上进行 docker-compose up 时,我收到此错误。 exec: "com.docker.cli": 在 $PATH 中找不到可执行文件 终端进程“/bin/zsh '-c', 'docker ...


OS X - 确定给定 PID 的环境?

对于给定的进程ID,确定环境变量(例如PATH)的最佳/最直接方法是什么?必须能够查询任何任意环境变量。 PATH 只是第一个 e...


launchctl 配置用户路径有什么作用?

我在 MacOS 中的 PATH 环境变量遇到了一个奇怪的问题,我花了几个小时来调试: 前段时间,当我试图解决 IntelliJ 终端 PATH 变量不存在的问题时...


如何从同一 YAML 文件中的其他位置引用 YAML“设置”?

我有以下 YAML 内容: 路径: 路径:/path/to/root/a 路径b:/路径/到/root/b 路径c:/路径/到/root/c 我如何通过从三个中删除 /path/to/root/ 来“规范化”这一点......


shell脚本字符转义失败

我的JVM参数配置如下: 设置“JSSE_OPTS=-Djdk.tls.ephemeralDHKeySize=2048” 设置“JAVA_OPTS =%JAVA_OPTS%%JSSE_OPTS%” 设置“PATH_OPTS=-Drelaxed-path-chars=^...


React Router v6 使用参数导航

目前,我在实现React Router v6(使用6.3.0)时遇到问题 假设我有如下所示的路由 const ParticipantRoutes = () => ( 目前,我在实现React Router v6(使用6.3.0)时遇到问题 假设我有如下所示的路由 const ParticipantRoutes = () => ( <ErrorBoundaryRoutes> <Route index element={<Participant />} /> <Route path="new" element={<ParticipantUpdate />} /> <Route path=":id"> <Route index element={<ParticipantDetail />} /> <Route path=":id"> <Route path="edit-invoice" element={<InvoiceUpdate />}/> </Route> <Route path="invoice" element={<ParticipantInvoiceUpdate />} /> <Route path="edit" element={<ParticipantUpdate />} /> <Route path="delete" element={<ParticipantDeleteDialog />} /> </Route> </ErrorBoundaryRoutes> ); 还有另一条路线,比如 const InvoiceRoutes = () => ( <ErrorBoundaryRoutes> <Route index element={<Invoice />} /> <Route path=":id"> <Route index element={<InvoiceDetail />} /> <Route path="delete" element={<InvoiceDeleteDialog />} /> <Route path="payment" element={<InvoicePaidDialog />} /> </Route> </ErrorBoundaryRoutes> ); 当我访问 URL 上定义的 ParticipantInvoiceUpdate 时,问题就出现了,比如 .../participant/*some-guid-participant*/*some-guid-participant-invoice*/edit-invoice 此页面具有向某些服务提交一些数据的行为,当接受服务器的响应时,我使用导航功能导航回 ParticipantDetail 元素。 navigate('/participant/${*some-guid-participant*}'); 但它不起作用,我尝试了一些东西,但似乎它只能导航到没有给出任何参数的元素。类似的东西 navigate('/participant'); 或 navigate('/invoice); 我也尝试过使用 generatePath 功能并将其与导航结合起来,但仍然没有成功 navigate(generatePath('/participant/:id',{id: participantId}), {replace:true}); 请帮助了解我是否遗漏了什么或误解了这个概念。 根据您的代码,路线:.../participant/*some-guid-participant*/*some-guid-participant-invoice*/edit-invoice 指组件 InvoiceUpdate 而不是 ParticipantInvoiceUpdate 此外,使用字符串格式时不要忘记将 ' 更改为 ` : navigate(`/participant/${some-guid-participant}`);


CMD 可以识别 PATH 变量,但 VS Code 不能识别

我遇到了一个问题,在 CMD 中可以识别 PATH 变量,但一旦我尝试在 VS Code 终端中使用它们,它们似乎就会崩溃。显然,我已经尝试重新启动计算机和 VS Code,但我...


laravel 中的具体迁移回滚

我正在尝试回滚一项特定迁移。 我正在使用 php artisan migrate:rollback --path=database/migrations/2023_09_04_051650_create_tickets_table.php 在本地主机上,它回滚该迁移...


ASP.NET Core razor 页面 - 使用 asp-route-

我已经为我的 asp.net core 项目 (.NET 8) 实现了基于路由的本地化。基本上满足这些要求: 当请求根(path = '/')时,CultureInfo.CurrentCulture 是...


如何在Windows上安装Python wand?

我使用 pip install wand 安装了 wand,并且 ImageMagick DLL(来自 ImageMagick-7.1.0-46-Q16-HDRI-x64-dll 包)位于 PATH 中。 这样做: 导入魔杖图像 与 wand.image.Image(文件...


clangd 修改系统包含路径

运行 clangd --check=my_file.cu 我得到了以下内容(简化): I[13:05:09.356] 测试源文件 /path/to/my_file.cu 我[13:05:09.362]正在加载编译数据库... 我[13:05:...


为什么 futures::executor::block_on 挂在诗歌处理程序中

使用 tokio::runtime::Handle; // 1.0.2 使用诗::{ 获取、处理程序、侦听器::TcpListener、中间件::跟踪、web::Path、EndpointExt、路由、服务器、 }; fn inside_example(handle: Handle) -> 字符串...


删除早于排除目录的文件 (Linux)

我正在尝试从当前位置删除早于 14 天的所有文件和子目录,排除文件夹“Folder”。我尝试的是 寻找 。 -mtime +14 -not -path "./Folder/*&


我无法从 Huggingface 下载数据集

从数据集导入load_dataset 数据集 = load_dataset(path='seamew/THUCNewsTitle', split='train') 我的网络没问题,但控制台总是显示: 回溯(最近一次调用最后一次): 文件“/


Nuxt 3 项目无法找到 PWA 图标

开发工具错误 我目前正在尝试在我的 nuxt 3 项目中实现 PWA 功能,但我不断遇到这个问题:[Vue Router warn]: No match found for location with path "/icon_512x512...


如何使用 ag 又名 the_silver_search 仅搜索目录?

我喜欢只搜索目录,选项 ag --list-file-types 对此没有帮助。坚持使用 ag 的原因是可以选择带有 --path-to-ignore 的文件,其中包含 pat...


无法通过PAT令牌调用Azure DevOps Rest Api

我正在尝试使用 Azure DevOps Rest api 将保存在本地目录(桌面)中的 json 文件导入到 Azure DevOps 库变量组。 这是剧本。 $jsonbody = Get-Content -Path "C: ar...


Azure Devops Powershell 脚本

我是 Azure DevOps 的新手。我们有一个管道,管道中的任务之一是将一些配置文件复制到另一台服务器,它看起来像 复制项目 -path D:\Config\*.* -Destination '\server\


导出ssh密钥对的位置

在我的 bash 配置文件中包含 $KEY="path/to/sshkey" 是否安全? 它有效,我只是想确保它不是一个漏洞。 一切都符合我的工作流程,只是想让...


Micronaut Key Store Path中可以设置S3路径吗?

我有一个使用 Micronaut 3.9.x(从 Micronaut 1 迁移)的 lambda 应用程序,它使用 HttpClient 并具有指向我的资源文件夹内的证书的 SSL 配置。我有


如何修复 Namecheap 的 npm WARN 生命周期错误?

这是我在 Namecheap Cpanel 中运行 NPM install 时遇到的错误: 使用“--scripts-prepend-node-path”选项包含执行 npm 的节点二进制文件的路径。 我尝试添加一个


在 Windows 上的命令行中使用gunzip

我需要在Windows终端中使用gunzip(gzip的解压工具) 我从这里下载了gzip(第一个下载链接) 我安装了它并将其 /bin 文件夹添加到我的 PATH va...


如何让 React-Dates DayPicker 单个 DateController 与自定义输入一起使用

如何使用自定义输入的爱彼迎日期选择器来打开和关闭日历? 这是自定义日期输入 https://airbnb.io/react-dates/?path=/story/daypickersingledatecontroller--with-cu...


将命令行参数传递给 Bokeh 服务器应用程序

我有一个 Bokeh 服务器应用程序。我想在命令行上传递自定义选项: 散景服务 /path/to/script.py --my-option foo 这可能吗? Bokeh 会通过这些选项吗...


NestJs 中请求 url 中不存在 Path Param 时如何手动处理?

我是 Nest 的新手,正在边学习边做一个项目。但今天我被困在做以下事情: @Delete('删除/:id') 删除合作伙伴(@Param()参数:ParamDto){ 返回 this.service.delete...


如何在 C for Windows 中正确链接到库

我目前正在尝试 Windows 的 C 编程。我有 Windows 11,我在 VS Code 上编码,并且我已经安装了 MinGW 并将其正确添加到 PATH 中。问题是我无法链接我的 p...


Python 的语音转文本 API v2 问题(权限被拒绝)

只能在 Google Shell 中使用路径设置命令“exports...”。不要在代码中和我的主平台上使用“PATH”的 shell 工作 Python Local 我面临着一个令人困惑的交通问题...


REGEX_extract 需要占用路径的一部分

我有一个名为“path”的列,我想创建一个包含项目名称的新列: 文件夹/1//文件/2//项目/AAA//数据集/BBBB 文件夹/1//文件/2//项目/ZZZ//数据集/XX55 文件夹/1//文件/3//


在生产中,django {% static 'file/path' %} 命令在 Herokuapp 上查找文件路径,而它应该通过 Cloudinary 查找

静态文件在生产中不起作用。 问题领域总结 经过严格审查和同行比较后,Cloudinary 和 Django settings.py 和模板设置正确。 检查


使用 libcurl 时出现“SSL CA 证书问题”错误

我使用--openssldir=< path to ssl >/ssl(链接到/etc/ssl)构建了openssl 1.1.1,并使用--with-ssl=< path to openssl >构建了curl 7.76.1。 编译了以下代码: #包括 我使用--openssldir=< path to ssl >/ssl(链接到/etc/ssl)构建了openssl 1.1.1,并使用--with-ssl=< path to openssl >构建了curl 7.76.1。 编译了以下代码: #include <iostream> #include <curl/curl.h> int main() { CURL *curl = curl_easy_init(); if (curl) { struct curl_slist *headers = NULL; headers = curl_slist_append(headers, "Accept: */*"); headers = curl_slist_append(headers, "Content-Type: application/json"); curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers); curl_easy_setopt(curl, CURLOPT_URL, "https://<address>"); curl_easy_setopt(curl, CURLOPT_POST, 1); curl_easy_setopt(curl, CURLOPT_POSTFIELDS, "<some data>"); curl_easy_perform(curl); curl_slist_free_all(headers) } curl_easy_cleanup(curl); } 当我运行此代码时,出现错误: curl_easy_operation() failed : Problem with the SSL CA cert (path? access rights?) 我在 strace 中看到,它正在尝试打开“/etc/pki/tls/certs/ca-bundle.crt” 但在我的机器(Ubuntu 12 和 Ubuntu 14)中没有文件夹“/etc/pki”。 为什么curl使用“/etc/pki”而不是“/etc/ssl”?我怎样才能强制它使用“/etc/ssl”? 我尝试使用 --without-nss 构建curl,但没有成功。 编辑: 我的解决方案是添加以下代码: ifstream caBundleFile("/etc/pki/tls/certs/ca-bundle.crt"); if (caBundleFile.good()) { curl_easy_setopt(curl, CURLOPT_CAINFO, "/etc/pki/tls/certs/ca-bundle.crt"); caBundleFile.close(); } else { curl_easy_setopt(curl, CURLOPT_CAPATH, "/etc/ssl/certs"); } 有两种流行的存储根证书的格式。第一个适用于 RHEL/Centos 等,第二个适用于 Ubuntu 等发行版。 对于未来的读者,答案是设置curl CA路径 #include <iostream> #include <curl/curl.h> const std::string curlCertPath = "./keys/curl-ca-bundle.crt"; int main() { CURL *curl; CURLcode res; curl_global_init(CURL_GLOBAL_ALL); curl = curl_easy_init(); if (curl) { curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/"); curl_easy_setopt(curl, CURLOPT_CAINFO, curlCertPath.c_str()); res = curl_easy_perform(curl); if (res == CURLE_OK) { std::cout << "Curl worked" << std::endl; } else { std::cout << "Error: curl failed: " << curl_easy_strerror(res) << std::endl; } curl_easy_cleanup(curl); } curl_global_cleanup(); return 0; }


如何将React项目用于html网站的整个子路由

我有一个现有的 HTML 页面和一个 React 项目。如何连接它们? 首页.html 进入React页面 应用程序.js 我有一个现有的 HTML 页面和一个 React 项目。如何连接它们? home.html <button>go to React page</button> 应用程序.js <BrowserRouter> <Routes> <Route path="/mypage" element={<Mypage />}> </Routes> </BrowserRouter> 我想点击“转到React页面”按钮,我可以导航到"/mypage"? 该按钮应实现对 "/mypage" URL 的导航操作,该 URL 最好为您的 React 应用程序提供服务。 home.html 更新按钮以包含重定向到子路线的点击处理程序 <button onclick="navigateToReactApp()">go to React page</button> const navigateToReactApp = () => { window.location.href = "/mypage"; // check the path correctness }; 或者使用锚标记,这在语义上可能更正确。 <a href="/mypage">go to React page</a> App.js 通过设置 "/mypage" 属性,更新路由器以使所有路由/链接/等从托管/服务应用程序的 basename relative 工作。 <BrowserRouter basename="/mypage"> <Routes> <Route path="/" element={<Mypage />}> </Routes> </BrowserRouter>


按照路径流对 svg 填充进行动画处理

我有以下SVG;它类似于字母“P”。我想用黑色填充整个“P”,但要逐渐地遵循绘图的流程,就像正在绘制一样。 我有以下SVG;它类似于字母“P”。我想用黑色填充整个“P”,但要逐渐地遵循绘图的流程,就像正在绘制一样。 <svg width="40" height="40" viewBox="0 0 40 40" fill="none" xmlns="http://www.w3.org/2000/svg"> <g stroke="#000" stroke-width="1" fill="none"> <path d="M31.5294 14.2118C31.5294 18.8819 28.7623 22.9082 24.7793 24.7351C26.4612 23.3496 27.5322 21.248 27.5322 18.896C27.5322 14.7642 24.2259 11.4042 20.112 11.3205C20.0574 11.3167 20.0075 11.3167 19.9529 11.3167C19.8983 11.3167 19.8485 11.3167 19.7939 11.3205C18.2673 11.4033 17.0588 12.6663 17.0588 14.2108V28.6814C17.0588 33.4748 13.1699 37.3638 8.37646 37.3638V14.2118C8.37646 7.81928 13.5605 2.63528 19.9529 2.63528C26.3454 2.63528 31.5294 7.81928 31.5294 14.2118Z"/> </g> </svg> 如果我只是从下到上或从左到右填充,其他类似问题的解决方案,它不会遵循绘制时的“P”形状。请注意:我对 SVG 没有太多专业知识。 我举了一个例子来说明如何做到这一点。我知道这可能不完全是您想要的,但这说明了一条可以遵循的道路。 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> <link rel="stylesheet" href="style.css"> </head> <body> <svg width="40" height="40" viewBox="0 0 40 40" fill="none" xmlns="http://www.w3.org/2000/svg"> <style> @keyframes fade-in-right { from { clip-path: circle(0px); } to { clip-path: circle(40px); } } #path2 { animation: fade-in-right ease 4s infinite; } </style> <g stroke="#000000" stroke-width="1" fill="none" id="g1"> <path d="m 31.5294,14.2118 c 0,4.6701 -2.7671,8.6964 -6.7501,10.5233 1.6819,-1.3855 2.7529,-3.4871 2.7529,-5.8391 0,-4.1318 -3.3063,-7.4918 -7.4202,-7.5755 -0.0546,-0.0038 -0.1045,-0.0038 -0.1591,-0.0038 -0.0546,0 -0.1044,0 -0.159,0.0038 -1.5266,0.0828 -2.7351,1.3458 -2.7351,2.8903 v 14.4706 c 0,4.7934 -3.8889,8.6824 -8.68234,8.6824 v -23.152 c 0,-6.39252 5.18404,-11.57652 11.57644,-11.57652 6.3925,0 11.5765,5.184 11.5765,11.57652 z" id="path1" /> </g> <g stroke="#000000" stroke-width="1" fill="none" id="g2"> <path d="m 31.5294,14.2118 c 0,4.6701 -2.7671,8.6964 -6.7501,10.5233 1.6819,-1.3855 2.7529,-3.4871 2.7529,-5.8391 0,-4.1318 -3.3063,-7.4918 -7.4202,-7.5755 -0.0546,-0.0038 -0.1045,-0.0038 -0.1591,-0.0038 -0.0546,0 -0.1044,0 -0.159,0.0038 -1.5266,0.0828 -2.7351,1.3458 -2.7351,2.8903 v 14.4706 c 0,4.7934 -3.8889,8.6824 -8.68234,8.6824 v -23.152 c 0,-6.39252 5.18404,-11.57652 11.57644,-11.57652 6.3925,0 11.5765,5.184 11.5765,11.57652 z" id="path2" style="fill:#000000;fill-opacity:1;stroke:none" /> </g> </svg> </body> </html>


通过更少的 Java API 调用来映射 Google 云端硬盘内容的有效方法

大家好,我有一个代码,用于列出共享驱动器中存在的文件(以便稍后下载并创建相同的文件夹路径) 目前我做这样的事情: 哈希映射 大家好,我有一个代码,用于列出共享驱动器中存在的文件(以便稍后下载并创建相同的文件夹路径) 目前我正在做这样的事情: HashMap<String, Strin> foldersPathToID = new HashMap<>(); //searching all folders first saving their IDs searchAllFoldersRecursive(folderName.trim(), driveId, foldersPathToID); //then listing files in all folders HashMap<String, List<File>> pathFile = new HashMap<>(); for (Entry<String, String> pathFolder : foldersPathToID.entrySet()) { List<File> result = search(Type.FILE, pathFolder.getValue()); if (result.size() > 0) { String targetPathFolder = pathFolder.getKey().trim(); pathFile.putIfAbsent(targetPathFolder, new ArrayList<>()); for (File file : result) { pathFile.get(targetPathFolder).add(file); } } } 递归方法在哪里: private static void searchAllFoldersRecursive(String nameFold, String id, HashMap<String, String> map) throws IOException, RefreshTokenException { map.putIfAbsent(nameFold, id); List<File> result; result = search(Type.FOLDER, id); // dig deeper if (result.size() > 0) { for (File folder : result) { searchAllFoldersRecursive(nameFold + java.io.File.separator + normalizeName(folder.getName()), folder.getId(), map); } } } 搜索功能是: private static List<com.google.api.services.drive.model.File> search(Type type, String folderId) throws IOException, RefreshTokenException { String nextPageToken = "go"; List<File> driveFolders = new ArrayList<>(); com.google.api.services.drive.Drive.Files.List request = service.files() .list() .setQ("'" + folderId + "' in parents and mimeType" + (type == Type.FOLDER ? "=" : "!=") + "'application/vnd.google-apps.folder' and trashed = false") .setPageSize(100).setFields("nextPageToken, files(id, name)"); while (nextPageToken != null && nextPageToken.length() > 0) { try { FileList result = request.execute(); driveFolders.addAll(result.getFiles()); nextPageToken = result.getNextPageToken(); request.setPageToken(nextPageToken); return driveFolders; } catch (TokenResponseException tokenError) { if (tokenError.getDetails().getError().equalsIgnoreCase("invalid_grant")) { log.err("Token no more valid removing it Please retry"); java.io.File cred = new java.io.File("./tokens/StoredCredential"); if (cred.exists()) { cred.delete(); } throw new RefreshTokenException("Creds invalid will retry re allow for the token"); } log.err("Error while geting response with token for folder id : " + folderId, tokenError); nextPageToken = null; } catch (Exception e) { log.err("Error while reading folder id : " + folderId, e); nextPageToken = null; } } return new ArrayList<>(); } 我确信有一种方法可以通过很少的 api 调用(甚至可能是一个调用?)对每个文件(使用文件夹树路径)进行正确的映射,因为在我的版本中,我花了很多时间进行调用 service.files().list().setQ("'" + folderId+ "' in parents and mimeType" + (type == Type.FOLDER ? "=" : "!=") + "'application/vnd.google-apps.folder' and trashed = false").setPageSize(100).setFields("nextPageToken, files(id, name)"); 每个子文件夹至少一次......并且递归搜索所有内容需要很长时间。最后,映射比下载本身花费的时间更多...... 我搜索了文档,也在此处搜索,但没有找到任何内容来列出具有一个库的所有驱动器调用任何想法? 我想使用专用的 java API 来获取共享 GoogleDrive 中的所有文件及其相对路径,但调用次数尽可能少。 提前感谢您的时间和答复 我建议您使用高效的数据结构和逻辑来构建文件夹树并将文件映射到其路径,如下所示 private static void mapDriveContent(String driveId) throws IOException { // HashMap to store folder ID to path mapping HashMap<String, String> idToPath = new HashMap<>(); // HashMap to store files based on their paths HashMap<String, List<File>> pathToFile = new HashMap<>(); // Fetch all files and folders in the drive List<File> allFiles = fetchAllFiles(driveId); // Build folder path mapping and organize files for (File file : allFiles) { String parentId = (file.getParents() != null && !file.getParents().isEmpty()) ? file.getParents().get(0) : null; String path = buildPath(file, parentId, idToPath); if (file.getMimeType().equals("application/vnd.google-apps.folder")) { idToPath.put(file.getId(), path); } else { pathToFile.computeIfAbsent(path, k -> new ArrayList<>()).add(file); } } // Now, pathToFile contains the mapping of paths to files // Your logic to handle these files goes here } private static List<File> fetchAllFiles(String driveId) throws IOException { // Implement fetching all files and folders here // Make sure to handle pagination if necessary // ... } private static String buildPath(File file, String parentId, HashMap<String, String> idToPath) { // Build the file path based on its parent ID and the idToPath mapping // ... }


Tailwind 和 CSS 动画环偏移缩小

<div class="flex flex-col items-center justify-center rounded-xl bg-[#101638] px-5 pb-8 pt-7"> <div class="relative mb-5 cursor-pointer"> <img class="mx-auto max-w-[90px] rounded-full p-1 ring ring-offset-8 ring-offset-[#101638] hover:ring-offset-0 ring-[#133e8d] md:max-w-[114px]" src="/images/Avatar1.png" alt="Bordered avatar"> <div class="absolute bottom-1 right-2 rounded-full bg-blue-600 px-2 py-1 ring-4 ring-[#0d1129]"> <svg class="svg-inline--fa fa-message-dots text-white" aria-hidden="true" focusable="false" data-prefix="fas" data-icon="message-dots" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"> <path class="" fill="currentColor" d="M0 64C0 28.7 28.7 0 64 0H448c35.3 0 64 28.7 64 64V352c0 35.3-28.7 64-64 64H309.3L185.6 508.8c-4.8 3.6-11.3 4.2-16.8 1.5s-8.8-8.2-8.8-14.3V416H64c-35.3 0-64-28.7-64-64V64zM128 240a32 32 0 1 0 0-64 32 32 0 1 0 0 64zm128 0a32 32 0 1 0 0-64 32 32 0 1 0 0 64zm160-32a32 32 0 1 0 -64 0 32 32 0 1 0 64 0z"></path> </svg> </div> </div> <div> <h1 class="font-bold">First Name</h1> </div> <div> <h1>Name</h1> </div> <div> <h1 class="text-[#636da8]">Project Mngr</h1> </div> </div> 如何为任何 css/tailwind 解决方案的偏移环的过渡设置动画? 例如,这 2 个缩略图,左边的缩略图悬停在其上,右边的缩略图是初始状态。我希望它在缩略图悬停时有一个缩小的动画,而不是我当前的动画,因为它非常突然 您可以考虑应用包含 transition-property 的 box-shadow CSS 值,例如 transition 或 transition-all Tailwind 类,以及非 0 transition-duration,上述类名也设置了: <script src="https://cdn.tailwindcss.com/3.4.1"></script> <div class="flex flex-col items-center justify-center rounded-xl bg-[#101638] px-5 pb-8 pt-7"> <div class="relative mb-5 cursor-pointer"> <img class="mx-auto max-w-[90px] rounded-full p-1 ring ring-offset-8 ring-offset-[#101638] hover:ring-offset-0 ring-[#133e8d] md:max-w-[114px] transition" src="https://picsum.photos/90/90" alt="Bordered avatar"> <div class="absolute bottom-1 right-2 rounded-full bg-blue-600 px-2 py-1 ring-4 ring-[#0d1129]"> <svg class="svg-inline--fa fa-message-dots text-white" aria-hidden="true" focusable="false" data-prefix="fas" data-icon="message-dots" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"> <path class="" fill="currentColor" d="M0 64C0 28.7 28.7 0 64 0H448c35.3 0 64 28.7 64 64V352c0 35.3-28.7 64-64 64H309.3L185.6 508.8c-4.8 3.6-11.3 4.2-16.8 1.5s-8.8-8.2-8.8-14.3V416H64c-35.3 0-64-28.7-64-64V64zM128 240a32 32 0 1 0 0-64 32 32 0 1 0 0 64zm128 0a32 32 0 1 0 0-64 32 32 0 1 0 0 64zm160-32a32 32 0 1 0 -64 0 32 32 0 1 0 64 0z"></path> </svg> </div> </div> <div> <h1 class="font-bold">First Name</h1> </div> <div> <h1>Name</h1> </div> <div> <h1 class="text-[#636da8]">Project Mngr</h1> </div> </div> 否则,您可以考虑通过 transition-property: box-shadow Tailwind 类应用 transition-duration: 150ms; 和 transition-[box-shadow](以及其他属性)以仅转换 box-shadow: <script src="https://cdn.tailwindcss.com/3.4.1"></script> <div class="flex flex-col items-center justify-center rounded-xl bg-[#101638] px-5 pb-8 pt-7"> <div class="relative mb-5 cursor-pointer"> <img class="mx-auto max-w-[90px] rounded-full p-1 ring ring-offset-8 ring-offset-[#101638] hover:ring-offset-0 ring-[#133e8d] md:max-w-[114px] transition-[box-shadow]" src="https://picsum.photos/90/90" alt="Bordered avatar"> <div class="absolute bottom-1 right-2 rounded-full bg-blue-600 px-2 py-1 ring-4 ring-[#0d1129]"> <svg class="svg-inline--fa fa-message-dots text-white" aria-hidden="true" focusable="false" data-prefix="fas" data-icon="message-dots" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"> <path class="" fill="currentColor" d="M0 64C0 28.7 28.7 0 64 0H448c35.3 0 64 28.7 64 64V352c0 35.3-28.7 64-64 64H309.3L185.6 508.8c-4.8 3.6-11.3 4.2-16.8 1.5s-8.8-8.2-8.8-14.3V416H64c-35.3 0-64-28.7-64-64V64zM128 240a32 32 0 1 0 0-64 32 32 0 1 0 0 64zm128 0a32 32 0 1 0 0-64 32 32 0 1 0 0 64zm160-32a32 32 0 1 0 -64 0 32 32 0 1 0 64 0z"></path> </svg> </div> </div> <div> <h1 class="font-bold">First Name</h1> </div> <div> <h1>Name</h1> </div> <div> <h1 class="text-[#636da8]">Project Mngr</h1> </div> </div>


在PHP中打印文件修改时间ISO-8601格式[重复]

我试图回显文件的上次更新时间并将其显示为 ISO-8601 时间戳格式。我尝试了一些命令,但它们没有获得正确的上次修改日期。 我试过: 我正在尝试 echo 文件的上次更新时间并将其显示为 ISO-8601 时间戳格式。我尝试了一些命令,但它们没有获得正确的上次修改日期。 我尝试过: <?php echo date("c"); ?> 但它只获取当前服务器时间,就像2024-01-11T11:39:33+02:00一样,它总是在变化。与date('c', time())相同。 以下两个似乎得到以下日期:1970-01-01T02:00:00+02:00: $lastmod = date('Y-m-dTH:i:s+00:00'); echo date('c', $timestamp) 和 $lastmod = date('Y-m-d\TH:i:s'); $tzd = date('Z'); $lastmod .= ($tzd < 0)? "-".gmdate('H:i', -$tzd) : "+".gmdate('H:i', $tzd); echo date('c', $timestamp) 我想要最后修改的 PHP/HTML 文件日期(时间戳);如果是两天前编辑的,则会显示日期等 您可以使用 PHP 中的 filemtime 函数来获取 ISO-8601 格式的文件的最后修改时间: $filename = 'path/to/your/file.php'; // Replace with your file path if (file_exists($filename)) { $lastModified = filemtime($filename); echo date('c', $lastModified); } else { echo "The file does not exist."; }


Ansible 无法通过 XPath 读取属性(不是元素)

我尝试从 XML 文件读取 XML 属性的值,但收到此错误: Xpath /sca:composite/@revision 未引用节点! 我的 XML 文件如下所示: 我试图从 XML 文件中读取 XML 属性的值,但收到此错误: Xpath /sca:composite/@revision 未引用节点! 我的 XML 文件如下所示: <composite revision="1.0.1" xmlns="http://xmlns.oracle.com/sca/1.0"> ... </composite> 我的 Ansible 命令是: - name: 'Get revision' xml: path: 'composite.xml' xpath: '/sca:composite/@revision' content: attribute namespaces: sca: 'http://xmlns.oracle.com/sca/1.0' register: my_revision 我尝试过不少于20种XPath的排列方式,比如: /composite/@revision /composite/revision /sca:composite/@revision /sca:composite/revision /sca:composite/@sca:revision 并使用 content 作为 text 和 attribute。 我能得到的最接近的结果是用 XPath 匹配根节点:/sca:composite。 但我就是找不到该属性。 有什么建议吗? 我找到了一个做作的两步解决方法。首先,XPath 仅匹配元素。其次,导航 JSON 结果/匹配属性。 -name: 'Match XPath' xml: path: 'composite.xml' xpath: '/sca:composite/@revision' content: attribute namespaces: sca: 'http://xmlns.oracle.com/sca/1.0' register: xpath_match -name: 'Get revision' set_fact: my_revision: '{{xpath_match.matches[0]["{http://xmlns.oracle.com/sca/1.0}composite"].revision}}' 注意:XPath 匹配返回一个 JSON 对象,例如: { "matches": [ { "{http://xmlns.oracle.com/sca/1.0}composite": { "revision": "1.0.1" } } ] } 不要对 "composite" 的 JSON 字段名称感到困惑。它的语法是"{xmlnamespace}composite"


如何使用DomDocument通过id获取值?

我正在尝试使用 DomDocument 获取下面表单的值,但到目前为止仍然失败 我正在尝试使用 DomDocument 获取下面表单的值,但到目前为止仍然失败 <?php $string ='<form action="profile" method="post" enctype="multipart/form-data"> <input type="hidden" name="id_user" id="id_user" value="123"> <input type="hidden" name="logo" id="logo" value="path/to/logo1.png"> <input type="hidden" name="status" id="status" value="Ok"> <input type="submit" value="PROFILE"> </form>'; ?> 这种情况下如何正确使用DomDocument? 我正在尝试下面的代码 $dom = new DomDocument(); $dom->loadHTML($string); $dom->getElementById("id_user"); 我期望得到 123 作为返回值 DomDocument 有点麻烦,但如果您遵循文档,您就可以到达那里。我找到了这条路线: $dom->getElementById("id_user")->attributes->getNamedItem("value")->value 返回: 123 参见:https://onlinephp.io/c/c37dc 可能还有其他方法可以做到同样的事情。


React 组件的样式与其他组件的样式冲突

我有一个像这样的应用程序组件: 常量应用程序 = () => { 返回 ( 我有一个像这样的应用程序组件: const App = () => { return ( <Router> <Route exact path='/' component={Landing} /> <Route path='/login' component={Login} /> </Router> ) } 每个组件都有自己的目录和样式表。我的文件夹结构是这样的: src | | Landing| | | | Landing.js | Landing.module.css | | Login| | | | Login.js | Login.module.css | app.js index.js 我的问题是Login和Landing组件的样式表相互冲突,并且Landing页面看起来不太好。例如,登录的背景颜色适用于登陆页面,但我不希望这样。 我只在每个组件中导入 CSS 文件,如下所示: import styles from './Landing.module.css' 这是我如何使用样式变量的示例: return ( <div className={styles.navBar}> <Link to="/"> <img className={styles.logo} src="https://image.flaticon.com/icons/png/512/2039/2039175.png" /> </Link> {loggedIn && <div> <button onClick={logout}>log out</button> <Link className={styles.navItem} to="/users">get users</Link> </div> } {!loggedIn && <div> <Link className={styles.navItem} to="/login">log in</Link> <Link className={styles.navItem, styles.btn} to="/signup">signup</Link> </div> } </div> ) 即使它很旧,我也会回答谁在后面:发生这种情况的原因是你的CSS选择器很可能具有相同的特异性,因此是外观的顺序决定了应用哪种样式。 文件夹结构中的 Login 位于 Landing 之后,因此您的捆绑程序将使 Login 的样式出现在捆绑的 CSS 中的最后,然后它将覆盖 Landing 的样式。 这个问题有很多解决方案: 您可以增加您想要赢得的选择器的特异性(例如,通过在 CSS 文件中重复两次该类) 您可以降低想要丢失的选择器的特异性(例如使用 :where()) 如果您同意支持哪些浏览器(例如@layer),现在您可以使用级联层 等等...


react-hook-form useForm 每次在 Nextjs 页面路由上执行

嗨,我是 Nextjs(v14) 的新手。我想使用react-hook-form 实现多页面表单。 然而,似乎每次都会执行useForm,并且defaultValues是在页面路由中设置的(点击 嗨,我是 Nextjs(v14) 的新手。我想使用react-hook-form 实现多页面表单。 不过,好像每次都会执行useForm,并且在页面路由时设置defaultValues(点击<Link to=XX>)。 如何跨多个页面保存表单数据? 请帮助我。 这是我的代码。 _app.tsx return ( <div> <FormProvider> <Component {...pageProps} /> </FormProvider> </div> ); FormProvider.tsx export const FormProvider = ({ children, }: { children: React.ReactNode; }) => { const defaultValues: MyForm = { name: '', description: '' }; const form = useForm({ defaultValues, resolver: zodResolver(MyFormSchema), }); const onSubmit = () => console.log("something to do"); return ( <Form {...form}> <form onSubmit={form.handleSubmit(onSubmit)}>{children}</form> </Form> ); }; 您正在寻找的是跨多个页面维护的某种全局状态。对于这个例子,我将使用 React 的上下文 API,如果这不适合您的用例,您可以找到一些其他状态管理库。 首先,您需要创建一个全局上下文,并在表单提供程序中包含一个全局状态 // FormProvider.tsx import { createContext, useContext, useState } from 'react'; const FormContext = createContext(); // Exported to be used in other components export const useFormContext = () => useContext(FormContext); export const FormProvider = ({ children }) => { const [formData, setFormData] = useState({}); return ( <FormContext.Provider value={{ formData, setFormData }}> {children} </FormContext.Provider> ); }; 现在您需要用 FormProvider 包装您的应用程序 // You are already doing this part //_app.tsx return ( <div> <FormProvider> <Component {...pageProps} /> </FormProvider> </div> ) 现在你可以像这样使用它了。请记住,您将更新表单的全局状态,该状态将在您的所有页面上发生变化。 // In your form component import { useForm } from 'react-hook-form'; import { useFormContext } from '../path/to/formContext'; const MyFormComponent = () => { const { formData, setFormData } = useFormContext(); const { register, handleSubmit } = useForm({ defaultValues: formData, resolver: zodResolver(MyFormSchema), }); const onSubmit = (data) => { setFormData(data); // Handle form submission }; return ( <form onSubmit={handleSubmit(onSubmit)}> {/* Form fields */} </form> ); }; 您可以从其他页面访问数据的示例 // In another page or component import { useFormContext } from '../path/to/formContext'; const AnotherPage = () => { const { formData } = useFormContext(); // Use formData as needed };


Laravel 购物车页面,表单内有一个表单,用于处理删除和提交数据更新数据库

我有一个购物车页面,表格内有一个表格,也许你可以建议我应该做什么? 根据图片,我给出的蓝色圆圈是一个表格 我的刀片代码 我有一个购物车页面,表格内有一个表格,也许你可以建议我应该做什么?根据图片我给出的蓝色圆圈是一个表格我的刀片代码<table class="table"> <thead> <tr> <th scope="col">No</th> <th scope="col">Nama Barang</th> <th scope="col">Quantity</th> <th scope="col">Action</th> </tr> </thead> <tbody> @php $no = 1; @endphp @forelse ($permintaans as $b) <tr> <td>{{ $no ++ }}</td> <td> {{ $b->nama_kategori }} {{ $b->nama_atk }} </td> <td> <form action="{{ route('permintaan.update', $b->id) }}" method="POST" style="display: inline-block;"> @csrf @method('PUT') <div class="input-group input-group-sm mb-3"> <input type="number" class="form-control" aria-label="Sizing example input" aria-describedby="inputGroup-sizing-sm" name="satuan_permintaan" min="0" max={{ $b->stok }} required> <span class="input-group-text" id="inputGroup-sizing-sm">{{ $b->subsatuan_atk }}</span> </div> </td> <td> <form action="{{ route('permintaan.destroy', $b->id) }}" method="POST" style="display: inline-block;"> @csrf @method('DELETE') <button type="submit" class="btn custom2-btn"><svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" fill="red" class="bi bi-trash" viewBox="0 0 16 16"> <path d="M5.5 5.5A.5.5 0 0 1 6 6v6a.5.5 0 0 1-1 0V6a.5.5 0 0 1 .5-.5m2.5 0a.5.5 0 0 1 .5.5v6a.5.5 0 0 1-1 0V6a.5.5 0 0 1 .5-.5m3 .5a.5.5 0 0 0-1 0v6a.5.5 0 0 0 1 0z"/> <path d="M14.5 3a1 1 0 0 1-1 1H13v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V4h-.5a1 1 0 0 1-1-1V2a1 1 0 0 1 1-1H6a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1h3.5a1 1 0 0 1 1 1zM4.118 4 4 4.059V13a1 1 0 0 0 1 1h6a1 1 0 0 0 1-1V4.059L11.882 4zM2.5 3h11V2h-11z"/> </svg></button> </form> </td> </tr> @empty @endforelse </tbody> </table> 我的控制器public function store(Request $request) { $task = new Permintaan(); $task->atk_id = $request->input('atk_id'); $task->proses = 'Proses'; if (Permintaan::where('atk_id', $task->atk_id)->exists()){ return redirect('/atk/permintaan')->with(['info' => 'ATK Sudah Dalam Permintaan']); } else{ $task->save(); return redirect()->route('permintaan.index'); } } public function destroy($id) { $permintaan = Permintaan::find($id); $permintaan->delete(); return redirect()->route('permintaan.index'); } 我要处理删除并提交数据更新数据库 在开始销毁表单之前关闭更新表单第一个表单标签(缺少)。


子控件中的绑定命令?

我有一个 UserControl,用作窗口对话框的“模板”。 它包含一个关闭按钮和一个取消按钮。 我有一个 UserControl,用作窗口对话框的“模板”。 它包含一个关闭按钮和一个取消按钮。 <UserControl x:Class="TombLib.WPF.Controls.WindowControlButtons" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:local="clr-namespace:TombLib.WPF.Controls" mc:Ignorable="d" xmlns:darkUI="clr-namespace:DarkUI.WPF;assembly=DarkUI.WPF" xmlns:vm="clr-namespace:TombLib.WPF.ViewModels" xmlns:sg="clr-namespace:SpacedGridControl;assembly=SpacedGridControl" d:DesignHeight="100" d:DesignWidth="300" x:Name="root"> <StackPanel VerticalAlignment="Center" HorizontalAlignment="Right" Height="Auto" Orientation="Horizontal"> <Button Name="oKButton" Margin="{x:Static darkUI:Defaults.MediumThickness}" Width="100" Height="Auto" Command="{Binding Close}" CommandParameter="{Binding Window}" Content="OK"></Button> <Button Name="cancelButton" Margin="{x:Static darkUI:Defaults.MediumThickness}" Width="100" Height="Auto" Command="{Binding Path=Cancel}" CommandParameter="{Binding Window}" Content="Cancel"></Button> </StackPanel> </UserControl> public partial class WindowControlButtons : UserControl { public static readonly DependencyProperty CancelProperty = DependencyProperty.Register( nameof(Cancel), typeof(ICommand), typeof(WindowControlButtons), new PropertyMetadata(null)); public ICommand Cancel { get { return (ICommand)GetValue(CancelProperty); } set { SetValue(CancelProperty, value); } } public static readonly DependencyProperty CloseProperty = DependencyProperty.Register( nameof(Close), typeof(ICommand), typeof(WindowControlButtons), new PropertyMetadata(null)); public ICommand Close { get { return (ICommand)GetValue(CloseProperty); } set { SetValue(CloseProperty, value); } } public static readonly DependencyProperty WindowParameter = DependencyProperty.Register( nameof(Window), typeof(object), typeof(WindowControlButtons), new PropertyMetadata(null)); public object? Window { get { return GetValue(WindowParameter); } set { SetValue(WindowParameter, value); } } public WindowControlButtons() { InitializeComponent(); } } 我想在以下窗口中使用它: <Window x:Class="TombLib.WPF.Windows.SelectIdWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:local="clr-namespace:TombLib.WPF.Windows" mc:Ignorable="d" xmlns:ctrl="clr-namespace:TombLib.WPF.Controls" xmlns:vm="clr-namespace:TombLib.WPF.ViewModels" xmlns:sg="clr-namespace:SpacedGridControl;assembly=SpacedGridControl" xmlns:darkUI="clr-namespace:DarkUI.WPF;assembly=DarkUI.WPF" Title="SelectIdWindow" Height="100" Width="300" d:DataContext="{d:DesignInstance Type=vm:SelectIdViewModel }" x:Name="Self"> <sg:SpacedGrid Margin="{x:Static darkUI:Defaults.MediumThickness}"> <!-- REDACTED --> <ctrl:WindowControlButtons DataContext="{Binding ElementName=Self}" Window="{Binding ElementName=Self, Mode=OneWay}" Close="{Binding CloseCommand,Mode=OneWay}" Cancel="{Binding CancelCommand,Mode=OneWay}" Height="Auto" Width="Auto" Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" HorizontalAlignment="Right"/> </sg:SpacedGrid> </Window> public partial class SelectIdWindow : Window { public ICommand? CloseCommand { get; set; } public ICommand? CancelCommand { get; set; } public SelectIdWindow() { CloseCommand = new WindowCloseCommand(); InitializeComponent(); } } public class SelectIdViewModel { public string RequestedId { get; set; } = string.Empty; public IEnumerable<string> TakenIds { get; set;} public SelectIdViewModel(IEnumerable<string> takenIDs) { TakenIds = takenIDs; } } 但是,当我打开窗口时如下: SelectIdWindow w = new SelectIdWindow(); var takenIDs = Entities.Select(kv => kv.Key.Name); w.DataContext = new SelectIdViewModel(takenIDs); w.ShowDialog(); 我在绑定 WindowControlButtons 时收到以下错误: DataContext 显式设置为 Self,它应该代表 Window,而不是 ViewModel。我在这里做错了什么? 绑定错误表明问题出在 Button.ICommand 属性上: 要修复此问题,请在 WindowControlButtons 绑定中添加 ElementName=root,以便绑定到声明的依赖项属性而不是 DataContext: <UserControl x:Class="TombLib.WPF.Controls.WindowControlButtons" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:local="clr-namespace:TombLib.WPF.Controls" mc:Ignorable="d" xmlns:darkUI="clr-namespace:DarkUI.WPF;assembly=DarkUI.WPF" xmlns:vm="clr-namespace:TombLib.WPF.ViewModels" xmlns:sg="clr-namespace:SpacedGridControl;assembly=SpacedGridControl" d:DesignHeight="100" d:DesignWidth="300" x:Name="root"> <StackPanel VerticalAlignment="Center" HorizontalAlignment="Right" Height="Auto" Orientation="Horizontal"> <Button Name="oKButton" ... Command="{Binding Close, ElementName=root}" CommandParameter="{Binding Window, ElementName=root}" Content="OK"/> <Button Name="cancelButton" ... Command="{Binding Path=Cancel, ElementName=root}" CommandParameter="{Binding Window, ElementName=root}" Content="Cancel"/> </StackPanel> </UserControl>


Flatpickr AlpineJS 在危险范围选择上坚持插件

我有一个工作完美的 Flatpickr 日期范围日历,它将日期存储在会话存储中。这是我的代码: 我有一个工作完美的 Flatpickr 日期范围日历,它将日期存储在会话存储中。这是我的代码: <div x-data="{ chosenDates: sessionStorage.getItem('_x_range'), value: [], init() { let picker = flatpickr(this.$refs.picker, { mode: 'range', inline: false, dateFormat: 'm/d/Y', showMonths: 2, }) this.$watch('value', () => picker.setDate(this.value)) }, }" > <div class="flex items-center flex-1 gap-2 overflow-hidden border border-gray-500 rounded-lg"> <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="ml-4 bi bi-calendar-event-fill" viewBox="0 0 16 16"> <path d="M4 .5a.5.5 0 0 0-1 0V1H2a2 2 0 0 0-2 2v1h16V3a2 2 0 0 0-2-2h-1V.5a.5.5 0 0 0-1 0V1H4zM16 14V5H0v9a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2m-3.5-7h1a.5.5 0 0 1 .5.5v1a.5.5 0 0 1-.5.5h-1a.5.5 0 0 1-.5-.5v-1a.5.5 0 0 1 .5-.5"/> </svg> <input id="rangeValue" :value="chosenDates" placeholder="Add dates" x-ref="picker" type="text" class="p-0 py-4 placeholder-gray-600 border-0 bg-none focus:ring-0 " data-input> </div> </div> 设置项目: function dateRange() { var date = document.getElementById("rangeValue").value; sessionStorage.setItem("_x_range", date); sessionStorage.setItem("start", start); sessionStorage.setItem("end", end); const start = sessionStorage.getItem("start"); } $('#rangeValue').on('focus', ({ currentTarget }) => $(currentTarget).blur()) $("#rangeValue").prop('readonly', false) ``` Receive item: if (sessionStorage.getItem("_x_range") != null) { document.getElementById("chosenRange").innerHTML = sessionStorage.getItem("_x_range"); document.getElementById("rangeValue").value = sessionStorage.getItem("_x_range"); } ``` 如果可能的话,我想学习如何使用 AplineJS 和 Persist 来设置它,以免代码过多而过期。 这可能吗? 这是一个可能的解决方案: <div x-data="{ thePicker: null, chosenDates: $persist([]).using(sessionStorage).as('_x_range'), init() { this.thePicker = flatpickr(this.$refs.picker, { mode: 'range', inline: false, dateFormat: 'm/d/Y', showMonths: 2, defaultDate: this.chosenDates, onChange: (selectedDates) => {this.chosenDates = [...selectedDates];} }); }, }" > <div class="flex items-center flex-1 gap-2 overflow-hidden border border-gray-500 rounded-lg"> <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="ml-4 bi bi-calendar-event-fill" viewBox="0 0 16 16"> <path d="M4 .5a.5.5 0 0 0-1 0V1H2a2 2 0 0 0-2 2v1h16V3a2 2 0 0 0-2-2h-1V.5a.5.5 0 0 0-1 0V1H4zM16 14V5H0v9a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2m-3.5-7h1a.5.5 0 0 1 .5.5v1a.5.5 0 0 1-.5.5h-1a.5.5 0 0 1-.5-.5v-1a.5.5 0 0 1 .5-.5"/> </svg> <input type="text" x-ref="picker" placeholder="Add dates" class="p-0 py-4 placeholder-gray-600 border-0 bg-none focus:ring-0" > <span title="Clear" class="text-blue-600 cursor-pointer" @click="thePicker.clear()" > X </span> </div> <div x-text="chosenDates"> </div> </div> 日期范围存储在 Alpine chosenDates 变量中,该变量通过 Persist 进行持久化并初始化为空数组。 当日期选择器初始化时,chosenDates变量用于填充defaultDate参数。 选择日期范围后,flatpicker 会触发 onChage 事件,因此我使用它将新范围复制到 chosenDates 变量中。 我添加了一个 “clear” 按钮以 flatpicker 方式重置输入字段,调用 clear() 方法(这是一个简单的示例),然后我必须将 flatpicker 引用存储在 thePicker 中变量. 我还添加了一个 通过 x-text 显示 choosenDates 的内容


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