diff --git a/.editorconfig b/.editorconfig index 5760be583..319299684 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,12 +1,13 @@ -# http://editorconfig.org root = true [*] indent_style = space indent_size = 2 +end_of_line = lf charset = utf-8 trim_trailing_whitespace = true insert_final_newline = true +quote_type = single [*.md] trim_trailing_whitespace = false diff --git a/.eslintignore b/.eslintignore index e1184ee65..7d1137ffe 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,23 +1,20 @@ # 忽略目录 -build/ -tests/ -demo/ -.ice/ -def-login-client/ - -# node 覆盖率文件 -coverage/ +build +lib +es +dist +tests +demo node_modules -extensions/*/build/ +.ice +def-login-client +coverage/ .vscode-test -packages/*/lib/ -packages/*/es/ -packages/*/build/ -app/main_dist/ -app/build/ tmp .tmp __mocks__ +out +__tests__ # 忽略文件 **/*-min.js diff --git a/.eslintrc.js b/.eslintrc.js index 5d752f2f4..76643ef43 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,47 +1,7 @@ -const { eslint, tslint, deepmerge } = require('@ice/spec'); - -const commonRules = { - 'react/jsx-filename-extension': [1, { extensions: ['.js', '.jsx', '.tsx'] }], - 'react/jsx-no-target-blank': [0], - '@typescript-eslint/indent': 0, - 'prefer-object-spread': 0, - 'max-classes-per-file': 0, - 'class-methods-use-this': 0, -}; - -const jsRules = deepmerge(eslint, { - env: { - jest: true, - }, - rules: { - ...commonRules, - }, -}); - -const tsRules = deepmerge(tslint, { - env: { - jest: true, - }, +module.exports = { + extends: 'eslint-config-ali/typescript/react', rules: { - ...commonRules, - '@typescript-eslint/no-inferrable-types': 1, - '@typescript-eslint/ban-ts-ignore': 0, - '@typescript-eslint/array-type': 0, - '@typescript-eslint/no-non-null-assertion': 0, - '@typescript-eslint/explicit-function-return-type': 0, - '@typescript-eslint/explicit-member-accessibility': 0, - '@typescript-eslint/no-parameter-properties': 0, + 'no-return-await': 1, + '@typescript-eslint/no-parameter-properties': 1, }, -}); - -delete tsRules.root; - -module.exports = { - ...jsRules, - overrides: [ - { - ...tsRules, - files: ['**/*.ts', '**/*.tsx'], - }, - ], }; diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6b67b01b4..27bd1d840 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,9 +18,6 @@ jobs: node-version: ${{ matrix.node-version }} - run: | npm run setup:packages - npm run lint - npm run prettier - npm run docs:check npm run dependency:check npm run test npm run coverage diff --git a/.gitignore b/.gitignore index f917e556d..828ccc0a7 100644 --- a/.gitignore +++ b/.gitignore @@ -10,7 +10,7 @@ node_modules .DS_Store .eslintcache .happypack -.vscode +extensions/*/web/.vscode coverage/ tmp/ .tmp/ diff --git a/.prettierrc.js b/.prettierrc.js index 03631c513..24c5859e6 100644 --- a/.prettierrc.js +++ b/.prettierrc.js @@ -1,5 +1,7 @@ -const { prettier, deepmerge } = require('@ice/spec'); - -module.exports = deepmerge(prettier, { - printWidth: 120, -}); +module.exports = { + printWidth: 100, + tabWidth: 2, + semi: true, + singleQuote: true, + trailingComma: 'all', +}; diff --git a/.stylelintignore b/.stylelintignore new file mode 100644 index 000000000..a35ef79bf --- /dev/null +++ b/.stylelintignore @@ -0,0 +1,20 @@ +# 忽略目录 +build +lib +es +dist +tests +demo +node_modules +.ice +def-login-client +coverage/ +.vscode-test +tmp +.tmp +__mocks__ +__tests__ + +# 忽略文件 +**/*-min.js +**/*.min.js diff --git a/.stylelintrc.js b/.stylelintrc.js new file mode 100644 index 000000000..74a5a54e3 --- /dev/null +++ b/.stylelintrc.js @@ -0,0 +1,3 @@ +module.exports = { + extends: 'stylelint-config-ali', +}; diff --git a/commitlint.config.js b/commitlint.config.js new file mode 100644 index 000000000..52f3b754b --- /dev/null +++ b/commitlint.config.js @@ -0,0 +1,3 @@ +module.exports = { + extends: ['ali'], +}; diff --git a/extensions/iceworks-app/CHANGELOG.md b/extensions/iceworks-app/CHANGELOG.md index ac7d3a337..30f563c73 100644 --- a/extensions/iceworks-app/CHANGELOG.md +++ b/extensions/iceworks-app/CHANGELOG.md @@ -1,5 +1,10 @@ # Change Log +## 0.5.0 + +- feat: Add Iceworks Doctor +- feat: Add welcome page + ## 0.4.10 - docs: update text for find component and generate page diff --git a/extensions/iceworks-app/package.json b/extensions/iceworks-app/package.json index 1ad41d782..e79724def 100644 --- a/extensions/iceworks-app/package.json +++ b/extensions/iceworks-app/package.json @@ -3,7 +3,7 @@ "displayName": "Iceworks Application Viewer", "description": "Quick view your Universal Application(React/Rax/Vue, etc).", "publisher": "iceworks-team", - "version": "0.4.10", + "version": "0.5.0", "engines": { "vscode": "^1.41.0" }, @@ -100,6 +100,10 @@ "dark": "assets/dark/setting.svg" } }, + { + "command": "iceworksApp.welcome.start", + "title": "%iceworksApp.command.welcome.start.title%" + }, { "command": "iceworksApp.editorMenu.DefPublish", "title": "%iceworksApp.command.DefPublish.title%", @@ -440,6 +444,11 @@ "https://registry.npm.taobao.org" ], "description": "%iceworksApp.configuration.properties.iceworks.npmRegistry.description%" + }, + "iceworks.showWelcomePage": { + "type": "boolean", + "default": true, + "description": "%iceworksApp.configuration.properties.iceworks.showWelcomePage.description%" } } } diff --git a/extensions/iceworks-app/package.nls.json b/extensions/iceworks-app/package.nls.json index 7a63af2ee..49373ffd7 100644 --- a/extensions/iceworks-app/package.nls.json +++ b/extensions/iceworks-app/package.nls.json @@ -5,11 +5,12 @@ "iceworksApp.view.components.name": "Components", "iceworksApp.view.nodeDependencies.name": "Node Dependencies", "iceworksApp.viewsWelcome.welcome.contents": "To use Iceworks, you need to open or create a application first. \n[Open a Folder](command:vscode.openFolder)\n[Create Application](command:iceworks-project-creator.start)\n[Configuration](command:iceworksApp.configHelper.start)\nRead the [docs](https://marketplace.visualstudio.com/items?itemName=iceworks-team.iceworks) to learn more about how to use Iceworks in VS Code.", - "iceworksApp.viewsWelcome.npmScripts.contents": "npm scripts could not be found in package.json.", - "iceworksApp.viewsWelcome.pages.contents": "Pages could not be found.", - "iceworksApp.viewsWelcome.components.contents": "Components could not be found.", - "iceworksApp.viewsWelcome.nodeDependencies.contents": "Node dependencies could not be found in package.json.", + "iceworksApp.viewsWelcome.npmScripts.contents": "npm scripts could not be found in package.json", + "iceworksApp.viewsWelcome.pages.contents": "Pages could not be found", + "iceworksApp.viewsWelcome.components.contents": "Components could not be found", + "iceworksApp.viewsWelcome.nodeDependencies.contents": "Node dependencies could not be found in package.json", "iceworksApp.command.configHelper.start.title": "Iceworks: Settings", + "iceworksApp.command.welcome.start.title": "Iceworks: Welcome", "iceworksApp.command.DefPublish.title": "Iceworks: Def Publish", "iceworksApp.command.quickEntries.start.title": "Start", "iceworksApp.command.npmScripts.refresh.title": "Refresh", @@ -33,5 +34,6 @@ "iceworksApp.command.nodeDependencies.refresh.title": "Refresh", "iceworksApp.command.nodeDependencies.upgrade.title": "Upgrade Dependency", "iceworksApp.configuration.properties.iceworks.packageManager.description": "Iceworks npm package manager.", - "iceworksApp.configuration.properties.iceworks.npmRegistry.description": "Iceworks npm registry." + "iceworksApp.configuration.properties.iceworks.npmRegistry.description": "Iceworks npm registry.", + "iceworksApp.configuration.properties.iceworks.showWelcomePage.description": "Show welcome page" } diff --git a/extensions/iceworks-app/package.nls.zh-cn.json b/extensions/iceworks-app/package.nls.zh-cn.json index 2f3b1c6df..627a5d85f 100644 --- a/extensions/iceworks-app/package.nls.zh-cn.json +++ b/extensions/iceworks-app/package.nls.zh-cn.json @@ -5,11 +5,12 @@ "iceworksApp.view.components.name": "组件列表", "iceworksApp.view.nodeDependencies.name": "依赖列表", "iceworksApp.viewsWelcome.welcome.contents": "要使用 Iceworks,您需要先打开或创建一个应用。\n[打开文件夹](command:vscode.openFolder)\n[创建应用](command:iceworks-project-creator.start)\n[设置](command:iceworksApp.configHelper.start)\n查看[文档](https://marketplace.visualstudio.com/items?itemName=iceworks-team.iceworks)以学习如何在 VS Code 中如何使用 Iceworks App。", - "iceworksApp.viewsWelcome.npmScripts.contents": "未找到 npm 脚本。", - "iceworksApp.viewsWelcome.pages.contents": "未找到页面。", - "iceworksApp.viewsWelcome.components.contents": "未找到组件。", - "iceworksApp.viewsWelcome.nodeDependencies.contents": "未找到依赖。", + "iceworksApp.viewsWelcome.npmScripts.contents": "未找到 npm 脚本", + "iceworksApp.viewsWelcome.pages.contents": "未找到页面", + "iceworksApp.viewsWelcome.components.contents": "未找到组件", + "iceworksApp.viewsWelcome.nodeDependencies.contents": "未找到依赖", "iceworksApp.command.configHelper.start.title": "Iceworks: 设置", + "iceworksApp.command.welcome.start.title": "Iceworks: 欢迎", "iceworksApp.command.DefPublish.title": "Iceworks: DEF 发布", "iceworksApp.command.quickEntries.start.title": "启动", "iceworksApp.command.npmScripts.refresh.title": "刷新", @@ -33,5 +34,6 @@ "iceworksApp.command.nodeDependencies.refresh.title": "刷新", "iceworksApp.command.nodeDependencies.upgrade.title": "升级依赖", "iceworksApp.configuration.properties.iceworks.packageManager.description": "Iceworks npm 包管理工具", - "iceworksApp.configuration.properties.iceworks.npmRegistry.description": "Iceworks npm 镜像源" + "iceworksApp.configuration.properties.iceworks.npmRegistry.description": "Iceworks npm 镜像源", + "iceworksApp.configuration.properties.iceworks.showWelcomePage.description": "是否显示欢迎页" } diff --git a/extensions/iceworks-app/src/commands/executeCommand.ts b/extensions/iceworks-app/src/commands/executeCommand.ts index c980c5c71..d20fd81ba 100644 --- a/extensions/iceworks-app/src/commands/executeCommand.ts +++ b/extensions/iceworks-app/src/commands/executeCommand.ts @@ -11,9 +11,9 @@ export default function executeCommand(command: vscode.Command) { return; } - const terminals = vscode.window.terminals; + const { terminals } = vscode.window; - let terminal: Terminal | undefined = terminals.find((terminal: Terminal) => terminal.name === script); + let terminal: Terminal | undefined = terminals.find(({ name }) => name === script); if (!terminal) { const terminalOptions: TerminalOptions = { cwd, name: script }; terminal = vscode.window.createTerminal(terminalOptions); diff --git a/extensions/iceworks-app/src/commands/stopCommand.ts b/extensions/iceworks-app/src/commands/stopCommand.ts index 977dcddfb..184fda8c4 100644 --- a/extensions/iceworks-app/src/commands/stopCommand.ts +++ b/extensions/iceworks-app/src/commands/stopCommand.ts @@ -1,12 +1,12 @@ import * as vscode from 'vscode'; export default function stopCommand(command: vscode.Command) { - const terminals = vscode.window.terminals; + const { terminals } = vscode.window; const commandArgs = command.arguments; if (!commandArgs) { return; } - const [cwd, script] = commandArgs; + const [script] = commandArgs; if (!script) { return; } diff --git a/extensions/iceworks-app/src/constants.ts b/extensions/iceworks-app/src/constants.ts index 320b6e57e..800b15080 100644 --- a/extensions/iceworks-app/src/constants.ts +++ b/extensions/iceworks-app/src/constants.ts @@ -6,3 +6,5 @@ export const showExtensionsQuickPickCommandId = 'iceworksApp.showEntriesQuickPic export const editorTitleRunDebugCommandId = 'npmScripts-editor-title-run-dev'; export const editorTitleRunBuildCommandId = 'npmScripts-editor-title-run-build'; + +export const projectExistsTime = 5; diff --git a/extensions/iceworks-app/src/debugConfig/getDefaultConfigs.ts b/extensions/iceworks-app/src/debugConfig/getDefaultConfigs.ts index ce3d5ac5a..144e7fcdc 100644 --- a/extensions/iceworks-app/src/debugConfig/getDefaultConfigs.ts +++ b/extensions/iceworks-app/src/debugConfig/getDefaultConfigs.ts @@ -70,7 +70,7 @@ export function getLaunchConfig(launchUrl?: string): IDebugConfig { baseUrl: BASE_URL, startLabel: CONFIG_START_LABEL, stopLabel: CONFIG_STOP_LABEL, - }) + }), ), }; } @@ -87,7 +87,7 @@ export function getTasksConfig(isPegasusProject = false, disableOpen = false): I isPegasusProject, startLabel: CONFIG_START_LABEL, stopLabel: CONFIG_STOP_LABEL, - }) + }), ), }; } diff --git a/extensions/iceworks-app/src/debugConfig/index.ts b/extensions/iceworks-app/src/debugConfig/index.ts index 113a3355d..3621e7261 100644 --- a/extensions/iceworks-app/src/debugConfig/index.ts +++ b/extensions/iceworks-app/src/debugConfig/index.ts @@ -22,7 +22,7 @@ function writeConfigFile(filePath: string, config: IDebugConfig) { filePath, '// See https://github.com/ice-lab/iceworks/blob/master/extensions/iceworks-app/docs/debug.md \n' + '// for the documentation about the Iceworks debug \n' + - `${JSON.stringify(config, null, ' ')}` + `${JSON.stringify(config, null, ' ')}`, ); } diff --git a/extensions/iceworks-app/src/extension.ts b/extensions/iceworks-app/src/extension.ts index abf63d39f..74b7d0762 100644 --- a/extensions/iceworks-app/src/extension.ts +++ b/extensions/iceworks-app/src/extension.ts @@ -4,21 +4,23 @@ import { connectService, getHtmlForWebview } from '@iceworks/vscode-webview/lib/ import { getProjectType, checkIsPegasusProject, + checkIsNotTarget, autoSetContext as autoSetContextByProject, + projectPath, } from '@iceworks/project-service'; import { Recorder, recordDAU } from '@iceworks/recorder'; -import { initExtension, registerCommand } from '@iceworks/common-service'; +import { initExtension, registerCommand, getFolderExistsTime, getDataFromSettingJson } from '@iceworks/common-service'; import { createNpmScriptsTreeView } from './views/npmScriptsView'; import { createNodeDependenciesTreeView } from './views/nodeDependenciesView'; import { createComponentsTreeView } from './views/componentsView'; import { createPagesTreeView } from './views/pagesView'; import { createQuickEntriesTreeView } from './views/quickEntriesView'; import services from './services'; -import { showExtensionsQuickPickCommandId } from './constants'; +import { showExtensionsQuickPickCommandId, projectExistsTime } from './constants'; import showEntriesQuickPick from './quickPicks/showEntriesQuickPick'; -import createEditorMenuAction from './createEditorMenuAction'; +import createEditorMenuAction from './utils/createEditorMenuAction'; import createExtensionsStatusBar from './statusBar/createExtensionsStatusBar'; -import autoStart from './autoStart'; +import autoStart from './utils/autoStart'; import i18n from './i18n'; // eslint-disable-next-line @@ -29,7 +31,7 @@ export async function activate(context: vscode.ExtensionContext) { const { subscriptions, extensionPath } = context; // auto set configuration & context - initExtension(context); + initExtension(context, name); autoSetContextByProject(); const projectType = await getProjectType(); @@ -43,44 +45,76 @@ export async function activate(context: vscode.ExtensionContext) { recorder.recordActivate(); await showEntriesQuickPick(); - }) + }), ); // init config webview - let webviewPanel: vscode.WebviewPanel | undefined; + let configWebviewPanel: vscode.WebviewPanel | undefined; function activeConfigWebview(focusField: string) { - if (webviewPanel) { - webviewPanel.reveal(); + if (configWebviewPanel) { + configWebviewPanel.reveal(); } else { - webviewPanel = window.createWebviewPanel( + configWebviewPanel = window.createWebviewPanel( 'iceworks', - i18n.format('extension.iceworksApp.extension.title'), + i18n.format('extension.iceworksApp.configHelper.extension.webviewTitle'), ViewColumn.One, { enableScripts: true, retainContextWhenHidden: true, - } + }, ); const extraHtml = ` `; - webviewPanel.webview.html = getHtmlForWebview(extensionPath, undefined, false, undefined, extraHtml); - webviewPanel.onDidDispose( + configWebviewPanel.webview.html = getHtmlForWebview(extensionPath, 'confighelper', true, undefined, extraHtml); + configWebviewPanel.onDidDispose( () => { - webviewPanel = undefined; + configWebviewPanel = undefined; }, null, - context.subscriptions + context.subscriptions, ); - connectService(webviewPanel, context, { services, recorder }); + connectService(configWebviewPanel, context, { services, recorder }); } } subscriptions.push( - registerCommand('iceworksApp.configHelper.start', function (focusField: string) { + registerCommand('iceworksApp.configHelper.start', (focusField: string) => { recorder.recordActivate(); activeConfigWebview(focusField); - }) + }), + ); + // init welcome webview + let welcomeWebviewPanel: vscode.WebviewPanel | undefined; + function activeWelcomeWebview() { + if (welcomeWebviewPanel) { + welcomeWebviewPanel.reveal(); + } else { + welcomeWebviewPanel = window.createWebviewPanel( + 'iceworks', + i18n.format('extension.iceworksApp.welcome.extension.webviewTitle'), + ViewColumn.One, + { + enableScripts: true, + retainContextWhenHidden: true, + }, + ); + + welcomeWebviewPanel.webview.html = getHtmlForWebview(extensionPath, 'welcome', true); + welcomeWebviewPanel.onDidDispose( + () => { + welcomeWebviewPanel = undefined; + }, + null, + context.subscriptions, + ); + connectService(welcomeWebviewPanel, context, { services, recorder }); + } + } + subscriptions.push( + registerCommand('iceworksApp.welcome.start', () => { + activeWelcomeWebview(); + }), ); // init tree view @@ -124,4 +158,15 @@ export async function activate(context: vscode.ExtensionContext) { vscode.commands.executeCommand('setContext', 'iceworks:showScriptIconInEditorTitleMenu', true); await createEditorMenuAction(); } + + // auto start welcome page when the application is new + const isNotTargetProject = await checkIsNotTarget(); + // get showWelcomePage configuration from settings.json + const isShowWelcomePage = await getDataFromSettingJson('showWelcomePage', true); + if (projectPath && !isNotTargetProject && isShowWelcomePage) { + const curProjectExistsTime = getFolderExistsTime(projectPath); + if (projectExistsTime > curProjectExistsTime) { + vscode.commands.executeCommand('iceworksApp.welcome.start'); + } + } } diff --git a/extensions/iceworks-app/src/locales/en-US.json b/extensions/iceworks-app/src/locales/en-US.json index 1c8ce6ddf..391a43180 100644 --- a/extensions/iceworks-app/src/locales/en-US.json +++ b/extensions/iceworks-app/src/locales/en-US.json @@ -13,6 +13,8 @@ "extension.iceworksApp.showEntriesQuickPick.createComponent.detail": "Download coomponent materials to local", "extension.iceworksApp.showEntriesQuickPick.openSettings.label": "Settings", "extension.iceworksApp.showEntriesQuickPick.openSettings.detail": "Set the related functions provided by Iceworks", + "extension.iceworksApp.showEntriesQuickPick.openDashboard.label": "Open Dashboard", + "extension.iceworksApp.showEntriesQuickPick.openDashboard.detail": "Display project details and code quality", "extension.iceworksApp.showEntriesQuickPick.showMaterialDocs.label": "Find Component", "extension.iceworksApp.showEntriesQuickPick.showMaterialDocs.detail": "Quickly search and browse component documents", "extension.iceworksApp.showEntriesQuickPick.runDebug.label": "Debug", @@ -25,6 +27,8 @@ "extension.iceworksApp.showEntriesQuickPick.reinstall.detail": "Reinstall the dependency packages for the application", "extension.iceworksApp.showEntriesQuickPick.addDepsAndDevDeps.label": "Add Dependency", "extension.iceworksApp.showEntriesQuickPick.addDepsAndDevDeps.detail": "Add a new dependency package for the application", + "extension.iceworksApp.showEntriesQuickPick.welcomePage.label": "Welcome", + "extension.iceworksApp.showEntriesQuickPick.welcomePage.detail": "Show welcome page", "extension.iceworksApp.showDepsInputBox.materialImport.placeHolder": "for example: lodash react@latest.", "extension.iceworksApp.showDepsInputBox.materialImport.prompt": "Please enter the name of the dependency to be addded to <%= depType %>. Multiple dependencies should be spilted by Spaces.", "extension.iceworksApp.showDefPublishEnvQuickPick.DEFEnvOptions.daily.label": "Daily", @@ -33,6 +37,7 @@ "extension.iceworksApp.showDefPublishEnvQuickPick.DEFEnvOptions.prod.detail": "Release to production environment.", "extension.iceworksApp.showDepsQuickPick.quickPickItem.detail": "Install <%= label %>", "extension.iceworksApp.openEntryFile.ErrorMessage": "Cannot find entry", - "extension.iceworksApp.extension.title": "Iceworks Settings", + "extension.iceworksApp.configHelper.extension.webviewTitle": "Settings - Iceworks", + "extension.iceworksApp.welcome.extension.webviewTitle": "Welcome - Iceworks", "extension.iceworksApp.extension.emptyWorkplace": "Current workspace is empty, please open or create an application." } diff --git a/extensions/iceworks-app/src/locales/zh-CN.json b/extensions/iceworks-app/src/locales/zh-CN.json index d5578bf54..a874f9560 100644 --- a/extensions/iceworks-app/src/locales/zh-CN.json +++ b/extensions/iceworks-app/src/locales/zh-CN.json @@ -13,6 +13,8 @@ "extension.iceworksApp.showEntriesQuickPick.materialImport.detail": "通过可视化操作添加组件到应用代码", "extension.iceworksApp.showEntriesQuickPick.openSettings.label": "设置", "extension.iceworksApp.showEntriesQuickPick.openSettings.detail": "设置 Iceworks 提供的相关功能", + "extension.iceworksApp.showEntriesQuickPick.openDashboard.label": "查看项目仪表盘", + "extension.iceworksApp.showEntriesQuickPick.openDashboard.detail": "查看项目信息及安全漏洞和质量问题", "extension.iceworksApp.showEntriesQuickPick.showMaterialDocs.label": "查找组件", "extension.iceworksApp.showEntriesQuickPick.showMaterialDocs.detail": "快速搜索组件文档并进行浏览", "extension.iceworksApp.showEntriesQuickPick.runDebug.label": "启动调试", @@ -25,6 +27,8 @@ "extension.iceworksApp.showEntriesQuickPick.reinstall.detail": "重新安装应用的依赖包", "extension.iceworksApp.showEntriesQuickPick.addDepsAndDevDeps.label": "添加依赖", "extension.iceworksApp.showEntriesQuickPick.addDepsAndDevDeps.detail": "为应用添加新的依赖", + "extension.iceworksApp.showEntriesQuickPick.welcomePage.label": "欢迎使用", + "extension.iceworksApp.showEntriesQuickPick.welcomePage.detail": "启动欢迎页", "extension.iceworksApp.showDepsInputBox.materialImport.placeHolder": "例如: lodash react@latest", "extension.iceworksApp.showDepsInputBox.materialImport.prompt": "请输入需要添加到 <%= depType %> 的依赖名称, 支持通过空格添加多个依赖", "extension.iceworksApp.showDefPublishEnvQuickPick.DEFEnvOptions.daily.label": "日常环境", @@ -33,5 +37,6 @@ "extension.iceworksApp.showDefPublishEnvQuickPick.DEFEnvOptions.prod.detail": "发布到生产环境", "extension.iceworksApp.showDepsQuickPick.quickPickItem.detail": "安装 <%= label %>", "extension.iceworksApp.openEntryFile.ErrorMessage": "没有找到入口", - "extension.iceworksApp.extension.title": "设置 - Iceworks" + "extension.iceworksApp.configHelper.extension.webviewTitle": "设置 - Iceworks", + "extension.iceworksApp.welcome.extension.webviewTitle": "欢迎 - Iceworks" } diff --git a/extensions/iceworks-app/src/quickPicks/showEntriesQuickPick.ts b/extensions/iceworks-app/src/quickPicks/showEntriesQuickPick.ts index 3da9de6e0..992655296 100644 --- a/extensions/iceworks-app/src/quickPicks/showEntriesQuickPick.ts +++ b/extensions/iceworks-app/src/quickPicks/showEntriesQuickPick.ts @@ -1,5 +1,5 @@ import * as vscode from 'vscode'; -import getQuickEntryOptions from '../getQuickEntryOptions'; +import getQuickEntryOptions from '../utils/getQuickEntryOptions'; const { window, commands } = vscode; diff --git a/extensions/iceworks-app/src/autoStart.ts b/extensions/iceworks-app/src/utils/autoStart.ts similarity index 99% rename from extensions/iceworks-app/src/autoStart.ts rename to extensions/iceworks-app/src/utils/autoStart.ts index 0e14b4508..417675738 100644 --- a/extensions/iceworks-app/src/autoStart.ts +++ b/extensions/iceworks-app/src/utils/autoStart.ts @@ -3,6 +3,7 @@ import { checkIsNotTarget } from '@iceworks/project-service'; export default async function () { const isNotTargetProject = await checkIsNotTarget(); + if (isNotTargetProject) { vscode.commands.executeCommand('iceworks-project-creator.start'); } diff --git a/extensions/iceworks-app/src/createEditorMenuAction.ts b/extensions/iceworks-app/src/utils/createEditorMenuAction.ts similarity index 90% rename from extensions/iceworks-app/src/createEditorMenuAction.ts rename to extensions/iceworks-app/src/utils/createEditorMenuAction.ts index d83efaebe..514c3d4b4 100644 --- a/extensions/iceworks-app/src/createEditorMenuAction.ts +++ b/extensions/iceworks-app/src/utils/createEditorMenuAction.ts @@ -1,9 +1,9 @@ import * as vscode from 'vscode'; import { createNpmCommand, checkPathExists, checkIsAliInternal, registerCommand } from '@iceworks/common-service'; import { dependencyDir, projectPath } from '@iceworks/project-service'; -import { setDebugConfig } from './debugConfig/index'; -import showDefPublishEnvQuickPick from './quickPicks/showDefPublishEnvQuickPick'; -import executeCommand from './commands/executeCommand'; +import { setDebugConfig } from '../debugConfig/index'; +import showDefPublishEnvQuickPick from '../quickPicks/showDefPublishEnvQuickPick'; +import executeCommand from '../commands/executeCommand'; export default async function createEditorMenuAction() { const EDITOR_MENU_RUN_DEBUG = 'iceworksApp.editorMenu.runDebug'; diff --git a/extensions/iceworks-app/src/getQuickEntryOptions.ts b/extensions/iceworks-app/src/utils/getQuickEntryOptions.ts similarity index 83% rename from extensions/iceworks-app/src/getQuickEntryOptions.ts rename to extensions/iceworks-app/src/utils/getQuickEntryOptions.ts index a8f92003e..c910174e8 100644 --- a/extensions/iceworks-app/src/getQuickEntryOptions.ts +++ b/extensions/iceworks-app/src/utils/getQuickEntryOptions.ts @@ -1,6 +1,7 @@ +import * as vscode from 'vscode'; import { getProjectType, checkIsPegasusProject, checkIsNotTarget } from '@iceworks/project-service'; import { checkIsAliInternal } from '@iceworks/common-service'; -import i18n from './i18n'; +import i18n from '../i18n'; const entries = [ { @@ -8,6 +9,18 @@ const entries = [ detail: i18n.format('extension.iceworksApp.showEntriesQuickPick.projectCreater.detail'), command: 'iceworks-project-creator.start', }, + { + label: i18n.format('extension.iceworksApp.showEntriesQuickPick.openDashboard.label'), + detail: i18n.format('extension.iceworksApp.showEntriesQuickPick.openDashboard.detail'), + command: 'iceworks-doctor.dashboard', + async condition() { + const doctorExtension = vscode.extensions.getExtension('iceworks-team.iceworks-doctor'); + if (doctorExtension) { + return !(await checkIsNotTarget()); + } + return false; + }, + }, { label: i18n.format('extension.iceworksApp.showEntriesQuickPick.generatePage.label'), detail: i18n.format('extension.iceworksApp.showEntriesQuickPick.generatePage.detail'), @@ -94,6 +107,11 @@ const entries = [ return !(await checkIsNotTarget()); }, }, + { + label: i18n.format('extension.iceworksApp.showEntriesQuickPick.welcomePage.label'), + detail: i18n.format('extension.iceworksApp.showEntriesQuickPick.welcomePage.detail'), + command: 'iceworksApp.welcome.start', + }, { label: i18n.format('extension.iceworksApp.showEntriesQuickPick.openSettings.label'), detail: i18n.format('extension.iceworksApp.showEntriesQuickPick.openSettings.detail'), @@ -103,13 +121,14 @@ const entries = [ export default async function () { const conditionResults = await Promise.all( - entries.map(async function ({ condition }) { + entries.map(async ({ condition }) => { if (condition) { - return await condition(); + const result = await condition(); + return result; } else { return true; } - }) + }), ); return entries.filter((v, index) => conditionResults[index]); diff --git a/extensions/iceworks-app/src/openEntryFile.ts b/extensions/iceworks-app/src/utils/openEntryFile.ts similarity index 84% rename from extensions/iceworks-app/src/openEntryFile.ts rename to extensions/iceworks-app/src/utils/openEntryFile.ts index eef063995..508bcfd7e 100644 --- a/extensions/iceworks-app/src/openEntryFile.ts +++ b/extensions/iceworks-app/src/utils/openEntryFile.ts @@ -1,6 +1,4 @@ -import * as path from 'path'; import * as vscode from 'vscode'; -import * as fsExtra from 'fs-extra'; import { findIndexFile } from '@iceworks/common-service'; export default function openEntryFile(p: string) { diff --git a/extensions/iceworks-app/src/views/componentsView.ts b/extensions/iceworks-app/src/views/componentsView.ts index cf25e72c5..953d8de41 100644 --- a/extensions/iceworks-app/src/views/componentsView.ts +++ b/extensions/iceworks-app/src/views/componentsView.ts @@ -3,7 +3,7 @@ import * as fse from 'fs-extra'; import * as path from 'path'; import { checkPathExists, registerCommand } from '@iceworks/common-service'; import { componentsPath, projectPath } from '@iceworks/project-service'; -import openEntryFile from '../openEntryFile'; +import openEntryFile from '../utils/openEntryFile'; import showAddComponentQuickPick from '../quickPicks/showAddComponentQuickPick'; class ComponentsProvider implements vscode.TreeDataProvider { @@ -12,7 +12,7 @@ class ComponentsProvider implements vscode.TreeDataProvider { private extensionContext: vscode.ExtensionContext; private onDidChange: vscode.EventEmitter = new vscode.EventEmitter< - ComponentTreeItem | undefined + ComponentTreeItem | undefined >(); readonly onDidChangeTreeData: vscode.Event = this.onDidChange.event; @@ -47,12 +47,12 @@ class ComponentsProvider implements vscode.TreeDataProvider { } } - private async getComponents(componentsPath: string) { + private async getComponents(targetPath: string) { try { - const isComponentPathExists = await checkPathExists(componentsPath); + const isComponentPathExists = await checkPathExists(targetPath); if (isComponentPathExists) { const toComponent = (componentName: string) => { - const componentPath = path.join(componentsPath, componentName); + const componentPath = path.join(targetPath, componentName); const command: vscode.Command = { command: 'iceworksApp.components.openFile', @@ -62,10 +62,10 @@ class ComponentsProvider implements vscode.TreeDataProvider { return new ComponentTreeItem(this.extensionContext, componentName, command, componentPath); }; - const dirNames = await fse.readdir(componentsPath); + const dirNames = await fse.readdir(targetPath); // except file const componentNames = dirNames.filter((dirname) => { - const stat = fse.statSync(path.join(componentsPath, dirname)); + const stat = fse.statSync(path.join(targetPath, dirname)); return stat.isDirectory(); }); return componentNames.map((componentName) => toComponent(componentName)); @@ -83,7 +83,8 @@ class ComponentTreeItem extends vscode.TreeItem { public readonly extensionContext: vscode.ExtensionContext, public readonly label: string, public readonly command: vscode.Command, - public readonly path: string + // eslint-disable-next-line no-shadow + public readonly path: string, ) { super(label); } diff --git a/extensions/iceworks-app/src/views/nodeDependenciesView.ts b/extensions/iceworks-app/src/views/nodeDependenciesView.ts index 3ad3362c2..839b9acab 100644 --- a/extensions/iceworks-app/src/views/nodeDependenciesView.ts +++ b/extensions/iceworks-app/src/views/nodeDependenciesView.ts @@ -21,7 +21,7 @@ class DepNodeProvider implements vscode.TreeDataProvider { private extensionContext: vscode.ExtensionContext; private onDidChange: vscode.EventEmitter = new vscode.EventEmitter< - DependencyTreeItem | undefined + DependencyTreeItem | undefined >(); readonly onDidChangeTreeData: vscode.Event = this.onDidChange.event; @@ -57,14 +57,13 @@ class DepNodeProvider implements vscode.TreeDataProvider { } else { return Promise.resolve( nodeDepTypes.map( - (nodeDepType) => - new DependencyTreeItem( - this.extensionContext, - nodeDepType, - vscode.TreeItemCollapsibleState.Collapsed, - nodeDepType - ) - ) + (nodeDepType) => new DependencyTreeItem( + this.extensionContext, + nodeDepType, + vscode.TreeItemCollapsibleState.Collapsed, + nodeDepType, + ), + ), ); } } @@ -96,7 +95,7 @@ class DepNodeProvider implements vscode.TreeDataProvider { outdated = await this.getNpmOutdated(dep, version); } return toDep(this.extensionContext, workspaceDir, dep, version, outdated); - }) + }), ); } @@ -166,7 +165,7 @@ class DependencyTreeItem extends vscode.TreeItem { public readonly id: string, public readonly command?: vscode.Command, public readonly version?: string, - public readonly outDated?: boolean + public readonly outDated?: boolean, ) { super(label, collapsibleState); this.id = id; @@ -186,10 +185,10 @@ class DependencyTreeItem extends vscode.TreeItem { iconPath = { dark: vscode.Uri.file( - this.extensionContext.asAbsolutePath(`assets/dark/${this.version ? 'dependency' : 'dependency-entry'}.svg`) + this.extensionContext.asAbsolutePath(`assets/dark/${this.version ? 'dependency' : 'dependency-entry'}.svg`), ), light: vscode.Uri.file( - this.extensionContext.asAbsolutePath(`assets/light/${this.version ? 'dependency' : 'dependency-entry'}.svg`) + this.extensionContext.asAbsolutePath(`assets/light/${this.version ? 'dependency' : 'dependency-entry'}.svg`), ), }; } @@ -210,12 +209,8 @@ export function createNodeDependenciesTreeView(context) { executeCommand(script); } }); - registerCommand('iceworksApp.nodeDependencies.dependencies.add', () => - showDepsInputBox(nodeDependenciesProvider, 'dependencies') - ); - registerCommand('iceworksApp.nodeDependencies.devDependencies.add', () => - showDepsInputBox(nodeDependenciesProvider, 'devDependencies') - ); + registerCommand('iceworksApp.nodeDependencies.dependencies.add', () => showDepsInputBox(nodeDependenciesProvider, 'dependencies')); + registerCommand('iceworksApp.nodeDependencies.devDependencies.add', () => showDepsInputBox(nodeDependenciesProvider, 'devDependencies')); registerCommand('iceworksApp.nodeDependencies.addDepsAndDevDeps', () => showDepsQuickPick(nodeDependenciesProvider)); const pattern = new vscode.RelativePattern(path.join(projectPath, dependencyDir), '**'); @@ -232,17 +227,17 @@ function toDep( workspaceDir: string, moduleName: string, version: string, - outdated: boolean + outdated: boolean, ) { const packageManager = getDataFromSettingJson('packageManager'); const isYarn = packageManager === 'yarn'; const npmCommand = createNpmCommand(isYarn ? 'upgrade' : 'update', moduleName); const command = outdated ? { - command: 'iceworksApp.nodeDependencies.upgrade', - title: 'Upgrade Dependency', - arguments: [workspaceDir, npmCommand], - } + command: 'iceworksApp.nodeDependencies.upgrade', + title: 'Upgrade Dependency', + arguments: [workspaceDir, npmCommand], + } : undefined; return new DependencyTreeItem( extensionContext, @@ -251,6 +246,6 @@ function toDep( `nodeDependencies-${moduleName}`, command, version, - outdated + outdated, ); } diff --git a/extensions/iceworks-app/src/views/npmScriptsView.ts b/extensions/iceworks-app/src/views/npmScriptsView.ts index e2e41d561..01582607a 100644 --- a/extensions/iceworks-app/src/views/npmScriptsView.ts +++ b/extensions/iceworks-app/src/views/npmScriptsView.ts @@ -12,7 +12,7 @@ export class NpmScriptsProvider implements vscode.TreeDataProvider = new vscode.EventEmitter< - ScriptTreeItem | undefined + ScriptTreeItem | undefined >(); readonly onDidChangeTreeData: vscode.Event = this.onDidChange.event; @@ -56,9 +56,7 @@ export class NpmScriptsProvider implements vscode.TreeDataProvider - toScript(script, packageJson.scripts[script], `npmScripts-${script}`) - ) + ? Object.keys(packageJson.scripts).map((script) => toScript(script, packageJson.scripts[script], `npmScripts-${script}`)) : []; return scripts; } else { @@ -73,7 +71,7 @@ export class ScriptTreeItem extends vscode.TreeItem { public readonly label: string, public readonly tooltip: string, public readonly command: vscode.Command, - public readonly id: string + public readonly id: string, ) { super(label); this.id = id; diff --git a/extensions/iceworks-app/src/views/pagesView.ts b/extensions/iceworks-app/src/views/pagesView.ts index 66a6b7080..f573eb4dd 100644 --- a/extensions/iceworks-app/src/views/pagesView.ts +++ b/extensions/iceworks-app/src/views/pagesView.ts @@ -2,8 +2,8 @@ import * as vscode from 'vscode'; import * as fse from 'fs-extra'; import * as path from 'path'; import { checkPathExists, registerCommand } from '@iceworks/common-service'; -import { pagesPath, projectPath } from '@iceworks/project-service'; -import openEntryFile from '../openEntryFile'; +import { pagesPath as projectPagesPath, projectPath } from '@iceworks/project-service'; +import openEntryFile from '../utils/openEntryFile'; import i18n from '../i18n'; export class PagesProvider implements vscode.TreeDataProvider { @@ -12,7 +12,7 @@ export class PagesProvider implements vscode.TreeDataProvider { private extensionContext: vscode.ExtensionContext; private onDidChange: vscode.EventEmitter = new vscode.EventEmitter< - PageTreeItem | undefined + PageTreeItem | undefined >(); readonly onDidChangeTreeData: vscode.Event = this.onDidChange.event; @@ -73,7 +73,8 @@ class PageTreeItem extends vscode.TreeItem { public readonly extensionContext: vscode.ExtensionContext, public readonly label: string, public readonly command: vscode.Command, - public readonly path: string + // eslint-disable-next-line no-shadow + public readonly path: string, ) { super(label); } @@ -120,7 +121,7 @@ export function createPagesTreeView(context: vscode.ExtensionContext) { registerCommand('iceworksApp.pages.openFile', (pagePath) => openEntryFile(pagePath)); registerCommand('iceworksApp.pages.delete', async (page) => await fse.remove(page.path)); - const pattern = new vscode.RelativePattern(pagesPath, '**'); + const pattern = new vscode.RelativePattern(projectPagesPath, '**'); const fileWatcher = vscode.workspace.createFileSystemWatcher(pattern, false, false, false); fileWatcher.onDidChange(() => pagesProvider.refresh()); fileWatcher.onDidCreate(() => pagesProvider.refresh()); diff --git a/extensions/iceworks-app/src/views/quickEntriesView.ts b/extensions/iceworks-app/src/views/quickEntriesView.ts index 721072418..11e823dc7 100644 --- a/extensions/iceworks-app/src/views/quickEntriesView.ts +++ b/extensions/iceworks-app/src/views/quickEntriesView.ts @@ -1,6 +1,6 @@ import * as vscode from 'vscode'; import { registerCommand, executeCommand } from '@iceworks/common-service'; -import getQuickEntryOptions from '../getQuickEntryOptions'; +import getQuickEntryOptions from '../utils/getQuickEntryOptions'; export class QuickEntriesProvider implements vscode.TreeDataProvider { private extensionContext: vscode.ExtensionContext; @@ -36,7 +36,7 @@ class QuickEntryItem extends vscode.TreeItem { public readonly extensionContext: vscode.ExtensionContext, public readonly label: string, public readonly tooltip: string, - public readonly command: vscode.Command + public readonly command: vscode.Command, ) { super(label); } diff --git a/extensions/iceworks-app/web/build.json b/extensions/iceworks-app/web/build.json index 81682baa5..150871095 100644 --- a/extensions/iceworks-app/web/build.json +++ b/extensions/iceworks-app/web/build.json @@ -2,6 +2,7 @@ "devServer": { "writeToDisk": true }, + "mpa": true, "publicPath": "./", "outputDir": "../build", "plugins": [ diff --git a/extensions/iceworks-app/web/public/assets/dingtalk.svg b/extensions/iceworks-app/web/public/assets/dingtalk.svg new file mode 100644 index 000000000..f0104889e --- /dev/null +++ b/extensions/iceworks-app/web/public/assets/dingtalk.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/extensions/iceworks-app/web/public/assets/doc.svg b/extensions/iceworks-app/web/public/assets/doc.svg new file mode 100644 index 000000000..b9bf175db --- /dev/null +++ b/extensions/iceworks-app/web/public/assets/doc.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/extensions/iceworks-app/web/public/assets/updates.svg b/extensions/iceworks-app/web/public/assets/updates.svg new file mode 100644 index 000000000..611957717 --- /dev/null +++ b/extensions/iceworks-app/web/public/assets/updates.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/extensions/iceworks-app/web/public/index.html b/extensions/iceworks-app/web/public/index.html index cf4a793e6..e0e6963d9 100644 --- a/extensions/iceworks-app/web/public/index.html +++ b/extensions/iceworks-app/web/public/index.html @@ -5,11 +5,11 @@ - Iceworks Application Creator + Iceworks App
- + \ No newline at end of file diff --git a/extensions/iceworks-app/web/src/constants.ts b/extensions/iceworks-app/web/src/constants.ts index a3ed8e7e7..9fb1f3d4b 100644 --- a/extensions/iceworks-app/web/src/constants.ts +++ b/extensions/iceworks-app/web/src/constants.ts @@ -10,5 +10,5 @@ export const AliPackageManager = 'tnpm'; export const urlRegExp = new RegExp( '^(?!mailto:)(?:(?:http|https|ftp)://|//)(?:\\S+(?::\\S*)?@)?(?:(?:(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}(?:\\.(?:[0-9]\\d?|1\\d\\d|2[0-4]\\d|25[0-4]))|(?:(?:[a-z\\u00a1-\\uffff0-9]+-?)*[a-z\\u00a1-\\uffff0-9]+)(?:\\.(?:[a-z\\u00a1-\\uffff0-9]+-?)*[a-z\\u00a1-\\uffff0-9]+)*(?:\\.(?:[a-z\\u00a1-\\uffff]{2,})))|localhost)(?::\\d{2,5})?(?:(/|\\?|#)[^\\s]*)?$', - 'i' + 'i', ); diff --git a/extensions/iceworks-app/web/src/i18n.tsx b/extensions/iceworks-app/web/src/i18n.tsx index a82e9b0f7..22cc7d3e5 100644 --- a/extensions/iceworks-app/web/src/i18n.tsx +++ b/extensions/iceworks-app/web/src/i18n.tsx @@ -29,6 +29,7 @@ const getIntl = (locale: string) => { } return createIntl({ locale, messages: localeMessage.messages }); }; + export const LocaleProvider = (props) => { const [i18n, setI18n] = useState(() => getIntl(DEFAULT_LOCALE)); const [loading, setLoading] = useState(true); diff --git a/extensions/iceworks-app/web/src/locales/en-US.json b/extensions/iceworks-app/web/src/locales/en-US.json index 958a1b0a5..a10c37ec1 100644 --- a/extensions/iceworks-app/web/src/locales/en-US.json +++ b/extensions/iceworks-app/web/src/locales/en-US.json @@ -1,28 +1,46 @@ { - "web.iceworksApp.customMaterialSource.confirmDelete": "Are you sure to delete the material source?", - "web.iceworksApp.customMaterialSource.editMaterialSource": "Edit Material Source", - "web.iceworksApp.customMaterialSource.addMaterialSource": "Add Material Source", - "web.iceworksApp.customMaterialSource.customMaterialSource": "Custom Material Source", - "web.iceworksApp.customMaterialSource.add": "Add", - "web.iceworksApp.customMaterialSource.help": "See《物料开发》to know how to create a custom material", - "web.iceworksApp.customMaterialSource.loading": "Loading", - "web.iceworksApp.index.CUSTOM_NPM_REGISTRY_SELECT_KEY": "Custom NPM Registry", - "web.iceworksApp.index.addMaterialSuccess": "Added material source successfully", - "web.iceworksApp.index.editMaterialSuccess": "Modified material source successfully", - "web.iceworksApp.index.deleteMaterialSuccess": "Material source deleted successfully", - "web.iceworksApp.index.editSettingSuccess": "Setting up completed successfully ", - "web.iceworksApp.index.npmPackageManager": "Npm Packages Manager", - "web.iceworksApp.index.chooseNpmPackageManager": "Choose NPM Packages Mananger", - "web.iceworksApp.index.npmRegistry": "Npm Registry", - "web.iceworksApp.index.chooseNpmRegistry": "Choose NPM Registry", - "web.iceworksApp.index.formatUrl": "Enter A NPM Registry Url", - "web.iceworksApp.index.customNpmRegistryPlaceHolder": "Custom NPM Registry", - "web.iceworksApp.MaterialSourceForm.materialNameLabel": "Material Name:", - "web.iceworksApp.MaterialSourceForm.materialName": "Please Enter Material Name", - "web.iceworksApp.MaterialSourceForm.materiaURLLabel": "Material URL", - "web.iceworksApp.MaterialSourceForm.materiaURL": "Please Enter Material URL", - "web.iceworksApp.MaterialSourceForm.materialDescriptionLabel": "Material Description:", - "web.iceworksApp.MaterialSourceForm.materialDescription": "Please Enter Material Description", - "web.iceworksApp.MaterialSourceForm.confirm": "Confirm", - "web.iceworksApp.MaterialSourceForm.cancel": "Cancel" + "web.iceworksApp.ConfigHelper.customMaterialSource.confirmDelete": "Are you sure to delete the material source?", + "web.iceworksApp.ConfigHelper.customMaterialSource.editMaterialSource": "Edit Material Source", + "web.iceworksApp.ConfigHelper.customMaterialSource.addMaterialSource": "Add Material Source", + "web.iceworksApp.ConfigHelper.customMaterialSource.customMaterialSource": "Custom Material Source", + "web.iceworksApp.ConfigHelper.customMaterialSource.add": "Add", + "web.iceworksApp.ConfigHelper.customMaterialSource.help": "See《物料开发》to know how to create a custom material", + "web.iceworksApp.ConfigHelper.customMaterialSource.loading": "Loading", + "web.iceworksApp.ConfigHelper.index.CUSTOM_NPM_REGISTRY_SELECT_KEY": "Custom NPM Registry", + "web.iceworksApp.ConfigHelper.index.addMaterialSuccess": "Added material source successfully", + "web.iceworksApp.ConfigHelper.index.editMaterialSuccess": "Modified material source successfully", + "web.iceworksApp.ConfigHelper.index.deleteMaterialSuccess": "Material source deleted successfully", + "web.iceworksApp.ConfigHelper.index.editSettingSuccess": "Setting up completed successfully ", + "web.iceworksApp.ConfigHelper.index.npmPackageManager": "Npm Packages Manager", + "web.iceworksApp.ConfigHelper.index.chooseNpmPackageManager": "Choose NPM Packages Mananger", + "web.iceworksApp.ConfigHelper.index.npmRegistry": "Npm Registry", + "web.iceworksApp.ConfigHelper.index.chooseNpmRegistry": "Choose NPM Registry", + "web.iceworksApp.ConfigHelper.index.formatUrl": "Enter A NPM Registry Url", + "web.iceworksApp.ConfigHelper.index.customNpmRegistryPlaceHolder": "Custom NPM Registry", + "web.iceworksApp.ConfigHelper.MaterialSourceForm.materialNameLabel": "Material Name:", + "web.iceworksApp.ConfigHelper.MaterialSourceForm.materialName": "Please Enter Material Name", + "web.iceworksApp.ConfigHelper.MaterialSourceForm.materiaURLLabel": "Material URL", + "web.iceworksApp.ConfigHelper.MaterialSourceForm.materiaURL": "Please Enter Material URL", + "web.iceworksApp.ConfigHelper.MaterialSourceForm.materialDescriptionLabel": "Material Description:", + "web.iceworksApp.ConfigHelper.MaterialSourceForm.materialDescription": "Please Enter Material Description", + "web.iceworksApp.ConfigHelper.MaterialSourceForm.confirm": "Confirm", + "web.iceworksApp.ConfigHelper.MaterialSourceForm.cancel": "Cancel", + "web.iceworksApp.Welcome.Content.title": "Quick Start", + "web.iceworksApp.Welcome.Content.desc": "It only takes 30 minutes to watch, greatly improving the development efficiency.", + "web.iceworksApp.Welcome.Content.videoTitle.createApplication": "1. Create a Hello World Application", + "web.iceworksApp.Welcome.Content.videoTitle.visualDevelopment": "2. Visual Development Based on Materials", + "web.iceworksApp.Welcome.Content.videoTitle.genreateComponent": "3. Generate Component by Visualization", + "web.iceworksApp.Welcome.Content.videoTitle.customMaterial": "4. Develop and Use Custom Materials", + "web.iceworksApp.Welcome.Header.title": "Welcome to Iceworks", + "web.iceworksApp.Welcome.Header.desc": "Iceworks is a visual intelligent assistant, to help you quickly develop frontend applications.", + "web.iceworksApp.Welcome.Information.title": "More Infomation", + "web.iceworksApp.Welcome.Information.doc.title": "Learn", + "web.iceworksApp.Welcome.Information.doc.desc": "Give you more feature detailed description", + "web.iceworksApp.Welcome.Information.doc.link": "View", + "web.iceworksApp.Welcome.Information.dingtalk.title": "DingTalk", + "web.iceworksApp.Welcome.Information.dingtalk.desc": "Join us for exchange and study", + "web.iceworksApp.Welcome.Information.dingtalk.link": "Join", + "web.iceworksApp.Welcome.Information.updates.title": "Updates", + "web.iceworksApp.Welcome.Information.updates.desc": "Iceworks release details", + "web.iceworksApp.Welcome.Information.updates.link": "View" } diff --git a/extensions/iceworks-app/web/src/locales/zh-CN.json b/extensions/iceworks-app/web/src/locales/zh-CN.json index 8c7c831b7..24f38467f 100644 --- a/extensions/iceworks-app/web/src/locales/zh-CN.json +++ b/extensions/iceworks-app/web/src/locales/zh-CN.json @@ -1,28 +1,47 @@ { - "web.iceworksApp.customMaterialSource.confirmDelete": "是否确定删除该物料源?", - "web.iceworksApp.customMaterialSource.editMaterialSource": "编辑物料源", - "web.iceworksApp.customMaterialSource.addMaterialSource": "新增物料源", - "web.iceworksApp.customMaterialSource.customMaterialSource": "自定义物料源", - "web.iceworksApp.customMaterialSource.add": "添加", - "web.iceworksApp.customMaterialSource.help": "查看《物料开发》了解如何开发自定义物料源", - "web.iceworksApp.customMaterialSource.loading": "加载中...", - "web.iceworksApp.index.CUSTOM_NPM_REGISTRY_SELECT_KEY": "npm - 自定义镜像源", - "web.iceworksApp.index.addMaterialSuccess": "新增物料源成功", - "web.iceworksApp.index.editMaterialSuccess": "修改物料源成功", - "web.iceworksApp.index.deleteMaterialSuccess": "删除物料源成功", - "web.iceworksApp.index.editSettingSuccess": "设置成功", - "web.iceworksApp.index.npmPackageManager": "npm 包管理工具", - "web.iceworksApp.index.chooseNpmPackageManager": "请选择 npm 包管理工具", - "web.iceworksApp.index.npmRegistry": "npm 镜像源", - "web.iceworksApp.index.chooseNpmRegistry": "请选择 npm 镜像源", - "web.iceworksApp.index.formatUrl": "请输入正确的 url", - "web.iceworksApp.index.customNpmRegistryPlaceHolder": "请输入自定义 npm 镜像源", - "web.iceworksApp.MaterialSourceForm.materialNameLabel": "物料名称:", - "web.iceworksApp.MaterialSourceForm.materialName": "请输入物料名称", - "web.iceworksApp.MaterialSourceForm.materiaURLLabel": "物料地址:", - "web.iceworksApp.MaterialSourceForm.materiaURL": "请输入物料地址", - "web.iceworksApp.MaterialSourceForm.materialDescriptionLabel": "物料描述:", - "web.iceworksApp.MaterialSourceForm.materialDescription": "请输入物料描述", - "web.iceworksApp.MaterialSourceForm.confirm": "确定", - "web.iceworksApp.MaterialSourceForm.cancel": "取消" + "web.iceworksApp.ConfigHelper.customMaterialSource.confirmDelete": "是否确定删除该物料源?", + "web.iceworksApp.ConfigHelper.customMaterialSource.editMaterialSource": "编辑物料源", + "web.iceworksApp.ConfigHelper.customMaterialSource.addMaterialSource": "新增物料源", + "web.iceworksApp.ConfigHelper.customMaterialSource.customMaterialSource": "自定义物料源", + "web.iceworksApp.ConfigHelper.customMaterialSource.add": "添加", + "web.iceworksApp.ConfigHelper.customMaterialSource.help": "查看《物料开发》了解如何开发自定义物料源", + "web.iceworksApp.ConfigHelper.customMaterialSource.loading": "加载中...", + "web.iceworksApp.ConfigHelper.index.CUSTOM_NPM_REGISTRY_SELECT_KEY": "npm - 自定义镜像源", + "web.iceworksApp.ConfigHelper.index.addMaterialSuccess": "新增物料源成功", + "web.iceworksApp.ConfigHelper.index.editMaterialSuccess": "修改物料源成功", + "web.iceworksApp.ConfigHelper.index.deleteMaterialSuccess": "删除物料源成功", + "web.iceworksApp.ConfigHelper.index.editSettingSuccess": "设置成功", + "web.iceworksApp.ConfigHelper.index.npmPackageManager": "npm 包管理工具", + "web.iceworksApp.ConfigHelper.index.chooseNpmPackageManager": "请选择 npm 包管理工具", + "web.iceworksApp.ConfigHelper.index.npmRegistry": "npm 镜像源", + "web.iceworksApp.ConfigHelper.index.chooseNpmRegistry": "请选择 npm 镜像源", + "web.iceworksApp.ConfigHelper.index.formatUrl": "请输入正确的 url", + "web.iceworksApp.ConfigHelper.index.customNpmRegistryPlaceHolder": "请输入自定义 npm 镜像源", + "web.iceworksApp.ConfigHelper.MaterialSourceForm.materialNameLabel": "物料名称:", + "web.iceworksApp.ConfigHelper.MaterialSourceForm.materialName": "请输入物料名称", + "web.iceworksApp.ConfigHelper.MaterialSourceForm.materiaURLLabel": "物料地址:", + "web.iceworksApp.ConfigHelper.MaterialSourceForm.materiaURL": "请输入物料地址", + "web.iceworksApp.ConfigHelper.MaterialSourceForm.materialDescriptionLabel": "物料描述:", + "web.iceworksApp.ConfigHelper.MaterialSourceForm.materialDescription": "请输入物料描述", + "web.iceworksApp.ConfigHelper.MaterialSourceForm.confirm": "确定", + "web.iceworksApp.ConfigHelper.MaterialSourceForm.cancel": "取消", + "web.iceworksApp.Welcome.Content.title": "上手教程", + "web.iceworksApp.Welcome.Content.desc": "只需 30 分钟观看时间,后期大大提升开发效率", + "web.iceworksApp.Welcome.Content.videoTitle.createApplication": "1. 创建 Hello World 应用", + "web.iceworksApp.Welcome.Content.videoTitle.visualDevelopment": "2. 基于物料进行可视化开发", + "web.iceworksApp.Welcome.Content.videoTitle.genreateComponent": "3. 可视化搭建组件", + "web.iceworksApp.Welcome.Content.videoTitle.customMaterial": "4. 开发和使用自定义物料", + "web.iceworksApp.Welcome.Header.title": "欢迎来到 Iceworks", + "web.iceworksApp.Welcome.Header.desc": "Iceworks 是一个可视化智能开发助手,帮助你更快更好更轻松地开发前端应用", + "web.iceworksApp.Welcome.Information.title": "更多信息", + "web.iceworksApp.Welcome.Information.doc.title": "学习", + "web.iceworksApp.Welcome.Information.doc.desc": "为你提供体系化的能力描述", + "web.iceworksApp.Welcome.Information.doc.link": "立即查看", + "web.iceworksApp.Welcome.Information.dingtalk.title": "钉钉群", + "web.iceworksApp.Welcome.Information.dingtalk.desc": "加入官方钉钉群一起交流学习", + "web.iceworksApp.Welcome.Information.dingtalk.link": "扫码加入", + "web.iceworksApp.Welcome.Information.updates.title": "动态", + "web.iceworksApp.Welcome.Information.updates.desc": "Iceworks 版本发布详情", + "web.iceworksApp.Welcome.Information.updates.link": "立即查看", + "web.iceworksApp.Welcome.showPageOption.title": "显示欢迎页" } diff --git a/extensions/iceworks-app/web/src/app.tsx b/extensions/iceworks-app/web/src/pages/ConfigHelper/app.ts similarity index 57% rename from extensions/iceworks-app/web/src/app.tsx rename to extensions/iceworks-app/web/src/pages/ConfigHelper/app.ts index c04f11345..8dc4788a6 100644 --- a/extensions/iceworks-app/web/src/app.tsx +++ b/extensions/iceworks-app/web/src/pages/ConfigHelper/app.ts @@ -1,7 +1,10 @@ -import React from 'react'; import { createApp } from 'ice'; +import Home from './index'; const appConfig = { + router: { + routes: [{ path: '/', component: Home }], + }, app: { rootId: 'ice-container', }, diff --git a/extensions/iceworks-app/web/src/pages/ConfigHelper/CustomMaterialSource.module.scss b/extensions/iceworks-app/web/src/pages/ConfigHelper/components/CustomMaterialSource/index.module.scss similarity index 100% rename from extensions/iceworks-app/web/src/pages/ConfigHelper/CustomMaterialSource.module.scss rename to extensions/iceworks-app/web/src/pages/ConfigHelper/components/CustomMaterialSource/index.module.scss diff --git a/extensions/iceworks-app/web/src/pages/ConfigHelper/CustomMaterialSource.tsx b/extensions/iceworks-app/web/src/pages/ConfigHelper/components/CustomMaterialSource/index.tsx similarity index 79% rename from extensions/iceworks-app/web/src/pages/ConfigHelper/CustomMaterialSource.tsx rename to extensions/iceworks-app/web/src/pages/ConfigHelper/components/CustomMaterialSource/index.tsx index 3c5d0e7dc..62a6a6aa8 100644 --- a/extensions/iceworks-app/web/src/pages/ConfigHelper/CustomMaterialSource.tsx +++ b/extensions/iceworks-app/web/src/pages/ConfigHelper/components/CustomMaterialSource/index.tsx @@ -2,10 +2,10 @@ import React, { useState, Suspense } from 'react'; import { Icon, List, Button, Dialog, Avatar, Balloon } from '@alifd/next'; import { IMaterialSource } from '@iceworks/material-utils'; import { FormattedMessage, useIntl } from 'react-intl'; -import editIcon from '../../../public/assets/edit.svg'; -import deleteIcon from '../../../public/assets/delete.svg'; -import MaterialSourceForm from './MaterialSourceForm'; -import styles from './CustomMaterialSource.module.scss'; +import editIcon from '../../../../../public/assets/edit.svg'; +import deleteIcon from '../../../../../public/assets/delete.svg'; +import MaterialSourceForm from '../MaterialSourceForm'; +import styles from './index.module.scss'; enum Operation { Edit, @@ -30,7 +30,7 @@ const CustomMaterialSource: React.FC = ({ }) => { const intl = useIntl(); const [visible, setVisible] = useState(addMaterialVisible); - const [currentMaterialSource, setCurrentMaterialSource] = useState({}); + const [currentMaterialSource, setCurrentMaterialSource] = useState>({}); const [operation, setOperation] = useState(); const onDialogShow = () => setVisible(true); @@ -62,19 +62,19 @@ const CustomMaterialSource: React.FC = ({ const onDelete = (materialSource: IMaterialSource) => { Dialog.confirm({ title: 'Confirm', - content: intl.formatMessage({ id: 'web.iceworksApp.customMaterialSource.confirmDelete' }), + content: intl.formatMessage({ id: 'web.iceworksApp.ConfigHelper.customMaterialSource.confirmDelete' }), onOk: () => onSourceDelete(materialSource), }); }; const dialogTitle = operation === Operation.Edit - ? intl.formatMessage({ id: 'web.iceworksApp.customMaterialSource.editMaterialSource' }) - : intl.formatMessage({ id: 'web.iceworksApp.customMaterialSource.addMaterialSource' }); + ? intl.formatMessage({ id: 'web.iceworksApp.ConfigHelper.customMaterialSource.editMaterialSource' }) + : intl.formatMessage({ id: 'web.iceworksApp.ConfigHelper.customMaterialSource.addMaterialSource' }); return (
- + } align="r" @@ -82,14 +82,14 @@ const CustomMaterialSource: React.FC = ({ triggerType="hover" > - +
@@ -112,7 +112,7 @@ const CustomMaterialSource: React.FC = ({ ))}
- + ; visible: boolean; onSubmit: (value: any) => void; onCancel: () => void; @@ -35,7 +35,7 @@ const MaterialSourceForm: React.FC = ({ title, value, onSub triggerType="hover" > - + @@ -46,38 +46,38 @@ const MaterialSourceForm: React.FC = ({ title, value, onSub >
- + - + diff --git a/extensions/iceworks-app/web/src/pages/ConfigHelper/index.tsx b/extensions/iceworks-app/web/src/pages/ConfigHelper/index.tsx index af5211637..26b480a55 100644 --- a/extensions/iceworks-app/web/src/pages/ConfigHelper/index.tsx +++ b/extensions/iceworks-app/web/src/pages/ConfigHelper/index.tsx @@ -5,8 +5,8 @@ import { IMaterialSource } from '@iceworks/material-utils'; import { packageManagers, npmRegistries, AliNpmRegistry, AliPackageManager, urlRegExp } from '@/constants'; import callService from '@/callService'; import { useIntl } from 'react-intl'; -import { LocaleProvider } from '../../i18n'; -import CustomMaterialSource from './CustomMaterialSource'; +import { LocaleProvider } from '@/i18n'; +import CustomMaterialSource from './components/CustomMaterialSource'; import styles from './index.module.scss'; const FormItem = Form.Item; @@ -18,7 +18,7 @@ const formItemLayout = { const CUSTOM_NPM_REGISTRY_FORM_ITEM_KEY = 'customNpmRegistry'; const CUSTOM_NPM_REGISTRY_SELECT_KEY = 'npm - 自定义镜像源'; -const ConfigHelper = (props) => { +const ConfigHelper = () => { const [materialSources, setMaterialSources] = useState([]); const [fields, setFields] = useState({}); const [loading, setLoading] = useState(false); @@ -28,7 +28,7 @@ const ConfigHelper = (props) => { try { const newMaterialSources = await callService('material', 'addSource', materialSource); setMaterialSources(newMaterialSources); - Notification.success({ content: intl.formatMessage({ id: 'web.iceworksApp.index.addMaterialSuccess' }) }); + Notification.success({ content: intl.formatMessage({ id: 'web.iceworksApp.ConfigHelper.index.addMaterialSuccess' }) }); } catch (e) { Notification.error({ content: e.message }); } @@ -38,7 +38,7 @@ const ConfigHelper = (props) => { try { const newMaterialSources = await callService('material', 'updateSource', materialSource, originMaterialSource); setMaterialSources(newMaterialSources); - Notification.success({ content: intl.formatMessage({ id: 'web.iceworksApp.index.editMaterialSuccess' }) }); + Notification.success({ content: intl.formatMessage({ id: 'web.iceworksApp.ConfigHelper.index.editMaterialSuccess' }) }); } catch (e) { Notification.error({ content: e.message }); } @@ -48,7 +48,7 @@ const ConfigHelper = (props) => { try { const newMaterialSources = await callService('material', 'removeSource', materialSource.source); setMaterialSources(newMaterialSources); - Notification.success({ content: intl.formatMessage({ id: 'web.iceworksApp.index.deleteMaterialSuccess' }) }); + Notification.success({ content: intl.formatMessage({ id: 'web.iceworksApp.ConfigHelper.index.deleteMaterialSuccess' }) }); } catch (e) { Notification.error({ content: e.message }); } @@ -68,7 +68,7 @@ const ConfigHelper = (props) => { } else { await callService('common', 'saveDataToSettingJson', name, value); } - Notification.success({ content: intl.formatMessage({ id: 'web.iceworksApp.index.editSettingSuccess' }) }); + Notification.success({ content: intl.formatMessage({ id: 'web.iceworksApp.ConfigHelper.index.editSettingSuccess' }) }); } catch (e) { Notification.error({ content: e.message }); } @@ -112,10 +112,10 @@ const ConfigHelper = (props) => { ) : (
- + - + {fields.npmRegistry === CUSTOM_NPM_REGISTRY_SELECT_KEY && ( - - - + + + )} { + const intl = useIntl(); + + const videosList = [ + { + title: intl.formatMessage({ id: 'web.iceworksApp.Welcome.Content.videoTitle.createApplication' }), + videoUrl: + 'https://iceworks.oss-cn-hangzhou.aliyuncs.com/iceworks-video/%E5%88%9B%E5%BB%BA%E4%B8%80%E4%B8%AA%20Hello%20World%20%E5%BA%94%E7%94%A8.mov', + }, + { + title: intl.formatMessage({ id: 'web.iceworksApp.Welcome.Content.videoTitle.visualDevelopment' }), + videoUrl: + 'https://iceworks.oss-cn-hangzhou.aliyuncs.com/iceworks-video/%E5%8F%AF%E8%A7%86%E5%8C%96%E5%BC%80%E5%8F%91.mov', + }, + { + title: intl.formatMessage({ id: 'web.iceworksApp.Welcome.Content.videoTitle.genreateComponent' }), + videoUrl: + 'https://iceworks.oss-cn-hangzhou.aliyuncs.com/iceworks-video/%E5%8F%AF%E8%A7%86%E5%8C%96%E6%90%AD%E5%BB%BA%E7%BB%84%E4%BB%B6.mov', + }, + { + title: intl.formatMessage({ id: 'web.iceworksApp.Welcome.Content.videoTitle.customMaterial' }), + videoUrl: + 'https://iceworks.oss-cn-hangzhou.aliyuncs.com/iceworks-video/%E8%87%AA%E5%AE%9A%E4%B9%89%E7%89%A9%E6%96%99%E6%BA%90.mov', + }, + ]; + + const [selectedKeyIndex, setSelectedKeyIndex] = useState(0); + + return ( +
+
+
+
+ {/*