mirror of
https://github.com/songquanpeng/one-api.git
synced 2026-04-26 19:54:24 +08:00
Compare commits
4 Commits
7b286036fc
...
79b2c5f598
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
79b2c5f598 | ||
|
|
8b8cd03e85 | ||
|
|
a78360efd8 | ||
|
|
8f6b13c2fe |
@@ -12,6 +12,22 @@ const (
|
||||
)
|
||||
|
||||
func Notify(by string, title string, description string, content string) error {
|
||||
|
||||
if by == ByAll {
|
||||
var errMsgs []string
|
||||
if err := SendEmail(title, config.RootUserEmail, content); err != nil {
|
||||
errMsgs = append(errMsgs, fmt.Sprintf("failed to send email: %v", err))
|
||||
}
|
||||
if err := SendMessage(title, description, content); err != nil {
|
||||
errMsgs = append(errMsgs, fmt.Sprintf("failed to send message: %v", err))
|
||||
}
|
||||
|
||||
if len(errMsgs) > 0 {
|
||||
return fmt.Errorf("multiple errors occurred: %v", errMsgs)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
if by == ByEmail {
|
||||
return SendEmail(title, config.RootUserEmail, content)
|
||||
}
|
||||
|
||||
@@ -266,7 +266,7 @@ func testChannels(ctx context.Context, notify bool, scope string) error {
|
||||
if notify {
|
||||
err := message.Notify(message.ByAll, "渠道测试完成", "", "渠道测试完成,如果没有收到禁用通知,说明所有渠道都正常")
|
||||
if err != nil {
|
||||
logger.SysError(fmt.Sprintf("failed to send email: %s", err.Error()))
|
||||
logger.SysError(fmt.Sprintf("failed to send notify: %s", err.Error()))
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
||||
@@ -1,17 +1,7 @@
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import {
|
||||
Button,
|
||||
Dropdown,
|
||||
Form,
|
||||
Input,
|
||||
Label,
|
||||
Message,
|
||||
Pagination,
|
||||
Popup,
|
||||
Table,
|
||||
} from 'semantic-ui-react';
|
||||
import { Link } from 'react-router-dom';
|
||||
import React, {useEffect, useState} from 'react';
|
||||
import {useTranslation} from 'react-i18next';
|
||||
import {Button, Dropdown, Form, Input, Label, Message, Pagination, Popup, Table,} from 'semantic-ui-react';
|
||||
import {Link} from 'react-router-dom';
|
||||
import {
|
||||
API,
|
||||
loadChannelModels,
|
||||
@@ -23,8 +13,8 @@ import {
|
||||
timestamp2string,
|
||||
} from '../helpers';
|
||||
|
||||
import { CHANNEL_OPTIONS, ITEMS_PER_PAGE } from '../constants';
|
||||
import { renderGroup, renderNumber } from '../helpers/render';
|
||||
import {CHANNEL_OPTIONS, ITEMS_PER_PAGE} from '../constants';
|
||||
import {renderGroup, renderNumber} from '../helpers/render';
|
||||
|
||||
function renderTimestamp(timestamp) {
|
||||
return <>{timestamp2string(timestamp)}</>;
|
||||
@@ -54,6 +44,9 @@ function renderType(type, t) {
|
||||
function renderBalance(type, balance, t) {
|
||||
switch (type) {
|
||||
case 1: // OpenAI
|
||||
if (balance === 0) {
|
||||
return <span>{t('channel.table.balance_not_supported')}</span>;
|
||||
}
|
||||
return <span>${balance.toFixed(2)}</span>;
|
||||
case 4: // CloseAI
|
||||
return <span>¥{balance.toFixed(2)}</span>;
|
||||
|
||||
Reference in New Issue
Block a user