Skip to content

Commit

Permalink
修复:模型多版本显示问题
Browse files Browse the repository at this point in the history
  • Loading branch information
modstart committed Oct 22, 2024
1 parent 26ba277 commit b8503ee
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/components/Server/ServerActionDelete.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const emit = defineEmits({
const doDelete = async () => {
const record = props.record
await Dialog.confirm(t('确定删除模型 {title} 吗?', {title: record.title}))
await Dialog.confirm(t('确定删除模型 {title} v{version} 吗?', {title: record.title, version: record.version}))
Dialog.loadingOn(t('正在删除'))
await sleep(500)
await serverStore.delete(record)
Expand Down
6 changes: 4 additions & 2 deletions src/components/Server/ServerImportLocalDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,12 @@ const doSubmit = async () => {
isImporting.value = true
logStatus.value = t('正在解压文件')
try {
// console.log('unzip.start', modelInfo.value.path, target)
await window.$mapi.misc.unzip(modelInfo.value.path, target, {
process: (type: string, file: any) => {
switch (type) {
case 'start':
// logAppend(t('正在解压 {name}', {name: file.fileName}))
logStatus.value = t('正在解压 {name}', {name: file.fileName})
break
case 'end':
break
Expand All @@ -77,6 +78,7 @@ const doSubmit = async () => {
}
},
})
// console.log('unzip.end', modelInfo.value.path, target)
// console.log('entry', modelInfo.value.entry)
if (modelInfo.value.entry) {
const executable = target + '/' + modelInfo.value.entry
Expand Down Expand Up @@ -210,7 +212,7 @@ const emit = defineEmits({
{{ $t('重新选择') }}
</a-button>
</div>
<div class="flex-grow pl-3">
<div class="flex-grow pl-3 text-sm truncate">
{{ logStatus }}
</div>
</div>
Expand Down
1 change: 1 addition & 0 deletions src/lang/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
"02261f68": "Cross language",
"02286f86": "Connecting",
"022cab31": "Running",
"03537548": "确定删除模型 {title} v{version} 吗?",
"041806bc": "GPU Priority",
"041b5a9a": "GPU Mode",
"04e64feb": "USB Connection",
Expand Down
1 change: 1 addition & 0 deletions src/lang/source.json
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@
"直接退出": "379a84eb",
"相同的种子可以确保每次生成结果数据一致": "5232d376",
"确定": "000ef0ec",
"确定删除模型 {title} v{version} 吗?": "03537548",
"确定删除模型 {title} 吗?": "702bab32",
"确定裁剪": "382747b5",
"确定退出软件?": "0b2004f2",
Expand Down
1 change: 1 addition & 0 deletions src/lang/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
"02261f68": "跨语种",
"02286f86": "连接中",
"022cab31": "运行中",
"03537548": "确定删除模型 {title} v{version} 吗?",
"041806bc": "GPU优先",
"041b5a9a": "GPU模式",
"04e64feb": "USB连接",
Expand Down
3 changes: 3 additions & 0 deletions src/pages/Server.vue
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,9 @@ const typeName = (type: string) => {
</div>
<div class="inline-block mr-4">
{{ record.title }}
<div class="inline-block rounded-3xl bg-gray-100 px-3">
v{{ record.version }}
</div>
</div>
</div>
<div>
Expand Down
11 changes: 7 additions & 4 deletions src/store/modules/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export const serverStore = defineStore("server", {
}
let changed = false
for (let lr of localRecords) {
const record = this.records.find((record) => record.name === lr.name)
const record = this.records.find((record) => record.key === lr.key)
if (!record) {
lr.status = createServerStatus(lr)
lr.runtime = createServerRuntime(lr)
Expand All @@ -99,8 +99,11 @@ export const serverStore = defineStore("server", {
await this.sync()
}
},
findRecord(server: ServerRecord) {
return this.records.find((record) => record.key = server.key)
},
async start(server: ServerRecord) {
const record = this.records.find((record) => record.name === server.name)
const record = this.findRecord(server)
if (record?.status === EnumServerStatus.STOPPED || record?.status === EnumServerStatus.ERROR) {
} else {
throw new Error('StatusError')
Expand Down Expand Up @@ -163,7 +166,7 @@ export const serverStore = defineStore("server", {
serverRuntime.pingCheckTimer = setTimeout(pingCheck, 10 * 1000)
},
async stop(server: ServerRecord) {
const record = this.records.find((record) => record.name === server.name)
const record = this.findRecord(server)
if (record?.status === EnumServerStatus.RUNNING) {
} else {
throw new Error('StatusError')
Expand All @@ -188,7 +191,7 @@ export const serverStore = defineStore("server", {
await this.sync()
},
async delete(server: ServerRecord) {
const index = this.records.findIndex((record) => record.name === server.name)
const index = this.records.findIndex((record) => record.key === server.key)
if (index === -1) {
return
}
Expand Down

0 comments on commit b8503ee

Please sign in to comment.