From 49f99bdd4b08fbbe692efdfe52ae3ca29f4e8c6c Mon Sep 17 00:00:00 2001 From: Tevin <tingquanren@163.com> Date: Tue, 12 Jul 2022 14:57:05 +0800 Subject: [PATCH] 增加跳转页面选择组件 --- bases/HostBoot.js | 24 ++++++++++++++++++++++-- 1 files changed, 22 insertions(+), 2 deletions(-) diff --git a/bases/HostBoot.js b/bases/HostBoot.js index 41a9460..6907708 100644 --- a/bases/HostBoot.js +++ b/bases/HostBoot.js @@ -5,6 +5,7 @@ import project from '@project'; import { Tools } from '@components/common/Tools'; +import { $localStorage } from '@components/common/LocalStorage'; export class HostBoot { @@ -27,9 +28,9 @@ /** * 创建主机类型 * @param {string} typeName - * @param {boolean} [isDefault=false] + * @param {string} [isDefault=''] */ - createHostType(typeName, isDefault = false) { + createHostType(typeName, isDefault = '') { if (isDefault === 'default') { this._data.defaultHostType = typeName; } @@ -93,6 +94,11 @@ type: typeName, }; } + // 如果有缓存,优先使用缓存 + const storageHostTypes = $localStorage.load('HostType'); + if (typeof storageHostTypes[typeName] !== 'undefined') { + this._data.activeHost[typeName] = storageHostTypes[typeName]; + } } _matchHostName(host) { @@ -129,8 +135,18 @@ host: host2, type: typeName, }; + // 存储自定义主机配置 + const storageHostTypes = $localStorage.load('HostType'); + storageHostTypes[typeName] = this._data.activeHost[typeName]; + $localStorage.save('HostType', storageHostTypes); } + /** + * 清除主机类型缓存 + */ + cleanHostStorage() { + $localStorage.remove('HostType'); + } /** * 判断是否为本地开发模式 @@ -171,6 +187,10 @@ return this._data.activeHost[typeName].name; } + /** + * 是否开启本地 mock + * @return {boolean} + */ isOnMock() { if (this.isDevMod()) { return this.getHostName() === 'lc'; -- Gitblit v1.9.1