优化env文件
This commit is contained in:
@@ -1,2 +1,4 @@
|
|||||||
NOCODB_TOKEN=
|
NOCODB_TOKEN=
|
||||||
NOCODB_LIST_URL=https://nocodb.example.com/api/v2/tables/xxx/records
|
NOCODB_LIST_URL=https://nocodb.example.com/api/v2/tables/xxx/records
|
||||||
|
NOCODB_FIELD_ID=账号ID
|
||||||
|
NOCODB_FIELD_ALIAS=_最终输出
|
||||||
@@ -1,3 +1,5 @@
|
|||||||
# Teams 别名插件
|
# Teams 别名插件
|
||||||
|
|
||||||
给 Microsoft Teams 好友的名称添加别名。
|
给 Microsoft Teams 好友的名称添加别名。
|
||||||
|
|
||||||
|
使用 NocoDB 数据库获取数据。修改 .env 之后别忘了修改 manifest.json 中的 host_permissions
|
||||||
|
|||||||
10
utils.js
10
utils.js
@@ -1,7 +1,9 @@
|
|||||||
const NOCODB_CONFIG = {
|
const NOCODB_CONFIG = {
|
||||||
// Token and URL are loaded from env.js (ENV_SECRETS global variable)
|
// Token and URL are loaded from env.js (ENV_SECRETS global variable)
|
||||||
TOKEN: (typeof ENV_SECRETS !== 'undefined' && ENV_SECRETS.NOCODB_TOKEN) ? ENV_SECRETS.NOCODB_TOKEN : "",
|
TOKEN: (typeof ENV_SECRETS !== 'undefined' && ENV_SECRETS.NOCODB_TOKEN) ? ENV_SECRETS.NOCODB_TOKEN : "",
|
||||||
LIST_URL: (typeof ENV_SECRETS !== 'undefined' && ENV_SECRETS.NOCODB_LIST_URL) ? ENV_SECRETS.NOCODB_LIST_URL : ""
|
LIST_URL: (typeof ENV_SECRETS !== 'undefined' && ENV_SECRETS.NOCODB_LIST_URL) ? ENV_SECRETS.NOCODB_LIST_URL : "",
|
||||||
|
FIELD_ID: (typeof ENV_SECRETS !== 'undefined' && ENV_SECRETS.NOCODB_FIELD_ID) ? ENV_SECRETS.NOCODB_FIELD_ID : "账号ID",
|
||||||
|
FIELD_ALIAS: (typeof ENV_SECRETS !== 'undefined' && ENV_SECRETS.NOCODB_FIELD_ALIAS) ? ENV_SECRETS.NOCODB_FIELD_ALIAS : "_最终输出"
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -29,7 +31,7 @@ async function fetchAliasesFromDB() {
|
|||||||
// 构建带参数的 URL
|
// 构建带参数的 URL
|
||||||
const url = new URL(listUrl);
|
const url = new URL(listUrl);
|
||||||
url.searchParams.append("limit", limit);
|
url.searchParams.append("limit", limit);
|
||||||
url.searchParams.append("fields", "账号ID,_最终输出");
|
url.searchParams.append("fields", `${NOCODB_CONFIG.FIELD_ID},${NOCODB_CONFIG.FIELD_ALIAS}`);
|
||||||
url.searchParams.append("offset", offset);
|
url.searchParams.append("offset", offset);
|
||||||
|
|
||||||
const response = await fetch(url.toString(), { headers });
|
const response = await fetch(url.toString(), { headers });
|
||||||
@@ -48,9 +50,9 @@ async function fetchAliasesFromDB() {
|
|||||||
|
|
||||||
// 整理数据
|
// 整理数据
|
||||||
rows.forEach(row => {
|
rows.forEach(row => {
|
||||||
if (row["账号ID"] && row["_最终输出"]) {
|
if (row[NOCODB_CONFIG.FIELD_ID] && row[NOCODB_CONFIG.FIELD_ALIAS]) {
|
||||||
// key = 账号ID, value = _最终输出
|
// key = 账号ID, value = _最终输出
|
||||||
allAliases[row["账号ID"]] = row["_最终输出"];
|
allAliases[row[NOCODB_CONFIG.FIELD_ID]] = row[NOCODB_CONFIG.FIELD_ALIAS];
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user