Skip to content

Commit

Permalink
feat: add About.vue (#572)
Browse files Browse the repository at this point in the history
  • Loading branch information
GuoHao authored Jun 16, 2024
1 parent 95fa5e9 commit 0b388aa
Showing 15 changed files with 232 additions and 26 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.MD
Original file line number Diff line number Diff line change
@@ -10,6 +10,7 @@
- 完善多语言翻译 #548
- 添加匹配移除条目剧集附件绑定 #554
- JWT令牌认证支持 #560
- 后台添加关于页展示应用信息 #552

## 插件

6 changes: 3 additions & 3 deletions console/src/components/upload/AttachmentPondUpload.vue
Original file line number Diff line number Diff line change
@@ -82,20 +82,20 @@ const server = computed({
process: {
url: './api/v1alpha1/attachment/fragment/unique',
withCredentials: true,
headers: {'Authorization':'Bearer ' + userStore.jwtToken},
headers: {Authorization: 'Bearer ' + userStore.jwtToken},
},
patch: {
url: './api/v1alpha1/attachment/fragment/patch/',
withCredentials: true,
headers: {
'PARENT-ID': reqHeaderParendId.value,
'Authorization':'Bearer ' + userStore.jwtToken
Authorization: 'Bearer ' + userStore.jwtToken,
},
},
revert: {
url: './api/v1alpha1/attachment/fragment/revert',
withCredentials: true,
headers: {'Authorization':'Bearer ' + userStore.jwtToken},
headers: {Authorization: 'Bearer ' + userStore.jwtToken},
},
};
},
2 changes: 1 addition & 1 deletion console/src/components/upload/UppyUpload.vue
Original file line number Diff line number Diff line change
@@ -66,7 +66,7 @@ const uppy = computed(() => {
}).use(XHRUpload, {
endpoint: `${import.meta.env.VITE_API_URL}${props.endpoint}`,
allowedMetaFields: props.allowedMetaFields,
headers: {'Authorization':'Bearer ' + userStore.jwtToken},
headers: {Authorization: 'Bearer ' + userStore.jwtToken},
withCredentials: true,
formData: true,
fieldName: props.name,
3 changes: 3 additions & 0 deletions console/src/locales/en.yaml
Original file line number Diff line number Diff line change
@@ -947,6 +947,9 @@ module:
password: SMTP Password
alias: SMTP Account Alias
receive-address: Recive Mail Address
about:
title: About
sidebar: About
login:
operations:
submit:
3 changes: 3 additions & 0 deletions console/src/locales/zh-CN.yaml
Original file line number Diff line number Diff line change
@@ -910,6 +910,9 @@ module:
required: 请输入邮件服务密码
mail-receive-address:
required: 请输入收件方邮件地址
about:
title: 关于
sidebar: 关于
login:
operations:
submit:
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
<script setup lang="ts">
import {computed, ref} from 'vue';
import {ElButton, ElDialog, ElForm, ElFormItem, ElInput, ElMessage, ElOption, ElSelect,} from 'element-plus';
import {
ElButton,
ElDialog,
ElForm,
ElFormItem,
ElInput,
ElMessage,
ElOption,
ElSelect,
} from 'element-plus';
import {Tickets} from '@element-plus/icons-vue';
import SubjectSelectDrawer from './SubjectSelectDrawer.vue';
import {apiClient} from '@/utils/api-client';
6 changes: 4 additions & 2 deletions console/src/modules/content/subject/SubjectSelectDrawer.vue
Original file line number Diff line number Diff line change
@@ -88,8 +88,10 @@ const fetchSubjects = async () => {
findSubjectsCondition.value.total = data.total;
subjects.value = data.items as Subject[];
if (props.filter && props.filter.length > 0) {
console.debug('props.filter', props.filter)
subjects.value = subjects.value.filter(sub => sub.id && sub.id > 0 && props.filter.indexOf(sub.id) < 0)
console.debug('props.filter', props.filter);
subjects.value = subjects.value.filter(
(sub) => sub.id && sub.id > 0 && props.filter.indexOf(sub.id) < 0
);
}
};
2 changes: 2 additions & 0 deletions console/src/modules/index.ts
Original file line number Diff line number Diff line change
@@ -4,6 +4,7 @@ import Attachment from './content/attachment/module';
import Subject from './content/subject/module';
import Plugin from './system/plugin/module';
import Setting from './system/setting/module';
import About from './system/about/module';
// import Tasks from './system/task/module';

const coreModules = [
@@ -13,6 +14,7 @@ const coreModules = [
Subject,
Plugin,
Setting,
About,
// Tasks,
];

161 changes: 161 additions & 0 deletions console/src/modules/system/about/About.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
<script setup lang="ts">
import {apiClient} from '@/utils/api-client';
import {formatDate} from '@/utils/date';
import {ElDescriptionsItem, ElDescriptions, ElImage} from 'element-plus';
import {onMounted, ref} from 'vue';
const actuatorInfo = ref();
const fetchActuatorInfo = async () => {
const {data} = await apiClient.actuator.info();
actuatorInfo.value = data;
};
const airTimeDateFormatter = (time) => {
// console.log('row', row);
return formatDate(new Date(time), 'yyyy-MM-dd');
};
onMounted(fetchActuatorInfo);
</script>
<template>
<!-- Basic -->
<el-descriptions
class="margin-top"
title="Basic"
:column="3"
size="large"
border
>
<!-- git -->
<el-descriptions-item>
<template #label> Git Branch</template>
{{ actuatorInfo?.git.branch }}
</el-descriptions-item>
<el-descriptions-item>
<template #label> Git Commit</template>
{{ actuatorInfo?.git.commit.id }}
</el-descriptions-item>
<el-descriptions-item>
<template #label> Commit Time</template>

{{ airTimeDateFormatter(actuatorInfo?.git.commit.time) }}
</el-descriptions-item>

<!-- build -->
<el-descriptions-item>
<template #label> Build Version</template>
{{ actuatorInfo?.build.version }}
</el-descriptions-item>
<el-descriptions-item>
<template #label> Build Name</template>
{{ actuatorInfo?.build.name }}
</el-descriptions-item>
<el-descriptions-item>
<template #label> Build Time</template>
{{ airTimeDateFormatter(actuatorInfo?.build.time) }}
</el-descriptions-item>

<!-- os -->
<el-descriptions-item>
<template #label> OS Name</template>
{{ actuatorInfo?.os.name }}
</el-descriptions-item>
<el-descriptions-item>
<template #label> OS Version</template>
{{ actuatorInfo?.os.version }}
</el-descriptions-item>
<el-descriptions-item>
<template #label> OS Arch</template>
{{ actuatorInfo?.os.arch }}
</el-descriptions-item>
</el-descriptions>

<br/>

<!-- Jave -->
<el-descriptions
class="margin-top"
title="Java"
:column="3"
size="large"
border
>
<!-- version -->
<el-descriptions-item>
<template #label> Java Version</template>
{{ actuatorInfo?.java.version }}
</el-descriptions-item>
<el-descriptions-item>
<template #label> Vendor Name</template>
{{ actuatorInfo?.java.vendor.name }}
</el-descriptions-item>
<el-descriptions-item>
<template #label> Vendor Version</template>
{{ actuatorInfo?.java.vendor.version }}
</el-descriptions-item>

<!-- runtime -->
<el-descriptions-item>
<template #label> Runtime Name</template>
{{ actuatorInfo?.java.runtime.name }}
</el-descriptions-item>
<el-descriptions-item :span="2">
<template #label> Runtime Version</template>
{{ actuatorInfo?.java.runtime.version }}
</el-descriptions-item>

<!-- jvm -->
<el-descriptions-item>
<template #label> JVM Name</template>
{{ actuatorInfo?.java.jvm.name }}
</el-descriptions-item>
<el-descriptions-item>
<template #label> JVM Vendor</template>
{{ actuatorInfo?.java.jvm.vendor }}
</el-descriptions-item>
<el-descriptions-item>
<template #label> JVM Version</template>
{{ actuatorInfo?.java.jvm.version }}
</el-descriptions-item>
</el-descriptions>

<br/>

<!-- Introduce -->
<el-descriptions
class="margin-top"
title="Ikaros Project"
:column="1"
size="large"
direction="vertical"
border
>
<el-descriptions-item>
<template #label> Offical</template>
<a href="https://ikaros.run" target="_blank">https://ikaros.run</a>
</el-descriptions-item>
<el-descriptions-item>
<template #label> GitHub</template>
<a href="https://github.com/ikaros-dev/ikaros" target="_blank"
>https://github.com/ikaros-dev/ikaros</a
>
</el-descriptions-item>
<el-descriptions-item>
<template #label> Contributors</template>
<el-image
style="width: 100%; height: 100%"
src="https://contrib.nn.ci/api?repo=ikaros-dev/ikaros&repo=ikaros-dev/docs&repo=ikaros-dev/app"
fit="fill"
/>
</el-descriptions-item>
<el-descriptions-item>
<template #label> Status</template>
<el-image
style="width: 100%; height: 100%"
src="https://repobeats.axiom.co/api/embed/f7285853048ff09f313f6483901e2af0e638f666.svg"
fit="fill"
/>
</el-descriptions-item>
</el-descriptions>
</template>
<style lang="scss" scoped></style>
28 changes: 28 additions & 0 deletions console/src/modules/system/about/module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import {definePlugin} from '@runikaros/shared';
import {markRaw} from 'vue';
import {Ship} from '@element-plus/icons-vue';
import About from './About.vue';

export default definePlugin({
name: 'SystemAbout',
components: {},
routes: [
{
parentName: 'Root',
route: {
path: '/about',
name: 'About',
component: About,
meta: {
title: 'module.about.title',
menu: {
name: 'module.about.sidebar',
group: 'system',
icon: markRaw(Ship),
priority: 0,
},
},
},
},
],
});
2 changes: 0 additions & 2 deletions console/src/modules/user/Login.vue
Original file line number Diff line number Diff line change
@@ -58,7 +58,6 @@ const handleLogin = async () => {
await userStore.applyJwtToken(form.value.username, form.value.password);
// Reload page
// if (route.query.redirect_uri) {
// window.location.reload();
@@ -68,7 +67,6 @@ const handleLogin = async () => {
if (!userStore.isAnonymous) {
window.location.reload();
}
} catch (e: unknown) {
console.error('Failed to login', e);
1 change: 0 additions & 1 deletion console/src/router/guards/auth-check.ts
Original file line number Diff line number Diff line change
@@ -19,7 +19,6 @@ export function setupAuthCheckGuard(router: Router) {
next();
return;
}


next({
name: 'Login',
22 changes: 11 additions & 11 deletions console/src/stores/user.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { defineStore } from 'pinia';

import type { User } from '@runikaros/api-client';
import {JwtApplyParamAuthTypeEnum} from '@runikaros/api-client'
import {JwtApplyParamAuthTypeEnum} from '@runikaros/api-client';
import { apiClient, setApiClientJwtToken } from '@/utils/api-client';

interface UserStoreState {
authType: JwtApplyParamAuthTypeEnum,
authType: JwtApplyParamAuthTypeEnum;
currentUser?: User;
isAnonymous: boolean;
jwtToken?:string;
jwtToken?: string;
}

export const useUserStore = defineStore('user', {
@@ -32,29 +32,29 @@ export const useUserStore = defineStore('user', {
} else {
this.jwtToken = undefined;
this.isAnonymous = true;
}
}
} catch (e) {
console.error('Failed to fetch current user', e);
this.isAnonymous = true;
this.jwtToken = undefined;
}
},
async applyJwtToken(username:string, password:string) {
async applyJwtToken(username: string, password: string) {
try {
const {data, status} = await apiClient.security.applyJwtToken({
const {data, status} = await apiClient.security.applyJwtToken({
jwtApplyParam: {
authType: 'USERNAME_PASSWORD',
username: username,
password: password
}
})
password: password,
},
});
if (status === 200) {
this.jwtToken = data;
this.isAnonymous = false;
} else {
this.jwtToken = undefined;
this.isAnonymous = true;
}
}
} catch (e) {
console.error('Failed to apply jwt token', e);
this.isAnonymous = true;
@@ -64,7 +64,7 @@ export const useUserStore = defineStore('user', {
this.jwtToken = undefined;
this.isAnonymous = true;
this.currentUser = undefined;
}
},
},
persist: {
enabled: true,
6 changes: 3 additions & 3 deletions console/src/utils/api-client.ts
Original file line number Diff line number Diff line change
@@ -200,10 +200,10 @@ function setupApiClient(axios: AxiosInstance) {
};
}

const setApiClientJwtToken = (token:string) => {
const setApiClientJwtToken = (token: string) => {
// console.debug('setJwtToken', token)
if (!token) return;
axiosInstance.defaults.headers.common['Authorization'] = 'Bearer ' + token;
}
};

export { apiClient,setApiClientJwtToken};
export {apiClient, setApiClientJwtToken};
Loading

0 comments on commit 0b388aa

Please sign in to comment.