repo_name string | dataset string | owner string | lang string | func_name string | code string | docstring string | url string | sha string |
|---|---|---|---|---|---|---|---|---|
my-fingerprint | github_2023 | omegaee | typescript | getSeedByMode | const getSeedByMode = (storage: LocalStorageObject, mode: HookMode) => {
switch (mode?.type) {
case HookType.browser:
return storage.config.browserSeed
case HookType.global:
return storage.config.customSeed
default:
return undefined
}
} | /**
* 获取seed
*/ | https://github.com/omegaee/my-fingerprint/blob/5177a7f0e061bef5ca76e08cd4aa5e9ecf61ff04/src/background/index.ts#L129-L138 | 5177a7f0e061bef5ca76e08cd4aa5e9ecf61ff04 |
my-fingerprint | github_2023 | omegaee | typescript | refreshRequestHeader | const refreshRequestHeader = async () => {
const storage = await getLocalStorage()
const options: chrome.declarativeNetRequest.UpdateRuleOptions = {
removeRuleIds: [UA_NET_RULE_ID],
}
if (!storage.config.enable || !storage.config.hookNetRequest) {
chrome.declarativeNetRequest.updateSessionRules(option... | /**
* 刷新请求头UA
*/ | https://github.com/omegaee/my-fingerprint/blob/5177a7f0e061bef5ca76e08cd4aa5e9ecf61ff04/src/background/index.ts#L143-L228 | 5177a7f0e061bef5ca76e08cd4aa5e9ecf61ff04 |
my-fingerprint | github_2023 | omegaee | typescript | updateLocalConfig | const updateLocalConfig = async (config: DeepPartial<LocalStorageConfig>) => {
const storage = await getLocalStorage()
storage.config = deepmerge<LocalStorageConfig, DeepPartial<LocalStorageConfig>>(
storage.config,
config,
{ arrayMerge: (destinationArray, sourceArray, options) => sourceArray },
)
s... | /**
* 修改配置
*/ | https://github.com/omegaee/my-fingerprint/blob/5177a7f0e061bef5ca76e08cd4aa5e9ecf61ff04/src/background/index.ts#L247-L263 | 5177a7f0e061bef5ca76e08cd4aa5e9ecf61ff04 |
my-fingerprint | github_2023 | omegaee | typescript | updateLocalWhitelist | const updateLocalWhitelist = async (type: 'add' | 'del', host: string | string[]) => {
const storage = await getLocalStorage()
if (Array.isArray(host)) {
if (type === 'add') {
for (const hh of host) {
storage.whitelist.add(hh)
}
} else if (type === 'del') {
for (const hh of host) {... | /**
* 修改白名单
*/ | https://github.com/omegaee/my-fingerprint/blob/5177a7f0e061bef5ca76e08cd4aa5e9ecf61ff04/src/background/index.ts#L268-L291 | 5177a7f0e061bef5ca76e08cd4aa5e9ecf61ff04 |
my-fingerprint | github_2023 | omegaee | typescript | getBadgeContent | const getBadgeContent = (records: Partial<Record<HookFingerprintKey, number>>): [string, string] => {
let baseNum = 0
let specialNum = 0
for (const [key, num] of Object.entries(records)) {
if (SPECIAL_KEYS.includes(key as any)) {
specialNum += num
} else {
baseNum += num
}
}
const show... | /**
* 获取Badge内容
* @returns [文本, 颜色]
*/ | https://github.com/omegaee/my-fingerprint/blob/5177a7f0e061bef5ca76e08cd4aa5e9ecf61ff04/src/background/index.ts#L297-L309 | 5177a7f0e061bef5ca76e08cd4aa5e9ecf61ff04 |
my-fingerprint | github_2023 | omegaee | typescript | setBadgeWhitelist | const setBadgeWhitelist = (tabId: number) => {
chrome.action.setBadgeText({ tabId, text: ' ' });
chrome.action.setBadgeBackgroundColor({ tabId, color: BADGE_COLOR.whitelist })
} | /**
* 设置白名单标识
*/ | https://github.com/omegaee/my-fingerprint/blob/5177a7f0e061bef5ca76e08cd4aa5e9ecf61ff04/src/background/index.ts#L314-L317 | 5177a7f0e061bef5ca76e08cd4aa5e9ecf61ff04 |
my-fingerprint | github_2023 | omegaee | typescript | remBadge | const remBadge = (tabId: number) => {
chrome.action.setBadgeText({ tabId, text: '' })
} | /**
* 移除标识
*/ | https://github.com/omegaee/my-fingerprint/blob/5177a7f0e061bef5ca76e08cd4aa5e9ecf61ff04/src/background/index.ts#L322-L324 | 5177a7f0e061bef5ca76e08cd4aa5e9ecf61ff04 |
my-fingerprint | github_2023 | omegaee | typescript | injectScript | const injectScript = (tabId: number, storage: LocalStorageObject) => {
chrome.scripting.executeScript({
target: {
tabId,
allFrames: true,
},
world: 'MAIN',
injectImmediately: true,
args: [tabId, { ...storage, whitelist: [...storage.whitelist] }],
func: coreInject,
}).catch(() => ... | /**
* 注入脚本
*/ | https://github.com/omegaee/my-fingerprint/blob/5177a7f0e061bef5ca76e08cd4aa5e9ecf61ff04/src/background/index.ts#L412-L423 | 5177a7f0e061bef5ca76e08cd4aa5e9ecf61ff04 |
my-fingerprint | github_2023 | omegaee | typescript | FingerprintHandler.isEnable | public isEnable() {
return !!this.conf.enable && !this.info.inWhitelist
} | /**
* 脚本是否启动
*/ | https://github.com/omegaee/my-fingerprint/blob/5177a7f0e061bef5ca76e08cd4aa5e9ecf61ff04/src/core/core.ts#L150-L152 | 5177a7f0e061bef5ca76e08cd4aa5e9ecf61ff04 |
my-fingerprint | github_2023 | omegaee | typescript | FingerprintHandler.hook | public hook() {
if (!this.isEnable()) return;
for (const task of hookTasks) {
if (!task.condition || task.condition(this) === true) {
task.onEnable?.(this)
}
}
} | /**
* hook内容
*/ | https://github.com/omegaee/my-fingerprint/blob/5177a7f0e061bef5ca76e08cd4aa5e9ecf61ff04/src/core/core.ts#L157-L164 | 5177a7f0e061bef5ca76e08cd4aa5e9ecf61ff04 |
my-fingerprint | github_2023 | omegaee | typescript | FingerprintHandler.hookIframe | public hookIframe = (iframe: HTMLIFrameElement) => {
new FingerprintHandler(iframe.contentWindow as any, this.info, this.conf)
} | /**
* hook iframe
*/ | https://github.com/omegaee/my-fingerprint/blob/5177a7f0e061bef5ca76e08cd4aa5e9ecf61ff04/src/core/core.ts#L169-L171 | 5177a7f0e061bef5ca76e08cd4aa5e9ecf61ff04 |
my-fingerprint | github_2023 | omegaee | typescript | FingerprintHandler.isAllDefault | public isAllDefault(ops?: Record<string, HookMode>) {
if (!ops) return true
for (const value of Object.values(ops)) {
if (value!.type !== HookType.default) return false
}
return true
} | /**
* 是否所有字段的type都是default
* ops为空则返回true
*/ | https://github.com/omegaee/my-fingerprint/blob/5177a7f0e061bef5ca76e08cd4aa5e9ecf61ff04/src/core/core.ts#L177-L183 | 5177a7f0e061bef5ca76e08cd4aa5e9ecf61ff04 |
my-fingerprint | github_2023 | omegaee | typescript | FingerprintHandler.getSeed | public getSeed = (type?: HookType): number | null => {
switch (type) {
case HookType.page:
return this.seed.page
case HookType.domain:
return this.seed.domain
case HookType.browser:
return this.seed.browser
case HookType.global:
return this.seed.global
c... | /**
* 获取value对应的的seed
*/ | https://github.com/omegaee/my-fingerprint/blob/5177a7f0e061bef5ca76e08cd4aa5e9ecf61ff04/src/core/core.ts#L188-L202 | 5177a7f0e061bef5ca76e08cd4aa5e9ecf61ff04 |
rill-flow | github_2023 | weibocom | typescript | getBaseConfig | function getBaseConfig(node) {
const {
type,
shape,
tooltip,
attrs,
x,
y,
size,
id,
position,
data,
actionType,
icon,
ports,
status,
nodePrototype,
label,
name,
} = node;
let _width,
_height,
_x = x,
_y = y,
_shape = shape,
_t... | /**
* 获取默认配置选项
* 兼容x6/g6
*/ | https://github.com/weibocom/rill-flow/blob/287042161999be39b1b92968f8fd60b3825b7fb1/flow-graph/src/common/transform.ts#L27-L104 | 287042161999be39b1b92968f8fd60b3825b7fb1 |
rill-flow | github_2023 | weibocom | typescript | Channel.dispatchEvent | static dispatchEvent(TypeEnum: CustomEventTypeEnum<string>, detail: any): void {
if (!TypeEnum) throw new Error('TypeEnum not found');
window.dispatchEvent(
new CustomEvent(TypeEnum, {
detail,
bubbles: false,
cancelable: true,
}),
);
} | /**
* 事件分发
* @param {CustomEventTypeEnum<string>} TypeEnum 事件分发类型
* @param {any} detail 详情
* @static
*/ | https://github.com/weibocom/rill-flow/blob/287042161999be39b1b92968f8fd60b3825b7fb1/flow-graph/src/common/transmit.ts#L13-L22 | 287042161999be39b1b92968f8fd60b3825b7fb1 |
rill-flow | github_2023 | weibocom | typescript | Channel.eventListener | static eventListener(TypeEnum: CustomEventTypeEnum<string>, callback: Function): void {
if (!TypeEnum) throw new Error('TypeEnum not found');
window.addEventListener(
TypeEnum,
function (event) {
callback(event.detail);
},
false,
);
} | /**
* 事件监听
* @param {CustomEventTypeEnum<string>} TypeEnum 事件分发类型
* @param {Function} callback 回调
* @static
*/ | https://github.com/weibocom/rill-flow/blob/287042161999be39b1b92968f8fd60b3825b7fb1/flow-graph/src/common/transmit.ts#L30-L39 | 287042161999be39b1b92968f8fd60b3825b7fb1 |
rill-flow | github_2023 | weibocom | typescript | getVariableName | const getVariableName = (title: string) => {
function strToHex(str: string) {
const result: string[] = [];
for (let i = 0; i < str.length; ++i) {
const hex = str.charCodeAt(i).toString(16);
result.push(('000' + hex).slice(-4));
}
return result.join('').toUpperCase();
}
return `__PRODU... | /**
* Get the configuration file variable name
* @param env
*/ | https://github.com/weibocom/rill-flow/blob/287042161999be39b1b92968f8fd60b3825b7fb1/rill-flow-ui/internal/vite-config/src/plugins/appConfig.ts#L76-L87 | 287042161999be39b1b92968f8fd60b3825b7fb1 |
rill-flow | github_2023 | weibocom | typescript | getConfFiles | function getConfFiles() {
const script = process.env.npm_lifecycle_script as string;
const reg = new RegExp('--mode ([a-z_\\d]+)');
const result = reg.exec(script);
if (result) {
const mode = result[1];
return ['.env', `.env.${mode}`];
}
return ['.env', '.env.production'];
} | /**
* 获取当前环境下生效的配置文件名
*/ | https://github.com/weibocom/rill-flow/blob/287042161999be39b1b92968f8fd60b3825b7fb1/rill-flow-ui/internal/vite-config/src/utils/env.ts#L9-L18 | 287042161999be39b1b92968f8fd60b3825b7fb1 |
rill-flow | github_2023 | weibocom | typescript | onMountedOrActivated | function onMountedOrActivated(hook: AnyFunction) {
let mounted: boolean;
onMounted(() => {
hook();
nextTick(() => {
mounted = true;
});
});
onActivated(() => {
if (mounted) {
hook();
}
});
} | /**
* 在 OnMounted 或者 OnActivated 时触发
* @param hook 任何函数(包括异步函数)
*/ | https://github.com/weibocom/rill-flow/blob/287042161999be39b1b92968f8fd60b3825b7fb1/rill-flow-ui/packages/hooks/src/onMountedOrActivated.ts#L8-L23 | 287042161999be39b1b92968f8fd60b3825b7fb1 |
rill-flow | github_2023 | weibocom | typescript | transform | function transform(c: string) {
const code: string[] = ['$', '(', ')', '*', '+', '.', '[', ']', '?', '\\', '^', '{', '}', '|'];
return code.includes(c) ? `\\${c}` : c;
} | // Translate special characters | https://github.com/weibocom/rill-flow/blob/287042161999be39b1b92968f8fd60b3825b7fb1/rill-flow-ui/src/components/Application/src/search/useMenuSearch.ts#L19-L22 | 287042161999be39b1b92968f8fd60b3825b7fb1 |
rill-flow | github_2023 | weibocom | typescript | handleMouseenter | function handleMouseenter(e: any) {
const index = e.target.dataset.index;
activeIndex.value = Number(index);
} | // Activate when the mouse moves to a certain line | https://github.com/weibocom/rill-flow/blob/287042161999be39b1b92968f8fd60b3825b7fb1/rill-flow-ui/src/components/Application/src/search/useMenuSearch.ts#L84-L87 | 287042161999be39b1b92968f8fd60b3825b7fb1 |
rill-flow | github_2023 | weibocom | typescript | handleUp | function handleUp() {
if (!searchResult.value.length) return;
activeIndex.value--;
if (activeIndex.value < 0) {
activeIndex.value = searchResult.value.length - 1;
}
handleScroll();
} | // Arrow key up | https://github.com/weibocom/rill-flow/blob/287042161999be39b1b92968f8fd60b3825b7fb1/rill-flow-ui/src/components/Application/src/search/useMenuSearch.ts#L90-L97 | 287042161999be39b1b92968f8fd60b3825b7fb1 |
rill-flow | github_2023 | weibocom | typescript | handleDown | function handleDown() {
if (!searchResult.value.length) return;
activeIndex.value++;
if (activeIndex.value > searchResult.value.length - 1) {
activeIndex.value = 0;
}
handleScroll();
} | // Arrow key down | https://github.com/weibocom/rill-flow/blob/287042161999be39b1b92968f8fd60b3825b7fb1/rill-flow-ui/src/components/Application/src/search/useMenuSearch.ts#L100-L107 | 287042161999be39b1b92968f8fd60b3825b7fb1 |
rill-flow | github_2023 | weibocom | typescript | handleScroll | function handleScroll() {
const refList = unref(refs);
if (!refList || !Array.isArray(refList) || refList.length === 0 || !unref(scrollWrap)) {
return;
}
const index = unref(activeIndex);
const currentRef = refList[index];
if (!currentRef) {
return;
}
const wrapEl = unref(sc... | // When the keyboard up and down keys move to an invisible place | https://github.com/weibocom/rill-flow/blob/287042161999be39b1b92968f8fd60b3825b7fb1/rill-flow-ui/src/components/Application/src/search/useMenuSearch.ts#L111-L134 | 287042161999be39b1b92968f8fd60b3825b7fb1 |
rill-flow | github_2023 | weibocom | typescript | handleEnter | async function handleEnter() {
if (!searchResult.value.length) {
return;
}
const result = unref(searchResult);
const index = unref(activeIndex);
if (result.length === 0 || index < 0) {
return;
}
const to = result[index];
handleClose();
await nextTick();
go(to.path);
... | // enter keyboard event | https://github.com/weibocom/rill-flow/blob/287042161999be39b1b92968f8fd60b3825b7fb1/rill-flow-ui/src/components/Application/src/search/useMenuSearch.ts#L137-L150 | 287042161999be39b1b92968f8fd60b3825b7fb1 |
rill-flow | github_2023 | weibocom | typescript | handleClose | function handleClose() {
searchResult.value = [];
emit('close');
} | // close search modal | https://github.com/weibocom/rill-flow/blob/287042161999be39b1b92968f8fd60b3825b7fb1/rill-flow-ui/src/components/Application/src/search/useMenuSearch.ts#L153-L156 | 287042161999be39b1b92968f8fd60b3825b7fb1 |
rill-flow | github_2023 | weibocom | typescript | getMarks | const getMarks = () => {
const l = {};
for (let i = min; i < max + 1; i++) {
l[i] = {
style: {
color: '#fff',
},
label: i,
};
}
return l;
}; | // 每行显示个数滑动条 | https://github.com/weibocom/rill-flow/blob/287042161999be39b1b92968f8fd60b3825b7fb1/rill-flow-ui/src/components/CardList/src/data.ts#L7-L18 | 287042161999be39b1b92968f8fd60b3825b7fb1 |
rill-flow | github_2023 | weibocom | typescript | setFieldsValue | async function setFieldsValue(values: Recordable): Promise<void> {
const fields = unref(getSchema)
.map((item) => item.field)
.filter(Boolean);
// key 支持 a.b.c 的嵌套写法
const delimiter = '.';
const nestKeyArray = fields.filter((item) => String(item).indexOf(delimiter) >= 0);
const validKe... | /**
* @description: Set form value
*/ | https://github.com/weibocom/rill-flow/blob/287042161999be39b1b92968f8fd60b3825b7fb1/rill-flow-ui/src/components/Form/src/hooks/useFormEvents.ts#L103-L170 | 287042161999be39b1b92968f8fd60b3825b7fb1 |
rill-flow | github_2023 | weibocom | typescript | removeSchemaByField | async function removeSchemaByField(fields: string | string[]): Promise<void> {
const schemaList: FormSchema[] = cloneDeep(unref(getSchema));
if (!fields) {
return;
}
let fieldList: string[] = isString(fields) ? [fields] : fields;
if (isString(fields)) {
fieldList = [fields];
}
f... | /**
* @description: Delete based on field name
*/ | https://github.com/weibocom/rill-flow/blob/287042161999be39b1b92968f8fd60b3825b7fb1/rill-flow-ui/src/components/Form/src/hooks/useFormEvents.ts#L175-L189 | 287042161999be39b1b92968f8fd60b3825b7fb1 |
rill-flow | github_2023 | weibocom | typescript | _removeSchemaByFeild | function _removeSchemaByFeild(field: string, schemaList: FormSchema[]): void {
if (isString(field)) {
const index = schemaList.findIndex((schema) => schema.field === field);
if (index !== -1) {
delete formModel[field];
schemaList.splice(index, 1);
}
}
} | /**
* @description: Delete based on field name
*/ | https://github.com/weibocom/rill-flow/blob/287042161999be39b1b92968f8fd60b3825b7fb1/rill-flow-ui/src/components/Form/src/hooks/useFormEvents.ts#L194-L202 | 287042161999be39b1b92968f8fd60b3825b7fb1 |
rill-flow | github_2023 | weibocom | typescript | appendSchemaByField | async function appendSchemaByField(
schema: FormSchema | FormSchema[],
prefixField?: string,
first = false,
) {
const schemaList: FormSchema[] = cloneDeep(unref(getSchema));
const addSchemaIds: string[] = Array.isArray(schema)
? schema.map((item) => item.field)
: [schema.field];
if... | /**
* @description: Insert after a certain field, if not insert the last
*/ | https://github.com/weibocom/rill-flow/blob/287042161999be39b1b92968f8fd60b3825b7fb1/rill-flow-ui/src/components/Form/src/hooks/useFormEvents.ts#L207-L234 | 287042161999be39b1b92968f8fd60b3825b7fb1 |
rill-flow | github_2023 | weibocom | typescript | itemIsDateType | function itemIsDateType(key: string) {
return unref(getSchema).some((item) => {
return item.field === key ? dateItemType.includes(item.component) : false;
});
} | /**
* @description: Is it time
*/ | https://github.com/weibocom/rill-flow/blob/287042161999be39b1b92968f8fd60b3825b7fb1/rill-flow-ui/src/components/Form/src/hooks/useFormEvents.ts#L333-L337 | 287042161999be39b1b92968f8fd60b3825b7fb1 |
rill-flow | github_2023 | weibocom | typescript | handleSubmit | async function handleSubmit(e?: Event): Promise<void> {
e && e.preventDefault();
const { submitFunc } = unref(getProps);
if (submitFunc && isFunction(submitFunc)) {
await submitFunc();
return;
}
const formEl = unref(formElRef);
if (!formEl) return;
try {
const values = awai... | /**
* @description: Form submission
*/ | https://github.com/weibocom/rill-flow/blob/287042161999be39b1b92968f8fd60b3825b7fb1/rill-flow-ui/src/components/Form/src/hooks/useFormEvents.ts#L358-L377 | 287042161999be39b1b92968f8fd60b3825b7fb1 |
rill-flow | github_2023 | weibocom | typescript | tryDeconstructArray | function tryDeconstructArray(key: string, value: any, target: Recordable) {
const pattern = /^\[(.+)\]$/;
if (pattern.test(key)) {
const match = key.match(pattern);
if (match && match[1]) {
const keys = match[1].split(',');
value = Array.isArray(value) ? value : [value];
keys.forEach((k, i... | /**
* @desription deconstruct array-link key. This method will mutate the target.
*/ | https://github.com/weibocom/rill-flow/blob/287042161999be39b1b92968f8fd60b3825b7fb1/rill-flow-ui/src/components/Form/src/hooks/useFormValues.ts#L18-L31 | 287042161999be39b1b92968f8fd60b3825b7fb1 |
rill-flow | github_2023 | weibocom | typescript | tryDeconstructObject | function tryDeconstructObject(key: string, value: any, target: Recordable) {
const pattern = /^\{(.+)\}$/;
if (pattern.test(key)) {
const match = key.match(pattern);
if (match && match[1]) {
const keys = match[1].split(',');
value = isObject(value) ? value : {};
keys.forEach((k) => {
... | /**
* @desription deconstruct object-link key. This method will mutate the target.
*/ | https://github.com/weibocom/rill-flow/blob/287042161999be39b1b92968f8fd60b3825b7fb1/rill-flow-ui/src/components/Form/src/hooks/useFormValues.ts#L36-L49 | 287042161999be39b1b92968f8fd60b3825b7fb1 |
rill-flow | github_2023 | weibocom | typescript | handleFormValues | function handleFormValues(values: Recordable) {
if (!isObject(values)) {
return {};
}
const res: Recordable = {};
for (const item of Object.entries(values)) {
let [, value] = item;
const [key] = item;
if (!key || (isArray(value) && value.length === 0) || isFunction(value)) {
... | // Processing form values | https://github.com/weibocom/rill-flow/blob/287042161999be39b1b92968f8fd60b3825b7fb1/rill-flow-ui/src/components/Form/src/hooks/useFormValues.ts#L58-L92 | 287042161999be39b1b92968f8fd60b3825b7fb1 |
rill-flow | github_2023 | weibocom | typescript | handleRangeTimeValue | function handleRangeTimeValue(values: Recordable) {
const fieldMapToTime = unref(getProps).fieldMapToTime;
if (!fieldMapToTime || !Array.isArray(fieldMapToTime)) {
return values;
}
for (const [field, [startTimeKey, endTimeKey], format = 'YYYY-MM-DD'] of fieldMapToTime) {
if (!field || !sta... | /**
* @description: Processing time interval parameters
*/ | https://github.com/weibocom/rill-flow/blob/287042161999be39b1b92968f8fd60b3825b7fb1/rill-flow-ui/src/components/Form/src/hooks/useFormValues.ts#L97-L124 | 287042161999be39b1b92968f8fd60b3825b7fb1 |
rill-flow | github_2023 | weibocom | typescript | resetKeys | function resetKeys() {
menuState.selectedKeys = [];
menuState.openKeys = [];
} | /**
* @description: 重置值
*/ | https://github.com/weibocom/rill-flow/blob/287042161999be39b1b92968f8fd60b3825b7fb1/rill-flow-ui/src/components/Menu/src/useOpenKeys.ts#L51-L54 | 287042161999be39b1b92968f8fd60b3825b7fb1 |
rill-flow | github_2023 | weibocom | typescript | getOriginWidth | function getOriginWidth(content: ContentType, options: QRCodeRenderersOptions) {
const _canvas = document.createElement('canvas');
return toCanvas(_canvas, content, options).then(() => _canvas.width);
} | // 得到原QrCode的大小,以便缩放得到正确的QrCode大小 | https://github.com/weibocom/rill-flow/blob/287042161999be39b1b92968f8fd60b3825b7fb1/rill-flow-ui/src/components/Qrcode/src/drawCanvas.ts#L23-L26 | 287042161999be39b1b92968f8fd60b3825b7fb1 |
rill-flow | github_2023 | weibocom | typescript | getErrorCorrectionLevel | function getErrorCorrectionLevel(content: ContentType) {
if (content.length > 36) {
return 'M';
} else if (content.length > 16) {
return 'Q';
} else {
return 'H';
}
} | // 对于内容少的QrCode,增大容错率 | https://github.com/weibocom/rill-flow/blob/287042161999be39b1b92968f8fd60b3825b7fb1/rill-flow-ui/src/components/Qrcode/src/drawCanvas.ts#L29-L37 | 287042161999be39b1b92968f8fd60b3825b7fb1 |
rill-flow | github_2023 | weibocom | typescript | drawLogoWithImage | const drawLogoWithImage = (image: CanvasImageSource) => {
ctx.drawImage(image, logoXY, logoXY, logoWidth, logoWidth);
}; | // 使用image绘制可以避免某些跨域情况 | https://github.com/weibocom/rill-flow/blob/287042161999be39b1b92968f8fd60b3825b7fb1/rill-flow-ui/src/components/Qrcode/src/drawLogo.ts#L42-L44 | 287042161999be39b1b92968f8fd60b3825b7fb1 |
rill-flow | github_2023 | weibocom | typescript | drawLogoWithCanvas | const drawLogoWithCanvas = (image: HTMLImageElement) => {
const canvasImage = document.createElement('canvas');
canvasImage.width = logoXY + logoWidth;
canvasImage.height = logoXY + logoWidth;
const imageCanvas = canvasImage.getContext('2d');
if (!imageCanvas || !ctx) return;
imageCanvas.drawIma... | // 使用canvas绘制以获得更多的功能 | https://github.com/weibocom/rill-flow/blob/287042161999be39b1b92968f8fd60b3825b7fb1/rill-flow-ui/src/components/Qrcode/src/drawLogo.ts#L47-L62 | 287042161999be39b1b92968f8fd60b3825b7fb1 |
rill-flow | github_2023 | weibocom | typescript | canvasRoundRect | function canvasRoundRect(ctx: CanvasRenderingContext2D) {
return (x: number, y: number, w: number, h: number, r: number) => {
const minSize = Math.min(w, h);
if (r > minSize / 2) {
r = minSize / 2;
}
ctx.beginPath();
ctx.moveTo(x + r, y);
ctx.arcTo(x + w, y, x + w, y + h, r);
ctx.arc... | // copy来的方法,用于绘制圆角 | https://github.com/weibocom/rill-flow/blob/287042161999be39b1b92968f8fd60b3825b7fb1/rill-flow-ui/src/components/Qrcode/src/drawLogo.ts#L74-L89 | 287042161999be39b1b92968f8fd60b3825b7fb1 |
rill-flow | github_2023 | weibocom | typescript | setColumns | function setColumns(columnList: Partial<BasicColumn>[] | (string | string[])[]) {
const columns = cloneDeep(columnList);
if (!isArray(columns)) return;
if (columns.length <= 0) {
columnsRef.value = [];
return;
}
const firstColumn = columns[0];
const cacheKeys = cacheColumns.map((i... | /**
* set columns
* @param columnList key|column
*/ | https://github.com/weibocom/rill-flow/blob/287042161999be39b1b92968f8fd60b3825b7fb1/rill-flow-ui/src/components/Table/src/hooks/useColumns.ts#L207-L242 | 287042161999be39b1b92968f8fd60b3825b7fb1 |
rill-flow | github_2023 | weibocom | typescript | getEnabledKeys | function getEnabledKeys(list?: TreeDataItem[]) {
const keys: string[] = [];
const treeData = list || unref(treeDataRef);
const { key: keyField, children: childrenField } = unref(getFieldNames);
if (!childrenField || !keyField) return keys;
for (let index = 0; index < treeData.length; index++) {
... | // get keys that can be checked and selected | https://github.com/weibocom/rill-flow/blob/287042161999be39b1b92968f8fd60b3825b7fb1/rill-flow-ui/src/components/Tree/src/hooks/useTree.ts#L28-L43 | 287042161999be39b1b92968f8fd60b3825b7fb1 |
rill-flow | github_2023 | weibocom | typescript | updateNodeByKey | function updateNodeByKey(key: string, node: TreeDataItem, list?: TreeDataItem[]) {
if (!key) return;
const treeData = list || unref(treeDataRef);
const { key: keyField, children: childrenField } = unref(getFieldNames);
if (!childrenField || !keyField) return;
for (let index = 0; index < treeData.l... | // Update node | https://github.com/weibocom/rill-flow/blob/287042161999be39b1b92968f8fd60b3825b7fb1/rill-flow-ui/src/components/Tree/src/hooks/useTree.ts#L68-L86 | 287042161999be39b1b92968f8fd60b3825b7fb1 |
rill-flow | github_2023 | weibocom | typescript | filterByLevel | function filterByLevel(level = 1, list?: TreeDataItem[], currentLevel = 1) {
if (!level) {
return [];
}
const res: (string | number)[] = [];
const data = list || unref(treeDataRef) || [];
for (let index = 0; index < data.length; index++) {
const item = data[index];
const { key: ke... | // Expand the specified level | https://github.com/weibocom/rill-flow/blob/287042161999be39b1b92968f8fd60b3825b7fb1/rill-flow-ui/src/components/Tree/src/hooks/useTree.ts#L89-L108 | 287042161999be39b1b92968f8fd60b3825b7fb1 |
rill-flow | github_2023 | weibocom | typescript | insertNodeByKey | function insertNodeByKey({ parentKey = null, node, push = 'push' }: InsertNodeParams) {
const treeData: any = cloneDeep(unref(treeDataRef));
if (!parentKey) {
treeData[push](node);
treeDataRef.value = treeData;
return;
}
const { key: keyField, children: childrenField } = unref(getField... | /**
* 添加节点
*/ | https://github.com/weibocom/rill-flow/blob/287042161999be39b1b92968f8fd60b3825b7fb1/rill-flow-ui/src/components/Tree/src/hooks/useTree.ts#L113-L131 | 287042161999be39b1b92968f8fd60b3825b7fb1 |
rill-flow | github_2023 | weibocom | typescript | insertNodesByKey | function insertNodesByKey({ parentKey = null, list, push = 'push' }: InsertNodeParams) {
const treeData: any = cloneDeep(unref(treeDataRef));
if (!list || list.length < 1) {
return;
}
if (!parentKey) {
for (let i = 0; i < list.length; i++) {
treeData[push](list[i]);
}
tre... | /**
* 批量添加节点
*/ | https://github.com/weibocom/rill-flow/blob/287042161999be39b1b92968f8fd60b3825b7fb1/rill-flow-ui/src/components/Tree/src/hooks/useTree.ts#L135-L161 | 287042161999be39b1b92968f8fd60b3825b7fb1 |
rill-flow | github_2023 | weibocom | typescript | deleteNodeByKey | function deleteNodeByKey(key: string, list?: TreeDataItem[]) {
if (!key) return;
const treeData = list || unref(treeDataRef);
const { key: keyField, children: childrenField } = unref(getFieldNames);
if (!childrenField || !keyField) return;
for (let index = 0; index < treeData.length; index++) {
... | // Delete node | https://github.com/weibocom/rill-flow/blob/287042161999be39b1b92968f8fd60b3825b7fb1/rill-flow-ui/src/components/Tree/src/hooks/useTree.ts#L163-L180 | 287042161999be39b1b92968f8fd60b3825b7fb1 |
rill-flow | github_2023 | weibocom | typescript | getSelectedNode | function getSelectedNode(key: KeyType, list?: TreeItem[], selectedNode?: TreeItem | null) {
if (!key && key !== 0) return null;
const treeData = list || unref(treeDataRef);
const { key: keyField, children: childrenField } = unref(getFieldNames);
if (!keyField) return;
treeData.forEach((item) => {
... | // Get selected node | https://github.com/weibocom/rill-flow/blob/287042161999be39b1b92968f8fd60b3825b7fb1/rill-flow-ui/src/components/Tree/src/hooks/useTree.ts#L183-L199 | 287042161999be39b1b92968f8fd60b3825b7fb1 |
rill-flow | github_2023 | weibocom | typescript | getModelKey | function getModelKey(renderOpts: VxeGlobalRendererHandles.RenderOptions) {
let prop = 'value';
switch (renderOpts.name) {
case 'ASwitch':
prop = 'checked';
break;
}
return prop;
} | /**
* @description: 获取组件传值所接受的属性
*/ | https://github.com/weibocom/rill-flow/blob/287042161999be39b1b92968f8fd60b3825b7fb1/rill-flow-ui/src/components/VxeTable/src/components/common.tsx#L43-L51 | 287042161999be39b1b92968f8fd60b3825b7fb1 |
rill-flow | github_2023 | weibocom | typescript | getModelEvent | function getModelEvent(renderOpts: VxeGlobalRendererHandles.RenderOptions) {
let type = 'update:value';
switch (renderOpts.name) {
case 'ASwitch':
type = 'update:checked';
break;
}
return type;
} | /**
* @description: 回去双向更新的方法
*/ | https://github.com/weibocom/rill-flow/blob/287042161999be39b1b92968f8fd60b3825b7fb1/rill-flow-ui/src/components/VxeTable/src/components/common.tsx#L56-L64 | 287042161999be39b1b92968f8fd60b3825b7fb1 |
rill-flow | github_2023 | weibocom | typescript | getChangeEvent | function getChangeEvent() {
return 'change';
} | /**
* @description: chang值改变方法
* @param {}
* @return {*}
* @author: *
*/ | https://github.com/weibocom/rill-flow/blob/287042161999be39b1b92968f8fd60b3825b7fb1/rill-flow-ui/src/components/VxeTable/src/components/common.tsx#L72-L74 | 287042161999be39b1b92968f8fd60b3825b7fb1 |
rill-flow | github_2023 | weibocom | typescript | getEventTargetNode | function getEventTargetNode(evnt: any, container: HTMLElement, className: string) {
let targetElem;
let target = evnt.target;
while (target && target.nodeType && target !== document) {
if (
className &&
target.className &&
target.className.split &&
target.className.split(' ').indexOf(c... | /**
* 检查触发源是否属于目标节点
*/ | https://github.com/weibocom/rill-flow/blob/287042161999be39b1b92968f8fd60b3825b7fb1/rill-flow-ui/src/components/VxeTable/src/components/index.tsx#L28-L45 | 287042161999be39b1b92968f8fd60b3825b7fb1 |
rill-flow | github_2023 | weibocom | typescript | handleClearEvent | function handleClearEvent(
params:
| VxeGlobalInterceptorHandles.InterceptorClearFilterParams
| VxeGlobalInterceptorHandles.InterceptorClearActivedParams
| VxeGlobalInterceptorHandles.InterceptorClearAreasParams,
) {
const { $event } = params;
const bodyElem = document.body;
if (
// 下拉框
getE... | /**
* 事件兼容性处理
*/ | https://github.com/weibocom/rill-flow/blob/287042161999be39b1b92968f8fd60b3825b7fb1/rill-flow-ui/src/components/VxeTable/src/components/index.tsx#L50-L70 | 287042161999be39b1b92968f8fd60b3825b7fb1 |
rill-flow | github_2023 | weibocom | typescript | remove | let remove: RemoveEventFn = () => {}; | /* eslint-disable-next-line */ | https://github.com/weibocom/rill-flow/blob/287042161999be39b1b92968f8fd60b3825b7fb1/rill-flow-ui/src/hooks/event/useEventListener.ts#L25-L25 | 287042161999be39b1b92968f8fd60b3825b7fb1 |
rill-flow | github_2023 | weibocom | typescript | setHeaderSetting | function setHeaderSetting(headerSetting: Partial<HeaderSetting>) {
appStore.setProjectConfig({ headerSetting });
} | // Set header configuration | https://github.com/weibocom/rill-flow/blob/287042161999be39b1b92968f8fd60b3825b7fb1/rill-flow-ui/src/hooks/setting/useHeaderSetting.ts#L82-L84 | 287042161999be39b1b92968f8fd60b3825b7fb1 |
rill-flow | github_2023 | weibocom | typescript | setMenuSetting | function setMenuSetting(menuSetting: Partial<MenuSetting>): void {
appStore.setMenuSetting(menuSetting);
} | // Set menu configuration | https://github.com/weibocom/rill-flow/blob/287042161999be39b1b92968f8fd60b3825b7fb1/rill-flow-ui/src/hooks/setting/useMenuSetting.ts#L125-L127 | 287042161999be39b1b92968f8fd60b3825b7fb1 |
rill-flow | github_2023 | weibocom | typescript | calcCompensationHeight | const calcCompensationHeight = () => {
compensationHeight.elements?.forEach((item) => {
height += getEl(unref(item))?.offsetHeight ?? 0;
});
}; | // compensation height | https://github.com/weibocom/rill-flow/blob/287042161999be39b1b92968f8fd60b3825b7fb1/rill-flow-ui/src/hooks/web/useContentHeight.ts#L152-L156 | 287042161999be39b1b92968f8fd60b3825b7fb1 |
rill-flow | github_2023 | weibocom | typescript | createConfirm | function createConfirm(options: ModalOptionsEx): ConfirmOptions {
const iconType = options.iconType || 'warning';
Reflect.deleteProperty(options, 'iconType');
const opt: ModalFuncProps = {
centered: true,
icon: getIcon(iconType),
...options,
content: renderContent(options),
};
return Modal.con... | /**
* @description: Create confirmation box
*/ | https://github.com/weibocom/rill-flow/blob/287042161999be39b1b92968f8fd60b3825b7fb1/rill-flow-ui/src/hooks/web/useMessage.tsx#L58-L68 | 287042161999be39b1b92968f8fd60b3825b7fb1 |
rill-flow | github_2023 | weibocom | typescript | togglePermissionMode | async function togglePermissionMode() {
appStore.setProjectConfig({
permissionMode:
appStore.projectConfig?.permissionMode === PermissionModeEnum.BACK
? PermissionModeEnum.ROUTE_MAPPING
: PermissionModeEnum.BACK,
});
location.reload();
} | /**
* Change permission mode
*/ | https://github.com/weibocom/rill-flow/blob/287042161999be39b1b92968f8fd60b3825b7fb1/rill-flow-ui/src/hooks/web/usePermission.ts#L30-L38 | 287042161999be39b1b92968f8fd60b3825b7fb1 |
rill-flow | github_2023 | weibocom | typescript | resume | async function resume() {
const tabStore = useMultipleTabStore();
tabStore.clearCacheTabs();
resetRouter();
const routes = await permissionStore.buildRoutesAction();
routes.forEach((route) => {
router.addRoute(route as unknown as RouteRecordRaw);
});
permissionStore.setLastBuildMenuTim... | /**
* Reset and regain authority resource information
* 重置和重新获得权限资源信息
* @param id
*/ | https://github.com/weibocom/rill-flow/blob/287042161999be39b1b92968f8fd60b3825b7fb1/rill-flow-ui/src/hooks/web/usePermission.ts#L45-L55 | 287042161999be39b1b92968f8fd60b3825b7fb1 |
rill-flow | github_2023 | weibocom | typescript | hasPermission | function hasPermission(value?: RoleEnum | RoleEnum[] | string | string[], def = true): boolean {
// Visible by default
if (!value) {
return def;
}
const permMode = projectSetting.permissionMode;
if ([PermissionModeEnum.ROUTE_MAPPING, PermissionModeEnum.ROLE].includes(permMode)) {
if (!... | /**
* Determine whether there is permission
*/ | https://github.com/weibocom/rill-flow/blob/287042161999be39b1b92968f8fd60b3825b7fb1/rill-flow-ui/src/hooks/web/usePermission.ts#L60-L83 | 287042161999be39b1b92968f8fd60b3825b7fb1 |
rill-flow | github_2023 | weibocom | typescript | changeRole | async function changeRole(roles: RoleEnum | RoleEnum[]): Promise<void> {
if (projectSetting.permissionMode !== PermissionModeEnum.ROUTE_MAPPING) {
throw new Error(
'Please switch PermissionModeEnum to ROUTE_MAPPING mode in the configuration to operate!',
);
}
if (!isArray(roles)) {
... | /**
* Change roles
* @param roles
*/ | https://github.com/weibocom/rill-flow/blob/287042161999be39b1b92968f8fd60b3825b7fb1/rill-flow-ui/src/hooks/web/usePermission.ts#L89-L101 | 287042161999be39b1b92968f8fd60b3825b7fb1 |
rill-flow | github_2023 | weibocom | typescript | refreshMenu | async function refreshMenu() {
resume();
} | /**
* refresh menu data
*/ | https://github.com/weibocom/rill-flow/blob/287042161999be39b1b92968f8fd60b3825b7fb1/rill-flow-ui/src/hooks/web/usePermission.ts#L106-L108 | 287042161999be39b1b92968f8fd60b3825b7fb1 |
rill-flow | github_2023 | weibocom | typescript | handleSplitLeftMenu | async function handleSplitLeftMenu(parentPath: string) {
if (unref(getSplitLeft) || unref(getIsMobile)) return;
// spilt mode left
const children = await getChildrenMenus(parentPath);
if (!children || !children.length) {
setMenuSetting({ hidden: true });
menusRef.value = [];
return;
... | // Handle left menu split | https://github.com/weibocom/rill-flow/blob/287042161999be39b1b92968f8fd60b3825b7fb1/rill-flow-ui/src/layouts/default/menu/useLayoutMenu.ts#L75-L89 | 287042161999be39b1b92968f8fd60b3825b7fb1 |
rill-flow | github_2023 | weibocom | typescript | genMenus | async function genMenus() {
// normal mode
if (unref(normalType) || unref(getIsMobile)) {
menusRef.value = await getMenus();
return;
}
// split-top
if (unref(getSpiltTop)) {
const shallowMenus = await getShallowMenus();
menusRef.value = shallowMenus;
return;
}
} | // get menus | https://github.com/weibocom/rill-flow/blob/287042161999be39b1b92968f8fd60b3825b7fb1/rill-flow-ui/src/layouts/default/menu/useLayoutMenu.ts#L92-L106 | 287042161999be39b1b92968f8fd60b3825b7fb1 |
rill-flow | github_2023 | weibocom | typescript | removeMouseup | function removeMouseup(ele: any) {
const wrap = getEl(siderRef);
document.onmouseup = function () {
document.onmousemove = null;
document.onmouseup = null;
wrap.style.transition = 'width 0.2s';
const width = parseInt(wrap.style.width);
if (!mix) {
const miniWidth = unref(g... | // Drag and drop in the menu area-release the mouse | https://github.com/weibocom/rill-flow/blob/287042161999be39b1b92968f8fd60b3825b7fb1/rill-flow-ui/src/layouts/default/sider/useLayoutSider.ts#L100-L123 | 287042161999be39b1b92968f8fd60b3825b7fb1 |
rill-flow | github_2023 | weibocom | typescript | filterAffixTabs | function filterAffixTabs(routes: RouteLocationNormalized[]) {
const tabs: RouteLocationNormalized[] = [];
routes &&
routes.forEach((route) => {
if (route.meta && route.meta.affix) {
tabs.push(toRaw(route));
}
});
return tabs;
} | /**
* @description: Filter all fixed routes
*/ | https://github.com/weibocom/rill-flow/blob/287042161999be39b1b92968f8fd60b3825b7fb1/rill-flow-ui/src/layouts/default/tabs/useMultipleTabs.ts#L18-L27 | 287042161999be39b1b92968f8fd60b3825b7fb1 |
rill-flow | github_2023 | weibocom | typescript | addAffixTabs | function addAffixTabs(): void {
const affixTabs = filterAffixTabs(router.getRoutes() as unknown as RouteLocationNormalized[]);
affixList.value = affixTabs;
for (const tab of affixTabs) {
tabStore.addTab({
meta: tab.meta,
name: tab.name,
path: tab.path,
} as unknown as Rou... | /**
* @description: Set fixed tabs
*/ | https://github.com/weibocom/rill-flow/blob/287042161999be39b1b92968f8fd60b3825b7fb1/rill-flow-ui/src/layouts/default/tabs/useMultipleTabs.ts#L32-L42 | 287042161999be39b1b92968f8fd60b3825b7fb1 |
rill-flow | github_2023 | weibocom | typescript | handleMenuEvent | function handleMenuEvent(menu: DropMenu): void {
const { event } = menu;
switch (event) {
case MenuEventEnum.REFRESH_PAGE:
// refresh page
refreshPage();
break;
// Close current
case MenuEventEnum.CLOSE_CURRENT:
close(tabContentProps.tabItem);
break;
... | // Handle right click event | https://github.com/weibocom/rill-flow/blob/287042161999be39b1b92968f8fd60b3825b7fb1/rill-flow-ui/src/layouts/default/tabs/useTabDropdown.ts#L110-L138 | 287042161999be39b1b92968f8fd60b3825b7fb1 |
rill-flow | github_2023 | weibocom | typescript | changeLocale | async function changeLocale(locale: LocaleType) {
const globalI18n = i18n.global;
const currentLocale = unref(globalI18n.locale);
if (currentLocale === locale) {
return locale;
}
if (loadLocalePool.includes(locale)) {
setI18nLanguage(locale);
return locale;
}
const langMod... | // Switching the language will change the locale of useI18n | https://github.com/weibocom/rill-flow/blob/287042161999be39b1b92968f8fd60b3825b7fb1/rill-flow-ui/src/locales/useLocale.ts#L40-L61 | 287042161999be39b1b92968f8fd60b3825b7fb1 |
rill-flow | github_2023 | weibocom | typescript | processStackMsg | function processStackMsg(error: Error) {
if (!error.stack) {
return '';
}
let stack = error.stack
.replace(/\n/gi, '') // Remove line breaks to save the size of the transmitted content
.replace(/\bat\b/gi, '@') // At in chrome, @ in ff
.split('@') // Split information with @
.slice(0, 9) // Th... | /**
* Handling error stack information
* @param error
*/ | https://github.com/weibocom/rill-flow/blob/287042161999be39b1b92968f8fd60b3825b7fb1/rill-flow-ui/src/logics/error-handle/index.ts#L17-L34 | 287042161999be39b1b92968f8fd60b3825b7fb1 |
rill-flow | github_2023 | weibocom | typescript | formatComponentName | function formatComponentName(vm: any) {
if (vm.$root === vm) {
return {
name: 'root',
path: 'root',
};
}
const options = vm.$options as any;
if (!options) {
return {
name: 'anonymous',
path: 'anonymous',
};
}
const name = options.name || options._componentTag;
retu... | /**
* get comp name
* @param vm
*/ | https://github.com/weibocom/rill-flow/blob/287042161999be39b1b92968f8fd60b3825b7fb1/rill-flow-ui/src/logics/error-handle/index.ts#L40-L60 | 287042161999be39b1b92968f8fd60b3825b7fb1 |
rill-flow | github_2023 | weibocom | typescript | vueErrorHandler | function vueErrorHandler(err: Error, vm: any, info: string) {
const errorLogStore = useErrorLogStoreWithOut();
const { name, path } = formatComponentName(vm);
errorLogStore.addErrorLogInfo({
type: ErrorTypeEnum.VUE,
name,
file: path,
message: err.message,
stack: processStackMsg(err),
detai... | /**
* Configure Vue error handling function
*/ | https://github.com/weibocom/rill-flow/blob/287042161999be39b1b92968f8fd60b3825b7fb1/rill-flow-ui/src/logics/error-handle/index.ts#L66-L78 | 287042161999be39b1b92968f8fd60b3825b7fb1 |
rill-flow | github_2023 | weibocom | typescript | registerPromiseErrorHandler | function registerPromiseErrorHandler() {
window.addEventListener(
'unhandledrejection',
function (event) {
const errorLogStore = useErrorLogStoreWithOut();
errorLogStore.addErrorLogInfo({
type: ErrorTypeEnum.PROMISE,
name: 'Promise Error!',
file: 'none',
detail: 'pr... | /**
* Configure Promise error handling function
*/ | https://github.com/weibocom/rill-flow/blob/287042161999be39b1b92968f8fd60b3825b7fb1/rill-flow-ui/src/logics/error-handle/index.ts#L117-L134 | 287042161999be39b1b92968f8fd60b3825b7fb1 |
rill-flow | github_2023 | weibocom | typescript | registerResourceErrorHandler | function registerResourceErrorHandler() {
// Monitoring resource loading error(img,script,css,and jsonp)
window.addEventListener(
'error',
function (e: Event) {
const target = e.target ? e.target : (e.srcElement as any);
const errorLogStore = useErrorLogStoreWithOut();
errorLogStore.addErr... | /**
* Configure monitoring resource loading error handling function
*/ | https://github.com/weibocom/rill-flow/blob/287042161999be39b1b92968f8fd60b3825b7fb1/rill-flow-ui/src/logics/error-handle/index.ts#L139-L162 | 287042161999be39b1b92968f8fd60b3825b7fb1 |
rill-flow | github_2023 | weibocom | typescript | createPageGuard | function createPageGuard(router: Router) {
const loadedPageMap = new Map<string, boolean>();
router.beforeEach(async (to) => {
// The page has already been loaded, it will be faster to open it again, you don’t need to do loading and other processing
to.meta.loaded = !!loadedPageMap.get(to.path);
// Not... | /**
* Hooks for handling page state
*/ | https://github.com/weibocom/rill-flow/blob/287042161999be39b1b92968f8fd60b3825b7fb1/rill-flow-ui/src/router/guard/index.ts#L32-L47 | 287042161999be39b1b92968f8fd60b3825b7fb1 |
rill-flow | github_2023 | weibocom | typescript | createPageLoadingGuard | function createPageLoadingGuard(router: Router) {
const userStore = useUserStoreWithOut();
const appStore = useAppStoreWithOut();
const { getOpenPageLoading } = useTransitionSetting();
router.beforeEach(async (to) => {
if (!userStore.getToken) {
return true;
}
if (to.meta.loaded) {
retur... | // Used to handle page loading status | https://github.com/weibocom/rill-flow/blob/287042161999be39b1b92968f8fd60b3825b7fb1/rill-flow-ui/src/router/guard/index.ts#L50-L79 | 287042161999be39b1b92968f8fd60b3825b7fb1 |
rill-flow | github_2023 | weibocom | typescript | createHttpGuard | function createHttpGuard(router: Router) {
const { removeAllHttpPending } = projectSetting;
let axiosCanceler: Nullable<AxiosCanceler>;
if (removeAllHttpPending) {
axiosCanceler = new AxiosCanceler();
}
router.beforeEach(async () => {
// Switching the route will delete the previous request
axiosCa... | /**
* The interface used to close the current page to complete the request when the route is switched
* @param router
*/ | https://github.com/weibocom/rill-flow/blob/287042161999be39b1b92968f8fd60b3825b7fb1/rill-flow-ui/src/router/guard/index.ts#L85-L96 | 287042161999be39b1b92968f8fd60b3825b7fb1 |
rill-flow | github_2023 | weibocom | typescript | createScrollGuard | function createScrollGuard(router: Router) {
const isHash = (href: string) => {
return /^#/.test(href);
};
const body = document.body;
router.afterEach(async (to) => {
// scroll top
isHash((to as RouteLocationNormalized & { href: string })?.href) && body.scrollTo(0, 0);
return true;
});
} | // Routing switch back to the top | https://github.com/weibocom/rill-flow/blob/287042161999be39b1b92968f8fd60b3825b7fb1/rill-flow-ui/src/router/guard/index.ts#L99-L111 | 287042161999be39b1b92968f8fd60b3825b7fb1 |
rill-flow | github_2023 | weibocom | typescript | joinParentPath | function joinParentPath(menus: Menu[], parentPath = '') {
for (let index = 0; index < menus.length; index++) {
const menu = menus[index];
// https://next.router.vuejs.org/guide/essentials/nested-routes.html
// Note that nested paths that start with / will be treated as a root path.
// 请注意,以 / 开头的嵌套路径将... | // 路径处理 | https://github.com/weibocom/rill-flow/blob/287042161999be39b1b92968f8fd60b3825b7fb1/rill-flow-ui/src/router/helper/menuHelper.ts#L15-L32 | 287042161999be39b1b92968f8fd60b3825b7fb1 |
rill-flow | github_2023 | weibocom | typescript | asyncImportRoute | function asyncImportRoute(routes: AppRouteRecordRaw[] | undefined) {
dynamicViewsModules = dynamicViewsModules || import.meta.glob('../../views/**/*.{vue,tsx}');
if (!routes) return;
routes.forEach((item) => {
if (!item.component && item.meta?.frameSrc) {
item.component = 'IFRAME';
}
const { com... | // Dynamic introduction | https://github.com/weibocom/rill-flow/blob/287042161999be39b1b92968f8fd60b3825b7fb1/rill-flow-ui/src/router/helper/routeHelper.ts#L19-L40 | 287042161999be39b1b92968f8fd60b3825b7fb1 |
rill-flow | github_2023 | weibocom | typescript | promoteRouteLevel | function promoteRouteLevel(routeModule: AppRouteModule) {
// Use vue-router to splice menus
// 使用vue-router拼接菜单
// createRouter 创建一个可以被 Vue 应用程序使用的路由实例
let router: Router | null = createRouter({
routes: [routeModule as unknown as RouteRecordNormalized],
history: createWebHistory(),
});
// getRoutes:... | // Routing level upgrade | https://github.com/weibocom/rill-flow/blob/287042161999be39b1b92968f8fd60b3825b7fb1/rill-flow-ui/src/router/helper/routeHelper.ts#L117-L133 | 287042161999be39b1b92968f8fd60b3825b7fb1 |
rill-flow | github_2023 | weibocom | typescript | addToChildren | function addToChildren(
routes: RouteRecordNormalized[],
children: AppRouteRecordRaw[],
routeModule: AppRouteModule,
) {
for (let index = 0; index < children.length; index++) {
const child = children[index];
const route = routes.find((item) => item.name === child.name);
if (!route) {
continue;... | // Add all sub-routes to the secondary route | https://github.com/weibocom/rill-flow/blob/287042161999be39b1b92968f8fd60b3825b7fb1/rill-flow-ui/src/router/helper/routeHelper.ts#L137-L156 | 287042161999be39b1b92968f8fd60b3825b7fb1 |
rill-flow | github_2023 | weibocom | typescript | isMultipleRoute | function isMultipleRoute(routeModule: AppRouteModule) {
// Reflect.has 与 in 操作符 相同, 用于检查一个对象(包括它原型链上)是否拥有某个属性
if (!routeModule || !Reflect.has(routeModule, 'children') || !routeModule.children?.length) {
return false;
}
const children = routeModule.children;
let flag = false;
for (let index = 0; index... | // Determine whether the level exceeds 2 levels | https://github.com/weibocom/rill-flow/blob/287042161999be39b1b92968f8fd60b3825b7fb1/rill-flow-ui/src/router/helper/routeHelper.ts#L160-L177 | 287042161999be39b1b92968f8fd60b3825b7fb1 |
rill-flow | github_2023 | weibocom | typescript | getPermissionMode | const getPermissionMode = () => {
const appStore = useAppStoreWithOut();
return appStore.getProjectConfig.permissionMode;
}; | // =========================== | https://github.com/weibocom/rill-flow/blob/287042161999be39b1b92968f8fd60b3825b7fb1/rill-flow-ui/src/router/menus/index.ts#L27-L30 | 287042161999be39b1b92968f8fd60b3825b7fb1 |
rill-flow | github_2023 | weibocom | typescript | menuFilter | const menuFilter = (items) => {
return items.filter((item) => {
const show = !item.meta?.hideMenu && !item.hideMenu;
if (show && item.children) {
item.children = menuFilter(item.children);
}
return show;
});
}; | //递归过滤所有隐藏的菜单 | https://github.com/weibocom/rill-flow/blob/287042161999be39b1b92968f8fd60b3825b7fb1/rill-flow-ui/src/router/menus/index.ts#L57-L65 | 287042161999be39b1b92968f8fd60b3825b7fb1 |
rill-flow | github_2023 | weibocom | typescript | routeFilter | const routeFilter = (route: AppRouteRecordRaw) => {
const { meta } = route;
// 抽出角色
const { roles } = meta || {};
if (!roles) return true;
// 进行角色权限判断
return roleList.some((role) => roles.includes(role));
}; | // 路由过滤器 在 函数filter 作为回调传入遍历使用 | https://github.com/weibocom/rill-flow/blob/287042161999be39b1b92968f8fd60b3825b7fb1/rill-flow-ui/src/store/modules/permission.ts#L122-L129 | 287042161999be39b1b92968f8fd60b3825b7fb1 |
rill-flow | github_2023 | weibocom | typescript | patchHomeAffix | const patchHomeAffix = (routes: AppRouteRecordRaw[]) => {
if (!routes || routes.length === 0) return;
let homePath: string = userStore.getUserInfo.homePath || PageEnum.BASE_HOME;
function patcher(routes: AppRouteRecordRaw[], parentPath = '') {
if (parentPath) parentPath = parentPath +... | /**
* @description 根据设置的首页path,修正routes中的affix标记(固定首页)
* */ | https://github.com/weibocom/rill-flow/blob/287042161999be39b1b92968f8fd60b3825b7fb1/rill-flow-ui/src/store/modules/permission.ts#L142-L169 | 287042161999be39b1b92968f8fd60b3825b7fb1 |
rill-flow | github_2023 | weibocom | typescript | addLight | function addLight(color: string, amount: number) {
const cc = parseInt(color, 16) + amount;
const c = cc > 255 ? 255 : cc;
return c.toString(16).length > 1 ? c.toString(16) : `0${c.toString(16)}`;
} | /* Suma el porcentaje indicado a un color (RR, GG o BB) hexadecimal para aclararlo */ | https://github.com/weibocom/rill-flow/blob/287042161999be39b1b92968f8fd60b3825b7fb1/rill-flow-ui/src/utils/color.ts#L98-L102 | 287042161999be39b1b92968f8fd60b3825b7fb1 |
rill-flow | github_2023 | weibocom | typescript | luminanace | function luminanace(r: number, g: number, b: number) {
const a = [r, g, b].map((v) => {
v /= 255;
return v <= 0.03928 ? v / 12.92 : Math.pow((v + 0.055) / 1.055, 2.4);
});
return a[0] * 0.2126 + a[1] * 0.7152 + a[2] * 0.0722;
} | /**
* Calculates luminance of an rgb color
* @param {number} r red
* @param {number} g green
* @param {number} b blue
*/ | https://github.com/weibocom/rill-flow/blob/287042161999be39b1b92968f8fd60b3825b7fb1/rill-flow-ui/src/utils/color.ts#L110-L116 | 287042161999be39b1b92968f8fd60b3825b7fb1 |
rill-flow | github_2023 | weibocom | typescript | contrast | function contrast(rgb1: string[], rgb2: number[]) {
return (
(luminanace(~~rgb1[0], ~~rgb1[1], ~~rgb1[2]) + 0.05) /
(luminanace(rgb2[0], rgb2[1], rgb2[2]) + 0.05)
);
} | /**
* Calculates contrast between two rgb colors
* @param {string} rgb1 rgb color 1
* @param {string} rgb2 rgb color 2
*/ | https://github.com/weibocom/rill-flow/blob/287042161999be39b1b92968f8fd60b3825b7fb1/rill-flow-ui/src/utils/color.ts#L123-L128 | 287042161999be39b1b92968f8fd60b3825b7fb1 |
rill-flow | github_2023 | weibocom | typescript | subtractLight | function subtractLight(color: string, amount: number) {
const cc = parseInt(color, 16) - amount;
const c = cc < 0 ? 0 : cc;
return c.toString(16).length > 1 ? c.toString(16) : `0${c.toString(16)}`;
} | /**
* Subtracts the indicated percentage to the R, G or B of a HEX color
* @param {string} color The color to change
* @param {number} amount The amount to change the color by
* @returns {string} The processed part of the color
*/ | https://github.com/weibocom/rill-flow/blob/287042161999be39b1b92968f8fd60b3825b7fb1/rill-flow-ui/src/utils/color.ts#L147-L151 | 287042161999be39b1b92968f8fd60b3825b7fb1 |
rill-flow | github_2023 | weibocom | typescript | propTypes.style | static get style() {
return toValidableType('style', {
type: [String, Object],
});
} | // a native-like validator that supports the `.validable` method | https://github.com/weibocom/rill-flow/blob/287042161999be39b1b92968f8fd60b3825b7fb1/rill-flow-ui/src/utils/propTypes.ts#L23-L27 | 287042161999be39b1b92968f8fd60b3825b7fb1 |
rill-flow | github_2023 | weibocom | typescript | Memory.get | get<K extends keyof T>(key: K) {
return this.cache[key];
} | // } | https://github.com/weibocom/rill-flow/blob/287042161999be39b1b92968f8fd60b3825b7fb1/rill-flow-ui/src/utils/cache/memory.ts#L36-L38 | 287042161999be39b1b92968f8fd60b3825b7fb1 |
rill-flow | github_2023 | weibocom | typescript | resizeHandler | function resizeHandler(entries: any[]) {
for (const entry of entries) {
const listeners = entry.target.__resizeListeners__ || [];
if (listeners.length) {
listeners.forEach((fn: () => any) => {
fn();
});
}
}
} | /* istanbul ignore next */ | https://github.com/weibocom/rill-flow/blob/287042161999be39b1b92968f8fd60b3825b7fb1/rill-flow-ui/src/utils/event/index.ts#L6-L15 | 287042161999be39b1b92968f8fd60b3825b7fb1 |
rill-flow | github_2023 | weibocom | typescript | getConfig | const getConfig = (config: Partial<TreeHelperConfig>) => Object.assign({}, DEFAULT_CONFIG, config); | // 获取配置。 Object.assign 从一个或多个源对象复制到目标对象 | https://github.com/weibocom/rill-flow/blob/287042161999be39b1b92968f8fd60b3825b7fb1/rill-flow-ui/src/utils/helper/treeHelper.ts#L15-L15 | 287042161999be39b1b92968f8fd60b3825b7fb1 |
rill-flow | github_2023 | weibocom | typescript | VAxios.createAxios | private createAxios(config: CreateAxiosOptions): void {
this.axiosInstance = axios.create(config);
} | /**
* @description: Create axios instance
*/ | https://github.com/weibocom/rill-flow/blob/287042161999be39b1b92968f8fd60b3825b7fb1/rill-flow-ui/src/utils/http/axios/Axios.ts#L36-L38 | 287042161999be39b1b92968f8fd60b3825b7fb1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.