@@ -172,7 +201,8 @@ export default {
activeFileNode: {},
dirDialogVisible: false,
fileDialogVisible: false,
- nodeExpandedDict: {}
+ nodeExpandedDict: {},
+ isShowDeleteNav: false
}
},
computed: {
@@ -349,9 +379,34 @@ export default {
this.activeFileNode = data
this.$st.sendEv('爬虫详情', '文件', '右键点击导航栏')
},
+ onEmptyClick () {
+ const data = { path: '' }
+ this.isShowCreatePopoverDict = {}
+ this.$set(this.isShowCreatePopoverDict, data.path, true)
+ this.activeFileNode = data
+ this.$st.sendEv('爬虫详情', '文件', '空白点击添加')
+ },
onHideCreate (data) {
this.$set(this.isShowCreatePopoverDict, data.path, false)
this.name = ''
+ },
+ onClickRemoveNav (data) {
+ this.$confirm(this.$t('Are you sure to delete this file/directory?'), this.$t('Notification'), {
+ confirmButtonText: this.$t('Confirm'),
+ cancelButtonText: this.$t('Cancel'),
+ confirmButtonClass: 'danger',
+ type: 'warning'
+ }).then(() => {
+ this.onFileDeleteNav(data.path)
+ })
+ },
+ async onFileDeleteNav (path) {
+ await this.$store.dispatch('file/deleteFile', { path })
+ await this.$store.dispatch('spider/getFileTree')
+ this.$message.success(this.$t('Deleted successfully'))
+ this.isShowDelete = false
+ this.showFile = false
+ this.$st.sendEv('爬虫详情', '文件', '删除')
}
},
async created () {
@@ -509,33 +564,52 @@ export default {
margin: 0;
}
- .create-item-list {
+ .action-item-list {
list-style: none;
padding: 0;
margin: 0
}
- .create-item-title {
+ .action-item-title {
padding-top: 10px;
padding-left: 15px;
- padding-bottom: 10px;
- border-bottom: 1px solid #eaecef;
+ padding-bottom: 5px;
}
- .create-item-list .create-item {
+ .action-item-list .action-item {
display: flex;
align-items: center;
height: 35px;
- padding: 0 0 0 15px;
+ padding: 0 0 0 10px;
margin: 0;
cursor: pointer;
}
- .create-item-list .create-item:hover {
+ .action-item-list .action-item:last-child {
+ border-bottom: 1px solid #eaecef;
+ }
+
+ .action-item-list .action-item:hover {
background: #F5F7FA;
}
- .create-item-list .create-item .create-item-text {
+ .action-item-list .action-item svg {
+ width: 20px;
+ }
+
+ .action-item-list .action-item .action-item-text {
margin-left: 5px;
}
+
+ .add-btn-wrapper {
+ width: 220px;
+ border-top: 1px solid #eaecef;
+ margin: 10px 10px;
+ }
+
+ .add-btn-wrapper .add-btn {
+ width: 80px;
+ margin-left: calc(120px - 40px - 10px);
+ margin-top: 20px;
+ }
diff --git a/frontend/src/i18n/en.js b/frontend/src/i18n/en.js
index b1c6ea43..0ac1c460 100644
--- a/frontend/src/i18n/en.js
+++ b/frontend/src/i18n/en.js
@@ -1 +1,24 @@
-export default {}
+export default {
+ // 内容
+ addNodeInstruction: `
+You cannot add nodes directly on the web interface in Crawlab.
+
+Adding a node is quite simple. The only thing you have to do is to run a Crawlab service on your target machine.
+
+#### Docker Deployment
+If you are running Crawlab using Docker, you can start a new \`worker\` container on the target machine, or add a \`worker\` service in the \`docker-compose.yml\`.
+
+\`\`\`bash
+docker run -d --restart always --name crawlab_worker \\
+ -e CRAWLAB_SERVER_MASTER=N \\
+ -e CRAWLAB_MONGO_HOST=xxx.xxx.xxx.xxx \\ # make sure you are connecting to the same MongoDB
+ -e CRAWLAB_REDIS_ADDRESS=xxx.xxx.xxx.xxx \\ # make sure you are connecting to the same Redis
+ tikazyq/crawlab:latest
+\`\`\`
+
+#### Direct Deploy
+If you are deploying directly, the only thing you have to do is to run a backend service on the target machine, you can refer to [Direct Deploy](https://docs.crawlab.cn/Installation/Direct.html).
+
+For more information, please refer to the [Official Documentation](https://docs.crawlab.cn).
+`
+}
diff --git a/frontend/src/i18n/zh.js b/frontend/src/i18n/zh.js
index a5dddfcc..c9c1d47a 100644
--- a/frontend/src/i18n/zh.js
+++ b/frontend/src/i18n/zh.js
@@ -68,6 +68,9 @@ export default {
'Rename': '重命名',
'Install': '安装',
'Uninstall': '卸载',
+ 'Create Directory': '新建目录',
+ 'Create File': '新建文件',
+ 'Add Node': '添加节点',
// 主页
'Total Tasks': '总任务数',
@@ -277,6 +280,7 @@ export default {
'Notification': '提示',
'Are you sure to delete this node?': '你确定要删除该节点?',
'Are you sure to run this spider?': '你确定要运行该爬虫?',
+ 'Are you sure to delete this file/directory?': '你确定要删除该文件/文件夹?',
'Added spider successfully': '成功添加爬虫',
'Uploaded spider files successfully': '成功上传爬虫文件',
'Node info has been saved successfully': '节点信息已成功保存',
@@ -325,7 +329,7 @@ export default {
'The schedule has been added': '已添加定时任务',
'The schedule has been saved': '已保存定时任务',
'Email format invalid': '邮箱地址格式不正确',
- 'Please select a file on the left.': '请在左侧选择一个文件.',
+ 'Please select a file or click the add button on the left.': '请在左侧选择一个文件或点击添加按钮.',
'New Directory': '新建目录',
'Enter new directory name': '输入新目录名称',
'New directory name': '新目录名称',
@@ -379,6 +383,29 @@ export default {
cron_format: 'Cron 格式: [秒] [分] [小时] [日] [月] [周]'
},
+ // 内容
+ addNodeInstruction: `
+您不能在 Crawlab 的 Web 界面直接添加节点。
+
+添加节点的方式非常简单,您只需要在目标机器上运行一个 Crawlab 服务就可以了。
+
+#### Docker 部署
+如果您是用 Docker 启动 Crawlab,可以在目标机器上运行一个新的 \`worker\` 容器,或者在 \`docker-compose.yml\` 中添加 \`worker\` 服务。
+
+\`\`\`bash
+docker run -d --restart always --name crawlab_worker \\
+ -e CRAWLAB_SERVER_MASTER=N \\
+ -e CRAWLAB_MONGO_HOST=xxx.xxx.xxx.xxx \\ # 保证连接的是同一个 MongoDB
+ -e CRAWLAB_REDIS_ADDRESS=xxx.xxx.xxx.xxx \\ # 保证连接的是同一个 Redis
+ tikazyq/crawlab:latest
+\`\`\`
+
+#### 直接部署
+如果您是用直接部署,只需要在目标机器上启动一个后端服务,请参考 [直接部署文档](https://docs.crawlab.cn/Installation/Direct.html)。
+
+更多信息,请参考 [官方文档](https://docs.crawlab.cn)。
+`,
+
// 其他
'Star crawlab-team/crawlab on GitHub': '在 GitHub 上为 Crawlab 加星吧'
}
diff --git a/frontend/src/router/index.js b/frontend/src/router/index.js
index 666792f1..cb2d0af4 100644
--- a/frontend/src/router/index.js
+++ b/frontend/src/router/index.js
@@ -1,6 +1,8 @@
import Vue from 'vue'
import Router from 'vue-router'
+import store from '../store'
+import request from '../api/request'
import stats from '../utils/stats'
/* Layout */
@@ -257,8 +259,13 @@ router.beforeEach((to, from, next) => {
}
})
-router.afterEach((to, from, next) => {
+router.afterEach(async (to, from, next) => {
if (to.path) {
+ await store.dispatch('setting/getSetting')
+ const res = await request.get('/version')
+ const version = res.data.data
+ store.commit('version/SET_VERSION', version)
+ sessionStorage.setItem('v', version)
stats.sendPv(to.path)
}
})
diff --git a/frontend/src/store/index.js b/frontend/src/store/index.js
index d6cdf11f..39c3bf18 100644
--- a/frontend/src/store/index.js
+++ b/frontend/src/store/index.js
@@ -14,6 +14,7 @@ import lang from './modules/lang'
import site from './modules/site'
import stats from './modules/stats'
import setting from './modules/setting'
+import version from './modules/version'
import getters from './getters'
Vue.use(Vuex)
@@ -33,7 +34,8 @@ const store = new Vuex.Store({
lang,
site,
setting,
- // 百度统计
+ version,
+ // 统计
stats
},
getters
diff --git a/frontend/src/store/modules/version.js b/frontend/src/store/modules/version.js
new file mode 100644
index 00000000..873f21bd
--- /dev/null
+++ b/frontend/src/store/modules/version.js
@@ -0,0 +1,21 @@
+const state = {
+ version: ''
+}
+
+const getters = {}
+
+const mutations = {
+ SET_VERSION: (state, value) => {
+ state.version = value
+ }
+}
+
+const actions = {}
+
+export default {
+ namespaced: true,
+ state,
+ getters,
+ mutations,
+ actions
+}
diff --git a/frontend/src/views/layout/components/Sidebar/index.vue b/frontend/src/views/layout/components/Sidebar/index.vue
index 34679a77..1123d332 100644
--- a/frontend/src/views/layout/components/Sidebar/index.vue
+++ b/frontend/src/views/layout/components/Sidebar/index.vue
@@ -49,7 +49,7 @@ export default {
return !this.sidebar.opened
},
version () {
- return window.sessionStorage.getItem('v')
+ return this.$store.state.version.version || window.sessionStorage.getItem('v')
}
},
data () {
diff --git a/frontend/src/views/node/NodeList.vue b/frontend/src/views/node/NodeList.vue
index 7b1c50d5..2b721950 100644
--- a/frontend/src/views/node/NodeList.vue
+++ b/frontend/src/views/node/NodeList.vue
@@ -1,26 +1,31 @@
-
-
-
-
-
-
- {{$t('Refresh')}}
-
+
+
-
-
+
+
+
+
+ {{$t('Add Node')}}
+
+
+
-
+
@@ -141,9 +147,11 @@