Last active
          November 3, 2025 01:59 
        
      - 
      
 - 
        
Save sunwu51/138971dc06aa83f493be5ba315bf49c2 to your computer and use it in GitHub Desktop.  
    mac通知栏展示au9999和ag2412价格
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | package main | |
| import ( | |
| "encoding/json" | |
| "fmt" | |
| "io" | |
| "net/http" | |
| "strings" | |
| "time" | |
| "github.com/getlantern/systray" | |
| ) | |
| type AuQuoteData struct { | |
| JO_71 struct { | |
| Q63 float64 `json:"q63"` | |
| Q80 float64 `json:"q80"` | |
| } `json:"JO_71"` | |
| JO_165757 struct { | |
| Q63 float64 `json:"q63"` | |
| Q80 float64 `json:"q80"` | |
| } `json:"JO_165757"` | |
| } | |
| func fetchQuote() (string, error) { | |
| client := &http.Client{} | |
| req, err := http.NewRequest("GET", "https://api.jijinhao.com/quoteCenter/realTime.htm?codes=JO_165757,JO_71", nil) | |
| if err != nil { | |
| return "", err | |
| } | |
| // Set the Referer header | |
| req.Header.Set("Referer", "https://m.cngold.org/") | |
| resp, err := client.Do(req) | |
| if err != nil { | |
| return "", err | |
| } | |
| defer resp.Body.Close() | |
| body, err := io.ReadAll(resp.Body) | |
| if err != nil { | |
| return "", err | |
| } | |
| // Extract JSON from the response body | |
| bodyStr := string(body) | |
| start := strings.Index(bodyStr, "var quote_json =") | |
| if start == -1 { | |
| return "", fmt.Errorf("quote_json not found") | |
| } | |
| start += len("var quote_json =") | |
| quoteJson := bodyStr[start:] | |
| var quoteData AuQuoteData | |
| if err := json.Unmarshal([]byte(quoteJson), "eData); err != nil { | |
| return "", err | |
| } | |
| ratio71 := fmt.Sprintf("📉%.2f%%", quoteData.JO_71.Q80) | |
| if quoteData.JO_71.Q80 > 0 { | |
| ratio71 = fmt.Sprintf("📈+%.2f%%", quoteData.JO_71.Q80) | |
| } | |
| ratio165757 := fmt.Sprintf("📉%.2f%%", quoteData.JO_165757.Q80) | |
| if quoteData.JO_165757.Q80 > 0 { | |
| ratio165757 = fmt.Sprintf("📈+%.2f%%", quoteData.JO_165757.Q80) | |
| } | |
| return fmt.Sprintf("au%.2f%s, ag%.2f%s", quoteData.JO_71.Q63, ratio71, quoteData.JO_165757.Q63, ratio165757), nil | |
| } | |
| func main() { | |
| onReady := func() { | |
| systray.SetTitle("Loading...") | |
| mQuit := systray.AddMenuItem("Quit", "Quit the application") | |
| go func() { | |
| <-mQuit.ClickedCh | |
| systray.Quit() | |
| }() | |
| go func() { | |
| for { | |
| quote, err1 := fetchQuote() | |
| if err1 != nil { | |
| systray.SetTitle("Error fetching quote") | |
| } else { | |
| systray.SetTitle(quote) | |
| } | |
| time.Sleep(2 * time.Second) | |
| } | |
| }() | |
| } | |
| onExit := func() {} | |
| systray.Run(onReady, onExit) | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment