mirror of
https://github.com/vbenjs/vben-admin-thin-next.git
synced 2025-01-23 09:40:22 +08:00
fix: file upload key loss #120
This commit is contained in:
parent
bae53f3e2c
commit
29461a8568
@ -14,5 +14,8 @@ VITE_DROP_CONSOLE = false
|
|||||||
# Basic interface address SPA
|
# Basic interface address SPA
|
||||||
VITE_GLOB_API_URL=/api
|
VITE_GLOB_API_URL=/api
|
||||||
|
|
||||||
|
# File upload address, optional
|
||||||
|
VITE_GLOB_UPLOAD_URL=/upload
|
||||||
|
|
||||||
# Interface prefix
|
# Interface prefix
|
||||||
VITE_GLOB_API_URL_PREFIX=
|
VITE_GLOB_API_URL_PREFIX=
|
||||||
|
@ -13,6 +13,10 @@ VITE_BUILD_GZIP = false
|
|||||||
# Basic interface address SPA
|
# Basic interface address SPA
|
||||||
VITE_GLOB_API_URL=/api
|
VITE_GLOB_API_URL=/api
|
||||||
|
|
||||||
|
# File upload address, optional
|
||||||
|
# It can be forwarded by nginx or write the actual address directly
|
||||||
|
VITE_GLOB_UPLOAD_URL=/upload
|
||||||
|
|
||||||
# Interface prefix
|
# Interface prefix
|
||||||
VITE_GLOB_API_URL_PREFIX=
|
VITE_GLOB_API_URL_PREFIX=
|
||||||
|
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
- i18n 支持 vscode `i18n-ally`插件
|
- i18n 支持 vscode `i18n-ally`插件
|
||||||
- 新增多级路由缓存示例
|
- 新增多级路由缓存示例
|
||||||
- 打包代码拆分(试验)
|
- 打包代码拆分(试验)
|
||||||
|
- 提取上传地址到全局变量,打包可以动态配置
|
||||||
|
|
||||||
### ⚡ Performance Improvements
|
### ⚡ Performance Improvements
|
||||||
|
|
||||||
@ -23,6 +24,7 @@
|
|||||||
- 升级`ant-design-vue`到`2.0.0-rc.3`
|
- 升级`ant-design-vue`到`2.0.0-rc.3`
|
||||||
- 重新引入`vueuse`
|
- 重新引入`vueuse`
|
||||||
- 移除 route meta 内的`afterCloseLoading`属性
|
- 移除 route meta 内的`afterCloseLoading`属性
|
||||||
|
- 文档更新
|
||||||
|
|
||||||
### 🐛 Bug Fixes
|
### 🐛 Bug Fixes
|
||||||
|
|
||||||
@ -31,6 +33,7 @@
|
|||||||
- 修复顶部菜单宽度计算问题
|
- 修复顶部菜单宽度计算问题
|
||||||
- 修复表格 tabSetting 问题
|
- 修复表格 tabSetting 问题
|
||||||
- 修复文件上传删除失效
|
- 修复文件上传删除失效
|
||||||
|
- 修复表格行编辑保存错误问题
|
||||||
|
|
||||||
## 2.0.0-rc.12 (2020-11-30)
|
## 2.0.0-rc.12 (2020-11-30)
|
||||||
|
|
||||||
|
@ -1,10 +1,9 @@
|
|||||||
import { UploadApiResult } from './model/uploadModel';
|
import { UploadApiResult } from './model/uploadModel';
|
||||||
import { defHttp } from '/@/utils/http/axios';
|
import { defHttp } from '/@/utils/http/axios';
|
||||||
import { UploadFileParams } from '/@/utils/http/axios/types';
|
import { UploadFileParams } from '/@/utils/http/axios/types';
|
||||||
|
import { useGlobSetting } from '/@/hooks/setting';
|
||||||
|
|
||||||
enum Api {
|
const { uploadUrl = '' } = useGlobSetting();
|
||||||
UPLOAD_URL = '/upload',
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description: Upload interface
|
* @description: Upload interface
|
||||||
@ -15,7 +14,7 @@ export function uploadApi(
|
|||||||
) {
|
) {
|
||||||
return defHttp.uploadFile<UploadApiResult>(
|
return defHttp.uploadFile<UploadApiResult>(
|
||||||
{
|
{
|
||||||
url: Api.UPLOAD_URL,
|
url: uploadUrl,
|
||||||
onUploadProgress,
|
onUploadProgress,
|
||||||
},
|
},
|
||||||
params
|
params
|
||||||
|
@ -31,6 +31,7 @@ export function jsonToSheetXlsx<T = any>({
|
|||||||
writeFile(workbook, filename, write2excelOpts);
|
writeFile(workbook, filename, write2excelOpts);
|
||||||
/* at this point, out.xlsb will have been downloaded */
|
/* at this point, out.xlsb will have been downloaded */
|
||||||
}
|
}
|
||||||
|
|
||||||
export function aoaToSheetXlsx<T = any>({
|
export function aoaToSheetXlsx<T = any>({
|
||||||
data,
|
data,
|
||||||
header,
|
header,
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
import type { ExcelData } from './types';
|
import type { ExcelData } from './types';
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: 'ImportExcel',
|
name: 'ImportExcel',
|
||||||
emits: ['success'],
|
emits: ['success', 'error'],
|
||||||
setup(_, { emit }) {
|
setup(_, { emit }) {
|
||||||
const inputRef = ref<HTMLInputElement | null>(null);
|
const inputRef = ref<HTMLInputElement | null>(null);
|
||||||
const loadingRef = ref<Boolean>(false);
|
const loadingRef = ref<Boolean>(false);
|
||||||
@ -82,6 +82,7 @@
|
|||||||
resolve('');
|
resolve('');
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
reject(error);
|
reject(error);
|
||||||
|
emit('error');
|
||||||
} finally {
|
} finally {
|
||||||
loadingRef.value = false;
|
loadingRef.value = false;
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,7 @@ export interface JsonToSheet<T = any> {
|
|||||||
json2sheetOpts?: JSON2SheetOpts;
|
json2sheetOpts?: JSON2SheetOpts;
|
||||||
write2excelOpts?: WritingOptions;
|
write2excelOpts?: WritingOptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface AoAToSheet<T = any> {
|
export interface AoAToSheet<T = any> {
|
||||||
data: T[][];
|
data: T[][];
|
||||||
header?: T[];
|
header?: T[];
|
||||||
|
@ -93,7 +93,6 @@ export type ComponentType =
|
|||||||
| 'SelectOption'
|
| 'SelectOption'
|
||||||
| 'TreeSelect'
|
| 'TreeSelect'
|
||||||
| 'Transfer'
|
| 'Transfer'
|
||||||
// | 'Radio'
|
|
||||||
| 'RadioButtonGroup'
|
| 'RadioButtonGroup'
|
||||||
| 'RadioGroup'
|
| 'RadioGroup'
|
||||||
| 'Checkbox'
|
| 'Checkbox'
|
||||||
|
@ -190,6 +190,7 @@ export default defineComponent({
|
|||||||
const { appendClass } = props;
|
const { appendClass } = props;
|
||||||
const isAppendActiveCls =
|
const isAppendActiveCls =
|
||||||
appendClass && level === 1 && menu.path === unref(currentParentPath);
|
appendClass && level === 1 && menu.path === unref(currentParentPath);
|
||||||
|
|
||||||
const levelCls = [
|
const levelCls = [
|
||||||
`${prefixCls}-item__level${level}`,
|
`${prefixCls}-item__level${level}`,
|
||||||
` ${menuState.theme} `,
|
` ${menuState.theme} `,
|
||||||
|
@ -38,9 +38,9 @@ export default defineComponent({
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{dataSource.map((record = {}) => {
|
{dataSource.map((record = {}, index) => {
|
||||||
return (
|
return (
|
||||||
<tr class="file-table-tr" key={record.uuid}>
|
<tr class="file-table-tr" key={`${index + record.name || ''}`}>
|
||||||
{columnList.map((item) => {
|
{columnList.map((item) => {
|
||||||
const { dataIndex = '', customRender, align = 'center' } = item;
|
const { dataIndex = '', customRender, align = 'center' } = item;
|
||||||
const render = customRender && isFunction(customRender);
|
const render = customRender && isFunction(customRender);
|
||||||
|
@ -18,6 +18,7 @@ const {
|
|||||||
VITE_GLOB_API_URL,
|
VITE_GLOB_API_URL,
|
||||||
VITE_GLOB_APP_SHORT_NAME,
|
VITE_GLOB_APP_SHORT_NAME,
|
||||||
VITE_GLOB_API_URL_PREFIX,
|
VITE_GLOB_API_URL_PREFIX,
|
||||||
|
VITE_GLOB_UPLOAD_URL,
|
||||||
} = ENV;
|
} = ENV;
|
||||||
|
|
||||||
if (!reg.test(VITE_GLOB_APP_SHORT_NAME)) {
|
if (!reg.test(VITE_GLOB_APP_SHORT_NAME)) {
|
||||||
@ -33,6 +34,7 @@ export const useGlobSetting = (): Readonly<GlobConfig> => {
|
|||||||
apiUrl: VITE_GLOB_API_URL,
|
apiUrl: VITE_GLOB_API_URL,
|
||||||
shortName: VITE_GLOB_APP_SHORT_NAME,
|
shortName: VITE_GLOB_APP_SHORT_NAME,
|
||||||
urlPrefix: VITE_GLOB_API_URL_PREFIX,
|
urlPrefix: VITE_GLOB_API_URL_PREFIX,
|
||||||
|
uploadUrl: VITE_GLOB_UPLOAD_URL,
|
||||||
};
|
};
|
||||||
return glob as Readonly<GlobConfig>;
|
return glob as Readonly<GlobConfig>;
|
||||||
};
|
};
|
||||||
|
2
src/types/config.d.ts
vendored
2
src/types/config.d.ts
vendored
@ -129,6 +129,7 @@ export interface GlobConfig {
|
|||||||
title: string;
|
title: string;
|
||||||
// 项目路径
|
// 项目路径
|
||||||
apiUrl: string;
|
apiUrl: string;
|
||||||
|
uploadUrl?: string;
|
||||||
urlPrefix?: string;
|
urlPrefix?: string;
|
||||||
shortName: string;
|
shortName: string;
|
||||||
}
|
}
|
||||||
@ -139,6 +140,7 @@ export interface GlobEnvConfig {
|
|||||||
VITE_GLOB_API_URL: string;
|
VITE_GLOB_API_URL: string;
|
||||||
VITE_GLOB_API_URL_PREFIX?: string;
|
VITE_GLOB_API_URL_PREFIX?: string;
|
||||||
VITE_GLOB_APP_SHORT_NAME: string;
|
VITE_GLOB_APP_SHORT_NAME: string;
|
||||||
|
VITE_GLOB_UPLOAD_URL?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface GlobWrap {
|
interface GlobWrap {
|
||||||
|
@ -11,11 +11,11 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { defineComponent } from 'vue';
|
import { defineComponent } from 'vue';
|
||||||
import { BasicTable } from '/@/components/Table';
|
import { BasicTable } from '/@/components/Table';
|
||||||
import { aoaToSheetXlsx, ExportExcelModel } from '/@/components/Excel';
|
import { aoaToSheetXlsx } from '/@/components/Excel';
|
||||||
import { arrHeader, arrData, columns, data } from './data';
|
import { arrHeader, arrData, columns, data } from './data';
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
components: { BasicTable, ExportExcelModel },
|
components: { BasicTable },
|
||||||
setup() {
|
setup() {
|
||||||
function aoaToExcel() {
|
function aoaToExcel() {
|
||||||
// 保证data顺序与header一致
|
// 保证data顺序与header一致
|
||||||
|
@ -12,11 +12,11 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { defineComponent } from 'vue';
|
import { defineComponent } from 'vue';
|
||||||
import { BasicTable } from '/@/components/Table';
|
import { BasicTable } from '/@/components/Table';
|
||||||
import { jsonToSheetXlsx, ExportExcelModel } from '/@/components/Excel';
|
import { jsonToSheetXlsx } from '/@/components/Excel';
|
||||||
import { columns, data } from './data';
|
import { columns, data } from './data';
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
components: { BasicTable, ExportExcelModel },
|
components: { BasicTable },
|
||||||
setup() {
|
setup() {
|
||||||
function defaultHeader() {
|
function defaultHeader() {
|
||||||
// 默认Object.keys(data[0])作为header
|
// 默认Object.keys(data[0])作为header
|
||||||
@ -25,6 +25,7 @@
|
|||||||
filename: '使用key作为默认头部.xlsx',
|
filename: '使用key作为默认头部.xlsx',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function customHeader() {
|
function customHeader() {
|
||||||
jsonToSheetXlsx({
|
jsonToSheetXlsx({
|
||||||
data,
|
data,
|
||||||
|
Loading…
Reference in New Issue
Block a user