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", "axios": "^0.24.0",
"localstorage-slim": "^2.2.0", "localstorage-slim": "^2.2.0",
"qrcode": "^1.5.0", "qrcode": "^1.5.0",
"query-string": "^7.1.1",
"react": "^17.0.2", "react": "^17.0.2",
"react-copy-to-clipboard": "^5.0.4", "react-copy-to-clipboard": "^5.0.4",
"react-dom": "^17.0.2", "react-dom": "^17.0.2",

View File

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

View File

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

View File

@ -29,8 +29,8 @@ export async function getProjects() {
} else { } else {
return client.list({ prefix: prefix, delimiter: '/' }) return client.list({ prefix: prefix, delimiter: '/' })
.then(result => .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() { export function getTenant() {
return packageJson.homepage === "/preview" ? "funplus" : packageJson.homepage.slice(1) const tenant = queryString.parseUrl(window.location.href)?.query?.tenant
return tenant || "funplus"
} }