|
@@ -1,12 +1,9 @@
|
|
|
const baseUrl = import.meta.env.VITE_BASE_URL;
|
|
|
const basePrefix = import.meta.env.VITE_BASE_PREFIX;
|
|
|
import { screenApi } from "@/api/screen"
|
|
|
-interface IUrlParams {
|
|
|
- [propsName: string]: any
|
|
|
-}
|
|
|
|
|
|
/** 统一 - get和post请求书写方式 */
|
|
|
-export function tansParams(params: any): string {
|
|
|
+export function tansParams(params) {
|
|
|
let result = ''
|
|
|
for (const propName of Object.keys(params)) {
|
|
|
const value = params[propName];
|
|
@@ -30,14 +27,14 @@ export function tansParams(params: any): string {
|
|
|
|
|
|
/** localhost - methods */
|
|
|
export class LocalCache {
|
|
|
- static setCath(key: string, value: any) {
|
|
|
+ static setCath(key, value) {
|
|
|
window.localStorage.setItem(key, JSON.stringify(value));
|
|
|
}
|
|
|
- static getCache(key: string) {
|
|
|
+ static getCache(key) {
|
|
|
const value = window.localStorage.getItem(key);
|
|
|
return value ? JSON.parse(value) : {};
|
|
|
}
|
|
|
- static deleteCatch(key: string) {
|
|
|
+ static deleteCatch(key) {
|
|
|
window.localStorage.removeItem(key);
|
|
|
}
|
|
|
static clearCache() {
|
|
@@ -50,7 +47,7 @@ export const getPreviewPath = (fileObjectKey = '') => {
|
|
|
return baseUrl + basePrefix + "/auth/t/queryFiles?fileName=" + new Date().getTime() + ".pdf&fileObjectKey=" + fileObjectKey;
|
|
|
}
|
|
|
|
|
|
-export const getQueryParamsAsObject = (url?: string) => {
|
|
|
+export const getQueryParamsAsObject = (url) => {
|
|
|
url = url || window.location.href;
|
|
|
|
|
|
const queryString = url.split('?')[1];
|
|
@@ -61,7 +58,7 @@ export const getQueryParamsAsObject = (url?: string) => {
|
|
|
|
|
|
const queryParams = queryString.split('&');
|
|
|
|
|
|
- const paramsObj:IUrlParams = {};
|
|
|
+ const paramsObj = {};
|
|
|
|
|
|
queryParams.forEach(function(param) {
|
|
|
const parts = param.split('=');
|
|
@@ -77,10 +74,10 @@ export const getQueryParamsAsObject = (url?: string) => {
|
|
|
* 复制文本
|
|
|
* @param options
|
|
|
*/
|
|
|
-export function copyText(options: { text: string; origin?: boolean }) {
|
|
|
+export function copyText(options) {
|
|
|
const props = { origin: true, ...options }
|
|
|
|
|
|
- let input: HTMLInputElement | HTMLTextAreaElement
|
|
|
+ let input;
|
|
|
|
|
|
if (props.origin) {
|
|
|
input = document.createElement('textarea')
|
|
@@ -97,7 +94,7 @@ export function copyText(options: { text: string; origin?: boolean }) {
|
|
|
}
|
|
|
|
|
|
|
|
|
-export const upLoadImageFun = async (targe:any) => {
|
|
|
+export const upLoadImageFun = async (targe) => {
|
|
|
const file = targe.files[0]; // 获取上传的文件
|
|
|
const allowedTypes = [
|
|
|
"image/png",
|
|
@@ -130,4 +127,18 @@ export const upLoadImageFun = async (targe:any) => {
|
|
|
} catch (error) {
|
|
|
return "";
|
|
|
}
|
|
|
-};
|
|
|
+};
|
|
|
+
|
|
|
+// 简易版防抖
|
|
|
+export const debounce = (func, wait) => {
|
|
|
+ let timeout = null;
|
|
|
+
|
|
|
+ return function() {
|
|
|
+ const context = this;
|
|
|
+ const args = arguments;
|
|
|
+ clearTimeout(timeout);
|
|
|
+ timeout = setTimeout(function() {
|
|
|
+ func.apply(context, args);
|
|
|
+ }, wait);
|
|
|
+ };
|
|
|
+}
|