前言
詢問DeepSeek根據自己所學到的知識來生成多個可執行的代碼,為高考學子加油。最開始生成的都會有點小問題,還是需要自己調試一遍,下面就是完整的代碼,當然了最后幾天也不會有多少人看,都在專心的備考。
Python勵志桌面程序
pip install pyqt5
通過按下ESC鍵進行退出。?
# 文件名:inspire_screensaver.py
import sys
import random
import timefrom PyQt5.QtWidgets import QApplication, QWidget, QLabel
from PyQt5.QtCore import Qt, QTimer, QPoint
from PyQt5.QtGui import QFont, QColor, QPainterclass Screensaver(QWidget):def __init__(self):super().__init__()self.texts = ["你考的不是試,是前途和暮年的歡喜","關關難過關關過,前路漫漫亦燦燦","愿你合上筆蓋的剎那,有俠客收劍入鞘的驕傲","筆鋒所指處,皆是心之所向,愿合筆時如收刀入鞘般驕傲!","十二載星月為伴,今朝試鋒,定當光芒萬丈","你的考卷終將化作通向理想大學的云梯,拾級而上終見星辰","此刻奮筆疾書的每個字,都是未來人生的精彩伏筆","乾坤未定,你我皆是奔騰向前的黑馬","愿提筆時驚風落雨,收卷日笑看云起","寒窗墨香終成劍,一朝出鞘動四方","且將新火試新茶,少年仗劍趁年華","鵬北海,鳳朝陽,今攜書劍路茫茫","春風得意馬蹄疾,一日看盡長安花","不必追求完美答卷,只需寫出青春無悔","錯的每道題都是為了遇見對的人,對的每道題都是為了遇見更好的自己","高考只是人生車站,從容下車后還有萬里山河待你丈量","備好2B鉛筆,也請帶上百分百的勇氣","早餐要吃好,準考證別忘帶,你平穩發揮就是最棒狀態","當交卷鈴聲響起,整個世界都會為你的堅持鼓掌","把三年青春濃縮成筆尖鋒芒,刺破迷茫照亮遠方","此刻你不僅是考生,更是手握命運改寫權的英雄","那些熬過的夜終將化作星光,鋪就你的狀元之路","少年應有鴻鵠志,當騎駿馬踏平川","愿九月踏入的校園,正是你此刻心馳神往的方向","今日考場方寸地,明日天地任爾行","這場考試過后,你選擇的世界正在向你奔來","現在寫下的每個答案,都在勾勒未來人生的輪廓","金榜題名時,勿忘與恩師共賞這漫天彩霞","請相信:你的long類型努力終將轉化為double型成功","人生不是單選題,但這次請堅定選擇自己的最優解","用三年的函數積累,求導出最燦爛的極值人生","當交卷鈴聲如約而至,便是你開啟新副本的入場音效","這場考試的隱藏獎勵是:解鎖無限可能的人生DLC"]self.initUI()# 初始化存儲數組self.positions = [] # 存儲(坐標, 顏色, 文本)self.time_stamps = [] # 對應生成時間戳self.directions = [] # 移動方向向量# 運動參數配置self.timer = QTimer(self)self.timer.timeout.connect(self.update)self.timer.start(40) # 刷新間隔(ms)self.fade_speed = 1.5 # 淡出速度self.max_trails = 15 # 最大點數self.move_speed = 2 # 移動速度(像素/幀)def initUI(self):self.setWindowTitle("高考加油屏保")self.showFullScreen()self.setCursor(Qt.BlankCursor)self.setStyleSheet("background: black;")# 退出提示標簽(動態適應分辨率)self.status_label = QLabel("按 ESC 退出", self)self.status_label.setStyleSheet("color: white; font-size: 16px;")self.status_label.adjustSize()self.status_label.move(10, self.height() - self.status_label.height() - 10)def paintEvent(self, event):painter = QPainter(self)painter.setRenderHint(QPainter.Antialiasing)current_time = time.time()text_metrics = painter.fontMetrics()text_font = QFont("微軟雅黑", 20) # 字號從默認調整為20painter.setFont(text_font)# === 運動計算 ===survived_indices = []for idx in range(min(len(self.positions), len(self.time_stamps), len(self.directions))):age = current_time - self.time_stamps[idx]alpha = 255 - int(self.fade_speed * age * 30)if alpha > 0: # 保留未消失的點survived_indices.append(idx)# 更新存活點數據(嚴格同步截斷)self.positions = [self.positions[i] for i in survived_indices][:self.max_trails]self.directions = [self.directions[i] for i in survived_indices][:self.max_trails]self.time_stamps = [self.time_stamps[i] for i in survived_indices][:self.max_trails]# === 移動計算 ===new_positions = []new_directions = []for idx in range(len(self.positions)):(pos, color, text) = self.positions[idx]dx, dy = self.directions[idx]# 計算新坐標(帶邊界約束)text_width = text_metrics.width(text)text_height = text_metrics.height()new_x = pos.x() + dxnew_y = pos.y() + dy# 邊界反彈處理if new_x < 0 or new_x > (self.width() - text_width):dx = -dx * 0.8new_x = max(0, min(new_x, self.width() - text_width))if new_y < text_height or new_y > (self.height() - text_height):dy = -dy * 0.8new_y = max(text_height, min(new_y, self.height() - text_height))new_positions.append((QPoint(int(new_x), int(new_y)), color, text))new_directions.append((dx, dy))# 更新數據self.positions = new_positionsself.directions = new_directions# === 生成新點 ===while len(self.positions) < self.max_trails:new_text = random.choice(self.texts)text_width = text_metrics.width(new_text)text_height = text_metrics.height()# 安全坐標生成(帶異常處理)try:safe_x = random.randint(0, self.width() - text_width)safe_y = random.randint(text_height, self.height() - text_height)except ValueError:safe_x = 0safe_y = text_heightself.positions.append((QPoint(safe_x, safe_y),QColor(random.randint(150, 255),random.randint(150, 255),random.randint(150, 255)),new_text))self.directions.append((random.uniform(-self.move_speed, self.move_speed),random.uniform(-self.move_speed, self.move_speed)))self.time_stamps.append(time.time())# === 繪制所有點 ===for (pos, color, text), ts in zip(self.positions, self.time_stamps):age = current_time - tsalpha = max(0, 255 - int(self.fade_speed * age * 50))painter.setPen(QColor(color.red(),color.green(),color.blue(),alpha))painter.drawText(pos, text)def keyPressEvent(self, event):if event.key() == Qt.Key_Escape:self.close()if __name__ == "__main__":# Windows系統內存優化if sys.platform == 'win32':import ctypesctypes.windll.kernel32.SetProcessWorkingSetSize(-1, 0x100000, 0x200000)app = QApplication(sys.argv)ex = Screensaver()sys.exit(app.exec_())
Vue3互動網頁
時間設置的是const target = new Date('2025-06-07T09:00:00')
<!-- 文件結構 -->
<!-- index.html -->
<!DOCTYPE html>
<html><head><title>高考能量站</title><script src="https://unpkg.com/vue@3"></script><style>body {margin: 0;background: linear-gradient(45deg, #1a237e, #4a148c);height: 100vh;overflow: hidden;}#app {display: flex;flex-direction: column;align-items: center;color: white;}.countdown {font-size: 3em;text-shadow: 0 0 10px rgba(255, 255, 255, 0.5);}.btn {padding: 15px 30px;background: #00e676;border: none;border-radius: 25px;font-size: 1.2em;cursor: pointer;transition: transform 0.3s;}canvas {position: fixed;top: 0;left: 0;pointer-events: none;}</style>
</head><body><div id="app"><h1>高考能量補給站</h1><div class="countdown">{{ days }}天{{ hours }}時{{ minutes }}分{{ second }}秒</div><button class="btn" @click="sendConfetti">獲取好運</button><canvas ref="canvas"></canvas></div><script>const { createApp, ref, onMounted } = Vue;createApp({setup() {const canvas = ref(null)const days = ref(0)const hours = ref(0)const minutes = ref(0)const second = ref(0)let ctx = null// 倒計時計算const updateTime = () => {// 高考時間(今年是25年了)const target = new Date('2025-06-07T09:00:00')const now = new Date()const diff = target - nowdays.value = Math.floor(diff / (1000 * 60 * 60 * 24))hours.value = Math.floor((diff % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60))minutes.value = Math.floor((diff % (1000 * 60 * 60)) / (1000 * 60))second.value = Math.floor((diff % (1000 * 60)) / 1000)}// 彩紙特效const sendConfetti = () => {for (let i = 0; i < 50; i++) {const x = Math.random() * canvas.value.widthconst y = Math.random() * canvas.value.heightctx.fillStyle = `hsl(${Math.random() * 360}, 70%, 60%)`ctx.beginPath()ctx.arc(x, y, 3, 0, Math.PI * 2)ctx.fill()}console.log('🎉')}onMounted(() => {// 初始化畫布ctx = canvas.value.getContext('2d')canvas.value.width = window.innerWidthcanvas.value.height = window.innerHeight// 啟動計時器setInterval(updateTime, 1000)updateTime()})// 需要返回return { days, hours, minutes, second, canvas, sendConfetti }}}).mount('#app')</script>
</body></html>
?
總結
暫時先這樣吧,有時間再來完善。?