feat: match different length of mac

This commit is contained in:
TaurusXin 2024-08-02 16:30:46 +08:00
parent ff240ae44c
commit c9f559a8ea
Signed by: taurusxin
GPG Key ID: C334DCA04AC2D2CC
9 changed files with 1353 additions and 1658 deletions

View File

@ -1 +1 @@
8857565900ea1a36112664798db58d03
066112e6c557bd6b8c986b4fd27a4b3f

File diff suppressed because it is too large Load Diff

View File

@ -29,6 +29,36 @@ import Download from './Download'
import { Separator } from '@/components/ui/separator'
import { Loader2 } from 'lucide-react'
interface MacAddress {
Prefix: string
VendorName: string
IsPrivate: boolean
BlockType: string
LastUpdate: string
}
const addColons = (hexString: string): string => {
// Check if the input string is valid
if (!/^[A-F0-9]{6,12}$/.test(hexString)) {
return ''
}
// Initialize the result array
const result: string[] = []
// Loop through the string and add colons every two characters
for (let i = 0; i < hexString.length; i += 2) {
if (i + 2 < hexString.length) {
result.push(hexString.substring(i, i + 2))
} else {
result.push(hexString.substring(i))
}
}
// Join the result array with colons
return result.join(':')
}
const Panel: React.FC = () => {
const [macInputDisabled, setMacInputDisabled] = useState(false)
@ -97,9 +127,8 @@ const Panel: React.FC = () => {
if (address.length < 6) {
return
}
address =
address.substring(0, 2) + ':' + address.substring(2, 4) + ':' + address.substring(4, 6)
QueryMacAddressByPrefix(address).then(res => {
address = addColons(address)
QueryMacAddressByPrefix(address).then((res: any) => {
if (res === null) {
setPrefix('Not Found')
setVendorName('')

View File

@ -0,0 +1,17 @@
export namespace service {
export class MacAddress {
static createFrom(source: any = {}) {
return new MacAddress(source);
}
constructor(source: any = {}) {
if ('string' === typeof source) source = JSON.parse(source);
}
}
}

View File

@ -233,3 +233,17 @@ export function ClipboardGetText(): Promise<string>;
// [ClipboardSetText](https://wails.io/docs/reference/runtime/clipboard#clipboardsettext)
// Sets a text on the clipboard
export function ClipboardSetText(text: string): Promise<boolean>;
// [OnFileDrop](https://wails.io/docs/reference/runtime/draganddrop#onfiledrop)
// OnFileDrop listens to drag and drop events and calls the callback with the coordinates of the drop and an array of path strings.
export function OnFileDrop(callback: (x: number, y: number ,paths: string[]) => void, useDropTarget: boolean) :void
// [OnFileDropOff](https://wails.io/docs/reference/runtime/draganddrop#dragandddropoff)
// OnFileDropOff removes the drag and drop listeners and handlers.
export function OnFileDropOff() :void
// Check if the file path resolver is available
export function CanResolveFilePaths(): boolean;
// Resolves file paths for an array of files
export function ResolveFilePaths(files: File[]): void

View File

@ -199,4 +199,40 @@ export function ClipboardGetText() {
export function ClipboardSetText(text) {
return window.runtime.ClipboardSetText(text);
}
/**
* Callback for OnFileDrop returns a slice of file path strings when a drop is finished.
*
* @export
* @callback OnFileDropCallback
* @param {number} x - x coordinate of the drop
* @param {number} y - y coordinate of the drop
* @param {string[]} paths - A list of file paths.
*/
/**
* OnFileDrop listens to drag and drop events and calls the callback with the coordinates of the drop and an array of path strings.
*
* @export
* @param {OnFileDropCallback} callback - Callback for OnFileDrop returns a slice of file path strings when a drop is finished.
* @param {boolean} [useDropTarget=true] - Only call the callback when the drop finished on an element that has the drop target style. (--wails-drop-target)
*/
export function OnFileDrop(callback, useDropTarget) {
return window.runtime.OnFileDrop(callback, useDropTarget);
}
/**
* OnFileDropOff removes the drag and drop listeners and handlers.
*/
export function OnFileDropOff() {
return window.runtime.OnFileDropOff();
}
export function CanResolveFilePaths() {
return window.runtime.CanResolveFilePaths();
}
export function ResolveFilePaths(files) {
return window.runtime.ResolveFilePaths(files);
}

2
go.mod
View File

@ -4,7 +4,7 @@ go 1.21
toolchain go1.21.10
require github.com/wailsapp/wails/v2 v2.8.2
require github.com/wailsapp/wails/v2 v2.9.1
require (
github.com/bep/debounce v1.2.1 // indirect

4
go.sum
View File

@ -63,8 +63,8 @@ github.com/wailsapp/go-webview2 v1.0.10 h1:PP5Hug6pnQEAhfRzLCoOh2jJaPdrqeRgJKZhy
github.com/wailsapp/go-webview2 v1.0.10/go.mod h1:Uk2BePfCRzttBBjFrBmqKGJd41P6QIHeV9kTgIeOZNo=
github.com/wailsapp/mimetype v1.4.1 h1:pQN9ycO7uo4vsUUuPeHEYoUkLVkaRntMnHJxVwYhwHs=
github.com/wailsapp/mimetype v1.4.1/go.mod h1:9aV5k31bBOv5z6u+QP8TltzvNGJPmNJD4XlAL3U+j3o=
github.com/wailsapp/wails/v2 v2.8.2 h1:rYOn9p+7bJiZuFSi2wDyq8rBLHrIX/FoUxov+RpdUOI=
github.com/wailsapp/wails/v2 v2.8.2/go.mod h1:5pTURIST4yZ/wRcmqDUtnM0Mk+caNax/oS610hFiy74=
github.com/wailsapp/wails/v2 v2.9.1 h1:irsXnoQrCpeKzKTYZ2SUVlRRyeMR6I0vCO9Q1cvlEdc=
github.com/wailsapp/wails/v2 v2.9.1/go.mod h1:7maJV2h+Egl11Ak8QZN/jlGLj2wg05bsQS+ywJPT0gI=
golang.org/x/crypto v0.23.0 h1:dIJU/v2J8Mdglj/8rJ6UUOM3Zc9zLZxVZwwxMooUSAI=
golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8=
golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1 h1:k/i9J1pBpvlfR+9QsetwPyERsqu1GIbi967PQMq3Ivc=

View File

@ -12,6 +12,6 @@
},
"info": {
"copyright": "TaurusXin 2024",
"productVersion": "1.2.0"
"productVersion": "1.3.0"
}
}