Skip to content

Commit 070f05b

Browse files
committed
stash
1 parent 3000316 commit 070f05b

File tree

16 files changed

+209
-62
lines changed

16 files changed

+209
-62
lines changed

locales/en-US.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@
4141
"what_this_is": "This program will guide you through installing the Rust programming language, with additional third party tools of your choice.",
4242
"custom_install_help": "Enter the value of each installation options, or just press 'Enter' key to use the default value.",
4343
"installation_path": "Installation path",
44-
"select_components_to_install": "Choose what components to install: (separated multiple options by spaces, required tools are automatically selected)",
44+
"select_components_to_install": "Select components to install",
45+
"select_components_cli_hint": "separated multiple options by spaces, required tools are automatically selected",
4546
"select_components_to_update": "Choose what components to update: (separated multiple options by spaces)",
4647
"select_components_to_remove": "Choose what components to remove: (separated multiple options by spaces)",
4748
"question_try_demo": "Do you want to try Rust with a demo project?",
@@ -121,9 +122,6 @@
121122
"package_source_missing_info": "One or more selected components require separated packages, you need to manually provide a path or link to install those.",
122123
"default_source_hint": "Note: If no input is provided and a default value exists, the default value will be used.",
123124
"question_package_source": "Enter the package source (path or url) for '%{tool}'",
124-
"install_default": "default",
125-
"install_everything": "everything",
126-
"install_custom": "customize",
127125

128126
"skip_ssl_check": "skip SSL certificate verification",
129127
"update_all": "Update all (including toolkit and toolkit manager)",

locales/zh-CN.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@
3939
"what_this_is": "该程序将指导您安装 Rust 编程语言以及其他可选的第三方工具。",
4040
"custom_install_help": "请根据提示输入安装选项,或直接按回车键使用默认的值。",
4141
"installation_path": "安装路径",
42-
"select_components_to_install": "请选择要安装的组件: (选择多个组件时请用空格键分隔;必要组件会自动添加,无需额外选择)",
42+
"select_components_to_install": "选择要安装的组件",
43+
"select_components_cli_hint": "选择多个组件时请用空格键分隔;必要组件会自动添加,无需额外选择",
4344
"select_components_to_update": "请选择要更新的组件: (选择多个组件时请用空格键分隔)",
4445
"select_components_to_remove": "请选择要卸载的组件: (选择多个组件时请用空格键分隔)",
4546
"question_try_demo": "是否要通过一个示例项目尝试 Rust 编程?",
@@ -117,9 +118,6 @@
117118
"package_source_missing_info": "一个或多个选定的组件需要额外配置安装包路径,您需要提供路径或链接来安装它们。",
118119
"default_source_hint": "注:如果未提供输入且存在默认值,则将使用默认值安装。",
119120
"question_package_source": "请输入 '%{tool}' 的安装包路径或链接",
120-
"install_default": "默认安装",
121-
"install_everything": "全量安装",
122-
"install_custom": "自定义组件选择",
123121

124122
"skip_ssl_check": "跳过 SSL 证书验证",
125123
"update_all": "全部更新 (包括套件及此管理工具)",

rim_gui/src-tauri/src/installer_mode.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ async fn load_manifest_and_ret_version() -> Result<String> {
115115
.clone()
116116
.unwrap_or_default())
117117
} else {
118+
debug!("manifest loaded");
118119
Ok(version)
119120
}
120121
}

rim_gui/src/components/BaseButton.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ const themeClasses = computed(() => {
4040
<style scoped>
4141
button {
4242
font-size: clamp(100%, 3vh, 20px);
43+
box-shadow: 0 0 0 2px rgba(255, 255, 255, .4);
4344
font-weight: bold;
4445
white-space: nowrap;
4546
overflow: hidden;
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
<template>
2+
<base-card overflow-auto>
3+
<div class="resizable-container" ref="container">
4+
<div class="panel left-panel" :style="{ width: leftWidth + 'px' }" ref="leftPanel">
5+
<slot name="left"></slot>
6+
</div>
7+
<div class="divider" @mousedown="startDrag"></div>
8+
<div class="panel right-panel" ref="rightPanel">
9+
<slot name="right"></slot>
10+
</div>
11+
</div>
12+
</base-card>
13+
</template>
14+
15+
<script setup lang="ts">
16+
import { ref, onUnmounted } from 'vue'
17+
18+
const container = ref<HTMLElement | null>(null)
19+
const leftPanel = ref<HTMLElement | null>(null)
20+
const leftWidth = ref(300)
21+
const minWidth = 100
22+
const isDragging = ref(false)
23+
24+
const startDrag = (e: MouseEvent) => {
25+
isDragging.value = true
26+
document.addEventListener('mousemove', onDrag)
27+
document.addEventListener('mouseup', stopDrag)
28+
e.preventDefault()
29+
}
30+
31+
const onDrag = (e: MouseEvent) => {
32+
if (!isDragging.value || !container.value) return
33+
34+
const containerRect = container.value.getBoundingClientRect()
35+
const newLeftWidth = Math.max(
36+
minWidth,
37+
Math.min(
38+
e.clientX - containerRect.left,
39+
containerRect.width - minWidth
40+
)
41+
)
42+
43+
leftWidth.value = newLeftWidth
44+
}
45+
46+
const stopDrag = () => {
47+
isDragging.value = false
48+
document.removeEventListener('mousemove', onDrag)
49+
document.removeEventListener('mouseup', stopDrag)
50+
}
51+
52+
// Cleanup event listeners
53+
onUnmounted(stopDrag)
54+
</script>
55+
56+
<style scoped>
57+
.resizable-container {
58+
display: flex;
59+
width: 100%;
60+
height: 100%;
61+
}
62+
63+
.panel {
64+
height: 100%;
65+
overflow: auto;
66+
box-sizing: border-box;
67+
}
68+
69+
.right-panel {
70+
flex: 1;
71+
padding-left: 2vw;
72+
}
73+
74+
.divider {
75+
width: 5px;
76+
background-color: rgba(255, 255, 255, 0.7);
77+
78+
cursor: col-resize;
79+
position: relative;
80+
transition: background-color 0.2s;
81+
}
82+
83+
.divider:hover,
84+
.divider:active {
85+
background-color: #aaa;
86+
}
87+
88+
.divider::before {
89+
content: '';
90+
position: absolute;
91+
top: 50%;
92+
left: 1px;
93+
right: 1px;
94+
height: 30px;
95+
margin-top: -15px;
96+
--uno: 'bg-primary'
97+
border-radius: 2px;
98+
}
99+
</style>

rim_gui/src/theme/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import Background from '@/components/Background.vue';
1313
import Inputton from '@/components/Inputton.vue';
1414
import PageNavButtons from '@/components/PageNavButtons.vue';
1515
import BaseDetails from '@/components/BaseDetails.vue';
16+
import SplitBox from '@/components/SplitBox.vue';
1617

1718
export default {
1819
install(app: App) {
@@ -30,5 +31,6 @@ export default {
3031
app.component('inputton', Inputton);
3132
app.component('page-nav-buttons', PageNavButtons);
3233
app.component('base-details', BaseDetails);
34+
app.component('split-box', SplitBox);
3335
},
3436
};

rim_gui/src/utils/common.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { installConf } from "./installConf";
2+
import { invokeCommand } from "./invokeCommand";
3+
import { RestrictedComponent } from "./types/Component";
4+
5+
/**
6+
* Handle the restricted components before installation,
7+
* as some components might need another package source.
8+
*
9+
* @param onDefault The default callback where there aren't any restricted components.
10+
* @param onRestricted Callback when restricted components detected in `installConf`.
11+
*/
12+
export function handleRestrictedComponents(onDefault: () => void, onRestricted: () => void) {
13+
invokeCommand('get_restricted_components', { components: installConf.getCheckedComponents() }).then((res) => {
14+
const restricted = res as RestrictedComponent[];
15+
if (restricted.length > 0) {
16+
installConf.setRestrictedComponents(restricted);
17+
onRestricted();
18+
} else {
19+
onDefault();
20+
}
21+
});
22+
}

rim_gui/src/utils/installConf.ts

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,12 @@ class InstallConf {
88
path: Ref<string>;
99
info: Ref<AppInfo | null> = ref(null);
1010
checkComponents: Ref<CheckItem<Component>[]>;
11-
isCustomInstall: boolean;
1211
version: Ref<string>;
1312
restrictedComponents: Ref<RestrictedComponent[]>;
1413

1514
constructor(path: string, components: CheckItem<Component>[]) {
1615
this.path = ref(path);
1716
this.checkComponents = ref(components);
18-
this.isCustomInstall = true;
1917
this.version = ref('');
2018
this.restrictedComponents = ref([]);
2119
}
@@ -48,10 +46,6 @@ class InstallConf {
4846
this.restrictedComponents.value = comps;
4947
}
5048

51-
setCustomInstall(isCustomInstall: boolean) {
52-
this.isCustomInstall = isCustomInstall;
53-
}
54-
5549
getGroups(): CheckGroup<Component>[] {
5650
const groups = this.checkComponents.value.reduce(
5751
(acc, item) => {
@@ -80,17 +74,20 @@ class InstallConf {
8074
return item.value as Component;
8175
});
8276
}
77+
78+
mapCheckedComponents(callback: (comp: CheckItem<Component>) => CheckItem<Component>) {
79+
this.checkComponents.value = this.checkComponents.value.map(callback)
80+
}
8381

8482
getRestrictedComponents(): RestrictedComponent[] {
8583
return this.restrictedComponents.value;
8684
}
8785

88-
loadManifest() {
89-
invokeCommand("load_manifest_and_ret_version").then((ver) => {
90-
if (typeof ver === 'string') {
91-
this.version.value = ver;
92-
}
93-
});
86+
async loadManifest() {
87+
const ver = await invokeCommand("load_manifest_and_ret_version");
88+
if (typeof ver === 'string') {
89+
this.version.value = ver;
90+
}
9491
}
9592

9693
async loadDefaultPath() {
@@ -122,8 +119,12 @@ class InstallConf {
122119
}
123120

124121
async loadAll() {
125-
await this.loadDefaultPath();
126-
await this.loadComponents();
122+
// make sure the manifest is loaded before loading components
123+
// as it requires the manifest to be loaded.
124+
this.loadManifest().then(async () => {
125+
await this.loadDefaultPath();
126+
await this.loadComponents();
127+
});
127128
}
128129
}
129130

rim_gui/src/utils/types/CheckBoxGroup.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { Component } from 'vue';
33
export interface CheckItem<T> {
44
label: string;
55
checked: boolean;
6-
required?: boolean;
76
disabled?: boolean;
87
value: T;
98
}

rim_gui/src/views/installer/ComponentsView.vue

Lines changed: 30 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<script setup lang="ts">
22
import { computed, onMounted, Ref, ref, watch } from 'vue';
3-
import { componentUtils, installConf } from '@/utils/index';
3+
import { componentUtils, installConf, invokeLabelList } from '@/utils/index';
44
import type {
55
CheckGroup,
66
CheckGroupItem,
@@ -9,8 +9,10 @@ import type {
99
} from '@/utils/index';
1010
import { useCustomRouter } from '@/router/index';
1111
import CheckBoxGroup from '@/components/CheckBoxGroup.vue';
12+
import { handleRestrictedComponents } from '@/utils/common';
1213
13-
const { routerBack } = useCustomRouter();
14+
const { routerBack, routerPush } = useCustomRouter();
15+
const labels = ref<Record<string, string>>({});
1416
const selectComponentId = ref(0);
1517
1618
const groupComponents: Ref<CheckGroup<Component>[]> = ref([]);
@@ -49,7 +51,6 @@ function updateInstallConf() {
4951
label: item.label,
5052
checked: item.checked,
5153
disabled: item.disabled,
52-
required: item.required,
5354
value: { ...item.value },
5455
};
5556
})
@@ -110,20 +111,35 @@ function handleSelectAll() {
110111
111112
function handleNextClick() {
112113
updateInstallConf();
113-
routerBack();
114+
handleRestrictedComponents(
115+
() => routerPush('/installer/confirmation'),
116+
() => routerPush('/installer/customize_package_sources'),
117+
);
114118
}
115119
116120
onMounted(() => {
117121
groupComponents.value = installConf.getGroups();
122+
123+
invokeLabelList(['select_components_to_install']).then((res) => {
124+
labels.value = res;
125+
});
118126
});
119127
</script>
120128

121129
<template>
122130
<div flex="~ col" w="full" h="full">
123-
<h4 ml="12px">安装选项</h4>
124-
<div flex="1 ~" p="12px" overflow="auto">
131+
<span class="info-label">{{ labels.select_components_to_install }}</span>
132+
<!-- <div flex="1 ~" p="12px" mb="7%" overflow="auto">
125133
<base-card overflow-auto p="4px" grow="1">
126-
<div p="t-8px l-8px">组件</div>
134+
135+
</base-card>
136+
<base-card overflow-auto basis="200px" grow="3" ml="12px">
137+
138+
</base-card>
139+
</div> -->
140+
<split-box flex="1 ~" mt="1.5%" mb="10vh">
141+
<template #left>
142+
<span>组件</span>
127143
<div ml="1.5rem">
128144
<base-check-box flex="~ items-center" v-model="checkedAllBundle" title="全选">
129145
<template #icon>
@@ -137,17 +153,15 @@ onMounted(() => {
137153

138154
<check-box-group v-for="group of groupComponents" :key="group.label" :group="group" expand
139155
@itemClick="handleComponentsClick" @change="handleComponentsChange" />
140-
</base-card>
141-
<base-card basis="200px" grow="4" ml="12px">
142-
<div>组件详细信息</div>
156+
</template>
157+
158+
<template #right>
159+
<span>组件详细信息</span>
143160
<p font="b">{{ curCheckComponent?.value.displayName }}</p>
144161
<p>{{ curCheckComponent?.value.desc }}</p>
145-
</base-card>
146-
</div>
162+
</template>
163+
</split-box>
147164

148-
<div basis="60px" flex="~ justify-end items-center">
149-
<base-button theme="primary" mr="12px" @click="routerBack">上一步</base-button>
150-
<base-button theme="primary" mr="12px" @click="handleNextClick">下一步</base-button>
151-
</div>
165+
<page-nav-buttons @back-clicked="routerBack" @next-clicked="handleNextClick" />
152166
</div>
153167
</template>

0 commit comments

Comments
 (0)