Skip to content

Commit

Permalink
fix(shims-vue): import path error
Browse files Browse the repository at this point in the history
  • Loading branch information
buqiyuan committed Feb 12, 2024
1 parent d3d93e4 commit f80c9ef
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 23 deletions.
3 changes: 0 additions & 3 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ VITE_APP_TITLE = Admin
# 网站前缀
VITE_BASE_URL = /

# base api
VITE_BASE_API_URL = '/api/admin/'

# enable mock in production
VITE_MOCK_IN_PROD = true

1 change: 1 addition & 0 deletions src/styles/variables.less
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@

@header-height: 64px;
@footer-height: 70px;
@primary-color: #00b96b;
25 changes: 14 additions & 11 deletions src/utils/request.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import axios, { CanceledError } from 'axios';
import { isString } from 'lodash-es';
import { message as $message, Modal } from 'ant-design-vue';
import type { AxiosRequestConfig, AxiosResponse } from 'axios';
import { ACCESS_TOKEN_KEY } from '@/enums/cacheEnum';
import { Storage } from '@/utils/Storage';
import { ResultEnum } from '@/enums/httpEnum';
import { useUserStore } from '@/store/modules/user';

export interface RequestOptions<Passive extends boolean = true> extends AxiosRequestConfig {
export interface RequestOptions extends AxiosRequestConfig {
/** 是否直接将数据从响应中提取出,例如直接返回 res.data,而忽略 res.code 等信息 */
isReturnResult?: Passive;
isReturnResult?: boolean;
/** 请求成功是提示信息 */
successMsg?: string;
/** 请求失败是提示信息 */
Expand Down Expand Up @@ -102,27 +103,29 @@ type BaseResponse<T = any> = Omit<API.ResOp, 'data'> & {

export function request<T = any>(
url: string,
config: RequestOptions<true>,
): Promise<BaseResponse<T>['data']>;

config: { isReturnResult: false } & RequestOptions,
): Promise<BaseResponse<T>>;
export function request<T = any>(
url: string,
config: RequestOptions<false>,
config: RequestOptions,
): Promise<BaseResponse<T>['data']>;
export function request<T = any>(
config: { isReturnResult: false } & RequestOptions,
): Promise<BaseResponse<T>>;
export function request<T = any>(config: RequestOptions): Promise<BaseResponse<T>['data']>;
/**
*
* @param url - request url
* @param config - AxiosRequestConfig
*/
export async function request<T = BaseResponse, Passive extends boolean = true>(
url: string,
config: RequestOptions<Passive> = {},
) {
export async function request(_url: string | RequestOptions, _config: RequestOptions = {}) {
const url = isString(_url) ? _url : _url.url;
const config = isString(_url) ? _config : _url;
try {
// 兼容 from data 文件上传的情况
const { requestType, isReturnResult = true, ...rest } = config;

const response = (await service.request<T>({
const response = (await service.request({
url,
...rest,
headers: {
Expand Down
9 changes: 3 additions & 6 deletions src/views/netdisk/manage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@
}
};
const handleClickFileItem = (row) => {
const handleClickFileItem = (row: API.SFileInfo) => {
console.log('handleClickFileItem ', row);
if (row.type === 'dir') {
if (isSearching.value) {
Expand All @@ -213,7 +213,7 @@
}
};
const handleDownload = async (row) => {
const handleDownload = async (row: API.SFileInfo) => {
try {
isLoading.value = true;
const data = await Api.netDiskManage.netDiskManageDownload({
Expand All @@ -227,9 +227,6 @@
}
};
/**
* @description 打开部门弹窗
*/
const handleRename = async (record: API.SFileInfo) => {
console.log('record', record);
Expand All @@ -254,7 +251,7 @@
});
};
const customRow = (record) => {
const customRow = (record: API.SFileInfo) => {
return {
onContextmenu: (e: MouseEvent) => {
createContextMenu({
Expand Down
2 changes: 1 addition & 1 deletion types/shims/shims-vue.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { PermissionType } from '@/permission/permCode/';
import type { PermissionType } from '@/permission/permCode';

// declare module '*.vue' {
// import * as vue from 'vue';
Expand Down
3 changes: 1 addition & 2 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,7 @@ export default ({ command, mode }: ConfigEnv): UserConfig => {
javascriptEnabled: true,
modifyVars: {},
additionalData: `
@primary-color: #00b96b;
@header-height: 60px;
@import '@/styles/variables.less';
`,
},
// scss: {
Expand Down

0 comments on commit f80c9ef

Please sign in to comment.