### Install Specific NodeJS Version
Source: https://docs.soybeanjs.cn/tutorial/nodejs
Installs a particular version of Node.js, for example, 18.20.5. This command downloads and sets up the specified Node.js runtime.
```bash
nvm install 18.20.5
```
--------------------------------
### Verify nvm Installation
Source: https://docs.soybeanjs.cn/tutorial/nodejs
Checks if the nvm command is recognized after installation by displaying its version. This confirms successful setup.
```bash
nvm --version
```
--------------------------------
### List Installed NodeJS Versions
Source: https://docs.soybeanjs.cn/tutorial/nodejs
Shows all Node.js versions that have been installed locally via nvm.
```bash
nvm ls
```
--------------------------------
### Install FNM on macOS
Source: https://docs.soybeanjs.cn/tutorial/nodejs
Installs FNM using a curl command, downloading and executing the installation script from the official FNM repository.
```bash
curl -fsSL https://fnm.vercel.app/install | bash
```
--------------------------------
### List Available NodeJS Versions
Source: https://docs.soybeanjs.cn/tutorial/nodejs
Fetches and displays a list of all remotely available Node.js versions that can be installed using nvm.
```bash
nvm ls-remote
```
--------------------------------
### Install nvm on Windows
Source: https://docs.soybeanjs.cn/tutorial/nodejs
Provides the download link for the nvm-windows installer. This tool is used to manage Node.js versions on Windows systems.
```bash
https://github.com/coreybutler/nvm-windows/releases/download/1.2.2/nvm-setup.exe
```
--------------------------------
### Switch NodeJS Version
Source: https://docs.soybeanjs.cn/tutorial/nodejs
Sets the active Node.js version to a previously installed one, for example, 18.20.5. Subsequent commands will use this version.
```bash
nvm use 18.20.5
```
--------------------------------
### Install klona
Source: https://docs.soybeanjs.cn/zh/recommend/klona
Install the klona library using npm for your project.
```bash
npm install --save klona
```
--------------------------------
### Install klona
Source: https://docs.soybeanjs.cn/recommend/klona
Install the klona package using npm for use in your project.
```bash
npm install --save klona
```
--------------------------------
### Install Node.js Versions with FNM
Source: https://docs.soybeanjs.cn/tutorial/nodejs
Installs specific Node.js versions (16, 14, 12) using the fnm install command.
```other
fnm install 16
fnm install 14
fnm install 12
```
--------------------------------
### JavaScript Route Configuration Example
Source: https://docs.soybeanjs.cn/guide/router/intro
An example of a route configuration object, demonstrating how to use the meta property with title, i18nKey, and hideInMenu from the RouteMeta interface.
```javascript
{
name: '403',
path: '/403',
component: 'layout.blank$view.403',
meta: {
title: '403',
i18nKey: 'route.403',
hideInMenu: true
}
}
```
--------------------------------
### Display FNM Help Information
Source: https://docs.soybeanjs.cn/tutorial/nodejs
Displays comprehensive help information for FNM, including all available commands and options.
```other
fnm -h
```
--------------------------------
### Test Node.js Command
Source: https://docs.soybeanjs.cn/tutorial/nodejs
Verifies the installed Node.js version by running the 'node -v' command.
```other
node -v
```
--------------------------------
### Install Chocolatey Package Manager
Source: https://docs.soybeanjs.cn/tutorial/nodejs
Installs Chocolatey, a package manager for Windows, using PowerShell. This is a prerequisite for installing fnm via Chocolatey.
```powershell
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
```
--------------------------------
### Route Configuration Example
Source: https://docs.soybeanjs.cn/guide/router/push
An example of how a route might be configured with a 'name' property, which is used as a key for the routerPushByKey method.
```json
{
"name": "soybean",
"path": "/soybean-page",
"component": "layout.base$view.soybean-page"
}
```
--------------------------------
### Install nvm on macOS
Source: https://docs.soybeanjs.cn/tutorial/nodejs
Installs the Node Version Manager (nvm) on macOS using a curl script. This tool helps manage multiple Node.js versions.
```bash
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
```
--------------------------------
### Install fnm using Chocolatey
Source: https://docs.soybeanjs.cn/tutorial/nodejs
Installs the Fast Node Manager (fnm) using the Chocolatey package manager. Requires administrator privileges.
```powershell
choco install fnm
```
--------------------------------
### Test fnm Command
Source: https://docs.soybeanjs.cn/tutorial/nodejs
Verifies that the fnm command is accessible and working by displaying its help information.
```powershell
fnm -h
```
--------------------------------
### useTable Hook Configuration Example
Source: https://docs.soybeanjs.cn/guide/hooks/use-table
A JavaScript example demonstrating how to configure and use the useTable hook. It shows passing the API function, a data transformer, and column definitions to initialize the hook.
```javascript
import { useTable } from '@/hooks/common/table';
import { fetchGetUserList } from '@/api/userApi';
const { data, loading, pagination } = useTable({
apiFn: fetchGetUserList,
transformer: response => {
const { records, total, current, size } = response.data;
return {
data: records,
pageNum: current,
pageSize: size,
total
};
},
columns: () => [
{
type: 'selection',
align: 'center',
width: 48
},
{
key: 'index',
title: 'index',
align: 'center',
width: 64
},
{
key: 'userName',
title: 'username',
align: 'center',
minWidth: 100
}
]
});
```
--------------------------------
### Install Project Dependencies with pnpm
Source: https://docs.soybeanjs.cn/guide/quick-start
Installs all necessary project dependencies using the pnpm package manager. This command should be run after cloning the repository.
```bash
pnpm i
```
--------------------------------
### Install simple-git-hooks
Source: https://docs.soybeanjs.cn/standard/lint
Installs the `simple-git-hooks` package as a development dependency. This package helps manage Git hooks by automatically setting them up based on configurations in `package.json`.
```bash
pnpm i simple-git-hooks -D
```
--------------------------------
### Configure fnm for PowerShell
Source: https://docs.soybeanjs.cn/tutorial/nodejs
Adds fnm environment configuration to PowerShell's profile script to enable automatic version switching on directory changes.
```powershell
fnm env --use-on-cd | Out-String | Invoke-Expression
```
--------------------------------
### VSCode Integrated Terminal Configuration
Source: https://docs.soybeanjs.cn/tutorial/nodejs
Configures VSCode's integrated terminal to use a specific CMD profile on Windows, executing a bashrc.cmd script upon startup.
```json
"terminal.integrated.defaultProfile.windows": "Default Cmd",
"terminal.integrated.profiles.windows": {
"Default Cmd": {
"path": "C:\\Windows\\System32\\cmd.exe",
"args": ["/k", "%USERPROFILE%\\bashrc.cmd"]
}
}
```
--------------------------------
### Install Dependencies for Offline Iconify Icons
Source: https://docs.soybeanjs.cn/guide/icon/usage
Commands to install necessary packages for using Iconify icons offline. `@iconify/vue` provides the Vue component for rendering, and `@iconify/json` includes the icon collection data.
```bash
## Include icon component data
pnpm add @iconify/vue
## Include offline icon data
pnpm add @iconify/json
```
--------------------------------
### Example Route Configuration
Source: https://docs.soybeanjs.cn/zh/guide/router/intro
An example of a route configuration object, demonstrating how to set meta properties like title, i18nKey, and hideInMenu. This structure is used for defining specific routes within the application.
```typescript
{
name: '403',
path: '/403',
component: 'layout.blank$view.403',
meta: {
title: '403',
i18nKey: 'route.403',
hideInMenu: true
}
}
```
--------------------------------
### Set up FNM Environment in Zshrc
Source: https://docs.soybeanjs.cn/tutorial/nodejs
Configures FNM to automatically manage Node.js versions based on the current directory by adding an eval command to the .zshrc file and then sourcing it.
```bash
eval "$(fnm env --use-on-cd)"
```
```bash
source ~/.zshrc
```
--------------------------------
### Configure fnm for CMD
Source: https://docs.soybeanjs.cn/tutorial/nodejs
Modifies the Command Prompt shortcut properties to load fnm environment variables via a bashrc.cmd script, enabling version switching.
```cmd
@echo off
FOR /f "tokens=\*" %%z IN ('fnm env --use-on-cd') DO CALL %%z
```
--------------------------------
### Check Current NodeJS Version
Source: https://docs.soybeanjs.cn/tutorial/nodejs
Displays the currently active Node.js version. This is useful for verifying the 'nvm use' command.
```bash
node -v
```
--------------------------------
### Vite Proxy Configuration Example
Source: https://docs.soybeanjs.cn/guide/request/proxy
Provides a concrete example of how to configure proxies in Vite using a JavaScript object. This configuration maps specific path prefixes to target servers, enabling custom proxy routing for different services.
```ts
{
'/proxy-default': {
target: 'https://default.com',
changeOrigin: true,
rewrite: (path) => path.replace(/^\/proxy-default/, ''),
},
'/proxy-demo': {
target: 'https://demo.com',
changeOrigin: true,
rewrite: (path) => path.replace(/^\/proxy-demo/, ''),
}
}
```
--------------------------------
### Vite Proxy Configuration Example
Source: https://docs.soybeanjs.cn/zh/guide/request/proxy
Demonstrates how to configure Vite proxy settings for different services, including target URLs, origin changes, and path rewriting.
```json
{
'/proxy-default': {
target: 'https://default.com',
changeOrigin: true,
rewrite: (path) => path.replace(/^\/proxy-default/, ''),
},
'/proxy-demo': {
target: 'https://demo.com',
changeOrigin: true,
rewrite: (path) => path.replace(/^\/proxy-demo/, ''),
}
}
```
--------------------------------
### Register Loading Function in main.ts
Source: https://docs.soybeanjs.cn/guide/theme/loading
This TypeScript snippet demonstrates how to register the `setupLoading` function before mounting the Vue application. This ensures the loading animation is displayed during the initial application setup phase.
```typescript
async function setupApp() {
setupLoading();
app.mount('#app');
}
```
--------------------------------
### Switch Active Node.js Version with FNM
Source: https://docs.soybeanjs.cn/tutorial/nodejs
Switches the currently active Node.js version to 16, 14, or 12 using the fnm use command.
```other
fnm use 16
fnm use 14
fnm use 12
```
--------------------------------
### Configure Git Bash for FNM
Source: https://docs.soybeanjs.cn/tutorial/nodejs
Adds FNM environment variables and path configurations to the .bash_profile for Git Bash, enabling fnm usage within the Git Bash terminal.
```bash
eval $(fnm env | sed 1d)
export PATH=$(cygpath $FNM_MULTISHELL_PATH):$PATH
if [[-f .node-version || -f .nvmrc]]; then
fnm use
fi
```
--------------------------------
### Add scripts for simple-git-hooks in package.json
Source: https://docs.soybeanjs.cn/standard/lint
Adds a `prepare` script to `package.json` that runs `simple-git-hooks` when the package is installed or updated. This ensures Git hooks are correctly registered.
```json
{
"scripts": {
"prepare": "simple-git-hooks"
}
}
```
--------------------------------
### useHookTable Usage Example
Source: https://docs.soybeanjs.cn/zh/guide/hooks/use-table
A practical example demonstrating how to use the `useHookTable` hook directly within a Vue.js component. It shows the setup of API parameters, column definitions, data transformation, and the invocation of the `getData` function.
```vue
```
--------------------------------
### Implement System Loading Animation in TypeScript
Source: https://docs.soybeanjs.cn/guide/theme/loading
This TypeScript function, `setupLoading`, creates a dynamic loading animation for system initialization. It uses theme colors to style a logo, rotating dots, and title text, then replaces the content of the '#app' DOM element with this animation. Dependencies include local storage for theme retrieval and a translation function.
```typescript
export function setupLoading() {
const themeColor = localStg.get('themeColor') || '#DB5A6B';
const { r, g, b } = getRgbOfColor(themeColor);
const primaryColor = `--primary-color: ${r} ${g} ${b}`;
const loadingClasses = [
'left-0 top-0',
'left-0 bottom-0 animate-delay-500',
'right-0 top-0 animate-delay-1000',
'right-0 bottom-0 animate-delay-1500'
];
const logoWithClass = systemLogo.replace('