|
@@ -6,6 +6,7 @@
|
|
|
添加组件方式:
|
|
|
<smart-endpoint-toggle-button
|
|
|
prefix="[your-prefix]"
|
|
|
+ regexGate="[regs]" -- 正则匹配接口路径如/his/store/productList 可填写/his/store 支持多个逗号分割
|
|
|
component-name="[your-component-name]">
|
|
|
</smart-endpoint-toggle-button>
|
|
|
提供可用的回调
|
|
@@ -38,6 +39,11 @@ export default {
|
|
|
type: String,
|
|
|
required: true
|
|
|
},
|
|
|
+ //regexGate:只对特定路径使用
|
|
|
+ regexGate: {
|
|
|
+ type: String,
|
|
|
+ required: true
|
|
|
+ },
|
|
|
// 组件名称,用于生成唯一标识
|
|
|
componentName: {
|
|
|
type: String,
|
|
@@ -56,25 +62,21 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
created() {
|
|
|
- console.log('SmartEndpointToggleButton created');
|
|
|
// 生成基于组件名和路由的唯一状态键
|
|
|
this.stateKey = this.generateStateKey()
|
|
|
// 初始化状态
|
|
|
this.initializeState()
|
|
|
},
|
|
|
activated() {
|
|
|
- console.log('SmartEndpointToggleButton activated,stateKey='+this.stateKey+',prefix='+this.prefix+',is='+this.isUsingNewEndpoint);
|
|
|
setActive(this.stateKey);
|
|
|
// 页面激活时恢复状态
|
|
|
this.restoreState()
|
|
|
},
|
|
|
deactivated() {
|
|
|
- console.log('SmartEndpointToggleButton deactivated');
|
|
|
// 页面失活时保存状态
|
|
|
this.saveState()
|
|
|
},
|
|
|
destroyed() {
|
|
|
- console.log('SmartEndpointToggleButton destroyed');
|
|
|
// 组件销毁
|
|
|
resetEndpoint(this.stateKey)
|
|
|
},
|
|
@@ -99,6 +101,7 @@ export default {
|
|
|
try {
|
|
|
const state = {
|
|
|
prefix: this.prefix,
|
|
|
+ regexGate: this.regexGate,
|
|
|
isUsingNewEndpoint: this.isUsingNewEndpoint,
|
|
|
timestamp: Date.now()
|
|
|
}
|