mirror of
https://github.com/coaidev/coai.git
synced 2025-05-19 13:00:14 +09:00
feat: update ui
This commit is contained in:
parent
74fbb7d005
commit
849c833c6f
@ -8,7 +8,7 @@
|
||||
},
|
||||
"package": {
|
||||
"productName": "chatnio",
|
||||
"version": "3.7.3"
|
||||
"version": "3.7.4"
|
||||
},
|
||||
"tauri": {
|
||||
"allowlist": {
|
||||
|
@ -10,8 +10,8 @@
|
||||
--foreground: 240 10% 3.9%;
|
||||
|
||||
--card: 0 0% 100%;
|
||||
--card-hover: 0 0% 97.5%;
|
||||
--card-active: 0 0% 95%;
|
||||
--card-hover: 0 0% 97%;
|
||||
--card-active: 0 0% 94.5%;
|
||||
--card-foreground: 240 10% 3.9%;
|
||||
|
||||
--popover: 0 0% 100%;
|
||||
@ -68,8 +68,8 @@
|
||||
--foreground: 210 40% 98%;
|
||||
|
||||
--card: 240 10% 3.9%;
|
||||
--card-hover: 240 10% 8.9%;
|
||||
--card-active: 240 10% 13.9%;
|
||||
--card-hover: 240 11% 12.5%;
|
||||
--card-active: 240 9.5% 19%;
|
||||
--card-foreground: 0 0% 98%;
|
||||
|
||||
--popover: 240 10% 3.9%;
|
||||
|
@ -413,7 +413,7 @@
|
||||
}
|
||||
|
||||
&.active {
|
||||
background: hsl(var(--card-hover));
|
||||
background: hsl(var(--card-active));
|
||||
border-color: hsl(var(--border-active));
|
||||
}
|
||||
}
|
||||
|
@ -16,6 +16,7 @@ import ModeToggle from "@/components/ThemeProvider.tsx";
|
||||
import router from "@/router.tsx";
|
||||
import MenuBar from "./MenuBar.tsx";
|
||||
import { getMemory } from "@/utils/memory.ts";
|
||||
import { deeptrainApiEndpoint } from "@/utils/env.ts";
|
||||
|
||||
function NavMenu() {
|
||||
const username = useSelector(selectUsername);
|
||||
@ -24,7 +25,7 @@ function NavMenu() {
|
||||
<div className={`avatar`}>
|
||||
<MenuBar>
|
||||
<Button variant={`ghost`} size={`icon`}>
|
||||
<img src={`https://api.deeptrain.net/avatar/${username}`} alt="" />
|
||||
<img src={`${deeptrainApiEndpoint}/avatar/${username}`} alt="" />
|
||||
</Button>
|
||||
</MenuBar>
|
||||
</div>
|
||||
|
@ -42,6 +42,7 @@ import { Input } from "@/components/ui/input.tsx";
|
||||
import { login } from "@/conf.ts";
|
||||
import MenuBar from "@/components/app/MenuBar.tsx";
|
||||
import { Separator } from "@/components/ui/separator.tsx";
|
||||
import { deeptrainApiEndpoint } from "@/utils/env.ts";
|
||||
|
||||
type Operation = {
|
||||
target: ConversationInstance | null;
|
||||
@ -329,7 +330,7 @@ function SidebarMenu() {
|
||||
<Separator orientation={`horizontal`} className={`mb-2`} />
|
||||
<MenuBar className={`menu-bar`}>
|
||||
<Button variant={`ghost`} className={`sidebar-wrapper`}>
|
||||
<img src={`https://api.deeptrain.net/avatar/${username}`} alt="" />
|
||||
<img src={`${deeptrainApiEndpoint}/avatar/${username}`} alt="" />
|
||||
<span className={`username`}>{username}</span>
|
||||
<MoreHorizontal className={`h-4 w-4`} />
|
||||
</Button>
|
||||
|
@ -25,6 +25,7 @@ import { expiredSelector, refreshSubscription } from "@/store/subscription.ts";
|
||||
import { Plus } from "lucide-react";
|
||||
import { subscriptionPrize } from "@/conf.ts";
|
||||
import { ToastAction } from "@/components/ui/toast.tsx";
|
||||
import { deeptrainEndpoint } from "@/utils/env.ts";
|
||||
|
||||
function countPrize(base: number, month: number): number {
|
||||
const prize = subscriptionPrize[base] * month;
|
||||
@ -74,14 +75,14 @@ async function callBuyAction(
|
||||
action: (
|
||||
<ToastAction
|
||||
altText={t("buy.go")}
|
||||
onClick={() => (location.href = "https://deeptrain.net/home/wallet")}
|
||||
onClick={() => (location.href = `${deeptrainEndpoint}/home/wallet`)}
|
||||
>
|
||||
{t("buy.go")}
|
||||
</ToastAction>
|
||||
),
|
||||
});
|
||||
setTimeout(() => {
|
||||
window.open("https://deeptrain.net/home/wallet");
|
||||
window.open(`${deeptrainEndpoint}/home/wallet`);
|
||||
}, 2000);
|
||||
}
|
||||
return res.status;
|
||||
|
@ -1,6 +1,8 @@
|
||||
import axios from "axios";
|
||||
import { Model, PlanModel } from "@/api/types.ts";
|
||||
import {
|
||||
deeptrainAppName,
|
||||
deeptrainEndpoint,
|
||||
getDev,
|
||||
getRestApi,
|
||||
getTokenField,
|
||||
@ -8,7 +10,7 @@ import {
|
||||
} from "@/utils/env.ts";
|
||||
import { getMemory } from "@/utils/memory.ts";
|
||||
|
||||
export const version = "3.7.3";
|
||||
export const version = "3.7.4";
|
||||
export const dev: boolean = getDev();
|
||||
export const deploy: boolean = true;
|
||||
export let rest_api: string = getRestApi(deploy);
|
||||
@ -417,7 +419,9 @@ export const subscriptionPrize: Record<number, number> = {
|
||||
};
|
||||
|
||||
export function login() {
|
||||
location.href = `https://deeptrain.net/login?app=${dev ? "dev" : "chatnio"}`;
|
||||
location.href = `${deeptrainEndpoint}/login?app=${
|
||||
dev ? "dev" : deeptrainAppName
|
||||
}`;
|
||||
}
|
||||
|
||||
axios.defaults.baseURL = rest_api;
|
||||
|
@ -23,6 +23,7 @@ import { Separator } from "@/components/ui/separator.tsx";
|
||||
import { Badge } from "@/components/ui/badge.tsx";
|
||||
import { useEffectAsync } from "@/utils/hook.ts";
|
||||
import { selectAuthenticated } from "@/store/auth.ts";
|
||||
import { deeptrainEndpoint } from "@/utils/env.ts";
|
||||
|
||||
function PackageDialog() {
|
||||
const { t } = useTranslation();
|
||||
@ -77,7 +78,7 @@ function PackageDialog() {
|
||||
</Button>
|
||||
<Button
|
||||
variant={`default`}
|
||||
onClick={() => window.open("https://deeptrain.net/home/package")}
|
||||
onClick={() => window.open(`${deeptrainEndpoint}/home/package`)}
|
||||
>
|
||||
{t("pkg.go")}
|
||||
</Button>
|
||||
|
@ -39,7 +39,7 @@ import { useToast } from "@/components/ui/use-toast.ts";
|
||||
import { useEffectAsync } from "@/utils/hook.ts";
|
||||
import { selectAuthenticated } from "@/store/auth.ts";
|
||||
import { ToastAction } from "@/components/ui/toast.tsx";
|
||||
import { docsEndpoint } from "@/utils/env.ts";
|
||||
import { deeptrainEndpoint, docsEndpoint } from "@/utils/env.ts";
|
||||
|
||||
type AmountComponentProps = {
|
||||
amount: number;
|
||||
@ -245,8 +245,7 @@ function QuotaDialog() {
|
||||
<ToastAction
|
||||
altText={t("buy.go")}
|
||||
onClick={() =>
|
||||
(location.href =
|
||||
"https://deeptrain.net/home/wallet")
|
||||
(location.href = `${deeptrainEndpoint}/home/wallet`)
|
||||
}
|
||||
>
|
||||
{t("buy.go")}
|
||||
@ -255,7 +254,7 @@ function QuotaDialog() {
|
||||
});
|
||||
setTimeout(() => {
|
||||
window.open(
|
||||
"https://deeptrain.net/home/wallet",
|
||||
`${deeptrainEndpoint}/home/wallet`,
|
||||
);
|
||||
}, 2000);
|
||||
}
|
||||
|
@ -12,6 +12,7 @@ import router from "@/router.tsx";
|
||||
import { useToast } from "@/components/ui/use-toast.ts";
|
||||
import { sharingEvent } from "@/events/sharing.ts";
|
||||
import { Message } from "@/api/types.ts";
|
||||
import { deeptrainApiEndpoint } from "@/utils/env.ts";
|
||||
|
||||
type SharingFormProps = {
|
||||
refer?: string;
|
||||
@ -32,10 +33,7 @@ function SharingForm({ refer, data }: SharingFormProps) {
|
||||
<div className={`sharing-container`}>
|
||||
<div className={`header`}>
|
||||
<div className={`user`}>
|
||||
<img
|
||||
src={`https://api.deeptrain.net/avatar/${data.username}`}
|
||||
alt=""
|
||||
/>
|
||||
<img src={`${deeptrainApiEndpoint}/avatar/${data.username}`} alt="" />
|
||||
<span>{data.username}</span>
|
||||
</div>
|
||||
<div className={`name`}>{data.name}</div>
|
||||
|
@ -4,6 +4,11 @@ export const blobEndpoint =
|
||||
import.meta.env.VITE_BLOB_ENDPOINT || "https://blob.chatnio.net";
|
||||
export const docsEndpoint =
|
||||
import.meta.env.VITE_DOCS_ENDPOINT || "https://docs.chatnio.net";
|
||||
export const deeptrainEndpoint =
|
||||
import.meta.env.VITE_DEEPTRAIN_ENDPOINT || "https://deeptrain.net";
|
||||
export const deeptrainAppName = import.meta.env.VITE_DEEPTRAIN_APP || "chatnio";
|
||||
export const deeptrainApiEndpoint =
|
||||
import.meta.env.VITE_DEEPTRAIN_API_ENDPOINT || "https://api.deeptrain.net";
|
||||
|
||||
export function getDev(): boolean {
|
||||
/**
|
||||
|
@ -12,8 +12,12 @@ type ValidateUserResponse struct {
|
||||
ID int `json:"id" required:"true"`
|
||||
}
|
||||
|
||||
func getDeeptrainApi(path string) string {
|
||||
return viper.GetString("auth.endpoint") + path
|
||||
}
|
||||
|
||||
func Validate(token string) *ValidateUserResponse {
|
||||
res, err := utils.Post("https://api.deeptrain.net/app/validate", map[string]string{
|
||||
res, err := utils.Post(getDeeptrainApi("/app/validate"), map[string]string{
|
||||
"Content-Type": "application/json",
|
||||
}, map[string]interface{}{
|
||||
"password": viper.GetString("auth.access"),
|
||||
|
@ -13,7 +13,7 @@ type CertResponse struct {
|
||||
}
|
||||
|
||||
func Cert(username string) *CertResponse {
|
||||
res, err := utils.Post("https://api.deeptrain.net/app/cert", map[string]string{
|
||||
res, err := utils.Post(getDeeptrainApi("/app/cert"), map[string]string{
|
||||
"Content-Type": "application/json",
|
||||
}, map[string]interface{}{
|
||||
"password": viper.GetString("auth.access"),
|
||||
|
@ -25,7 +25,7 @@ func GenerateOrder() string {
|
||||
|
||||
func GetBalance(username string) float32 {
|
||||
order := GenerateOrder()
|
||||
res, err := utils.Post("https://api.deeptrain.net/app/balance", map[string]string{
|
||||
res, err := utils.Post(getDeeptrainApi("/app/balance"), map[string]string{
|
||||
"Content-Type": "application/json",
|
||||
}, map[string]interface{}{
|
||||
"password": viper.GetString("auth.access"),
|
||||
@ -46,7 +46,7 @@ func GetBalance(username string) float32 {
|
||||
|
||||
func Pay(username string, amount float32) bool {
|
||||
order := GenerateOrder()
|
||||
res, err := utils.Post("https://api.deeptrain.net/app/payment", map[string]string{
|
||||
res, err := utils.Post(getDeeptrainApi("/app/payment"), map[string]string{
|
||||
"Content-Type": "application/json",
|
||||
}, map[string]interface{}{
|
||||
"password": viper.GetString("auth.access"),
|
||||
|
@ -2,6 +2,7 @@ package utils
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/go-redis/redis/v8"
|
||||
"time"
|
||||
@ -47,7 +48,7 @@ func GetJson[T any](cache *redis.Client, key string) *T {
|
||||
func IncrWithLimit(cache *redis.Client, key string, delta int64, limit int64, expiration int64) bool {
|
||||
// not exist
|
||||
if _, err := cache.Get(context.Background(), key).Result(); err != nil {
|
||||
if err == redis.Nil {
|
||||
if errors.Is(err, redis.Nil) {
|
||||
cache.Set(context.Background(), key, delta, time.Duration(expiration)*time.Second)
|
||||
return true
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user