mirror of
https://github.com/songquanpeng/one-api.git
synced 2025-11-17 13:43:42 +08:00
fix: copy fails in http environment (#43)
* 🐛 fix: copy fails in http environment * 🎨 optimize: web UI
This commit is contained in:
@@ -161,8 +161,8 @@ const LoginForm = ({ ...others }) => {
|
||||
submit: null
|
||||
}}
|
||||
validationSchema={Yup.object().shape({
|
||||
username: Yup.string().max(255).required('Username is required'),
|
||||
password: Yup.string().max(255).required('Password is required')
|
||||
username: Yup.string().max(255).required('用户名/邮箱是必填项'),
|
||||
password: Yup.string().max(255).required('密码是必填项')
|
||||
})}
|
||||
onSubmit={async (values, { setErrors, setStatus, setSubmitting }) => {
|
||||
const { success, message } = await login(values.username, values.password);
|
||||
|
||||
@@ -296,7 +296,7 @@ const RegisterForm = ({ ...others }) => {
|
||||
<Box sx={{ mt: 2 }}>
|
||||
<AnimateButton>
|
||||
<Button disableElevation disabled={isSubmitting} fullWidth size="large" type="submit" variant="contained" color="primary">
|
||||
Sign up
|
||||
注册
|
||||
</Button>
|
||||
</AnimateButton>
|
||||
</Box>
|
||||
|
||||
@@ -5,7 +5,7 @@ import { useSearchParams } from 'react-router-dom';
|
||||
import { Button, Stack, Typography, Alert } from '@mui/material';
|
||||
|
||||
// assets
|
||||
import { showError, showInfo } from 'utils/common';
|
||||
import { showError, copy } from 'utils/common';
|
||||
import { API } from 'utils/api';
|
||||
|
||||
// ===========================|| FIREBASE - REGISTER ||=========================== //
|
||||
@@ -25,8 +25,7 @@ const ResetPasswordForm = () => {
|
||||
if (success) {
|
||||
let password = res.data.data;
|
||||
setNewPassword(password);
|
||||
navigator.clipboard.writeText(password);
|
||||
showInfo(`新密码已复制到剪贴板:${password}`);
|
||||
copy(password, '新密码');
|
||||
} else {
|
||||
showError(message);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ import PropTypes from 'prop-types';
|
||||
import { Tooltip, Stack, Container } from '@mui/material';
|
||||
import Label from 'ui-component/Label';
|
||||
import { styled } from '@mui/material/styles';
|
||||
import { showSuccess } from 'utils/common';
|
||||
import { copy } from 'utils/common';
|
||||
|
||||
const TooltipContainer = styled(Container)({
|
||||
maxHeight: '250px',
|
||||
@@ -28,8 +28,7 @@ const NameLabel = ({ name, models }) => {
|
||||
variant="ghost"
|
||||
key={index}
|
||||
onClick={() => {
|
||||
navigator.clipboard.writeText(item);
|
||||
showSuccess('复制模型名称成功!');
|
||||
copy(item, '模型名称');
|
||||
}}
|
||||
>
|
||||
{item}
|
||||
|
||||
@@ -2,7 +2,7 @@ import { useState, useEffect } from 'react';
|
||||
import SubCard from 'ui-component/cards/SubCard';
|
||||
// import { gridSpacing } from 'store/constant';
|
||||
import { API } from 'utils/api';
|
||||
import { showError, showSuccess } from 'utils/common';
|
||||
import { showError, copy } from 'utils/common';
|
||||
import { Typography, Accordion, AccordionSummary, AccordionDetails, Box, Stack } from '@mui/material';
|
||||
import ExpandMoreIcon from '@mui/icons-material/ExpandMore';
|
||||
import Label from 'ui-component/Label';
|
||||
@@ -50,8 +50,7 @@ const SupportModels = () => {
|
||||
color="primary"
|
||||
key={model}
|
||||
onClick={() => {
|
||||
navigator.clipboard.writeText(model);
|
||||
showSuccess('复制模型名称成功!');
|
||||
copy(model, '模型名称');
|
||||
}}
|
||||
>
|
||||
{model}
|
||||
|
||||
@@ -19,8 +19,7 @@ import SubCard from 'ui-component/cards/SubCard';
|
||||
import { IconBrandWechat, IconBrandGithub, IconMail } from '@tabler/icons-react';
|
||||
import Label from 'ui-component/Label';
|
||||
import { API } from 'utils/api';
|
||||
import { showError, showSuccess } from 'utils/common';
|
||||
import { onGitHubOAuthClicked } from 'utils/common';
|
||||
import { showError, showSuccess, onGitHubOAuthClicked, copy } from 'utils/common';
|
||||
import * as Yup from 'yup';
|
||||
import WechatModal from 'views/Authentication/AuthForms/WechatModal';
|
||||
import { useSelector } from 'react-redux';
|
||||
@@ -93,8 +92,7 @@ export default function Profile() {
|
||||
const { success, message, data } = res.data;
|
||||
if (success) {
|
||||
setInputs((inputs) => ({ ...inputs, access_token: data }));
|
||||
navigator.clipboard.writeText(data);
|
||||
showSuccess(`令牌已重置并已复制到剪贴板`);
|
||||
copy(data, '令牌');
|
||||
} else {
|
||||
showError(message);
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ import {
|
||||
|
||||
import Label from 'ui-component/Label';
|
||||
import TableSwitch from 'ui-component/Switch';
|
||||
import { timestamp2string, renderQuota, showSuccess } from 'utils/common';
|
||||
import { timestamp2string, renderQuota, copy } from 'utils/common';
|
||||
|
||||
import { IconDotsVertical, IconEdit, IconTrash } from '@tabler/icons-react';
|
||||
|
||||
@@ -83,8 +83,7 @@ export default function RedemptionTableRow({ item, manageRedemption, handleOpenM
|
||||
variant="contained"
|
||||
color="primary"
|
||||
onClick={() => {
|
||||
navigator.clipboard.writeText(item.key);
|
||||
showSuccess('已复制到剪贴板!');
|
||||
copy(item.key, '兑换码');
|
||||
}}
|
||||
>
|
||||
复制
|
||||
|
||||
@@ -20,7 +20,7 @@ import {
|
||||
} from '@mui/material';
|
||||
|
||||
import TableSwitch from 'ui-component/Switch';
|
||||
import { renderQuota, showSuccess, timestamp2string } from 'utils/common';
|
||||
import { renderQuota, timestamp2string, copy } from 'utils/common';
|
||||
|
||||
import { IconDotsVertical, IconEdit, IconTrash, IconCaretDownFilled } from '@tabler/icons-react';
|
||||
|
||||
@@ -141,8 +141,7 @@ export default function TokensTableRow({ item, manageToken, handleOpenModal, set
|
||||
if (type === 'link') {
|
||||
window.open(text);
|
||||
} else {
|
||||
navigator.clipboard.writeText(text);
|
||||
showSuccess('已复制到剪贴板!');
|
||||
copy(text, '链接');
|
||||
}
|
||||
handleCloseMenu();
|
||||
};
|
||||
@@ -211,8 +210,7 @@ export default function TokensTableRow({ item, manageToken, handleOpenModal, set
|
||||
<Button
|
||||
color="primary"
|
||||
onClick={() => {
|
||||
navigator.clipboard.writeText(`sk-${item.key}`);
|
||||
showSuccess('已复制到剪贴板!');
|
||||
copy(`sk-${item.key}`, '令牌');
|
||||
}}
|
||||
>
|
||||
复制
|
||||
|
||||
@@ -4,7 +4,7 @@ import SubCard from 'ui-component/cards/SubCard';
|
||||
import inviteImage from 'assets/images/invite/cwok_casual_19.webp';
|
||||
import { useState } from 'react';
|
||||
import { API } from 'utils/api';
|
||||
import { showError, showSuccess } from 'utils/common';
|
||||
import { showError, copy } from 'utils/common';
|
||||
|
||||
const InviteCard = () => {
|
||||
const theme = useTheme();
|
||||
@@ -12,8 +12,7 @@ const InviteCard = () => {
|
||||
|
||||
const handleInviteUrl = async () => {
|
||||
if (inviteUl) {
|
||||
navigator.clipboard.writeText(inviteUl);
|
||||
showSuccess(`邀请链接已复制到剪切板`);
|
||||
copy(inviteUl, '邀请链接');
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -23,8 +22,7 @@ const InviteCard = () => {
|
||||
if (success) {
|
||||
let link = `${window.location.origin}/register?aff=${data}`;
|
||||
setInviteUrl(link);
|
||||
navigator.clipboard.writeText(link);
|
||||
showSuccess(`邀请链接已复制到剪切板`);
|
||||
copy(link, '邀请链接');
|
||||
} else {
|
||||
showError(message);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user