Commit 29461a856826fbb7726848982387ea78f8573754
1 parent
bae53f3e
fix: file upload key loss #120
Showing
14 changed files
with
29 additions
and
12 deletions
.env.development
@@ -14,5 +14,8 @@ VITE_DROP_CONSOLE = false | @@ -14,5 +14,8 @@ VITE_DROP_CONSOLE = false | ||
14 | # Basic interface address SPA | 14 | # Basic interface address SPA |
15 | VITE_GLOB_API_URL=/api | 15 | VITE_GLOB_API_URL=/api |
16 | 16 | ||
17 | +# File upload address, optional | ||
18 | +VITE_GLOB_UPLOAD_URL=/upload | ||
19 | + | ||
17 | # Interface prefix | 20 | # Interface prefix |
18 | VITE_GLOB_API_URL_PREFIX= | 21 | VITE_GLOB_API_URL_PREFIX= |
.env.production
@@ -13,6 +13,10 @@ VITE_BUILD_GZIP = false | @@ -13,6 +13,10 @@ VITE_BUILD_GZIP = false | ||
13 | # Basic interface address SPA | 13 | # Basic interface address SPA |
14 | VITE_GLOB_API_URL=/api | 14 | VITE_GLOB_API_URL=/api |
15 | 15 | ||
16 | +# File upload address, optional | ||
17 | +# It can be forwarded by nginx or write the actual address directly | ||
18 | +VITE_GLOB_UPLOAD_URL=/upload | ||
19 | + | ||
16 | # Interface prefix | 20 | # Interface prefix |
17 | VITE_GLOB_API_URL_PREFIX= | 21 | VITE_GLOB_API_URL_PREFIX= |
18 | 22 |
CHANGELOG.zh_CN.md
@@ -11,6 +11,7 @@ | @@ -11,6 +11,7 @@ | ||
11 | - i18n 支持 vscode `i18n-ally`插件 | 11 | - i18n 支持 vscode `i18n-ally`插件 |
12 | - 新增多级路由缓存示例 | 12 | - 新增多级路由缓存示例 |
13 | - 打包代码拆分(试验) | 13 | - 打包代码拆分(试验) |
14 | +- 提取上传地址到全局变量,打包可以动态配置 | ||
14 | 15 | ||
15 | ### ⚡ Performance Improvements | 16 | ### ⚡ Performance Improvements |
16 | 17 | ||
@@ -23,6 +24,7 @@ | @@ -23,6 +24,7 @@ | ||
23 | - 升级`ant-design-vue`到`2.0.0-rc.3` | 24 | - 升级`ant-design-vue`到`2.0.0-rc.3` |
24 | - 重新引入`vueuse` | 25 | - 重新引入`vueuse` |
25 | - 移除 route meta 内的`afterCloseLoading`属性 | 26 | - 移除 route meta 内的`afterCloseLoading`属性 |
27 | +- 文档更新 | ||
26 | 28 | ||
27 | ### 🐛 Bug Fixes | 29 | ### 🐛 Bug Fixes |
28 | 30 | ||
@@ -31,6 +33,7 @@ | @@ -31,6 +33,7 @@ | ||
31 | - 修复顶部菜单宽度计算问题 | 33 | - 修复顶部菜单宽度计算问题 |
32 | - 修复表格 tabSetting 问题 | 34 | - 修复表格 tabSetting 问题 |
33 | - 修复文件上传删除失效 | 35 | - 修复文件上传删除失效 |
36 | +- 修复表格行编辑保存错误问题 | ||
34 | 37 | ||
35 | ## 2.0.0-rc.12 (2020-11-30) | 38 | ## 2.0.0-rc.12 (2020-11-30) |
36 | 39 |
src/api/sys/upload.ts
1 | import { UploadApiResult } from './model/uploadModel'; | 1 | import { UploadApiResult } from './model/uploadModel'; |
2 | import { defHttp } from '/@/utils/http/axios'; | 2 | import { defHttp } from '/@/utils/http/axios'; |
3 | import { UploadFileParams } from '/@/utils/http/axios/types'; | 3 | import { UploadFileParams } from '/@/utils/http/axios/types'; |
4 | +import { useGlobSetting } from '/@/hooks/setting'; | ||
4 | 5 | ||
5 | -enum Api { | ||
6 | - UPLOAD_URL = '/upload', | ||
7 | -} | 6 | +const { uploadUrl = '' } = useGlobSetting(); |
8 | 7 | ||
9 | /** | 8 | /** |
10 | * @description: Upload interface | 9 | * @description: Upload interface |
@@ -15,7 +14,7 @@ export function uploadApi( | @@ -15,7 +14,7 @@ export function uploadApi( | ||
15 | ) { | 14 | ) { |
16 | return defHttp.uploadFile<UploadApiResult>( | 15 | return defHttp.uploadFile<UploadApiResult>( |
17 | { | 16 | { |
18 | - url: Api.UPLOAD_URL, | 17 | + url: uploadUrl, |
19 | onUploadProgress, | 18 | onUploadProgress, |
20 | }, | 19 | }, |
21 | params | 20 | params |
src/components/Excel/src/Export2Excel.ts
@@ -31,6 +31,7 @@ export function jsonToSheetXlsx<T = any>({ | @@ -31,6 +31,7 @@ export function jsonToSheetXlsx<T = any>({ | ||
31 | writeFile(workbook, filename, write2excelOpts); | 31 | writeFile(workbook, filename, write2excelOpts); |
32 | /* at this point, out.xlsb will have been downloaded */ | 32 | /* at this point, out.xlsb will have been downloaded */ |
33 | } | 33 | } |
34 | + | ||
34 | export function aoaToSheetXlsx<T = any>({ | 35 | export function aoaToSheetXlsx<T = any>({ |
35 | data, | 36 | data, |
36 | header, | 37 | header, |
src/components/Excel/src/ImportExcel.vue
@@ -17,7 +17,7 @@ | @@ -17,7 +17,7 @@ | ||
17 | import type { ExcelData } from './types'; | 17 | import type { ExcelData } from './types'; |
18 | export default defineComponent({ | 18 | export default defineComponent({ |
19 | name: 'ImportExcel', | 19 | name: 'ImportExcel', |
20 | - emits: ['success'], | 20 | + emits: ['success', 'error'], |
21 | setup(_, { emit }) { | 21 | setup(_, { emit }) { |
22 | const inputRef = ref<HTMLInputElement | null>(null); | 22 | const inputRef = ref<HTMLInputElement | null>(null); |
23 | const loadingRef = ref<Boolean>(false); | 23 | const loadingRef = ref<Boolean>(false); |
@@ -82,6 +82,7 @@ | @@ -82,6 +82,7 @@ | ||
82 | resolve(''); | 82 | resolve(''); |
83 | } catch (error) { | 83 | } catch (error) { |
84 | reject(error); | 84 | reject(error); |
85 | + emit('error'); | ||
85 | } finally { | 86 | } finally { |
86 | loadingRef.value = false; | 87 | loadingRef.value = false; |
87 | } | 88 | } |
src/components/Excel/src/types.ts
@@ -17,6 +17,7 @@ export interface JsonToSheet<T = any> { | @@ -17,6 +17,7 @@ export interface JsonToSheet<T = any> { | ||
17 | json2sheetOpts?: JSON2SheetOpts; | 17 | json2sheetOpts?: JSON2SheetOpts; |
18 | write2excelOpts?: WritingOptions; | 18 | write2excelOpts?: WritingOptions; |
19 | } | 19 | } |
20 | + | ||
20 | export interface AoAToSheet<T = any> { | 21 | export interface AoAToSheet<T = any> { |
21 | data: T[][]; | 22 | data: T[][]; |
22 | header?: T[]; | 23 | header?: T[]; |
src/components/Form/src/types/index.ts
@@ -93,7 +93,6 @@ export type ComponentType = | @@ -93,7 +93,6 @@ export type ComponentType = | ||
93 | | 'SelectOption' | 93 | | 'SelectOption' |
94 | | 'TreeSelect' | 94 | | 'TreeSelect' |
95 | | 'Transfer' | 95 | | 'Transfer' |
96 | - // | 'Radio' | ||
97 | | 'RadioButtonGroup' | 96 | | 'RadioButtonGroup' |
98 | | 'RadioGroup' | 97 | | 'RadioGroup' |
99 | | 'Checkbox' | 98 | | 'Checkbox' |
src/components/Menu/src/BasicMenu.tsx
@@ -190,6 +190,7 @@ export default defineComponent({ | @@ -190,6 +190,7 @@ export default defineComponent({ | ||
190 | const { appendClass } = props; | 190 | const { appendClass } = props; |
191 | const isAppendActiveCls = | 191 | const isAppendActiveCls = |
192 | appendClass && level === 1 && menu.path === unref(currentParentPath); | 192 | appendClass && level === 1 && menu.path === unref(currentParentPath); |
193 | + | ||
193 | const levelCls = [ | 194 | const levelCls = [ |
194 | `${prefixCls}-item__level${level}`, | 195 | `${prefixCls}-item__level${level}`, |
195 | ` ${menuState.theme} `, | 196 | ` ${menuState.theme} `, |
src/components/Upload/src/FileList.tsx
@@ -38,9 +38,9 @@ export default defineComponent({ | @@ -38,9 +38,9 @@ export default defineComponent({ | ||
38 | </tr> | 38 | </tr> |
39 | </thead> | 39 | </thead> |
40 | <tbody> | 40 | <tbody> |
41 | - {dataSource.map((record = {}) => { | 41 | + {dataSource.map((record = {}, index) => { |
42 | return ( | 42 | return ( |
43 | - <tr class="file-table-tr" key={record.uuid}> | 43 | + <tr class="file-table-tr" key={`${index + record.name || ''}`}> |
44 | {columnList.map((item) => { | 44 | {columnList.map((item) => { |
45 | const { dataIndex = '', customRender, align = 'center' } = item; | 45 | const { dataIndex = '', customRender, align = 'center' } = item; |
46 | const render = customRender && isFunction(customRender); | 46 | const render = customRender && isFunction(customRender); |
src/hooks/setting/index.ts
@@ -18,6 +18,7 @@ const { | @@ -18,6 +18,7 @@ const { | ||
18 | VITE_GLOB_API_URL, | 18 | VITE_GLOB_API_URL, |
19 | VITE_GLOB_APP_SHORT_NAME, | 19 | VITE_GLOB_APP_SHORT_NAME, |
20 | VITE_GLOB_API_URL_PREFIX, | 20 | VITE_GLOB_API_URL_PREFIX, |
21 | + VITE_GLOB_UPLOAD_URL, | ||
21 | } = ENV; | 22 | } = ENV; |
22 | 23 | ||
23 | if (!reg.test(VITE_GLOB_APP_SHORT_NAME)) { | 24 | if (!reg.test(VITE_GLOB_APP_SHORT_NAME)) { |
@@ -33,6 +34,7 @@ export const useGlobSetting = (): Readonly<GlobConfig> => { | @@ -33,6 +34,7 @@ export const useGlobSetting = (): Readonly<GlobConfig> => { | ||
33 | apiUrl: VITE_GLOB_API_URL, | 34 | apiUrl: VITE_GLOB_API_URL, |
34 | shortName: VITE_GLOB_APP_SHORT_NAME, | 35 | shortName: VITE_GLOB_APP_SHORT_NAME, |
35 | urlPrefix: VITE_GLOB_API_URL_PREFIX, | 36 | urlPrefix: VITE_GLOB_API_URL_PREFIX, |
37 | + uploadUrl: VITE_GLOB_UPLOAD_URL, | ||
36 | }; | 38 | }; |
37 | return glob as Readonly<GlobConfig>; | 39 | return glob as Readonly<GlobConfig>; |
38 | }; | 40 | }; |
src/types/config.d.ts
@@ -129,6 +129,7 @@ export interface GlobConfig { | @@ -129,6 +129,7 @@ export interface GlobConfig { | ||
129 | title: string; | 129 | title: string; |
130 | // 项目路径 | 130 | // 项目路径 |
131 | apiUrl: string; | 131 | apiUrl: string; |
132 | + uploadUrl?: string; | ||
132 | urlPrefix?: string; | 133 | urlPrefix?: string; |
133 | shortName: string; | 134 | shortName: string; |
134 | } | 135 | } |
@@ -139,6 +140,7 @@ export interface GlobEnvConfig { | @@ -139,6 +140,7 @@ export interface GlobEnvConfig { | ||
139 | VITE_GLOB_API_URL: string; | 140 | VITE_GLOB_API_URL: string; |
140 | VITE_GLOB_API_URL_PREFIX?: string; | 141 | VITE_GLOB_API_URL_PREFIX?: string; |
141 | VITE_GLOB_APP_SHORT_NAME: string; | 142 | VITE_GLOB_APP_SHORT_NAME: string; |
143 | + VITE_GLOB_UPLOAD_URL?: string; | ||
142 | } | 144 | } |
143 | 145 | ||
144 | interface GlobWrap { | 146 | interface GlobWrap { |
src/views/demo/excel/ArrayExport.vue
@@ -11,11 +11,11 @@ | @@ -11,11 +11,11 @@ | ||
11 | <script lang="ts"> | 11 | <script lang="ts"> |
12 | import { defineComponent } from 'vue'; | 12 | import { defineComponent } from 'vue'; |
13 | import { BasicTable } from '/@/components/Table'; | 13 | import { BasicTable } from '/@/components/Table'; |
14 | - import { aoaToSheetXlsx, ExportExcelModel } from '/@/components/Excel'; | 14 | + import { aoaToSheetXlsx } from '/@/components/Excel'; |
15 | import { arrHeader, arrData, columns, data } from './data'; | 15 | import { arrHeader, arrData, columns, data } from './data'; |
16 | 16 | ||
17 | export default defineComponent({ | 17 | export default defineComponent({ |
18 | - components: { BasicTable, ExportExcelModel }, | 18 | + components: { BasicTable }, |
19 | setup() { | 19 | setup() { |
20 | function aoaToExcel() { | 20 | function aoaToExcel() { |
21 | // 保证data顺序与header一致 | 21 | // 保证data顺序与header一致 |
src/views/demo/excel/JsonExport.vue
@@ -12,11 +12,11 @@ | @@ -12,11 +12,11 @@ | ||
12 | <script lang="ts"> | 12 | <script lang="ts"> |
13 | import { defineComponent } from 'vue'; | 13 | import { defineComponent } from 'vue'; |
14 | import { BasicTable } from '/@/components/Table'; | 14 | import { BasicTable } from '/@/components/Table'; |
15 | - import { jsonToSheetXlsx, ExportExcelModel } from '/@/components/Excel'; | 15 | + import { jsonToSheetXlsx } from '/@/components/Excel'; |
16 | import { columns, data } from './data'; | 16 | import { columns, data } from './data'; |
17 | 17 | ||
18 | export default defineComponent({ | 18 | export default defineComponent({ |
19 | - components: { BasicTable, ExportExcelModel }, | 19 | + components: { BasicTable }, |
20 | setup() { | 20 | setup() { |
21 | function defaultHeader() { | 21 | function defaultHeader() { |
22 | // 默认Object.keys(data[0])作为header | 22 | // 默认Object.keys(data[0])作为header |
@@ -25,6 +25,7 @@ | @@ -25,6 +25,7 @@ | ||
25 | filename: '使用key作为默认头部.xlsx', | 25 | filename: '使用key作为默认头部.xlsx', |
26 | }); | 26 | }); |
27 | } | 27 | } |
28 | + | ||
28 | function customHeader() { | 29 | function customHeader() { |
29 | jsonToSheetXlsx({ | 30 | jsonToSheetXlsx({ |
30 | data, | 31 | data, |