A lot of time in the work should pay attention to efficiency, simplify some tedious and repetitive things.

I used node V10.19.0, NPM 6.13.4, and Alfred 4.0.9

If you don’t know Alfred, click here

Without further ado, let’s use NodeJS to create Alfred’s Workflow tool

Functional requirements:

  • Obtain the IP address of the LAN
  • Obtain the PUBLIC IP address
  • Enter the IP address to query the owning place

Since I’m a front-end developer myself, NODEJS is no stranger to me, so today I’ll talk about the NDOEJS Development Workflow plug-in

Original intention: I do a lot of mobile terminal projects, often need to connect the mobile phone and computer to a local area network for debugging, every time I have to check my network card IP. It’s easy to burn yourself out (haha)

Let’s start with the renderings

  • Enter IP directly

  • Enter ipP directly

  • Enter IP + IP address

To make up

You need to know about Alfy before you start

  • Open Alfred’sPreferencesTo findWorkFlows, select the one at the bottom of the list+Number, chooseBlank Workflow

  • 2. Fill in the name, description, category and version information, author and website of the plug-in. Icon to find a favorite drag to the right of the box on the line

The Bundle Id must be entered

  • 3. Right-click a blank area and chooseInputs= >Script Filter, a box will pop up

  • 4. Fill in the following information and clicksave

  • 5. In the list, click CreateworkFlowchooseopen in Finder

  • 6. Use your handy editor (I used vscode) to open the project folder, bring out the terminal, and execute in the current foldernpm init -y

After you run it, you need to install the dependencies

npm i afly ip --save
Copy the code
  • 7. Create a root directoryindex.js

    const alfy = require("alfy");
    const ip = require("ip");
    
    const localNetWork = ip.address();
    
    alfy.output([
        {
            title: "LAN address:" + localNetWork,
            subtitle: "Press ⌘L to see the full error and ⌘C to copy it.".arg: localNetWork
        }
    ]);
    Copy the code

    Let’s run the terminalnode index.js, and check whether the output is normal. If the output is normal, over is displayed

  • 8. Bring up thealfredEnter the IP address in the box window and the display will be successful

  • 9. Press Enter to place the result on the clipboard (go backworkflowPage, right click pop-up menu, select, click will pop up a window, directly clicksaveSave ~)


Here basic flow has ended, the rest still need comrades to continue to work hard 💪

If you need the rest of the function, please download and use it at the end. If you need to apply for an AK parameter, please fill it out by yourself

The last

  • Nodejs for IP download

  • The project address