wip-request改用 luch-request

(https://ext.dcloud.net.cn/plugin?id=392)
This commit is contained in:
Huang 2022-06-08 17:57:08 +08:00
parent 9d35fec10a
commit 9975bd9a22
26 changed files with 372 additions and 282 deletions

View File

@ -3,7 +3,14 @@ VITE_PROD = false
VITE_DEV = true
# BASE_URL
VITE_BASE_URL = http://api-catch.ranesuangyu.top
VITE_BASE_URL = /api
# PROXY_BASE_URL
# 仅H5跨域需使用proxy,其他端请直接设置 VITE_BASE_URL 即可
VITE_PROXY_BASE_URL = http://api-catch.ranesuangyu.top
# 上传域名
VITE_UPLOAD_URL = 'YOUR UPLOAD URL'
VITE_UPLOAD_URL = /upload
# 代理上传域名
VITE_PROXY_UPLOAD_URL = 'YOUR UPLOAD URL'

1
src/env.d.ts vendored
View File

@ -11,6 +11,7 @@ interface ImportMetaEnv {
readonly VITE_ENV: string;
readonly VITE_APP_TITLE: string;
readonly VITE_BASE_URL: string;
readonly VITE_PROXY_BASE_URL: string;
readonly VITE_UPLOAD_URL: string;
readonly VITE_PROD: boolean;
readonly VITE_DEV: boolean;

View File

@ -1,2 +0,0 @@
import Request from './core/Request';
export default Request;

View File

@ -1,72 +1,80 @@
{
"name": "",
"appid": "",
"description": "",
"versionName": "1.0.0",
"versionCode": "100",
"transformPx": false,
/* 5+App */
"app-plus": {
"usingComponents": true,
"nvueStyleCompiler": "uni-app",
"compilerVersion": 3,
"splashscreen": {
"alwaysShowBeforeRender": true,
"waiting": true,
"autoclose": true,
"delay": 0
"name" : "",
"appid" : "",
"description" : "",
"versionName" : "1.0.0",
"versionCode" : "100",
"transformPx" : false,
/* 5+App */
"app-plus" : {
"usingComponents" : true,
"nvueStyleCompiler" : "uni-app",
"compilerVersion" : 3,
"splashscreen" : {
"alwaysShowBeforeRender" : true,
"waiting" : true,
"autoclose" : true,
"delay" : 0
},
/* */
"modules" : {},
/* */
"distribute" : {
/* android */
"android" : {
"permissions" : [
"<uses-permission android:name=\"android.permission.CHANGE_NETWORK_STATE\"/>",
"<uses-permission android:name=\"android.permission.MOUNT_UNMOUNT_FILESYSTEMS\"/>",
"<uses-permission android:name=\"android.permission.VIBRATE\"/>",
"<uses-permission android:name=\"android.permission.READ_LOGS\"/>",
"<uses-permission android:name=\"android.permission.ACCESS_WIFI_STATE\"/>",
"<uses-feature android:name=\"android.hardware.camera.autofocus\"/>",
"<uses-permission android:name=\"android.permission.ACCESS_NETWORK_STATE\"/>",
"<uses-permission android:name=\"android.permission.CAMERA\"/>",
"<uses-permission android:name=\"android.permission.GET_ACCOUNTS\"/>",
"<uses-permission android:name=\"android.permission.READ_PHONE_STATE\"/>",
"<uses-permission android:name=\"android.permission.CHANGE_WIFI_STATE\"/>",
"<uses-permission android:name=\"android.permission.WAKE_LOCK\"/>",
"<uses-permission android:name=\"android.permission.FLASHLIGHT\"/>",
"<uses-feature android:name=\"android.hardware.camera\"/>",
"<uses-permission android:name=\"android.permission.WRITE_SETTINGS\"/>"
]
},
/* ios */
"ios" : {},
/* SDK */
"sdkConfigs" : {}
}
},
/* */
"modules": {},
/* */
"distribute": {
/* android */
"android": {
"permissions": [
"<uses-permission android:name=\"android.permission.CHANGE_NETWORK_STATE\"/>",
"<uses-permission android:name=\"android.permission.MOUNT_UNMOUNT_FILESYSTEMS\"/>",
"<uses-permission android:name=\"android.permission.VIBRATE\"/>",
"<uses-permission android:name=\"android.permission.READ_LOGS\"/>",
"<uses-permission android:name=\"android.permission.ACCESS_WIFI_STATE\"/>",
"<uses-feature android:name=\"android.hardware.camera.autofocus\"/>",
"<uses-permission android:name=\"android.permission.ACCESS_NETWORK_STATE\"/>",
"<uses-permission android:name=\"android.permission.CAMERA\"/>",
"<uses-permission android:name=\"android.permission.GET_ACCOUNTS\"/>",
"<uses-permission android:name=\"android.permission.READ_PHONE_STATE\"/>",
"<uses-permission android:name=\"android.permission.CHANGE_WIFI_STATE\"/>",
"<uses-permission android:name=\"android.permission.WAKE_LOCK\"/>",
"<uses-permission android:name=\"android.permission.FLASHLIGHT\"/>",
"<uses-feature android:name=\"android.hardware.camera\"/>",
"<uses-permission android:name=\"android.permission.WRITE_SETTINGS\"/>"
]
},
/* ios */
"ios": {},
/* SDK */
"sdkConfigs": {}
/* */
"quickapp" : {},
/* */
"mp-weixin" : {
"appid" : "",
"setting" : {
"urlCheck" : false
},
"usingComponents" : true
},
"mp-alipay" : {
"usingComponents" : true
},
"mp-baidu" : {
"usingComponents" : true
},
"mp-toutiao" : {
"usingComponents" : true
},
"uniStatistics" : {
"enable" : false
},
"vueVersion" : "3",
"h5" : {
"router" : {
"mode" : "history"
},
"devServer" : {
"https" : false
}
}
},
/* */
"quickapp": {},
/* */
"mp-weixin": {
"appid": "",
"setting": {
"urlCheck": false
},
"usingComponents": true
},
"mp-alipay": {
"usingComponents": true
},
"mp-baidu": {
"usingComponents": true
},
"mp-toutiao": {
"usingComponents": true
},
"uniStatistics": {
"enable": false
},
"vueVersion": "3"
}

View File

@ -17,18 +17,15 @@
<script setup lang="ts">
import { reactive, ref } from 'vue';
import { request } from '@/utils/http/index';
import { defHttp } from '@/utils/http/index';
const form = reactive({
email: 'catch@admin.com',
password: 'catchadmin',
});
const loginType = ref('');
const submit = () => {
request
.post({
url: '/login',
data: form,
})
defHttp
.post('/login', form)
.then((res: any) => {
loginType.value = '登录成功';
console.log(res.message);

View File

@ -98,13 +98,16 @@ export interface HttpInterceptorManager<V, E = V> {
): void;
eject(id: number): void;
}
export interface Interceptors {
request: HttpInterceptorManager<HttpRequestConfig, HttpRequestConfig>;
response: HttpInterceptorManager<HttpResponse, HttpError>;
}
export abstract class HttpRequestAbstract {
constructor(config?: HttpRequestConfig);
constructor(config?: Partial<HttpRequestConfig>);
config: HttpRequestConfig;
interceptors: {
request: HttpInterceptorManager<HttpRequestConfig, HttpRequestConfig>;
response: HttpInterceptorManager<HttpResponse, HttpError>;
};
interceptors: Interceptors;
middleware<T = any>(config: HttpRequestConfig): HttpPromise<T>;
request<T = any>(config: HttpRequestConfig<UniApp.RequestTask>): HttpPromise<T>;
get<T = any>(url: string, config?: HttpRequestConfig<UniApp.RequestTask>): HttpPromise<T>;

View File

@ -2,6 +2,7 @@ import buildURL from '../helpers/buildURL';
import buildFullPath from '../core/buildFullPath';
import settle from '../core/settle';
import { isUndefined } from '../utils';
import { HttpRequestConfig } from '@/types/http';
/**
*
@ -18,10 +19,10 @@ const mergeKeys = (keys, config2) => {
});
return config;
};
export default (config) => {
export default (config: HttpRequestConfig) => {
return new Promise((resolve, reject) => {
let fullPath = buildURL(buildFullPath(config.baseURL, config.url), config.params);
const _config = {
let fullPath = buildURL(buildFullPath(config.baseURL, config.url || ''), config.params);
const _config: UniApp.RequestOptions = {
url: fullPath,
header: config.header,
complete: (response) => {

View File

@ -1,6 +1,9 @@
'use strict';
function InterceptorManager() {
export class InterceptorManager1 {}
function InterceptorManager(): void {
// @ts-ignore
this.handlers = [];
}
@ -12,7 +15,7 @@ function InterceptorManager() {
*
* @return {Number} An ID used to remove interceptor later
*/
InterceptorManager.prototype.use = function use(fulfilled, rejected) {
InterceptorManager.prototype.use = function use(fulfilled: any, rejected: any) {
this.handlers.push({
fulfilled: fulfilled,
rejected: rejected,

View File

@ -15,10 +15,14 @@ import dispatchRequest from './dispatchRequest';
import InterceptorManager from './InterceptorManager';
import mergeConfig from './mergeConfig';
import defaults from './defaults';
import { cloneDeep } from 'lodash-es';
import { isPlainObject } from '../utils';
import clone from '../utils/clone';
import { HttpRequestConfig, Interceptors } from '@/types/http';
export default class Request {
private readonly config: HttpRequestConfig | undefined;
private readonly interceptors: Interceptors;
/**
* @param {Object} arg -
* @param {String} arg.baseURL -
@ -33,12 +37,12 @@ export default class Request {
* @param {Boolean} arg.firstIpv4 - DNS解析时优先使用ipv4false App-Android (HBuilderX 2.8.0+)
* @param {Function(statusCode):Boolean} arg.validateStatus - statusCode >= 200 && statusCode < 300
*/
constructor(arg = {}) {
constructor(arg?: Partial<HttpRequestConfig>) {
if (!isPlainObject(arg)) {
arg = {};
console.warn('设置全局参数必须接收一个Object');
}
this.config = clone({ ...defaults, ...arg });
this.config = cloneDeep({ ...defaults, ...arg });
this.interceptors = {
request: new InterceptorManager(),
response: new InterceptorManager(),
@ -49,7 +53,7 @@ export default class Request {
* @Function
* @param {Request~setConfigCallback} f -
*/
setConfig(f) {
setConfig(f: (_config: HttpRequestConfig) => HttpRequestConfig) {
this.config = f(this.config);
}

View File

@ -12,7 +12,7 @@ import combineURLs from '../helpers/combineURLs';
* @param {string} requestedURL Absolute or relative URL to combine
* @returns {string} The combined full path
*/
export default function buildFullPath(baseURL, requestedURL) {
export default function buildFullPath(baseURL: string | undefined, requestedURL: string): string {
if (baseURL && !isAbsoluteURL(requestedURL)) {
return combineURLs(baseURL, requestedURL);
}

View File

@ -1,3 +1,5 @@
import { HttpRequestConfig } from '@/utils/types/http';
/**
*
*/
@ -23,7 +25,7 @@ export default {
// #ifdef APP-PLUS
firstIpv4: false,
// #endif
validateStatus: function validateStatus(status) {
validateStatus: function validateStatus(status: Number) {
return status >= 200 && status < 300;
},
};
} as HttpRequestConfig;

View File

@ -1,4 +1,4 @@
import adapter from '../adapters/index';
import adapter from '../adapters';
export default (config) => {
return adapter(config);

View File

@ -1,6 +1,6 @@
'use strict';
import * as utils from './../utils';
import * as utils from '../utils';
function encode(val) {
return encodeURIComponent(val)
@ -20,19 +20,18 @@ function encode(val) {
* @param {object} [params] The params to be appended
* @returns {string} The formatted url
*/
export default function buildURL(url, params) {
/*eslint no-param-reassign:0*/
export default function buildURL(url: string, params?: any) {
if (!params) {
return url;
}
var serializedParams;
let serializedParams;
if (utils.isURLSearchParams(params)) {
serializedParams = params.toString();
} else {
var parts = [];
const parts: string[] = [];
utils.forEach(params, function serialize(val, key) {
utils.forEach(params, function serialize(val: string, key: string) {
if (val === null || typeof val === 'undefined') {
return;
}
@ -57,7 +56,7 @@ export default function buildURL(url, params) {
}
if (serializedParams) {
var hashmarkIndex = url.indexOf('#');
const hashmarkIndex = url.indexOf('#');
if (hashmarkIndex !== -1) {
url = url.slice(0, hashmarkIndex);
}

View File

@ -7,7 +7,7 @@
* @param {string} relativeURL The relative URL
* @returns {string} The combined URL
*/
export default function combineURLs(baseURL, relativeURL) {
export default function combineURLs(baseURL: string, relativeURL: string): string {
return relativeURL
? baseURL.replace(/\/+$/, '') + '/' + relativeURL.replace(/^\/+/, '')
: baseURL;

View File

@ -6,7 +6,7 @@
* @param {string} url The URL to test
* @returns {boolean} True if the specified URL is absolute, otherwise false
*/
export default function isAbsoluteURL(url) {
export default function isAbsoluteURL(url: string): boolean {
// A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
// RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
// by any combination of letters, digits, plus, period, or hyphen.

View File

@ -1,26 +1,75 @@
import { HttpRequest } from '@/utils/http/request';
import Request from './core/Request';
import { assign } from 'lodash-es';
import { Request, RequestOptions } from '@/utils/types/request';
const BASE_URL = import.meta.env.VITE_BASE_URL;
function invoke(args: Request.Params & Partial<RequestOptions>) {
args = assign(args, {
dataType: 'json',
responseType: 'text',
header: {
'Content-Type': 'application/json;charset=UTF-8;',
Accept: 'application/json, text/plain, */*',
},
});
}
const BASE_URL = import.meta.env.VITE_BASE_URL;
const HEADER = {
'Content-Type': 'application/json;charset=UTF-8;',
Accept: 'application/json, text/plain, */*',
};
const getTokenStorage = () => {
let token = '';
try {
token = uni.getStorageSync('token');
} catch (e) {}
return token;
};
function createRequest() {
return new HttpRequest({
baseUrl: BASE_URL,
interceptors: {
invoke,
},
return new Request({
baseURL: BASE_URL,
header: HEADER,
});
}
export const request = createRequest();
const defHttp = createRequest();
// defHttp.setConfig((config) => { /* 设置全局配置 */
// config.header = {
// ...config.header,
// a: 1, // 演示
// b: 2 // 演示
// }
// return config
// })
/**
*
*/
defHttp.interceptors.request.use(
(config) => {
config.header = assign(config.header, {
token: getTokenStorage(),
});
console.log('interceptors.request', config);
/*
if (!token) { // 如果token不存在return Promise.reject(config) 会取消本次请求
return Promise.reject(config)
}
*/
return config;
},
(config) => {
return Promise.reject(config);
},
);
/**
*
*/
defHttp.interceptors.response.use(
async (response) => {
/* 请求之后拦截器。可以使用async await 做异步操作 */
// if (response.data.code !== 200) { // 服务端返回的状态码不等于200则reject()
// return Promise.reject(response)
// }
return response;
},
(response) => {
// 请求错误做点什么。可以使用async await 做异步操作
console.log(response);
return Promise.reject(response);
},
);
export { defHttp };

View File

@ -1,93 +0,0 @@
import { assign, cloneDeep, reject } from 'lodash-es';
import { Request, RequestOptions } from '@/utils/types/request';
export class HttpRequest {
private readonly options: Request.OptionsConfig;
requestTask: UniApp.RequestTask | undefined;
constructor(options: Request.OptionsConfig) {
this.options = options;
this.setupInterceptors();
this.requestTask = undefined;
}
/**
*
* https://uniapp.dcloud.io/api/interceptor.html
*/
setupInterceptors() {
this.options.interceptors && uni.addInterceptor('request', this.options.interceptors);
}
/**
* request调用
* @param requestParams
* @param options
*/
async request(requestParams: Request.Params, options?: Partial<RequestOptions>) {
let _params = cloneDeep(requestParams);
const url = `${this.options.baseUrl}${_params.url}`;
_params = assign(_params, this.options, options, { url });
// this.requestTask = await uni.request(_params);
return new Promise((resolve, reject) => {
this.requestTask = uni.request({
..._params,
success: (res) => {
resolve(res);
},
fail: (err) => {
// #ifdef APP-PLUS
reject(err);
// #endif
// #ifndef APP-PLUS
reject('请求失败');
// #endif
},
complete: () => {},
});
});
}
/**
*
*/
abort() {
this.requestTask && this.requestTask.abort();
}
get(requestParams: Request.Params, options?: Partial<RequestOptions>) {
return this.request(assign(requestParams, { method: 'GET' }), options);
}
post(requestParams: Request.Params, options?: Partial<RequestOptions>) {
return this.request(assign(requestParams, { method: 'POST' }), options);
}
put(requestParams: Request.Params, options?: Partial<RequestOptions>) {
return this.request(assign(requestParams, { method: 'PUT' }), options);
}
delete(requestParams: Request.Params, options?: Partial<RequestOptions>) {
return this.request(assign(requestParams, { method: 'DELETE' }), options);
}
option(requestParams: Request.Params, options?: Partial<RequestOptions>) {
return this.request(assign(requestParams, { method: 'OPTIONS' }), options);
}
/* #ifndef APP-PLUS */
trace(requestParams: Request.Params, options?: Partial<RequestOptions>) {
return this.request(assign(requestParams, { method: 'TRACE' }), options);
}
connect(requestParams: Request.Params, options?: Partial<RequestOptions>) {
return this.request(assign(requestParams, { method: 'CONNECT' }), options);
}
head(requestParams: Request.Params, options?: Partial<RequestOptions>) {
return this.request(assign(requestParams, { method: 'HEAD' }), options);
}
/* #endif */
}

View File

@ -1,8 +1,10 @@
'use strict';
import { cloneDeep } from 'lodash-es';
// utils is a library of generic helper functions non-specific to axios
var toString = Object.prototype.toString;
const toString = Object.prototype.toString;
/**
* Determine if a value is an Array
@ -40,7 +42,7 @@ export function isDate(val) {
* @param {Object} val The value to test
* @returns {boolean} True if value is a URLSearchParams object, otherwise false
*/
export function isURLSearchParams(val) {
export function isURLSearchParams(val: object) {
return typeof URLSearchParams !== 'undefined' && val instanceof URLSearchParams;
}

View File

@ -1,4 +1,6 @@
/* eslint-disable */
import { cloneDeep } from 'lodash-es';
var clone = (function () {
'use strict';
@ -257,4 +259,4 @@ var clone = (function () {
return clone;
})();
export default clone;
export { cloneDeep };

14
src/utils/index.ts Normal file
View File

@ -0,0 +1,14 @@
import { isObject } from '@/utils/is';
/**
*
* @param src
* @param target
*/
export function deepMerge<T = any>(src: any = {}, target: any = {}): T {
let key: string;
for (key in target) {
src[key] = isObject(src[key]) ? deepMerge(src[key], target[key]) : (src[key] = target[key]);
}
return src;
}

99
src/utils/is.ts Normal file
View File

@ -0,0 +1,99 @@
const toString = Object.prototype.toString;
export function is(val: unknown, type: string) {
return toString.call(val) === `[object ${type}]`;
}
export function isDef<T = unknown>(val?: T): val is T {
return typeof val !== 'undefined';
}
export function isUnDef<T = unknown>(val?: T): val is T {
return !isDef(val);
}
export function isObject(val: any): val is Record<any, any> {
return val !== null && is(val, 'Object');
}
export function isEmpty<T = unknown>(val: T): val is T {
if (isArray(val) || isString(val)) {
return val.length === 0;
}
if (val instanceof Map || val instanceof Set) {
return val.size === 0;
}
if (isObject(val)) {
return Object.keys(val).length === 0;
}
return false;
}
export function isDate(val: unknown): val is Date {
return is(val, 'Date');
}
export function isNull(val: unknown): val is null {
return val === null;
}
export function isNullAndUnDef(val: unknown): val is null | undefined {
return isUnDef(val) && isNull(val);
}
export function isNullOrUnDef(val: unknown): val is null | undefined {
return isUnDef(val) || isNull(val);
}
export function isNumber(val: unknown): val is number {
return is(val, 'Number');
}
export function isPromise<T = any>(val: unknown): val is Promise<T> {
return is(val, 'Promise') && isObject(val) && isFunction(val.then) && isFunction(val.catch);
}
export function isString(val: unknown): val is string {
return is(val, 'String');
}
export function isFunction(val: unknown): val is Function {
return typeof val === 'function';
}
export function isBoolean(val: unknown): val is boolean {
return is(val, 'Boolean');
}
export function isRegExp(val: unknown): val is RegExp {
return is(val, 'RegExp');
}
export function isArray(val: any): val is Array<any> {
return val && Array.isArray(val);
}
export function isWindow(val: any): val is Window {
return typeof window !== 'undefined' && is(val, 'Window');
}
export function isElement(val: unknown): val is Element {
return isObject(val) && !!val.tagName;
}
export function isMap(val: unknown): val is Map<any, any> {
return is(val, 'Map');
}
export const isServer = typeof window === 'undefined';
export const isClient = !isServer;
export function isUrl(path: string): boolean {
const reg =
/(((^https?:(?:\/\/)?)(?:[-;:&=\+\$,\w]+@)?[A-Za-z0-9.-]+(?::\d+)?|(?:www.|[-;:&=\+\$,\w]+@)[A-Za-z0-9.-]+)((?:\/[\+~%\/.\w-_]*)?\??(?:[-\+=&;%@.\w_]*)#?(?:[\w]*))?)$/;
return reg.test(path);
}

9
src/utils/log.ts Normal file
View File

@ -0,0 +1,9 @@
const projectName = import.meta.env.VITE_APP_TITLE;
export function warn(message: string) {
console.warn(`[${projectName} warn]:${message}`);
}
export function error(message: string) {
throw new Error(`[${projectName} error]:${message}`);
}

View File

@ -1,20 +0,0 @@
import { extend } from 'lodash-es';
declare type RequestOptions = UniApp.RequestOptions;
declare namespace Request {
/**
*
*/
interface OptionsConfig extends Partial<RequestOptions> {
interceptors?: UniApp.InterceptorOptions;
baseUrl: string;
}
interface Params<T = any> {
url: string;
data?: string | AnyObject | ArrayBuffer | T;
method?: 'OPTIONS' | 'GET' | 'HEAD' | 'POST' | 'PUT' | 'DELETE' | 'TRACE' | 'CONNECT';
skipAuth?: Boolean;
}
}

View File

@ -1,53 +1,58 @@
import { defineConfig } from 'vite';
import { ConfigEnv, UserConfig } from 'vite';
import uni from '@dcloudio/vite-plugin-uni';
import eslintPlugin from 'vite-plugin-eslint';
import windicss from 'vite-plugin-windicss';
import MiniProgramTailwind from '@dcasia/mini-program-tailwind-webpack-plugin/rollup';
import { resolve } from 'path';
import { loadEnv } from 'vite';
// https://vitejs.dev/config/
export default defineConfig({
base: './',
resolve: {
alias: {
'@': resolve('./src'),
},
},
server: {
host: true,
proxy: {
'/api': {
target: 'http://127.0.0.0:8000',
changeOrigin: true,
rewrite: (path) => path.replace(/^\/api/, ''),
},
'/upload': {
target: 'http://127.0.0.0:8000/upload',
changeOrigin: true,
rewrite: (path) => path.replace(/^\/upload/, ''),
export default ({ mode }: ConfigEnv): UserConfig => {
const root = process.cwd();
const env = loadEnv(mode, root);
return {
base: './',
resolve: {
alias: {
'@': resolve('./src'),
},
},
},
plugins: [
uni(),
windicss(),
MiniProgramTailwind({
// 是否开启自动转换至 rpx 单位值的功能
enableRpx: true,
// 设计稿的像素宽度值,该尺寸会影响 rpx 转换过程中的计算比率
designWidth: 350,
}),
// eslintPlugin({
// include: ['src/**/*.js', 'src/**/*.vue', 'src/**/*.ts'],
// exclude: ['./node_modules/**'],
// cache: false,
// }),
],
css: {
preprocessorOptions: {
scss: {
additionalData: '@import "@/assets/style/main.scss";',
server: {
host: true,
proxy: {
'/api': {
target: env.VITE_PROXY_BASE_URL,
changeOrigin: true,
rewrite: (path) => path.replace(/^\/api/, ''),
},
'/upload': {
target: env.VITE_PROXY_UPLOAD_URL,
changeOrigin: true,
rewrite: (path) => path.replace(/^\/upload/, ''),
},
},
},
},
});
plugins: [
uni(),
windicss(),
MiniProgramTailwind({
// 是否开启自动转换至 rpx 单位值的功能
enableRpx: true,
// 设计稿的像素宽度值,该尺寸会影响 rpx 转换过程中的计算比率
designWidth: 350,
}),
// eslintPlugin({
// include: ['src/**/*.js', 'src/**/*.vue', 'src/**/*.ts'],
// exclude: ['./node_modules/**'],
// cache: false,
// }),
],
css: {
preprocessorOptions: {
scss: {
additionalData: '@import "@/assets/style/main.scss";',
},
},
},
};
};