diff --git a/docs/zh-CN/api/ams-config.md b/docs/zh-CN/api/ams-config.md index 97bdf5fe..d70dc2b3 100644 --- a/docs/zh-CN/api/ams-config.md +++ b/docs/zh-CN/api/ams-config.md @@ -29,12 +29,14 @@ ams.config({ return res; }, - // 全局默认withCredentials,请求接口是否携带cookie - withCredentials: true, - // 全局默认contentType json | form - contentType: 'json', - // 全局成功code - successCode: 0 + api: { + // 全局默认withCredentials,请求接口是否携带cookie + withCredentials: true, + // 全局默认contentType json | form + contentType: 'json', + // 全局成功code + successCode: 0 + } } }) ``` \ No newline at end of file diff --git a/docs/zh-CN/api/getstart.md b/docs/zh-CN/api/getstart.md index 2a2ac4f2..9569d5a5 100644 --- a/docs/zh-CN/api/getstart.md +++ b/docs/zh-CN/api/getstart.md @@ -10,7 +10,7 @@ 注意要先引入vue element-ui的依赖 ```html - + ``` diff --git a/docs/zh-CN/api/quickstart.md b/docs/zh-CN/api/quickstart.md index 79157161..d0350c6a 100644 --- a/docs/zh-CN/api/quickstart.md +++ b/docs/zh-CN/api/quickstart.md @@ -44,7 +44,7 @@ Vue.use(ams); - + ``` 尝试AMS的最简单的方式是使用[JSRUN上的官方入门Demo](http://jsrun.net/sehKp/edit?utm_source=website)。你可以在浏览器新标签页中打开它,跟着例子学习一些基础用法。 diff --git a/docs/zh-CN/api/template.md b/docs/zh-CN/api/template.md index 34bdb6a4..0ebdd04e 100644 --- a/docs/zh-CN/api/template.md +++ b/docs/zh-CN/api/template.md @@ -19,7 +19,7 @@ Template: Template 模板 - + diff --git a/src/fields/common/text-edit.vue b/src/fields/common/text-edit.vue index 4bc8423d..61bf54ee 100644 --- a/src/fields/common/text-edit.vue +++ b/src/fields/common/text-edit.vue @@ -1,12 +1,17 @@ + diff --git a/src/operations/filter/index.js b/src/operations/filter/index.js new file mode 100644 index 00000000..f6c6eeec --- /dev/null +++ b/src/operations/filter/index.js @@ -0,0 +1,8 @@ +import operation from './filter'; + +export default { + type: 'filter', + install(Vue) { + Vue.component(`ams-operation-${this.type}`, operation); + } +}; diff --git a/src/utils/index.js b/src/utils/index.js index c6f02244..0d3a5bd2 100644 --- a/src/utils/index.js +++ b/src/utils/index.js @@ -3,6 +3,7 @@ export * from './date'; export * from './dom'; export * from './function'; export * from './tools'; +export * from './localstorage'; export function get(object, path) { path = path.split('.'); diff --git a/src/utils/localstorage.js b/src/utils/localstorage.js new file mode 100644 index 00000000..be41f247 --- /dev/null +++ b/src/utils/localstorage.js @@ -0,0 +1,50 @@ +import ams from '../ams'; +const PREFIX = 'AMS_'; +const storage = window.localStorage; +/** + * 把数据序列化为 JSON 后存储、读取 + */ +const getAppName = () => { + const appName = ams.configs.appName; + if (appName) { + return appName.toLocaleUpperCase() + '_'; + } + return ''; +}; +export const LocalStorage = { + /** + * @param {string} key + * @param {any} val + */ + set(key, val) { + if (typeof val === 'undefined') { + storage.removeItem(key); + } else { + try { + storage.setItem(PREFIX + getAppName() + key, JSON.stringify(val)); + } catch (e) { + console.error('localStorage的空间已满,问题详情:', e); + } + } + }, + + /** + * @param {string} key + * @return {any} 若为 JSON 格式,则返回 parse 后的结果,否则返回原字符串 + */ + get(key) { + const string = storage.getItem(PREFIX + getAppName() + key); + try { + return JSON.parse(string); + } catch (e) { + return string; + } + }, + + /** + * @param {string} key + */ + remove(key) { + storage.removeItem(PREFIX + key); + } +};