mirror of
https://gitee.com/vnotex/vnote.git
synced 2025-07-05 13:59:52 +08:00
add docs about task
This commit is contained in:
parent
5e1f145441
commit
64db9f16e8
294
en_us/docs/Users/Task.md
Normal file
294
en_us/docs/Users/Task.md
Normal file
@ -0,0 +1,294 @@
|
||||
# Task
|
||||
VNote supports a simple task system like [VSCode Tasks](https://code.visualstudio.com/docs/editor/tasks), which enables executing third-party programs easily.
|
||||
|
||||
## Loading Tasks
|
||||
VNote will try to load tasks from three locations:
|
||||
|
||||
* `default_config_folder/tasks` for built-in tasks
|
||||
* `user_config_folder/tasks` for user-defined tasks
|
||||
* `notebook_config_folder/tasks` for tasks defined by this notebook
|
||||
|
||||
A task is defined by a `*.json` entry file.
|
||||
|
||||
## A Simple Task
|
||||
Click the `Add Task` item on the task menu, which will open the user-defined tasks folder.
|
||||
|
||||

|
||||
|
||||
New a folder named `hello` and under it create a file named `hello.json`. Edit the JSON file as:
|
||||
|
||||
```json
|
||||
{
|
||||
"command": "echo 'Hello Tasks'"
|
||||
}
|
||||
```
|
||||
|
||||
Reload tasks in the menu and we could see that a new task named `hello` is listed on the menu. Click it to run the task.
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
### Customize Menu Item
|
||||
```json
|
||||
{
|
||||
"label": "Hello",
|
||||
"icon": "tasks-solid.svg",
|
||||
"shortcut": "Alt+H, T",
|
||||
"command": "echo",
|
||||
"args": [
|
||||
"Hello tasks!"
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
The icon file `tasks-solid.svg` should be saved alongside the JSON entry file.
|
||||
|
||||
### Sub-Tasks
|
||||
Tasks could be embedded infinitely. Sub-tasks will inherit most properties from parent.
|
||||
|
||||
```json
|
||||
{
|
||||
"label": "Hello Tasks",
|
||||
"icon": "tasks-solid.svg",
|
||||
"shortcut": "Alt+H, T",
|
||||
"command": "echo",
|
||||
"args": ["Hello tasks!"],
|
||||
"tasks": [
|
||||
{
|
||||
"label": "Hello Cat",
|
||||
"icon": "cat-solid.svg",
|
||||
"shortcut": "Alt+H, C",
|
||||
"args": ["Hello cat!"]
|
||||
},
|
||||
{
|
||||
"label": "Hello Dove",
|
||||
"icon": "dove-solid.svg",
|
||||
"shortcut": "Alt+H, D",
|
||||
"args": ["Hello dove!"]
|
||||
},
|
||||
{
|
||||
"label": "Hello Fish",
|
||||
"icon": "fish-solid.svg",
|
||||
"shortcut": "Alt+H, F",
|
||||
"args": ["Hello fish!"]
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### Command Types
|
||||
The `type` property of one task defines how the command will be executed.
|
||||
|
||||
* `shell`: Default, will run the command as a shell command
|
||||
* `process`: Will run the command as a standalone program
|
||||
|
||||
```json
|
||||
{
|
||||
"type": "process",
|
||||
"label": "Open File with",
|
||||
"args": ["${file}"],
|
||||
"tasks": [
|
||||
{
|
||||
"label": "Typora",
|
||||
"icon": "Typora.svg",
|
||||
"command": "C:\\Programs\\Typora0.9.98\\x64\\Typora.exe"
|
||||
},
|
||||
{
|
||||
"label": "VS Code",
|
||||
"icon": "vscode.svg",
|
||||
"command": "C:\\Users\\tootal\\AppData\\Local\\Programs\\Microsoft VS Code\\Code.exe"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
::: alert-info
|
||||
|
||||
Yep, `tootal` is the contributor who initiated the Task system of VNote!
|
||||
|
||||
:::
|
||||
|
||||
VNote does not provide a terminal. We may need to use `start` or `gnome-terminal` or `konsole` to run some programs in terminal.
|
||||
|
||||
```json
|
||||
{
|
||||
"label": "Vim",
|
||||
"icon": "vim.svg",
|
||||
"type": "process",
|
||||
"command": "gnome-terminal",
|
||||
"args": [
|
||||
"--execute",
|
||||
"vim",
|
||||
"${file}"
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### Localization and Platform-Specific Options
|
||||
Provide a **locale string** JSON object to provide localization.
|
||||
|
||||
```json
|
||||
{
|
||||
"label": {
|
||||
"en_US": "Hello",
|
||||
"zh_CN": "你好"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
We could use `windows`/`linux`/`osx` keyword to specify options for different platforms.
|
||||
|
||||
```json
|
||||
{
|
||||
"type": "process",
|
||||
"label": "Open File with",
|
||||
"args": ["${file}"],
|
||||
"tasks": [
|
||||
{
|
||||
"label": "Typora",
|
||||
"icon": "Typora.svg",
|
||||
"windows": {
|
||||
"command": "C:\\Programs\\Typora0.9.98\\x64\\Typora.exe"
|
||||
},
|
||||
"linux": {
|
||||
"command": "/usr/bin/typora"
|
||||
}
|
||||
},
|
||||
{
|
||||
"label": "VS Code",
|
||||
"icon": "vscode.svg",
|
||||
"windows": {
|
||||
"command": "C:\\Users\\tootal\\AppData\\Local\\Programs\\Microsoft VS Code\\Code.exe"
|
||||
},
|
||||
"linux": {
|
||||
"command": "/usr/bin/code"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## Task Options
|
||||
A task could have several options, some of them are mandatory.
|
||||
|
||||
We will use `[m]` to mark the mandatory options, `[l]` to mark the options supporting localization.
|
||||
|
||||
* `version`: the version of the task file
|
||||
* `label[l]`: the name of the task
|
||||
* `type`: the type of task; `shell`(default)/`process`
|
||||
* `command[l]`: the command to execute
|
||||
* `args[l]`: the arguments passed to the command
|
||||
* `options`: options for runnig task
|
||||
* `cwd`: current working directory to run task; will try current notebook root folder, then current buffer folder, and then current task file folder in order if missing
|
||||
* `env`: environment variables for running task
|
||||
* `shell`: options for tasks of `shell` type
|
||||
* `executable`: the shell executable file; `Powershell.exe` by default on Windows and `/bin/bash` by default on Linux/macOS
|
||||
* `args`: the arguments to start shell
|
||||
* `tasks`: define sub-tasks
|
||||
* `inputs`: define input variables
|
||||
* `id[m]`: ID of the input variable
|
||||
* `type`: `promptString` (default, prompt for user input) or `pickString` (prompt for user selection)
|
||||
* `description[l]`: description of the input variable
|
||||
* `default[l]`: default value
|
||||
* `password`: whether use password mode for `promptString` type
|
||||
* `options[l]`: options defined for `pickString` type
|
||||
* `windows`: options for Windows system
|
||||
* `linux`: options for Linux system
|
||||
* `osx`: options for macOS system
|
||||
|
||||
## Variables
|
||||
A task could use variables provided by VNote in the form `${variableName}`. Variables could provide useful information to the task when running.
|
||||
|
||||
Variables could be used in options `command`/`args`/`options.cwd`/`options.env`.
|
||||
|
||||
### Built-In Variables
|
||||
Notebook-related variables:
|
||||
|
||||
* `notebookFolder`: path of the notebook root folder
|
||||
* `notebookFolderName`
|
||||
* `notebookName`
|
||||
* `notebookDescription`
|
||||
|
||||
Buffer-related variables:
|
||||
|
||||
* `buffer`: path of current buffer
|
||||
* `bufferNotebookFolder`: path of the notebook root folder of the notebook of current buffer
|
||||
* `bufferRelativePath`
|
||||
* `bufferName`
|
||||
* `bufferBaseName`
|
||||
* `bufferDir`: folder of current buffer
|
||||
* `bufferExt`: extension suffix of current buffer
|
||||
* `selectedText`: selected text of current buffer view window
|
||||
|
||||
Task-related variables:
|
||||
|
||||
* `cwd`: current working directory
|
||||
* `taskFile`: the path of the task entry file
|
||||
* `taskDir`: the path of the directory containing the task entry file
|
||||
* `exeFile`: the path of VNote executable file
|
||||
* `pathSeparator`: the platform-dependent path separator
|
||||
* `notebookTaskFolder`: the path of current notebook task folder
|
||||
* `userTaskFolder`: the path of user task folder
|
||||
* `appTaskFolder`: the path of default task folder
|
||||
* `userThemeFolder`: the path of user theme folder
|
||||
* `appThemeFolder`: the path of default theme folder
|
||||
* `userDocsFolder`: the path of user docs folder
|
||||
* `appDocsFolder`: the path of default docs folder
|
||||
|
||||
Other specifal variables:
|
||||
|
||||
* Call **snippets** of VNote via `${magic:snippet_name}`
|
||||
* Access environment variable via `${env:env_name}`
|
||||
* Access VNote's configurations via `${config:[main|session].json_object_path}`
|
||||
* `main` for the main configurations from `vnotex.json` and `session` for the session configurations from `session.json`
|
||||
* Use `arr[index]` to access a JSON array
|
||||
* `${config:main.core.shortcuts.FullScreen}` will get the shortcut of `FullScreen`
|
||||
|
||||
#### Input Variables
|
||||
A task could use **input variables** to prompt for user inputs via `${input:input_id}`.
|
||||
|
||||
There are now two types of input variables:
|
||||
|
||||
* `promptString`
|
||||
* `pickString`
|
||||
|
||||
```json
|
||||
{
|
||||
"command": "echo",
|
||||
"args": ["${input:what}"],
|
||||
"inputs": [
|
||||
{
|
||||
"id": "what",
|
||||
"type": "promptString",
|
||||
"description": "Type something, it will show in output panel."
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
#### Shell Variables
|
||||
A task could execute a shell command and get its output via **shell variables** like `${shell:shell_command}`.
|
||||
|
||||
* `${shell:git rev-parse --abbrev-ref HEAD}` → `master`
|
||||
* `${shell:whoami}` → `tootal`
|
||||
* `${shell:dig github.com -4 +short}` → `52.69.186.44`
|
||||
|
||||
## Examples
|
||||
There is a built-in task named `Git` which locates in the default configuration task folder.
|
||||
|
||||
Compile and run:
|
||||
|
||||
```json
|
||||
{
|
||||
"command": "g++ \"${file}\" -o \"${fileBasenameNoExtension}\"; if ($?) { start cmd \"/c `\"${fileBasenameNoExtension}`\" & pause\" }"
|
||||
}
|
||||
```
|
||||
|
||||
Run a HTTP server:
|
||||
|
||||
```json
|
||||
{
|
||||
"command": "start cmd.exe \"/c python -m http.server\" ; start http://localhost:8000"
|
||||
}
|
||||
```
|
@ -19,7 +19,7 @@ Some key files of a theme:
|
||||
- `highlight.css`: style sheet file of the read mode of Markdown for code block syntax highlight; VNote uses [Prism](https://prismjs.com/) for syntax highlight in read mode;
|
||||
|
||||
## Samples
|
||||
### Custom Fonts
|
||||
### Customize Editor Fonts
|
||||
#### Read Mode
|
||||
For the font in **read mode**, it is specified in `web.css` by the `font-family` and `font-size`.
|
||||
|
||||
@ -126,3 +126,32 @@ Markdown editor:
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Customize Interface Fonts
|
||||
We need to edit `interface.qss` to customize the fonts of interface, such as the menu and the navigation tree.
|
||||
|
||||
[Qt docs](https://doc.qt.io/qt-5/stylesheet-examples.html) provides many detailed examples about the Qt stylesheet.
|
||||
|
||||
Change the font size of all the widgets:
|
||||
|
||||
```css
|
||||
QWidget {
|
||||
font-size: 12pt;
|
||||
}
|
||||
```
|
||||
|
||||
Change the font size of all the tree view and list view:
|
||||
|
||||
```css
|
||||
QTreeView, QListView {
|
||||
font-size: 12pt;
|
||||
}
|
||||
```
|
||||
|
||||
Change the font size of the notebook node explorer:
|
||||
|
||||
```css
|
||||
vnotex--NotebookNodeExplorer QTreeView {
|
||||
font-size: 14pt;
|
||||
}
|
||||
```
|
@ -31,6 +31,16 @@
|
||||
"tags": [
|
||||
]
|
||||
},
|
||||
{
|
||||
"attachment_folder": "",
|
||||
"created_time": "2018-11-24T12:22:16Z",
|
||||
"id": "15",
|
||||
"modified_time": "2021-07-13T12:08:47Z",
|
||||
"name": "Frequently Asked Questions.md",
|
||||
"signature": "20733444373619",
|
||||
"tags": [
|
||||
]
|
||||
},
|
||||
{
|
||||
"attachment_folder": "",
|
||||
"created_time": "2018-11-24T12:13:02Z",
|
||||
@ -75,7 +85,7 @@
|
||||
"attachment_folder": "",
|
||||
"created_time": "2018-11-24T12:18:17Z",
|
||||
"id": "12",
|
||||
"modified_time": "2021-07-29T13:14:53Z",
|
||||
"modified_time": "2021-12-23T05:58:40Z",
|
||||
"name": "Themes and Styles.md",
|
||||
"signature": "2110466178163",
|
||||
"tags": [
|
||||
@ -103,11 +113,11 @@
|
||||
},
|
||||
{
|
||||
"attachment_folder": "",
|
||||
"created_time": "2018-11-24T12:22:16Z",
|
||||
"id": "15",
|
||||
"modified_time": "2021-07-13T12:08:47Z",
|
||||
"name": "Frequently Asked Questions.md",
|
||||
"signature": "20733444373619",
|
||||
"created_time": "2021-12-23T07:29:06Z",
|
||||
"id": "49",
|
||||
"modified_time": "2021-12-24T13:29:09Z",
|
||||
"name": "Task.md",
|
||||
"signature": "177733903682",
|
||||
"tags": [
|
||||
]
|
||||
}
|
||||
|
BIN
en_us/docs/Users/vx_images/268813715229690.png
Normal file
BIN
en_us/docs/Users/vx_images/268813715229690.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 7.2 KiB |
BIN
en_us/docs/Users/vx_images/508234115217557.png
Normal file
BIN
en_us/docs/Users/vx_images/508234115217557.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 9.8 KiB |
BIN
en_us/docs/Users/vx_images/513614215237723.png
Normal file
BIN
en_us/docs/Users/vx_images/513614215237723.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.0 KiB |
@ -3,7 +3,7 @@
|
||||
|
||||
::: alert-success
|
||||
|
||||
VNote 3.10.1 is released! Check out [what's new](https://github.com/vnotex/vnote/releases)!
|
||||
VNote 3.11.0 is released! Check out [what's new](https://github.com/vnotex/vnote/releases)!
|
||||
|
||||
:::
|
||||
|
||||
@ -34,7 +34,7 @@ VNote 3.10.1 is released! Check out [what's new](https://github.com/vnotex/vnote
|
||||

|
||||
|
||||
## Concentration
|
||||
- **No** live preview side by side
|
||||
- In-place preview or side-by-side live preview
|
||||
- Focus on your note in both **read** and **edit** mode
|
||||
|
||||

|
||||
|
@ -5,7 +5,7 @@
|
||||
"attachment_folder": "",
|
||||
"created_time": "2018-11-24T05:04:27Z",
|
||||
"id": "19",
|
||||
"modified_time": "2021-08-29T03:16:36Z",
|
||||
"modified_time": "2021-12-24T13:37:07Z",
|
||||
"name": "index.md",
|
||||
"signature": "79316798291059",
|
||||
"tags": [
|
||||
|
Binary file not shown.
@ -31,6 +31,16 @@
|
||||
"tags": [
|
||||
]
|
||||
},
|
||||
{
|
||||
"attachment_folder": "",
|
||||
"created_time": "2018-11-24T12:31:22Z",
|
||||
"id": "42",
|
||||
"modified_time": "2021-07-13T12:07:30Z",
|
||||
"name": "常见问题.md",
|
||||
"signature": "75906594258035",
|
||||
"tags": [
|
||||
]
|
||||
},
|
||||
{
|
||||
"attachment_folder": "",
|
||||
"created_time": "2018-11-24T12:29:25Z",
|
||||
@ -75,7 +85,7 @@
|
||||
"attachment_folder": "",
|
||||
"created_time": "2018-11-24T12:30:05Z",
|
||||
"id": "39",
|
||||
"modified_time": "2021-07-29T13:15:36Z",
|
||||
"modified_time": "2021-12-23T06:01:10Z",
|
||||
"name": "主题和样式.md",
|
||||
"signature": "102269103520883",
|
||||
"tags": [
|
||||
@ -103,11 +113,11 @@
|
||||
},
|
||||
{
|
||||
"attachment_folder": "",
|
||||
"created_time": "2018-11-24T12:31:22Z",
|
||||
"id": "42",
|
||||
"modified_time": "2021-07-13T12:07:30Z",
|
||||
"name": "常见问题.md",
|
||||
"signature": "75906594258035",
|
||||
"created_time": "2021-12-24T07:55:35Z",
|
||||
"id": "50",
|
||||
"modified_time": "2021-12-24T13:34:53Z",
|
||||
"name": "任务.md",
|
||||
"signature": "177733991671",
|
||||
"tags": [
|
||||
]
|
||||
}
|
||||
|
BIN
zh_cn/docs/用户/vx_images/12811816237724.png
Normal file
BIN
zh_cn/docs/用户/vx_images/12811816237724.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.0 KiB |
BIN
zh_cn/docs/用户/vx_images/310341616229691.png
Normal file
BIN
zh_cn/docs/用户/vx_images/310341616229691.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 7.2 KiB |
BIN
zh_cn/docs/用户/vx_images/566291716217558.png
Normal file
BIN
zh_cn/docs/用户/vx_images/566291716217558.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 9.8 KiB |
@ -19,7 +19,7 @@
|
||||
- `highlight.css`: Markdown阅读模式的代码块语法高亮样式文件;VNote在阅读模式使用[Prism](https://prismjs.com/)来进行语法高亮;
|
||||
|
||||
## 示例
|
||||
### 自定义字体
|
||||
### 自定义编辑器字体
|
||||
#### 阅读模式
|
||||
**阅读模式**的字体定义在文件`web.css`的`font-family`和`font-size`中。
|
||||
|
||||
@ -126,3 +126,32 @@ Markdown编辑器:
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### 自定义界面字体
|
||||
我们需要编辑`interface.qss`来自定义界面字体,例如菜单或者导航树。
|
||||
|
||||
[Qt文档](https://doc.qt.io/qt-5/stylesheet-examples.html)提供了关于Qt样式的很详细的例子。
|
||||
|
||||
改变所有部件的字体大小:
|
||||
|
||||
```css
|
||||
QWidget {
|
||||
font-size: 12pt;
|
||||
}
|
||||
```
|
||||
|
||||
改变所有树或者列表部件的字体大小:
|
||||
|
||||
```css
|
||||
QTreeView, QListView {
|
||||
font-size: 12pt;
|
||||
}
|
||||
```
|
||||
|
||||
改变笔记本节点浏览器的字体大小:
|
||||
|
||||
```css
|
||||
vnotex--NotebookNodeExplorer QTreeView {
|
||||
font-size: 14pt;
|
||||
}
|
||||
```
|
294
zh_cn/docs/用户/任务.md
Normal file
294
zh_cn/docs/用户/任务.md
Normal file
@ -0,0 +1,294 @@
|
||||
# 任务
|
||||
VNote支持一个类似于[VSCode Tasks](https://code.visualstudio.com/docs/editor/tasks)的简单任务系统,可以方便地执行第三方程序。
|
||||
|
||||
## 加载任务
|
||||
VNote会尝试从下面三个位置加载任务:
|
||||
|
||||
* `默认配置文件夹/tasks`包含内置的任务
|
||||
* `用户配置文件夹/tasks`包含用户定义的任务
|
||||
* `笔记本配置文件夹/tasks`包含该笔记本定义的任务
|
||||
|
||||
一个任务由一个`*.json`的入口文件给出定义。
|
||||
|
||||
## 一个简单的任务
|
||||
点击任务菜单中的`添加任务`,打开用户定义的任务文件夹。
|
||||
|
||||

|
||||
|
||||
新建一个文件夹`hello`并在其下面新建一个文件`hello.json`。编辑该文件如下:
|
||||
|
||||
```json
|
||||
{
|
||||
"command": "echo 'Hello Tasks'"
|
||||
}
|
||||
```
|
||||
|
||||
重新加载任务,我们可以看到菜单里面列出了一个新的任务`hello`。点击运行该任务。
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
### 自定义菜单项
|
||||
```json
|
||||
{
|
||||
"label": "Hello",
|
||||
"icon": "tasks-solid.svg",
|
||||
"shortcut": "Alt+H, T",
|
||||
"command": "echo",
|
||||
"args": [
|
||||
"Hello tasks!"
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
其中的图标文件`tasks-solid.svg`需要保存在JSON入口文件同目录。
|
||||
|
||||
### 子任务
|
||||
任务可以无限嵌套。子任务会继承父任务的大部分属性。
|
||||
|
||||
```json
|
||||
{
|
||||
"label": "Hello Tasks",
|
||||
"icon": "tasks-solid.svg",
|
||||
"shortcut": "Alt+H, T",
|
||||
"command": "echo",
|
||||
"args": ["Hello tasks!"],
|
||||
"tasks": [
|
||||
{
|
||||
"label": "Hello Cat",
|
||||
"icon": "cat-solid.svg",
|
||||
"shortcut": "Alt+H, C",
|
||||
"args": ["Hello cat!"]
|
||||
},
|
||||
{
|
||||
"label": "Hello Dove",
|
||||
"icon": "dove-solid.svg",
|
||||
"shortcut": "Alt+H, D",
|
||||
"args": ["Hello dove!"]
|
||||
},
|
||||
{
|
||||
"label": "Hello Fish",
|
||||
"icon": "fish-solid.svg",
|
||||
"shortcut": "Alt+H, F",
|
||||
"args": ["Hello fish!"]
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### 命令类型
|
||||
任务的`type`属性定义了该任务的命令是如何被执行的。
|
||||
|
||||
* `shell`: 默认,将命令作为一个shell命令执行
|
||||
* `process`: 将命令作为一个独立的程序执行
|
||||
|
||||
```json
|
||||
{
|
||||
"type": "process",
|
||||
"label": "Open File with",
|
||||
"args": ["${file}"],
|
||||
"tasks": [
|
||||
{
|
||||
"label": "Typora",
|
||||
"icon": "Typora.svg",
|
||||
"command": "C:\\Programs\\Typora0.9.98\\x64\\Typora.exe"
|
||||
},
|
||||
{
|
||||
"label": "VS Code",
|
||||
"icon": "vscode.svg",
|
||||
"command": "C:\\Users\\tootal\\AppData\\Local\\Programs\\Microsoft VS Code\\Code.exe"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
::: alert-info
|
||||
|
||||
是的,`tootal`就是那个发起VNote任务系统的贡献者!
|
||||
|
||||
:::
|
||||
|
||||
VNote没有提供一个终端。我们可能需要使用`start`或者`gnome-terminal`或者`konsole`来在终端里面运行某些程序。
|
||||
|
||||
```json
|
||||
{
|
||||
"label": "Vim",
|
||||
"icon": "vim.svg",
|
||||
"type": "process",
|
||||
"command": "gnome-terminal",
|
||||
"args": [
|
||||
"--execute",
|
||||
"vim",
|
||||
"${file}"
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### 本地化和平台依赖选项
|
||||
可以通过一个**区域字符串**JSON对象来提供本地化。
|
||||
|
||||
```json
|
||||
{
|
||||
"label": {
|
||||
"en_US": "Hello",
|
||||
"zh_CN": "你好"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
可以使用`windows`/`linux`/`osx`关键词来指明不同平台的选项。
|
||||
|
||||
```json
|
||||
{
|
||||
"type": "process",
|
||||
"label": "Open File with",
|
||||
"args": ["${file}"],
|
||||
"tasks": [
|
||||
{
|
||||
"label": "Typora",
|
||||
"icon": "Typora.svg",
|
||||
"windows": {
|
||||
"command": "C:\\Programs\\Typora0.9.98\\x64\\Typora.exe"
|
||||
},
|
||||
"linux": {
|
||||
"command": "/usr/bin/typora"
|
||||
}
|
||||
},
|
||||
{
|
||||
"label": "VS Code",
|
||||
"icon": "vscode.svg",
|
||||
"windows": {
|
||||
"command": "C:\\Users\\tootal\\AppData\\Local\\Programs\\Microsoft VS Code\\Code.exe"
|
||||
},
|
||||
"linux": {
|
||||
"command": "/usr/bin/code"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 任务选项
|
||||
一个任务可以有多个选项,其中有一些是必须的。
|
||||
|
||||
我们使用`[m]`来标记必须选项,`[l]`来标记支持本地化的选项。
|
||||
|
||||
* `version`: 任务文件的版本
|
||||
* `label[l]`: 任务的名字
|
||||
* `type`: 任务的类型,`shell`(默认)或者`process`
|
||||
* `command[l]`: 需要执行的命令
|
||||
* `args[l]`: 传递给命令的参数
|
||||
* `options`: 运行任务的选项
|
||||
* `cwd`: 运行任务时的当前工作目录;如果不指定,会顺序尝试当前笔记本根文件夹,然后当前缓冲区所在文件夹,然后是当前任务文件所在文件夹
|
||||
* `env`: 运行任务的环境变量
|
||||
* `shell`: `shell`类型的任务的选项
|
||||
* `executable`: shell可执行文件;Windows上默认为`Powershell.exe`,Linux/macOS上默认为`/bin/bash`
|
||||
* `args`: 启动shell的参数
|
||||
* `tasks`: 定义子任务
|
||||
* `inputs`: 定义输入变量
|
||||
* `id[m]`: 输入变量的ID
|
||||
* `type`: `promptString`(默认,会提示用户输入),`pickString`(提示用户选择)
|
||||
* `description[l]`: 输入变量的描述
|
||||
* `default[l]`: 默认值
|
||||
* `password`: `promptString`类型下,是否启用密码模式
|
||||
* `options[l]`: `pickString`类型下提供的选项
|
||||
* `windows`: 指定Windows系统的选项
|
||||
* `linux`: 指定Linux系统的选项
|
||||
* `osx`: 指定macOS系统的选项
|
||||
|
||||
## 变量
|
||||
一个任务可以通过形式`${variableName}`来使用VNote提供的变量。变量可以在任务运行时提供有用的信息。
|
||||
|
||||
变量可以在选项`command`/`args`/`options.cwd`/`options.env`中使用。
|
||||
|
||||
### 内建变量
|
||||
笔记本相关变量:
|
||||
|
||||
* `notebookFolder`: 笔记本根文件夹路径
|
||||
* `notebookFolderName`
|
||||
* `notebookName`
|
||||
* `notebookDescription`
|
||||
|
||||
缓冲区相关变量:
|
||||
|
||||
* `buffer`: 当前缓冲区路径
|
||||
* `bufferNotebookFolder`: 当前缓冲区所属笔记本的根文件夹路径
|
||||
* `bufferRelativePath`
|
||||
* `bufferName`
|
||||
* `bufferBaseName`
|
||||
* `bufferDir`: 当前缓冲区所在目录
|
||||
* `bufferExt`: 当前缓冲区的扩展名后缀
|
||||
* `selectedText`: 当前缓冲区查看窗口的所选文本
|
||||
|
||||
任务相关变量:
|
||||
|
||||
* `cwd`: 当前工作目录
|
||||
* `taskFile`: 任务入口文件路径
|
||||
* `taskDir`: 任务入口文件所在目录
|
||||
* `exeFile`: VNote可执行文件路径
|
||||
* `pathSeparator`: 平台相关的路径分隔符
|
||||
* `notebookTaskFolder`: 当前笔记本任务文件夹路径
|
||||
* `userTaskFolder`: 用户任务文件夹路径
|
||||
* `appTaskFolder`: 默认任务文件夹路径
|
||||
* `userThemeFolder`: 用户主题文件夹路径
|
||||
* `appThemeFolder`: 默认主题文件夹路径
|
||||
* `userDocsFolder`: 用户文档文件夹路径
|
||||
* `appDocsFolder`: 默认文档文件夹路径
|
||||
|
||||
其他特殊变量:
|
||||
|
||||
* 通过`${magic:snippet_name}`引用VNote的**片段**
|
||||
* 通过`${env:env_name}`访问环境变量
|
||||
* 通过`${config:[main|session].json_object_path}`访问VNote的配置选项
|
||||
* `main`对应读取自`vnotex.json`的主要配置,`session`对应读取自`session.json`的会话配置
|
||||
* 使用`arr[index]`来访问一个JSON数组
|
||||
* 例如`${config:main.core.shortcuts.FullScreen}`可以读取`FullScreen`对应的快捷键
|
||||
|
||||
#### 输入变量
|
||||
一个任务可以通过`${input:input_id}`使用**输入变量**来提示用户提供输入
|
||||
|
||||
目前有两种类型的输入变量:
|
||||
|
||||
* `promptString`
|
||||
* `pickString`
|
||||
|
||||
```json
|
||||
{
|
||||
"command": "echo",
|
||||
"args": ["${input:what}"],
|
||||
"inputs": [
|
||||
{
|
||||
"id": "what",
|
||||
"type": "promptString",
|
||||
"description": "Type something, it will show in output panel."
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
#### Shell变量
|
||||
一个任务可以通过`${shell:shell_command}`使用**shell变量**来执行一个shell命令并获取其输出。
|
||||
|
||||
* `${shell:git rev-parse --abbrev-ref HEAD}` → `master`
|
||||
* `${shell:whoami}` → `tootal`
|
||||
* `${shell:dig github.com -4 +short}` → `52.69.186.44`
|
||||
|
||||
## 示例
|
||||
在默认配置任务文件夹中有一个内建的`Git`任务。
|
||||
|
||||
编译并运行:
|
||||
|
||||
```json
|
||||
{
|
||||
"command": "g++ \"${file}\" -o \"${fileBasenameNoExtension}\"; if ($?) { start cmd \"/c `\"${fileBasenameNoExtension}`\" & pause\" }"
|
||||
}
|
||||
```
|
||||
|
||||
运行一个HTTP服务:
|
||||
|
||||
```json
|
||||
{
|
||||
"command": "start cmd.exe \"/c python -m http.server\" ; start http://localhost:8000"
|
||||
}
|
||||
```
|
@ -3,7 +3,7 @@
|
||||
|
||||
::: alert-success
|
||||
|
||||
VNote 3.10.1已发布! 看看都有[哪些更新](https://github.com/vnotex/vnote/releases) !
|
||||
VNote 3.11.0已发布! 看看都有[哪些更新](https://github.com/vnotex/vnote/releases) !
|
||||
|
||||
观看[展示录屏](https://www.bilibili.com/video/av77455284) !
|
||||
|
||||
@ -36,7 +36,7 @@ VNote 3.10.1已发布! 看看都有[哪些更新](https://github.com/vnotex/vn
|
||||

|
||||
|
||||
## 专注
|
||||
- 没有双边实时预览
|
||||
- 原地预览或者双边实时预览
|
||||
- 通过**阅读**和**编辑**模式以专注于笔记
|
||||
|
||||

|
||||
|
@ -25,7 +25,7 @@
|
||||
"attachment_folder": "",
|
||||
"created_time": "2018-11-24T09:30:11Z",
|
||||
"id": "47",
|
||||
"modified_time": "2021-08-29T03:16:48Z",
|
||||
"modified_time": "2021-12-24T13:36:34Z",
|
||||
"name": "index.md",
|
||||
"signature": "53181922294899",
|
||||
"tags": [
|
||||
|
Loading…
x
Reference in New Issue
Block a user