Skip to content

Commit

Permalink
dev
Browse files Browse the repository at this point in the history
  • Loading branch information
zanllp committed Jul 10, 2024
1 parent 9bef303 commit 85caca9
Show file tree
Hide file tree
Showing 9 changed files with 145 additions and 64 deletions.
75 changes: 74 additions & 1 deletion .github/workflows/tauri_app_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,81 @@ jobs:
vue/src-tauri/target/release/bundle/nsis/Infinite Image Browsing_${{ env.VERSION }}_x64-setup.exe
vue/src-tauri/target/release/bundle/deb/infinite-image-browsing_${{ env.VERSION }}_amd64.deb
build-by-pyinstaller:
strategy:
matrix:
os: [windows-latest]

runs-on: ${{ matrix.os }}

permissions:
contents: write
steps:
- name: Check-out repository
uses: actions/checkout@v3

- run: echo "VERSION=$(jq -r '.package.version' vue/src-tauri/tauri.conf.json)" >> $env:GITHUB_ENV

- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
cache: 'pip'
cache-dependency-path: |
**/requirements*.txt
- name: Install Dependencies
run: |
pip install -r requirements.txt
- uses: sayyid5416/pyinstaller@v1
with:
spec: 'app.py'
upload_exe_with_name: 'My executable'
options: --onefile

- run: mv dist/app.exe vue/src-tauri/iib_api_server-x86_64-pc-windows-msvc.exe

- name: Install frontend dependencies
run: yarn install
working-directory: vue

- name: Rust setup
uses: dtolnay/rust-toolchain@stable

- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: 18

- name: Rust cache
uses: swatinem/rust-cache@v2
with:
workspaces: './vue/src-tauri -> target'

- name: Install dependencies (ubuntu only)
if: matrix.os == 'ubuntu-20.04'
run: |
sudo apt-get update
sudo apt-get install -y libgtk-3-dev webkit2gtk-4.0 libayatana-appindicator3-dev librsvg2-dev patchelf
- name: Build the app
run: |
yarn tauri-build
working-directory: vue

- run: mv vue/src-tauri/target/release/bundle/nsis/Infinite Image Browsing_${{ env.VERSION }}_x64-setup.exe vue/src-tauri/target/release/bundle/nsis/Infinite Image Browsing_${{ env.VERSION }}_x64-setup-pyinstaller.exe

- name: Upload Artifacts
uses: actions/upload-artifact@v3
with:
name: bundle-${{ env.VERSION }}-${{ runner.os }}
path: |
vue/src-tauri/target/release/bundle/nsis/Infinite Image Browsing_${{ env.VERSION }}_x64-setup.exe
release:
needs: build
needs: [build, build-by-pyinstaller]
runs-on: ubuntu-latest

permissions:
Expand Down
4 changes: 2 additions & 2 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ def setup_parser() -> argparse.ArgumentParser:
parser.add_argument(
"--generate_image_cache",
action="store_true",
help="Pre-generate image cache to speed up browsing.",
help="Pre-generate image cache to speed up browsing. By default, only the extra paths added by the user are processed, not the paths in sd_webui_config. If you need to process paths in sd_webui_config, you must use the --sd_webui_config and --sd_webui_path_relative_to_config parameters.",
)
parser.add_argument(
"--generate_image_cache_size",
Expand Down Expand Up @@ -296,4 +296,4 @@ async def async_launch_app(
)
exit(0)

launch_app(**vars(args))
launch_app(**vars(args))
4 changes: 2 additions & 2 deletions scripts/iib/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
to_abs_path,
is_secret_key_required,
open_file_with_default_app,
is_nuitka,
is_exe_ver,
backup_db_file,
get_current_commit_hash,
get_current_tag
Expand Down Expand Up @@ -118,7 +118,7 @@ def infinite_image_browsing_api(app: FastAPI, **kwargs):
cache_base_dir = get_cache_dir()

# print(f"IIB api_base:{api_base} fe_public_path:{fe_public_path}")
if IIB_DEBUG or is_nuitka:
if IIB_DEBUG or is_exe_ver:
@app.exception_handler(Exception)
async def exception_handler(request: Request, exc: Exception):
error_msg = f"An exception occurred while processing {request.method} {request.url}: {exc}"
Expand Down
3 changes: 2 additions & 1 deletion scripts/iib/plugin.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os
import importlib.util
import sys
from scripts.iib.tool import cwd

def load_plugins(plugin_dir):
plugins = []
Expand All @@ -18,7 +19,7 @@ def load_plugins(plugin_dir):
plugin_inst_map = {}
# 使用插件
try:
plugin_dir = os.path.normpath(os.path.join(os.path.dirname(__file__), '../../', 'plugins'))
plugin_dir = os.path.normpath(os.path.join(cwd, 'plugins'))
plugins = load_plugins(plugin_dir)
sys.path.append(plugin_dir)
for plugin in plugins:
Expand Down
6 changes: 4 additions & 2 deletions scripts/iib/tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import platform
import re
import tempfile
import imghdr
import subprocess
from typing import Dict, List
import sys
Expand All @@ -29,7 +28,10 @@

is_dev = os.getenv("APP_ENV") == "dev"
is_nuitka = "__compiled__" in globals()
cwd = os.getcwd() if is_nuitka else os.path.normpath(os.path.join(__file__, "../../../"))
is_pyinstaller_bundle = bool(getattr(sys, 'frozen', False) and hasattr(sys, '_MEIPASS'))
is_exe_ver = is_nuitka or is_pyinstaller_bundle

cwd = os.getcwd() if is_exe_ver else os.path.normpath(os.path.join(__file__, "../../../"))
is_win = platform.system().lower().find("windows") != -1


Expand Down
1 change: 1 addition & 0 deletions vue/src/i18n/en.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { IIBI18nMap } from '.'

export const en: IIBI18nMap = {
selectFolder: 'Select Folder',
openFileLocationInNewTab: 'Open File Location in New Tab',
copyTo: 'Copy to',
moveTo: 'Move to',
Expand Down
1 change: 1 addition & 0 deletions vue/src/i18n/zh-hans.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export const zhHans = {
selectFolder: '选择文件夹',
openFileLocationInNewTab: '在新标签页打开文件位置',
copyTo: '复制到',
moveTo: '移动到',
Expand Down
3 changes: 2 additions & 1 deletion vue/src/i18n/zh-hant.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { IIBI18nMap } from '.'

export const zhHant: Partial<IIBI18nMap> = {
selectFolder: '選擇文件夾',
openFileLocationInNewTab: '在新標籤頁打開文件位置',
copyTo: '複製到',
moveTo: '移動到',
Expand Down Expand Up @@ -93,7 +94,7 @@ export const zhHant: Partial<IIBI18nMap> = {
previewInNewWindow: '在新窗口預覽',
copySourceFilePreviewLink: '複製源文件預覽連結',
viewGenerationInfo: '檢視生成信息(提示等)',
sendToTxt2img: '发送到文生圖',
sendToTxt2img: '發送到文生圖',
sendToImg2img: '發送到圖生圖',
sendToInpaint: '發送到局部重繪',
sendToControlNet: '發送到ControlNet',
Expand Down
112 changes: 57 additions & 55 deletions vue/src/page/SplitViewTab/extraPathControlFunc.ts
Original file line number Diff line number Diff line change
@@ -1,83 +1,85 @@

import { ExtraPathType, addExtraPath, aliasExtraPath, removeExtraPath } from '@/api/db'
import { globalEvents } from '@/util'
import { Input, Modal, RadioButton, RadioGroup, message } from 'ant-design-vue'
import { Input, Modal, RadioButton, RadioGroup, message, Button } from 'ant-design-vue'
import { open } from '@tauri-apps/api/dialog'
import { checkPathExists } from '@/api'
import { h, ref } from 'vue'
import { t } from '@/i18n'
import { useGlobalStore } from '@/store/useGlobalStore'
import { isTauri } from '@/util/env'



export const addToExtraPath = async (initType: ExtraPathType, initPath?: string) => {
const g = useGlobalStore()
let path: string = initPath ?? ''
const path = ref(initPath ?? '')

const type = ref(initType)
if (import.meta.env.TAURI_ARCH) {
const openToSelectPath = async () => {
const ret = await open({ directory: true, defaultPath: initPath })
if (typeof ret === 'string') {
path = ret
path.value = ret
} else {
return
}
} else {
path = await new Promise<string>((resolve) => {
const key = ref(path)
console.log('dfd', key.value)
Modal.confirm({
title: t('inputTargetFolderPath'),
width: '800px',
content: () => {
return h('div', [
g.conf?.enable_access_control ? h('a', {
style: {
'word-break': 'break-all',
'margin-bottom': '4px',
display: 'block'
},
target: '_blank',
href: 'https://github.com/zanllp/sd-webui-infinite-image-browsing/issues/518'
}, 'Please open this link first (Access Control mode only)') : '',
h(Input, {
value: key.value,
'onUpdate:value': (v: string) => (key.value = v)
}),
h('div', [
h('span', t('type')+': '),
h(RadioGroup, {
value: type.value,
'onUpdate:value': (v: ExtraPathType) => (type.value = v),
buttonStyle: 'solid',
style: { margin: '16px 0 32px' }
}, [
h(RadioButton, { value: 'walk' }, 'Walk'),
h(RadioButton, { value: 'scanned' }, 'Normal'),
h(RadioButton, { value: 'scanned-fixed' }, 'Fixed')
])
]),
h('p', 'Walk: '+ t('walkModeDoc')),
h('p', 'Normal: '+ t('normalModelDoc')),
h('p', 'Fixed: '+ t('fixedModeDoc'))
])
},
async onOk () {
const path = key.value
const res = await checkPathExists([path])
if (res[path]) {
resolve(key.value)
} else {
message.error(t('pathDoesNotExist'))
}
}
path.value = await new Promise<string>((resolve) => {
Modal.confirm({
title: t('inputTargetFolderPath'),
width: '800px',
content: () => {
return h('div', [
g.conf?.enable_access_control ? h('a', {
style: {
'word-break': 'break-all',
'margin-bottom': '4px',
display: 'block'
},
target: '_blank',
href: 'https://github.com/zanllp/sd-webui-infinite-image-browsing/issues/518'
}, 'Please open this link first (Access Control mode only)') : '',
isTauri ? h(Button, { onClick: openToSelectPath, style: { margin: '4px 0' } } , t('selectFolder') ): '',
h(Input, {
value: path.value,
'onUpdate:value': (v: string) => (path.value = v)
}),
h('div', [
h('span', t('type')+': '),
h(RadioGroup, {
value: type.value,
'onUpdate:value': (v: ExtraPathType) => (type.value = v),
buttonStyle: 'solid',
style: { margin: '16px 0 32px' }
}, [
h(RadioButton, { value: 'walk' }, 'Walk'),
h(RadioButton, { value: 'scanned' }, 'Normal'),
h(RadioButton, { value: 'scanned-fixed' }, 'Fixed')
])
]),
h('p', 'Walk: '+ t('walkModeDoc')),
h('p', 'Normal: '+ t('normalModelDoc')),
h('p', 'Fixed: '+ t('fixedModeDoc'))
])
},
async onOk () {
if (!path.value) {
message.error(t('pathIsEmpty'))
throw new Error('pathIsEmpty')
}
const res = await checkPathExists([path.value])
if (res[path.value]) {
resolve(path.value)
} else {
message.error(t('pathDoesNotExist'))
}
})
}
})
}
})
Modal.confirm({
content: t('confirmToAddToExtraPath'),
async onOk () {
await addExtraPath({ types: [type.value], path })
await addExtraPath({ types: [type.value], path: path.value })
message.success(t('addCompleted'))
globalEvents.emit('searchIndexExpired')
globalEvents.emit('updateGlobalSetting')
Expand Down

0 comments on commit 85caca9

Please sign in to comment.