no message

This commit is contained in:
小陌 2023-07-07 12:35:25 +08:00
parent 7db9708231
commit 8ae965de48
7 changed files with 32 additions and 51 deletions

View File

@ -1,8 +1,9 @@
import http from "@/utils/request" import http from "@/utils/request"
export default { export default {
upload: { upload: {
url: '/app/upload',
post: async function(data, config = {}) { post: async function(data, config = {}) {
return await http.post('/app/upload', data, config); return await http.post(this.url, data, config);
} }
}, },
uploadFile: { uploadFile: {

View File

@ -6,10 +6,10 @@ export default {
} }
}, },
table: { table: {
get: async function(name = '', config = {}) { get: async function(name = '') {
return await http.get('/system/table/get', { return await http.get('/system/table/get', {
name name
}, config); }, {cache:true});
} }
}, },
} }

View File

@ -1,22 +1,20 @@
export default { export default {
state: { state: {
cacheList: {} cacheList: {}
},
mutations: {
setCache(state, { name, value }) {
state.cacheList[name] = value;
}, },
getCache(state, name) { mutations: {
if (!Object.prototype.hasOwnProperty.call(state.cacheList, name)) { setCache(state, payload) {
state.cacheList[name] = null; const {
} key,
return state.cacheList[name]; value
}, } = payload;
removeCache(state, name) { state.cacheList[key] = value;
delete state.cacheList[name]; },
}, removeCache(state, key) {
clearCache(state) { delete state.cacheList[key];
state.cacheList = {}; },
clearCache(state) {
state.cacheList = {};
}
} }
}
} }

View File

@ -1,17 +1,16 @@
import config from "@/config"; import config from "@/config";
import tool from "@/utils/tool";
export default { export default {
state: { state: {
//移动端布局 //移动端布局
ismobile: false, ismobile: false,
//布局 //布局
layout: tool.data.get('layout') || config.LAYOUT, layout: config.LAYOUT,
//菜单是否折叠 toggle //菜单是否折叠 toggle
menuIsCollapse: tool.data.get('layoutmenuiscollapse') || config.MENU_IS_COLLAPSE || false, menuIsCollapse: config.MENU_IS_COLLAPSE || false,
//多标签栏 //多标签栏
layoutTags: tool.data.get('layouttags') || config.LAYOUT_TAGS, layoutTags: config.LAYOUT_TAGS,
//显示页头 //显示页头
layoutHeader: tool.data.get('layoutheader') || true, layoutHeader: true,
}, },
mutations: { mutations: {
SET_ismobile(state, key) { SET_ismobile(state, key) {

View File

@ -91,13 +91,9 @@ var http = {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
// 缓存存在, 优先使用缓存 // 缓存存在, 优先使用缓存
var cacheKey = ''; var cacheKey = '';
if (typeof config.cache !== 'undefined' && !isNaN(config.cache) && config.cache > 0) { if (typeof config.cache !== 'undefined' && config.cache) {
cacheKey = tool.crypto.MD5(url + (new URLSearchParams(params)).toString()); cacheKey = tool.crypto.MD5(url + (new URLSearchParams(params)).toString());
const cachedData = tool.store.get(cacheKey);
const cachedData = tool.data.get(cacheKey);
if (cachedData) { if (cachedData) {
return resolve(cachedData); return resolve(cachedData);
} }
@ -108,8 +104,8 @@ var http = {
params: params, params: params,
...config ...config
}).then((response) => { }).then((response) => {
if (cacheKey && typeof config.cache !== 'undefined' && !isNaN(config.cache) && config.cache > 0) { if (cacheKey && typeof config.cache !== 'undefined' && config.cache) {
tool.data.set(cacheKey, response.data, config.cache); tool.store.set(cacheKey, response.data);
} }
resolve(response.data); resolve(response.data);
}).catch((error) => { }).catch((error) => {

View File

@ -1,8 +1,5 @@
/* /*
* @Descripttion: 工具集 * @Descripttion: 工具集
* @version: 1.2
* @LastEditors: sakuya
* @LastEditTime: 2022年5月24日00:28:56
*/ */
import CryptoJS from 'crypto-js'; import CryptoJS from 'crypto-js';
import sysConfig from "@/config"; import sysConfig from "@/config";
@ -13,14 +10,13 @@ const tool = {}
/* store */ /* store */
tool.store = { tool.store = {
set(key, data) { set(key, data) {
return store.commit('setCache', key, data); return store.commit('setCache', {key:key, value:data});
}, },
get(key) { get(key) {
try { if (!Object.prototype.hasOwnProperty.call(store.state.cache.cacheList, key)) {
return store.commit('getCache', key); store.state.cache.cacheList[key] = null;
} catch (err) {
return null
} }
return store.state.cache.cacheList[key];
}, },
remove(key) { remove(key) {
return store.commit('removeCache', key); return store.commit('removeCache', key);

View File

@ -106,15 +106,6 @@
} }
}); });
} }
this.$tool.store.set('cacheKey', {uid:1});
console.log(this.$tool.store.get('cacheKey'))
}, },
computed: { computed: {
filterObj(){ filterObj(){