|
| 1 | +# Python Module Feature Toggle - Implementation Summary |
| 2 | + |
| 3 | +## Changes Made |
| 4 | + |
| 5 | +### 1. Environment Variable Configuration |
| 6 | +**File**: `.env` |
| 7 | +- Added `VUE_APP_ENABLE_PYTHON_MODULE=false` (default disabled) |
| 8 | +- This controls whether the Python Module feature is available |
| 9 | + |
| 10 | +### 2. Router Configuration |
| 11 | +**File**: `src/apps/linkis/router.js` |
| 12 | + |
| 13 | +**Changes**: |
| 14 | +- Added environment variable check: `export const isPythonModuleEnabled = process.env.VUE_APP_ENABLE_PYTHON_MODULE === 'true'` |
| 15 | +- Modified pythonModule route to be conditionally loaded: |
| 16 | + ```javascript |
| 17 | + ...(isPythonModuleEnabled ? [{ |
| 18 | + name: 'pythonModule', |
| 19 | + path: 'pythonModule', |
| 20 | + component: () => import('./module/pythonModule/index.vue'), |
| 21 | + meta: { |
| 22 | + title: 'pythonModule', |
| 23 | + publicPage: true, |
| 24 | + }, |
| 25 | + }] : []), |
| 26 | + ``` |
| 27 | + |
| 28 | +### 3. View Component Updates |
| 29 | +**File**: `src/apps/linkis/view/linkis/index.vue` |
| 30 | + |
| 31 | +**Changes**: |
| 32 | +- Imported `isPythonModuleEnabled` from router |
| 33 | +- Added to component data: `isPythonModuleEnabled: isPythonModuleEnabled` |
| 34 | +- Modified sidebar menu visibility condition to hide Python Module when disabled: |
| 35 | + ```javascript |
| 36 | + v-if="(!isLogAdmin? ...) && (item.key !== '1-13' || isPythonModuleEnabled)" |
| 37 | + ``` |
| 38 | +- Updated default redirect logic in `mounted()`: |
| 39 | + ```javascript |
| 40 | + if(!localStorage.getItem('hasRead')) { |
| 41 | + if (isPythonModuleEnabled) { |
| 42 | + this.clickToRoute('1-13-1') // Python Module |
| 43 | + } else { |
| 44 | + this.clickToRoute('1-1') // Global History |
| 45 | + } |
| 46 | + } |
| 47 | + ``` |
| 48 | + |
| 49 | +## Feature Behavior |
| 50 | + |
| 51 | +### When VUE_APP_ENABLE_PYTHON_MODULE=false (Default) |
| 52 | +✅ **Recommended for users without WeBank npm registry access** |
| 53 | + |
| 54 | +- Python Module route is NOT registered |
| 55 | +- Python Module menu item is HIDDEN from sidebar |
| 56 | +- After login, users are redirected to **Global History** page |
| 57 | +- Accessing `/console/pythonModule` directly will show 404 error |
| 58 | +- No dependency on internal `@webank` packages required |
| 59 | + |
| 60 | +### When VUE_APP_ENABLE_PYTHON_MODULE=true |
| 61 | +⚠️ **Requires WeBank internal npm registry access** |
| 62 | + |
| 63 | +- Python Module route is registered |
| 64 | +- Python Module menu item is VISIBLE in sidebar |
| 65 | +- After login, users are redirected to **Python Module** page (if first time) |
| 66 | +- Accessing `/console/pythonModule` directly works normally |
| 67 | +- Requires successful build of PythonModule sub-application |
| 68 | + |
| 69 | +## Testing |
| 70 | + |
| 71 | +To test the feature toggle: |
| 72 | + |
| 73 | +### Test 1: Disabled State (Default) |
| 74 | +```bash |
| 75 | +# 1. Ensure .env has VUE_APP_ENABLE_PYTHON_MODULE=false |
| 76 | +cat linkis-web/.env | grep VUE_APP_ENABLE_PYTHON_MODULE |
| 77 | + |
| 78 | +# 2. Rebuild |
| 79 | +cd linkis-web |
| 80 | +npm run build |
| 81 | + |
| 82 | +# 3. Verify behavior: |
| 83 | +# - Python Module menu should NOT appear in sidebar |
| 84 | +# - Login should redirect to Global History |
| 85 | +# - /console/pythonModule should return 404 |
| 86 | +``` |
| 87 | + |
| 88 | +### Test 2: Enabled State |
| 89 | +```bash |
| 90 | +# 1. Update .env |
| 91 | +echo "VUE_APP_ENABLE_PYTHON_MODULE=true" >> linkis-web/.env |
| 92 | + |
| 93 | +# 2. Rebuild |
| 94 | +cd linkis-web |
| 95 | +npm run build |
| 96 | + |
| 97 | +# 3. Verify behavior: |
| 98 | +# - Python Module menu should appear in sidebar |
| 99 | +# - Login should redirect to Python Module |
| 100 | +# - /console/pythonModule should work (if built) |
| 101 | +``` |
| 102 | + |
| 103 | +## Migration Notes |
| 104 | + |
| 105 | +- **Backward Compatibility**: Default is `false`, so existing deployments won't be affected |
| 106 | +- **No Breaking Changes**: All other features remain unchanged |
| 107 | +- **Easy Rollback**: Simply set `VUE_APP_ENABLE_PYTHON_MODULE=false` and rebuild |
| 108 | + |
| 109 | +## Documentation |
| 110 | + |
| 111 | +- Detailed configuration guide: `PYTHON_MODULE_CONFIG.md` |
| 112 | +- This summary document: `PYTHON_MODULE_CHANGES.md` |
| 113 | + |
| 114 | +## Next Steps |
| 115 | + |
| 116 | +For users who want to enable Python Module: |
| 117 | +1. Obtain access to WeBank internal npm registry |
| 118 | +2. Configure `.npmrc` with registry credentials |
| 119 | +3. Set `VUE_APP_ENABLE_PYTHON_MODULE=true` in `.env` |
| 120 | +4. Run `npm run installAll` to install all dependencies |
| 121 | +5. Run `npm run buildSubModule` to build Python Module |
| 122 | +6. Run `npm run build` to build main application |
0 commit comments