diff --git a/spug_api/apps/app/urls.py b/spug_api/apps/app/urls.py index 27c6ab5..93c360b 100644 --- a/spug_api/apps/app/urls.py +++ b/spug_api/apps/app/urls.py @@ -7,6 +7,7 @@ from .views import * urlpatterns = [ path('', AppView.as_view()), + path('kit/key/', kit_key), path('deploy/', DeployView.as_view()), path('deploy//versions/', get_versions), ] diff --git a/spug_api/apps/app/views.py b/spug_api/apps/app/views.py index 412f386..f5ebbff 100644 --- a/spug_api/apps/app/views.py +++ b/spug_api/apps/app/views.py @@ -8,6 +8,7 @@ from libs import JsonParser, Argument, json_response from apps.app.models import App, Deploy, DeployExtend1, DeployExtend2 from apps.config.models import Config from apps.app.utils import fetch_versions, remove_repo +from apps.setting.utils import AppSetting import subprocess import json import os @@ -15,12 +16,6 @@ import os class AppView(View): def get(self, request): - # v2.3.14 临时数据初始化 - app = App.objects.first() - if app and hasattr(app, 'sort_id') and app.sort_id == 0: - for app in App.objects.all(): - app.sort_id = app.id - app.save() query = {} if not request.user.is_supper: query['id__in'] = request.user.deploy_perms['apps'] @@ -181,3 +176,8 @@ def get_versions(request, d_id): return json_response(error='该应用不支持此操作') branches, tags = fetch_versions(deploy) return json_response({'branches': branches, 'tags': tags}) + + +def kit_key(request): + api_key = AppSetting.get_default('api_key') + return json_response(api_key) diff --git a/spug_web/src/pages/deploy/app/AutoDeploy.js b/spug_web/src/pages/deploy/app/AutoDeploy.js index 26c143b..f35c48f 100644 --- a/spug_web/src/pages/deploy/app/AutoDeploy.js +++ b/spug_web/src/pages/deploy/app/AutoDeploy.js @@ -1,6 +1,6 @@ import React, { useState, useEffect } from 'react'; import { observer } from 'mobx-react'; -import { Modal, Form, Input, Select, Radio, Button, message } from 'antd'; +import { Modal, Form, Input, Select, Radio, Button, Alert, message } from 'antd'; import { LoadingOutlined, SyncOutlined } from '@ant-design/icons'; import { http } from 'libs'; import store from './store'; @@ -13,11 +13,14 @@ export default observer(function AutoDeploy() { const [branches, setBranches] = useState([]); const [branch, setBranch] = useState(); const [url, setURL] = useState(); + const [key, setKey] = useState(); useEffect(() => { if (store.deploy.extend === '1') { fetchVersions() } + http.get('/api/app/kit/key/') + .then(res => setKey(res)) }, []) useEffect(() => { @@ -36,9 +39,9 @@ export default observer(function AutoDeploy() { .finally(() => setFetching(false)) } - function copyToClipBoard() { + function copyToClipBoard(data) { const t = document.createElement('input'); - t.value = url; + t.value = data; document.body.appendChild(t); t.select(); document.execCommand('copy'); @@ -54,6 +57,7 @@ export default observer(function AutoDeploy() { title="Webhook" footer={null} onCancel={() => store.autoVisible = false}> +
setType(e.target.value)}> @@ -96,7 +100,16 @@ export default observer(function AutoDeploy() { ) : ( -
{url}
+
copyToClipBoard(url)}>{url}
+
+ )} + {key ? ( + +
copyToClipBoard(key)}>{key}
+
+ ) : ( + +
请在系统管理/系统设置/开放服务设置中设置。
)}