Skip to content

Commit

Permalink
chore: Update Node.js version to 20 in CI Test workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
cf-pages committed Jul 7, 2024
1 parent 11a4aa0 commit b8700b3
Show file tree
Hide file tree
Showing 11 changed files with 1,196 additions and 7 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/ci-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: CI Test

on:
pull_request:
branches: [ main ]

jobs:
test:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '20'
- name: Install dependencies
run: npm install
- name: Run tests
run: npm run ci-test
4 changes: 2 additions & 2 deletions .github/workflows/sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@ jobs:
- name: Sync check
if: failure()
run: |
echo "[Error] 由于上游仓库的 workflow 文件变更,导致 GitHub 自动暂停了本次自动更新,你需要手动 Sync Fork 一次,详细教程请查看:https://github.com/Yidadaa/ChatGPT-Next-Web/blob/main/README_CN.md#%E6%89%93%E5%BC%80%E8%87%AA%E5%8A%A8%E6%9B%B4%E6%96%B0"
echo "[Error] Due to a change in the workflow file of the upstream repository, GitHub has automatically suspended the scheduled automatic update. You need to manually sync your fork. Please refer to the detailed tutorial for instructions: https://github.com/Yidadaa/ChatGPT-Next-Web#enable-automatic-updates"
echo "[Error] 由于上游仓库的 workflow 文件变更,导致 GitHub 自动暂停了本次自动更新,你需要手动 Sync Fork 一次,详细教程请查看项目README.md "
echo "[Error] Due to a change in the workflow file of the upstream repository, GitHub has automatically suspended the scheduled automatic update. You need to manually sync your fork. Please refer to the project README.md for instructions. "
exit 1
30 changes: 30 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,36 @@
Hostloc @feixiang 和@乌拉擦 提供的思路和代码

## 更新日志
2024 年 7 月 6 日--后台管理页面更新

- 支持两个新的管理页面视图(网格视图和瀑布流)

1、网格视图,感谢@DJChanahCJD 提交的代码
支持批量删除/复制链接
支持按时间倒序排序
支持分页功能
![](https://camo.githubusercontent.com/a0551aa92f39517f0b30d86883882c1af4c9b3486e540c7750af4dbe707371fa/68747470733a2f2f696d6774632d3369312e70616765732e6465762f66696c652f6262616438336561616630356635333731363237322e706e67)
2、瀑布流视图,感谢@panther125 提交的代码
![](https://camo.githubusercontent.com/63d64491afc5654186248141bd343c363808bf8a77d3b879ffc1b8e57e5ac85d/68747470733a2f2f696d6167652e67696e636f64652e6963752f66696c652f3930346435373737613363306530613936623963642e706e67)

- 添加自动更新支持

现在fork的项目能够自动和上游仓库同步最新的更改,自动实装最新的项目功能,感谢 @bian2022

打开自动更新步骤:
当你 fork 项目之后,由于 Github 的限制,需要手动去你 fork 后的项目的 Actions 页面启用 Workflows,并启用 Upstream Sync Action,启用之后即可开启每小时定时自动更新:
![](https://im.gurl.eu.org/file/f27ff07538de656844923.png)
![](https://im.gurl.eu.org/file/063b360119211c9b984c0.png)
`如果你遇到了 Upstream Sync 执行错误,请手动 Sync Fork 一次!`

手动更新代码

如果你想让手动立即更新,可以查看 [Github 的文档](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/syncing-a-fork) 了解如何让 fork 的项目与上游代码同步。

你可以 star/watch 本项目或者 follow 作者来及时获得新功能更新通知。
- 添加远端遥测

可通过添加`disable_telemetry`环境变量退出遥测

2023 年 1 月 18 日--图片管理功能更新

Expand Down
File renamed without changes.
142 changes: 142 additions & 0 deletions admin-waterfall.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Waterfall</title>
<style>
body{
background: linear-gradient(90deg, #ffd7e4 0%, #c8f1ff 100%);
}
::-webkit-scrollbar {
width: 8px;
height: 8px;
}

::-webkit-scrollbar-corner {
background-color: transparent;
}

::-webkit-scrollbar-thumb {
background-color: #49b1f5;
background-image: -webkit-linear-gradient(45deg, hsla(0, 0%, 100%, .4) 25%, transparent 0, transparent 50%, hsla(0, 0%, 100%, .4) 0, hsla(0, 0%, 100%, .4) 75%, transparent 0, transparent);
border-radius: 2em;
}

::-webkit-scrollbar-track {
background-color: rgba(73, 177, 245, .2);
border-radius: 2em;
}
.box {
position: relative;
}
img {
width: 200px;
height: auto;
padding: 5px;
margin-left: 1.25%;
border-radius: 20px;
}
#bigimg {
display: none;
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.5);
}
#bigimg img {
position: absolute;
width: 90%;
height: 100%;
top: 50%;
left: 50%;
object-fit: contain;
transform: translate(-50%, -50%);
}
</style>
</head>
<body>
<div class="box">
</div>
<!-- 放大遮罩层 -->
<div id="bigimg" onclick="closeBigImg();"></div>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/jquery.min.js"></script>
<script>
var imgList
$.ajax({
url: "./api/manage/list",
async: false,
dataType: "json",
success: function(data) {
imgList = data; // 将请求的数据赋值给全局变量
}
});
var targetElement = document.querySelector('.box');
let str ='';
for (let i = 0; i < imgList.length; i++){
if(imgList[i].name.indexOf(".mp4")>0)continue;
str += '<img onclick="showBigImg(this)" data-original='+"/file/"+imgList[i].name+' src='+"/file/"+imgList[i].name +'>';
}
targetElement.innerHTML = str
</script>
</body>
<script>
window.onload = $(function () {
// 获取图片的宽度(200px)
let imgWidth = $('img').outerWidth(); // 200
//console.log(imgWidth)
waterfallHandler();

// 瀑布流处理
function waterfallHandler() {
// 获取图片的列数
let column = parseInt($(window).width() / imgWidth);
//console.log(column)
// 高度数组
let heightArr = [];
for(let i=0; i<column; i++) {
heightArr[i] = 0;
}
$.each($('img'), function (index, item) {
// 当前元素的高度
let itemHeight = $(item).outerHeight();
// 高度数组最小的高度
let minHeight = Math.min(...heightArr);
// 高度数组最小的高度的索引
let minIndex = heightArr.indexOf(minHeight);
$(item).css({
position: 'absolute',
top: minHeight + 'px',
left: minIndex * imgWidth + 'px'
});

heightArr[minIndex] += itemHeight;
});
}

// 窗口大小改变
$(window).resize(function () {
waterfallHandler();
});
});
function showBigImg(img) {
var bigImg = document.getElementById('bigimg');
var imgUrl = img.getAttribute('data-original');
bigImg.innerHTML = '<img src="' + imgUrl + '">';
bigImg.style.display = 'block';
// 获取屏幕的宽度和高度
//var screenWidth = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
//var screenHeight = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
//bigImg.style.maxWidth = screenWidth * 0.9 + 'px';
//bigImg.style.maxHeight = screenHeight * 0.9 + 'px';
}

function closeBigImg() {
var bigImg = document.getElementById('bigimg');
bigImg.style.display = 'none';
bigImg.innerHTML = '';
}
</script>
</html>
15 changes: 14 additions & 1 deletion admin.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,20 @@
<span style="
position: absolute;
right: 0px;
" v-if="showLogoutButton"><el-button
" v-if="showLogoutButton">
<a href="./admin-imgtc.html">
<el-button
size="mini"
type="warning"
>网格视图</el-button>
</a>
<a href="./admin-waterfall.html">
<el-button
size="mini"
type="primary"
>瀑布流</el-button>
</a>
<el-button
size="mini"
type="info"
@click="handleLogout()">退出登录</el-button></span></div>
Expand Down
2 changes: 1 addition & 1 deletion functions/upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export async function onRequestPost(context) { // Contents of context object
data, // arbitrary space for passing data between middlewares
} = context;
const clonedRequest = request.clone();
errorHandling(context);
await errorHandling(context);
telemetryData(context);
const url = new URL(clonedRequest.url);
const response = fetch('https://telegra.ph/' + url.pathname + url.search, {
Expand Down
25 changes: 22 additions & 3 deletions functions/utils/middleware.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
import sentryPlugin from "@cloudflare/pages-plugin-sentry";
import '@sentry/tracing';

export function errorHandling(context) {
export async function errorHandling(context) {
const env = context.env;
const sampleRate = env.sampleRate || 0.001;
console.log("sampleRate", sampleRate)
if (typeof env.disable_telemetry == "undefined" || env.disable_telemetry == null || env.disable_telemetry == "") {
context.data.telemetry = true;
let remoteSampleRate = 0.001;
try {
const sampleRate = await fetchSampleRate(context)
console.log("sampleRate", sampleRate);
//check if the sample rate is not null
if (sampleRate) {
remoteSampleRate = sampleRate;
}
} catch (e) { console.log(e) }
const sampleRate = env.sampleRate || remoteSampleRate;
console.log("sampleRate", sampleRate);
return sentryPlugin({
dsn: "https://219f636ac7bde5edab2c3e16885cb535@o4507041519108096.ingest.us.sentry.io/4507541492727808",
tracesSampleRate: sampleRate,
Expand Down Expand Up @@ -80,4 +89,14 @@ export async function traceData(context, span, op, name) {
);
}
}
}

async function fetchSampleRate(context) {
const data = context.data
if (data.telemetry) {
const url = "https://frozen-sentinel.pages.dev/signal/sampleRate.json";
const response = await fetch(url);
const json = await response.json();
return json.rate;
}
}
Loading

0 comments on commit b8700b3

Please sign in to comment.