Browse Source

version page

master
OhYee 2 years ago
parent
commit
18b38e60fc
Signed by: OhYee
GPG Key ID: 5A9E1F63ED274FBB
  1. 1
      next.config.js
  2. 35
      pages/version.tsx
  3. 6
      utils/api.ts
  4. 7
      utils/global.ts

1
next.config.js

@ -6,5 +6,6 @@ module.exports = { @@ -6,5 +6,6 @@ module.exports = {
},
publicRuntimeConfig: {
//这里的配置既可以服务端获取到,也可以在浏览器端获取到
version: Date.now(),
},
};

35
pages/version.tsx

@ -0,0 +1,35 @@ @@ -0,0 +1,35 @@
import React, { ComponentProps } from 'react';
import Head from 'next/head';
import getConfig from 'next/config';
import Card from '@/components/card';
import { Flex } from '@/components/container';
import { Context } from '@/utils/global';
class Version extends React.Component<{}, { version: string }> {
render() {
return (
<Context.Consumer>
{(context) => (
<Card neumorphism>
<Head>
<title>{`版本信息|${context.blog_name}`}</title>
</Head>
<Flex direction="TB" fullWidth>
<p>
<b></b> {context.front_version}
</p>
<p>
<b></b> {context.back_version}
</p>
</Flex>
</Card>
)}
</Context.Consumer>
);
}
}
export default Version;

6
utils/api.ts

@ -473,3 +473,9 @@ export const qiniu_rename_image = async ( @@ -473,3 +473,9 @@ export const qiniu_rename_image = async (
) => {
return await request('get', '/api/qiniu/image/rename', { bucket, key, new_key }, callback);
};
export const version = async (
callback?: RequestCallback<{version:string}>,
) => {
return await request('get', '/api/version', {}, callback);
};

7
utils/global.ts

@ -1,4 +1,7 @@ @@ -1,4 +1,7 @@
import React from 'react';
import getConfig from 'next/config';
import { formatDate } from './time';
export const defaultContext: GlobalProps = {
callback: () => {},
@ -22,6 +25,8 @@ export const defaultContext: GlobalProps = { @@ -22,6 +25,8 @@ export const defaultContext: GlobalProps = {
ad_show: '',
ad_inner: '',
ad_text: '',
front_version: formatDate(getConfig().publicRuntimeConfig.version),
back_version: 'UNKNOWN',
user: {
id: '000000000000000000000000',
username: '',
@ -67,6 +72,8 @@ export declare interface GlobalProps { @@ -67,6 +72,8 @@ export declare interface GlobalProps {
ad_show: string;
ad_inner: string;
ad_text: string;
front_version: string;
back_version: string;
}
export function getTimeTheme() {

Loading…
Cancel
Save