File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1010 >
1111 <n-tab-pane name =" signin" tab =" 编辑" >
1212 <n-form >
13- <n-form-item-row label =" 用户名 " >
13+ <n-form-item-row label =" 接口名称 " >
1414 <n-input />
1515 </n-form-item-row >
16- <n-form-item-row label =" 密码 " >
16+ <n-form-item-row label =" url " >
1717 <n-input />
1818 </n-form-item-row >
1919 </n-form >
20- <n-button type =" primary" block secondary strong > 登录 </n-button >
20+ <n-button type =" primary" block secondary strong > 接口名称 </n-button >
2121 </n-tab-pane >
22- <n-tab-pane name =" signup" tab =" 编辑 " >
22+ <n-tab-pane name =" signup" tab =" 预览 " >
2323 <n-form >
24- <n-form-item-row label =" 用户名 " >
24+ <n-form-item-row label =" 接口名称 " >
2525 <n-input />
2626 </n-form-item-row >
27- <n-form-item-row label =" 密码" >
28- <n-input />
29- </n-form-item-row >
30- <n-form-item-row label =" 重复密码" >
27+ <n-form-item-row label =" url" >
3128 <n-input />
3229 </n-form-item-row >
3330 </n-form >
3835</template >
3936
4037<script setup lang="ts">
38+ import { ref , onMounted , watch } from ' vue' ;
39+ import type { tMockItem , tMockProject } from ' ~/electron/utils/mock/types' ;
40+
41+ interface Props {
42+ id: number ;
43+ project: tMockProject | null ;
44+ }
45+ const props = defineProps <Props >();
46+
47+ const mockData = ref <tMockItem >();
48+
49+ const fetchData = () => {
50+ const { id, project } = props ;
51+ const data = project ?.mockList .find ((m : tMockItem ) => m .id === id );
52+ if (data ) {
53+ mockData .value = data ;
54+ }
55+ };
56+ watch (
57+ () => props .project ,
58+ () => {
59+ fetchData ();
60+ }
61+ );
62+ onMounted (() => {
63+ fetchData ();
64+ });
4165 </script >
4266
4367<style scoped></style >
Original file line number Diff line number Diff line change 3232 :mock-list =" project?.mockList || []"
3333 :base-url =" project?.config?.baseUrl || ''"
3434 />
35- <ApiDetail v-else />
35+ <ApiDetail v-else :id = " mockId " :project = " project " />
3636 </n-layout >
3737 </n-layout >
3838 </n-layout >
@@ -56,15 +56,16 @@ const { routerPush } = useRouterPush();
5656const route = useRoute ();
5757const id = Number (route .query ?.id );
5858const menuValue = ref (' api-list' );
59- // eslint-disable-next-line @typescript-eslint/ban-types
6059const project = ref <tMockProject | null >(null );
60+ const mockId = ref (0 );
6161
6262const { iconRender } = useIconRender ();
6363
6464const options = computed <any []>(() => {
6565 const baseItem = {
6666 label: ' 全部接口' ,
6767 key: ' api-list' ,
68+ id: 0 ,
6869 icon: iconRender ({ icon: ' vscode-icons:default-folder-opened' })
6970 };
7071 const list =
@@ -87,8 +88,11 @@ const fetchData = async () => {
8788const handleToProjects = () => {
8889 routerPush ({ name: routeName (' mock_projects' ) });
8990};
90- const handleUpdateValue = (key : string ) => {
91+ const handleUpdateValue = (key : string , item : any ) => {
9192 menuValue .value = key ;
93+ if (item .id ) {
94+ mockId .value = item .id ;
95+ }
9296};
9397const handleAddMock = async () => {
9498 try {
@@ -101,7 +105,7 @@ const handleAddMock = async () => {
101105 createdAt: new Date ().getTime (),
102106 data: {
103107 code: 200 ,
104- msg: ' holle ' ,
108+ msg: ' test ' ,
105109 data: {
106110 ' list|1-10' : [
107111 {
You can’t perform that action at this time.
0 commit comments