vibe-web-sdk 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,310 @@
1
+ <template>
2
+ <div class="navbar-self" v-show="flag">
3
+ <div class="navbar-wrapper">
4
+ <div class="header-container">
5
+ <div class="logo-container" style="cursor:pointer" @click="handleLogoClick">
6
+ <img v-if="logo == null" class="logo" src="../../assets/images/logo.png" alt="Element Plus Logo" />
7
+ <img v-else class="logo" :src="logo" alt="Element Plus Logo" />
8
+ <span>E-NOESIS</span>
9
+ </div>
10
+ <div class="content-container">
11
+ <div>
12
+ <img v-if="isDark" src="../../assets/images/moon.png" @click="handleImgClick" style="height:20px;padding-right:20px;cursor:pointer" />
13
+ <img v-else src="../../assets/images/sun.png" @click="handleImgClick" style="height:20px;padding-right:20px;cursor:pointer" />
14
+ </div>
15
+ <el-dropdown trigger="click" style="margin-right: 20px; cursor: pointer">
16
+ <span class="el-dropdown-link">
17
+ <div class="language-selector">
18
+ <img v-if="currentLang === 'zh-CN'" src="../../assets/images/flags/cn.svg"
19
+ class="flag-icon" alt="Chinese" />
20
+ <img v-else-if="currentLang === 'de-DE'" src="../../assets/images/flags/de.svg"
21
+ class="flag-icon" alt="German" />
22
+ <img v-if="currentLang === 'en-US'" src="../../assets/images/flags/gb.svg"
23
+ class="flag-icon" alt="English" />
24
+ </div>
25
+ </span>
26
+ <template #dropdown>
27
+ <el-dropdown-menu style="color: #6e8992">
28
+ <el-dropdown-item v-for="item in languages" :key="item.value"
29
+ @click="changeLang(item.value)">
30
+ <div class="language-item">
31
+ <img v-if="item.value === 'zh-CN'" src="../../assets/images/flags/cn.svg"
32
+ class="flag-icon-small" alt="Chinese" />
33
+ <img v-else-if="item.value === 'de-DE'" src="../../assets/images/flags/de.svg"
34
+ class="flag-icon-small" alt="German" />
35
+ <img v-else-if="item.value === 'en-US'" src="../../assets/images/flags/gb.svg"
36
+ class="flag-icon-small" alt="English" />
37
+ <span style="margin-left: 8px;">{{ item.label }}</span>
38
+ </div>
39
+ </el-dropdown-item>
40
+ </el-dropdown-menu>
41
+ </template>
42
+ </el-dropdown>
43
+ <div style="display:flex">
44
+ <el-dropdown trigger="click" style="cursor: pointer;color:#6e8992">
45
+ <span class="el-dropdown-link">
46
+ <el-icon size="24">
47
+ <User />
48
+ </el-icon>
49
+ </span>
50
+
51
+ <template #dropdown>
52
+ <el-dropdown-menu style="color:#6e8992">
53
+ <el-dropdown-item @click="loginOut">{{
54
+ logoutLabel}}</el-dropdown-item>
55
+ </el-dropdown-menu>
56
+ </template>
57
+ </el-dropdown>
58
+ </div>
59
+ <div>
60
+ <div style="color: #6e8992;"> {{ userName }} </div>
61
+ <div v-if="isProd"
62
+ style="overflow: hidden;text-overflow: ellipsis;white-space: nowrap;font-size: 10px; color:#6e8992">
63
+ {{ currentUser.deptName }}</div>
64
+ </div>
65
+ </div>
66
+ </div>
67
+ </div>
68
+ </div>
69
+ </template>
70
+
71
+
72
+
73
+ <script>
74
+ import {
75
+ useDark,
76
+ useToggle
77
+ } from "@vueuse/core";
78
+ import {
79
+ mapGetters
80
+ } from "vuex";
81
+ import {
82
+ logout
83
+ } from "../../api/login";
84
+ import en from "../../lang/en";
85
+ import zh from "../../lang/zh";
86
+ import {
87
+ getToken,
88
+ removeToken
89
+ } from "../../utils/auth";
90
+ import {
91
+ getLanguages,
92
+ getPlatFormLogo
93
+ } from "../../api/application/index";
94
+
95
+ export default {
96
+ name: "self-header",
97
+ data() {
98
+ return {
99
+ logo: null,
100
+ languages: [],
101
+ flag: true,
102
+ isDark: useDark({
103
+ selector: "body",
104
+ attribute: "color-scheme",
105
+ valueDark: "dark",
106
+ valueLight: "light",
107
+ }),
108
+ logoutLabel: "",
109
+ currentLang: localStorage.getItem('locale') || 'zh-CN',
110
+ };
111
+ },
112
+ computed: {
113
+ ...mapGetters(["userName"]),
114
+ currentUser() {
115
+ return JSON.parse(this.$store.state.user.user);
116
+ },
117
+ // 是否为生产环境
118
+ isProd() {
119
+ return process.env.VUE_APP_PROJECT_DEV !== "true" || process.env.VUE_APP_PROJECT_DEV === undefined;
120
+ },
121
+ logo() {
122
+ return localStorage.getItem("frame_logo") === "null" ? null : localStorage.getItem("frame_logo");
123
+ }
124
+ },
125
+ created() {
126
+ // 非调试模式下,未登录,跳转到登录页
127
+ if (getToken() === undefined && this.flag) {
128
+ if (process.env.VUE_APP_PROJECT_DEV === "false" || process.env.VUE_APP_PROJECT_DEV === undefined) {
129
+ self.location.href = "/home#/login";
130
+ }
131
+ } else {
132
+ getLanguages().then((response) => {
133
+ if (response.code === 200) {
134
+ this.languages = [];
135
+ response.rows.forEach((element) => {
136
+ this.languages.push({
137
+ label: element.remark,
138
+ value: element.type,
139
+ });
140
+ });
141
+ }
142
+ });
143
+ }
144
+ if (this.$store.state.user.language === "en-US") {
145
+ this.languageLabel = en.headerLanguage;
146
+ this.logoutLabel = en.logoutLabel;
147
+ } else if (this.$store.state.user.language === "zh-CN") {
148
+ this.languageLabel = zh.headerLanguage;
149
+ this.logoutLabel = zh.logoutLabel;
150
+ } else {
151
+ this.languageLabel = zh.headerLanguage;
152
+ this.logoutLabel = zh.logoutLabel;
153
+ }
154
+ this.getPlatFormLogo();
155
+ },
156
+ methods: {
157
+ handleImgClick(){
158
+ this.isDark = !this.isDark;
159
+ this.toggleDark();
160
+ },
161
+ getPlatFormLogo() {
162
+ getPlatFormLogo().then((res) => {
163
+ if (res.data == null) {
164
+ localStorage.setItem("frame_logo", null);
165
+ } else {
166
+ localStorage.setItem("frame_logo", res.data.fileContent);
167
+ }
168
+ });
169
+ },
170
+ toggleDark:useToggle(useDark()),
171
+ handleLogoClick(){
172
+ self.location.href = "/home";
173
+ },
174
+ loginOut() {
175
+ logout().then(() => {
176
+ removeToken();
177
+ self.location.href = "/home#/login";
178
+ });
179
+ },
180
+ changeLang(val) {
181
+ if (val === "en-US") {
182
+ this.languageLabel = en.headerLanguage;
183
+ this.logoutLabel = en.logoutLabel;
184
+ } else if (val === "zh-CN") {
185
+ this.languageLabel = zh.headerLanguage;
186
+ this.logoutLabel = zh.logoutLabel;
187
+ }
188
+ window.location.reload();
189
+ this.$i18n.locale = val;
190
+ this.$store.dispatch("SwitchLanguage", val);
191
+ },
192
+ },
193
+ watch: {
194
+ $route(to) {
195
+ if (to.path.includes("/login")) {
196
+ this.flag = false;
197
+ } else {
198
+ this.flag = true;
199
+ }
200
+ },
201
+ },
202
+ };
203
+ </script>
204
+
205
+
206
+ <style scoped>
207
+ .navbar-self {
208
+ position: sticky;
209
+ width: 100%;
210
+ z-index: 100;
211
+ top: 0;
212
+ left: 0;
213
+ }
214
+
215
+ .navbar-wrapper {
216
+ position: relative;
217
+ height: var(--header-height);
218
+ padding: 0 12px 0 12px;
219
+ background-image: radial-gradient(transparent 1px, var(--bg-color) 1px);
220
+ background-size: 4px 4px;
221
+ backdrop-filter: saturate(50%) blur(4px);
222
+ -webkit-backdrop-filter: saturate(50%) blur(4px);
223
+ top: 0;
224
+ border-bottom: 1px solid #dcdfe6;
225
+ }
226
+
227
+ .dark .navbar-wrapper {
228
+ position: relative;
229
+ height: var(--header-height);
230
+ padding: 0 12px 0 12px;
231
+ background-image: radial-gradient(transparent 1px, var(--bg-color) 1px);
232
+ background-size: 4px 4px;
233
+ backdrop-filter: saturate(50%) blur(4px);
234
+ -webkit-backdrop-filter: saturate(50%) blur(4px);
235
+ top: 0;
236
+ border-bottom: 1px solid #121a22;
237
+ background: #121a22 !important;
238
+ }
239
+
240
+ .navbar-wrapper .header-container {
241
+ display: flex;
242
+ justify-content: space-between;
243
+ margin: 0 auto;
244
+ max-width: 1650px;
245
+ }
246
+
247
+ .logo-container {
248
+ display: flex;
249
+ align-items: center;
250
+ height: var(--header-height);
251
+ font-family: futura, sans-serif;
252
+ --tw-text-opacity: 1;
253
+ color: rgb(85 191 226 / var(--tw-text-opacity, 1));
254
+ letter-spacing: .1em;
255
+ gap: .75rem;
256
+ font-weight: 700;
257
+ align-items: center;
258
+
259
+
260
+ }
261
+
262
+ .navbar-wrapper .header-container .content-container {
263
+ display: flex;
264
+ justify-content: flex-end;
265
+ align-items: center;
266
+ flex-grow: 1;
267
+ height: 45px;
268
+ }
269
+
270
+ .logo-container>img {
271
+ height: 32px;
272
+ width: 32px;
273
+ }
274
+
275
+ /* Modern switch styles */
276
+ .modern-switch {
277
+ margin-right: 20px;
278
+ --el-switch-on-color: #dcdfe6;
279
+ --el-switch-off-color: #dcdfe6;
280
+ }
281
+
282
+ .dark .modern-switch {
283
+ --el-switch-on-color: #2c3e50;
284
+ --el-switch-off-color: #2c3e50;
285
+ }
286
+
287
+ /* Language selector styles */
288
+ .language-selector {
289
+ display: flex;
290
+ align-items: center;
291
+ }
292
+
293
+ .flag-icon {
294
+ width: 20px;
295
+ height: 15px;
296
+ object-fit: cover;
297
+ }
298
+
299
+ .flag-icon-small {
300
+ width: 16px;
301
+ height: 12px;
302
+ border-radius: 2px;
303
+ object-fit: cover;
304
+ }
305
+
306
+ .language-item {
307
+ display: flex;
308
+ align-items: center;
309
+ }
310
+ </style>