support multiple tenants

master
Aaron Yu 2022-07-10 14:55:23 +08:00
parent 44a67f8200
commit b18e96d1b0
6 changed files with 15805 additions and 14 deletions

15806
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -14,6 +14,7 @@
"axios": "^0.24.0",
"localstorage-slim": "^2.2.0",
"qrcode": "^1.5.0",
"query-string": "^7.1.1",
"react": "^17.0.2",
"react-copy-to-clipboard": "^5.0.4",
"react-dom": "^17.0.2",

View File

@ -80,7 +80,7 @@ class App extends React.Component {
loading: true
})
var projectNames = await this.fetchProjects();
var projectNames = await this.fetchProjects() || ['无项目'];
this.setState({
projects: projectNames,
selectedProjectName: projectNames[0],

View File

@ -9,6 +9,7 @@ var rowTitles = ['开头', '中间', '结尾']
function SettingFrame(props) {
var [settingArr, setSettingArr] = useState([1, 2, 3])
var [openPopup, setOpenPopup] = useState(false);
console.log(props.settingValue)
useEffect(() => {
setSettingArr(props.settingValue)
}, [props.settingValue])

View File

@ -29,8 +29,8 @@ export async function getProjects() {
} else {
return client.list({ prefix: prefix, delimiter: '/' })
.then(result =>
result.prefixes.map(item => item.slice(prefix.length, item.length - 1))
)
result.prefixes?.map(item => item.slice(prefix.length, item.length - 1)))
.catch(() => []);
}
}

View File

@ -1,5 +1,6 @@
import packageJson from '../package.json'
import queryString from 'query-string'
export function getTenant() {
return packageJson.homepage === "/preview" ? "funplus" : packageJson.homepage.slice(1)
const tenant = queryString.parseUrl(window.location.href)?.query?.tenant
return tenant || "funplus"
}