diff --git a/linkis-web/.env b/linkis-web/.env index 4660cdface..5f7be0422c 100644 --- a/linkis-web/.env +++ b/linkis-web/.env @@ -1,5 +1,7 @@ VUE_APP_HOST= -BACKEND_URL=http://127.0.0.1:9001 VUE_APP_MN_CONFIG_PREFIX= VUE_APP_MN_CONFIG_SOCKET=/ws/api/entrance/connect VUE_APP_VERSION=1.8.0 +# Enable or disable Python Module feature (true/false) +# Set to false if you cannot access @webank internal npm packages +VUE_APP_ENABLE_PYTHON_MODULE=false diff --git a/linkis-web/.gitignore b/linkis-web/.gitignore index 89cc5767eb..8f5fdeb918 100644 --- a/linkis-web/.gitignore +++ b/linkis-web/.gitignore @@ -2,11 +2,12 @@ .vscode .cache .idea/ +.fes node_modules/ dist/ -package-lock.json apache-linkis-*.tar.gz ./cn.json .env.* +package-lock.json diff --git a/linkis-web/PYTHON_MODULE_CHANGES.md b/linkis-web/PYTHON_MODULE_CHANGES.md new file mode 100644 index 0000000000..c5389aacd8 --- /dev/null +++ b/linkis-web/PYTHON_MODULE_CHANGES.md @@ -0,0 +1,122 @@ +# Python Module Feature Toggle - Implementation Summary + +## Changes Made + +### 1. Environment Variable Configuration +**File**: `.env` +- Added `VUE_APP_ENABLE_PYTHON_MODULE=false` (default disabled) +- This controls whether the Python Module feature is available + +### 2. Router Configuration +**File**: `src/apps/linkis/router.js` + +**Changes**: +- Added environment variable check: `export const isPythonModuleEnabled = process.env.VUE_APP_ENABLE_PYTHON_MODULE === 'true'` +- Modified pythonModule route to be conditionally loaded: + ```javascript + ...(isPythonModuleEnabled ? [{ + name: 'pythonModule', + path: 'pythonModule', + component: () => import('./module/pythonModule/index.vue'), + meta: { + title: 'pythonModule', + publicPage: true, + }, + }] : []), + ``` + +### 3. View Component Updates +**File**: `src/apps/linkis/view/linkis/index.vue` + +**Changes**: +- Imported `isPythonModuleEnabled` from router +- Added to component data: `isPythonModuleEnabled: isPythonModuleEnabled` +- Modified sidebar menu visibility condition to hide Python Module when disabled: + ```javascript + v-if="(!isLogAdmin? ...) && (item.key !== '1-13' || isPythonModuleEnabled)" + ``` +- Updated default redirect logic in `mounted()`: + ```javascript + if(!localStorage.getItem('hasRead')) { + if (isPythonModuleEnabled) { + this.clickToRoute('1-13-1') // Python Module + } else { + this.clickToRoute('1-1') // Global History + } + } + ``` + +## Feature Behavior + +### When VUE_APP_ENABLE_PYTHON_MODULE=false (Default) +✅ **Recommended for users without WeBank npm registry access** + +- Python Module route is NOT registered +- Python Module menu item is HIDDEN from sidebar +- After login, users are redirected to **Global History** page +- Accessing `/console/pythonModule` directly will show 404 error +- No dependency on internal `@webank` packages required + +### When VUE_APP_ENABLE_PYTHON_MODULE=true +⚠️ **Requires WeBank internal npm registry access** + +- Python Module route is registered +- Python Module menu item is VISIBLE in sidebar +- After login, users are redirected to **Python Module** page (if first time) +- Accessing `/console/pythonModule` directly works normally +- Requires successful build of PythonModule sub-application + +## Testing + +To test the feature toggle: + +### Test 1: Disabled State (Default) +```bash +# 1. Ensure .env has VUE_APP_ENABLE_PYTHON_MODULE=false +cat linkis-web/.env | grep VUE_APP_ENABLE_PYTHON_MODULE + +# 2. Rebuild +cd linkis-web +npm run build + +# 3. Verify behavior: +# - Python Module menu should NOT appear in sidebar +# - Login should redirect to Global History +# - /console/pythonModule should return 404 +``` + +### Test 2: Enabled State +```bash +# 1. Update .env +echo "VUE_APP_ENABLE_PYTHON_MODULE=true" >> linkis-web/.env + +# 2. Rebuild +cd linkis-web +npm run build + +# 3. Verify behavior: +# - Python Module menu should appear in sidebar +# - Login should redirect to Python Module +# - /console/pythonModule should work (if built) +``` + +## Migration Notes + +- **Backward Compatibility**: Default is `false`, so existing deployments won't be affected +- **No Breaking Changes**: All other features remain unchanged +- **Easy Rollback**: Simply set `VUE_APP_ENABLE_PYTHON_MODULE=false` and rebuild + +## Documentation + +- Detailed configuration guide: `PYTHON_MODULE_CONFIG.md` +- This summary document: `PYTHON_MODULE_CHANGES.md` + +## Next Steps + +For users who want to enable Python Module: +1. Obtain access to WeBank internal npm registry +2. Configure `.npmrc` with registry credentials +3. Set `VUE_APP_ENABLE_PYTHON_MODULE=true` in `.env` +4. Run `npm run installAll` to install all dependencies +5. Run `npm run buildSubModule` to build Python Module +6. Run `npm run build` to build main application diff --git a/linkis-web/PYTHON_MODULE_CONFIG.md b/linkis-web/PYTHON_MODULE_CONFIG.md new file mode 100644 index 0000000000..6ca023b8b4 --- /dev/null +++ b/linkis-web/PYTHON_MODULE_CONFIG.md @@ -0,0 +1,95 @@ +# Python Module Feature Configuration + +## Overview + +The Python Module feature can be enabled or disabled via environment variable configuration. This feature depends on internal WeBank npm packages (`@webank/fes-design-material`, `@webank/letgo-components`) which are not publicly available. + +## Configuration + +### Environment Variable + +Edit the `.env` file in the `linkis-web` root directory: + +```bash +# Enable or disable Python Module feature (true/false) +# Set to false if you cannot access @webank internal npm packages +VUE_APP_ENABLE_PYTHON_MODULE=false +``` + +### Options + +- `VUE_APP_ENABLE_PYTHON_MODULE=true`: Enable Python Module feature + - The Python Module menu item will be displayed in the sidebar + - After login, users will be redirected to the Python Module page + - Requires access to WeBank internal npm registry to build + +- `VUE_APP_ENABLE_PYTHON_MODULE=false`: Disable Python Module feature (Default) + - The Python Module menu item will be hidden from the sidebar + - After login, users will be redirected to the Global History page + - No special npm registry access required + +## Implementation Details + +### Modified Files + +1. **`.env`**: Added `VUE_APP_ENABLE_PYTHON_MODULE` environment variable +2. **`src/apps/linkis/router.js`**: + - Added `isPythonModuleEnabled` constant + - Conditionally load pythonModule route +3. **`src/apps/linkis/view/linkis/index.vue`**: + - Import `isPythonModuleEnabled` from router + - Conditionally display pythonModule in sidebar menu + - Modified default redirect logic based on feature flag + +### Behavior + +When `VUE_APP_ENABLE_PYTHON_MODULE=false`: +- ❌ Python Module route is not registered +- ❌ Python Module menu item is hidden +- ✅ Users are redirected to Global History page after login +- ✅ Direct access to `/console/pythonModule` will show 404 + +When `VUE_APP_ENABLE_PYTHON_MODULE=true`: +- ✅ Python Module route is registered +- ✅ Python Module menu item is visible +- ✅ Users are redirected to Python Module page after login (if not `hasRead`) +- ✅ Direct access to `/console/pythonModule` works + +## Building + +After changing the environment variable: + +```bash +# Rebuild the project +cd linkis-web +npm run build +``` + +## For Internal Users + +If you have access to WeBank's internal npm registry: + +1. Set `VUE_APP_ENABLE_PYTHON_MODULE=true` in `.env` +2. Configure npm registry (contact your administrator for registry URL) +3. Install dependencies: `npm run installAll` +4. Build PythonModule: `npm run buildSubModule` +5. Build main application: `npm run build` + +## Troubleshooting + +### Issue: 404 Error when accessing Python Module + +**Solution**: Check that `VUE_APP_ENABLE_PYTHON_MODULE=true` and rebuild the application + +### Issue: Python Module menu not showing + +**Solution**: +1. Verify `.env` has `VUE_APP_ENABLE_PYTHON_MODULE=true` +2. Clear browser cache +3. Rebuild: `npm run build` + +### Issue: Cannot install dependencies for PythonModule + +**Solution**: +1. Set `VUE_APP_ENABLE_PYTHON_MODULE=false` to disable the feature +2. Or configure access to WeBank internal npm registry diff --git a/linkis-web/package.json b/linkis-web/package.json index 4ee88e7d5e..52984ce787 100644 --- a/linkis-web/package.json +++ b/linkis-web/package.json @@ -8,7 +8,9 @@ "lint": "vue-cli-service lint --no-fix", "fix": "eslint --ext .js,.vue src --fix", "precommit": "lint-staged", - "preinstall": "npm install --package-lock-only --ignore-scripts && npx npm-force-resolutions" + "preinstall": "npm install --package-lock-only --ignore-scripts && npx npm-force-resolutions", + "buildSubModule": "cd src/apps/PythonModule && npm run build:prod && cd ../../..", + "installAll": "npm install && cd src/apps/PythonModule && npm install --legacy-peer-deps && cd ../../.." }, "husky": { "hooks": { @@ -23,55 +25,58 @@ }, "dependencies": { "@form-create/iview": "2.5.27", - "axios": "1.12.0", - "babel-polyfill": "6.26.0", - "core-js": "3.27.2", + "axios": "1.12.2", "dexie": "3.2.3", "dt-sql-parser": "3.0.5", - "eslint": "7.21.0", - "eslint-plugin-vue": "9.6.0", + "echarts": "^5.6.0", "highlight.js": "10.7.0", + "hint.css": "^2.7.0", "iview": "3.5.4", "jsencrypt": "3.2.1", "lodash": "4.17.21", "md5": "2.3.0", - "mitt": "1.2.0", "moment": "2.29.4", "monaco-editor": "0.30.1", "object-to-formdata": "4.2.2", "path-browserify": "1.0.1", - "postcss": "8.4.31", "qs": "6.11.0", "reconnecting-websocket": "4.4.0", + "sass": "1.77.8", "sql-formatter": "2.3.3", "svgo": "3.0.2", "v-jsoneditor": "1.4.5", - "vue": "3.0.0", + "vue": "2.6.12", "vue-i18n": "8.22.1", "vue-router": "3.4.8", "vuedraggable": "2.24.3", "vuescroll": "4.16.1", "worker-loader": "3.0.8", - "echarts": "^5.1.1" + "xterm": "5.3.0", + "xterm-addon-fit": "0.8.0" }, "devDependencies": { "@intlify/vue-i18n-loader": "1.0.0", - "@vue/cli-plugin-babel": "5.0.8", + "@vue/cli-plugin-babel": "5.0.1", "@vue/cli-plugin-eslint": "5.0.8", "@vue/cli-service": "5.0.8", "@vue/eslint-config-standard": "4.0.0", "archiver": "3.1.1", "autoprefixer": "10.4.14", "babel-eslint": "10.1.0", + "babel-polyfill": "6.26.0", "copy-webpack-plugin": "9.1.0", + "core-js": "3.27.2", "csp-html-webpack-plugin": "5.1.0", + "eslint": "7.21.0", + "eslint-plugin-vue": "9.6.0", "filemanager-webpack-plugin": "7.0.0", "husky": "1.3.1", "lint-staged": "13.1.1", "material-design-icons": "3.0.1", + "mitt": "1.2.0", "monaco-editor-webpack-plugin": "6.0.0", - "node-sass": "8.0.0", "npm-force-resolutions": "0.0.10", + "postcss": "8.4.21", "sass-loader": "10.4.1", "svg-sprite-loader": "6.0.0", "vue-cli-plugin-mockjs": "0.1.3", @@ -79,6 +84,6 @@ "webpack-virtual-modules": "0.3.2" }, "resolutions": { - "postcss": "8.4.31" + "postcss": "8.4.21" } } diff --git a/linkis-web/src/apps/PythonModule/.gitattributes b/linkis-web/src/apps/PythonModule/.gitattributes new file mode 100644 index 0000000000..ec8935df7d --- /dev/null +++ b/linkis-web/src/apps/PythonModule/.gitattributes @@ -0,0 +1,9 @@ +* text=auto +* text eol=lf +*.png binary +*.gif binary +*.ttf binary +*.woff binary +*.eot binary +*.woff binary +*.otf binary \ No newline at end of file diff --git a/linkis-web/src/apps/PythonModule/index.html b/linkis-web/src/apps/PythonModule/index.html index a015c28931..14b2fef00a 100644 --- a/linkis-web/src/apps/PythonModule/index.html +++ b/linkis-web/src/apps/PythonModule/index.html @@ -15,7 +15,7 @@ ~ limitations under the License. --> - + diff --git a/linkis-web/src/apps/PythonModule/package.json b/linkis-web/src/apps/PythonModule/package.json new file mode 100644 index 0000000000..d01518360b --- /dev/null +++ b/linkis-web/src/apps/PythonModule/package.json @@ -0,0 +1,32 @@ +{ + "dependencies": { + "core-js": "3.35.1", + "vue": "3.3.9", + "@vueuse/core": "10.9.0", + "lodash-es": "4.17.21", + "@qlin/request": "0.2.6", + "@webank/letgo-components": "1.1.4", + "@fesjs/fes-design": "0.8.60", + "@webank/fes-design-material": "0.2.31", + "@fesjs/traction-widget": "1.9.1", + "dayjs": "1.11.9", + "lodash": "4.17.21", + "@fesjs/fes": "3.1.10", + "@fesjs/plugin-model": "3.0.1", + "@fesjs/plugin-request": "4.0.0-rc.3", + "@fesjs/plugin-locale": "4.2.5", + "@fesjs/builder-vite": "4.0.2" + }, + "name": "linkis", + "version": "1.0.0", + "scripts": { + "build:test": "cross-env FES_ENV=test fes build", + "build:prod": "cross-env FES_ENV=prod fes build", + "analyze": "cross-env ANALYZE=1 fes build", + "dev": "fes dev" + }, + "devDependencies": { + "typescript": "5.3.3", + "cross-env": "7.0.3" + } +} \ No newline at end of file diff --git a/linkis-web/src/apps/PythonModule/public/logo.svg b/linkis-web/src/apps/PythonModule/public/logo.svg new file mode 100644 index 0000000000..210841be54 --- /dev/null +++ b/linkis-web/src/apps/PythonModule/public/logo.svg @@ -0,0 +1,33 @@ + + + 编组 11 + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/linkis-web/src/apps/PythonModule/tsconfig.json b/linkis-web/src/apps/PythonModule/tsconfig.json new file mode 100644 index 0000000000..5ccb046d8a --- /dev/null +++ b/linkis-web/src/apps/PythonModule/tsconfig.json @@ -0,0 +1,33 @@ +{ + "compilerOptions": { + "module": "esnext", + "target": "esnext", + "lib": [ + "esnext", + "dom" + ], + "sourceMap": true, + "baseUrl": ".", + "jsx": "preserve", + "allowSyntheticDefaultImports": true, + "moduleResolution": "node", + "forceConsistentCasingInFileNames": true, + "noImplicitReturns": true, + "noUnusedLocals": true, + "allowJs": true, + "experimentalDecorators": true, + "strict": true, + "paths": { + "@/*": [ + "./src/*" + ], + "@@/*": [ + "./src/.fes/*" + ] + } + }, + "include": [ + "src", + "package.json" + ] +} \ No newline at end of file diff --git a/linkis-web/src/apps/URM/i18n/common/en.json b/linkis-web/src/apps/URM/i18n/common/en.json index f6f8319cc8..89ab41bc82 100644 --- a/linkis-web/src/apps/URM/i18n/common/en.json +++ b/linkis-web/src/apps/URM/i18n/common/en.json @@ -60,6 +60,7 @@ "no": "No", "sprak": "sprak", "jarPackage": "jar Package", + "registerFunc": "Register Function", "scriptPath": "Script Path", "registerFunction": "Register Function", "registerFormat": "Register Format", @@ -88,7 +89,8 @@ "XGHS": "Update Funtion", "XG": "Update", "QPZS": "View in Full Screen", - "QXQP": "Cancel Full Screen" + "QXQP": "Cancel Full Screen", + "XZHS": "Select Function" } } } diff --git a/linkis-web/src/apps/URM/i18n/common/zh.json b/linkis-web/src/apps/URM/i18n/common/zh.json index 942c66a7e2..becc40b4fe 100644 --- a/linkis-web/src/apps/URM/i18n/common/zh.json +++ b/linkis-web/src/apps/URM/i18n/common/zh.json @@ -60,6 +60,7 @@ "no": "否", "sprak": "sprak", "jarPackage": "jar包", + "registerFunc": "注册函数", "scriptPath": "脚本路径", "registerFunction": "注册的函数", "registerFormat": "注册格式", @@ -88,7 +89,8 @@ "XGHS": "修改函数", "XG": "修改", "QPZS": "全屏展示", - "QXQP": "取消全屏" + "QXQP": "取消全屏", + "XZHS": "选择函数" } } } diff --git a/linkis-web/src/apps/URM/module/functionManagement/addFunctionModal.vue b/linkis-web/src/apps/URM/module/functionManagement/addFunctionModal.vue index 10fb4e2344..a12a1abac2 100644 --- a/linkis-web/src/apps/URM/module/functionManagement/addFunctionModal.vue +++ b/linkis-web/src/apps/URM/module/functionManagement/addFunctionModal.vue @@ -5,15 +5,15 @@ ~ The ASF licenses this file to You under the Apache License, Version 2.0 ~ (the "License"); you may not use this file except in compliance with ~ the License. You may obtain a copy of the License at - ~ + ~ ~ http://www.apache.org/licenses/LICENSE-2.0 - ~ + ~ ~ Unless required by applicable law or agreed to in writing, software ~ distributed under the License is distributed on an "AS IS" BASIS, ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ~ See the License for the specific language governing permissions and ~ limitations under the License. - --> +-->