Skip to content

Commit

Permalink
Merge pull request #842 from Hi-Windom/v0.35
Browse files Browse the repository at this point in the history
V0.35
  • Loading branch information
Soltus authored Jun 26, 2024
2 parents 4307af8 + ea16151 commit 08b9ef2
Show file tree
Hide file tree
Showing 25 changed files with 585 additions and 280 deletions.
49 changes: 49 additions & 0 deletions .github/README.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// github 根路径的 README.adoc 文件

link:./docs/Sillot-android[汐洛安卓]
| link:./docs/Sillot-Gibbet[汐洛绞架]
| link:./docs/compatibility[兼容性]
| link:./docs/document[文档]
| link:./docs/roadmap[路线图]

image::split.png[Split Image]

image:https://img.shields.io/github/license/Hi-Windom/Sillot?style=flat&color=0080ff[license]
image:https://img.shields.io/github/last-commit/Hi-Windom/Sillot?style=flat&logo=git&logoColor=white&color=0080ff[last-commit]
image:https://img.shields.io/github/languages/top/Hi-Windom/Sillot?style=flat&color=0080ff[repo-top-language]
image:https://img.shields.io/github/languages/count/Hi-Windom/Sillot?style=flat&color=0080ff[repo-language-count]

image:https://app.codacy.com/project/badge/Grade/3106acfdbc5041118d800c5b4f2f935d[
codacy,
link="https://app.codacy.com/gh/Hi-Windom/Sillot/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade"
]
image:https://www.codefactor.io/repository/github/hi-windom/sillot/badge[
codefactor,
link="https://www.codefactor.io/repository/github/hi-windom/sillot"
]
image:https://codecov.io/gh/Hi-Windom/Sillot/branch/master/graph/badge.svg?token=C6PLVT0R2V[
codecov,
link="https://codecov.io/gh/Hi-Windom/Sillot"
]
image:https://img.shields.io/github/downloads/Hi-Windom/Sillot/total.svg?style=flat-square&color=A26738&logo=github[
downloads,
link="https://github.com/Hi-Windom/Sillot/releases"
]
image:https://img.shields.io/docker/pulls/soltus/sillot?color=99CCFF&label=pulls&logo=docker&logoColor=99CCFF[
docker-pulls,
link="https://hub.docker.com/r/soltus/sillot"
]
image:https://hits.b3log.org/Hi-Windom/Sillot.svg[
Hits,
link="https://github.com/Hi-Windom/Sillot"
]

// 注意当前设置 master 为默认分支
image:https://repobeats.axiom.co/api/embed/708cdf00c747155e49ff28c0c0024e17a28e5705.svg[
Insights,
link="https://github.com/Hi-Windom/Sillot/pulse"
]

image::../app/stage/icon.png[Sillot Logo]

image::https://capsule-render.vercel.app/api?type=waving&color=timeGradient&height=300&&section=footer&text=Hi-Windom&fontSize=90&fontAlign=50&fontAlignY=70&desc=Power%20by%20&descAlign=50&descSize=30&descAlignY=40&animation=twinkling[Hi-Windom Footer]
72 changes: 0 additions & 72 deletions .github/README.md

This file was deleted.

11 changes: 10 additions & 1 deletion .vscode/Sillot.code-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,14 @@
},
// 实验性设置
"notebook.experimental.remoteSave": true,
"markdown.experimental.updateLinksOnPaste": true
"markdown.experimental.updateLinksOnPaste": true,
// CodeGeeX 智能编程助手设置
"Codegeex.Chat.LanguagePreference": "中文",
"Codegeex.Comment.LanguagePreference": "中文",
"Codegeex.SidebarUI.LanguagePreference": "中文",
"Codegeex.CandidateNum": "2 (中)",
"Codegeex.CompletionModel": "CodeGeeX Pro[Beta]",
"asciidoc.antora.enableAntoraSupport": false
},
"extensions": {
"recommendations": [
Expand Down Expand Up @@ -187,6 +194,8 @@
"MainaWycliffe.view-package-on-npm", // 好用,但有点占地方,因此仅推荐
// WakaTime
"WakaTime.vscode-wakatime", // 统计个人编程数据,需要配置TOKEN
"asciidoctor.asciidoctor-vscode", // adoc 官方插件
"AMiner.codegeex", // CodeGeeX 智能编程助手
],
"unwantedRecommendations": [
"oderwat.indent-rainbow", // 花里胡哨影响观感
Expand Down
4 changes: 3 additions & 1 deletion .vscode/extensions/Sillot/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "sillot",
"displayName": "汐洛 Sillot",
"description": "汐洛彖夲肜矩阵(Sillot T☳Converbenk Matrix)为智慧新彖务服务。此插件为汐洛官方插件,提供多功能一体化集成。",
"version": "0.35.24062419",
"version": "0.35.24062700",
"preview": true,
"repository": "https://github.com/Hi-Windom/Sillot",
"publisher": "Hi-Windom",
Expand Down Expand Up @@ -445,6 +445,7 @@
"@vscode/test-cli": "^0.0.8",
"@vscode/test-electron": "^2.3.10",
"@vscode/vsce": "^2.29.0",
"copy-webpack-plugin": "^12.0.2",
"eslint": "^8.57.0",
"jsonc-parser": "^3.2.1",
"mkdirp": "^3.0.1",
Expand All @@ -457,6 +458,7 @@
},
"dependencies": {
"@octokit/rest": "^20.1.1",
"@vscode/webview-ui-toolkit": "^1.4.0",
"fs-extra": "^11.2.0",
"json5": "^2.2.3"
},
Expand Down
94 changes: 19 additions & 75 deletions .vscode/extensions/Sillot/src/task/添加并推送Git_Tag.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import * as vscode from "vscode";
import * as path from "path";
import fs from "fs-extra";
import { formatDate } from "sofill/mid";
import { readJSONFile } from "../utils/json";
import { C } from "../extension.const";
import { getUri, getNonce } from "../utils/webview";

export async function add_task_添加并推送Git_Tag(context: vscode.ExtensionContext) {
const TAG = "汐洛.添加并推送Git_Tag";
Expand Down Expand Up @@ -38,42 +38,14 @@ export async function add_task_添加并推送Git_Tag(context: vscode.ExtensionC
/*html*/ `<h2>${TAG}</h2>
<h3>当前 webview 载体扩展版本:${extensionVersion}</h3>
<h3>目标 git 本地仓库:${selectedProject}</h3>
<input id="git_tag" placeholder="请输入 git tag" oninput="checkInput(this)"/><span class="error-message"></span><br>
<textarea id="git_tag_description" data-vscode-context='{"webviewSection": "editor", "preventDefaultContextMenuItems": true}' placeholder="描述(可选)"></textarea><br>
<button onClick="runCMD('git_tag')">提交</button><button onClick="runCMD('git_tag_push')">推送到远端</button>
<button onClick="closeModal()">关闭面板</button>
<script>
window.vscode = acquireVsCodeApi(); // acquireVsCodeApi 只能调用一次
function runCMD(text) {
const tagElement = document.getElementById('git_tag')
const descriptionElement = document.getElementById('git_tag_description')
window.vscode.postMessage({ message: 'runCMD', text: text, cmd: [tagElement.value, descriptionElement.value] });
}
function closeModal() {window.vscode.postMessage({ message: 'closeModal' });}
function checkInput(inputElement) {
const value = inputElement.value;
const illegalChars = ['。', ',', '/', ',', '、'];
let hasIllegalChar = false;
let illegalCharMessage = "疑似输入非法字符: ";
for (let char of illegalChars) {
if (value.includes(char)) {
hasIllegalChar = true;
illegalCharMessage += char + " ";
}
}
const messageElement = inputElement.nextElementSibling;
if (hasIllegalChar) {
inputElement.classList.add('error-input');
messageElement.textContent = illegalCharMessage;
} else {
inputElement.classList.remove('error-input');
messageElement.textContent = "";
}
}
</script>
<section id ="git-tag-form">
<vscode-text-field id="git_tag" placeholder="请输入 git tag">标签名</vscode-text-field>
<span class="error-message"></span><br>
<vscode-text-area id="git_tag_description" data-vscode-context='{"webviewSection": "editor", "preventDefaultContextMenuItems": true}' placeholder="为空则自动使用最后一条提交的描述" resize="vertical" rows=5>描述(可选)</vscode-text-area><br>
<vscode-button id="runCMD('git_tag')">提交</vscode-button>
<vscode-button id="runCMD('git_tag_push')">推送到远端</vscode-button>
<vscode-button id="closeModal()">关闭面板</vscode-button>
</section>
`,
iconPath
);
Expand Down Expand Up @@ -143,25 +115,24 @@ export function showCustomModal(tag: string, body: string, iconPath: string | un
enableForms: true,
retainContextWhenHidden: true, // webview被隐藏时保持状态,避免被重置.很高的内存开销 REF https://code.visualstudio.com/api/extension-guides/webview#retaincontextwhenhidden
});
panel.webview.html = /*html*/ `
const extensionUri = vscode.extensions.getExtension(C.extensionId)?.extensionUri;
if (extensionUri) {
const jsUri = getUri(panel.webview, extensionUri, ["out", "webview.js"]);
const styleUri = getUri(panel.webview, extensionUri, ["out", "webview.css"]);
const nonce = getNonce();
panel.webview.html = /*html*/ `
<html>
<head>
<style>
.error-input {
border: 2px solid red;
margin-right: 3px;
}
.error-message {
color: red;
font-size: 1.31em;
}
</style>
<meta http-equiv="Content-Security-Policy" content="default-src 'none'; script-src 'nonce-${nonce}'; style-src 'unsafe-inline' 'self' https:;">
<link rel="stylesheet" href="${styleUri}">
</head>
<body>
${body}
</body>
<script type="module" nonce="${nonce}" src="${jsUri}"></script>
</html>
`;
}
panel.webview.onDidReceiveMessage(jj => {
console.log(jj);
switch (jj.message) {
Expand All @@ -177,30 +148,3 @@ export function showCustomModal(tag: string, body: string, iconPath: string | un
}
return panel;
}

/**
* 获取某个扩展文件相对于webview需要的一种特殊路径格式
* 形如:vscode-resource:/Users/toonces/projects/vscode-cat-coding/media/cat.gif
* @param context 上下文
* @param relativePath 扩展中某个文件相对于根目录的路径,如 images/test.jpg
*/
function getExtensionFileVscodeResource(context: vscode.ExtensionContext, relativePath: string) {
const diskPath = vscode.Uri.file(path.join(context.extensionPath, relativePath));
return diskPath.with({ scheme: "vscode-resource" }).toString();
}

/**
* 从某个HTML文件读取能被Webview加载的HTML内容
* @param {*} context 上下文
* @param {*} templatePath 相对于插件根目录的html文件相对路径
*/
function getWebViewContent(context: vscode.ExtensionContext, templatePath: string) {
const resourcePath = path.join(context.extensionPath, templatePath);
const dirPath = path.dirname(resourcePath);
let html = fs.readFileSync(resourcePath, "utf-8");
// vscode不支持直接加载本地资源,需要替换成其专有路径格式,这里只是简单的将样式和JS的路径替换
html = html.replace(/(<link.+?href="|<script.+?src="|<img.+?src=")(.+?)"/g, (m: any, $1: string, $2: string) => {
return $1 + vscode.Uri.file(path.resolve(dirPath, $2)).with({ scheme: "vscode-resource" }).toString() + '"';
});
return html;
}
63 changes: 63 additions & 0 deletions .vscode/extensions/Sillot/src/utils/webview.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import { Uri, type Webview } from "vscode";
import * as vscode from "vscode";
import * as path from "path";
import fs from "fs-extra";

/**
* A helper function which will get the webview URI of a given file or resource.
*
* @remarks This URI can be used within a webview's HTML as a link to the
* given file/resource.
*
* @param webview A reference to the extension webview
* @param extensionUri The URI of the directory containing the extension
* @param pathList An array of strings representing the path to a file/resource
* @returns A URI pointing to the file/resource
*/
export function getUri(webview: Webview, extensionUri: Uri, pathList: string[]) {
return webview.asWebviewUri(Uri.joinPath(extensionUri, ...pathList));
}

/**
* A helper function that returns a unique alphanumeric identifier called a nonce.
*
* @remarks This function is primarily used to help enforce content security
* policies for resources/scripts being executed in a webview context.
*
* @returns A nonce
*/
export function getNonce() {
let text = "";
const possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
for (let i = 0; i < 32; i++) {
text += possible.charAt(Math.floor(Math.random() * possible.length));
}
return text;
}

/**
* 获取某个扩展文件相对于webview需要的一种特殊路径格式
* 形如:vscode-resource:/Users/toonces/projects/vscode-cat-coding/media/cat.gif
* @param context 上下文
* @param relativePath 扩展中某个文件相对于根目录的路径,如 images/test.jpg
*/
export function getExtensionFileVscodeResource(context: vscode.ExtensionContext, relativePath: string) {
const diskPath = vscode.Uri.file(path.join(context.extensionPath, relativePath));
return diskPath.with({ scheme: "vscode-resource" }).toString();
}

/**
* 从某个HTML文件读取能被Webview加载的HTML内容
* @param {*} context 上下文
* @param {*} templatePath 相对于插件根目录的html文件相对路径
*/
export function getWebViewContent(context: vscode.ExtensionContext, templatePath: string) {
const resourcePath = path.join(context.extensionPath, templatePath);
const dirPath = path.dirname(resourcePath);
let html = fs.readFileSync(resourcePath, "utf-8");
// vscode不支持直接加载本地资源,需要替换成其专有路径格式,这里只是简单的将样式和JS的路径替换
html = html.replace(/(<link.+?href="|<script.+?src="|<img.+?src=")(.+?)"/g, (m: any, $1: string, $2: string) => {
return $1 + vscode.Uri.file(path.resolve(dirPath, $2)).with({ scheme: "vscode-resource" }).toString() + '"';
});
return html;
}
Loading

0 comments on commit 08b9ef2

Please sign in to comment.