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