|
@@ -1,41 +1,57 @@
|
|
|
<template>
|
|
|
<div id="homeIndex">
|
|
|
<el-row>
|
|
|
- <el-col :span="24" class="main animate__animated animate__backInRight">
|
|
|
- <el-col :span="12" class="one">
|
|
|
- <cForm :span="24" :fields="formFields" :form="form" :rules="rules" @save="onSubmit"></cForm>
|
|
|
+ <el-col :span="24" class="main animate__animated animate__backInRight" v-loading="loading">
|
|
|
+ <el-col :span="24" class="one">
|
|
|
+ <el-button type="primary" v-for="i in list" :key="i._id" @click="toPath(i)">{{ i.name }}</el-button>
|
|
|
</el-col>
|
|
|
</el-col>
|
|
|
</el-row>
|
|
|
</div>
|
|
|
</template>
|
|
|
+
|
|
|
<script setup lang="ts">
|
|
|
-import type { FormRules } from 'element-plus';
|
|
|
+// 基础
|
|
|
import type { Ref } from 'vue';
|
|
|
-import { ref, reactive, onMounted } from 'vue';
|
|
|
import { ElMessage } from 'element-plus';
|
|
|
-import { AdminStore } from '@common/src/stores/admins/admin'; // 角色
|
|
|
-import type { IQueryResult } from '@/util/types.util';
|
|
|
-const admin = AdminStore();
|
|
|
-let form: Ref<any> = ref({});
|
|
|
-// 表单
|
|
|
-let formFields: Ref<any[]> = ref([
|
|
|
- { label: '账号', model: 'account' },
|
|
|
- { label: '密码', model: 'password' }
|
|
|
-]);
|
|
|
-const rules = reactive<FormRules>({});
|
|
|
+import { onMounted, ref } from 'vue';
|
|
|
+import { useRouter } from 'vue-router';
|
|
|
+// 接口
|
|
|
+import { ModuleStore } from '@common/src/stores/system/module';
|
|
|
+import { MenusStore } from '@common/src/stores/system/menus';
|
|
|
+import type { IQueryResult } from '@/util/types.util'; //
|
|
|
+const moduleAxios = ModuleStore();
|
|
|
+const menusAxios = MenusStore();
|
|
|
+
|
|
|
+// 路由
|
|
|
+const router = useRouter();
|
|
|
+// 加载中
|
|
|
+const loading: Ref<any> = ref(false);
|
|
|
+
|
|
|
+const list: Ref<any> = ref([]);
|
|
|
+
|
|
|
+// 请求
|
|
|
onMounted(async () => {
|
|
|
+ loading.value = true;
|
|
|
await search();
|
|
|
+ loading.value = false;
|
|
|
});
|
|
|
-const search = async () => {};
|
|
|
-// 提交
|
|
|
-const onSubmit = async (data) => {
|
|
|
- let res: IQueryResult = await admin.login(data);
|
|
|
- if (res.errcode == 0) {
|
|
|
- ElMessage({ type: `success`, message: `登陆成功` });
|
|
|
- localStorage.setItem('token', `${res.data}`);
|
|
|
- console.log(res.data);
|
|
|
+const search = async () => {
|
|
|
+ let name = import.meta.env.VITE_APP_ROUTER;
|
|
|
+ const res: IQueryResult = await moduleAxios.query({ name: name, is_use: '0' });
|
|
|
+ if (res && res.errcode == '0') {
|
|
|
+ if (res.total > 0) {
|
|
|
+ let moduleInfo = res.data[0];
|
|
|
+ let menusInfo: IQueryResult = await menusAxios.query({ module_id: moduleInfo._id });
|
|
|
+ if (res.errcode == '0') list.value = menusInfo.data;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ ElMessage({ message: `${res.errmsg}`, type: 'error' });
|
|
|
}
|
|
|
};
|
|
|
+const toPath = (e) => {
|
|
|
+ console.log(e.path);
|
|
|
+ router.push({ path: `${e.path}` });
|
|
|
+};
|
|
|
</script>
|
|
|
<style scoped lang="scss"></style>
|