diff --git a/index.html b/index.html index f7f6135..29c49b5 100644 --- a/index.html +++ b/index.html @@ -1,87 +1,99 @@ - + - - - - - - pure-admin-thin - - - + + + + + + vue3-mgt-template + + + - -
- -
-
- - + 40% { + box-shadow: 0 2.5em 0 0; + } + } + +
+ + + diff --git a/src/router/modules/demo.ts b/src/router/modules/demo.ts index ef75461..6174732 100644 --- a/src/router/modules/demo.ts +++ b/src/router/modules/demo.ts @@ -9,6 +9,10 @@ const titleArr = [ key: 'tools', title: '工具方法', }, + { + key: 'importOrExportExcel', + title: '导入导出excel', + }, ]; // @/views/demo/**/*.vue diff --git a/src/utils/tools.ts b/src/utils/tools.ts index 476e57f..685313d 100644 --- a/src/utils/tools.ts +++ b/src/utils/tools.ts @@ -15,6 +15,19 @@ export const url = { .join('&') ); }, + /** + * 获取url参数对象 + * @param url {string} 完整url,默认当前页面url + * @returns {Record} { x: 1, y: 2, z: 3 } + */ + getUrlToParams: (url: string = window.location.href): Record => { + const urlParams = new URLSearchParams(url.split('?')[1]); + const params = {}; + for (const [key, value] of urlParams.entries()) { + params[key] = value; + } + return params; + }, }; /** route路由相关工具 */ @@ -28,6 +41,44 @@ export const route = { }, getTitleFromPathStr: (arr: any, path: string): string => { const item = arr.find(({ key }) => path.includes(key)); - return item ? item.title : null; // 如果找到,返回 title;否则返回 null + return item ? item.title : path; // 如果找到,返回 title;否则返回 null + }, +}; + +/** 数组相关工具 */ +export const array = { + /** + * 判断两个数组是否相等,只递归一层,如果有嵌套数组或对象,则只判断第一层,并且永远不相等 + * 支持忽略指定字段 + * [{ a:1, b:2 }, { c:3, d:4 }] 比较 [{ a:1, b:2 }, { c:3, d:4 }] 结果为 true + * [{ a:1, b:2 }, { c:3, d:4 }] 比较 [{ a:1, b:2 }, { c:3, d:5 }] 结果为 false + * [{ a:1, b: { b1: 1 }}, { c:3, d:4 }] 比较 [{ a:1, b: { b1: 1 }}, { c:3, d:4 }] 结果为false,因为b是对象,只比较第一层 + * @param arr1 + * @param arr2 + * @param ignoreFields ['a', 'b'] + * @returns boolean + */ + arraysAreEqual: (arr1: any[], arr2: any[], ignoreFields: Array = []): boolean => { + if (arr1.length !== arr2.length) { + return false; + } + return arr1.every((item, index) => { + const item2 = arr2[index]; + if (typeof item === 'object' && typeof item2 === 'object') { + return Object.keys(item) + .filter((key) => ignoreFields.indexOf(key) === -1) + .every((key) => item[key] === item2[key]); + } else { + return item === item2; + } + }); }, }; + +export const generateUUID = () => { + return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => { + const r = (Math.random() * 16) | 0, + v = c == 'x' ? r : (r & 0x3) | 0x8; + return v.toString(16); + }); +}; diff --git a/src/views/demo/importOrExportExcel/index.vue b/src/views/demo/importOrExportExcel/index.vue new file mode 100644 index 0000000..a5de7aa --- /dev/null +++ b/src/views/demo/importOrExportExcel/index.vue @@ -0,0 +1,53 @@ + + + + + diff --git a/src/views/demo/tools/index.vue b/src/views/demo/tools/index.vue index db131ca..cbe6593 100644 --- a/src/views/demo/tools/index.vue +++ b/src/views/demo/tools/index.vue @@ -1,15 +1,73 @@ diff --git a/src/views/template/base/index.vue b/src/views/template/base/index.vue index c93fe11..672cdf4 100644 --- a/src/views/template/base/index.vue +++ b/src/views/template/base/index.vue @@ -8,8 +8,6 @@ import { ref } from 'vue'; defineOptions({ name: 'TemplateBase', }); - -const page = ref({});