Skip to content

Commit

Permalink
cursor-vip update
Browse files Browse the repository at this point in the history
  • Loading branch information
[email protected] committed Oct 19, 2024
1 parent 0e694a6 commit 2afe836
Show file tree
Hide file tree
Showing 8 changed files with 67 additions and 16 deletions.
6 changes: 3 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ func main() {
}

func startServer(productSelected string, modelIndexSelected int) {
sigs := make(chan os.Signal, 1)
signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM, syscall.SIGHUP, syscall.SIGQUIT, syscall.SIGKILL)
tui.Sigs = make(chan os.Signal, 1)
signal.Notify(tui.Sigs, syscall.SIGINT, syscall.SIGTERM, syscall.SIGHUP, syscall.SIGQUIT, syscall.SIGKILL)
go func() {
<-sigs
<-tui.Sigs
auth.UnSetClient(productSelected)
if modelIndexSelected == 2 {
tui.UnSetProxy()
Expand Down
4 changes: 3 additions & 1 deletion tui/locales/en.ini
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ CURSOR VIP:CURSOR VIP
请输入产品编号(直接回车默认为1,可以同时输入多个例如 145)::Please enter the product number (press Enter directly to default to 1, you can enter multiple at the same time, such as 145):
输入有误:Input error
选择的产品为::The selected product is:
选择有效期::Select validity period:
选择有效期::'Select validity period: '
小时(免费): ' hours (free)'
年(购买): ' year (purchase)'
请输入有效期编号(直接回车默认为1)::Please enter the validity period number (press Enter directly to default to 1):
选择的有效期为::The selected validity period is:
(已复制到剪贴板):(Copied to clipboard)
Expand Down
4 changes: 3 additions & 1 deletion tui/locales/es.ini
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ CURSOR VIP:CURSOR VIP
请输入产品编号(直接回车默认为1,可以同时输入多个例如 145)::Ingrese el número de producto (presione Enter directamente para que sea 1, puede ingresar varios al mismo tiempo, como 145):
输入有误:Error de entrada
选择的产品为::El producto seleccionado es:
选择有效期::Seleccione el período de validez:
选择有效期::'Seleccione el período de validez: '
小时(免费): ' horas (gratis)'
年(购买): ' año (compra)'
请输入有效期编号(直接回车默认为1)::Ingrese el número de período de validez (presione Enter directamente para que sea 1):
选择的有效期为::El período de validez seleccionado es:
(已复制到剪贴板):(Copiado al portapapeles)
Expand Down
4 changes: 3 additions & 1 deletion tui/locales/hu.ini
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ CURSOR VIP:CURSOR VIP
请输入产品编号(直接回车默认为1,可以同时输入多个例如 145)::Kérjük, adja meg a cikkszámot (közvetlenül adja meg az alapértelmezett értékeket 1-re, egyszerre többet is megadhat, például 145):
输入有误:Rossz bemenet
选择的产品为::A kiválasztott termék:
选择有效期::Válassza ki a lejárati időt:
选择有效期::'Válassza ki a lejárati időt: '
小时(免费): ' óra (ingyenes)'
年(购买): ' év (vásárlás)'
请输入有效期编号(直接回车默认为1)::Kérjük, adja meg az érvényességi számot (közvetlenül írja be az alapértelmezett értékeket 1-re):
选择的有效期为::A kiválasztott lejárati idő:
(已复制到剪贴板):(Másolva a vágólapra)
Expand Down
4 changes: 3 additions & 1 deletion tui/locales/nl.ini
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ CURSOR VIP:CURSOR VIP
请输入产品编号(直接回车默认为1,可以同时输入多个例如 145)::Voer het productnummer in (druk op Enter om standaard naar 1 te gaan, u kunt meerdere tegelijk invoeren, zoals 145):
输入有误:Invoerfout
选择的产品为::Het geselecteerde product is:
选择有效期::Selecteer de geldigheidsduur:
选择有效期::'Selecteer de geldigheidsduur: '
小时(免费): ' uur (gratis)'
年(购买): ' jaar (aankoop)'
请输入有效期编号(直接回车默认为1)::Voer het nummer van de geldigheidsduur in (druk op Enter om standaard naar 1 te gaan):
选择的有效期为::De geselecteerde geldigheidsduur is:
(已复制到剪贴板):(Gekopieerd naar klembord)
Expand Down
4 changes: 3 additions & 1 deletion tui/locales/ru.ini
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ CURSOR VIP:CURSOR VIP
请输入产品编号(直接回车默认为1,可以同时输入多个例如 145)::Введите номер продукта (нажмите Enter, чтобы выбрать 1, вы можете ввести несколько одновременно, например 145):
输入有误:Ошибка ввода
选择的产品为::Выбранный продукт:
选择有效期::Выберите срок действия:
选择有效期::'Выберите срок действия: '
小时(免费): ' часа (бесплатно)'
年(购买): ' год (покупка)'
请输入有效期编号(直接回车默认为1)::Введите номер срока действия (нажмите Enter, чтобы выбрать 1):
选择的有效期为::Выбранный срок действия:
(已复制到剪贴板):(Скопировано в буфер обмена)
Expand Down
4 changes: 3 additions & 1 deletion tui/locales/tr.ini
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ CURSOR VIP:VIP İmleci
请输入产品编号(直接回车默认为1,可以同时输入多个例如 145)::Ürün numarasını girin (1'i seçmek için Enter'a basın, aynı anda birden fazla girebilirsiniz, örneğin 145):
输入有误:Hatalı giriş
选择的产品为::Seçilen ürün:
选择有效期::Geçerlilik süresini seçin:
选择有效期::'Geçerlilik süresini seçin: '
小时(免费): ' saat (ücretsiz)'
年(购买): ' yıl (satın al)'
请输入有效期编号(直接回车默认为1)::Geçerlilik süresi numarasını girin (1'i seçmek için Enter'a basın):
选择的有效期为::Seçilen geçerlilik süresi:
(已复制到剪贴板):(Panoya kopyalandı)
Expand Down
53 changes: 46 additions & 7 deletions tui/tui.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@ import (
"sort"
"strconv"
"strings"
"syscall"
"time"

"github.com/unknwon/i18n"
)

var version = 113
var version = 114

var hosts = []string{"https://cursor.jeter.eu.org", "http://129.154.205.7:7193"}
var host = hosts[0]
Expand All @@ -36,6 +37,7 @@ var defaultColor = "%s"
var lang, _ = getLocale()
var deviceID = getMacMD5()
var Cli = Client{Hosts: hosts}
var Sigs chan os.Signal

//go:embed all:locales
var localeFS embed.FS
Expand Down Expand Up @@ -98,7 +100,7 @@ func Run() (productSelected string, modelIndexSelected int) {
checkUpdate(version)
fmt.Println()

if runtime.GOOS != "linux" {
if false {
fmt.Printf(defaultColor, Trr.Tr("选择启动模式:"))
for i, v := range []string{Trr.Tr("极简模式"), Trr.Tr("强劲代理模式")} {
fmt.Printf(hGreen, fmt.Sprintf("%d. %s\t", i+1, v))
Expand Down Expand Up @@ -142,7 +144,29 @@ func Run() (productSelected string, modelIndexSelected int) {
productSelected = jbProduct[0]
}
// 到期了
periodIndex := 1
if expTime.Before(time.Now()) {
fmt.Printf(defaultColor, Trr.Tr("选择有效期:"))
jbPeriod := []string{"1" + Trr.Tr("年(购买)"), "2" + Trr.Tr("小时(免费)")}
for i, v := range jbPeriod {
fmt.Printf(hGreen, fmt.Sprintf("%d. %s\t", i+1, v))
}
fmt.Println()
fmt.Printf("%s", Trr.Tr("请输入有效期编号(直接回车默认为1):"))
_, _ = fmt.Scanln(&periodIndex)
if periodIndex < 1 || periodIndex > len(jbPeriod) {
fmt.Println(Trr.Tr("输入有误"))
return
}
fmt.Println(Trr.Tr("选择的有效期为:") + jbPeriod[periodIndex-1])
fmt.Println()

if periodIndex == 2 {
fmt.Printf(green, Trr.Tr("授权成功!使用过程请不要关闭此窗口"))
countDown(2 * 60 * 60)
return
}

payUrl, orderID := Cli.GetPayUrl()
isCopyText := ""
errClip := clipboard.WriteAll(payUrl)
Expand All @@ -160,16 +184,31 @@ func Run() (productSelected string, modelIndexSelected int) {
fmt.Println(Trr.Tr("未捐赠,请捐赠完成后回车"))
goto checkPay
}
isOk, result := Cli.GetLic()
if !isOk {
fmt.Printf(red, result)
return
}
_, _, _, _, exp = Cli.GetMyInfo(deviceID)
expTime, _ = time.ParseInLocation("2006-01-02 15:04:05", exp, time.Local)
fmt.Println()
}
fmt.Printf(green, Trr.Tr("授权成功!使用过程请不要关闭此窗口"))
countDown(int(expTime.Sub(time.Now()).Seconds()))
return
}
func countDown(seconds int) {
go func(seconds int) {
countdown := seconds // Countdown in seconds
for countdown >= 0 {
days := countdown / (24 * 3600)
hours := (countdown % (24 * 3600)) / 3600
minutes := (countdown % 3600) / 60
seconds := countdown % 60

fmt.Printf("\r%dd %dh %dm %ds", days, hours, minutes, seconds)
time.Sleep(1 * time.Second)
countdown--
}
// 发送退出信号
Sigs <- syscall.SIGTERM
}(seconds)
}

func getMacMD5() string {
// 获取本机的MAC地址
Expand Down

0 comments on commit 2afe836

Please sign in to comment.