mirror of
https://github.com/m-xlsea/ruoyi-plus-soybean.git
synced 2025-09-24 07:49:47 +08:00
feat: 完成代码生成模板(1.0)
This commit is contained in:
@ -1,7 +1,9 @@
|
||||
<script setup lang="ts">
|
||||
import { createTextVNode, defineComponent } from 'vue';
|
||||
import { createTextVNode, defineComponent, onMounted } from 'vue';
|
||||
import { useDialog, useLoadingBar, useMessage, useNotification } from 'naive-ui';
|
||||
import useContentLoading from '@/hooks/common/loading';
|
||||
import { initWebSocket } from '@/utils/websocket';
|
||||
import { initSSE } from '@/utils/sse';
|
||||
|
||||
defineOptions({
|
||||
name: 'AppProvider'
|
||||
@ -25,6 +27,12 @@ const ContextHolder = defineComponent({
|
||||
return () => createTextVNode();
|
||||
}
|
||||
});
|
||||
|
||||
onMounted(() => {
|
||||
const protocol = window.location.protocol === 'https:' ? 'wss://' : 'ws://';
|
||||
initWebSocket(`${protocol + window.location.host + import.meta.env.VITE_APP_BASE_API}/resource/websocket`);
|
||||
initSSE(`${import.meta.env.VITE_APP_BASE_API}/resource/sse`);
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
@ -1,9 +1,11 @@
|
||||
import { ref } from 'vue';
|
||||
import { ref, watch } from 'vue';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { fetchGetDictDataByType } from '@/service/api/system';
|
||||
import { useDictStore } from '@/store/modules/dict';
|
||||
|
||||
export function useDict(dictType: string, immediate: boolean = true) {
|
||||
const dictStore = useDictStore();
|
||||
const { dictData: dictList } = storeToRefs(dictStore);
|
||||
|
||||
const data = ref<Api.System.DictData[]>([]);
|
||||
const record = ref<Record<string, string>>({});
|
||||
@ -43,6 +45,17 @@ export function useDict(dictType: string, immediate: boolean = true) {
|
||||
getRecord();
|
||||
getOptions();
|
||||
});
|
||||
} else {
|
||||
watch(
|
||||
() => dictList.value[dictType],
|
||||
val => {
|
||||
if (val && val.length) {
|
||||
getRecord();
|
||||
getOptions();
|
||||
}
|
||||
},
|
||||
{ immediate: true }
|
||||
);
|
||||
}
|
||||
|
||||
return {
|
||||
|
@ -1,11 +1,9 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, defineAsyncComponent, onMounted } from 'vue';
|
||||
import { computed, defineAsyncComponent } from 'vue';
|
||||
import { AdminLayout, LAYOUT_SCROLL_EL_ID } from '@sa/materials';
|
||||
import type { LayoutMode } from '@sa/materials';
|
||||
import { useAppStore } from '@/store/modules/app';
|
||||
import { useThemeStore } from '@/store/modules/theme';
|
||||
import { initWebSocket } from '@/utils/websocket';
|
||||
import { initSSE } from '@/utils/sse';
|
||||
import GlobalHeader from '../modules/global-header/index.vue';
|
||||
import GlobalSider from '../modules/global-sider/index.vue';
|
||||
import GlobalTab from '../modules/global-tab/index.vue';
|
||||
@ -102,12 +100,6 @@ function getSiderCollapsedWidth() {
|
||||
|
||||
return w;
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
const protocol = window.location.protocol === 'https:' ? 'wss://' : 'ws://';
|
||||
initWebSocket(`${protocol + window.location.host + import.meta.env.VITE_APP_BASE_API}/resource/websocket`);
|
||||
initSSE(`${import.meta.env.VITE_APP_BASE_API}/resource/sse`);
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
7
src/typings/api/api.d.ts
vendored
7
src/typings/api/api.d.ts
vendored
@ -21,7 +21,12 @@ declare namespace Api {
|
||||
}
|
||||
|
||||
/** common search params of table */
|
||||
type CommonSearchParams = Pick<Common.PaginatingCommonParams, 'pageNum' | 'pageSize'>;
|
||||
type CommonSearchParams<T = any> = Pick<Common.PaginatingCommonParams, 'pageNum' | 'pageSize'> &
|
||||
CommonType.RecordNullable<{
|
||||
orderByColumn: keyof T;
|
||||
isAsc: 'asc' | 'desc';
|
||||
params: { [key: string]: any };
|
||||
}>;
|
||||
|
||||
/**
|
||||
* 启用状态
|
||||
|
6
src/typings/api/system.api.d.ts
vendored
6
src/typings/api/system.api.d.ts
vendored
@ -10,8 +10,6 @@ declare namespace Api {
|
||||
* backend api module: "system"
|
||||
*/
|
||||
namespace System {
|
||||
type CommonSearchParams = Pick<Common.PaginatingCommonParams, 'pageNum' | 'pageSize'>;
|
||||
|
||||
/** role */
|
||||
type Role = Common.CommonRecord<{
|
||||
/** 数据范围(1:全部数据权限 2:自定数据权限 3:本部门数据权限 4:本部门及以下数据权限) */
|
||||
@ -40,7 +38,7 @@ declare namespace Api {
|
||||
|
||||
/** role search params */
|
||||
type RoleSearchParams = CommonType.RecordNullable<
|
||||
Pick<Role, 'roleName' | 'roleKey' | 'status'> & CommonSearchParams
|
||||
Pick<Role, 'roleName' | 'roleKey' | 'status'> & Common.CommonSearchParams<Role>
|
||||
>;
|
||||
|
||||
/** role list */
|
||||
@ -93,7 +91,7 @@ declare namespace Api {
|
||||
|
||||
/** user search params */
|
||||
type UserSearchParams = CommonType.RecordNullable<
|
||||
Pick<User, 'userName' | 'sex' | 'nickName' | 'phonenumber' | 'email' | 'status'> & CommonSearchParams
|
||||
Pick<User, 'userName' | 'sex' | 'nickName' | 'phonenumber' | 'email' | 'status'> & Common.CommonSearchParams<User>
|
||||
>;
|
||||
|
||||
/** user list */
|
||||
|
@ -40,8 +40,8 @@ const visible = defineModel<boolean>('visible', {
|
||||
default: false
|
||||
});
|
||||
|
||||
const { options: showHideOptions, getOptions: getShowHideOptions } = useDict('sys_show_hide', false);
|
||||
const { options: enableStatusOptions, getOptions: getNormalDisableOptions } = useDict('sys_normal_disable', false);
|
||||
const { options: showHideOptions } = useDict('sys_show_hide', false);
|
||||
const { options: enableStatusOptions } = useDict('sys_normal_disable');
|
||||
|
||||
const iconType = ref<Api.System.IconType>('1');
|
||||
const { formRef, validate, restoreValidation } = useNaiveForm();
|
||||
@ -217,9 +217,6 @@ watch(visible, () => {
|
||||
if (visible.value) {
|
||||
handleInitModel();
|
||||
restoreValidation();
|
||||
getShowHideOptions();
|
||||
getShowHideOptions();
|
||||
getNormalDisableOptions();
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -70,7 +70,9 @@ const genMap: Api.Tool.GenTablePreview = {
|
||||
'vm/sql/sql.vm': 'sql',
|
||||
'vm/soybean/api/soy.api.ts.vm': 'api.ts',
|
||||
'vm/soybean/typings/soy.api.d.ts.vm': 'type.d.ts',
|
||||
'vm/soybean/soy.index.vue.vm': 'index.vue'
|
||||
'vm/soybean/soy.index.vue.vm': 'index.vue',
|
||||
'vm/soybean/modules/soy.search.vue.vm': 'search.vue',
|
||||
'vm/soybean/modules/soy.operate-drawer.vue.vm': 'operate-drawer.vue'
|
||||
};
|
||||
|
||||
function getGenLanguage(name: string) {
|
||||
|
Reference in New Issue
Block a user