fix
This commit is contained in:
@@ -6,6 +6,7 @@ import { Result } from '@kevisual/query';
|
||||
import { fileIsExist } from '@/uitls/file.ts';
|
||||
import { glob } from 'fast-glob';
|
||||
import inquirer from 'inquirer';
|
||||
import { getEnvToken } from '../get-config.ts';
|
||||
|
||||
type DownloadTask = {
|
||||
downloadPath: string;
|
||||
@@ -38,7 +39,7 @@ type Options = {
|
||||
[key: string]: any;
|
||||
};
|
||||
export const fetchLink = async (url: string = '', opts?: Options) => {
|
||||
const token = process.env.KEVISUAL_TOKEN || storage.getItem('token');
|
||||
const token = storage.getItem('token') || getEnvToken();
|
||||
const fetchURL = new URL(url);
|
||||
const check = opts?.check ?? false;
|
||||
const isKevisual = !!url.includes('kevisual');
|
||||
@@ -272,8 +273,14 @@ export type AiList = {
|
||||
pathname?: string;
|
||||
url?: string;
|
||||
};
|
||||
/**
|
||||
* AI路径的资源下载地址
|
||||
* @param url
|
||||
* @param opts
|
||||
* @returns
|
||||
*/
|
||||
export const fetchAiList = async (url: string, opts?: { recursive: boolean }): Promise<Result<AiList[]>> => {
|
||||
const token = process.env.KEVISUAL_TOKEN || storage.getItem('token');
|
||||
const token = storage.getItem('token') || getEnvToken();
|
||||
const _url = new URL(url);
|
||||
const dir = _url.searchParams.get('dir');
|
||||
if (!dir) {
|
||||
|
||||
@@ -35,3 +35,7 @@ export const writeConfig = (config: Record<string, any>) => {
|
||||
fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
|
||||
return config;
|
||||
};
|
||||
|
||||
export const getEnvToken = () => {
|
||||
return process.env.KEVISUAL_TOKEN || '';
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Query } from '@kevisual/query/query';
|
||||
import { getConfig } from './get-config.ts';
|
||||
import { getConfig, getEnvToken } from './get-config.ts';
|
||||
import { QueryLoginNode, storage } from '@kevisual/query-login/node';
|
||||
const config = getConfig();
|
||||
export const baseURL = config?.baseURL || 'https://kevisual.cn';
|
||||
@@ -14,7 +14,7 @@ export const getHeader = async () => {
|
||||
const headers: Record<string, string> = {
|
||||
'Content-Type': 'application/json',
|
||||
};
|
||||
let token = process.env.KEVISUAL_TOKEN;
|
||||
let token = getEnvToken();
|
||||
if (!token) {
|
||||
token = await storage.getItem('token');
|
||||
}
|
||||
@@ -26,7 +26,7 @@ export const getHeader = async () => {
|
||||
|
||||
query.beforeRequest = async (config) => {
|
||||
if (config.headers) {
|
||||
let token = process.env.KEVISUAL_TOKEN;
|
||||
let token = getEnvToken();
|
||||
if (!token) {
|
||||
token = await storage.getItem('token');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user