feat: use commit time as version id

This commit is contained in:
Yidadaa
2023-05-04 00:12:00 +08:00
parent 074bd9f045
commit fce3b3ce7b
3 changed files with 30 additions and 12 deletions

View File

@@ -183,6 +183,19 @@ function UserPromptModal(props: { onClose?: () => void }) {
);
}
function formatVersionDate(t: string) {
const d = new Date(+t);
const year = d.getUTCFullYear();
const month = d.getUTCMonth() + 1;
const day = d.getUTCDate();
return [
year.toString(),
month.toString().padStart(2, "0"),
day.toString().padStart(2, "0"),
].join("");
}
export function Settings() {
const navigate = useNavigate();
const [showEmojiPicker, setShowEmojiPicker] = useState(false);
@@ -193,8 +206,8 @@ export function Settings() {
const updateStore = useUpdateStore();
const [checkingUpdate, setCheckingUpdate] = useState(false);
const currentVersion = updateStore.version;
const remoteId = updateStore.remoteVersion;
const currentVersion = formatVersionDate(updateStore.version);
const remoteId = formatVersionDate(updateStore.remoteVersion);
const hasNewVersion = currentVersion !== remoteId;
function checkUpdate(force = false) {
@@ -202,6 +215,15 @@ export function Settings() {
updateStore.getLatestVersion(force).then(() => {
setCheckingUpdate(false);
});
console.log(
"[Update] local version ",
new Date(+updateStore.version).toLocaleString(),
);
console.log(
"[Update] remote version ",
new Date(+updateStore.remoteVersion).toLocaleString(),
);
}
const usage = {