mirror of
https://github.com/lutinglt/gitea-github-theme.git
synced 2026-10-28 09:44:55 +00:00
refactor code
This commit is contained in:
15 files changed
+87
-69
No files matched your search
+1
-3
@@ -3,6 +3,4 @@
|
|||||||
# 忽略非项目代码统计
|
# 忽略非项目代码统计
|
||||||
.github/** linguist-vendored
|
.github/** linguist-vendored
|
||||||
.vscode/** linguist-generated
|
.vscode/** linguist-generated
|
||||||
gitea/** linguist-generated
|
gitea/** linguist-generated
|
||||||
screenshots/** linguist-vendored
|
|
||||||
scripts/** linguist-vendored
|
|
||||||
Vendored
+8
-5
@@ -5,12 +5,15 @@ on:
|
|||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
|
|
||||||
|
env:
|
||||||
|
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v6
|
||||||
- uses: dorny/paths-filter@v3
|
- uses: dorny/paths-filter@v4
|
||||||
id: changes
|
id: changes
|
||||||
with:
|
with:
|
||||||
filters: |
|
filters: |
|
||||||
@@ -32,14 +35,14 @@ jobs:
|
|||||||
|
|
||||||
- name: Upload css assets
|
- name: Upload css assets
|
||||||
if: steps.build.outcome == 'success'
|
if: steps.build.outcome == 'success'
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v7
|
||||||
with:
|
with:
|
||||||
name: themes
|
name: themes
|
||||||
path: dist/*.css
|
path: dist/*.css
|
||||||
|
|
||||||
- name: Upload templates assets
|
- name: Upload templates assets
|
||||||
if: steps.build.outcome == 'success'
|
if: steps.build.outcome == 'success'
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v7
|
||||||
with:
|
with:
|
||||||
name: templates
|
name: templates
|
||||||
path: templates
|
path: templates
|
||||||
@@ -52,7 +55,7 @@ jobs:
|
|||||||
|
|
||||||
- name: Upload locales assets
|
- name: Upload locales assets
|
||||||
if: steps.locales.outcome =='success'
|
if: steps.locales.outcome =='success'
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v7
|
||||||
with:
|
with:
|
||||||
name: locales
|
name: locales
|
||||||
path: dist/options/locale
|
path: dist/options/locale
|
||||||
Vendored
+4
-1
@@ -6,11 +6,14 @@ on:
|
|||||||
permissions:
|
permissions:
|
||||||
contents: write
|
contents: write
|
||||||
|
|
||||||
|
env:
|
||||||
|
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
release:
|
release:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v6
|
||||||
- name: Build theme
|
- name: Build theme
|
||||||
run: |
|
run: |
|
||||||
npm install
|
npm install
|
||||||
|
|||||||
+2
-2
@@ -24,12 +24,12 @@ import tseslint from "typescript-eslint";
|
|||||||
|
|
||||||
export default defineConfig([
|
export default defineConfig([
|
||||||
{
|
{
|
||||||
files: ["**/*.{js,mjs,cjs,ts,mts,cts}"],
|
files: ["**/*.ts"],
|
||||||
plugins: { js },
|
plugins: { js },
|
||||||
extends: ["js/recommended"],
|
extends: ["js/recommended"],
|
||||||
languageOptions: {
|
languageOptions: {
|
||||||
ecmaVersion: "latest",
|
ecmaVersion: "latest",
|
||||||
globals: globals.browser,
|
globals: globals.node,
|
||||||
},
|
},
|
||||||
rules: {
|
rules: {
|
||||||
"@typescript-eslint/no-unused-vars": [
|
"@typescript-eslint/no-unused-vars": [
|
||||||
|
|||||||
+4
-4
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "gitea-github-theme",
|
"name": "gitea-github-theme",
|
||||||
"version": "1.26.2",
|
"version": "1.26.1",
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"author": {
|
"author": {
|
||||||
"name": "lutinglt",
|
"name": "lutinglt",
|
||||||
@@ -12,9 +12,9 @@
|
|||||||
"lint": "eslint .",
|
"lint": "eslint .",
|
||||||
"format": "prettier --write .",
|
"format": "prettier --write .",
|
||||||
"commit": "npm run lint && npm run format && npm run build",
|
"commit": "npm run lint && npm run format && npm run build",
|
||||||
"version": "node scripts/version.cjs",
|
"version": "node scripts/version.ts",
|
||||||
"tr": "node scripts/translate.cjs",
|
"tr": "node scripts/translate.ts",
|
||||||
"update:gitea": "node scripts/update_gitea.cjs",
|
"update:gitea": "node scripts/update_gitea.ts",
|
||||||
"release": "npm run build && npm run tr",
|
"release": "npm run build && npm run tr",
|
||||||
"install:clean": "npm cache clean --force && rm -rf node_modules package-lock.json && npm install"
|
"install:clean": "npm cache clean --force && rm -rf node_modules package-lock.json && npm install"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -17,22 +17,14 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const fs = require("fs");
|
import dotenv from "dotenv";
|
||||||
const path = require("path");
|
import child_process from "node:child_process";
|
||||||
const child_process = require("child_process");
|
import fs from "node:fs";
|
||||||
|
import path from "node:path";
|
||||||
|
import { pkg, rootDir, setGlobalProxy } from "./utils.ts";
|
||||||
|
|
||||||
const { ProxyAgent, setGlobalDispatcher } = require("undici");
|
|
||||||
const proxyUrl = process.env.HTTPS_PROXY || process.env.HTTP_PROXY || process.env.ALL_PROXY;
|
|
||||||
if (proxyUrl) {
|
|
||||||
setGlobalDispatcher(new ProxyAgent(proxyUrl));
|
|
||||||
}
|
|
||||||
|
|
||||||
const dotenv = require("dotenv");
|
|
||||||
dotenv.config({ quiet: true });
|
dotenv.config({ quiet: true });
|
||||||
|
setGlobalProxy();
|
||||||
const rootDir = path.join(__dirname, "..");
|
|
||||||
const pkgPath = path.join(rootDir, "package.json");
|
|
||||||
const pkg = JSON.parse(fs.readFileSync(pkgPath));
|
|
||||||
|
|
||||||
const githubSite = "https://raw.githubusercontent.com";
|
const githubSite = "https://raw.githubusercontent.com";
|
||||||
const giteaRepo = "go-gitea/gitea";
|
const giteaRepo = "go-gitea/gitea";
|
||||||
@@ -41,14 +33,12 @@ const githubTagPath = "refs/tags";
|
|||||||
const localePath = "options/locale";
|
const localePath = "options/locale";
|
||||||
|
|
||||||
const [major, minor, patch, tag = ""] = pkg.version.split(".");
|
const [major, minor, patch, tag = ""] = pkg.version.split(".");
|
||||||
|
|
||||||
console.log("Version:", pkg.version);
|
console.log("Version:", pkg.version);
|
||||||
let versionPath = "";
|
|
||||||
if (tag.includes("rc") || patch.includes("latest")) {
|
const versionPath =
|
||||||
versionPath = `${githubBranchPath}/v${major}.${minor}`;
|
tag.includes("rc") || patch.includes("latest")
|
||||||
} else {
|
? `${githubBranchPath}/v${major}.${minor}`
|
||||||
versionPath = `${githubTagPath}/v${major}.${minor}.${patch}`;
|
: `${githubTagPath}/v${major}.${minor}.${patch}`;
|
||||||
}
|
|
||||||
|
|
||||||
const githubUrl = `${githubSite}/${giteaRepo}/${versionPath}/${localePath}`;
|
const githubUrl = `${githubSite}/${giteaRepo}/${versionPath}/${localePath}`;
|
||||||
const locales = fs.readdirSync(path.join(rootDir, localePath)).filter(file => file.endsWith(".json"));
|
const locales = fs.readdirSync(path.join(rootDir, localePath)).filter(file => file.endsWith(".json"));
|
||||||
@@ -63,7 +53,7 @@ const locales = fs.readdirSync(path.join(rootDir, localePath)).filter(file => fi
|
|||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
throw new Error(`HTTP error! status: ${response.status}`);
|
throw new Error(`HTTP error! status: ${response.status}`);
|
||||||
}
|
}
|
||||||
let content = await response.json();
|
const content = (await response.json()) as Record<string, string>;
|
||||||
if (locale.includes("zh-CN")) {
|
if (locale.includes("zh-CN")) {
|
||||||
for (const key of Object.keys(content)) {
|
for (const key of Object.keys(content)) {
|
||||||
if (typeof content[key] === "string") {
|
if (typeof content[key] === "string") {
|
||||||
@@ -17,18 +17,11 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const fs = require("fs");
|
import fs from "node:fs";
|
||||||
const path = require("path");
|
import path from "node:path";
|
||||||
|
import { pkg, rootDir, setGlobalProxy } from "./utils.ts";
|
||||||
|
|
||||||
const { ProxyAgent, setGlobalDispatcher } = require("undici");
|
setGlobalProxy();
|
||||||
const proxyUrl = process.env.HTTPS_PROXY || process.env.HTTP_PROXY || process.env.ALL_PROXY;
|
|
||||||
if (proxyUrl) {
|
|
||||||
setGlobalDispatcher(new ProxyAgent(proxyUrl));
|
|
||||||
}
|
|
||||||
|
|
||||||
const rootDir = path.join(__dirname, "..");
|
|
||||||
const pkgPath = path.join(rootDir, "package.json");
|
|
||||||
const pkg = JSON.parse(fs.readFileSync(pkgPath));
|
|
||||||
|
|
||||||
const githubSite = "https://raw.githubusercontent.com";
|
const githubSite = "https://raw.githubusercontent.com";
|
||||||
const giteaRepo = "go-gitea/gitea";
|
const giteaRepo = "go-gitea/gitea";
|
||||||
@@ -40,8 +33,8 @@ const versionPath = `${githubTagPath}/v${major}.${minor}.${patch}`;
|
|||||||
const githubBaseUrl = `${githubSite}/${giteaRepo}/${versionPath}`;
|
const githubBaseUrl = `${githubSite}/${giteaRepo}/${versionPath}`;
|
||||||
|
|
||||||
// 递归读取所有子目录中的文件
|
// 递归读取所有子目录中的文件
|
||||||
function readFilesRecursively(dir) {
|
function readFilesRecursively(dir: string) {
|
||||||
const results = [];
|
const results: string[] = [];
|
||||||
const files = fs.readdirSync(dir);
|
const files = fs.readdirSync(dir);
|
||||||
|
|
||||||
for (const file of files) {
|
for (const file of files) {
|
||||||
@@ -72,7 +65,7 @@ const files = readFilesRecursively(localGiteaPath);
|
|||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
throw new Error(`HTTP error! status: ${response.status}`);
|
throw new Error(`HTTP error! status: ${response.status}`);
|
||||||
}
|
}
|
||||||
let content = await response.text();
|
const content = await response.text();
|
||||||
fs.writeFileSync(path.join(localGiteaPath, file), content);
|
fs.writeFileSync(path.join(localGiteaPath, file), content);
|
||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
/*!
|
||||||
|
* Copyright (c) https://github.com/lutinglt
|
||||||
|
*
|
||||||
|
* See the NOTICE file distributed with this work for additional
|
||||||
|
* information regarding copyright ownership.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import path from "node:path";
|
||||||
|
import { fileURLToPath } from "node:url";
|
||||||
|
import { ProxyAgent, setGlobalDispatcher } from "undici";
|
||||||
|
import pkg from "../package.json" with { type: "json" };
|
||||||
|
|
||||||
|
export function setGlobalProxy() {
|
||||||
|
const proxyUrl = process.env.HTTPS_PROXY || process.env.HTTP_PROXY || process.env.ALL_PROXY;
|
||||||
|
if (proxyUrl) {
|
||||||
|
setGlobalDispatcher(new ProxyAgent(proxyUrl));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export { pkg };
|
||||||
|
export const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||||
|
export const rootDir = path.join(__dirname, "..");
|
||||||
@@ -17,10 +17,6 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const fs = require("fs");
|
import { pkg } from "./utils.ts";
|
||||||
const path = require("path");
|
|
||||||
|
|
||||||
const pkgPath = path.join(__dirname, "..", "package.json");
|
|
||||||
const pkg = JSON.parse(fs.readFileSync(pkgPath));
|
|
||||||
|
|
||||||
console.log(pkg.version);
|
console.log(pkg.version);
|
||||||
+1
-1
@@ -156,7 +156,7 @@ export function github2ThemeColor(githubColor: GitHubColor): ThemeColor {
|
|||||||
input: {
|
input: {
|
||||||
text: themeVars.color.text.self,
|
text: themeVars.color.text.self,
|
||||||
background: githubColor.bgColor.muted,
|
background: githubColor.bgColor.muted,
|
||||||
toggleBackgound: githubColor.bgColor.inset,
|
toggleBackground: githubColor.bgColor.inset,
|
||||||
border: themeVars.color.light.border,
|
border: themeVars.color.light.border,
|
||||||
},
|
},
|
||||||
light: { self: themeVars.color.body, border: githubColor.borderColor.default },
|
light: { self: themeVars.color.body, border: githubColor.borderColor.default },
|
||||||
|
|||||||
@@ -27,6 +27,6 @@ type CSSVarName = `--${string}`;
|
|||||||
*/
|
*/
|
||||||
export function extractVarName(cssvar: CSSVarFunction): CSSVarName {
|
export function extractVarName(cssvar: CSSVarFunction): CSSVarName {
|
||||||
assertVarName(cssvar);
|
assertVarName(cssvar);
|
||||||
const var_name = cssvar.replace("var(--", "").replace(")", "");
|
const varName = cssvar.replace("var(--", "").replace(")", "");
|
||||||
return `--${var_name}`;
|
return `--${varName}`;
|
||||||
}
|
}
|
||||||
@@ -67,7 +67,7 @@ export const other = {
|
|||||||
/** 滑块按钮的背景色, 不能与背景色一致
|
/** 滑块按钮的背景色, 不能与背景色一致
|
||||||
* @example 管理设置中启用/禁用头像
|
* @example 管理设置中启用/禁用头像
|
||||||
*/
|
*/
|
||||||
toggleBackgound: "color-input-toggle-background",
|
toggleBackground: "color-input-toggle-background",
|
||||||
border: null,
|
border: null,
|
||||||
},
|
},
|
||||||
light: {
|
light: {
|
||||||
|
|||||||
@@ -120,15 +120,16 @@ export const clone = css`
|
|||||||
margin-right: 4px;
|
margin-right: 4px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
> .item{
|
> .item {
|
||||||
&:hover {
|
&:hover {
|
||||||
color: ${themeVars.color.text.self};
|
color: ${themeVars.color.text.self};
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
background: ${themeVars.github.control.transparent.bgColor.hover};
|
background: ${themeVars.github.control.transparent.bgColor.hover};
|
||||||
&:active {
|
&:active {
|
||||||
background: ${themeVars.github.control.transparent.bgColor.active};
|
background: ${themeVars.github.control.transparent.bgColor.active};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -100,7 +100,7 @@ export const selectionDropdown = css`
|
|||||||
border-bottom-right-radius: ${otherThemeVars.border.radius} !important;
|
border-bottom-right-radius: ${otherThemeVars.border.radius} !important;
|
||||||
}
|
}
|
||||||
/* 修复 Gitea 1.26 (:not(:focus)) 导致的小按钮右边框出现问题, 例如软件包类型, 通常相邻有元素 */
|
/* 修复 Gitea 1.26 (:not(:focus)) 导致的小按钮右边框出现问题, 例如软件包类型, 通常相邻有元素 */
|
||||||
.ui.action.input:not([class*="left action"])>.ui.small.dropdown.selection {
|
.ui.action.input:not([class*="left action"]) > .ui.small.dropdown.selection {
|
||||||
border-right: none;
|
border-right: none;
|
||||||
}
|
}
|
||||||
/* 修复因为上面的排除导致的圆角问题 */
|
/* 修复因为上面的排除导致的圆角问题 */
|
||||||
|
|||||||
+1
-1
@@ -37,5 +37,5 @@
|
|||||||
"themes": ["./themes"]
|
"themes": ["./themes"]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"include": ["src", "styles", "themes", "vite.config.ts", "theme.config.ts", "eslint.config.ts"]
|
"include": ["src", "styles", "themes", "scripts", "vite.config.ts", "theme.config.ts", "eslint.config.ts"]
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user