Skip to content

Commit

Permalink
fix: 版本号问题 (#1638)
Browse files Browse the repository at this point in the history
* fix: 版本号问题

* feat: 去掉v匹配版本更新

* feat: 去掉v匹配版本更新
  • Loading branch information
song-xiao-lin authored May 10, 2024
1 parent 21b6d68 commit 8d5c79b
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 22 deletions.
46 changes: 31 additions & 15 deletions app/renderer/src/main/src/components/layout/FuncDomain.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1115,6 +1115,7 @@ interface UIOpUpdateProps {
role?: string | null
updateContent?: string
onUpdateEdit?: (type: "yakit" | "yaklang", isEnterprise?: boolean) => any
removePrefixV: (version: string) => string
}

/** @name Yakit版本 */
Expand All @@ -1128,10 +1129,11 @@ const UIOpUpdateYakit: React.FC<UIOpUpdateProps> = React.memo((props) => {
isEnterprise,
role,
updateContent = "",
onUpdateEdit
onUpdateEdit,
removePrefixV
} = props

const isUpdate = isSimple ? false : lastVersion !== "" && lastVersion !== version
const isUpdate = isSimple ? false : lastVersion !== "" && removePrefixV(lastVersion) !== removePrefixV(version)

const content: string[] = useMemo(() => {
if (updateContent) {
Expand Down Expand Up @@ -1224,11 +1226,12 @@ const UIOpUpdateYaklang: React.FC<UIOpUpdateProps> = React.memo((props) => {
onDownload,
role,
updateContent = "",
onUpdateEdit
onUpdateEdit,
removePrefixV
} = props

const isUpdate = lastVersion !== "" && lastVersion !== version && localVersion !== lastVersion
const isKillEngine = localVersion && localVersion !== version && localVersion === lastVersion
const isUpdate = lastVersion !== "" && removePrefixV(lastVersion) !== removePrefixV(version) && removePrefixV(localVersion) !== removePrefixV(lastVersion)
const isKillEngine = localVersion && removePrefixV(localVersion) !== removePrefixV(version) && removePrefixV(localVersion) === removePrefixV(lastVersion)

const content: string[] = useMemo(() => {
if (updateContent) {
Expand Down Expand Up @@ -1438,22 +1441,32 @@ const UIOpNotice: React.FC<UIOpNoticeProp> = React.memo((props) => {
version: "",
content: ""
})

const removePrefixV = (version: string) => {
return version.startsWith('v') ? version.slice(1) : version
}
const companyYakit: string = useMemo(() => {
if (!yakitLastVersion) return ""
if (yakitLastVersion !== companyYakitContent.version) return ""
if (yakitLastVersion === companyYakitContent.version) return companyYakitContent.content
const lastVersion = removePrefixV(yakitLastVersion)
const contentVersion = removePrefixV(companyYakitContent.version)
if (lastVersion !== contentVersion) return ""
if (lastVersion === contentVersion) return companyYakitContent.content
return ""
}, [yakitLastVersion, companyYakitContent])
const communityYakit: string = useMemo(() => {
if (!yakitLastVersion) return ""
if (yakitLastVersion !== communityYakitContent.version) return ""
if (yakitLastVersion === communityYakitContent.version) return communityYakitContent.content
const lastVersion = removePrefixV(yakitLastVersion)
const contentVersion = removePrefixV(communityYakitContent.version)
if (lastVersion !== contentVersion) return ""
if (lastVersion === contentVersion) return communityYakitContent.content
return ""
}, [yakitLastVersion, communityYakitContent])
const communityYaklang: string = useMemo(() => {
if (!yaklangLastVersion) return ""
if (yaklangLastVersion !== communityYaklangContent.version) return ""
if (yaklangLastVersion === communityYaklangContent.version) return communityYaklangContent.content
const lastVersion = removePrefixV(yaklangLastVersion)
const contentVersion = removePrefixV(communityYaklangContent.version)
if (lastVersion !== contentVersion) return ""
if (lastVersion === contentVersion) return communityYaklangContent.content
return ""
}, [yaklangLastVersion, communityYaklangContent])

Expand Down Expand Up @@ -1544,7 +1557,7 @@ const UIOpNotice: React.FC<UIOpNoticeProp> = React.memo((props) => {
ipcRenderer
.invoke("fetch-latest-yaklang-version")
.then((data: string) => {
if (yaklangVersion !== data) setYaklangLastVersion(data)
if (yaklangVersion !== data) setYaklangLastVersion(data.startsWith('v') ? data.slice(1) : data)
})
.catch((err) => {
setYaklangLastVersion("")
Expand Down Expand Up @@ -1741,6 +1754,7 @@ const UIOpNotice: React.FC<UIOpNoticeProp> = React.memo((props) => {
role={userInfo.role}
updateContent={isCommunityEdition() ? companyYakit : communityYakit}
onUpdateEdit={UpdateContentEdit}
removePrefixV={removePrefixV}
/>
)}
{!isEnpriTraceAgent() && (
Expand All @@ -1753,6 +1767,7 @@ const UIOpNotice: React.FC<UIOpNoticeProp> = React.memo((props) => {
role={userInfo.role}
updateContent={isEnterpriseEdition() ? companyYakit : communityYakit}
onUpdateEdit={UpdateContentEdit}
removePrefixV={removePrefixV}
/>
)}
<UIOpUpdateYaklang
Expand All @@ -1765,6 +1780,7 @@ const UIOpNotice: React.FC<UIOpNoticeProp> = React.memo((props) => {
role={userInfo.role}
updateContent={communityYaklang}
onUpdateEdit={UpdateContentEdit}
removePrefixV={removePrefixV}
/>
</div>
<div className={styles["history-version"]}>
Expand Down Expand Up @@ -1811,9 +1827,9 @@ const UIOpNotice: React.FC<UIOpNoticeProp> = React.memo((props) => {

const isUpdate = useMemo(() => {
return isEnpriTraceAgent()
? yaklangLastVersion !== "" && yaklangLastVersion !== yaklangVersion
: (yakitLastVersion !== "" && yakitLastVersion !== yakitVersion) ||
(yaklangLastVersion !== "" && yaklangLastVersion !== yaklangVersion)
? yaklangLastVersion !== "" && removePrefixV(yaklangLastVersion) !== removePrefixV(yaklangVersion)
: (yakitLastVersion !== "" && removePrefixV(yakitLastVersion) !== removePrefixV(yakitVersion)) ||
(yaklangLastVersion !== "" && removePrefixV(yaklangLastVersion) !== removePrefixV(yaklangVersion))
}, [yakitVersion, yakitLastVersion, yaklangLastVersion, yaklangVersion])

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ export const LocalEngine: React.FC<LocalEngineProps> = memo(
.invoke("fetch-latest-yaklang-version")
.then((data: string) => {
if (preventUpdateHint.current) return
setLatestYaklang(data || "")
setLatestYaklang(data.startsWith('v') ? data.slice(1) : data)
})
.catch((err) => {})
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,22 @@ export const UpdateYakitAndYaklang: React.FC<UpdateYakitAndYaklangProps> = React
version: "",
content: ""
})

const removePrefixV = (version: string) => {
return version.startsWith('v') ? version.slice(1) : version
}

const yakitContent: string[] = useMemo(() => {
if (!yakitUpdateContent.content) return []
if (yakitUpdateContent.version !== latestYakit) return []
if (removePrefixV(yakitUpdateContent.version) !== removePrefixV(latestYakit)) return []
if (yakitUpdateContent.content) {
return yakitUpdateContent.content.split("\n")
}
return []
}, [yakitUpdateContent])
const yaklangContent: string[] = useMemo(() => {
if (!yaklangUpdateContent.content) return []
if (yaklangUpdateContent.version !== latestYaklang) return []
if (removePrefixV(yaklangUpdateContent.version) !== removePrefixV(latestYaklang)) return []
if (yaklangUpdateContent.content) {
return yaklangUpdateContent.content.split("\n")
}
Expand All @@ -90,7 +95,7 @@ export const UpdateYakitAndYaklang: React.FC<UpdateYakitAndYaklangProps> = React
if (!res) return
try {
const data: UpdateContentProp = JSON.parse(res)
if (data.version !== latestYakit) return
if (removePrefixV(data.version) !== removePrefixV(latestYakit)) return
setYakitUpdateContent({...data})
} catch (error) {}
})
Expand All @@ -110,7 +115,7 @@ export const UpdateYakitAndYaklang: React.FC<UpdateYakitAndYaklangProps> = React
if (!res) return
try {
const data: UpdateContentProp = JSON.parse(res)
if (data.version !== latestYaklang) return
if (removePrefixV(data.version) !== removePrefixV(latestYaklang)) return
setYaklangUpdateContent({...data})
} catch (error) {}
})
Expand Down Expand Up @@ -144,13 +149,13 @@ export const UpdateYakitAndYaklang: React.FC<UpdateYakitAndYaklangProps> = React
const isShowYakit = useMemo(() => {
if (!isShow) return false
if (!currentYakit || !latestYakit) return false
if (`v${currentYakit}` !== latestYakit) return true
if (removePrefixV(currentYakit) !== removePrefixV(latestYakit)) return true
return false
}, [currentYakit, latestYakit, isShow])
const isShowYaklang = useMemo(() => {
if (!isShow) return false
if (!currentYaklang || !latestYaklang) return false
if (currentYaklang !== latestYaklang) return true
if (removePrefixV(currentYaklang) !== removePrefixV(latestYaklang)) return true
return false
}, [currentYaklang, latestYaklang, isShow])

Expand Down

0 comments on commit 8d5c79b

Please sign in to comment.