-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: 添加 tools 配置添加自定义按钮配置;添加 addButton() 和 removeButton() 两个方法,用来在工具…
…栏添加按钮或者移除工具栏按钮
- Loading branch information
1 parent
eb9b2ed
commit d63fd62
Showing
49 changed files
with
1,017 additions
and
185 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
section.section | ||
header.section__header | ||
h3#method-addButton.section__h3 addButton(button) | ||
div.section__content | ||
h4.section__h4 Description | ||
p addButton() 方法添加自定义的工具栏按钮。 | ||
h4.section__h4 Parameters | ||
h5.section__h4 button | ||
dl.section__dl | ||
dt.section__dt Type: | ||
dd.section__dd Object|Array | ||
p (必须)单个按钮的配置信息或者多个按钮的配置信息。 | ||
h4.section__h4 Returns | ||
dl.section__dl | ||
dt.section__dt Type: | ||
dd.section__dd Outline | ||
p Outline 对象,便于链式方法调用。 | ||
pre.section__pre | ||
code.section__code. | ||
const outline = new Outline(Outline.DEFAULTS) | ||
// 如果需要其它图标,可以到 https://github.com/yaohaixiao/icons.toolkit.vue 项目中选择需要的图标资源 | ||
const clean = '<svg xmlns="http://www.w3.org/2000/svg" width="200" height="200" viewBox="0 0 1024 1024">' + | ||
'<path d="M704 32V320h288a32 32 0 0 1 32 32v320a32 32 0 0 1-32 32H32a32 32 0 0 1-32-32v-320A32 32 0 0 1 32 320H320V32a32 32 0 0 1 32-32h320a32 32 0 0 1 32 32zM576 128H448v320H128v128h768V448H576V128z"></path>' + | ||
'<path d="M896 576v416a32 32 0 0 1-32 32h-704a32 32 0 0 1-32-32V576h768z m-128 128H256v192h512v-192z"></path>' + | ||
'</svg>' | ||
|
||
outline.addButton({ | ||
name: 'clean', | ||
// 图标 | ||
icon: clean, | ||
size: 20, | ||
color: '#f00' | ||
// link 指定按钮点击后页面的跳转地址 | ||
link: 'https://github.com/yaohaixiao', | ||
// link 和 action 只能二选一 | ||
// action 指定按钮的处理方式 | ||
action: { | ||
type: 'click', | ||
// 指定回调函数的 this 上下文,不设置 this 指向 toolbar 组件 | ||
context: outline, | ||
handler: function() { | ||
// 回调函数的处理逻辑 | ||
} | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
section.section | ||
header.section__header | ||
h3#method-removeButton.section__h3 removeButton(name) | ||
div.section__content | ||
h4.section__h4 Description | ||
p removeButton() 方法移除工具栏按钮。 | ||
h4.section__h4 Parameters | ||
h5.section__h4 name | ||
dl.section__dl | ||
dt.section__dt Type: | ||
dd.section__dd String | ||
p (必须)按钮名称。 | ||
h4.section__h4 Returns | ||
dl.section__dl | ||
dt.section__dt Type: | ||
dd.section__dd Outline | ||
p Outline 对象,便于链式方法调用。 | ||
pre.section__pre | ||
code.section__code. | ||
const outline = new Outline(Outline.DEFAULTS) | ||
// 如果需要其它图标,可以到 https://github.com/yaohaixiao/icons.toolkit.vue 项目中选择需要的图标资源 | ||
const clean = '<svg xmlns="http://www.w3.org/2000/svg" width="200" height="200" viewBox="0 0 1024 1024">' + | ||
'<path d="M704 32V320h288a32 32 0 0 1 32 32v320a32 32 0 0 1-32 32H32a32 32 0 0 1-32-32v-320A32 32 0 0 1 32 320H320V32a32 32 0 0 1 32-32h320a32 32 0 0 1 32 32zM576 128H448v320H128v128h768V448H576V128z"></path>' + | ||
'<path d="M896 576v416a32 32 0 0 1-32 32h-704a32 32 0 0 1-32-32V576h768z m-128 128H256v192h512v-192z"></path>' + | ||
'</svg>' | ||
|
||
outline.addButton({ | ||
name: 'clean', | ||
// 图标 | ||
icon: clean, | ||
size: 20, | ||
color: '#f00' | ||
// link 指定按钮点击后页面的跳转地址 | ||
link: 'https://github.com/yaohaixiao', | ||
// link 和 action 只能二选一 | ||
// action 指定按钮的处理方式 | ||
action: { | ||
type: 'click', | ||
// 指定回调函数的 this 上下文,不设置 this 指向 toolbar 组件 | ||
context: outline, | ||
handler: function() { | ||
// 回调函数的处理逻辑 | ||
} | ||
} | ||
}) | ||
|
||
setTimeout(() => { | ||
outline.addButton('clean') | ||
}, 5000) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
section.section | ||
header.section__header | ||
h3#option-tools.section__h3 tools | ||
div.section__content | ||
h4.section__h4 Description | ||
dl.section__dl | ||
dt.section__dt Type: | ||
dd.section__dd Array | ||
dl.section__dl | ||
dt.section__dt Default: | ||
dd.section__dd [] | ||
p 可选,自定义的按钮配置项。tools 中的按钮会排列显示在 homepage, git, tags, issues 等按钮之后。 | ||
pre.section__pre | ||
code.section__code. | ||
const outline = new Outline(Outline.DEFAULTS) | ||
// 如果需要其它图标,可以到 https://github.com/yaohaixiao/icons.toolkit.vue 项目中选择需要的图标资源 | ||
const clean = '<svg xmlns="http://www.w3.org/2000/svg" width="200" height="200" viewBox="0 0 1024 1024">' + | ||
'<path d="M704 32V320h288a32 32 0 0 1 32 32v320a32 32 0 0 1-32 32H32a32 32 0 0 1-32-32v-320A32 32 0 0 1 32 320H320V32a32 32 0 0 1 32-32h320a32 32 0 0 1 32 32zM576 128H448v320H128v128h768V448H576V128z"></path>' + | ||
'<path d="M896 576v416a32 32 0 0 1-32 32h-704a32 32 0 0 1-32-32V576h768z m-128 128H256v192h512v-192z"></path>' + | ||
'</svg>' | ||
|
||
// 侧边栏的 Toolbar 会多出一个 git 图标的按钮 | ||
outline.reload({ | ||
git: 'https://github.com/yaohaixiao/outline.js', | ||
tools: [ | ||
{ | ||
name: 'clean', | ||
// 图标 | ||
icon: clean, | ||
size: 20, | ||
color: '#f00' | ||
// link 指定按钮点击后页面的跳转地址 | ||
link: 'https://github.com/yaohaixiao', | ||
// link 和 action 只能二选一 | ||
// action 指定按钮的处理方式 | ||
action: { | ||
type: 'click', | ||
// 指定回调函数的 this 上下文,不设置 this 指向 toolbar 组件 | ||
context: outline, | ||
handler: function() { | ||
// 回调函数的处理逻辑 | ||
} | ||
} | ||
} | ||
] | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
section.section | ||
header.section__header | ||
h3#property-buttons.section__h3 buttons | ||
div.section__content | ||
h4.section__h4 Description | ||
dl.section__dl | ||
dt.section__dt Type: | ||
dd.section__dd Array | ||
p 存储的是 Outline 对象当前工具栏的完整的按钮配置信息: | ||
pre.section__pre | ||
code.section__code. | ||
// 设置默认配置项 | ||
const outline = new Outline(Outline.DEFAULTS) | ||
|
||
// 查看全部按钮配置信息 | ||
outline.buttons | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.