mirror of
https://github.com/Physton/sd-webui-prompt-all-in-one.git
synced 2026-01-26 19:29:56 +00:00
Add About window
Former-commit-id: 5fc236655eae88c1a2de0b1167733e0a0986bdcb
This commit is contained in:
@@ -1 +1 @@
|
||||
8c3c12af638d571917342cee642eaad476faca68
|
||||
f6a24778b29e3ac4ce40489a30befea649c34fe9
|
||||
@@ -1 +1 @@
|
||||
f0989385b264c03c690ea019a8ce9eeb8653b629
|
||||
eee6babe1b0f66667f5d0cc62da24707704274ea
|
||||
@@ -1 +1 @@
|
||||
f6e65e80bbbcd4e8f3d757aaa6d79e731fe9fba4
|
||||
94f23b71949a9379ef12a4b726fe7babe1ebb494
|
||||
84
scripts/get_version.py
Normal file
84
scripts/get_version.py
Normal file
@@ -0,0 +1,84 @@
|
||||
import os
|
||||
import re
|
||||
import requests
|
||||
import subprocess
|
||||
import hashlib
|
||||
|
||||
def get_git_commit_version():
|
||||
extension_dir = os.path.dirname(os.path.abspath(__file__)) + '/../'
|
||||
extension_dir = os.path.normpath(extension_dir)
|
||||
git_path = os.path.join(extension_dir, '.git')
|
||||
if os.path.exists(git_path):
|
||||
try:
|
||||
git = os.environ.get('GIT', "git")
|
||||
if not git:
|
||||
git = "git"
|
||||
cmd = [git, 'rev-parse', 'HEAD']
|
||||
commit_version = subprocess.check_output(cmd, cwd=extension_dir).decode('utf-8').strip()
|
||||
if re.match(r'^[0-9a-f]{40}$', commit_version):
|
||||
return commit_version
|
||||
except Exception as e:
|
||||
pass
|
||||
|
||||
try:
|
||||
ref_path = os.path.join(git_path, 'refs', 'heads', 'main')
|
||||
with open(ref_path, 'r') as f:
|
||||
commit_version = f.read().strip()
|
||||
if re.match(r'^[0-9a-f]{40}$', commit_version):
|
||||
return commit_version
|
||||
except Exception as e:
|
||||
pass
|
||||
|
||||
return ''
|
||||
|
||||
def _handle_versions(response, filter_update_readme=False):
|
||||
try:
|
||||
if response.status_code != 200:
|
||||
return []
|
||||
result = response.json()
|
||||
if not result:
|
||||
return []
|
||||
versions = []
|
||||
for item in result:
|
||||
message = item['commit']['message']
|
||||
is_update_readme = False
|
||||
if message.lower().strip() == 'update readme.md':
|
||||
if filter_update_readme:
|
||||
continue
|
||||
is_update_readme = True
|
||||
versions.append({
|
||||
'version': item['sha'],
|
||||
'message': message,
|
||||
'date': item['commit']['committer']['date'],
|
||||
'is_update_readme': is_update_readme
|
||||
})
|
||||
return versions
|
||||
except Exception as e:
|
||||
return []
|
||||
|
||||
def get_git_remote_versions(page=1, per_page=100, filter_update_readme=False):
|
||||
api_urls = [
|
||||
'https://api.github.com/repos/physton/sd-webui-prompt-all-in-one/commits',
|
||||
'https://gitee.com/api/v5/repos/physton/sd-webui-prompt-all-in-one/commits'
|
||||
]
|
||||
|
||||
for api_url in api_urls:
|
||||
try:
|
||||
api_url += f'?page={page}&per_page={per_page}'
|
||||
key = hashlib.md5(api_url.encode('utf-8')).hexdigest()
|
||||
response = requests.get(api_url)
|
||||
versions = _handle_versions(response, filter_update_readme)
|
||||
return versions
|
||||
except Exception as e:
|
||||
pass
|
||||
|
||||
return []
|
||||
|
||||
def get_latest_version():
|
||||
current_version = get_git_commit_version()
|
||||
# if not current_version:
|
||||
# return current_version
|
||||
versions = get_git_remote_versions(1, 10, True)
|
||||
if len(versions) < 1:
|
||||
return current_version
|
||||
return versions[0]['version']
|
||||
@@ -18,8 +18,7 @@ from scripts.get_extra_networks import get_extra_networks
|
||||
from scripts.packages import get_packages_state, install_package
|
||||
from scripts.gen_openai import gen_openai
|
||||
from scripts.get_lang import get_lang
|
||||
|
||||
VERSION = '0.0.1'
|
||||
from scripts.get_version import get_git_commit_version, get_git_remote_versions, get_latest_version
|
||||
|
||||
try:
|
||||
from modules.shared import cmd_opts
|
||||
@@ -59,7 +58,16 @@ def on_app_started(_: gr.Blocks, app: FastAPI):
|
||||
|
||||
@app.get("/physton_prompt/get_version")
|
||||
async def _get_version():
|
||||
return {"version": VERSION}
|
||||
return {
|
||||
'version': get_git_commit_version(),
|
||||
'latest_version': get_latest_version(),
|
||||
}
|
||||
|
||||
@app.get("/physton_prompt/get_remote_versions")
|
||||
async def _get_remote_versions(page: int = 1, per_page: int = 100):
|
||||
return {
|
||||
'versions': get_git_remote_versions(page, per_page),
|
||||
}
|
||||
|
||||
@app.get("/physton_prompt/get_config")
|
||||
async def _get_config():
|
||||
|
||||
@@ -36,6 +36,10 @@
|
||||
:loras="loras"
|
||||
:lycos="lycos"
|
||||
:embeddings="embeddings"
|
||||
:version="version"
|
||||
:latest-version="latestVersion"
|
||||
:is-latest-version="isLatestVersion"
|
||||
@click:show-about="onShowAbout"
|
||||
></physton-prompt>
|
||||
</template>
|
||||
<translate-setting ref="translateSetting" v-model:language-code="languageCode"
|
||||
@@ -77,6 +81,9 @@
|
||||
<chatgpt-prompt ref="chatgptPrompt" v-model:language-code="languageCode"
|
||||
:translate-apis="translateApis" :languages="languages"
|
||||
@use="onUseChatgpt" />
|
||||
<about ref="about" v-model:language-code="languageCode"
|
||||
:translate-apis="translateApis" :languages="languages"
|
||||
:version="version" :latest-version="latestVersion" :is-latest-version="isLatestVersion" />
|
||||
|
||||
<div class="physton-paste-popup" v-if="showPastePopup" @click="closePastePopup">
|
||||
<div class="paste-popup-main" @click.stop>
|
||||
@@ -109,10 +116,12 @@ import ExtensionCss from "@/components/extensionCss.vue";
|
||||
import PromptFormat from "@/components/promptFormat.vue";
|
||||
import PackagesState from "@/components/packagesState.vue";
|
||||
import ChatgptPrompt from "@/components/chatgptPrompt.vue";
|
||||
import About from "@/components/about.vue";
|
||||
|
||||
export default {
|
||||
name: 'App',
|
||||
components: {
|
||||
About,
|
||||
ChatgptPrompt,
|
||||
PackagesState,
|
||||
PromptFormat,
|
||||
@@ -242,6 +251,10 @@ export default {
|
||||
|
||||
python: '',
|
||||
packagesState: [],
|
||||
|
||||
version: '',
|
||||
latestVersion: '',
|
||||
isLatestVersion: true,
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
@@ -533,7 +546,14 @@ export default {
|
||||
|
||||
this.handlePaste()
|
||||
|
||||
this.gradioAPI.getVersion().then(res => {
|
||||
this.version = res.version
|
||||
this.latestVersion = res.latest_version
|
||||
this.isLatestVersion = res.version === res.latest_version
|
||||
})
|
||||
|
||||
// todo: test
|
||||
// this.$refs.about.open()
|
||||
// this.$refs.chatgptPrompt.open()
|
||||
// this.$refs.promptFormat.open()
|
||||
// this.$refs.translateSetting.open(this.translateApi)
|
||||
@@ -722,6 +742,9 @@ export default {
|
||||
if (!item) return
|
||||
this.$refs[item.id][0].useChatgpt(prompt)
|
||||
},
|
||||
onShowAbout() {
|
||||
this.$refs.about.open()
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
129
src/src/components/about.vue
Normal file
129
src/src/components/about.vue
Normal file
@@ -0,0 +1,129 @@
|
||||
<template>
|
||||
<div class="physton-about-prompt" v-if="isOpen" @click="close">
|
||||
<div class="about-main" @click.stop>
|
||||
<div class="about-close" @click="close">
|
||||
<icon-svg name="close"/>
|
||||
</div>
|
||||
<div class="about-body" @click.stop>
|
||||
<p class="body-title"><a href="https://github.com/Physton/sd-webui-prompt-all-in-one" target="_blank">sd-webui-prompt-all-in-one</a></p>
|
||||
<p>
|
||||
<a v-for="(item) in icons" :key="item.title" :href="item.url" target="_blank">
|
||||
<img :src="item.image" :alt="item.title" />
|
||||
</a>
|
||||
</p>
|
||||
<p>
|
||||
<span>{{ getLang('version') }}: <a :href="commitUrl(version)" target="_blank">{{ formatVersion(version) }}</a></span>
|
||||
<span class="has-new-version" v-if="!isLatestVersion && latestVersion"> ({{ getLang('has_new_version') }}: <a :href="commitUrl(latestVersion)" target="_blank">{{ formatVersion(latestVersion) }}</a>)</span>
|
||||
</p>
|
||||
<p>{{ getLang('wiki_desc') }} <a href="https://physton.github.io/sd-webui-prompt-all-in-one-assets/#/Installation" target="_blank">Wiki</a></p>
|
||||
<div class="version-list">
|
||||
<icon-svg v-if="loading" name="loading"/>
|
||||
<div class="version-item" v-for="(item) in versions" :key="item.version">
|
||||
<div class="item-header">
|
||||
<div class="version-sha"><a :href="commitUrl(item.version)" target="_blank">{{ formatVersion(item.version) }}</a></div>
|
||||
<div class="version-date">{{ item.date }}</div>
|
||||
</div>
|
||||
<div class="version-msg">{{ item.message }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import LanguageMixin from "@/mixins/languageMixin";
|
||||
import IconSvg from "@/components/iconSvg.vue";
|
||||
import common from "@/utils/common";
|
||||
|
||||
export default {
|
||||
name: 'About',
|
||||
components: {IconSvg},
|
||||
mixins: [LanguageMixin],
|
||||
props: {
|
||||
version: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
latestVersion: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
isLatestVersion: {
|
||||
type: Boolean,
|
||||
default: true,
|
||||
},
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
isOpen: false,
|
||||
loading: false,
|
||||
versions: [],
|
||||
icons: [
|
||||
{
|
||||
'title': 'GitHub stars',
|
||||
'url': 'https://github.com/Physton/sd-webui-prompt-all-in-one/stargazers',
|
||||
'image': 'https://img.shields.io/github/stars/Physton/sd-webui-prompt-all-in-one?style=plastic',
|
||||
},
|
||||
{
|
||||
'title': 'GitHub forks',
|
||||
'url': 'https://github.com/Physton/sd-webui-prompt-all-in-one/network/members',
|
||||
'image': 'https://img.shields.io/github/forks/Physton/sd-webui-prompt-all-in-one?style=plastic',
|
||||
},
|
||||
{
|
||||
'title': 'GitHub issues',
|
||||
'url': 'https://github.com/Physton/sd-webui-prompt-all-in-one/issues',
|
||||
'image': 'https://img.shields.io/github/issues/Physton/sd-webui-prompt-all-in-one?style=plastic',
|
||||
},
|
||||
{
|
||||
'title': 'GitHub issues closed',
|
||||
'url': 'https://github.com/Physton/sd-webui-prompt-all-in-one/issues?q=is%3Aissue+is%3Aclosed',
|
||||
'image': 'https://img.shields.io/github/issues-closed/Physton/sd-webui-prompt-all-in-one?style=plastic',
|
||||
},
|
||||
{
|
||||
'title': 'GitHub license',
|
||||
'url': 'https://github.com/Physton/sd-webui-prompt-all-in-one/blob/master/LICENSE.md',
|
||||
'image': 'https://img.shields.io/github/license/Physton/sd-webui-prompt-all-in-one?style=plastic',
|
||||
},
|
||||
{
|
||||
'title': 'GitHub commits',
|
||||
'url': 'https://github.com/Physton/sd-webui-prompt-all-in-one/commits/main',
|
||||
'image': 'https://img.shields.io/github/last-commit/Physton/sd-webui-prompt-all-in-one?style=plastic',
|
||||
},
|
||||
]
|
||||
}
|
||||
},
|
||||
emits: ['use'],
|
||||
computed: {},
|
||||
mounted() {
|
||||
},
|
||||
methods: {
|
||||
open() {
|
||||
this.isOpen = true
|
||||
this.versions = []
|
||||
this.loading = true
|
||||
this.gradioAPI.getRemoteVersions().then(res => {
|
||||
this.loading = false
|
||||
let versions = []
|
||||
res.forEach((item, index) => {
|
||||
if (item.is_update_readme) return
|
||||
item.date = common.formatTime(item.date)
|
||||
versions.push(item)
|
||||
})
|
||||
this.versions = versions
|
||||
}).catch(err => {
|
||||
this.loading = false
|
||||
})
|
||||
},
|
||||
close() {
|
||||
this.isOpen = false
|
||||
},
|
||||
commitUrl(version) {
|
||||
return 'https://github.com/Physton/sd-webui-prompt-all-in-one/commit/' + version
|
||||
},
|
||||
formatVersion(version) {
|
||||
if (!version) return this.getLang('unknown_version')
|
||||
return version.slice(0, 7)
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
@@ -117,7 +117,7 @@ export default {
|
||||
},
|
||||
methods: {
|
||||
formatTime(time) {
|
||||
return common.formatTime(time, false)
|
||||
return common.formatTime(time * 1000, false)
|
||||
},
|
||||
getFavorites(favoriteKey) {
|
||||
if (!favoriteKey) return
|
||||
|
||||
@@ -121,7 +121,7 @@ export default {
|
||||
},
|
||||
methods: {
|
||||
formatTime(time) {
|
||||
return common.formatTime(time, false)
|
||||
return common.formatTime(time * 1000, false)
|
||||
},
|
||||
getHistories(historyKey) {
|
||||
if (!historyKey) return
|
||||
|
||||
@@ -1 +1 @@
|
||||
a0419acb5f80b8b9774051d49ab33a9ef9a776fa
|
||||
f1925daddc3097ff0dae4b577a8e100bc68fdf77
|
||||
@@ -416,7 +416,7 @@ export default {
|
||||
* @returns {string}
|
||||
*/
|
||||
formatTime(time, hasYear = true) {
|
||||
let now = new Date(time * 1000);
|
||||
let now = new Date(time);
|
||||
let year = now.getFullYear();
|
||||
let month = now.getMonth() + 1;
|
||||
if (month < 10) month = "0" + month;
|
||||
|
||||
@@ -16,7 +16,11 @@ export default class GradioAPI {
|
||||
}
|
||||
|
||||
async getVersion() {
|
||||
return (await this.api.get("/get_version")).data.version
|
||||
return (await this.api.get("/get_version")).data
|
||||
}
|
||||
|
||||
async getRemoteVersions(page = 1, per_page = 100) {
|
||||
return (await this.api.get("/get_remote_versions", {params: {page, per_page}})).data.versions
|
||||
}
|
||||
|
||||
async getConfig() {
|
||||
|
||||
@@ -55,7 +55,7 @@
|
||||
fill: #596572;
|
||||
}
|
||||
/*图标尺寸*/
|
||||
.physton-gradio-container.dark .physton-prompt .prompt-header .setting-box .icon-svg-api svg,.physton-gradio-container.dark .physton-prompt .prompt-header .setting-box .icon-svg-format svg, .physton-gradio-container.dark .physton-prompt .prompt-header .setting-box .icon-svg-theme svg, .physton-gradio-container.dark .physton-prompt .prompt-header .setting-box .icon-svg-remove-space svg, .physton-gradio-container.dark .physton-prompt .prompt-header .setting-box .icon-svg-tooltip svg {
|
||||
.physton-gradio-container.dark .physton-prompt .prompt-header .setting-box .icon-svg-api svg,.physton-gradio-container.dark .physton-prompt .prompt-header .setting-box .icon-svg-format svg, .physton-gradio-container.dark .physton-prompt .prompt-header .setting-box .icon-svg-theme svg, .physton-gradio-container.dark .physton-prompt .prompt-header .setting-box .icon-svg-remove-space svg, .physton-gradio-container.dark .physton-prompt .prompt-header .setting-box .icon-svg-tooltip svg, .physton-gradio-container.dark .physton-prompt .prompt-header .setting-box .icon-svg-about svg {
|
||||
width: auto;
|
||||
height: 18px;
|
||||
}
|
||||
@@ -538,7 +538,7 @@
|
||||
fill: #565656c2;
|
||||
}
|
||||
/*图标尺寸*/
|
||||
.physton-gradio-container.light .physton-prompt .prompt-header .setting-box .icon-svg-api svg, .physton-gradio-container.light .physton-prompt .prompt-header .setting-box .icon-svg-format svg, .physton-gradio-container.light .physton-prompt .prompt-header .setting-box .icon-svg-theme svg, .physton-gradio-container.light .physton-prompt .prompt-header .setting-box .icon-svg-remove-space svg, .physton-gradio-container.light .physton-prompt .prompt-header .setting-box .icon-svg-tooltip svg {
|
||||
.physton-gradio-container.light .physton-prompt .prompt-header .setting-box .icon-svg-api svg, .physton-gradio-container.light .physton-prompt .prompt-header .setting-box .icon-svg-format svg, .physton-gradio-container.light .physton-prompt .prompt-header .setting-box .icon-svg-theme svg, .physton-gradio-container.light .physton-prompt .prompt-header .setting-box .icon-svg-remove-space svg, .physton-gradio-container.light .physton-prompt .prompt-header .setting-box .icon-svg-tooltip svg, .physton-gradio-container.light .physton-prompt .prompt-header .setting-box .icon-svg-about svg {
|
||||
width: auto;
|
||||
height: 18px;
|
||||
}
|
||||
|
||||
10
styles/extensions/Webui/style.min.css
vendored
10
styles/extensions/Webui/style.min.css
vendored
@@ -60,6 +60,11 @@
|
||||
/* 功能设置图标样式*/
|
||||
fill: var(--body-text-color);
|
||||
}
|
||||
.physton-prompt .prompt-header .setting-box .icon-svg-about svg path{
|
||||
|
||||
/* 功能设置图标样式*/
|
||||
fill: var(--body-text-color);
|
||||
}
|
||||
.physton-prompt .prompt-header .setting-box .icon-svg-theme svg path{
|
||||
|
||||
fill: var(--body-text-color);
|
||||
@@ -96,6 +101,11 @@
|
||||
height: auto;
|
||||
width: 22px;
|
||||
}
|
||||
.physton-prompt .prompt-header .setting-box .icon-svg-about svg {
|
||||
|
||||
height: auto;
|
||||
width: 22px;
|
||||
}
|
||||
|
||||
|
||||
.physton-prompt .prompt-header .prompt-unfold .icon-svg-unfold svg {
|
||||
|
||||
@@ -102,6 +102,7 @@
|
||||
--pp-ph-sb-iconSvgEnglish-color: #4d4f4d;
|
||||
--pp-ph-sb-iconSvgRemoveSpace-color: #4d4f4d;
|
||||
--pp-ph-sb-iconSvgTooltip-color: #4d4f4d;
|
||||
--pp-ph-sb-iconSvgAbout-color: #4d4f4d;
|
||||
|
||||
// .physton-prompt .prompt-header
|
||||
--pp-ph-iconSvgInput-color: #4d4f4d;
|
||||
@@ -215,6 +216,7 @@
|
||||
--pp-ph-sb-iconSvgEnglish-color: #b3b3b3;
|
||||
--pp-ph-sb-iconSvgRemoveSpace-color: #b3b3b3;
|
||||
--pp-ph-sb-iconSvgTooltip-color: #b3b3b3;
|
||||
--pp-ph-sb-iconSvgAbout-color: #b3b3b3;
|
||||
|
||||
// .physton-prompt .prompt-header
|
||||
--pp-ph-iconSvgInput-color: #b3b3b3;
|
||||
|
||||
2
styles/extensions/minimalist/style.min.css
vendored
2
styles/extensions/minimalist/style.min.css
vendored
File diff suppressed because one or more lines are too long
4
styles/icons/about.svg
Normal file
4
styles/icons/about.svg
Normal file
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg id="uuid-ec83c61a-ff3f-478d-b756-c23dba55e302" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 120 120">
|
||||
<path d="m57.47,40c1.61,0,6.56-.77,8.14-2.29,1.55-1.48,2.41-3.54,2.36-5.69.03-2.13-.82-4.18-2.36-5.65-1.49-1.51-3.53-2.35-5.66-2.32-2.09-.03-4.1.8-5.56,2.29-1.54,1.48-2.38,3.54-2.34,5.68,0,2.3.79,4.21,2.36,5.72,1.58,1.5,1.49,2.26,3.05,2.26ZM60,0C26.86,0,0,26.86,0,60s26.86,60,60,60,60-26.86,60-60S93.14,0,60,0Zm0,112c-28.72,0-52-23.28-52-52S31.28,8,60,8s52,23.28,52,52-23.28,52-52,52Zm4.94-34.82l-1.86,1.86,4.97-26.35c.03-.18-.02-.35-.02-.53v-.08c.02-1.07-.4-2.1-1.18-2.84l-.03-.06s-.06-.02-.08-.05c-.46-.43-1.02-.75-1.62-.93-.21-.06-.38-.18-.6-.22-.15-.02-.3.02-.46,0h-.39c-1.52.02-2.93.84-3.69,2.16l-10.78,10.78c-1.62,1.62-1.62,4.25,0,5.88,1.62,1.62,4.25,1.62,5.88,0h0l1.86-1.86-4.96,26.35c-.03.18.02.35.02.54v.08c-.03,1.07.4,2.1,1.18,2.84l.03.05.08.06c.47.42,1.02.73,1.62.92.2.06.37.18.59.22.16.02.31-.02.47,0l.39-.02c1.52,0,2.93-.82,3.69-2.14l10.78-10.78c1.62-1.62,1.62-4.25,0-5.87-1.62-1.62-4.25-1.62-5.87,0h0Z"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.1 KiB |
@@ -1 +1 @@
|
||||
abb8af0c0abe043e4cddd9a0f5ecb0d801ccd4f7
|
||||
9a31b0506a52effe9cc6312a29f7a494d816eb00
|
||||
@@ -1 +1 @@
|
||||
9f706d1f0e0aa24d899dee1de34e9e416c04392f
|
||||
7088e9ddf5c4a87b2e5c028f215d500c6f3b7ee1
|
||||
9
tests/get_version.py
Normal file
9
tests/get_version.py
Normal file
@@ -0,0 +1,9 @@
|
||||
import os
|
||||
import sys
|
||||
sys.path.append(os.path.join(os.path.dirname(__file__), ".."))
|
||||
|
||||
from scripts.get_version import get_git_commit_version, get_git_remote_versions, get_latest_version
|
||||
|
||||
print(get_git_remote_versions())
|
||||
print(get_git_commit_version())
|
||||
print(get_latest_version())
|
||||
Reference in New Issue
Block a user