小编dea*_*904的帖子

使用gatsby-plugin-netlify从Netlify重定向到自定义域?

我有这样一个_redirects文件:

https://example.netlify.com/* https://example.com/:splat 301!
Run Code Online (Sandbox Code Playgroud)

在根文件夹中.

如何使用gatsby-plugin-netlifyhttps://example.netlify.com域重定向到https://example.com

javascript reactjs gatsby netlify

1
推荐指数
1
解决办法
499
查看次数

Cocoa Xcode:使用 Swift 4 for Mac 以编程方式从 AppDelegate 打开窗口控制器?

我正在制作一个简单的菜单栏应用程序,它有 2 个项目 -首选项退出

我想在单击首选项时打开一个新窗口

目前我有

func applicationDidFinishLaunching(_ aNotification: Notification) {
        constructMenu()
    }

func constructMenu() {
        let menu = NSMenu()

        menu.addItem(NSMenuItem(
                       title: "Preferences...", 
                       action: #selector(AppDelegate.preferencesWindow(_:)), 
                       keyEquivalent: "P"))
        menu.addItem(NSMenuItem.separator())
        menu.addItem(NSMenuItem(
                       title: "Quit", 
                       action: #selector(NSApplication.terminate(_:)), 
                       keyEquivalent: "q"))

        statusItem.menu = menu
    }

@objc func preferencesWindow(_ sender: Any) {
        print("open preference window here")
        if let storyboard = NSStoryboard(name: NSStoryboard.Name(rawValue: "Main"), bundle: nil) {
            let controller = storyboard.instantiateControllerWithIdentifier("preferencesWindow")
 as NSViewController

            if let window = NSApplication.shared.mainWindow {
                window.contentViewController = controller // …
Run Code Online (Sandbox Code Playgroud)

macos xcode cocoa swift swift4

1
推荐指数
1
解决办法
1292
查看次数

Swift 中如何知道实际的互联网是否可用?

我希望在我的 WiFi 路由器颜色从绿色变为红色时收到通知

我正在制作一个应用程序,它可以通过 Swift 的菜单栏告诉您是否在线或离线,该应用程序是开源的,可以在https://github.com/deadcoder0904/net-alert找到

我想知道当 Swift 中 WiFi 颜色发生变化时是否可以收到通知。

我无法不断地 ping 我的服务器来知道颜色发生了变化,因为这会浪费互联网资源。

那么在 Swift 中是否可以知道这一点呢?

notifications reachability ios swift

1
推荐指数
1
解决办法
1483
查看次数

如何在 JavaScript 中使用 Array.fill 创建 0...499?

我想使用Array.fill方法创建一个从 0...499 的序列,例如

const arr = []
for(let i = 0; i < 500; i++)
   arr.push(i);
Run Code Online (Sandbox Code Playgroud)

目前,我正在使用Array.from类似:

const arr = Array.from(Array(500).keys())
Run Code Online (Sandbox Code Playgroud)

但我怎样才能使用它来Array.fill创建序列呢?有可能吗?

javascript arrays ecmascript-6 es6-modules

1
推荐指数
1
解决办法
4421
查看次数

Next js 错误“警告:预期服务器 HTML 在 &lt;div&gt; 中包含匹配的 &lt;button&gt;”

我有一个黑暗模式组件,它是太阳和月亮图标之间的简单切换。

暗模式.tsx

import { observer } from 'mobx-react'
import { MoonIcon, SunIcon } from '@heroicons/react/solid'

import { useStore } from '@/store/index'

export const DarkMode = observer(() => {
    const { theme, setTheme, isPersisting } = useStore()

    if (!isPersisting) return null

    return (
        <>
            {theme === 'dark' && (
                <button
                    className="fixed bottom-12 right-12 focus:outline-none"
                    title="Activate light mode"
                    onClick={() => {
                        setTheme('light')
                    }}
                >
                    <MoonIcon className="w-8 h-8" />
                </button>
            )}
            {theme === 'light' && (
                <button
                    className="fixed bottom-12 right-12 focus:outline-none"
                    title="Activate dark …
Run Code Online (Sandbox Code Playgroud)

javascript reactjs mobx next.js tailwind-css

1
推荐指数
1
解决办法
1879
查看次数

相当于 Windows PowerShell 的“rm -rf”?

我已经阅读了Windows 的“rm -rf”等价问题. 而且我还尝试了以下命令:

$ rm app
$ rmdir /s /q app
$ rmdir -s -q app
$ rd /s /q app
Run Code Online (Sandbox Code Playgroud)

以及许多其他变体。它总是提示我:

C:\ThisDirectoryDoesNotExist\app\ 中的项目有子项,并且未指定 Recurse 参数。如果继续,所有子项都将随项目一起删除。你确定你要继续吗?

[Y] 是 [A] 全是 [N] 否 [L] 全否 [S] 暂停 [?] 帮助(默认为“Y”):A

当我选择时A,它会抛出一个错误:

rm:无法删除项目 C:\ThisDirectoryDoesNotExist\app.git\objects\pack\pack-45e426475eb08ff5042bf88556fbedd3956fba53.idx:您没有足够的访问权限来执行此操作。

我该怎么做?

windows powershell

0
推荐指数
1
解决办法
1万
查看次数