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