Merge branch 'feature/refactor' of github.com:AUTO-MAS-Project/AUTO-MAS into feature/refactor
This commit is contained in:
@@ -14,6 +14,9 @@ import { useSettingsApi } from '../composables/useSettingsApi'
|
|||||||
import type { SelectValue } from 'ant-design-vue/es/select'
|
import type { SelectValue } from 'ant-design-vue/es/select'
|
||||||
import type { SettingsData } from '../types/settings'
|
import type { SettingsData } from '../types/settings'
|
||||||
import { Service, type VersionOut } from '@/api'
|
import { Service, type VersionOut } from '@/api'
|
||||||
|
import UpdateModal from '@/components/UpdateModal.vue'
|
||||||
|
|
||||||
|
const updateData = ref<Record<string, string[]>>({})
|
||||||
|
|
||||||
const app_version = import.meta.env.VITE_APP_VERSION || '获取版本失败!'
|
const app_version = import.meta.env.VITE_APP_VERSION || '获取版本失败!'
|
||||||
|
|
||||||
@@ -21,6 +24,8 @@ const router = useRouter()
|
|||||||
const { themeMode, themeColor, themeColors, setThemeMode, setThemeColor } = useTheme()
|
const { themeMode, themeColor, themeColors, setThemeMode, setThemeColor } = useTheme()
|
||||||
const { loading, getSettings, updateSettings } = useSettingsApi()
|
const { loading, getSettings, updateSettings } = useSettingsApi()
|
||||||
|
|
||||||
|
const updateVisible = ref(false)
|
||||||
|
|
||||||
const activeKey = ref('basic')
|
const activeKey = ref('basic')
|
||||||
|
|
||||||
const backendUpdateInfo = ref<VersionOut | null>(null)
|
const backendUpdateInfo = ref<VersionOut | null>(null)
|
||||||
@@ -210,6 +215,34 @@ const openDevTools = () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const version = import.meta.env.VITE_APP_VERSION || '获取版本失败!'
|
||||||
|
|
||||||
|
const checkUpdate = async () => {
|
||||||
|
try {
|
||||||
|
const response = await Service.checkUpdateApiUpdateCheckPost({
|
||||||
|
current_version: version,
|
||||||
|
})
|
||||||
|
if (response.code === 200) {
|
||||||
|
if (response.if_need_update) {
|
||||||
|
updateData.value = response.update_info
|
||||||
|
updateVisible.value = true
|
||||||
|
} else {
|
||||||
|
message.success("暂无更新~")
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
message.error(response.message || '获取更新失败')
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('获取更新失败:', error)
|
||||||
|
return '获取更新失败!'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 确认回调
|
||||||
|
const onUpdateConfirmed = () => {
|
||||||
|
updateVisible.value = false
|
||||||
|
}
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
loadSettings()
|
loadSettings()
|
||||||
getBackendVersion()
|
getBackendVersion()
|
||||||
@@ -1224,11 +1257,23 @@ onMounted(() => {
|
|||||||
</div>
|
</div>
|
||||||
</a-col>
|
</a-col>
|
||||||
</a-row>
|
</a-row>
|
||||||
|
<a-button
|
||||||
|
type="primary"
|
||||||
|
@click="checkUpdate"
|
||||||
|
size="large"
|
||||||
|
>检查更新</a-button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</a-tab-pane>
|
</a-tab-pane>
|
||||||
</a-tabs>
|
</a-tabs>
|
||||||
</div>
|
</div>
|
||||||
|
<!-- 更新模态框 -->
|
||||||
|
<UpdateModal
|
||||||
|
v-if="updateVisible"
|
||||||
|
v-model:visible="updateVisible"
|
||||||
|
:update-data="updateData"
|
||||||
|
@confirmed="onUpdateConfirmed"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user