feat: add query-login

This commit is contained in:
2025-03-22 00:52:58 +08:00
parent 3d45a83129
commit 4b16ec8499
17 changed files with 530 additions and 650 deletions

View File

@@ -3,13 +3,12 @@ import glob from 'fast-glob';
import path from 'path';
import fs from 'fs';
import FormData from 'form-data';
import { getBaseURL, query } from '@/module/query.ts';
import { getBaseURL, query, storage } from '@/module/query.ts';
import { getConfig } from '@/module/index.ts';
import inquirer from 'inquirer';
import { packLib, unpackLib } from './publish.ts';
import chalk from 'chalk';
import { installDeps } from '@/uitls/npm.ts';
const command = new Command('deploy')
.description('把前端文件传到服务器')
.argument('<filePath>', 'Path to the file to be uploaded, filepath or directory') // 定义文件路径参数
@@ -123,10 +122,11 @@ const uploadFiles = async (
if (username) {
form.append('username', username);
}
return new Promise((resolve) => {
return new Promise(async (resolve) => {
const _baseURL = getBaseURL();
const url = new URL(_baseURL);
console.log('upload url', url.hostname, url.protocol, url.port);
const token = await storage.getItem('token');
form.submit(
{
path: '/api/app/upload',
@@ -135,7 +135,7 @@ const uploadFiles = async (
port: url.port,
method: 'POST',
headers: {
Authorization: 'Bearer ' + config.token,
Authorization: 'Bearer ' + token,
...form.getHeaders(),
},
},