mirror of
https://github.com/coaidev/coai.git
synced 2025-05-23 15:00:14 +09:00
update apikey and service
This commit is contained in:
parent
bc4c5ea88c
commit
98a40fbe66
@ -32,7 +32,7 @@ export const supportModelConvertor: Record<string, string> = {
|
||||
"Claude-2": "claude-1",
|
||||
"Claude-2-100k": "claude-2", // not claude-2-100k
|
||||
"SparkDesk 讯飞星火": "spark-desk",
|
||||
"Palm2": "chat-bison-001",
|
||||
Palm2: "chat-bison-001",
|
||||
};
|
||||
|
||||
export function login() {
|
||||
@ -41,5 +41,3 @@ export function login() {
|
||||
|
||||
axios.defaults.baseURL = rest_api;
|
||||
axios.defaults.headers.post["Content-Type"] = "application/json";
|
||||
|
||||
console.debug(`chatnio application (version: ${version})`);
|
||||
|
@ -15,11 +15,13 @@ import {
|
||||
dialogSelector,
|
||||
setDialog,
|
||||
keySelector,
|
||||
getApiKey,
|
||||
} from "../store/api.ts";
|
||||
import { Input } from "../components/ui/input.tsx";
|
||||
import { Copy, ExternalLink } from "lucide-react";
|
||||
import { useToast } from "../components/ui/use-toast.ts";
|
||||
import {copyClipboard} from "../utils.ts";
|
||||
import { copyClipboard, useEffectAsync } from "../utils.ts";
|
||||
import { selectInit } from "../store/auth.ts";
|
||||
|
||||
function Package() {
|
||||
const { t } = useTranslation();
|
||||
@ -27,6 +29,11 @@ function Package() {
|
||||
const open = useSelector(dialogSelector);
|
||||
const key = useSelector(keySelector);
|
||||
const { toast } = useToast();
|
||||
const init = useSelector(selectInit);
|
||||
|
||||
useEffectAsync(async () => {
|
||||
if (init) await getApiKey(dispatch);
|
||||
}, [init]);
|
||||
|
||||
async function copyKey() {
|
||||
await copyClipboard(key);
|
||||
|
@ -1,18 +1,23 @@
|
||||
// @ts-ignore
|
||||
import { registerSW } from "virtual:pwa-register";
|
||||
import { version } from "./conf.ts";
|
||||
|
||||
export const updateSW = registerSW({
|
||||
onRegisteredSW(url: string, registration: ServiceWorkerRegistration) {
|
||||
if (!(!registration.installing && navigator)) return;
|
||||
if ("connection" in navigator && !navigator.onLine) return;
|
||||
|
||||
console.debug(
|
||||
"[service] checking for update (current version: %s)",
|
||||
version,
|
||||
);
|
||||
fetch(url, {
|
||||
headers: { "Service-Worker": "script", "Cache-Control": "no-cache" },
|
||||
cache: "no-store",
|
||||
}).then(async (resp) => {
|
||||
if (resp?.status === 200) {
|
||||
await registration.update();
|
||||
if (registration.onupdatefound) console.debug("update found");
|
||||
if (registration.onupdatefound) console.debug("[service] update found");
|
||||
}
|
||||
});
|
||||
},
|
||||
|
@ -34,7 +34,7 @@ export default apiSlice.reducer;
|
||||
export const dialogSelector = (state: any): boolean => state.api.dialog;
|
||||
export const keySelector = (state: any): string => state.api.key;
|
||||
|
||||
export const getPackage = async (dispatch: AppDispatch) => {
|
||||
export const getApiKey = async (dispatch: AppDispatch) => {
|
||||
const response = await getKey();
|
||||
if (response.status) dispatch(setKey(response.key));
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user