Skip to content

Commit

Permalink
Merge branch 'master' of github.com:star7th/showdoc
Browse files Browse the repository at this point in the history
  • Loading branch information
star7th committed May 13, 2023
2 parents 7c1a543 + e65e4bf commit d549e54
Show file tree
Hide file tree
Showing 16 changed files with 115 additions and 12 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/docker-arm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: ci

on:
push:
branches:
- "master"

jobs:
docker:
runs-on: ubuntu-latest
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
id: docker_build
uses: docker/build-push-action@v2
with:
push: true
tags: star7th/showdoc:arm-latest
file: DockerfileARM # 使用仓库下的DockerfileARM文件进行构建
platforms: |
linux/arm/v5
linux/arm/v7
linux/arm64
26 changes: 26 additions & 0 deletions .github/workflows/docker-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Build and push Docker image
on:
release:
types: [published]

jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
id: docker_build
uses: docker/build-push-action@v2
with:
push: true
tags: star7th/showdoc:${{ github.event.release.tag_name }}
13 changes: 13 additions & 0 deletions DockerfileARM
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM arm64v8/wordpress:php7.4

COPY ./ /var/www/html/
RUN mkdir -p /showdoc_data/html
RUN cp -R /var/www/html/ /showdoc_data/
RUN rm -rf /usr/src/wordpress
COPY ./ /usr/src/wordpress
RUN echo "<?php echo file_get_contents('index.html'); ?>" > /var/www/html/web/index.php
RUN chmod -R 777 /var/www/html/

# 写环境变量
ENV SHOWDOC_DOCKER_VERSION 2.4
ENV SHOWDOC_DOCKER_ARM 1
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"Api"
],
"homepage": "https://github.com/star7th/showdoc",
"version": "v3.1.0",
"version": "v3.1.1",
"license": "Apache-2.0",
"authors": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,15 @@ public function saveConfig()
$beian = I("beian");
$site_url = I("site_url");
$open_api_key = I("open_api_key");
$open_api_host = I("open_api_host");
D("Options")->set("history_version_count", $history_version_count);
D("Options")->set("register_open", $register_open);
D("Options")->set("home_page", $home_page);
D("Options")->set("home_item", $home_item);
D("Options")->set("beian", $beian);
D("Options")->set("site_url", $site_url);
D("Options")->set("open_api_key", $open_api_key);
D("Options")->set("open_api_host", $open_api_host);
D("Options")->set("show_watermark", $show_watermark);

if ($oss_open) {
Expand All @@ -55,6 +57,7 @@ public function loadConfig()
$beian = D("Options")->get("beian");
$site_url = D("Options")->get("site_url");
$open_api_key = D("Options")->get("open_api_key");
$open_api_host = D("Options")->get("open_api_host");
$oss_setting = json_decode($oss_setting, 1);

//如果强等于false,那就是尚未有数据。关闭注册应该是有数据且数据为字符串0
Expand All @@ -72,6 +75,7 @@ public function loadConfig()
"site_url" => $site_url,
"oss_setting" => $oss_setting,
"open_api_key" => $open_api_key,
"open_api_host" => $open_api_host,
);
$this->sendResult($array);
}
Expand Down
15 changes: 13 additions & 2 deletions server/Application/Api/Controller/AiController.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,20 @@ public function send($content)
),
),
));
$api_base_url = env('API_BASE_URL', 'https://api.openai.com');
$open_api_host = D("Options")->get("open_api_host");
if (!$open_api_host) {
$open_api_host = 'https://api.openai.com';
}
if (!strstr($open_api_host, 'http')) {
$open_api_host = 'https://' . $open_api_host;
}
if (substr($open_api_host, -1) === '/') { // 如果字符串以 / 符号结尾:
$open_api_host = substr($open_api_host, 0, -1); // 将字符串的最后一个字符剪切掉

}
$curl = curl_init(); //初始化
curl_setopt($curl, CURLOPT_URL, $api_base_url . '/v1/chat/completions'); //设置url
curl_setopt($curl, CURLOPT_ENCODING, '');
curl_setopt($curl, CURLOPT_URL, $open_api_host . '/v1/chat/completions'); //设置url
curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); //设置http验证方法
curl_setopt($curl, CURLOPT_TIMEOUT, 120);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); //设置curl_exec获取的信息的返回方式
Expand Down
2 changes: 1 addition & 1 deletion web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@
'../server/index.php?s=',
// "lang" :'en'
lang: 'zh-cn'
}</script><link href=./static/css/app.ebeffe2948eb6b4f85c67f44a1860bf3.css rel=stylesheet></head><body class=grey-bg><div id=app></div><script type=text/javascript src=./static/js/manifest.3ad1d5771e9b13dbdad2.js></script><script type=text/javascript src=./static/js/vendor.339f5a1f86786a88b9d4.js></script><script type=text/javascript src=./static/js/app.0cf128d74464e1dccf3a.js></script></body></html>
}</script><link href=./static/css/app.cf5cf8d7db49bba7dd9f2a5241bd431c.css rel=stylesheet></head><body class=grey-bg><div id=app></div><script type=text/javascript src=./static/js/manifest.3ad1d5771e9b13dbdad2.js></script><script type=text/javascript src=./static/js/vendor.339f5a1f86786a88b9d4.js></script><script type=text/javascript src=./static/js/app.7d4ce78ff195400edcb7.js></script></body></html>

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion web/static/js/app.0cf128d74464e1dccf3a.js

This file was deleted.

1 change: 1 addition & 0 deletions web/static/js/app.7d4ce78ff195400edcb7.js

Large diffs are not rendered by default.

20 changes: 19 additions & 1 deletion web_src/src/components/admin/setting/Index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,20 @@
></i>
</el-tooltip>
</el-form-item>
<el-form-item v-show="$lang == 'zh-cn'" label="AI助手代理HOST">
<el-input
v-model="form.open_api_host"
class="form-el"
placeholder="可选"
></el-input>

<el-tooltip effect="dark" content="点击查看填写说明" placement="top">
<i
class="el-icon-question cursor-pointer "
@click="toOutLink('https://github.com/star7th/showdoc/issues/1904')"
></i>
</el-tooltip>
</el-form-item>
<el-form-item :label="$t('oss_open')">
<el-switch v-model="form.oss_open"></el-switch>
</el-form-item>
Expand Down Expand Up @@ -225,7 +239,8 @@ export default {
beian: '',
show_watermark: false,
site_url: '',
open_api_key: ''
open_api_key: '',
open_api_host: ''
},
itemList: []
}
Expand Down Expand Up @@ -272,6 +287,9 @@ export default {
this.form.open_api_key = data.data.open_api_key
? data.data.open_api_key
: ''
this.form.open_api_host = data.data.open_api_host
? data.data.open_api_host
: ''
})
},
getItemList() {
Expand Down
2 changes: 1 addition & 1 deletion web_src/src/components/item/home/ItemList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ import Recycle from '@/components/item/setting/Recycle'
import Archive from '@/components/item/setting/Archive'
import Attorn from '@/components/item/setting/Attorn'
import Delete from '@/components/item/setting/Delete'
import Share from '@/components/item/home/share'
import Share from '@/components/item/home/Share'
export default {
name: 'ItemList',
components: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ import Archive from '@/components/item/setting/Archive'
import Attorn from '@/components/item/setting/Attorn'
import Delete from '@/components/item/setting/Delete'
import ItemUpdate from '@/components/item/add/Basic'
import Share from '@/components/item/home/share'
import Share from '@/components/item/home/Share'
import PageEdit from '@/components/page/edit/Index'
export default {
components: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ import Archive from '@/components/item/setting/Archive'
import Attorn from '@/components/item/setting/Attorn'
import Delete from '@/components/item/setting/Delete'
import ItemUpdate from '@/components/item/add/Basic'
import Share from '@/components/item/home/share'
import Share from '@/components/item/home/Share'
export default {
components: {
Member,
Expand Down
2 changes: 1 addition & 1 deletion web_src/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import 'babel-polyfill'
import VueClipboard from 'vue-clipboard2'
import store from './store/'
import '../src/assets/tailwind.css' // 引入tailwind
import SDialog from '@/components/common/SDialog'
import SDialog from '@/components/common/Sdialog'

Vue.use(util)
Vue.config.productionTip = false
Expand Down
2 changes: 1 addition & 1 deletion web_src/src/router/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Vue from 'vue'
import Router from 'vue-router'
import Index from '@/components/Index'
import UserLogin from '@/components/user/Login'
import UserSetting from '@/components/user/setting/index'
import UserSetting from '@/components/user/setting/Index'
import UserRegister from '@/components/user/Register'
import loginByUserToken from '@/components/user/loginByUserToken'
import ItemIndex from '@/components/item/home/Index'
Expand Down

0 comments on commit d549e54

Please sign in to comment.