Skip to content

Commit

Permalink
ESLint && Sytlelint (#1893)
Browse files Browse the repository at this point in the history
  • Loading branch information
yzygyin authored Aug 15, 2024
1 parent 2ceb914 commit 0c3d1eb
Show file tree
Hide file tree
Showing 73 changed files with 1,071 additions and 971 deletions.
4 changes: 4 additions & 0 deletions src/bk-login/pages/.bk.production.env
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,7 @@ BK_CSRF_COOKIE_NAME = '{{ CSRF_COOKIE_NAME }}'

BK_SHARED_RES_URL = '{{ BK_SHARED_RES_URL }}'

BK_COMPONENT_API_URL = '{{ BK_COMPONENT_API_URL }}'

BK_DOMAIN = '{{ BK_DOMAIN }}'

2 changes: 2 additions & 0 deletions src/bk-login/pages/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
var CSRF_COOKIE_NAME = '<%= process.env.BK_CSRF_COOKIE_NAME %>';
var ENABLE_BK_NOTICE = '<%= process.env.BK_ENABLE_BK_NOTICE %>';
var BK_SHARED_RES_URL = '<%= process.env.BK_SHARED_RES_URL %>';
var BK_COMPONENT_API_URL = '<%= process.env.BK_COMPONENT_API_URL %>';
var BK_DOMAIN = '<%= process.env.BK_DOMAIN %>';
</script>
<script src="<%= process.env.BK_STATIC_URL %>/js/particles.js"></script>
</body>
Expand Down
4 changes: 3 additions & 1 deletion src/bk-login/pages/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"dev": "bk-cli-service-webpack dev",
"build": "bk-cli-service-webpack build",
"server": "node ./paas-server/index.js",
"lint:style": "stylelint **/*.{html,vue,css,sass,scss,less} --fix"
"lint:style": "stylelint **/*.{html,vue,css,sass,scss,less} --fix",
"lint:fix": "eslint --fix --ext .js,.vue,.ts ./src"
},
"keywords": [
"bk-ci",
Expand All @@ -28,6 +29,7 @@
"pinia": "^2.0.23",
"request": "^2.88.2",
"vue": "^3.2.41",
"vue-dompurify-html": "^5.1.0",
"vue-i18n": "^9.9.0",
"vue-router": "^4.1.6"
},
Expand Down
42 changes: 21 additions & 21 deletions src/bk-login/pages/src/app.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
</div>
<div id="particles-js"></div>
<footer class="footer">
<p >
<span v-html="contact"></span>
<p>
<span v-dompurify-html="contact"></span>
<bk-popover theme="light" placement="bottom">
<a href="" target="_blank" class="link follow-us">
| {{ $t('关注我们') }}
| {{ $t('关注我们') }}
</a>
<template #content>
<span class="qr-box"><img class="qr" src="../static/images/qr.png" alt=""></span>
Expand All @@ -31,9 +31,9 @@
</template>

<script setup lang="ts">
import { onMounted, computed} from 'vue';
import { getPlatformConfig, setShortcutIcon, setDocumentTitle} from '@blueking/platform-config';
import {platformConfig} from '@/store/platformConfig';
import { onMounted, computed } from 'vue';
import { getPlatformConfig, setShortcutIcon, setDocumentTitle } from '@blueking/platform-config';
import { platformConfig } from '@/store/platformConfig';
onMounted(() => {
particlesJS(
Expand Down Expand Up @@ -158,23 +158,23 @@ onMounted(() => {
});
const platformConfigData = platformConfig();
const url = `${window.BK_SHARED_RES_URL}/bk_login/base.js` // url 远程配置文件地址
const url = `${window.BK_SHARED_RES_URL}/bk_login/base.js`; // url 远程配置文件地址
const defaults = {
name: '蓝鲸用户管理',
nameEn: 'BK USER',
brandName: '腾讯蓝鲸智云',
brandNameEn: 'BlueKing',
favicon: '/static/favicon.ico',
version: '3.0',
}
name: '登录',
nameEn: 'Login',
brandName: '蓝鲸智云',
brandNameEn: 'BlueKing',
version: '3.0',
};
const getConfigData = async() => {
const config = await getPlatformConfig(url, defaults)
setShortcutIcon(config.favicon);
setDocumentTitle(config.i18n);
platformConfigData.update(config);
}
getConfigData()
const getConfigData = async () => {
const config = await getPlatformConfig(url, defaults);
setShortcutIcon(config.favicon);
setDocumentTitle(config.i18n);
platformConfigData.update(config);
};
getConfigData();
const contact = computed(() => platformConfigData.i18n.footerInfoHTML);
const copyright = computed(() => platformConfigData.footerCopyrightContent);
</script>
Expand Down
4 changes: 2 additions & 2 deletions src/bk-login/pages/src/css/index.css
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
@import url(./main.css);
@import url(./reset.css);
@import './main.css';
@import './reset.css';
49 changes: 3 additions & 46 deletions src/bk-login/pages/src/css/reset.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*CSS Reset*/
/* CSS Reset */
html,
body,
div,
Expand All @@ -24,7 +24,6 @@ textarea,
p,
blockquote,
tr,

th,
td,
hgroup,
Expand All @@ -39,115 +38,74 @@ menu,
button,
applet,
object,

iframe,
a,
abbr,

acronym,

address,
big,

cite,

code,
del,

dfn,

em,

img,

ins,

kbd,

q,
s,

samp,
small,

strike,

strong,

sub,

sup,

tt,

var,
b,
u,

i,

center,
label,
table,

caption,

tbody,

tfoot,

thead,

canvas,

details,
embed,
main,

output,

ruby,

summary,
time,

mark,

audio,

video {
margin: 0;
padding: 0;
}

/* HTML5 display-role reset for older browsers */
article,

aside,

details,

figcaption,

figure,

footer,

hgroup,

menu,

nav,

section {
display: block;
}

body {
font-family: -apple-system,BlinkMacSystemFont,PingFang SC,Microsoft YaHei,Helvetica Neue,Arial,sans-serif;
font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Microsoft YaHei', 'Helvetica Neue', Arial, sans-serif;
line-height: 1.5;
font-size: 12px;
color: #63656E;
color: #63656e;
text-size-adjust: 100%;
-webkit-tap-highlight-color: transparent;
outline: 0;
Expand Down Expand Up @@ -209,7 +167,6 @@ select,
textarea {
box-sizing: content-box;
box-sizing: content-box;
box-sizing: content-box;
}

button {
Expand Down
2 changes: 2 additions & 0 deletions src/bk-login/pages/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import router from './router';
import App from './app.vue';
import './css/index.css';
import i18n from './language/index';
import VueDOMPurifyHTML from 'vue-dompurify-html';

// 全量引入 bkui-vue
import bkui from 'bkui-vue';
Expand All @@ -15,4 +16,5 @@ createApp(App)
.use(createPinia())
.use(bkui)
.use(i18n)
.use(VueDOMPurifyHTML)
.mount('.app');
4 changes: 2 additions & 2 deletions src/bk-login/pages/src/store/platformConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export const platformConfig = defineStore('platformConfig', {
}),
actions: {
update(value: any) {
this.$patch(value);
},
this.$patch(value);
},
},
});
43 changes: 22 additions & 21 deletions src/bk-login/pages/src/views/home.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<bk-form v-show="!isAdminShow" form-type="vertical" v-bkloading="{ loading }">
<div class="tenant-logo">
<img :src="appLogo"/>
<img :src="appLogo" />
</div>

<section v-if="!hasStorage && !loading">
Expand All @@ -23,10 +23,10 @@
:id="item.id"
:key="item.id"
:name="`${item.name} (${item.id})`">
<div class="options-show">
<span>{{ `${item.name} (${item.id})` }}</span>
<bk-tag v-if="inputTenant?.name" size="small">{{ $t('隐藏租户') }}</bk-tag>
</div>
<div class="options-show">
<span>{{ `${item.name} (${item.id})` }}</span>
<bk-tag v-if="inputTenant?.name" size="small">{{ $t('隐藏租户') }}</bk-tag>
</div>
</bk-option>
</bk-select>
<span v-if="inputTenant !== null && !inputTenant?.name">{{ $t('暂无匹配租户') }}</span>
Expand Down Expand Up @@ -98,7 +98,7 @@
:key="item.id"
@click="handleChangeStorageTenant(item)">
<span class="item-name">{{ item.name }} / {{ getUserGroupName(item) }}</span>
<close class="delete-icon" @click.stop="deleteStorageTenant(item)"/>
<close class="delete-icon" @click.stop="deleteStorageTenant(item)" />
</div>
<div class="add" @click="addTenant">{{ $t('其他租户或用户来源') }}</div>
</section>
Expand Down Expand Up @@ -156,7 +156,7 @@
</div>
<div class="language-switcher">
<div class="language-select" style="display: flex">
<p class="language-item" :class="{ active: activeTab === 'zh-cn' }" @click="handleSwitchLocale('zh-cn')">
<p class="language-item" :class="{ active: activeTab === 'zh-cn' }" @click="handleSwitchLocale('zh-cn')">
<span id="ch" class="text-active ">中文</span>
</p>
<p class="language-item " :class="{ active: activeTab === 'en' }" @click="handleSwitchLocale('en')">
Expand All @@ -177,7 +177,7 @@
<script setup lang="ts">
import { getGlobalSettings, getIdpList, getTenantList } from '@/http/api';
import { Transfer, Close} from 'bkui-vue/lib/icon';
import { Transfer, Close } from 'bkui-vue/lib/icon';
import { type Ref, onBeforeMount, ref, watch, computed } from 'vue';
import Password from './components/password.vue';
import Protocol from './components/protocol.vue';
Expand All @@ -186,10 +186,11 @@ import CustomLogin from './components/custom-login.vue';
import { platformConfig } from '@/store/platformConfig';
import I18n, { t } from '@/language/index';
import Cookies from 'js-cookie';
import logoPng from '../../static/images/blueking.png'
const platformConfigData = platformConfig()
const appLogo = computed(() => platformConfigData.appLogo);
const activeTab = ref(I18n.global.locale.value)
const platformConfigData = platformConfig();
const appLogo = computed(() => platformConfigData.appLogo ? platformConfigData.appLogo : logoPng);
const activeTab = ref(I18n.global.locale.value);
interface Item {
Expand Down Expand Up @@ -233,7 +234,7 @@ const inputTenant = ref(null);
* @param id 租户ID
*/
const handleTenantChange = async (id: string) => {
// 清空时清空输入租户名称
// 清空时清空输入租户名称
if (!id) {
inputTenant.value = null;
return;
Expand Down Expand Up @@ -454,7 +455,7 @@ const getUserGroupName = (tenant: Tenant) => {
if (userGroupId === tenant.id) {
return '本租户';
}
return userGroupId
return userGroupId;
};
/**
Expand All @@ -469,23 +470,23 @@ const deleteStorageTenant = (item: any) => {
const obj = storageTenantList.value.find(i => i.id === item.id);
tenantMap.value = Object.fromEntries(Object.entries(tenantMap.value).filter(([key]) => key !== obj.id));
localStorage.setItem('tenantMap', JSON.stringify(tenantMap.value));
}
};
const selectRef = ref()
const selectRef = ref();
/**
* 下拉框中的值展示
*/
const showOptions = computed(() => {
const options = inputTenant.value?.name ? [inputTenant.value]:allTenantList.value
inputTenant.value?.name && selectRef.value?.showPopover()
return options
})
const options = inputTenant.value?.name ? [inputTenant.value] : allTenantList.value;
inputTenant.value?.name && selectRef.value?.showPopover();
return options;
});
// 语言切换
const handleSwitchLocale = (locale: string) => {
activeTab.value = locale
activeTab.value = locale;
const api = `${window.BK_COMPONENT_API_URL}/api/c/compapi/v2/usermanage/fe_update_user_language/`;
const scriptId = 'jsonp-script';
const prevJsonpScript = document.getElementById(scriptId);
Expand All @@ -505,7 +506,7 @@ const handleSwitchLocale = (locale: string) => {
});
I18n.global.locale.value = locale as any;
document.querySelector('html')?.setAttribute('lang', locale);
// window.location.reload();
window.location.reload();
};
</script>
Expand Down
Loading

0 comments on commit 0c3d1eb

Please sign in to comment.