mirror of
https://github.com/vbenjs/vben-admin-thin-next.git
synced 2025-02-02 18:08:40 +08:00
refactor(sys): change to setup syntax
This commit is contained in:
parent
66feb779a8
commit
bb89c5059c
@ -25,6 +25,7 @@ module.exports = defineConfig({
|
|||||||
'plugin:jest/recommended',
|
'plugin:jest/recommended',
|
||||||
],
|
],
|
||||||
rules: {
|
rules: {
|
||||||
|
'vue/script-setup-uses-vars': 'error',
|
||||||
'@typescript-eslint/ban-ts-ignore': 'off',
|
'@typescript-eslint/ban-ts-ignore': 'off',
|
||||||
'@typescript-eslint/explicit-function-return-type': 'off',
|
'@typescript-eslint/explicit-function-return-type': 'off',
|
||||||
'@typescript-eslint/no-explicit-any': 'off',
|
'@typescript-eslint/no-explicit-any': 'off',
|
||||||
@ -61,7 +62,6 @@ module.exports = defineConfig({
|
|||||||
'vue/singleline-html-element-content-newline': 'off',
|
'vue/singleline-html-element-content-newline': 'off',
|
||||||
'vue/attribute-hyphenation': 'off',
|
'vue/attribute-hyphenation': 'off',
|
||||||
'vue/require-default-prop': 'off',
|
'vue/require-default-prop': 'off',
|
||||||
'vue/script-setup-uses-vars': 'off',
|
|
||||||
'vue/html-self-closing': [
|
'vue/html-self-closing': [
|
||||||
'error',
|
'error',
|
||||||
{
|
{
|
||||||
|
17
src/App.vue
17
src/App.vue
@ -6,23 +6,14 @@
|
|||||||
</ConfigProvider>
|
</ConfigProvider>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts" setup>
|
||||||
import { defineComponent } from 'vue';
|
|
||||||
import { ConfigProvider } from 'ant-design-vue';
|
import { ConfigProvider } from 'ant-design-vue';
|
||||||
import { AppProvider } from '/@/components/Application';
|
import { AppProvider } from '/@/components/Application';
|
||||||
import { useTitle } from '/@/hooks/web/useTitle';
|
import { useTitle } from '/@/hooks/web/useTitle';
|
||||||
import { useLocale } from '/@/locales/useLocale';
|
import { useLocale } from '/@/locales/useLocale';
|
||||||
|
|
||||||
export default defineComponent({
|
// support Multi-language
|
||||||
name: 'App',
|
const { getAntdLocale } = useLocale();
|
||||||
components: { ConfigProvider, AppProvider },
|
|
||||||
setup() {
|
|
||||||
useTitle();
|
|
||||||
|
|
||||||
// support Multi-language
|
useTitle();
|
||||||
const { getAntdLocale } = useLocale();
|
|
||||||
|
|
||||||
return { getAntdLocale };
|
|
||||||
},
|
|
||||||
});
|
|
||||||
</script>
|
</script>
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
<template>
|
<template>
|
||||||
<Button v-bind="getBindValue" :class="getButtonClass" @click="onClick">
|
<Button v-bind="getBindValue" :class="getButtonClass" @click="onClick">
|
||||||
<template #default="data">
|
<template #default>
|
||||||
<Icon :icon="preIcon" v-if="preIcon" :size="iconSize" />
|
<Icon :icon="preIcon" v-if="preIcon" :size="iconSize" />
|
||||||
<slot v-bind="data"></slot>
|
<slot></slot>
|
||||||
<Icon :icon="postIcon" v-if="postIcon" :size="iconSize" />
|
<Icon :icon="postIcon" v-if="postIcon" :size="iconSize" />
|
||||||
</template>
|
</template>
|
||||||
</Button>
|
</Button>
|
||||||
|
@ -14,94 +14,85 @@
|
|||||||
<Description @register="registerDev" class="enter-y" />
|
<Description @register="registerDev" class="enter-y" />
|
||||||
</PageWrapper>
|
</PageWrapper>
|
||||||
</template>
|
</template>
|
||||||
<script lang="ts">
|
<script lang="ts" setup>
|
||||||
import { defineComponent, h } from 'vue';
|
import { h } from 'vue';
|
||||||
|
|
||||||
import { Tag } from 'ant-design-vue';
|
import { Tag } from 'ant-design-vue';
|
||||||
import { PageWrapper } from '/@/components/Page';
|
import { PageWrapper } from '/@/components/Page';
|
||||||
import { Description, DescItem, useDescription } from '/@/components/Description/index';
|
import { Description, DescItem, useDescription } from '/@/components/Description/index';
|
||||||
|
|
||||||
import { GITHUB_URL, SITE_URL, DOC_URL } from '/@/settings/siteSetting';
|
import { GITHUB_URL, SITE_URL, DOC_URL } from '/@/settings/siteSetting';
|
||||||
export default defineComponent({
|
|
||||||
name: 'AboutPage',
|
|
||||||
components: { Description, PageWrapper },
|
|
||||||
setup() {
|
|
||||||
const { pkg, lastBuildTime } = __APP_INFO__;
|
|
||||||
|
|
||||||
const { dependencies, devDependencies, name, version } = pkg;
|
const { pkg, lastBuildTime } = __APP_INFO__;
|
||||||
|
|
||||||
const schema: DescItem[] = [];
|
const { dependencies, devDependencies, name, version } = pkg;
|
||||||
const devSchema: DescItem[] = [];
|
|
||||||
|
|
||||||
const commonTagRender = (color: string) => (curVal) => h(Tag, { color }, () => curVal);
|
const schema: DescItem[] = [];
|
||||||
const commonLinkRender = (text: string) => (href) => h('a', { href, target: '_blank' }, text);
|
const devSchema: DescItem[] = [];
|
||||||
|
|
||||||
const infoSchema: DescItem[] = [
|
const commonTagRender = (color: string) => (curVal) => h(Tag, { color }, () => curVal);
|
||||||
{
|
const commonLinkRender = (text: string) => (href) => h('a', { href, target: '_blank' }, text);
|
||||||
label: '版本',
|
|
||||||
field: 'version',
|
|
||||||
render: commonTagRender('blue'),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: '最后编译时间',
|
|
||||||
field: 'lastBuildTime',
|
|
||||||
render: commonTagRender('blue'),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: '文档地址',
|
|
||||||
field: 'doc',
|
|
||||||
render: commonLinkRender('文档地址'),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: '预览地址',
|
|
||||||
field: 'preview',
|
|
||||||
render: commonLinkRender('预览地址'),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: 'Github',
|
|
||||||
field: 'github',
|
|
||||||
render: commonLinkRender('Github'),
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
const infoData = {
|
const infoSchema: DescItem[] = [
|
||||||
version,
|
{
|
||||||
lastBuildTime,
|
label: '版本',
|
||||||
doc: DOC_URL,
|
field: 'version',
|
||||||
preview: SITE_URL,
|
render: commonTagRender('blue'),
|
||||||
github: GITHUB_URL,
|
|
||||||
};
|
|
||||||
|
|
||||||
Object.keys(dependencies).forEach((key) => {
|
|
||||||
schema.push({ field: key, label: key });
|
|
||||||
});
|
|
||||||
|
|
||||||
Object.keys(devDependencies).forEach((key) => {
|
|
||||||
devSchema.push({ field: key, label: key });
|
|
||||||
});
|
|
||||||
|
|
||||||
const [register] = useDescription({
|
|
||||||
title: '生产环境依赖',
|
|
||||||
data: dependencies,
|
|
||||||
schema: schema,
|
|
||||||
column: 3,
|
|
||||||
});
|
|
||||||
|
|
||||||
const [registerDev] = useDescription({
|
|
||||||
title: '开发环境依赖',
|
|
||||||
data: devDependencies,
|
|
||||||
schema: devSchema,
|
|
||||||
column: 3,
|
|
||||||
});
|
|
||||||
|
|
||||||
const [infoRegister] = useDescription({
|
|
||||||
title: '项目信息',
|
|
||||||
data: infoData,
|
|
||||||
schema: infoSchema,
|
|
||||||
column: 2,
|
|
||||||
});
|
|
||||||
|
|
||||||
return { register, registerDev, infoRegister, name, GITHUB_URL };
|
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
label: '最后编译时间',
|
||||||
|
field: 'lastBuildTime',
|
||||||
|
render: commonTagRender('blue'),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '文档地址',
|
||||||
|
field: 'doc',
|
||||||
|
render: commonLinkRender('文档地址'),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '预览地址',
|
||||||
|
field: 'preview',
|
||||||
|
render: commonLinkRender('预览地址'),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Github',
|
||||||
|
field: 'github',
|
||||||
|
render: commonLinkRender('Github'),
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
const infoData = {
|
||||||
|
version,
|
||||||
|
lastBuildTime,
|
||||||
|
doc: DOC_URL,
|
||||||
|
preview: SITE_URL,
|
||||||
|
github: GITHUB_URL,
|
||||||
|
};
|
||||||
|
|
||||||
|
Object.keys(dependencies).forEach((key) => {
|
||||||
|
schema.push({ field: key, label: key });
|
||||||
|
});
|
||||||
|
|
||||||
|
Object.keys(devDependencies).forEach((key) => {
|
||||||
|
devSchema.push({ field: key, label: key });
|
||||||
|
});
|
||||||
|
|
||||||
|
const [register] = useDescription({
|
||||||
|
title: '生产环境依赖',
|
||||||
|
data: dependencies,
|
||||||
|
schema: schema,
|
||||||
|
column: 3,
|
||||||
|
});
|
||||||
|
|
||||||
|
const [registerDev] = useDescription({
|
||||||
|
title: '开发环境依赖',
|
||||||
|
data: devDependencies,
|
||||||
|
schema: devSchema,
|
||||||
|
column: 3,
|
||||||
|
});
|
||||||
|
|
||||||
|
const [infoRegister] = useDescription({
|
||||||
|
title: '项目信息',
|
||||||
|
data: infoData,
|
||||||
|
schema: infoSchema,
|
||||||
|
column: 2,
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
@ -3,40 +3,26 @@
|
|||||||
<Description :data="info" @register="register" />
|
<Description :data="info" @register="register" />
|
||||||
</BasicModal>
|
</BasicModal>
|
||||||
</template>
|
</template>
|
||||||
<script lang="ts">
|
<script lang="ts" setup>
|
||||||
import type { PropType } from 'vue';
|
import type { PropType } from 'vue';
|
||||||
import type { ErrorLogInfo } from '/#/store';
|
import type { ErrorLogInfo } from '/#/store';
|
||||||
|
import { defineProps } from 'vue';
|
||||||
import { defineComponent } from 'vue';
|
|
||||||
import { BasicModal } from '/@/components/Modal/index';
|
import { BasicModal } from '/@/components/Modal/index';
|
||||||
import { Description, useDescription } from '/@/components/Description/index';
|
import { Description, useDescription } from '/@/components/Description/index';
|
||||||
|
|
||||||
import { useI18n } from '/@/hooks/web/useI18n';
|
import { useI18n } from '/@/hooks/web/useI18n';
|
||||||
|
|
||||||
import { getDescSchema } from './data';
|
import { getDescSchema } from './data';
|
||||||
|
|
||||||
export default defineComponent({
|
defineProps({
|
||||||
name: 'ErrorLogDetailModal',
|
info: {
|
||||||
components: { BasicModal, Description },
|
type: Object as PropType<ErrorLogInfo>,
|
||||||
props: {
|
default: null,
|
||||||
info: {
|
|
||||||
type: Object as PropType<ErrorLogInfo>,
|
|
||||||
default: null,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
setup() {
|
|
||||||
const { t } = useI18n();
|
|
||||||
|
|
||||||
const [register] = useDescription({
|
|
||||||
column: 2,
|
|
||||||
schema: getDescSchema()!,
|
|
||||||
});
|
|
||||||
|
|
||||||
return {
|
|
||||||
register,
|
|
||||||
useI18n,
|
|
||||||
t,
|
|
||||||
};
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const { t } = useI18n();
|
||||||
|
|
||||||
|
const [register] = useDescription({
|
||||||
|
column: 2,
|
||||||
|
schema: getDescSchema()!,
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
@ -27,91 +27,66 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts" setup>
|
||||||
import type { ErrorLogInfo } from '/#/store';
|
import type { ErrorLogInfo } from '/#/store';
|
||||||
|
import { watch, ref, nextTick } from 'vue';
|
||||||
import { defineComponent, watch, ref, nextTick } from 'vue';
|
|
||||||
|
|
||||||
import DetailModal from './DetailModal.vue';
|
import DetailModal from './DetailModal.vue';
|
||||||
import { BasicTable, useTable, TableAction } from '/@/components/Table/index';
|
import { BasicTable, useTable, TableAction } from '/@/components/Table/index';
|
||||||
|
|
||||||
import { useModal } from '/@/components/Modal';
|
import { useModal } from '/@/components/Modal';
|
||||||
import { useMessage } from '/@/hooks/web/useMessage';
|
import { useMessage } from '/@/hooks/web/useMessage';
|
||||||
import { useI18n } from '/@/hooks/web/useI18n';
|
import { useI18n } from '/@/hooks/web/useI18n';
|
||||||
|
|
||||||
import { useErrorLogStore } from '/@/store/modules/errorLog';
|
import { useErrorLogStore } from '/@/store/modules/errorLog';
|
||||||
|
|
||||||
import { fireErrorApi } from '/@/api/demo/error';
|
import { fireErrorApi } from '/@/api/demo/error';
|
||||||
|
|
||||||
import { getColumns } from './data';
|
import { getColumns } from './data';
|
||||||
|
|
||||||
import { cloneDeep } from 'lodash-es';
|
import { cloneDeep } from 'lodash-es';
|
||||||
|
|
||||||
export default defineComponent({
|
const rowInfo = ref<ErrorLogInfo>();
|
||||||
name: 'ErrorHandler',
|
const imgList = ref<string[]>([]);
|
||||||
components: { DetailModal, BasicTable, TableAction },
|
|
||||||
setup() {
|
|
||||||
const rowInfo = ref<ErrorLogInfo>();
|
|
||||||
const imgList = ref<string[]>([]);
|
|
||||||
|
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const errorLogStore = useErrorLogStore();
|
const errorLogStore = useErrorLogStore();
|
||||||
const [register, { setTableData }] = useTable({
|
const [register, { setTableData }] = useTable({
|
||||||
title: t('sys.errorLog.tableTitle'),
|
title: t('sys.errorLog.tableTitle'),
|
||||||
columns: getColumns(),
|
columns: getColumns(),
|
||||||
actionColumn: {
|
actionColumn: {
|
||||||
width: 80,
|
width: 80,
|
||||||
title: 'Action',
|
title: 'Action',
|
||||||
dataIndex: 'action',
|
dataIndex: 'action',
|
||||||
slots: { customRender: 'action' },
|
slots: { customRender: 'action' },
|
||||||
},
|
|
||||||
});
|
|
||||||
const [registerModal, { openModal }] = useModal();
|
|
||||||
|
|
||||||
watch(
|
|
||||||
() => errorLogStore.getErrorLogInfoList,
|
|
||||||
(list) => {
|
|
||||||
nextTick(() => {
|
|
||||||
setTableData(cloneDeep(list));
|
|
||||||
});
|
|
||||||
},
|
|
||||||
{
|
|
||||||
immediate: true,
|
|
||||||
}
|
|
||||||
);
|
|
||||||
const { createMessage } = useMessage();
|
|
||||||
if (import.meta.env.DEV) {
|
|
||||||
createMessage.info(t('sys.errorLog.enableMessage'));
|
|
||||||
}
|
|
||||||
// 查看详情
|
|
||||||
function handleDetail(row: ErrorLogInfo) {
|
|
||||||
rowInfo.value = row;
|
|
||||||
openModal(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
function fireVueError() {
|
|
||||||
throw new Error('fire vue error!');
|
|
||||||
}
|
|
||||||
|
|
||||||
function fireResourceError() {
|
|
||||||
imgList.value.push(`${new Date().getTime()}.png`);
|
|
||||||
}
|
|
||||||
|
|
||||||
async function fireAjaxError() {
|
|
||||||
await fireErrorApi();
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
register,
|
|
||||||
registerModal,
|
|
||||||
handleDetail,
|
|
||||||
fireVueError,
|
|
||||||
fireResourceError,
|
|
||||||
fireAjaxError,
|
|
||||||
imgList,
|
|
||||||
rowInfo,
|
|
||||||
t,
|
|
||||||
};
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
const [registerModal, { openModal }] = useModal();
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => errorLogStore.getErrorLogInfoList,
|
||||||
|
(list) => {
|
||||||
|
nextTick(() => {
|
||||||
|
setTableData(cloneDeep(list));
|
||||||
|
});
|
||||||
|
},
|
||||||
|
{
|
||||||
|
immediate: true,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
const { createMessage } = useMessage();
|
||||||
|
if (import.meta.env.DEV) {
|
||||||
|
createMessage.info(t('sys.errorLog.enableMessage'));
|
||||||
|
}
|
||||||
|
// 查看详情
|
||||||
|
function handleDetail(row: ErrorLogInfo) {
|
||||||
|
rowInfo.value = row;
|
||||||
|
openModal(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
function fireVueError() {
|
||||||
|
throw new Error('fire vue error!');
|
||||||
|
}
|
||||||
|
|
||||||
|
function fireResourceError() {
|
||||||
|
imgList.value.push(`${new Date().getTime()}.png`);
|
||||||
|
}
|
||||||
|
|
||||||
|
async function fireAjaxError() {
|
||||||
|
await fireErrorApi();
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
@ -1,19 +1,14 @@
|
|||||||
<script lang="tsx">
|
<script lang="tsx">
|
||||||
import type { PropType } from 'vue';
|
import type { PropType } from 'vue';
|
||||||
|
|
||||||
import { Result, Button } from 'ant-design-vue';
|
import { Result, Button } from 'ant-design-vue';
|
||||||
import { defineComponent, ref, computed, unref } from 'vue';
|
import { defineComponent, ref, computed, unref } from 'vue';
|
||||||
|
|
||||||
import { ExceptionEnum } from '/@/enums/exceptionEnum';
|
import { ExceptionEnum } from '/@/enums/exceptionEnum';
|
||||||
|
|
||||||
import notDataSvg from '/@/assets/svg/no-data.svg';
|
import notDataSvg from '/@/assets/svg/no-data.svg';
|
||||||
import netWorkSvg from '/@/assets/svg/net-error.svg';
|
import netWorkSvg from '/@/assets/svg/net-error.svg';
|
||||||
|
|
||||||
import { useRoute } from 'vue-router';
|
import { useRoute } from 'vue-router';
|
||||||
import { useDesign } from '/@/hooks/web/useDesign';
|
import { useDesign } from '/@/hooks/web/useDesign';
|
||||||
import { useI18n } from '/@/hooks/web/useI18n';
|
import { useI18n } from '/@/hooks/web/useI18n';
|
||||||
import { useGo, useRedo } from '/@/hooks/web/usePage';
|
import { useGo, useRedo } from '/@/hooks/web/usePage';
|
||||||
|
|
||||||
import { PageEnum } from '/@/enums/pageEnum';
|
import { PageEnum } from '/@/enums/pageEnum';
|
||||||
|
|
||||||
interface MapValue {
|
interface MapValue {
|
||||||
|
@ -10,66 +10,50 @@
|
|||||||
</Spin>
|
</Spin>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script lang="ts">
|
<script lang="ts" setup>
|
||||||
import type { CSSProperties } from 'vue';
|
import type { CSSProperties } from 'vue';
|
||||||
import { defineComponent, ref, unref, computed } from 'vue';
|
import { ref, unref, computed, defineProps } from 'vue';
|
||||||
import { Spin } from 'ant-design-vue';
|
import { Spin } from 'ant-design-vue';
|
||||||
|
|
||||||
import { useWindowSizeFn } from '/@/hooks/event/useWindowSizeFn';
|
import { useWindowSizeFn } from '/@/hooks/event/useWindowSizeFn';
|
||||||
|
|
||||||
import { propTypes } from '/@/utils/propTypes';
|
import { propTypes } from '/@/utils/propTypes';
|
||||||
import { useDesign } from '/@/hooks/web/useDesign';
|
import { useDesign } from '/@/hooks/web/useDesign';
|
||||||
import { useLayoutHeight } from '/@/layouts/default/content/useContentViewHeight';
|
import { useLayoutHeight } from '/@/layouts/default/content/useContentViewHeight';
|
||||||
|
|
||||||
export default defineComponent({
|
defineProps({
|
||||||
name: 'IFrame',
|
frameSrc: propTypes.string.def(''),
|
||||||
components: { Spin },
|
|
||||||
props: {
|
|
||||||
frameSrc: propTypes.string.def(''),
|
|
||||||
},
|
|
||||||
setup() {
|
|
||||||
const loading = ref(true);
|
|
||||||
const topRef = ref(50);
|
|
||||||
const heightRef = ref(window.innerHeight);
|
|
||||||
const frameRef = ref<HTMLFrameElement>();
|
|
||||||
const { headerHeightRef } = useLayoutHeight();
|
|
||||||
|
|
||||||
const { prefixCls } = useDesign('iframe-page');
|
|
||||||
useWindowSizeFn(calcHeight, 150, { immediate: true });
|
|
||||||
|
|
||||||
const getWrapStyle = computed((): CSSProperties => {
|
|
||||||
return {
|
|
||||||
height: `${unref(heightRef)}px`,
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
function calcHeight() {
|
|
||||||
const iframe = unref(frameRef);
|
|
||||||
if (!iframe) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const top = headerHeightRef.value;
|
|
||||||
topRef.value = top;
|
|
||||||
heightRef.value = window.innerHeight - top;
|
|
||||||
const clientHeight = document.documentElement.clientHeight - top;
|
|
||||||
iframe.style.height = `${clientHeight}px`;
|
|
||||||
}
|
|
||||||
|
|
||||||
function hideLoading() {
|
|
||||||
loading.value = false;
|
|
||||||
calcHeight();
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
getWrapStyle,
|
|
||||||
loading,
|
|
||||||
frameRef,
|
|
||||||
prefixCls,
|
|
||||||
|
|
||||||
hideLoading,
|
|
||||||
};
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const loading = ref(true);
|
||||||
|
const topRef = ref(50);
|
||||||
|
const heightRef = ref(window.innerHeight);
|
||||||
|
const frameRef = ref<HTMLFrameElement>();
|
||||||
|
const { headerHeightRef } = useLayoutHeight();
|
||||||
|
|
||||||
|
const { prefixCls } = useDesign('iframe-page');
|
||||||
|
useWindowSizeFn(calcHeight, 150, { immediate: true });
|
||||||
|
|
||||||
|
const getWrapStyle = computed((): CSSProperties => {
|
||||||
|
return {
|
||||||
|
height: `${unref(heightRef)}px`,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
function calcHeight() {
|
||||||
|
const iframe = unref(frameRef);
|
||||||
|
if (!iframe) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const top = headerHeightRef.value;
|
||||||
|
topRef.value = top;
|
||||||
|
heightRef.value = window.innerHeight - top;
|
||||||
|
const clientHeight = document.documentElement.clientHeight - top;
|
||||||
|
iframe.style.height = `${clientHeight}px`;
|
||||||
|
}
|
||||||
|
|
||||||
|
function hideLoading() {
|
||||||
|
loading.value = false;
|
||||||
|
calcHeight();
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
<style lang="less" scoped>
|
<style lang="less" scoped>
|
||||||
@prefix-cls: ~'@{namespace}-iframe-page';
|
@prefix-cls: ~'@{namespace}-iframe-page';
|
||||||
|
@ -92,84 +92,61 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script lang="ts">
|
<script lang="ts" setup>
|
||||||
import { defineComponent, ref, computed } from 'vue';
|
import { ref, computed } from 'vue';
|
||||||
import { Input } from 'ant-design-vue';
|
import { Input } from 'ant-design-vue';
|
||||||
|
|
||||||
import { useUserStore } from '/@/store/modules/user';
|
import { useUserStore } from '/@/store/modules/user';
|
||||||
import { useLockStore } from '/@/store/modules/lock';
|
import { useLockStore } from '/@/store/modules/lock';
|
||||||
import { useI18n } from '/@/hooks/web/useI18n';
|
import { useI18n } from '/@/hooks/web/useI18n';
|
||||||
|
|
||||||
import { useNow } from './useNow';
|
import { useNow } from './useNow';
|
||||||
import { useDesign } from '/@/hooks/web/useDesign';
|
import { useDesign } from '/@/hooks/web/useDesign';
|
||||||
|
|
||||||
import { LockOutlined } from '@ant-design/icons-vue';
|
import { LockOutlined } from '@ant-design/icons-vue';
|
||||||
import headerImg from '/@/assets/images/header.jpg';
|
import headerImg from '/@/assets/images/header.jpg';
|
||||||
|
|
||||||
export default defineComponent({
|
const InputPassword = Input.Password;
|
||||||
name: 'LockPage',
|
|
||||||
components: { LockOutlined, InputPassword: Input.Password },
|
|
||||||
|
|
||||||
setup() {
|
const password = ref('');
|
||||||
const password = ref('');
|
const loading = ref(false);
|
||||||
const loading = ref(false);
|
const errMsg = ref(false);
|
||||||
const errMsg = ref(false);
|
const showDate = ref(true);
|
||||||
const showDate = ref(true);
|
|
||||||
|
|
||||||
const { prefixCls } = useDesign('lock-page');
|
const { prefixCls } = useDesign('lock-page');
|
||||||
const lockStore = useLockStore();
|
const lockStore = useLockStore();
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
|
|
||||||
const { ...state } = useNow(true);
|
const { hour, month, minute, meridiem, year, day, week } = useNow(true);
|
||||||
|
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
|
|
||||||
const userinfo = computed(() => {
|
const userinfo = computed(() => {
|
||||||
return userStore.getUserInfo || {};
|
return userStore.getUserInfo || {};
|
||||||
});
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @description: unLock
|
|
||||||
*/
|
|
||||||
async function unLock() {
|
|
||||||
if (!password.value) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
let pwd = password.value;
|
|
||||||
try {
|
|
||||||
loading.value = true;
|
|
||||||
const res = await lockStore.unLock(pwd);
|
|
||||||
errMsg.value = !res;
|
|
||||||
} finally {
|
|
||||||
loading.value = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function goLogin() {
|
|
||||||
userStore.logout(true);
|
|
||||||
lockStore.resetLockInfo();
|
|
||||||
}
|
|
||||||
|
|
||||||
function handleShowForm(show = false) {
|
|
||||||
showDate.value = show;
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
goLogin,
|
|
||||||
userinfo,
|
|
||||||
unLock,
|
|
||||||
errMsg,
|
|
||||||
loading,
|
|
||||||
t,
|
|
||||||
prefixCls,
|
|
||||||
showDate,
|
|
||||||
password,
|
|
||||||
handleShowForm,
|
|
||||||
headerImg,
|
|
||||||
...state,
|
|
||||||
};
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description: unLock
|
||||||
|
*/
|
||||||
|
async function unLock() {
|
||||||
|
if (!password.value) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
let pwd = password.value;
|
||||||
|
try {
|
||||||
|
loading.value = true;
|
||||||
|
const res = await lockStore.unLock(pwd);
|
||||||
|
errMsg.value = !res;
|
||||||
|
} finally {
|
||||||
|
loading.value = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function goLogin() {
|
||||||
|
userStore.logout(true);
|
||||||
|
lockStore.resetLockInfo();
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleShowForm(show = false) {
|
||||||
|
showDate.value = show;
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
<style lang="less" scoped>
|
<style lang="less" scoped>
|
||||||
@prefix-cls: ~'@{namespace}-lock-page';
|
@prefix-cls: ~'@{namespace}-lock-page';
|
||||||
|
@ -3,18 +3,11 @@
|
|||||||
<LockPage v-if="getIsLock" />
|
<LockPage v-if="getIsLock" />
|
||||||
</transition>
|
</transition>
|
||||||
</template>
|
</template>
|
||||||
<script lang="ts">
|
<script lang="ts" setup>
|
||||||
import { defineComponent, computed } from 'vue';
|
import { computed } from 'vue';
|
||||||
import LockPage from './LockPage.vue';
|
import LockPage from './LockPage.vue';
|
||||||
|
|
||||||
import { useLockStore } from '/@/store/modules/lock';
|
import { useLockStore } from '/@/store/modules/lock';
|
||||||
export default defineComponent({
|
|
||||||
name: 'Lock',
|
const lockStore = useLockStore();
|
||||||
components: { LockPage },
|
const getIsLock = computed(() => lockStore?.getLockInfo?.isLock ?? false);
|
||||||
setup() {
|
|
||||||
const lockStore = useLockStore();
|
|
||||||
const getIsLock = computed(() => lockStore?.getLockInfo?.isLock ?? false);
|
|
||||||
return { getIsLock };
|
|
||||||
},
|
|
||||||
});
|
|
||||||
</script>
|
</script>
|
||||||
|
@ -32,58 +32,33 @@
|
|||||||
</Form>
|
</Form>
|
||||||
</template>
|
</template>
|
||||||
</template>
|
</template>
|
||||||
<script lang="ts">
|
<script lang="ts" setup>
|
||||||
import { defineComponent, reactive, ref, computed, unref } from 'vue';
|
import { reactive, ref, computed, unref } from 'vue';
|
||||||
|
|
||||||
import LoginFormTitle from './LoginFormTitle.vue';
|
import LoginFormTitle from './LoginFormTitle.vue';
|
||||||
import { Form, Input, Button } from 'ant-design-vue';
|
import { Form, Input, Button } from 'ant-design-vue';
|
||||||
import { CountdownInput } from '/@/components/CountDown';
|
import { CountdownInput } from '/@/components/CountDown';
|
||||||
|
|
||||||
import { useI18n } from '/@/hooks/web/useI18n';
|
import { useI18n } from '/@/hooks/web/useI18n';
|
||||||
import { useLoginState, useFormRules, LoginStateEnum } from './useLogin';
|
import { useLoginState, useFormRules, LoginStateEnum } from './useLogin';
|
||||||
|
|
||||||
export default defineComponent({
|
const FormItem = Form.Item;
|
||||||
name: 'ForgetPasswordForm',
|
const { t } = useI18n();
|
||||||
components: {
|
const { handleBackLogin, getLoginState } = useLoginState();
|
||||||
Button,
|
const { getFormRules } = useFormRules();
|
||||||
Form,
|
|
||||||
FormItem: Form.Item,
|
|
||||||
Input,
|
|
||||||
CountdownInput,
|
|
||||||
LoginFormTitle,
|
|
||||||
},
|
|
||||||
setup() {
|
|
||||||
const { t } = useI18n();
|
|
||||||
const { handleBackLogin, getLoginState } = useLoginState();
|
|
||||||
const { getFormRules } = useFormRules();
|
|
||||||
|
|
||||||
const formRef = ref();
|
const formRef = ref();
|
||||||
const loading = ref(false);
|
const loading = ref(false);
|
||||||
|
|
||||||
const formData = reactive({
|
const formData = reactive({
|
||||||
account: '',
|
account: '',
|
||||||
mobile: '',
|
mobile: '',
|
||||||
sms: '',
|
sms: '',
|
||||||
});
|
|
||||||
|
|
||||||
const getShow = computed(() => unref(getLoginState) === LoginStateEnum.RESET_PASSWORD);
|
|
||||||
|
|
||||||
async function handleReset() {
|
|
||||||
const form = unref(formRef);
|
|
||||||
if (!form) return;
|
|
||||||
await form.resetFields();
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
t,
|
|
||||||
formRef,
|
|
||||||
formData,
|
|
||||||
getFormRules,
|
|
||||||
handleReset,
|
|
||||||
loading,
|
|
||||||
handleBackLogin,
|
|
||||||
getShow,
|
|
||||||
};
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const getShow = computed(() => unref(getLoginState) === LoginStateEnum.RESET_PASSWORD);
|
||||||
|
|
||||||
|
async function handleReset() {
|
||||||
|
const form = unref(formRef);
|
||||||
|
if (!form) return;
|
||||||
|
await form.resetFields();
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
@ -61,9 +61,8 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script lang="ts">
|
<script lang="ts" setup>
|
||||||
import { defineComponent, computed } from 'vue';
|
import { computed, defineProps } from 'vue';
|
||||||
|
|
||||||
import { AppLogo } from '/@/components/Application';
|
import { AppLogo } from '/@/components/Application';
|
||||||
import { AppLocalePicker, AppDarkModeToggle } from '/@/components/Application';
|
import { AppLocalePicker, AppDarkModeToggle } from '/@/components/Application';
|
||||||
import LoginForm from './LoginForm.vue';
|
import LoginForm from './LoginForm.vue';
|
||||||
@ -71,43 +70,23 @@
|
|||||||
import RegisterForm from './RegisterForm.vue';
|
import RegisterForm from './RegisterForm.vue';
|
||||||
import MobileForm from './MobileForm.vue';
|
import MobileForm from './MobileForm.vue';
|
||||||
import QrCodeForm from './QrCodeForm.vue';
|
import QrCodeForm from './QrCodeForm.vue';
|
||||||
|
|
||||||
import { useGlobSetting } from '/@/hooks/setting';
|
import { useGlobSetting } from '/@/hooks/setting';
|
||||||
import { useI18n } from '/@/hooks/web/useI18n';
|
import { useI18n } from '/@/hooks/web/useI18n';
|
||||||
import { useDesign } from '/@/hooks/web/useDesign';
|
import { useDesign } from '/@/hooks/web/useDesign';
|
||||||
import { useLocaleStore } from '/@/store/modules/locale';
|
import { useLocaleStore } from '/@/store/modules/locale';
|
||||||
|
|
||||||
export default defineComponent({
|
defineProps({
|
||||||
name: 'Login',
|
sessionTimeout: {
|
||||||
components: {
|
type: Boolean,
|
||||||
AppLogo,
|
|
||||||
LoginForm,
|
|
||||||
ForgetPasswordForm,
|
|
||||||
RegisterForm,
|
|
||||||
MobileForm,
|
|
||||||
QrCodeForm,
|
|
||||||
AppLocalePicker,
|
|
||||||
AppDarkModeToggle,
|
|
||||||
},
|
|
||||||
props: {
|
|
||||||
sessionTimeout: {
|
|
||||||
type: Boolean,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
setup() {
|
|
||||||
const globSetting = useGlobSetting();
|
|
||||||
const { prefixCls } = useDesign('login');
|
|
||||||
const { t } = useI18n();
|
|
||||||
const localeStore = useLocaleStore();
|
|
||||||
|
|
||||||
return {
|
|
||||||
t,
|
|
||||||
prefixCls,
|
|
||||||
title: computed(() => globSetting?.title ?? ''),
|
|
||||||
showLocale: localeStore.getShowPicker,
|
|
||||||
};
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const globSetting = useGlobSetting();
|
||||||
|
const { prefixCls } = useDesign('login');
|
||||||
|
const { t } = useI18n();
|
||||||
|
const localeStore = useLocaleStore();
|
||||||
|
const showLocale = localeStore.getShowPicker;
|
||||||
|
const title = computed(() => globSetting?.title ?? '');
|
||||||
</script>
|
</script>
|
||||||
<style lang="less">
|
<style lang="less">
|
||||||
@prefix-cls: ~'@{namespace}-login';
|
@prefix-cls: ~'@{namespace}-login';
|
||||||
|
@ -81,8 +81,8 @@
|
|||||||
</div>
|
</div>
|
||||||
</Form>
|
</Form>
|
||||||
</template>
|
</template>
|
||||||
<script lang="ts">
|
<script lang="ts" setup>
|
||||||
import { defineComponent, reactive, ref, toRaw, unref, computed } from 'vue';
|
import { reactive, ref, toRaw, unref, computed } from 'vue';
|
||||||
|
|
||||||
import { Checkbox, Form, Input, Row, Col, Button, Divider } from 'ant-design-vue';
|
import { Checkbox, Form, Input, Row, Col, Button, Divider } from 'ant-design-vue';
|
||||||
import {
|
import {
|
||||||
@ -102,92 +102,60 @@
|
|||||||
import { useDesign } from '/@/hooks/web/useDesign';
|
import { useDesign } from '/@/hooks/web/useDesign';
|
||||||
//import { onKeyStroke } from '@vueuse/core';
|
//import { onKeyStroke } from '@vueuse/core';
|
||||||
|
|
||||||
export default defineComponent({
|
const ACol = Col;
|
||||||
name: 'LoginForm',
|
const ARow = Row;
|
||||||
components: {
|
const FormItem = Form.Item;
|
||||||
[Col.name]: Col,
|
const InputPassword = Input.Password;
|
||||||
[Row.name]: Row,
|
const { t } = useI18n();
|
||||||
Checkbox,
|
const { notification, createErrorModal } = useMessage();
|
||||||
Button,
|
const { prefixCls } = useDesign('login');
|
||||||
Form,
|
const userStore = useUserStore();
|
||||||
FormItem: Form.Item,
|
|
||||||
Input,
|
|
||||||
Divider,
|
|
||||||
LoginFormTitle,
|
|
||||||
InputPassword: Input.Password,
|
|
||||||
GithubFilled,
|
|
||||||
WechatFilled,
|
|
||||||
AlipayCircleFilled,
|
|
||||||
GoogleCircleFilled,
|
|
||||||
TwitterCircleFilled,
|
|
||||||
},
|
|
||||||
setup() {
|
|
||||||
const { t } = useI18n();
|
|
||||||
const { notification, createErrorModal } = useMessage();
|
|
||||||
const { prefixCls } = useDesign('login');
|
|
||||||
const userStore = useUserStore();
|
|
||||||
|
|
||||||
const { setLoginState, getLoginState } = useLoginState();
|
const { setLoginState, getLoginState } = useLoginState();
|
||||||
const { getFormRules } = useFormRules();
|
const { getFormRules } = useFormRules();
|
||||||
|
|
||||||
const formRef = ref();
|
const formRef = ref();
|
||||||
const loading = ref(false);
|
const loading = ref(false);
|
||||||
const rememberMe = ref(false);
|
const rememberMe = ref(false);
|
||||||
|
|
||||||
const formData = reactive({
|
const formData = reactive({
|
||||||
account: 'vben',
|
account: 'vben',
|
||||||
password: '123456',
|
password: '123456',
|
||||||
});
|
|
||||||
|
|
||||||
const { validForm } = useFormValid(formRef);
|
|
||||||
|
|
||||||
//onKeyStroke('Enter', handleLogin);
|
|
||||||
|
|
||||||
const getShow = computed(() => unref(getLoginState) === LoginStateEnum.LOGIN);
|
|
||||||
|
|
||||||
async function handleLogin() {
|
|
||||||
const data = await validForm();
|
|
||||||
if (!data) return;
|
|
||||||
try {
|
|
||||||
loading.value = true;
|
|
||||||
const userInfo = await userStore.login(
|
|
||||||
toRaw({
|
|
||||||
password: data.password,
|
|
||||||
username: data.account,
|
|
||||||
mode: 'none', //不要默认的错误提示
|
|
||||||
})
|
|
||||||
);
|
|
||||||
if (userInfo) {
|
|
||||||
notification.success({
|
|
||||||
message: t('sys.login.loginSuccessTitle'),
|
|
||||||
description: `${t('sys.login.loginSuccessDesc')}: ${userInfo.realName}`,
|
|
||||||
duration: 3,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
createErrorModal({
|
|
||||||
title: t('sys.api.errorTip'),
|
|
||||||
content: error.message || t('sys.api.networkExceptionMsg'),
|
|
||||||
getContainer: () => document.body.querySelector(`.${prefixCls}`) || document.body,
|
|
||||||
});
|
|
||||||
} finally {
|
|
||||||
loading.value = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
t,
|
|
||||||
prefixCls,
|
|
||||||
formRef,
|
|
||||||
formData,
|
|
||||||
getFormRules,
|
|
||||||
rememberMe,
|
|
||||||
handleLogin,
|
|
||||||
loading,
|
|
||||||
setLoginState,
|
|
||||||
LoginStateEnum,
|
|
||||||
getShow,
|
|
||||||
};
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const { validForm } = useFormValid(formRef);
|
||||||
|
|
||||||
|
//onKeyStroke('Enter', handleLogin);
|
||||||
|
|
||||||
|
const getShow = computed(() => unref(getLoginState) === LoginStateEnum.LOGIN);
|
||||||
|
|
||||||
|
async function handleLogin() {
|
||||||
|
const data = await validForm();
|
||||||
|
if (!data) return;
|
||||||
|
try {
|
||||||
|
loading.value = true;
|
||||||
|
const userInfo = await userStore.login(
|
||||||
|
toRaw({
|
||||||
|
password: data.password,
|
||||||
|
username: data.account,
|
||||||
|
mode: 'none', //不要默认的错误提示
|
||||||
|
})
|
||||||
|
);
|
||||||
|
if (userInfo) {
|
||||||
|
notification.success({
|
||||||
|
message: t('sys.login.loginSuccessTitle'),
|
||||||
|
description: `${t('sys.login.loginSuccessDesc')}: ${userInfo.realName}`,
|
||||||
|
duration: 3,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
createErrorModal({
|
||||||
|
title: t('sys.api.errorTip'),
|
||||||
|
content: error.message || t('sys.api.networkExceptionMsg'),
|
||||||
|
getContainer: () => document.body.querySelector(`.${prefixCls}`) || document.body,
|
||||||
|
});
|
||||||
|
} finally {
|
||||||
|
loading.value = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
@ -3,33 +3,23 @@
|
|||||||
{{ getFormTitle }}
|
{{ getFormTitle }}
|
||||||
</h2>
|
</h2>
|
||||||
</template>
|
</template>
|
||||||
<script lang="ts">
|
<script lang="ts" setup>
|
||||||
import { defineComponent, computed, unref } from 'vue';
|
import { computed, unref } from 'vue';
|
||||||
|
|
||||||
import { useI18n } from '/@/hooks/web/useI18n';
|
import { useI18n } from '/@/hooks/web/useI18n';
|
||||||
import { LoginStateEnum, useLoginState } from './useLogin';
|
import { LoginStateEnum, useLoginState } from './useLogin';
|
||||||
|
|
||||||
export default defineComponent({
|
const { t } = useI18n();
|
||||||
name: 'LoginFormTitle',
|
|
||||||
setup() {
|
|
||||||
const { t } = useI18n();
|
|
||||||
|
|
||||||
const { getLoginState } = useLoginState();
|
const { getLoginState } = useLoginState();
|
||||||
|
|
||||||
const getFormTitle = computed(() => {
|
const getFormTitle = computed(() => {
|
||||||
const titleObj = {
|
const titleObj = {
|
||||||
[LoginStateEnum.RESET_PASSWORD]: t('sys.login.forgetFormTitle'),
|
[LoginStateEnum.RESET_PASSWORD]: t('sys.login.forgetFormTitle'),
|
||||||
[LoginStateEnum.LOGIN]: t('sys.login.signInFormTitle'),
|
[LoginStateEnum.LOGIN]: t('sys.login.signInFormTitle'),
|
||||||
[LoginStateEnum.REGISTER]: t('sys.login.signUpFormTitle'),
|
[LoginStateEnum.REGISTER]: t('sys.login.signUpFormTitle'),
|
||||||
[LoginStateEnum.MOBILE]: t('sys.login.mobileSignInFormTitle'),
|
[LoginStateEnum.MOBILE]: t('sys.login.mobileSignInFormTitle'),
|
||||||
[LoginStateEnum.QR_CODE]: t('sys.login.qrSignInFormTitle'),
|
[LoginStateEnum.QR_CODE]: t('sys.login.qrSignInFormTitle'),
|
||||||
};
|
};
|
||||||
return titleObj[unref(getLoginState)];
|
return titleObj[unref(getLoginState)];
|
||||||
});
|
|
||||||
|
|
||||||
return {
|
|
||||||
getFormTitle,
|
|
||||||
};
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
@ -30,59 +30,34 @@
|
|||||||
</Form>
|
</Form>
|
||||||
</template>
|
</template>
|
||||||
</template>
|
</template>
|
||||||
<script lang="ts">
|
<script lang="ts" setup>
|
||||||
import { defineComponent, reactive, ref, computed, unref } from 'vue';
|
import { reactive, ref, computed, unref } from 'vue';
|
||||||
|
|
||||||
import { Form, Input, Button } from 'ant-design-vue';
|
import { Form, Input, Button } from 'ant-design-vue';
|
||||||
import { CountdownInput } from '/@/components/CountDown';
|
import { CountdownInput } from '/@/components/CountDown';
|
||||||
import LoginFormTitle from './LoginFormTitle.vue';
|
import LoginFormTitle from './LoginFormTitle.vue';
|
||||||
|
|
||||||
import { useI18n } from '/@/hooks/web/useI18n';
|
import { useI18n } from '/@/hooks/web/useI18n';
|
||||||
import { useLoginState, useFormRules, useFormValid, LoginStateEnum } from './useLogin';
|
import { useLoginState, useFormRules, useFormValid, LoginStateEnum } from './useLogin';
|
||||||
|
|
||||||
export default defineComponent({
|
const FormItem = Form.Item;
|
||||||
name: 'MobileForm',
|
const { t } = useI18n();
|
||||||
components: {
|
const { handleBackLogin, getLoginState } = useLoginState();
|
||||||
Button,
|
const { getFormRules } = useFormRules();
|
||||||
Form,
|
|
||||||
FormItem: Form.Item,
|
|
||||||
Input,
|
|
||||||
CountdownInput,
|
|
||||||
LoginFormTitle,
|
|
||||||
},
|
|
||||||
setup() {
|
|
||||||
const { t } = useI18n();
|
|
||||||
const { handleBackLogin, getLoginState } = useLoginState();
|
|
||||||
const { getFormRules } = useFormRules();
|
|
||||||
|
|
||||||
const formRef = ref();
|
const formRef = ref();
|
||||||
const loading = ref(false);
|
const loading = ref(false);
|
||||||
|
|
||||||
const formData = reactive({
|
const formData = reactive({
|
||||||
mobile: '',
|
mobile: '',
|
||||||
sms: '',
|
sms: '',
|
||||||
});
|
|
||||||
|
|
||||||
const { validForm } = useFormValid(formRef);
|
|
||||||
|
|
||||||
const getShow = computed(() => unref(getLoginState) === LoginStateEnum.MOBILE);
|
|
||||||
|
|
||||||
async function handleLogin() {
|
|
||||||
const data = await validForm();
|
|
||||||
if (!data) return;
|
|
||||||
console.log(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
t,
|
|
||||||
formRef,
|
|
||||||
formData,
|
|
||||||
getFormRules,
|
|
||||||
handleLogin,
|
|
||||||
loading,
|
|
||||||
handleBackLogin,
|
|
||||||
getShow,
|
|
||||||
};
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const { validForm } = useFormValid(formRef);
|
||||||
|
|
||||||
|
const getShow = computed(() => unref(getLoginState) === LoginStateEnum.MOBILE);
|
||||||
|
|
||||||
|
async function handleLogin() {
|
||||||
|
const data = await validForm();
|
||||||
|
if (!data) return;
|
||||||
|
console.log(data);
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
@ -14,37 +14,18 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</template>
|
</template>
|
||||||
<script lang="ts">
|
<script lang="ts" setup>
|
||||||
import { defineComponent, computed, unref } from 'vue';
|
import { computed, unref } from 'vue';
|
||||||
|
|
||||||
import LoginFormTitle from './LoginFormTitle.vue';
|
import LoginFormTitle from './LoginFormTitle.vue';
|
||||||
import { Button, Divider } from 'ant-design-vue';
|
import { Button, Divider } from 'ant-design-vue';
|
||||||
import { QrCode } from '/@/components/Qrcode/index';
|
import { QrCode } from '/@/components/Qrcode/index';
|
||||||
|
|
||||||
import { useI18n } from '/@/hooks/web/useI18n';
|
import { useI18n } from '/@/hooks/web/useI18n';
|
||||||
import { useLoginState, LoginStateEnum } from './useLogin';
|
import { useLoginState, LoginStateEnum } from './useLogin';
|
||||||
|
|
||||||
const qrCodeUrl = 'https://vvbin.cn/next/login';
|
const qrCodeUrl = 'https://vvbin.cn/next/login';
|
||||||
export default defineComponent({
|
|
||||||
name: 'QrCodeForm',
|
|
||||||
components: {
|
|
||||||
Button,
|
|
||||||
QrCode,
|
|
||||||
Divider,
|
|
||||||
LoginFormTitle,
|
|
||||||
},
|
|
||||||
setup() {
|
|
||||||
const { t } = useI18n();
|
|
||||||
const { handleBackLogin, getLoginState } = useLoginState();
|
|
||||||
|
|
||||||
const getShow = computed(() => unref(getLoginState) === LoginStateEnum.QR_CODE);
|
const { t } = useI18n();
|
||||||
|
const { handleBackLogin, getLoginState } = useLoginState();
|
||||||
|
|
||||||
return {
|
const getShow = computed(() => unref(getLoginState) === LoginStateEnum.QR_CODE);
|
||||||
t,
|
|
||||||
handleBackLogin,
|
|
||||||
qrCodeUrl,
|
|
||||||
getShow,
|
|
||||||
};
|
|
||||||
},
|
|
||||||
});
|
|
||||||
</script>
|
</script>
|
||||||
|
@ -65,67 +65,40 @@
|
|||||||
</Form>
|
</Form>
|
||||||
</template>
|
</template>
|
||||||
</template>
|
</template>
|
||||||
<script lang="ts">
|
<script lang="ts" setup>
|
||||||
import { defineComponent, reactive, ref, unref, computed } from 'vue';
|
import { reactive, ref, unref, computed } from 'vue';
|
||||||
|
|
||||||
import LoginFormTitle from './LoginFormTitle.vue';
|
import LoginFormTitle from './LoginFormTitle.vue';
|
||||||
import { Form, Input, Button, Checkbox } from 'ant-design-vue';
|
import { Form, Input, Button, Checkbox } from 'ant-design-vue';
|
||||||
import { StrengthMeter } from '/@/components/StrengthMeter';
|
import { StrengthMeter } from '/@/components/StrengthMeter';
|
||||||
import { CountdownInput } from '/@/components/CountDown';
|
import { CountdownInput } from '/@/components/CountDown';
|
||||||
|
|
||||||
import { useI18n } from '/@/hooks/web/useI18n';
|
import { useI18n } from '/@/hooks/web/useI18n';
|
||||||
import { useLoginState, useFormRules, useFormValid, LoginStateEnum } from './useLogin';
|
import { useLoginState, useFormRules, useFormValid, LoginStateEnum } from './useLogin';
|
||||||
|
|
||||||
export default defineComponent({
|
const FormItem = Form.Item;
|
||||||
name: 'RegisterPasswordForm',
|
const InputPassword = Input.Password;
|
||||||
components: {
|
const { t } = useI18n();
|
||||||
Button,
|
const { handleBackLogin, getLoginState } = useLoginState();
|
||||||
Form,
|
|
||||||
FormItem: Form.Item,
|
|
||||||
Input,
|
|
||||||
InputPassword: Input.Password,
|
|
||||||
Checkbox,
|
|
||||||
StrengthMeter,
|
|
||||||
CountdownInput,
|
|
||||||
LoginFormTitle,
|
|
||||||
},
|
|
||||||
setup() {
|
|
||||||
const { t } = useI18n();
|
|
||||||
const { handleBackLogin, getLoginState } = useLoginState();
|
|
||||||
|
|
||||||
const formRef = ref();
|
const formRef = ref();
|
||||||
const loading = ref(false);
|
const loading = ref(false);
|
||||||
|
|
||||||
const formData = reactive({
|
const formData = reactive({
|
||||||
account: '',
|
account: '',
|
||||||
password: '',
|
password: '',
|
||||||
confirmPassword: '',
|
confirmPassword: '',
|
||||||
mobile: '',
|
mobile: '',
|
||||||
sms: '',
|
sms: '',
|
||||||
policy: false,
|
policy: false,
|
||||||
});
|
|
||||||
|
|
||||||
const { getFormRules } = useFormRules(formData);
|
|
||||||
const { validForm } = useFormValid(formRef);
|
|
||||||
|
|
||||||
const getShow = computed(() => unref(getLoginState) === LoginStateEnum.REGISTER);
|
|
||||||
|
|
||||||
async function handleRegister() {
|
|
||||||
const data = await validForm();
|
|
||||||
if (!data) return;
|
|
||||||
console.log(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
t,
|
|
||||||
formRef,
|
|
||||||
formData,
|
|
||||||
getFormRules,
|
|
||||||
handleRegister,
|
|
||||||
loading,
|
|
||||||
handleBackLogin,
|
|
||||||
getShow,
|
|
||||||
};
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const { getFormRules } = useFormRules(formData);
|
||||||
|
const { validForm } = useFormValid(formRef);
|
||||||
|
|
||||||
|
const getShow = computed(() => unref(getLoginState) === LoginStateEnum.REGISTER);
|
||||||
|
|
||||||
|
async function handleRegister() {
|
||||||
|
const data = await validForm();
|
||||||
|
if (!data) return;
|
||||||
|
console.log(data);
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
@ -5,47 +5,39 @@
|
|||||||
</div>
|
</div>
|
||||||
</transition>
|
</transition>
|
||||||
</template>
|
</template>
|
||||||
<script lang="ts">
|
<script lang="ts" setup>
|
||||||
import { defineComponent, onBeforeUnmount, onMounted, ref } from 'vue';
|
import { onBeforeUnmount, onMounted, ref } from 'vue';
|
||||||
import Login from './Login.vue';
|
import Login from './Login.vue';
|
||||||
|
|
||||||
import { useDesign } from '/@/hooks/web/useDesign';
|
import { useDesign } from '/@/hooks/web/useDesign';
|
||||||
import { useUserStore } from '/@/store/modules/user';
|
import { useUserStore } from '/@/store/modules/user';
|
||||||
import { usePermissionStore } from '/@/store/modules/permission';
|
import { usePermissionStore } from '/@/store/modules/permission';
|
||||||
import { useAppStore } from '/@/store/modules/app';
|
import { useAppStore } from '/@/store/modules/app';
|
||||||
import { PermissionModeEnum } from '/@/enums/appEnum';
|
import { PermissionModeEnum } from '/@/enums/appEnum';
|
||||||
export default defineComponent({
|
|
||||||
name: 'SessionTimeoutLogin',
|
|
||||||
components: { Login },
|
|
||||||
setup() {
|
|
||||||
const { prefixCls } = useDesign('st-login');
|
|
||||||
const userStore = useUserStore();
|
|
||||||
const permissionStore = usePermissionStore();
|
|
||||||
const appStore = useAppStore();
|
|
||||||
const userId = ref<Nullable<number | string>>(0);
|
|
||||||
|
|
||||||
const isBackMode = () => {
|
const { prefixCls } = useDesign('st-login');
|
||||||
return appStore.getProjectConfig.permissionMode === PermissionModeEnum.BACK;
|
const userStore = useUserStore();
|
||||||
};
|
const permissionStore = usePermissionStore();
|
||||||
|
const appStore = useAppStore();
|
||||||
|
const userId = ref<Nullable<number | string>>(0);
|
||||||
|
|
||||||
onMounted(() => {
|
const isBackMode = () => {
|
||||||
// 记录当前的UserId
|
return appStore.getProjectConfig.permissionMode === PermissionModeEnum.BACK;
|
||||||
userId.value = userStore.getUserInfo?.userId;
|
};
|
||||||
console.log('Mounted', userStore.getUserInfo);
|
|
||||||
});
|
|
||||||
|
|
||||||
onBeforeUnmount(() => {
|
onMounted(() => {
|
||||||
if (userId.value && userId.value !== userStore.getUserInfo.userId) {
|
// 记录当前的UserId
|
||||||
// 登录的不是同一个用户,刷新整个页面以便丢弃之前用户的页面状态
|
userId.value = userStore.getUserInfo?.userId;
|
||||||
document.location.reload();
|
console.log('Mounted', userStore.getUserInfo);
|
||||||
} else if (isBackMode() && permissionStore.getLastBuildMenuTime === 0) {
|
});
|
||||||
// 后台权限模式下,没有成功加载过菜单,就重新加载整个页面。这通常发生在会话过期后按F5刷新整个页面后载入了本模块这种场景
|
|
||||||
document.location.reload();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
return { prefixCls };
|
onBeforeUnmount(() => {
|
||||||
},
|
if (userId.value && userId.value !== userStore.getUserInfo.userId) {
|
||||||
|
// 登录的不是同一个用户,刷新整个页面以便丢弃之前用户的页面状态
|
||||||
|
document.location.reload();
|
||||||
|
} else if (isBackMode() && permissionStore.getLastBuildMenuTime === 0) {
|
||||||
|
// 后台权限模式下,没有成功加载过菜单,就重新加载整个页面。这通常发生在会话过期后按F5刷新整个页面后载入了本模块这种场景
|
||||||
|
document.location.reload();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
<style lang="less" scoped>
|
<style lang="less" scoped>
|
||||||
|
@ -1,26 +1,19 @@
|
|||||||
<template>
|
<template>
|
||||||
<div></div>
|
<div></div>
|
||||||
</template>
|
</template>
|
||||||
<script lang="ts">
|
<script lang="ts" setup>
|
||||||
import { defineComponent, unref } from 'vue';
|
import { unref } from 'vue';
|
||||||
import { useRouter } from 'vue-router';
|
import { useRouter } from 'vue-router';
|
||||||
|
|
||||||
export default defineComponent({
|
const { currentRoute, replace } = useRouter();
|
||||||
name: 'Redirect',
|
|
||||||
setup() {
|
|
||||||
const { currentRoute, replace } = useRouter();
|
|
||||||
|
|
||||||
const { params, query } = unref(currentRoute);
|
const { params, query } = unref(currentRoute);
|
||||||
const { path } = params;
|
const { path } = params;
|
||||||
|
|
||||||
const _path = Array.isArray(path) ? path.join('/') : path;
|
const _path = Array.isArray(path) ? path.join('/') : path;
|
||||||
|
|
||||||
replace({
|
replace({
|
||||||
path: '/' + _path,
|
path: '/' + _path,
|
||||||
query,
|
query,
|
||||||
});
|
|
||||||
|
|
||||||
return {};
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
Loading…
Reference in New Issue
Block a user