mirror of
				https://github.com/lutinglt/gitea-github-theme.git
				synced 2025-10-31 17:11:12 +00:00 
			
		
		
		
	版本号自动生成
This commit is contained in:
		| @@ -1,4 +1,6 @@ | ||||
| import { createGlobalTheme, globalStyle } from "@vanilla-extract/css"; | ||||
| import fs from "node:fs"; | ||||
| import path from "node:path"; | ||||
| import { otherThemeVars, themeInfoVars, themeVars } from "src/types/vars"; | ||||
| import type { MapLeafNodes, WithOptionalLayer } from "./types"; | ||||
|  | ||||
| @@ -32,9 +34,19 @@ const emoji = ` | ||||
| .emoji[aria-label="musical notes"] | ||||
| `; | ||||
|  | ||||
| // 版本号: 版本号.YYMMDD | ||||
| const now = new Date(); | ||||
| const year = now.getFullYear().toString().slice(-2); | ||||
| const month = (now.getMonth() + 1).toString().padStart(2, "0"); | ||||
| const day = now.getDate().toString().padStart(2, "0"); | ||||
|  | ||||
| const pkgPath = path.join(__dirname, "../..", "package.json"); | ||||
| const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf-8")); | ||||
| const version = `"${pkg.version}.${year}${month}${day}"`; | ||||
|  | ||||
| export function createTheme(theme: Theme): void { | ||||
|   const isDarkTheme: boolean = JSON.parse(theme.isDarkTheme); | ||||
|   createGlobalTheme(":root", themeInfoVars, { version: "1.24.6.250909" }); | ||||
|   createGlobalTheme(":root", themeInfoVars, { version }); | ||||
|   createGlobalTheme(":root", themeVars, theme); | ||||
|   createGlobalTheme(":root", otherThemeVars, { | ||||
|     border: { radius: "6px" }, | ||||
|   | ||||
| @@ -50,9 +50,9 @@ export function themeInput(outDir: string, themeDir: string, mode: string): { [k | ||||
|   return input; | ||||
| } | ||||
|  | ||||
| function getAutoThemeInfo(nameGroup: string[]): string { | ||||
| function giteaThemeMetaInfo(nameGroup: string[]): string { | ||||
|   const displayName = nameGroup.map(word => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()).join(" "); | ||||
|   return `gitea-theme-meta-info { --theme-display-name: GitHub ${displayName};}`; // 不要省略分号, 也不要追加任何变量, 否则 Gitea 不识别 | ||||
|   return `gitea-theme-meta-info{--theme-display-name:"GitHub ${displayName}";}`; // 不要省略分号, 也不要追加任何变量, 否则 Gitea 不识别 | ||||
| } | ||||
|  | ||||
| const prefix = "theme-github-"; | ||||
| @@ -88,23 +88,22 @@ export function themePlugin(): Plugin { | ||||
|           const originalFileName = value.originalFileNames.pop(); | ||||
|           const type = value.type; | ||||
|           // 合并样式文件和主题信息 | ||||
|           const meta = getAutoThemeInfo(key.split(".")[0].split("-")); | ||||
|           const source = `${meta}\n${value.source.toString()}${styles}`; | ||||
|           const meta = giteaThemeMetaInfo(key.split(".")[0].split("-")); | ||||
|           const source = `${meta}${value.source.toString()}${styles}`; | ||||
|           // 添加主题到输出 | ||||
|           this.emitFile({ name, fileName, source, type, originalFileName }); | ||||
|           // 自动颜色主题 | ||||
|           const nameGroup = key.split(".")[0].split("-"); | ||||
|           const isDark = nameGroup.at(-1) === "dark"; | ||||
|           const isDark = key.endsWith("dark.css"); | ||||
|           const darkName = key.replace("light", "dark"); | ||||
|           const lightName = darkName.replace("dark", "light"); | ||||
|           const autoName = `${prefix}${darkName.replace("dark", "auto")}`; | ||||
|           const findTheme = isDark ? lightName : darkName; | ||||
|           if (findTheme in bundle) { | ||||
|             const autoName = `${prefix}${darkName.replace("dark", "auto")}`; | ||||
|             const lightContent = `@import "./${prefix}${lightName}" (prefers-color-scheme: light);`; | ||||
|             const darkContent = `@import "./${prefix}${darkName}" (prefers-color-scheme: dark);`; | ||||
|             const autoNameGroup = nameGroup.slice(0, -1); | ||||
|             autoNameGroup.push("auto"); | ||||
|             const metaInfo = getAutoThemeInfo(autoNameGroup); | ||||
|             const nameGroup = key.split(".")[0].split("-").slice(0, -1); | ||||
|             nameGroup.push("auto"); | ||||
|             const metaInfo = giteaThemeMetaInfo(nameGroup); | ||||
|             this.emitFile({ | ||||
|               name: autoName, | ||||
|               fileName: autoName, | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 lutinglt
					lutinglt